| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → SimEvents |
| Contents | Index |
| Learn more about SimEvents |
| On this page… |
|---|
Role of Explicitly Generated Events |
You can generate an event and use it to
Invoke a discrete event subsystem, Embedded MATLAB Function block, or Stateflow block
Cause certain events, such as the opening of a gate or the reading of memory in a Signal Latch block
Generate an entity
For most purposes, a function call is an appropriate type of event to generate.
Note While you can invoke triggered subsystems,Embedded MATLAB Function blocks, and Stateflow blocks upon trigger edges, trigger usage has limitations in discrete-event simulations. In particular, you should use function calls instead of triggers if you want the invocations to occur asynchronously, to be prioritized among other simultaneous events, or to occur more than once in a fixed time instant. |
The table below indicates which blocks generate function calls when other events occur.
| Event Upon Which to Generate Another Event | Block |
|---|---|
| Entity advancement | Entity-Based Function-Call Event Generator |
| Signal-based event | Signal-Based Function-Call Event Generator |
| Function call | Signal-Based Function-Call Event Generator |
The fragment below, which is part of an example in Using Stateflow Charts to Implement a Failure State, uses entities to represent failures and repairs of a server elsewhere in the model:
A failure of the server is modeled as an entity's arrival at the block labeled Repair Work. When the Repair Work block's #n signal increases to reflect the entity arrival, the Signal-Based Function-Call Event Generator block generates a function call that calls the Stateflow block to change the state of the server from up to down.
A completed repair of the server is modeled as an entity's departure from the Repair Work block. When the Repair Work block's #n signal decreases to reflect the entity departure, the Signal-Based Function-Call Event Generator block generates a function call that calls the Stateflow block to change the state of the server from down to up.

One reason to use function calls rather than triggers to call a Stateflow block in discrete-event simulations is that an event-based signal can experience a trigger edge due to a zero-duration value that a time-based block would not recognize. The Signal-Based Function-Call Event Generator can detect signal-based events that involve zero-duration values.
To generate events using intergeneration times from a signal or a statistical distribution, use this procedure:
Use the signal or statistical distribution with the Time-Based Entity Generator block to generate entities.
Use the Entity-Based Function-Call Event Generator block to generate an event associated with each entity.
Terminate the entity path with an Entity Sink block.
In the special case when the intergeneration time is constant, a simpler alternative is to use the Function-Call Generator block in the Simulink Ports & Subsystems library.
The example below (open model) uses the top entity generator to generate entities whose sole purpose is to cause the generation of events with intergeneration times from a statistical distribution. The bottom entity generator generates entities that enter a gated queuing system.

![]() | Observing Events | Manipulating Events | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |