Documentation
Trains
Each train has a trainnumber. The trainnumber is for prioritization, when multiple trains compete for the same track. Lower numbers mean higher priorities, e.g. train 0 has the highest priority. Priorities can't be changed dynamicly.
Each train has one home-track at each station.
Train numbering
Variable trainNum is used to identify trains.
The assignment of numbers to trains is chosen as followed
trainNum | Starting track |
---|---|
0 | KH_ST_1 |
1 | KH_ST_2 |
2 | KH_ST_3 (r) |
3 | KH_ST_4 (r) |
4 | IC_ST_3 |
5 | IC_ST_2 |
6 | OC_ST_2 |
7 | OC_ST_1 |
8 | KH_ST_5 |
9 | IC_ST_1 |
10 | OC_ST_3 |
Logging
Variable debug indicates verbose logging.
Prefix of all log messages must be : [trainnum][ST-ST]
Use println function to produce textual output. Do not use printf or other io functions, because output may not be flushed correctly.
Tracks
Stopping on tracks without contacts is permitted. Therefore they must be reserved and used with an adjacent track.
Each station has one drive-through track for each possible direction:
station | drive-through track |
---|---|
IC_station | IC_ST_1 |
OC_station | OC_ST_3 |
KH_station | KH_ST_5 |
KH_station(r) | KH_ST_1 |
Station-to-Station
Fuctions $void railArrival(int train, int station)$ and $int railDeparture(int train)$ should be used at the end of every Station-to-Station-Controller.
At the end of every Station-to-Station-Controller the trains should stand in one station, because every Controller starts with the train in standstill.
TrainController
Train-Schedules should be modelled by putting together the Station-to-Station-Controllers for every train in individual regions.
Speed:
- SLOW: for the stations
- CAUTION: for points and slowdown
- NORMAL: for the other tracks
Codestyle
Use entry-/exit-actions instead of actions on transitions, if possible.
If using hostcode, only use functions delivered by our own C-Interface and not the Höhrmann-API.
Mutual Exclusion
bool <track>_req[<trainAmount>] contains the requests for each track and train. Before the availability of arrays, we used bool <train>_<track>_req.
int <track>_perm contains the trainnumber of the train, who is allowed to drive on <track>.
Quit, Pause and Cleanup
Quit, pause and cleanup functionality is handled in the c interface.
CTRL+C (SIGINT) quits the controller
CTRL+\ (SIGQUIT) cleans up
CTRL+Z (SIGSTP) pauses and continues