preamble             ''PacShip:  Pacific Shipping Simulation

'' Author:  Ron Sweet, April 1987
''   based upon GRPORT, written by Garth Morgan, March 1986, as
''                      revised by Ed Russell, March 1987

   normally mode is undefined

   processes include FINAL.REPORT
      every TUG
         has a TUG.PORT                   ''port TUG belongs to; must be 1st
         and a TUG.STATUS
         and a TUG.LOCATION
         and a TUG.SHIP.IN.TOW            ''pointer to SHIP being towed
         and owns a TUG.QUEUE
      define TUG.PORT, TUG.SHIP.IN.TOW, TUG.COLOR, TUG.STATUS, TUG.LOCATION
             as integer variables
      define TUG.QUEUE as a fifo set

      every SHIP
         has a SHIP.PORT                  ''port SHIP is currently in, if any
         and a SHIP.TYPE
         and a SHIP.SPEED
         and a SHIP.DIRECTION
         and a SHIP.LOCATION
         and a SHIP.BERTH                 ''index of SHIP's assigned BERTH
         and a SHIP.DESTINATION.PORT
         and may belong to a TUG.QUEUE
         and may belong to a PORT.HARBOR  ''for displaying SHIPs in HARBOR
      define SHIP.PORT, SHIP.LOCATION, SHIP.BERTH and SHIP.DESTINATION.PORT
       as integer variables
      define FREIGHTER.ICON, TANKER.ICON as 3-dim real arrays
      define SHIP.DIRECTION and SHIP.SPEED as real variables
      define SHIP.TYPE as a text variable

   resources include DOCK

   temporary entities
      every DAYS
         has a DAY.A
      define DAY.A as an integer variable

      every HOURS
         has an HOUR.A
      define HOUR.A as an integer variable

      every MINUTES
         has a MINUTE.A
      define MINUTE.A as an integer variable

      every SHIP.COUNTER
         has a SHIP.COUNTER.PORT
      define SHIP.COUNTER.PORT as an integer variable

      every BERTH                         ''to manage docked SHIP display
         has a BERTH.STATUS
         and a BERTH.PORT
         and a BERTH.X.LOCATION
         and a BERTH.Y.LOCATION
         and belongs to a PORT.BERTH.SET
      define BERTH.STATUS and BERTH.PORT as integer variables
      define BERTH.X.LOCATION as a real variable
      define BERTH.Y.LOCATION as a real variable

   permanent entities
      every PORT
         has a PORT.TUG
         and a PORT.NO.OF.BERTHS
         and a PORT.DOCKS.IN.USE
         and a PORT.IN.PORT.TIME
         and a PORT.SHIP.COUNTER
         and a PORT.X.LOCATION
         and a PORT.Y.LOCATION
         and a PORT.X.ENTRANCE
         and a PORT.Y.ENTRANCE
         and a PORT.NAME
         and a PORT.LOADING.TIME random step variable
         and owns a PORT.HARBOR
         and owns a PORT.BERTH.SET
      define PORT.NO.OF.BERTHS and PORT.DOCKS.IN.USE
       as integer variables
      define PORT.NAME as a text variable
      define PORT.TUG and PORT.SHIP.COUNTER as pointer variables
      define PORT.IN.PORT.TIME, PORT.LOADING.TIME, PORT.X.LOCATION,
       PORT.Y.LOCATION, PORT.X.ENTRANCE, PORT.Y.ENTRANCE as real variables
      define PORT.HARBOR and PORT.BERTH.SET as fifo sets

   dynamic graphic entities include SHIP, ICON and TUG
   graphic entities include SHIP.COUNTER 

   define NO.OF.PORTS, NO.OF.FREIGHTERS, NO.OF.TANKERS, RUN.LENGTH,
    COMPRESS.TIME, and TIMESCALE as integer variables
   define INIT.X1, INIT.Y1, INIT.X2, INIT.Y2 as real variables
   define WORLDS as a 2-dim real array

   accumulate AVG.DOCK.QUEUE as the average
      and MAX.DOCK.QUEUE as the maximum of N.Q.DOCK
   accumulate DOCK.UTILIZATION as the average of PORT.DOCKS.IN.USE
   accumulate AVG.TUG.QUEUE as the average
      and MAX.TUG.QUEUE as the maximum of N.TUG.QUEUE
   accumulate TUG.UTILIZATION as the average of TUG.STATUS
   tally AVG.IN.PORT.TIME as the average
      and MAX.IN.PORT.TIME as the maximum
      and NO.OF.SHIPS.SERVED as the number of PORT.IN.PORT.TIME

   define .END.OF.SIMULATION to mean TIME.V >= RUN.LENGTH
   define .IN.HARBOR to mean 1
   define .AT.DOCK to mean 2
   define .AT.SEA to mean 3
   define .IDLE to mean 0
   define .BUSY to mean 1
   define .SKIP.TEXT to mean while mode is text, skip 1 field

   define ..YES to mean 1
   define ..NO to mean 2

   define .TRUE to mean 1
   define .FALSE to mean 0

   ''transform numbers
   define .TITLE.TRANSFORM to mean 1
   define .OCEAN to mean 2
   define .PORT.TRANSFORMS to mean 3

end   ''preamble
