| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → SimEvents |
| Contents | Index |
| Learn more about SimEvents |
| On this page… |
|---|
To see how the event calendar drives the simulation of a simple event-based model, consider the queue-server model depicted below.

Assume that the blocks are configured so that:
The Time-Based Entity Generator block generates an entity at T = 0.9, 1.7, 3.8, 3.9, and 6.
The queue has infinite capacity.
The server uses service times of 1.3, 2.0, and 0.7 seconds for the first three entities.
The sections below indicate how the event calendar and the system's states change during the simulation.
When the simulation starts, the queue and server are empty. The entity generator schedules an event for T = 0.9. The event calendar looks like the table below.
| Time of Event (s) | Type of Event |
|---|---|
| 0.9 | Time-Based Entity Generator block generates an entity. |
At T = 0.9,
The entity generator generates an entity and attempts to output it.
The queue is empty, so the entity advances from the entity generator to the queue.
The newly generated entity is the only one in the queue, so the queue attempts to output the entity. It queries the server to determine whether the server can accept the entity.
The server is empty, so the entity advances from the queue to the server.
The server's entity input port becomes temporarily unavailable to future entities.
The server schedules an event that indicates when the entity's service time is completed. The service time is 1.3 seconds, so service is complete at T = 2.2.
The entity generator schedules its next entity-generation event, at T = 1.7.
In the schematic below, the circled notation "e1" depicts the first entity and the dashed arrow is meant to indicate that this entity advances from the entity generator through the queue to the server.

The event calendar looks like this.
| Time of Event (s) | Event Description |
|---|---|
| 1.7 | Time-Based Entity Generator block generates second entity. |
| 2.2 | Single Server block completes service on the first entity. |
At T = 1.7,
The entity generator generates an entity and attempts to output it.
The queue is empty, so the entity advances from the entity generator to the queue.
The newly generated entity is the only one in the queue, so the queue attempts to output the entity. However, the server's entity input port is unavailable, so the entity stays in the queue. The queue's entity output port is said to be blocked because an entity has tried and failed to depart via this port.
The entity generator schedules its next entity-generation event, at T = 3.8.

| Time of Event (s) | Event Description |
|---|---|
| 2.2 | Single Server block completes service on the first entity. |
| 3.8 | Time-Based Entity Generator block generates the third entity. |
At T = 2.2,
The server finishes serving its entity and attempts to output it. The server queries the next block to determine whether it can accept the entity.
The sink block accepts all entities by definition, so the entity advances from the server to the sink.
The server's entity input port becomes available. The server executes an event to notify the queue about the newly available entity input port. This is called an entity request event.
The queue is now able to output the second entity to the server. As a result, the queue becomes empty and the server becomes busy again.
The server's entity input port becomes temporarily unavailable to future entities.
The server schedules an event that indicates when the second entity's service time is completed. The service time is 2.0 seconds.
Note The server's entity input port started this time instant in the unavailable state, became available (when the first entity departed from the server), and then became unavailable once again (when the second entity arrived at the server). It is not uncommon for a state to change more than once in the same time instant. |

| Time of Event (s) | Event Description |
|---|---|
| 3.8 | Time-Based Entity Generator block generates the third entity. |
| 4.2 | Single Server block completes service on the second entity. |
At T = 3.8,
The entity generator generates an entity and attempts to output it.
The queue is empty, so the entity advances from the entity generator to the queue.
The newly generated entity is the only one in the queue, so the queue attempts to output the entity. However, the server's entity input port is unavailable, so the entity stays in the queue.
The entity generator schedules its next entity-generation event, at T = 3.9.

| Time of Event (s) | Event Description |
|---|---|
| 3.9 | Time-Based Entity Generator block generates the fourth entity. |
| 4.2 | Single Server block completes service on the second entity. |
At T = 3.9,
The entity generator generates an entity and attempts to output it.
The queue is not full, so the entity advances from the entity generator to the queue.
The server's entity input port is still unavailable, so the queue cannot output an entity. The queue length is currently two.
The entity generator schedules its next entity-generation event, at T = 6.

| Time of Event (s) | Event Description |
|---|---|
| 4.2 | Single Server block completes service on the second entity. |
| 6 | Time-Based Entity Generator block generates the fifth entity. |
At T = 4.2,
The server finishes serving its entity and attempts to output it.
The sink block accepts all entities by definition, so the entity advances from the server to the sink.
The server's entity input port becomes available, so it executes an entity request event. The queue's entity output port becomes unblocked. The queue is now able to output the third entity to the server. As a result, the queue length becomes one, and the server becomes busy.
The server's entity input port becomes temporarily unavailable to future entities.
The server schedules an event that indicates when the entity's service time is completed. The service time is 0.7 seconds.
The queue attempts to output the fourth entity. However, the server's entity input port is unavailable, so this entity stays in the queue. The queue's entity output port becomes blocked.
Note The queue's entity output port started this time instant in the blocked state, became unblocked (when it sensed that the server's entity input port became available), and then became blocked once again (when the server began serving the third entity). |

| Time of Event (s) | Event Description |
|---|---|
| 4.9 | Single Server block completes service on the third entity. |
| 6 | Time-Based Entity Generator block generates the fifth entity |
![]() | Supported Events in SimEvents Models | Observing Events | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |