Show last authors
1 [[image:attach:interface.png]]
2
3 == Errors: ==
4
5 * collision_error
6 ** -1: no error
7 ** other values: a single track with multiple trains
8 * train_speed_mismatch_error[NUM_TRAINS]
9 ** -1: no error
10 ** 1: the front and rear wagon have different speeds
11 * train_point_changed_error[NUM_TRAINS]
12 ** indicates, that a point was changed while the train was standing on it,
13 i.e., the front passed the point, but the rear not yet.
14 ** -1: no error
15 ** other values: the point that has the error
16 * wagon_error_message[NUM_TRAINS][2]
17 ** -1: no error
18 ** 1: point not set correctly
19 ** 2: wagon uses wrong direction on KH_LN_2 or KH_LN_7, because the corresponding point was set wrongly
20 ** 3: wagon position under min of track (indicates a mistake in the environment)
21 ** 4: wagon position over max of track (indicates a mistake in the environment)
22 ** 5: diamond point set to send a train backwards through IC or OC. May cause further unexpected behavior
23 * wagon_error_pos[NUM_TRAINS][2]
24 ** NOTE: The meaning depends on wagon_error_message.
25 ** if wagon_error_message is 0
26 *** this error can be ignored
27 ** if wagon_error_message is 1, 2 or 5\\
28 *** the point on which the error occurs
29 ** if wagon_error_message is 3 or 4\\
30 *** the track on which the error occurs
31
32 == Environment: ==
33
34 * (((
35 {{{track_contacts: int[NUM_TRACKS][2]}}}
36
37 * (((
38 0: no signal
39 )))
40 * (((
41 1: forwards
42 )))
43 * (((
44 2: backwards
45 )))
46 * (((
47 3: uni
48 )))
49 )))
50 * (((
51 {{{cross_contacts: int[NUM_CONTACTS]}}}
52
53 * (((
54 0: no signal
55 )))
56 * (((
57 1: closing
58 )))
59 * (((
60 2: opening
61 )))
62 )))
63
64 == User: ==
65
66 * (((
67 {{{train_setup: int[NUM_TRAINS] }}}
68
69 * (((
70 index: train number
71 )))
72 * (((
73 value: track number, (negative: train stands against main travel direction)
74 )))
75 )))
76 * (((
77 {{{destination: int[NUM_TRAINS]}}}
78
79 * (((
80 index. train number
81 )))
82 * (((
83 value: track number
84 )))
85 )))
86 * (((
87 {{{speeds: int[NUM_TRAINS][4]}}}
88
89 * (((
90 index: train number
91 )))
92 * (((
93 index: 0-3
94 )))
95 * (((
96 value: 1-127
97 )))
98 )))
99
100 == Controller: ==
101
102 * (((
103 {{{track_speeds: int[NUM_TRACKS]}}}
104
105 * (((
106 0: off
107 )))
108 * (((
109 1 to 127: forward speed
110 )))
111 * (((
112 -1 to -127: backward speed
113 )))
114 )))
115 * (((
116 {{{signals: int[NUM_TRACKS][2]}}}
117
118 * (((
119 0: off
120 )))
121 * (((
122 1: red
123 )))
124 * (((
125 2: yellow
126 )))
127 * (((
128 3: green
129 )))
130 )))
131 * (((
132 {{{lamps: bool[NUM_LAMPS]}}}
133
134 * (((
135 true: on
136 )))
137 * (((
138 false: off
139 )))
140 )))
141 * (((
142 {{{cross_light: int}}}
143
144 * (((
145 0: off
146 )))
147 * (((
148 1: red
149 )))
150 * (((
151 2: yellow
152 )))
153 )))
154 * (((
155 {{{bell: bool}}}
156
157 * (((
158 true: on
159 )))
160 * (((
161 false: off
162 )))
163 )))
164 * (((
165 {{{points: bool[NUM_POINTS]}}}
166
167 * (((
168 true: branch
169 )))
170 * (((
171 false: straight
172 )))
173 )))
174 * (((
175 {{{gate: bool}}}
176
177 * (((
178 true: down
179 )))
180 * (((
181 false: up
182 )))
183 )))
184 * (((
185 {{{reached: bool[NUM_TRAINS]}}}
186
187 * (((
188 index: train number
189 )))
190 * (((
191 value: true: destination reached; false: destination not yet reached
192 )))
193 )))
194
195 == Scheduler: ==
196
197 * (((
198 {{{schedule: int[NUM_TRAINS]}}}
199
200 * (((
201 index: train number
202 )))
203 * (((
204 value: next save track on the way to destination
205 )))
206 )))
207
208 {{code language="sct" title="Controller-Environment Interface"}}
209 scchart environment {
210
211 //------------------------------------------------------------\\
212 //-- INPUTS --\\
213 //------------------------------------------------------------\\
214 // Initial track of the trains
215 input int train_setup[NUM_TRAINS];
216 // Speed of all tracks
217 input int track_speeds[NUM_TRACKS];
218 // State of all switches
219 input bool points[NUM_POINTS];
220 // State of all signals
221 input int signals[NUM_TRACKS][2];
222
223 //------------------------------------------------------------\\
224 //-- OUTPUTS --\\
225 //------------------------------------------------------------\\
226 // State of all contacts of the railway
227 output int track_contacts[NUM_TRACKS][2];
228
229 //------------------------------------------------------------\\
230 //-- RAILWAY CONSTANTS --\\
231 //------------------------------------------------------------\\
232 const int NUM_TRACKS = 48;
233 const int NUM_TRAINS = 11;
234 const int NUM_POINTS = 30;
235 const int NUM_LAMPS = 24;
236 const int NO_TRACK = -1;
237
238 //------------------------------------------------------------\\
239 //-- RAILWAY INTERFACE --\\
240 //------------------------------------------------------------\\
241 const int OFF = 0, RED = 1, YELLOW = 2, GREEN = 4;
242 const int ON = 1, OFF = 0, FWD = 1, REV = 2, BRAKE = 3;
243
244 const int DOWN = 0, UP = 1;
245 const int NONE = 0, UNI = 3;
246
247 const int STRAIGHT = 0, BRANCH = 1;
248
249 const int IC_JCT_0 = 0 , IC_LN_0 = 1 , IC_LN_1 = 2 , IC_LN_2 = 3;
250 const int IC_LN_3 = 4 , IC_LN_4 = 5 , IC_LN_5 = 6 , IC_ST_0 = 7;
251 const int IC_ST_1 = 8 , IC_ST_2 = 9 , IC_ST_3 = 10, IC_ST_4 = 11;
252 const int IO_LN_0 = 12, IO_LN_1 = 13, IO_LN_2 = 14;
253
254 const int KH_LN_0 = 15, KH_LN_1 = 16, KH_LN_2 = 17, KH_LN_3 = 18;
255 const int KH_LN_4 = 19, KH_LN_5 = 20, KH_LN_6 = 21, KH_LN_7 = 22;
256 const int KH_LN_8 = 23, KH_ST_0 = 24, KH_ST_1 = 25, KH_ST_2 = 26;
257 const int KH_ST_3 = 27, KH_ST_4 = 28, KH_ST_5 = 29, KH_ST_6 = 30;
258 const int KIO_LN_0 = 31, KIO_LN_1 = 32;
259
260 const int OC_JCT_0 = 33, OC_LN_0 = 34, OC_LN_1 = 35, OC_LN_2 = 36;
261 const int OC_LN_3 = 37, OC_LN_4 = 38, OC_LN_5 = 39, OC_ST_0 = 40;
262 const int OC_ST_1 = 41, OC_ST_2 = 42, OC_ST_3 = 43, OC_ST_4 = 44;
263 const int OI_LN_0 = 45, OI_LN_1 = 46, OI_LN_2 = 47;
264
265 initial state init;
266 }
267 {{/code}}