Count Simultaneous Departures from a Server

This example shows how to count the simultaneous departures of entities from a server. Use the d output from the Entity Server block to learn how many entities have departed (or arrived at) the block. The output signal also indicates when departures occurred. This method of counting is cumulative throughout the simulation.

Model using an Entity Generator, Entity Server, Entity Terminator and Simulink Function block

To open the example, see Count Simultaneous Departures.

  1. In a new model, from the SimEvents® library, drag the Entity Generator, Entity Server, Entity Terminator, and Simulink Function blocks. Add a Simulink® Scope block.

  2. Double-click the Entity Generator block.

    • In the Event actions tab, to generate random attribute values, enter:

      entity.Attribute1=rand();
  3. Double-click the Entity Server block. In the Main tab:

    • In the Capacity parameter, enter inf.

    • For the Service time parameter, select MATLAB action.

    • In the Service time action parameter, enter:

      dt = getServiceTime();
    • In the Statistics tab, select Number of entities departed, d.

  4. In the Simulink Function block, add a Repeating Sequence Stair and define the getServiceTime function.

    Inside the Simulink Function block including a Repeating Sequence Stair block. The Repeating Sequence Stair block window show the output values and sample time.

  5. Connect the blocks as shown and simulate the model. Observe that the scope displays simultaneous entity departures for the corresponding time.

    Scope block showing the entity departures

See Also

| | | | | | |

Related Examples

More About