This procedure, executed by a VE, is responsible for deciding whether a box can leave the funnel and enter the conveyor or whether it must reschedule its attempt.
Evaluation Mechanics:
First, it identifies which box is attempting to enter, either through the received parameter or, if the process is being reactivated, through the first pending entity in RR_InputBuffer.
Next, it identifies the tail box (the last one to enter RR_Conveyor), since its physical rear position defines the actual admission limit. Thanks to the causal topology maintained by the resource, this reference is obtained directly through RR_EntityTail, without needing to traverse the conveyor.
From that point, four scenarios are evaluated:
- Empty Conveyor: If there is no one on the conveyor, entry is immediate.
- Sufficient Space: If the distance between the entrance and the rear of the last box is sufficient, the box enters.
- Blocked by a Stop: If there is not enough space and the limiting box is stopped (due to a jam), the timeout becomes invalid. The VE saves the ID of the waiting box in RR_EnteringEntity and terminates. The process will resume only when the conveyor starts moving again.
- Blocked While Moving: If the limiting box is moving but has not yet created enough space, the exact reevaluation time is calculated based on its speed.
Note that RR_EntryTimeout does not guarantee entry at the scheduled time: it only guarantees that this is the next moment when the geometry might allow it. If the limiting box stops before then, the timeout becomes invalid.
Example
PROCEDURE RR_EntryTimeout
assign ENTITYNUMBER,P$PARAM_A
if (P$ENTITYNUMBER == 0 )
FOREACH entityNumber,IN_RESOURCE,RR_InputBuffer
if (P$ENTITYNUMBER == 0 )
assign ENTITYNUMBER, P$entityNumber
endif
ENDFOREACH
endif
if (P$ENTITYNUMBER == 0 )
terminate_ve
endif
; find entity closest to conveyor init
assign tailEntity,X$RR_EntityTail
if (P$tailEntity == 0)
savevalue RR_EntryLimit,0
WAKE RR_InputBuffer,-1,P$ENTITYNUMBER
terminate_ve
endif
; calculate current position
assign advance, P$(RR_Position,P$tailEntity) + (AC1$ - P$(RR_Time,P$tailEntity)) * X$RR_Speed * P$(RR_Moving,P$tailEntity)
savevalue RR_EntryLimit,P$advance - P$(RR_Length,P$tailEntity) *0.5
; entity fully entered conveyor
IF (P$advance - P$(RR_Length,P$tailEntity) *0.5 >= P$(RR_Length,P$ENTITYNUMBER) * 0.5 + X$RR_Gap)
savevalue RR_EntryLimit,0
WAKE RR_InputBuffer,-1,P$ENTITYNUMBER
terminate_ve
ENDIF
; entity stopped moving, timeout loses validity
if (P$(RR_Moving,P$tailEntity)==0)
;ASSIGN msg,{operation:"write",value:"RR_EnteringEntity Saving P$ENTITYNUMBER"}
;EXEC_MEDIA {name:logUI,in:V$msg}
savevalue RR_EnteringEntity,P$ENTITYNUMBER
TERMINATE_VE
endif
; entity has not fully entered yet
assign remainingToEnter, ceil( (P$(RR_Length,P$ENTITYNUMBER) * 0.5 + (P$(RR_Length,P$tailEntity) *0.5 + X$RR_Gap) - P$advance) / X$RR_Speed, X$RR_decimals)
timeout RR_EntryTimeout, P$remainingToEnter, P$ENTITYNUMBER
TERMINATE_VE
ENDPROCEDURE