process TV

define COUNT as an integer variable


let LOCATION.A(TV) = LOCATION.F(ENTER.X, INSPECTOR.Y)
let VELOCITY.A(TV) = VELOCITY.F(TV.VELOCITY, 0)
wait TIME(.TO.ENTER) units

'LOOP'

let VELOCITY.A(TV) = 0

let LOCATION.A(TV) = LOCATION.F(QUEUE.X,
INSPECTOR.Y + N.Q.INSPECTOR * TV.SIZE)

request 1 INSPECTOR

let LOCATION.A(TV) = LOCATION.F(INSPECTOR.X, INSPECTOR.Y)

let COUNT = 0
for each QC.E in Q.INSPECTOR do
    let LOCATION.A(WHO.A(QC.E)) = LOCATION.F(QUEUE.X,
    INSPECTOR.Y + COUNT * TV.SIZE)
    add 1 to COUNT
loop

wait TIME(.TO.INSPECT) units

relinquish 1 INSPECTOR

if PASSED.INSPECTION = .TRUE
    let LOCATION.A(TV) = LOCATION.F(PASS.X, INSPECTOR.Y)
    let VELOCITY.A(TV) = VELOCITY.F(TV.VELOCITY, 0)
    wait TIME(.TO.EXIT) units
    return
otherwise

let LOCATION.A(TV) = LOCATION.F(INSPECTOR.X, FAIL.Y)
let VELOCITY.A(TV) = VELOCITY.F(TV.VELOCITY, - PI.C / 2)
wait TIME(.TO.GOTO.ADJUSTMENT) units

let VELOCITY.A(TV) = 0

let LOCATION.A(TV) = LOCATION.F(QUEUE.X,
ADJUSTOR.Y - N.Q.ADJUSTOR * TV.SIZE)

request 1 ADJUSTOR

let LOCATION.A(TV) = LOCATION.F(ADJUSTOR.X, ADJUSTOR.Y)

let COUNT = 0
for each QC.E in Q.ADJUSTOR do
    let LOCATION.A(WHO.A(QC.E)) = LOCATION.F(QUEUE.X,
    ADJUSTOR.Y - COUNT * TV.SIZE)
    add 1 to COUNT
loop

wait TIME(.TO.ADJUST) units

relinquish 1 ADJUSTOR

let LOCATION.A(TV) = LOCATION.F(ADJUSTOR.X, ADJUSTED.Y)
let VELOCITY.A(TV) = VELOCITY.F(TV.VELOCITY, PI.C / 2)
wait TIME(.TO.GOTO.INSPECTION) units

go to 'LOOP'

end
