Wiki source code of Scheduler
Last modified by aas2 on 2025/01/30 12:17
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | 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 {{code language="none"}}route{{/code}} and {{code language="none"}}train_on_track{{/code}}. Following inputs are used to achieve this: | ||
2 | |||
3 | (% class="wrapped" %) | ||
4 | |=((( | ||
5 | initial_position | ||
6 | )))|((( | ||
7 | Send to controller as input, only used in first tick and never after. Determines the starting position of a train and has to be a segment. | ||
8 | ))) | ||
9 | |=((( | ||
10 | final_station | ||
11 | )))|((( | ||
12 | Send to controller as input. This may be influenced by the deadlock avoidance if necessary (forces a destination on blocking trains that do not have a destination). | ||
13 | ))) | ||
14 | |=((( | ||
15 | current_position | ||
16 | )))|((( | ||
17 | Send by hardware abstraction to determine the current segment. | ||
18 | ))) | ||
19 | |=((( | ||
20 | reached | ||
21 | )))|((( | ||
22 | Send by hardware abstraction to signal, that the segment specified by | ||
23 | |||
24 | {{code language="none"}} | ||
25 | next_segment | ||
26 | {{/code}} | ||
27 | |||
28 | was reached. | ||
29 | ))) | ||
30 | |=((( | ||
31 | route | ||
32 | )))|((( | ||
33 | May be 0 or 1. From every station it is possible to take two different routes to a different station. If | ||
34 | |||
35 | {{code language="none"}} | ||
36 | route | ||
37 | {{/code}} | ||
38 | |||
39 | 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 | ||
40 | ))) | ||
41 | |=((( | ||
42 | train_on_track | ||
43 | )))|((( | ||
44 | 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. | ||
45 | ))) | ||
46 | |=((( | ||
47 | lock_XX | ||
48 | )))|((( | ||
49 | Set by deadlock prevention to lock specific segment transition in KH and to KIO | ||
50 | ))) | ||
51 | |||
52 | \\ | ||
53 | |||
54 | === Relevant Scheduler Outputs === | ||
55 | |||
56 | 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. | ||
57 | |||
58 | (% class="wrapped" %) | ||
59 | |=((( | ||
60 | (pre_)next_segment | ||
61 | )))|((( | ||
62 | Used by hardware abstraction to determine what tracks need to be to reserved and what tracks need to be powered. Its is also used by deadlock prevention to set | ||
63 | |||
64 | {{code language="none"}} | ||
65 | route | ||
66 | {{/code}} | ||
67 | |||
68 | or set | ||
69 | |||
70 | {{code language="none"}} | ||
71 | final_station | ||
72 | {{/code}} | ||
73 | ))) | ||
74 | |=((( | ||
75 | moving | ||
76 | )))|((( | ||
77 | 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 | ||
78 | |||
79 | {{code language="none"}} | ||
80 | lock_XX | ||
81 | {{/code}} | ||
82 | |||
83 | ). | ||
84 | ))) | ||
85 | |||
86 | \\ | ||
87 | |||
88 | The Scheduler uses the following internal variables to determine the location and state of each train. | ||
89 | |||
90 | (% class="wrapped" %) | ||
91 | |=((( | ||
92 | station (output) | ||
93 | )))|((( | ||
94 | The | ||
95 | |||
96 | {{code language="none"}} | ||
97 | final_station | ||
98 | {{/code}} | ||
99 | |||
100 | the train is currently heading to. Only updated if the train reached a station. A train may not change station while not being in at least a substation of its route. | ||
101 | ))) | ||
102 | |=((( | ||
103 | taken_route | ||
104 | )))|((( | ||
105 | The | ||
106 | |||
107 | {{code language="none"}} | ||
108 | route | ||
109 | {{/code}} | ||
110 | |||
111 | 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. | ||
112 | ))) | ||
113 | |=((( | ||
114 | still_moving | ||
115 | )))|((( | ||
116 | Boolean used to signal that regardless whether {{code language="none"}}next_segment == NO_DESTINATION{{/code}}, a train still has a destination he is heading to. | ||
117 | ))) | ||
118 | |=((( | ||
119 | not_in_station | ||
120 | )))|((( | ||
121 | Only set in first tick, if | ||
122 | |||
123 | {{code language="none"}} | ||
124 | initial_position | ||
125 | {{/code}} | ||
126 | |||
127 | is no platform. Used to handle the special cases that can happen. Only used untill a station is reached. | ||
128 | ))) | ||
129 | |=((( | ||
130 | only_passing_by | ||
131 | )))|((( | ||
132 | Signals that a train does not want to enter a specific platform in a station. Mostly used if a train has to pass a station to reach his final station. | ||
133 | ))) | ||
134 | |=((( | ||
135 | station_position (output) | ||
136 | )))|((( | ||
137 | The last station a train has visited. Is set to a possible previous station if | ||
138 | |||
139 | {{code language="none"}} | ||
140 | initial_position | ||
141 | {{/code}} | ||
142 | |||
143 | is no platform. | ||
144 | ))) | ||
145 | |=((( | ||
146 | substation (output) | ||
147 | )))|((( | ||
148 | Indicates next platform/ station a train should head to. If | ||
149 | |||
150 | {{code language="none"}} | ||
151 | substation | ||
152 | {{/code}} | ||
153 | |||
154 | is not equal to station the station is used instead of a specific platform. | ||
155 | ))) | ||
156 | |||
157 | \\ | ||
158 | |||
159 | The {{code language="none"}}station_position{{/code}}, {{code language="none"}}station{{/code}} and {{code language="none"}}taken_route{{/code}} (and {{code language="none"}}not_in_station{{/code}} until first station is reached) to determine the next substation. The variables {{code language="none"}}current_position{{/code}} and {{code language="none"}}substation{{/code}} (and {{code language="none"}}lock_XX{{/code}}, {{code language="none"}}only_passing_by{{/code}}) are used to determine the {{code language="none"}}next_segment{{/code}}. | ||
160 | |||
161 | \\ |