Queue - Enqueue messages and entities - Simulink (original) (raw)

Enqueue messages and entities

Libraries:
Simulink / Messages & Events
SimEvents

Alternative Configurations of Queue Block:
Entity Queue

Description

This block stores entities or messages in a queue, based on their order of arrival or priority. Each element at the head of the queue departs when the downstream block is ready to accept it.

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.

Examples

Ports

Input

expand all

Input 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

Output

expand all

Output 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

Number of entities that have departed the block.

Dependencies

To enable this port, in the Statistics tab, select the Number of entities departed, d check box.

Data Types: double

Number of entities that have not yet departed the block.

Dependencies

To enable this port, in the Statistics tab, select the Number of entities in block, n check box.

Data Types: double

Average wait time for entities in the block.

Dependencies

To enable this port, in the Statistics tab, select the Average wait, w check box.

Data Types: double

Port_l outputs the average length of the entity queue.

Dependencies

To enable this port, in the Statistics tab, select the Average queue length, l check box.

Data Types: double

Number of entities that are pulled out of this block.

Dependencies

To enable this port, in the Statistics tab, select the Number of entities extracted, ex check box.

Data Types: double

Parameters

expand all

Select this check box to choose between two queue overwriting policies.

Programmatic Use

Block Parameter:QueueOverwriting
Type: character vector
Values: 'on' | 'off'
Default:'on' (for Simulink) and 'off' (for SimEvents)

Specify the capacity of the queue.

Programmatic Use

Block Parameter:Capacity
Type: character vector
Values: '25' | scalar
Default:'25'

Choose the queue type.

Programmatic Use

Block Parameter:QueueType
Type: character vector
Values:'FIFO' | 'LIFO' 'Priority'
Default:'FIFO'

Specify the tag when accepting entities broadcast via multicast sources. The Entity Multicast block requires SimEvents license.

Dependencies

This parameter is visible when you clear the Overwrite the oldest element if queue is full check box, and setEntity arrival source toMulticast.

Programmatic Use

Block Parameter:MulticastTag
Type: character vector
Values: 'A' | character vector
Default:'A'

Specify the priority source either as a custom entity attribute that you created, or the entitySys.priority attribute, specifically.

For example, assume that you added two new attributes namedheight and width for an entity in the Entity Type tab of a Entity Generator block. These attributes appear as options, in the form of character vectors, for thePriority source parameter. The value of the parameters determine the entity priority.

Note

If you do not replace the default text prompt, PriorityAttribute, with a priority source, then the model generates an error during compilation.

Dependencies

This parameter is visible when you clear the Overwrite the oldest element if queue is full check box, and setQueue type toPriority.

Programmatic Use

Block Parameter:PrioritySource
Type: character vector
Values:'entity' |'entitySys.priority' character vector

Choose the direction of sorting based on priority.

Dependencies

This parameter is visible when you clear the Overwrite the oldest element if queue is full check box, and setQueue type toPriority.

Programmatic Use

Block Parameter:SortingDirection
Type: character vector
Values:'Ascending' | 'Descending'
Default:'Ascending'

Choose the source of arrival for the entities.

Dependencies

This parameter is visible when you clear the Overwrite the oldest element if queue is full check box.

Programmatic Use

Block Parameter:EntityArrivalSource
Type: character vector
Values: 'Input port' | 'Multicast'
Default: 'Input port'

Specify the behavior of the entity in certain events. Define the behavior in the Event action parameter. TheEntry and the Exit actions are called just after the entity entry and just before entity exit. TheBlocked action is called after an entity is blocked. For more information, see Events and Event Actions (SimEvents).

Note

If an event action changes an entity, related block behavior such as resorting a priority queue, and rescheduling of any events, will occur after the event action has fully finished and returned.

Note

Event actions do not support fixed point data type.

Dependencies

Event actions are visible when you clear the Overwrite the oldest element if queue is full check box.

Programmatic Use

Block Parameter:EntryAction, ExitAction, BlockedAction
Type: character vector
Values: MATLAB code
Default:''

Number of entities that have departed the block.

Dependencies

Number of entities departed, d is visible when you clear the Overwrite the oldest element if queue is full check box.

Programmatic Use

Block Parameter:NumberEntitiesDeparted
Type: character vector
Values: 'on' | 'off'
Default:'off'

Number of entities present in the block, but which are yet to depart.

Dependencies

Number of entities in block, n is visible when you clear the Overwrite the oldest element if queue is full check box.

Programmatic Use

Block Parameter:NumberEntitiesInBlock
Type: character vector
Values: 'on' | 'off'
Default:'off'

Sum of the wait times for entities departing the block divided by their total number. Wait time is the duration between theEntity Queue block entry and exit of an entity. For more information, see Interpret SimEvents Models Using Statistical Analysis (SimEvents).

Dependencies

Average wait, w is visible when you clear theOverwrite the oldest element if queue is full check box.

Programmatic Use

Block Parameter:AverageWait
Type: character vector
Values: 'on' | 'off'
Default:'off'

Accumulated time-weighted average queue size. The block computes this value by:

  1. Multiplying the size of the queue by its duration to calculate time-weighted queue size
  2. Summing up all time-weighted queue sizes and averaging them over total time

For more information, see Interpret SimEvents Models Using Statistical Analysis (SimEvents).

Dependencies

Average queue length, l is visible when you clear the Overwrite the oldest element if queue is full check box.

Programmatic Use

Block Parameter:AverageQueueLength
Type: character vector
Values: 'on' | 'off'
Default:'off'

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).

Dependencies

Number of entities extracted, ex is visible when you clear the Overwrite the oldest element if queue is full check box.

Programmatic Use

Block Parameter:NumEntitiesExtracted
Type: character vector
Values: 'on' | 'off'
Default:'off'

Block Characteristics

Data Types Boolean | bus double enumerated fixed point integer single string
Direct Feedthrough no
Multidimensional Signals yes
Variable-Size Signals no
Zero-Crossing Detection no

Alternative Configurations

expand all

The Entity Queue block clears the Overwrite the oldest element if queue is full parameter, sets theCapacity parameter to 25, and sets theQueue type parameter to FIFO.

Libraries:
Simulink / Messages & Events
SimEvents

Extended Capabilities

expand all

Code generation is not supported for event actions and statistics.

When you generate code for a model that contains a message queue and has multitasking enabled, enable concurrent tasking behavior if that model will be deployed to a multitasking environment. Otherwise, the generated code has the potential for data corruption. You enable concurrent tasking behavior by selectingAllow tasks to execute concurrently on target.

Version History

Introduced in R2016a