ObjectType
Document
DocName Project Version FullName ShortDescription
CrossingCtrl RailwayCrossing V2
 
Description
This control object type together with TrackCtrl realizes the core of the control functionality of the railway crossing.

The following strategies can be distinguished:

  • TrainsPrec: all trains take precedence over cars
  • CarsPrec: the cars take precedence over trains (if gate can safely be opened)
  • CarsFTPrec: fast trains, then cars take precedence
  • UserHalt: all trains halt (get the stopping signal)
CrossingCtrl receives requests from each track for setting the respective signal (go/halt). Depending on the selected strategy and the constraints (nbr. of cars waiting, ...), CrossingCtrl can allow a track to change the signal state to go, thus allowing the trains to precede past the gate. Further, the gate is openend if all tracks have set their signals to halt (the tracks automatically keep the signals in the 'halt' state, when all trains past sensor ts1 have left the crossing area, i.e. passed sensor ts2).
 
Components
ModelName Number Type
gate 1 GateCtrl
tracks n TrackCtrl
road 1 RoadCtrl
 
Tasks
ModelName Description Strategy StrategyType RealizedRequirements
CrossingCtrlTask1 Initializing the Controller During the initilization phase (curMode = init), receive initTracks with the appropiate parameters, create the given number of tracks and increment curTrackNbr. Store the new tracks in the tracks-field and set the signal of each track to Halt. Stop initializing by receiving initTracksDone and switch curMode to CPFTOpened.
CrossingCtrlTask2 Receiving noTrains Receive noTrains with the given track t1. Set tracks(t1).train to false.
CrossingCtrlTask3 Monitoring the cars waiting Receive newCars and set the carsWait-variable to the given value
CrossingCtrlTask4 Realizing the strategy Train Precedence If the gate is closed (TPClosed), and a train approaches the signal (askForGo) on the given track t1, set tracks(t1).train to true and set the signal to go by sending setSignalState with go. If the gate is opened (TPOpened), and a train approaches, close additionally the gate by sending setGate with closed.
If the gate is closed (TPClosed), and a newSignalState is received, store the signal state of the given track and check the signals of all the tracks. If they all are set to Halt, open the gate (setGate) and switch to TPOpened, otherwise stay in TPClosed. If the gate is opened, and newSignalState is received, set only the signal of the given track to the given state. 
CrossingCtrlTask5 Realizing the strategy Cars Precedence If the gate is closed (CPClosed), and a train approaches the signal (askForGo) on the given track t1, set tracks(t1).train to true and set the signal to go by sending setSignalState with go, iff there are cars waiting (carsWait). If the gate is opened (CPOpened), and a train approaches, close additionally the gate by sending setGate with closed, if there are no cars waiting (carsWait). 
If the gate is closed (CPClosed), and a newSignalState is received, set the signal of the given track to the given state and check the signals of all the tracks. If they all are set to Halt, open the gate (setGate) and switch to CPOpened, otherwise stay in CPClosed. If the gate is opened, and newSignalState is received, set only the signal of the given track to the given state.
If the gate is opened (CPOpened), and the value of carsWait switches to False, set the signal state to Go of all these tracks, on which a train is waiting. If there was one or more track with waiting trains, close the gate (setGate).
CrossingCtrlTask6 Realizing the strategy Fast Trains, then Cars Precedence If the gate is closed (CPFTClosed), and a train approaches the signal (askForGo) on the given track t1, set tracks(t1).train to true and set the signal to go by sending setSignalState with go, iff there are no cars waiting (carsWait) and the given track is a track with fast trains. If the gate is opened (CPFTOpened), and a train approaches, close additionally the gate by sending setGate with closed, if there are no cars waiting (carsWait) or a fast train approaches. 
If the gate is closed (CPFTClosed), and a newSignalState is received, store the signal state of the given track and check the signals of all the tracks. If they all are set to Halt, open the gate (setGate) and switch to CPFTOpened, otherwise stay in CPFTClosed. If the gate is opened, and newSignalState is received, set only the signal of the given track to the given state.
If the gate is opened (CPFTOpened), and the value of carsWait switches to False, set the signal state to Go of all these tracks, on which a train is waiting. If there was one or more track with waiting trains, close the gate (setGate).
CrossingCtrlTask7 Realizing the strategies, where the user controls the gate If a train approaches the signal (askForGo) on the given track t1, set tracks(t1).train to true. If a newSignalState is received, store the signal state of the given track. This strategy takes place for both user control states (UHOpened, UGClosed)
CrossingCtrlTask8 Switching between different strategies If the gate is closed (state is TPClosed, CPClosed, CPFTClosed, UGClosed), and the mode is set to TrainsPrec or CarsPrec or UserHalt, set the gate to opened, if no trains are waiting. If trains are waiting, and the desired mode is UserHalt, send a message to the user. If the desired mode is CarsFTPrec, set the gate to opened, if there are waiting cars and no waiting fast trains. Otherwise set the signal to Go of all tracks, on which trains are waiting (setSignalState).  If the gate becomes opened, switch to the corresponding Opened-State (TPOpened, CPOpened, CPFTOpened, UHOpened).
If the gate is opened, (state is TPOpened, CPOpened, CPFTOpened, UHOpened), and the mode is set to TrainsPrec, set the signal state to Go of all these tracks, on which a train is waiting. If there was one or more track with waiting trains, close the gate (setGate). If the desired mode is CarsFTPrec, set the signal accordingly to the strategy above, if there are no waiting cars or fast trains are waiting. If the mode is set to UserGo, set the signal accordingly to the strategy above and close the gate. If the gate becomes closed, switch to the corresponding Closed-State (TPClosed, CPClosed, CPFTClosed, UHClosed).
 
Attributes
ModelName FullName Type Value Tasks Usage Description
curMode current Mode Enum (init, CPFTOpened, CPFTClosed, TPOpened, TPClosed, CPOpened, CPClosed, UGClosed, UGOpened) init CrossingCtrlTask1, CrossingCtrlTask4, CrossingCtrlTask5, CrossingCtrlTask6, CrossingCtrlTask7, CrossingCtrlTask8 r/w The first part of the different states sings the strategy (CPFT, CP, ...), and the second part signs the state of the gate (Opened, Closed)
curTrackNbr current track number Integer 0 CrossingCtrlTask1 w
tracks Array (td:SignalStateType, train:Boolean, trType:TrackType, trDur:Duration) CrossingCtrlTask1, CrossingCtrlTask2, CrossingCtrlTask4, CrossingCtrlTask5, CrossingCtrlTask6, CrossingCtrlTask7, CrossingCtrlTask8 w td: the current state of the signal
train: the presence of at least one train on the track
trDur: the duration of a train to pass from the first sensor on the track to the leaving sensor
carsWait Boolean false CrossingCtrlTask3, CrossingCtrlTask5, CrossingCtrlTask6, CrossingCtrlTask8 w
 
Signals
ModelName FullName Parameters Tasks Usage Description SignalPaths
initTracks Integer, TrackDurationType, Duration CrossingCtrlTask1 c Signs to create the given number of tracks with same parameters, given by the TrackDurationType, and different periods to create new Trains on this track.
initTracksDone CrossingCtrlTask1 c
noTrains Integer CrossingCtrlTask2 c Signs, that there are no more trains on the given track.
newCars Boolean CrossingCtrlTask3, CrossingCtrlTask5, CrossingCtrlTask6, CrossingCtrlTask8 c
askForGo Integer CrossingCtrlTask4, CrossingCtrlTask5, CrossingCtrlTask6, CrossingCtrlTask7, CrossingCtrlTask8 c
setSignalState Integer, SignalStateType CrossingCtrlTask4, CrossingCtrlTask5, CrossingCtrlTask6, CrossingCtrlTask8 p
newSignalState Integer, SignalStateType CrossingCtrlTask4, CrossingCtrlTask5, CrossingCtrlTask6, CrossingCtrlTask7, CrossingCtrlTask8 c
setGate GateStateType CrossingCtrlTask4, CrossingCtrlTask5, CrossingCtrlTask6, CrossingCtrlTask8 p