Examples Using Entity-Departure Subsystems

Example: Using Entity-Based Timing for Choosing a Port

This example performs the entity-based routing described in Timing for Choosing a Port Using a Sequence. The example routes entities by establishing a sequence of paths and then choosing a number from that sequence for each entity that arrives at the routing block. This is the situation shown in the figure Departure Port Changes with Each Entity.

In the model shown below, the Function-Call Subsystem block contains a Repeating Sequence Stair block whose Sample time parameter is set to -1 (inherited). Any entity that arrives at the Output Switch block previously departed from the Entity Departure Event to Function-Call Event block. The function-call output from that block caused the subsystem to produce a number that indicates which entity output port the entity uses when it departs from the Output Switch block.

If you used the Repeating Sequence Stair block with an explicit sample time and not inside a subsystem, then the routing behavior would depend on the clock, as shown in the figure Departure Port Changes with Time, rather than on entity departures.

Top-Level Model

Subsystem Contents

The Entity Departure Event to Function-Call Event block, which issues function calls after entity departures, appears before the Single Server block instead of between the Single Server block and the Output Switch block. This placement ensures that when the function call executes the subsystem, the entity has not yet arrived at the switch but rather is stored in the server.

Example: Performing a Computation on Selected Entity Paths

The model below performs a computation whenever an entity arrives at the IN2 or IN3 entity input port of a Path Combiner block, but not when an entity arrives at the IN1 port of the Path Combiner block. The computation occurs inside the Function-Call Subsystem block. When an entity departs from specific blocks that precede the Path Combiner block, the corresponding Entity-Based Function-Call Event Generator block issues a function call. A Mux block combines the two function-call signals, creating a function-call signal that calls the subsystem. If both event generators issue a function call at the same value of the simulation clock, then the subsystem is called twice at that time.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS