The Scheduler is used to route between segments with contact. Each train is scheduled individually without looking at the other trains. Other trains may only influence the schedule through the inputs route and train_on_track. Following inputs are used to achieve this:



initial_position

Send by Controller as input, only used in first tick and never after. determines the starting position of a train and has to be a segment.

final_station

Send by Controlleras input. This may be influenced by the deadlock avoidance if necessary (forces a destination on blocking trains that do not have a destination).

current_position

Send by hardware abstraction to determine the current segment.

reached

Send by hardware abstraction to signal, that the segment specified by next_segment was reached.

route

May be 0 or 1. From every station it is possible to take two different routes to a different station. If route is 0 the normal "shortest" (the path that passes less stations) is used. 1 is used to signal that an alternative route should be used. It is set by the deadlock prevention

train_on_track

send by hardware abstraction to check if some tracks are blocked. Only relevant for driving to an alternative platform if current platform is in use.

lock_XX

Set by deadlock prevention to lock specific segment transition in KH and to KIO


Relevant Scheduler Outputs

Describes the outputs that are relevant for other parts of the controller. This is a deeper explanation of why a train drives in a specific way.

(pre_)next_segment

Used by hardware abstraction to determine what tracks need to be to reservated and what tracks need to be powered. Its is also used by deadlock prevention to set 

route

 or set 

final_station

moving

Boolean that signals whether a train intends to move. May be true for trains that are not moving physically if they are blocked in any way (either by hardware abstraction or one of lock_XX).


The Scheduler uses following internal variables to determine the location and state of each train:

  • station (output): The final_station the train is currently heading to. Only updated if the train reached a station. A train may not change station while not being in a station.
  • taken_route: The route the train is currently using. Only updated if the train reached a station. A train may not change station while not being in a station.
  • still_moving: Boolean used to signal that regardless whether next_segment = NO_DESTINATION, a train still has a destination he is heading to.
  • not_in_station: Only set in first tick, if initial position is no platform. Used to handle the special cases that can happen. Only used till a station was reached.
  • only_passing_by: Signals that a train does not want to enter a specific platform in a station. Mostly used if train has to pass a station to reach his final station
  • station_position (output): The last station a train has visited. Is set to possible previous station if initial_position is no platform
  • substation (output): next platform/station a train should head to. If substation is not equal to station the station is used instead of a specific platform.

The station_position, station and taken_route (and not_in_station till first station is reached) to determine the next substation. current_position and substation (and lock_XX, only_passing_by) are used  to determine the next_segment.

Tags:
Created by stu114053 on 2017/08/17 13:08