When a box wakes up from the funnel and enters the conveyor, the RR_Conveyor procedure is triggered. Its purpose is to initialize the entity's kinematic state, integrate it into the conveyor's causal topology, and determine whether it should assume any control role.
A. Kinematic Initialization
Upon entry, the box ceases to be a static entity and becomes a kinematic vector. Three critical attributes are assigned using ASSIGN:
- RR_Time: The exact entry time (
AC1$). - RR_Position: Initial position (0, the entrance).
- RR_Moving: Active state (1).
In addition, its topological references are initialized, describing the neighboring boxes within the conveyor:
- RR_PackFront
- RR_PackRear
Immediately afterward, the system forces an admission reevaluation (RR_EntryTimeout) in case boxes are waiting in RR_InputBuffer.
B. Insertion into the Topology
The conveyor maintains an explicit causal topology through a doubly linked list.
Each new box is always inserted behind the system's current tail:
- If the conveyor is empty, the entity simultaneously becomes RR_EntityLeader and RR_EntityTail.
- If boxes are already present, the new entity is linked to the current tail through RR_PackFront and RR_PackRear.
After insertion, RR_EntityTail points to the new box.
Thanks to this structure, the resource always knows which entity is closest to the exit and which is closest to the entrance, without needing to traverse the conveyor.
C. Recovery of Stop Propagation
The entry of a new box may reveal a special situation.
If a stop propagation is active and the entity immediately ahead is stopped, this means there is a pending stop whose temporal chain has disappeared.
This scenario can occur when a new box enters behind an entity that is already stopped.
In that case, the newly arrived entity itself reactivates the propagation through a new RR_StopTimeout, allowing the logic to continue exactly where it was interrupted.
D. Exit Ownership
Conveyor exit follows a single-ownership policy.
Only the entity closest to the exit can own the prediction of leaving the conveyor.
Therefore:
- If entities are already inside the conveyor, the new box enters a passive state and does not schedule any additional event.
- If it is the only entity present, it assumes the role of RR_LeavingEntity.
In the latter case, it calculates the travel time to the end of the conveyor and schedules an RR_ExitTimeout.
Note that the entity does not schedule its exit as a guaranteed future action. What it schedules is the next known reevaluation of the exit state under the system's current regime.
Example
PROCEDURE RR_Conveyor
assign RR_Time,AC1$
assign RR_Time,AC1$,P$ENTITYNUMBER
assign RR_Position,0,P$ENTITYNUMBER
assign RR_Moving,1,P$ENTITYNUMBER
assign RR_PackFront,0,P$ENTITYNUMBER
assign RR_PackRear,0,P$ENTITYNUMBER
savevalue RR_EntryLimit,0
; double linked list
if (X$RR_EntityTail == 0)
savevalue RR_EntityLeader, P$ENTITYNUMBER
else
assign RR_PackFront, X$RR_EntityTail, P$ENTITYNUMBER
assign RR_PackRear, P$ENTITYNUMBER, X$RR_EntityTail
endif
savevalue RR_EntityTail, P$ENTITYNUMBER
if (R$(RR_InputBuffer,IN)>0)
timeout RR_EntryTimeout,0
endif
call setStatusDisplay
; check active stop limit against new entity
assign front,P$(RR_PackFront,P$ENTITYNUMBER)
if (X$RR_StopLimit > X$RR_Length * -1 && P$(RR_Moving,P$front)==0 && P$front!=0)
;ASSIGN msg,{operation:"write",value:"RR_Conveyor Orphan stop detected. Front entity P$front is stopped. Re-triggering stop propagation."}
;EXEC_MEDIA {name:logUI,in:V$msg}
savevalue RR_StopRegimeVersion, X$RR_StopRegimeVersion + 1
timeout RR_StopTimeout,0,X$RR_StopRegimeVersion
endif
; only first entity schedules exit ownership
if (R$(RR_Conveyor,IN)>1)
terminate_ve
endif
assign time, ceil( X$RR_Length / X$RR_Speed , X$RR_decimals)
savevalue RR_LeavingEntity,P$ENTITYNUMBER
savevalue RR_ExitRegimeVersion, X$RR_ExitRegimeVersion + 1
timeout RR_ExitTimeout,P$time,X$RR_ExitRegimeVersion,44444
TERMINATE_VE
ENDPROCEDURE