The Event-Based Entity Generator block enables you to generate entities in response to signal-based events that occur during the simulation. The Generate entities upon parameter of the block determines:
The kind of signal input port the block has
The kinds of events that cause the block to generate an entity
Event times and the time intervals between pairs of successive entities are not necessarily predictable in advance.
Note: The Event-Based Entity Generator block can respond to triggers and function calls. However, do not place the block inside a triggered or function-call subsystem. Like other blocks that possess entity ports, the Event-Based Entity Generator block is not valid inside a triggered or function-call subsystem.
To specify intergeneration times between pairs of successive entities instead of using an event-based approach, use the Time-Based Entity Generator block. For more information, see Specify Intergeneration Times for Entities.
Generating entities when events occur is appropriate if you want the dynamics of your model to determine when to generate entities.
To generate an entity each time a Stateflow® chart transitions from state A to state B, configure the chart to output a function call upon such a transition. Then configure the Event-Based Entity Generator block to react to each function call by generating an entity.
To generate an entity each time a real-valued statistical signal crosses a threshold, configure the Event-Based Entity Generator block to react to triggers. Connect the tr signal input port of the block to the statistical signal minus the threshold.
In the following figure, the Event-Based Entity Generator block generates a new entity each time the average waiting time of the queue crosses a threshold. The threshold is 5 s.
To generate multiple entities simultaneously, configure the Event-Based Entity Generator block to react to function calls. Then connect its fcn input port to a signal that represents multiple function calls. For an example, see the Preloading Queues with Entities example.
Note: If you generate multiple entities simultaneously, then consider the appropriateness of other blocks in the model. For example, if three simultaneously generated entities advance to a single server block, then consider inserting a queue block between the generator block and the server block. As a result, entities (in particular, the second and third entities) have a place to wait for the server to become available.