Enqueue messages and entities
Simulink / Messages & Events
SimEvents
This block stores entities or messages in a queue, based on the order of arrival or priority. Each element at the head of the queue departs when the downstream block is ready to accept it. The Queue block and the Entity Queue block are the same blocks with different default values for the Overwrite the oldest element if queue is full check box.
You can specify the capacity of the queue, and the policy when the queue is full. The block supports three different message or queue sorting policies, first-in-first out (FIFO), last-in-first out (LIFO), and priority. The priority queue can be used only when the Overwrite the oldest element if queue is full check box is cleared.
Port_1
— Input entity or messageInput entity or message that carries scalar, bus, or vector data to enter the queue.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| enumerated
| bus
| fixed point
Port_1
— Output entity or messageOutput port that allows entities or messages at the head of the queue to depart when a downstream block is ready to accept them.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| enumerated
| bus
| fixed point
Port_d
— Number of entities that have departed the blockNumber of entities that have departed the block.
To enable this port, select Overwrite the oldest element if queue is full check box, and click the Statistics tab and select the box labeled Number of entities departed, d.
Data Types: double
Port_n
— Number of entities that have not yet departed the blockNumber of entities that have not yet departed the block.
To enable this port, select Overwrite the oldest element if queue is full check box, and click the Statistics tab and select the box labeled Number of entities in block, n.
Data Types: double
Port_w
— Average wait time for entities in the blockAverage wait time for entities in the block.
To enable this port, select Overwrite the oldest element if queue is full check box, and click the Statistics tab and select the box labeled Average wait, w.
Data Types: double
Port_l
— Average length of the entity queuePort_l outputs the average length of the entity queue.
To enable this port, select Overwrite the oldest element if queue is full check box, and click the Statistics tab and select the box labeled Average queue length, l.
Data Types: double
Port_ex
— Number of entities extractedNumber of entities that are pulled out of this block.
To enable this port, select Overwrite the oldest element if queue is full check box, and click the Statistics tab and select the box labeled Number of entities extracted, ex.
Data Types: double
Overwrite the oldest element if queue is full
— Specify queue overwriting policySelect this check box to choose between two queue overwriting policies.
If you select the check box, an incoming message overwrites the oldest if the queue is full.
This mode represents a simple message buffer that you can use to generate asynchronous communication between Simulink components and production code.
If you clear the check box, the block does not accept new messages if the queue is full.
In this mode, you can manipulate entity data using event actions and visualize statistics.
To customize actions when entities or messages enter, exit, or are
blocked, enter MATLAB® code in the Entry action
,
Exit action
, or Blocked
action
field of the Event actions
tab. For more information, see Events and Event Actions (SimEvents).
For an example, see Manage Entities Using Event Actions (SimEvents).
Block Parameter:
QueueOverwriting |
Type: character vector |
Values: 'on'
| 'off' |
Default:
'on' (for Simulink) and 'off' (for SimEvents) |
Capacity
— Specify the capacity of the queueSpecify the capacity of the queue.
Block Parameter:
Capacity |
Type: character vector |
Values: '25'
| scalar |
Default:
'25' |
Queue type
— Choose the queue typeFIFO
(default) | LIFO
| Priority
Choose the queue type.
FIFO
— first-in-first-out
LIFO
— last-in-first-out
Priority
— store elements in order of
priority, see Serve High-Priority Customers by Sorting Entities Based on Priority (SimEvents).
Priority
can be selected when you
clear the Overwrite the oldest element if queue is
full check box.
Note
Priority queue does not support fixed
point
data type.
Block Parameter:
QueueType |
Type: character vector |
Values:
'FIFO' | 'LIFO' |
'Priority' |
Default:
'FIFO' |
Multicast tag
— Specify the tag when accepting entities broadcast via multicast sourcesA
(default) | character vectorSpecify the tag when accepting entities broadcast via multicast sources. The Entity Multicast block requires SimEvents license.
This parameter is visible when you clear the Overwrite the
oldest element if queue is full check box, and set
Entity arrival source to
Multicast
.
Block Parameter:
MulticastTag |
Type: character vector |
Values: 'A'
| character vector |
Default:
'A' |
Priority source
— Specify which attribute of the entity determines its priority PriorityAttribute
(default) | character vectorSpecify which attribute of the entity determines its priority.
This parameter is visible when you clear the Overwrite the
oldest element if queue is full check box, and set
Queue type to
Priority
.
Block Parameter:
PrioritySource |
Type: character vector |
Values:
'PriorityAttribute' | character
vector |
Default:
'PriorityAttribute' |
Sorting direction
— Choose the direction of sorting based on priorityAscending
(default) | Descending
Choose the direction of sorting based on priority.
Ascending
— Elements with smaller
priority values appear in front of the queue.
Descending
— Elements with greater
priority values appear in front of the queue.
This parameter is visible when you clear the Overwrite the
oldest element if queue is full check box, and set
Queue type to
Priority
.
Block Parameter:
SortingDirection |
Type: character vector |
Values:
'Ascending' | 'Descending'
|
Default:
'Ascending' |
Entity arrival source
— Choose the source of arrival for the entitiesInput port
(default) | Multicast
Choose the source of arrival for the entities.
Input port
— Input port is source of
messages or entities.
Multicast
— Entity
Multicast block is source of entities. The Entity
Multicast block requires SimEvents license.
This parameter is visible when you clear the Overwrite the
oldest element if queue is full check box, and set
Queue type to
Priority
.
Block Parameter:
EntityArrivalSource |
Type: character vector |
Values: 'Input
port' | 'Multicast'
|
Default: 'Input
port' |
Event action
— Specify the behavior of the entity in certain eventsEntry
(default) | Exit
| Blocked
Specify the behavior of the entity in certain events. Define the behavior in the Event action parameter. The Entry and the Exit actions are called just after the entity entry and just before entity exit. The Blocked action is called after an entity is blocked. For more information, see Events and Event Actions (SimEvents).
Note
Event actions do not support fixed point
data
type.
Event actions are visible when you clear the Overwrite the oldest element if queue is full check box.
Block Parameter:
EntryAction, ExitAction,
BlockedAction |
Type: character vector |
Values: MATLAB code |
Default:
'' |
Number of entities departed, d
— Outputs the number of entities that have departed the blockoff
(default) |
on
Number of entities that have departed the block.
Number of entities departed, d is visible when you clear the Overwrite the oldest element if queue is full check box.
Block Parameter:
NumberEntitiesDeparted |
Type: character vector |
Values: 'on'
| 'off' |
Default:
'off' |
Number of entities in block, n
— Outputs the number of entities present in the block, that are yet to departoff
(default) |
on
Number of entities present in the block, but which are yet to depart.
Number of entities in block, n is visible when you clear the Overwrite the oldest element if queue is full check box.
Block Parameter:
NumberEntitiesInBlock |
Type: character vector |
Values: 'on'
| 'off' |
Default:
'off' |
Average wait, w
— Outputs the average wait time off
(default) |
on
Sum of the wait times for entities departing the block divided by their total number. Wait time is the duration between the Entity Queue block entry and exit of an entity. For more information, see Interpret SimEvents Models Using Statistical Analysis (SimEvents).
Average wait, w is visible when you clear the Overwrite the oldest element if queue is full check box.
Block Parameter:
AverageWait |
Type: character vector |
Values: 'on'
| 'off' |
Default:
'off' |
Average queue length, l
— Outputs the average length of the entity queueoff
(default) |
on
Accumulated time-weighted average queue size. The block computes this value by:
Multiplying the size of the queue by its duration to calculate time-weighted queue size
Summing up all time-weighted queue sizes and averaging them over total time
For more information, see Interpret SimEvents Models Using Statistical Analysis (SimEvents).
Average queue length, l is visible when you clear the Overwrite the oldest element if queue is full check box.
Block Parameter:
AverageQueueLength |
Type: character vector |
Values: 'on'
| 'off' |
Default:
'off' |
Number of entities extracted, ex
— Number of entities extracted from this blockoff
(default) | on
Outputs the number of extracted entities which are pulled out from this block by the Entity Find block. The Entity Find block requires a SimEvents license. If the extracted entity is the first entity in the queue, the next entity is set as the pending entity to leave the block. If an entity attribute defines the priority in a priority queue and it is modified by the Entity Find block, the queue is sorted again. When an entity is extracted, Number of entities departed, d, Number of entities in block, n, Average wait, w, and Average queue length, l statistics are updated accordingly. For more information about finding and extracting entities, see Find and Extract Entities in SimEvents Models (SimEvents).
Number of entities extracted, ex is visible when you clear the Overwrite the oldest element if queue is full check box.
Block Parameter:
NumEntitiesExtracted |
Type: character vector |
Values: 'on'
| 'off' |
Default:
'off' |
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
Code generation is not supported for event actions and statistics.