Process LIFT

  '' Goldmine Simulation                                       August 2, 1988
  '' CACI Products Company

  '' This process manages the lift operations.


  Define LIFTSPEED as a real variable


  Let LIFTSPEED = 100.0/3.0  ''ft/min

  Until TIME.V ge STOP.TIME*60 do
    ''Descend to level 2
    Let VELOCITY.A(LIFT) = VELOCITY.F(LIFTSPEED, -PI.C/2)
    Let LIFT.STATUS(LIFT) = "DOWN"
    Wait 3 MINUTES

    If LOAD.QUEUE(1) is not empty or LOAD.QUEUE(2) is empty
      ''Descend to level 1
      Wait 3 MINUTES
      Let VELOCITY.A(LIFT) = 0                             

      ''If level 1 queue is empty then stop the lift
      If LOAD.QUEUE(1) is empty
        Let LIFT.STATUS(LIFT) = "STOP"
        Suspend
      Endif

      ''Load the lift while removing gold from level 1 queue
      Let LIFT.STATUS(LIFT) = "LOAD"
      Until N.LIFT.LOAD eq LIFT.CAPACITY or LOAD.QUEUE(1) is empty do
        Remove the first LOAD from LOAD.QUEUE(1)
        Erase LOAD '' disappear
        File this LOAD in LIFT.LOAD
        Display LIFT
        Wait UNIFORM.F(0.75, 1.25, 1) MINUTES
      Loop

      ''Ascend to level 2
      Let VELOCITY.A(LIFT) = VELOCITY.F(LIFTSPEED, PI.C/2)      
      Let LIFT.STATUS(LIFT) = "UP"
      Wait 3 MINUTES
    Endif

    If LOAD.QUEUE(2) is not empty and N.LIFT.LOAD lt LIFT.CAPACITY
      Let VELOCITY.A(LIFT) = 0                                  

      ''Load the lift while removing gold from level 2 queue
      Let LIFT.STATUS(LIFT) = "LOAD"
      Until N.LIFT.LOAD eq LIFT.CAPACITY or LOAD.QUEUE(2) is empty do
        Remove the first LOAD from LOAD.QUEUE(2)
        Erase LOAD '' disappear
        File this LOAD in LIFT.LOAD
        Display LIFT                                      
        Wait uniform.f(0.75, 1.25, 1) MINUTES
      Loop
    Endif

    ''Ascend to the surface
    Let VELOCITY.A(LIFT) = VELOCITY.F(LIFTSPEED, PI.C/2) 
    Let LIFT.STATUS(LIFT) = "UP"
    Wait 3 MINUTES
    Let VELOCITY.A(LIFT) = 0

    ''Unload the lift
    Let LIFT.STATUS(LIFT) = "UNLOAD"
    Let CONTENTS = N.LIFT.LOAD
    Until LIFT.LOAD is empty do
      Remove the first LOAD from LIFT.LOAD
      Destroy this LOAD
      Display LIFT                               
      Wait UNIFORM.F(0.75, 1.25, 1) MINUTES
    Loop
  Loop

  Activate a FINAL.REPORT now


End ''LIFT
