Hardwarecontrol
The Hardwarecontrol should give an abstraction for controllng the Hardware wich also makes sure some of the base rules apply.
Tasks/Rules the Hardwarecontrol should manage:
- train tracking
- block locking/crash avoidance
- speed control: slow down(/speed up?)/parking in a segment
- same speed policy (same speed on all tracks beneath a train)
- automatic signal management
- automatic point branching
We split up the track into smaller interacting parts to achive this:
- Segment (1 Track, 2 Contacts, 1 Signal)
- Segment_bid (bi-directional) (1 Track, 2 Contacts, 2 Signals)
- Track (1 Track)
- Track_bid (1 Track)
- Point_in (1 Point with 2 incoming and 1 outgoing tracks)
- Point_out (1 Point with 1 incoming and 2 outgoing tracks)
- Point_bid (1 Point, 2 to 1 bi-directional point)
- Cross_in (1 Track, 2 Points, has 2 incoming, 1 outgoing and 1 bi-directional track where incoming trains get on the main track and outgoing come from the side track)
- Cross_out (1 Track, 2 Points, has 1 incoming, 2 outgoing and 1 bi-directional track where outgoing trains come from the main track and incoming go to the side track)
The differenciation of bi-directional and uni-directional Elements is done to have simpler Parts for the unidirectional parts.
With these we can model the railway system by connecting these parts in terms of mapping input and output values according to the connections. To fullfill the tasks/rules every connection (uni-directional) has the following variables, where in and out descibes if it's an input/output of the previous part in travel direction:
- out int requestLockFor: >0: id of the track to request the lock for, -1: get next lock (not supported if nondeterministic)
- out int requestLockTrain: when requestLockFor!=0 the id of the incoming train
- in bool Locked: the next part is locked and expects an incoming train, lock is releaded when train reaches the next track
- in bool Branched: the connection to the next "part"(save track) is branched (to set the signal)
- in bool PullSpeed: the speed to synchronize to have one speed for all used tracks.
To stay dependency cycle free there has to be a part in each cycle wich writes each of these in order and first read afterwards.