interface.png

Errors:

  • collision_error
    • -1: no error
    • other values: a single track with multiple trains
  • train_speed_mismatch_error[NUM_TRAINS]
    • -1: no error
    • 1: the front and rear wagon have different speeds
  • train_point_changed_error[NUM_TRAINS]
    • indicates, that a point was changed while the train was standing on it,
      i.e., the front passed the point, but the rear not yet.
    • -1: no error
    • other values: the point that has the error
  • wagon_error_message[NUM_TRAINS][2]
    • -1: no error
    • 1: point not set correctly
    • 2: wagon uses wrong direction on KH_LN_2 or KH_LN_7, because the corresponding point was set wrongly
    • 3: wagon position under min of track (indicates a mistake in the environment)
    • 4: wagon position over max of track (indicates a mistake in the environment)
    • 5: diamond point set to send a train backwards through IC or OC. May cause further unexpected behavior
  • wagon_error_pos[NUM_TRAINS][2]
    • NOTE: The meaning depends on wagon_error_message.
    • if wagon_error_message is 0
      • this error can be ignored
    • if wagon_error_message is 1, 2 or 5
      • the point on which the error occurs
    • if wagon_error_message is 3 or 4
      • the track on which the error occurs

Environment:

  • track_contacts: int[NUM_TRACKS][2]
    • 0: no signal

    • 1: forwards

    • 2: backwards

    • 3: uni

  • cross_contacts: int[NUM_CONTACTS]
    • 0: no signal

    • 1: closing

    • 2: opening

User:

  • train_setup: int[NUM_TRAINS] 
    • index: train number

    • value: track number, (negative: train stands against main travel direction)

  • destination: int[NUM_TRAINS]
    • index. train number

    • value: track number

  • speeds: int[NUM_TRAINS][4]
    • index: train number

    • index: 0-3

    • value: 1-127

Controller:

  • track_speeds: int[NUM_TRACKS]
    • 0: off

    • 1 to 127: forward speed

    • -1 to -127: backward speed

  • signals: int[NUM_TRACKS][2]
    • 0: off

    • 1: red

    • 2: yellow

    • 3: green

  • lamps: bool[NUM_LAMPS]
    • true: on

    • false: off

  • cross_light: int
    • 0: off

    • 1: red

    • 2: yellow

  • bell: bool
    • true: on

    • false: off

  • points: bool[NUM_POINTS]
    • true: branch

    • false: straight

  • gate: bool
    • true: down

    • false: up

  • reached: bool[NUM_TRAINS]
    • index: train number

    • value: true: destination reached; false: destination not yet reached

Scheduler:

  • schedule: int[NUM_TRAINS]
    • index: train number

    • value: next save track on the way to destination

Controller-Environment Interface
scchart environment {

  //------------------------------------------------------------\\
  //--                       INPUTS                           --\\
  //------------------------------------------------------------\\
  // Initial track of the trains
  input int train_setup[NUM_TRAINS];
  // Speed of all tracks
  input int track_speeds[NUM_TRACKS];
  // State of all switches
  input bool points[NUM_POINTS];
  // State of all signals
  input int signals[NUM_TRACKS][2];
 
  //------------------------------------------------------------\\
  //--                       OUTPUTS                          --\\
  //------------------------------------------------------------\\
  // State of all contacts of the railway
  output int track_contacts[NUM_TRACKS][2];
 
  //------------------------------------------------------------\\
  //--                  RAILWAY  CONSTANTS                    --\\
  //------------------------------------------------------------\\
  const int NUM_TRACKS = 48;
  const int NUM_TRAINS = 11;
  const int NUM_POINTS = 30;
  const int NUM_LAMPS = 24;
  const int NO_TRACK = -1;
 
  //------------------------------------------------------------\\
  //--                  RAILWAY  INTERFACE                    --\\
  //------------------------------------------------------------\\
  const int OFF = 0, RED = 1, YELLOW = 2, GREEN = 4;
  const int ON  = 1, OFF = 0, FWD    = 1, REV   = 2, BRAKE = 3;
 
  const int DOWN = 0, UP = 1;
  const int NONE = 0, UNI = 3;
 
  const int STRAIGHT = 0, BRANCH = 1;
 
  const int IC_JCT_0 = 0 , IC_LN_0  = 1 , IC_LN_1 = 2 , IC_LN_2 = 3;
  const int IC_LN_3  = 4 , IC_LN_4  = 5 , IC_LN_5 = 6 , IC_ST_0 = 7;
  const int IC_ST_1  = 8 , IC_ST_2  = 9 , IC_ST_3 = 10, IC_ST_4 = 11;
  const int IO_LN_0  = 12, IO_LN_1     = 13, IO_LN_2 = 14;
 
  const int KH_LN_0  = 15, KH_LN_1     = 16, KH_LN_2 = 17, KH_LN_3 = 18;
  const int KH_LN_4  = 19, KH_LN_5     = 20, KH_LN_6 = 21, KH_LN_7 = 22;
  const int KH_LN_8  = 23, KH_ST_0     = 24, KH_ST_1 = 25, KH_ST_2 = 26;
  const int KH_ST_3  = 27, KH_ST_4  = 28, KH_ST_5 = 29, KH_ST_6 = 30;
  const int KIO_LN_0 = 31, KIO_LN_1 = 32;
 
  const int OC_JCT_0 = 33, OC_LN_0     = 34, OC_LN_1 = 35, OC_LN_2 = 36;
  const int OC_LN_3  = 37, OC_LN_4     = 38, OC_LN_5 = 39, OC_ST_0 = 40;
  const int OC_ST_1  = 41, OC_ST_2     = 42, OC_ST_3 = 43, OC_ST_4 = 44;
  const int OI_LN_0  = 45, OI_LN_1     = 46, OI_LN_2 = 47;

  initial state init;
}
Tags: