graphic_.png

Environment:

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

    • 1: forwards

    • 2: backwards

    • 3: uni

  • cross_contacts: int[]
    • 0: no signal

    • 1: closing

    • 2: opening

User:

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

    • value: train number, negativ for backwards driving trains

  • destination: int[]
    • index. train number

    • value: track number

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

    • index: 0-3

    • value: 1-127

Controller:

  • track_speeds: int[TRACK_SEGMENTS][2]
    • 0: off

    • 1 to 127: forward speed

    • -1 to -127: backward speed

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

    • 1: red

    • 2: yellow

    • 3: green

  • lamps: bool[]
    • 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[]
    • index: train number

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

Scheduler:

  • schedule: int[]
    • 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[TRACK_SEGMENTS];
  // State of all switches
  input bool points[NUM_POINTS];
  // State of all signals
  input int signals[TRACK_SEGMENTS][2];
 
  //------------------------------------------------------------\\
  //--                       OUTPUTS                          --\\
  //------------------------------------------------------------\\
  // State of all contacts of the railway
  output int track_contacts[TRACK_SEGMENTS][2];
 
  //------------------------------------------------------------\\
  //--                  RAILWAY  CONSTANTS                    --\\
  //------------------------------------------------------------\\
  const int TRACK_SEGMENTS = 48;
  const int NUM_TRAINS = 11;
  const int NUM_POINTS = 28;
  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: