Customize Discrete-Event System Behavior Using Events and Event Actions
You can customize the behavior of a discrete-event system by defining events and event actions.
Define event actions in response to events
Event Types and Event Actions
A discrete-event system can have these event types and their targets.
|Allow an entity to acquire one or more resources.
|Destroy an existing entity in storage.
|Move an entity from its current storage to another storage or output port.
|Iterate and process each entity in storage.
|Allow an entity to release one or more resources.
|Allow an entity to release all previously acquired resources.
|Create an event to indicate that the storage acceptance policy is changed and the storage retests the arriving entities.
|Create a timer event.
|Create an entity inside storage.
If a forward event fails because of blocking, the forward event remains active. When space becomes available, the discrete-event system reschedules the forward event for immediate execution.
You can schedule multiple events of the same type for the same actor. When using multiple events of the same type, use tags to distinguish between the events. For example, an entity can have multiple timers with distinct tags. When one timer expires, you can use the
tagargument of the
timermethod to differentiate which timer it is. For more information, see Custom Entity Storage Block with Multiple Timer Events.
If you schedule two events with the same tag on the same actor, the later event replaces the first event. If you schedule two events with different tags, the discrete-event system calls them separately.
When an event occurs, a discrete-event system responds to it by invoking a corresponding action. Implement these actions as System object™ methods. This table lists each action method and the triggering event.
|Called if, upon execution of a forward event, the entity cannot leave due to blocking from the target storage.
|Called before an entity is destroyed and removed from storage.
|Called upon an entity entry.
|Called upon entity exit. When an entity is forwarded from
1 to storage
the exit action of storage
1 and then the
entry action of storage
2 are called.
|Called after a new entity is created inside a storage element.
|Upon the execution of an Iterate event, this method is invoked for each entity from the front to the back of the storage, with the option of early termination. If entities need to be resorted due to key value changes, resorting takes place after the entire iteration is complete.
|Called after a successful resource acquisition. A resource acquisition is successful only if all of the specified resources are acquired.
|Called after the resource release.
|Called after the test entry event.
|Called upon executing a timer event of an entity.
Use these methods to initialize empty arrays and events of a discrete-event system.
Cancel Previously Scheduled Events
Use these methods to cancel previously scheduled events of a discrete-event system.
|Cancel previously scheduled resource acquisition event
|Cancel previously scheduled entity destroy event.
|Cancel entity forward event.
|Cancel previously scheduled entity generation event.
|Cancel previously scheduled iterate event.
|Cancel previously scheduled timer event.
There are two distinct identifiers for the events provided by the
Tag — Use the
tagas an input argument for a method.
event1 = obj.eventTimer('mytimer1', 2); event2 = obj.eventTimer('mytimer2', 5);
mytimer2are used as tags to refer to these two timer events.
Destination — Use the destination to identify forward events.
event1 = obj.eventForward('storage', 2, 0.8); event2 = obj.eventForward('output', 1, 2);
outputare used to distinguish two forward events.
The events are not distinguishable when their identifiers are the same. This table shows how to identify an event when multiple events of the same type act on the same target.
If you define an event that is yet to be executed and a second event with the same type and identifier, the first event is replaced by the second one.