This example shows how to change the selected output port of an Entity Output Switch block to route entities along different paths. The software selects the path on a per-entity basis, not on a predetermined time schedule.
Consider the following example.
The SwitchCtrl function contains a single Repeating
Sequence Stair block, whose Sample time parameter
is set to
When the Simulink Function block executes, it outputs the next number from a repeating sequence. In this model, the output message value is 3, 2 or 1, based on the sequence of values specified in the Repeating Sequence Stair block.
When service in the Entity Server block is complete, the entity advances to the Entity Output Switch block. The output message of the Simulink Function block determines which output port the entity uses when it departs the Entity Output Switch block.
When the Entity Output Switch block uses an input message, the block might attempt to use the message before its first sample time hit. If the initial value of the message is out of range (for example, it is unavailable). You should then specify the initial port selection in the Entity Output Switch block's dialog box. Use this procedure:
Select From control port.
Set From control port to the desired initial port selection. The value must be an integer between 1 and Number of output ports. The Entity Output Switch block uses Initial port selection until the first control port message arrives.