Main Content

Route Vehicles Using an Entity Output Switch Block

This example shows how to route vehicles to two different pumps in a gas station by controlling an Entity Output Switch block.

In the example, vehicles are generated by an Entity Generator block, which represents vehicle arrival. After their arrival, vehicles are routed to two different gas pumps using an Entity Output Switch block. A Simulink Function block controls the selected output port of the Entity Output Switch block. The vehicle's departure from the Entity Generator block invokes the Simulink Function block.

Control Entity Output Switch Block

  • In the Entity Output Switch Block, set the Switching Criterion to From control port.

  • In the Simulink Function block, use a Uniform Random Number block to generate random numbers between 1 and 2.

  • The generated random number is rounded to the integers 1 or 2 by the Round block.

  • The integer value of the signal is converted to a message by the Message Send block.

  • The output value from the Simulink Function block corresponds to the selected output of the Entity Output Switch block.

Simulate Model and Review Results

Simulate the model and observe that 14 vehicles use Gas Pump1 and 16 vehicles use Gas Pump2.

See Also

| | |

Related Topics