Page 639 - ExtendSim User Guide
P. 639

• If a button is clicked
• Attheendofthesimulation
At the start of the model run, all blocks receive application messages to check their dialogs and connections for consistency and to initialize variables, import data, or allocate any arrays used during the simulation. At the end of the simulation run, blocks are triggered to collect statistics, dispose of any temporary arrays, and update the status of the model. Other application mes- sages are sent only when a specific event, parameter change, or dialog click occurs. The Devel- oper Reference has a complete list of application messages, including CheckData, InitSim, Simulate, EndSim and FinalCalc.
Link alerts
Link alerts are a special type of application message. If a block is linked to a data source in a global array or ExtendSim database, it will receive a message whenever the value in that data source changes. That message may cause changes in the block’s data. The application sends link alert messages in continuous, discrete event, and discrete rate models. In a discrete event or discrete rate model, the alerted block may, in turn, send messages out its connectors.
Managing this message is important because linking blocks to a data source that frequently changes may slow down the simulation. If a simulation model is running slowly, and blocks have links to data sources, consider sending or receiving link alert messages only at the start or end of the simulation. This can be done by modifying the properties of the link so it only sends messages at the appropriate times. (See “Link dialog checkboxes” on page 743).
Continuous model messaging
In a continuous model, the most important application message is the simulate message that causes code in blocks to execute as simulation time advances. At each step of the simulation, the application sends a simulate message to every block in the model in the sequence defined by the model’s simulation order. (Simulation order is determined by the application at the start of the run based on settings in the Simulation Setup dialog, as discussed in “Continuous tab” on page 596.) In the simulate message handler, each block will perform its intended calcula- tion. For example, if Add is selected in the Math block (Value library), the block will add all its inputs when it gets a simulate message. Likewise, a Decision block (Value library) will check its inputs and output a true or false value based on the options selected in its dialog.
Block to block messages
Blocks can send messages to each other either through connections or “through the air.” This often happens when one block has calculated a new value and wishes to alert one or more blocks to this change. Continuous blocks, such as those in the Value library, do not typically send or receive block messages. Discrete event (Item library) and discrete rate (Rate library) blocks often send and receive block messages.
Discrete event block messaging
In addition to receiving application messages, discrete event blocks communicate with each other using block messages. A variety of messages are sent between blocks during the course of the simulation. These block messages fall into the following categories:
• Event.CommunicationbetweentheExecutiveandvariousItemlibraryblocksinthemodel.
• Value connector. Notifies connected blocks that the value of a output connector has
changed or requests updated input connector information.
• Itemconnector.Propelsitemsthroughthemodel.
Model Execution 613
How ExtendSim passes messages in models
How To

   637   638   639   640   641