The present application is related to a previously filed United States patent application, entitled “Method and System for Transferring Data Between a Discrete Event Environment and an External Environment”, application Ser. No. 11/024,148, filed Dec. 21, 2004, the contents of which are hereby incorporated by reference in their entirety.
The illustrative embodiment relates generally to discrete event modeling and more particularly to dynamically delaying function calls based on an input signal.
Graphical analysis, simulation, and execution methods are used in modeling, design, analysis, and synthesis of engineered systems. These methods provide a visual representation of a model, for example, by representing the model as a block diagram. The visual representation provides a convenient interpretation of model components and structure. The visual representation also provides a quick intuitive notion of system behavior. The components of a block diagram can also capture a mathematical representation of the actual system being modeled.
Historically, time-based block diagram models have been used to study, design, debug, and refine dynamic systems representative of many real-world systems. A dynamic system (either natural or man-made) is a system whose response at any given time is a function of its input stimuli, its current state, and the current time. More recently, discrete event system (DES) modeling environments have been developed to allow for the design and simulation of event-driven systems. In a DES modeling environment, a system's state transitions depend on discrete incidents called events. DES models execute based upon the occurrence of events. Unlike traditional time-driven models, an event-driven model can move time forward in arbitrary increments without the need to integrate along the time intervals that each increment covers.
The occurrence of an event in a DES model may cause a generation of a function call to a function block component, a function call in code, or a function call to a function subsystem (either in the DES modeling environment or another accessible modeling environment) that are to be executed upon receipt of the function call. A delay component may be interposed between the function call generator component and the target of the function call in the model. While there are a number of mechanisms available in time-driven systems by which the amount of delay in the delay component may be dynamically adjusted during the execution of the model, corresponding mechanisms are lacking in DES model environments.
The illustrative embodiment of the present invention provides a mechanism to dynamically vary the amount of delay for an event-generated function call. The event causing the generation of the function call may be a signal-based event, function call event or some other type of event. A function call generating delay component is inserted into a DES model and dynamically adjusts the amount of delay to apply prior to generating and transmitting the function call to an intended target component. The function call generating component reads a value from an input port in determining the amount of delay. The identified value at the input port may be a signal value or an attribute associated with an event entity received at the port.
In one embodiment of the present invention, a computing device implemented method for delaying function calls in a discrete event system (DES) modeling environment includes the step of identifying an occurrence of an event during an execution of a model in the DES modeling environment. The method also delays either the generation of a function call in response to the identified event or a transmission of the function call to an intended target component. The amount of the delay is adjusted dynamically.
In another embodiment of the present invention a system for delaying function calls in a discrete event system (DES) modeling environment includes an event generation component. The event generation component initiates an event during an execution of a model in the DES modeling environment. The system also includes a function call generation delay component. The function call generation delay component delays the generation of a function call in response to a detection of the event or a transmission of the function call to an intended target component. The amount of the delay being adjusted dynamically. The system additionally includes the intended target component. The intended target component executes at least one function in response to a receipt of the function call.
In one embodiment of the present invention, a method for delaying function calls includes the step of identifying an occurrence of an event during an execution of an event-driven model. The method also delays either the generation of a function call in response to the identified event or a transmission of the function call to an intended target component. The amount of delay for the generation of the function call or the transmission of the function call is adjusted dynamically.
In another embodiment of the present invention, a system for delaying function calls includes an event generation component. The event generation component initiates an event during an execution of an event-driven model. The system also includes a function call generation delay component that delays either a generation of a function call in response to a detection of the event or a transmission of the function call to an intended target component. The amount of delay for the generation of the function call or the transmission of the function call is adjusted dynamically. Additionally, the system also includes the intended target component. The intended target component executes at least one function in response to a receipt of the function call.
The invention is pointed out with particularity in the appended claims. The advantages of the invention described above, as well as further advantages of the invention, may be better understood by reference to the following description taken in conjunction with the accompanying drawings, in which:
Discrete Event Systems (DES) modeling environments, such as SIMEVENTS from The MathWorks, Inc. of Natick, Mass., extend time-driven modeling systems by providing tools for modeling and simulating discrete-event systems. Working in conjunction with a time-driven modeling environment such as SIMULINK, also from The MathWorks, Inc., a user is able to create a discrete-event simulation model to model the passing of entities through a network of queues, servers, gates, and switches based on the occurrence of various events. The user may be able to configure entities with user-defined attributes to model networks in packet-based communications, manufacturing, logistics, mission planning, supervisory control, service scheduling, and other applications. A DES modeling environment enables the user to model systems that are based on discrete events. Exemplary events include but are not limited to the creation or movement of an entity, the opening of a gate, a state transition in a statechart or a change in value of a signal. The illustrative embodiment of the present invention provides additional flexibility to the DES modeling environment by providing a mechanism that allows a user to dynamically vary the delay in generated function calls during the execution of a DES model.
The DES model 10 may include a number of block components such as, for example, an event generation component 11, a function call generation delay component 12 and an intended target component 13. The event generation component 11 may generate a signal event by generating an updated signal, generating a signal with a changed value, generating a trigger signal with a rising or falling edge or the event generation component may generate a function call event. As is explained further below, the function call generation delay component 12 identifies the occurrence of an event at an input port and generates a function call intended for the intended target component 12 in response. The transmission of the function call to the intended target component is delayed by a dynamically adjusted amount as discussed further below. The function call generation delay component 12 may be instantiated from a block in a library available to the DES modeling environment 4.
The computing device 2 may also support a MATLAB environment 7 (or a traditional time-driven graphical modeling environment such as SIMULINK) (MATLAB is a software technical computing environment produced by The MathWorks, Inc. while SIMULINK is a graphical modeling environment also produced by The MathWorks, Inc.) including a MATLAB workspace 8 that may hold one or more MATLAB workspace variables 9. The workspace variables 9 may be utilized during the execution of models in the DES modeling environment 4. Similarly, the computing device 2 may also support a state-based modeling environment 3 such as STATEFLOW (also from The MathWorks, Inc.) in communication with the DES modeling environment 4. It will be appreciated that although
A primary type of data component within a DES model may be referred to as an “entity”. Entities are abstract representations of items of interest within the DES model and may vary depending upon that which is being modeled by the DES system. Entities are the items that pass from block to block in the DES modeling environment. For example, when modeling a digital network, an entity may represent a data packet. In another example, when modeling a manufacturing plant, entities may take the form of individual items on the assembly line or represent aggregates of entities, for example crates stacked on a pallet. Each DES model may have one or more entities within the model at a given time.
The blocks or components in a DES model are interconnected using connectors that pass entities and other information between blocks or components. The information may include information from other models or data sources or references that have some contribution to the creation or operation of the entities as they pass through the DES model. The blocks or components can also have connectors that pass information out to other models or data sources outside of the DES model. The connectors may be graphical references such as lines or symbolic references.
In operation, the DES modeling environment 4 may make use of the various blocks to organize and manipulate entities through the DES model. For example, the event modeling manager 5 manages the configuration of multiple blocks to form the DES model 10. Blocks can be placed in the model 10 for entity generation, subsequent entity manipulation, and eventually entity termination. The basic operation of the DES model 10 involves passing the entities through the blocks according to instructions governed by the event modeling manager 5 and solver 6. The event modeling manager 5 may be represented by an event calendar, wherein the event calendar serves to drive the DES model 10 forward by executing the next scheduled event in the event calendar. The solver 6 is a DES specific mechanism which allows for the execution of events in the DES event calendar in light of operations that can occur in the external environment. The solver 6 is in communication with the external environment and can notify the external environment of events occurring within the DES modeling environment 4 that can affect the behavior of the external environment.
In one embodiment of the invention, an entity contains a set of attributes associated with the entity. However, an entity can contain as few as zero attributes. An attribute can be a field wherein the attribute is named and the attribute type is defined. For example, a field can define the entity type as a Boolean, a real number, an integer number, an enumerated type, a string, a vector, a matrix, a frame, and the like. The field may be defined as an arbitrary data type that represents an arbitrarily complex structure containing data that may include hierarchical composition as well as models and model parts. The contained data may be anything from a single bit of information to any sequence of such bits representing characters, numeric values, or any other syntactic and/or semantic datum. Furthermore, an entity may contain sub-entities. Sub-entities can be utilized in numerous operations such as recursive nesting or combining hierarchies.
Entities and sub-entities can also include timer objects and timeout objects that are used to add in the modeling environment. Timer objects are extra data that is carried by the entity/sub-entity that allows the start of a time interval to be recorded and at a later time the difference between the later time and the recorded time is calculated to determine lapsed time. Timeout objects are modules that consist of data and functions that allow an interval to be set by a Schedule timeout block. If the entity carrying the timeout object passes through the Cancel Timeout block before the timeout expires, the timeout is cancelled and nothing extraordinary happens. If the entity carrying the timeout object does not pass through the Cancel Timeout block before the timeout expires, the entity may be moved from its location in the simulation to another location.
The generation of entities can be automatic, or can be user-defined. User-defined entities allow, for example, users within a particular industry to define those attributes that are specific to their needs. The entity can then be incorporated into a DES model, thereby providing additional flexibility. Entities can further incorporate randomness into their behavior via probability distributions associated with blocks generating each entity. These probability distributions may be representative of the probability of an entity being generated based upon a set of defined variables. A probability distribution can be user defined or can be generated automatically, such that a probability of an event occurring drives entity generation within the model. Furthermore, the generation of a probability distribution may be accomplished utilizing other applications or environments, such as, but not limited to, a MATLAB environment or a SIMULINK environment.
In order to better explain the dynamic varying of delay times provided by the illustrative embodiment, a mechanism for a static delay of function calls in a DES modeling environment is first examined. In one implementation, a DES modeling environment can be configured so that a function call generation delay component provides a fixed delay between the generation of a function call and its transmission to an intended target.
The function call generation delay component block 20 converts a signal-based event or a function-call input into one or more function calls that may be used to invoke function-call subsystems, state chart systems and/or blocks, such as, for example STATEFLOW systems (STATEFLOW is also produced by The MathWorks, Inc.) or other blocks that accept function-call inputs. The output function calls may also be delayed by an amount of time that is specified via a parameter.
The time-based entity generator block 42 generates an entity every second. The #d output signal 43 from the Entity Generator block is incremented after every entity departure. The update in #d signal sends a trigger signal which is received at the input port 45 of the function call generation delay component block 44. The delay parameter of the function call generation delay component block is set to 1.5 sec through the dialog depicted in
The illustrative embodiment allows a user to delay the function-call generation by an amount of time that is dependent upon a specified input signal.
The delay value at the input port may be evaluated at the time the event that generates the function call occurs, as is the case when the value is generated by a SIMULINK sine wave generator, the Sine block. The value may also be evaluated before that time, as would be the case if the value was generated by a SIMULINK Constant block. The delay value read from an attribute is set before the event that caused the function call generation because of a previous evaluation of SIMULINK or SIMEVENTS blocks.
The user may also delay the output function calls by an amount of time that is specified via a parameter or an input signal. The primary criterion controlling the generation of a function call event is the receipt of a signal-based event or a function call. By default, the block generates a function call upon each event of the type specified by the user. The function call generation delay component block may also be used to generate more than one function call per event. In order to generate more than one function call upon each event, the user may select a ‘Generate optional f2 function call’ parameter from a dialog. It will be appreciated that in order to generate a third or additional function call other parameters could be selected from a dialog. The function calls may also be made contingent upon a secondary criterion. For example, the function call may be made contingent upon the user selecting a “Suppress function call f1 if enable signal e1 is not positive’ or ‘Suppress function call f2 if enable signal e2 is not positive’ parameter from a dialog. Selection of such a parameter results in the instantiation of a block with an additional signal input port, labeled e1 or e2, to which the user connects a control signal. If the control signal is zero or negative when the block is about to generate the function call, then the block suppresses the function call. An exception can be thrown or error status set if the function call is suppressed. Also, the user may be asked to arbitrate in the event of suppression. The e1 and e2 ports operate independently of each other as secondary criteria for their respective function-call output ports. It will be appreciated that the names of the parameters, labels and dialog options are illustrative and represent implementation choices in the DES modeling environment 4. Other names of the parameters, labels and dialog options may be substituted for those discussed herein without departing from the scope of the present invention. In an alternative embodiment, more than two function calls may be generated for each event detected at the input of the block.
Exemplary labels and descriptions of the meanings that may be attached to signal input and output ports that may be used with the illustrative embodiment include, but are not limited to:
Signal Input Ports
Label Description
The #f1 and #f2 ports generate the count of the function calls versus time. When one of these ports is connected to a ‘DES To Workspace’ block set to record time along with signal values, the time of function calls can be logged to the MATLAB workspace.
In another embodiment of the invention, the function call generation delay component may be used to perform function call generation in a feedback topology.
It should be appreciated that one function call generation delay component block may be connected to many different targets and one function-call target may be called from many different function call generation delay component blocks. The function calls from function call generation delay components may be multiplexed with function calls from other sources. The target of a function call may be a reused entity. For example, in case of duplicate functionality in a model, this may be captured by a reference to one common source representing this functionality. This reused function can be called from different function call generation delay component blocks with different arguments. For parameters of this reused functionality that are tunable during execution, the functionality may be duplicated, inlined, so that changing the parameter in the referenced functionality does not affect the functionality as connected to the other function call generation delay component blocks.
The argument list of the function-call may be user configurable. For example, in case of hierarchically structured input arguments, the user may choose to have these structures flattened into a list of unstructured arguments. Other options include the ordering of the arguments and whether the input arguments should be passed by reference or by value. Furthermore, in case of graphical function-call blocks, the user may choose to use the graphical input/output or the functional input/output in the function call argument list. For example, in case of a muxed input signal to a function-call subsystem, the input argument can be a multi-dimensional variable or it can be the functional sources separately. Further options include whether the parameters as used by a function are to be local to the function or whether they should be global.
The function call generation delay component block can generate a number of statistics related to the generation of function calls. The time between function calls can be recorded and output from a port on the function call generation delay component block. The mean, variance as well as other statistic based on moments of the time between these function calls can be generated. This calculation can be performed either within the block or in another block that accepts as input, the time between function calls.
In an alternative embodiment of the invention, the time delay may be based on the priority assigned to an input signal.
In one aspect of the present invention, a record of an identified event may be stored in a buffer or other location either in, or accessible to, the function call generation delay component block. Subsequently, the record of the stored event may be retrieved and serve as the basis for the generation of a function call.
In another aspect of the present invention, the function call generation delay component block may generate a function call that is compiled into code. The generated function call may be provided to a code generation component that generates executable code for the function call. The code may be in C, C++, Fortran, Java, Perl, UML, SysML, SDL, HDL or may be generated as a sequence diagram.
In one aspect of the present invention, the generated function call may be used to communicate data in the DES model. The generated function call may carry data that is accessible by a target of the function call. The function call may also return data from a target of the function call to the caller of the function, the function call generation delay component, regardless of whether or not the original function call carried data to the target. The function call may also be a remote procedure/remote method invocation call.
It should be appreciated that although many of the examples discussed above have discussed direct connections between a component and an input port in a DES model, other non-direct connections may also be utilized within the scope of the present invention. For example, the event can be ‘posted’ to the function call generation delay component block by symbolic reference, for example. Similarly, the generated function call does not need an explicit graphical connection, either. It could be referenced by a symbol or it could be included in a signal (or other type) connection.
The present invention may be provided as one or more computer-readable programs embodied on or in one or more mediums. The mediums may be a floppy disk, a hard disk, a compact disc, a digital versatile disc, a flash memory card, a Programmable ROM (PROM), a Magnetic RAM (MRAM), a Random Access Memory (RAM), a Read-Only Memory (ROM), or a magnetic tape. In general, the computer-readable programs may be implemented in any programming language. Some examples of languages that can be used include MATLAB, FORTRAN, C, C#, Python, JavaScript, or Java. The software programs may be stored on or in one or more mediums as object code. Hardware acceleration may be used and all or a portion of the code may run on a Field Programmable Gate Array (FPGA), an Application Specific Instruction-set Processor (ASIP), or an Application Specific Integrated Circuit (ASIC). The code may run in a virtualized environment such as in a virtual machine. Multiple virtual machines running the code may be resident on a single processor and multiple processors having two or more cores may be implemented on the same chip.
Since certain changes may be made without departing from the scope of the present invention, it is intended that all matter contained in the above description or shown in the accompanying drawings be interpreted as illustrative and not in a literal sense. Practitioners of the art will realize that the sequence of steps and architectures depicted in the figures may be altered without departing from the scope of the present invention and that the illustrations contained herein are singular examples of a multitude of possible depictions of the present invention.
Number | Name | Date | Kind |
---|---|---|---|
5371851 | Pieper et al. | Dec 1994 | A |
6466898 | Chan | Oct 2002 | B1 |
7487077 | Clune et al. | Feb 2009 | B1 |