Documentation Center

  • Trial Software
  • Product Updates

Output Switch

Select entity output port for departure

Library

Routing

Description

This block receives entities, which depart through one of multiple entity output ports. The selected port can change during the simulation.

Managing Arrivals and Departures

When the selected port is not blocked, an arriving entity departs through that port. When an entity attempts to arrive and the selected port is blocked, the block's behavior depends on the block's configuration and state, as illustrated in the figure.

    Note:   This block permits storage only if you set Switching criterion to From signal port p, and then select Store entity before switching.

Entities that time out depart via the block's TO port. For information about how you can handle such entities, see Handle Timed-Out Entities.

Switching Criteria

The Switching criterion parameter indicates how the block determines which entity output port is selected for departure at any given time. The values of the Switching criterion parameter are described in the table below.

Switching criterion ValueDescription
Round robinThe first arriving entity in the simulation departs via the OUT1 port. Upon each subsequent arrival, the block selects the entity output port next to the last selected port. After exhausting all entity output ports, the block returns to the first one, OUT1.
EquiprobableAt the beginning of the simulation and upon each departure, the block randomly chooses the entity output port through which the next arriving entity departs. All entity output ports are equally likely to be selected. The Initial seed parameter initializes the random number generation process.
First port that is not blockedWhen an entity attempts to arrive, the block attempts to output the entity through OUT1. If that port is blocked, then the block attempts to output the entity through OUT2, and so on. If all entity output ports are blocked, then this block's IN port is unavailable and the entity cannot arrive.
From signal port pSelecting this option creates an additional signal input port, labeled p. The signal at this port uses integer values between 1 and the Number of entity output ports parameter value to refer to entity output ports. The block monitors the p signal's value throughout the simulation and reacts to changes by selecting the corresponding entity output port.
From attributeAn arriving entity departs through the entity output port that corresponds to the value of an attribute of your choice. Name the attribute using the Attribute name parameter. The attribute value must be an integer between 1 and the Number of entity output ports parameter value. If the indicated entity output port is blocked, then this block does not accept the entity for arrival until the entity output port becomes unblocked.

    Note:   If you set Switching criterion to From signal port p, then the block offers several options to help you ensure that the signal is up to date and valid when the block uses it to determine how to process the arriving entity. Be especially careful when the signal is in a feedback loop, or when the signal can change at the same time an entity arrives. For details, see Use Signals To Route Entities. For common problems and troubleshooting tips, see Unexpected Use of Old Value of Signal.

Ports

Entity Input Ports

LabelDescription
INPort for arriving entities.

Signal Input Ports

LabelDescription
pIndex of the entity output port through which an arriving entity departs. Values must be integers between 1 and Number of entity output ports. This signal must be an event-based signal. You see this port only if you set Switching criterion to From signal port p.

Entity Output Ports

LabelDescription
OUT1, OUT2, OUT3, and so onEntity ports through which an arriving entity departs, where the Switching criterion parameter determines which of multiple ports the entity departs through. The Number of entity output ports parameter determines how many of these entity output ports the block has.
TOPort for entities that time out while in this block. You see this port only if you set Switching criterion to From signal port p, select Store entity before switching, and select Enable TO port for timed-out entities. This port must not be blocked when an entity attempts to depart here.

Signal Output Ports

LabelDescriptionTime of Update When Statistic Is OnOrder of Update
#dNumber of entities that have departed from this block without timing out, since the start of the simulation.After entity departure via a port other than TO3
#toNumber of entities that have timed out from this block since the start of the simulation.After entity departure via the TO port2
pe

A value of 1 indicates that the block stores an entity that has tried and failed to depart. In that case, the entity is a pending entity.

A value of 0 indicates that the block does not store any pending entities.

Sample time hit of 1 occurs after the block stores an entity that has tried and failed to depart.

Sample time hit of 0 occurs after the departure of the pending entity via any port.

1
lastIndex of the output port through which the last entity departed, excluding timed-out entities. Aside from the initial output, values of this signal are 1, 2, 3,..., Number of entity output ports.After entity departure via a port other than TO2

The initial output value, which is in effect from the start of the simulation until the first update by the block, is 0 for all signals.

Dialog Box

Output Switch Tab

Number of entity output ports

Determines how many entity output ports the block has.

Switching criterion

The rule that determines which entity output port an arriving entity departs through.

Initial seed

A nonnegative integer that initializes the random number generator used to select an entity output port. You see this field only if you set Switching criterion to Equiprobable.

Specify initial port selection

Select this option to indicate the initially selected entity output port. For details, see Specify an Initial Port Selection. You see this field only if you set Switching criterion to From signal port p.

Initial port selection

The entity output port that the block selects when the simulation begins. The value must be an integer between 1 and Number of entity output ports. The block uses Initial port selection instead of the p signal's value until the signal has its first sample time hit. You see this field only if you set Switching criterion to From signal port p and select Specify initial port selection.

Store entity before switching

If you select this option, the block can store one entity at a time. Furthermore, the block decouples its arrival and departure processing to give other blocks in the simulation an opportunity to update the p signal if appropriate. If you do not select this option, the block processes an arrival and departure as an atomic operation and assumes that the p signal is already up to date at the given time. For details, see Use the Storage Option to Prevent Latency Problems. You see this field only if you set Switching criterion to From signal port p.

Resolve simultaneous signal updates according to event priority

Select this option to prioritize the port-selection event explicitly, relative to other simultaneous events in the simulation. If you do not select this option, the event has priority SYS1 on the event calendar. For details, see Resolve Simultaneous Signal Updates. You see this field only if you set Switching criterion to From signal port p and do not select Store entity before switching.

Event priority

The priority of the port-selection event, relative to other simultaneous events in the simulation. For details, see Specify Event Priorities to Resolve Simultaneous Signal Updates. You see this field only if you set Switching criterion to From signal port p, do not select Store entity before switching, and select Resolve simultaneous signal updates according to event priority.

Attribute name

The name of an attribute used to select an entity output port. You see this field only if you set Switching criterion to From attribute.

Timeout Tab

Enable TO port for timed-out entities

This option is available only if you set Switching criterion to From signal port p, and then select Store entity before switching on the Output Switch tab of the dialog box. This option becomes relevant if an entity times out while in this block. Selecting this option provides a TO entity output port through which the timed-out entity departs. If you clear this option in a model that uses timeouts, see the description of the If entity has no destination when timeout occurs parameter on the Schedule Timeout block reference page.

Statistics Tab

These parameters determine whether the block produces data at signal output ports or omits those ports. For descriptions of the data and ports, see the preceding table, "Signal Output Ports".

Number of entities departed

Allows you to use the signal output port labeled #d.

Number of entities timed out

Allows you to use the signal output port labeled #to.

Pending entity present in block, pe

Allows you to use the signal output port labeled pe. You can select this check box only if you set Switching criterion to From signal port p, and then select Store entity before switching on the Output Switch tab of the dialog box.

Last entity departure port

Allows you to use the signal output port labeled last.

Was this topic helpful?