Queue
Overview and Key Concepts
The queue is used to store flow items when a downstream object cannot accept them yet. By default, the queue works in a first-in-first-out manner, meaning that when the downstream object becomes available, the flow item that has been waiting for that object the longest will leave the queue first. The queue has options for accumulating flow items into a batch before releasing them.
The queue is a fixed resource. It will continue to receive flow items until it reaches its maximum content. If batching is disabled, the queue will release the flow item as soon as it arrives in the queue, and the OnEndCollecting trigger will be called right before each flow item is released.
Batching
If batching is enabled, then the queue will wait until it receives its target batch of flow items, then it will release all the flow items in the batch at the same time. By default the maximum wait time is 0. A max wait time of 0 means that there is no max wait time, or the queue will wait indefinitely to collect its batch. If the max wait time is non-zero, then when the first flow item arrives, the queue will start a timer. If at the end of the timer the batch is still not met, the queue will finish collecting the batch and release all flow items it collected.
The OnEndCollecting trigger is called just before the flow items are released, a reference to the first flow item in the batch is passed as item, and the number of items collected is passed as param(2). If the queue is configured to flush contents between batches, then it will close its input ports as soon as it ends collecting a batch, and will wait until the full batch has exited before opening the input ports again. If the queue doesn't flush contents between batches, then if will immediately start collecting another batch as soon as it finishes collecting each batch. This means that you can have several finished batches still in the queue at any given time, waiting to leave.
Events
For information on events, see the Event Listening page.
The queue uses the standard events that are common to all fixed resources. See Fixed Resources - Events for an explanation of these events.
The queue has the following additional events:
On End Collecting
This event occurs when the queue completes a batch of items, before the items leave the queue.
It has the following parameters:
Event Parameter | Type | Explanation |
---|---|---|
Entering Item | Object | A reference to the last flow item in the batch. |
Batch Size | int | The number of flow items in the batch. |
States
For statistical purposes, the queue will be in one of the following states at various points during a simulation run. The current state can be viewed by clicking on the object and then viewing the Statistics pane in Quick Properties.
Empty
The queue is empty.
Collecting
The queue is collecting flow items for a batch.
Releasing
The queue has finished collecting its batch(es) and is releasing the flow items that it has. Also if the queue is not batching, and has flow items in its queue, it will be in this state.
Waiting for Transport
The queue has flow items that have been released and are ready to move downstream, but are waiting for a transport to come and pick them up.
Statistics
The queue uses the standard statistics that are common to all fixed resources. See Fixed Resources - Statistics for an explanation of these statistics.
Properties
The queue object has five tabs with various properties. The last four tabs are the standard tabs that are common to all fixed resources. For more information about the properties on those tabs, see:
Only the Queue tab is unique to the queue object. The properties on this tab will be explained in more detail in the following sections.
Maximum Content
This is the maximum number of flow items the queue can hold at once.
LIFO
If this box is checked the queue will act as a "last in first out" (LIFO) queue, otherwise it will act as a first in first out (FIFO) queue.
Batching
These fields define the queue's batching abilities:
- Perform batching - If this box is checked, the queue will accumulate flow items into a batch before releasing them downstream. Accumulation continues until either the target batch size is met or the max wait time expires. If this box is not checked, no batching will occur, and flow items may leave as soon as downstream objects are available.
- Target Batch Size - This number defines the size of the batches that the queue will gather before sending the flow items downstream. Flow items are sent downstream individually.
- Max Wait Time - This number is the maximum length of time that the queue will wait before sending the flow items downstream. If this time expires and the batch size has not been met, the currently collected batch will be released anyway. If 0 is specified in this field, then there is no maximum wait time, or in other words the queue will wait indefinitely.
- Flush contents between batches - If this box is checked the queue will not allow new flow items to enter until the entire current batch has left.
Visual
These properties define how the queue locates the flow items within itself when they enter:
- Item Placement - This menu defines how the flow items
are placed in the queue visually. It has the following options:
- Stack Vertically The flow items are stacked on top of each other. The flow item at the bottom of the pile is the one that has been in the queue the longest.
- Horizontal Line - The flow items are lined up horizontally. The one closest to the output ports of the queue is the one that has been in the queue the longest.
- Stack inside Queue - The flow items are stacked in rows inside the queue. The flow items will move if a product ranked before them is taken out of the queue. If you would like the product positions to stay the same once they are in the queue, then have the queue be LIFO by having downstream objects pull only the last product in the queue.
- Do Nothing - Flow items are all placed at the same point in the queue. This may make it appear as if the queue is only holding one flow item.
- Stack Base Z - This number defines the height where the queue begins placing flow items that are being stacked vertically or inside the queue.