Wiki source code of Basic design
Version 8.1 by nbw on 2014/06/22 18:51
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | |||
| 2 | |||
| 3 | {{toc/}} | ||
| 4 | |||
| 5 | We compose our railway controller from several train controllers, combined with controllers for mutual exclusion. | ||
| 6 | |||
| 7 | == Mutual Exclusion == | ||
| 8 | |||
| 9 | === Normal segments === | ||
| 10 | |||
| 11 | **For each block** we generate one mutex controller, similar to the following pattern. | ||
| 12 | |||
| 13 | [[image:attach:Mutex.png]] | ||
| 14 | |||
| 15 | **For each controlled train** one state and the corresponding transitions are added. | ||
| 16 | |||
| 17 | A train **must** signal the wish to enter a segment by setting the variable **bool <segment>_req[trainNum] **to true. | ||
| 18 | The right to enter a segement is given to the train by setting the variable **int <segment>_perm** to the train number. | ||
| 19 | After leaving a segment the train **must** remove his request by setting <segment>_req[trainNum] to false again. | ||
| 20 | |||
| 21 | For a free track the *_perm variable is set to -1 and all tracks, apart from starting positions, are initialised with -1. For the starting positions the *_perm variables are set to the corresponding train number and the *_req variable for the train is set to true. | ||
| 22 | |||
| 23 | **A train must not enter a segment or alter the settings of a segment without holding the lock for the segment. No exceptions from this rule are allowed.** | ||
| 24 | |||
| 25 | === Kicking Horse Pass === | ||
| 26 | |||
| 27 | To prevent collisions on the track, a special controller manages the rights to enter or leave the Kicking Horse Pass. | ||
| 28 | |||
| 29 | [[image:attach:Mutex_KH.png]] | ||
| 30 | |||
| 31 | The controller splits the pass into two parts, //left// and //right//, corresponding to the track layout chart. [[(Simplified track layout)>>url:http://www.informatik.uni-kiel.de/~~railway/Downloads/kscheme.pdf||shape="rect"]] | ||
| 32 | |||
| 33 | Each part has two operational modes, //in// and //out//, being active when trains are allowed to either enter or leave the pass. When entering the pass the controller counts the entering trains and only lets two trains enter (one after the other). When leaving the pass the trains are removed from the counter, making space for the next train. | ||
| 34 | |||
| 35 | == Train controller == | ||
| 36 | |||
| 37 | Each train controller is set in a separate region with a referenced state. This state has the following interface | ||
| 38 | |||
| 39 | |||
| 40 | \\\\\\\\ | ||
| 41 | |||
| 42 | {{{ input int *_perm; # All permission variables (Tracks) input bool *_perm # KH permission variables input int trainNum; input bool cleanup; input bool debug; output bool *_req[]; # All request variables}}} | ||
| 43 | |||
| 44 | The train controller is composed of several //Station-2-Station// controllers. These are combined to form a complete schedule. Additionally the cleanup signal has to be watched to abort the schedule and return back to the initial position. | ||
| 45 | |||
| 46 | == Station-2-Station controller == | ||
| 47 | |||
| 48 | Each station-2-station controller realizes the movement from one of the stations (IC,OC,KH) to a second station. All controllers using IC or OC parts have to respect the traveling directions. For the Kicking Horse Pass two separate controllers, forwards and backwards, are used. | ||
| 49 | |||
| 50 | The controllers starting from Kicking Horse Pass Station make an assumption of the direction of the train. These are dependent of the directions of the inner or outer circle, e.g. the KHIC controller starts backwards because this is the only valid direction to travel this path. To drive a train from the Kicking Horse Station (facing forward) to the Inner Circle we have to combine the KHOC and OCIC controllers. | ||
| 51 | |||
| 52 | [[image:attach:ICIC.png]] | ||
| 53 | |||
| 54 | When arriving on a station the train controller **must** first call the function //void railArrival(int train, int station)//. This starts the waiting timer for the train. | ||
| 55 | Next the train **must** wait for// int railDeparture(int train)// to return 1. | ||
| 56 | After the waiting has finished the controller can reach a final state and pass the control back to the train controller. |