Page 346 - ExtendSim User Guide
P. 346

320 Tips and Techniques
Messaging in discrete event models
• When a message is sent from an input value connector, the sending block requests an updated connector value from the receiving blocks. Messages sent out the input connectors go only to the outputs of the directly connected blocks.
• Wheneveranoutputconnectorchanges,messagesaresenttoalloftheinputsofthedirectly connected blocks. In this case, the sending block alerts the receiving blocks of a connector value change. Blocks that receive messages at their input connectors may, if appropriate, propagate messages:
• Out other input connectors to make sure that all input values are current
• Totheiroutputconnectorstonotifyotherblocksofthechangeinvalue
Through this mechanism, a single value change may cause any number of connected blocks to recalculate, ensuring that any system dependencies are automatically evaluated. For example, if the value of an input connector on an equation-type block changes, messages are first sent out the other input value connectors if they are connected (ensuring the equation will have up- to-date inputs prior to calculation.) Then, with updated inputs, the block recalculates its equa- tion and posts the new results on its output value connectors. Once the new results have been posted, messages are sent out the output connectors, alerting any connected blocks that the results have changed.
Example of value connector messaging
The sample model shown below illustrates how value connector messages work. In this exam- ple, items arrive, an attribute is set to a random number, and the items are then processed at two work areas (Queue and Activity blocks) in series. Three Value library blocks (Random Num- ber, Math, and Display Value) provide a random number for the attribute value, add the two queue lengths, and display the sum of the lengths, respectively.
Example of value connector messages
When an item arrives to the Set block a message is sent out its value input connector. The Random Number block responds by providing a new ran- dom number each time it receives a message. This simple messaging exam- ple is shown at the right.
In a discrete event or discrete rate model, the only time most Value library blocks (such as the Random Number block) are alerted to do something is when they receive a message on one of their value connectors. For instance, do not expect the Random Number block to continuously output a stream of random numbers in discrete event or discrete rate models.
One message sent
Discrete Event


































































































   344   345   346   347   348