Arrays and Buffers

Queue Parts for Processing

medium

Queues up to four part IDs and releases them in arrival order.

What it teaches

When the next machine is busy, parts wait in line and leave in the order they arrived. In_Load and In_Unload act once each time they turn on. Holding one on does not load or unload again. A part ID can be 0, and empty slots are 0 too, so keep a count of stored parts rather than reading it off the array. Peek shows which part leaves next without removing it.

Parameters

TagDirectionTypeDefaultDescription
In_LoadInputBOOL0Request to add an ID
In_UnloadInputBOOL0Request to remove an ID
In_PartIdInputDINT101ID to add; every DINT value, including 0, is valid
In_ResetInputBOOL0Clear storage and results
Out_PartIdOutputDINT0Last successfully removed ID
Out_PeekOutputDINT0Next ID to remove, or 0 when empty
Out_CountOutputDINT0Number of stored IDs
Sts_EmptyOutputBOOL01 when no IDs are stored
Sts_FullOutputBOOL01 when four IDs are stored
Ref_PartsInOutDINT[4]Four IDs in loading order, oldest at index 0; unused slots are 0

Required behavior