Hide last authors
stu115342 1.1 1 [[image:attach:graphic_.png]]
2
3 == Environment: ==
4
5 * (((
aas2 12.1 6 {{{track_contacts: int[NUM_TRACKS][2]}}}
stu115342 1.1 7
8 * (((
9 0: no signal
10 )))
11 * (((
12 1: forwards
13 )))
14 * (((
15 2: backwards
16 )))
17 * (((
18 3: uni
19 )))
20 )))
21 * (((
aas2 4.1 22 {{{cross_contacts: int[]}}}
stu115342 1.1 23
24 * (((
25 0: no signal
26 )))
27 * (((
28 1: closing
29 )))
30 * (((
31 2: opening
32 )))
33 )))
34
35 == User: ==
36
37 * (((
aas2 4.1 38 {{{train_setup: int[NUM_TRAINS] }}}
stu115342 1.1 39
40 * (((
aas2 6.1 41 index: train number
stu115342 1.1 42 )))
43 * (((
aas2 10.1 44 value: track number, (negative: train stands against main travel direction)
stu115342 1.1 45 )))
46 )))
47 * (((
aas2 6.1 48 {{{destination: int[NUM_TRAINS]}}}
stu115342 1.1 49
50 * (((
51 index. train number
52 )))
53 * (((
54 value: track number
55 )))
56 )))
57 * (((
aas2 6.1 58 {{{speeds: int[NUM_TRAINS][4]}}}
stu115342 1.1 59
60 * (((
61 index: train number
62 )))
63 * (((
64 index: 0-3
65 )))
66 * (((
67 value: 1-127
68 )))
69 )))
70
71 == Controller: ==
72
stu115342 3.1 73 * (((
aas2 12.1 74 {{{track_speeds: int[NUM_TRACKS]}}}
stu115342 1.1 75
stu115342 3.1 76 * (((
77 0: off
78 )))
79 * (((
80 1 to 127: forward speed
81 )))
82 * (((
83 -1 to -127: backward speed
84 )))
85 )))
86 * (((
aas2 12.1 87 {{{signals: int[NUM_TRACKS][2]}}}
stu115342 3.1 88
89 * (((
90 0: off
91 )))
92 * (((
93 1: red
94 )))
95 * (((
96 2: yellow
97 )))
98 * (((
99 3: green
100 )))
101 )))
102 * (((
103 {{{lamps: bool[]}}}
104
105 * (((
106 true: on
107 )))
108 * (((
109 false: off
110 )))
111 )))
112 * (((
aas2 4.1 113 {{{cross_light: int}}}
stu115342 3.1 114
115 * (((
116 0: off
117 )))
118 * (((
119 1: red
120 )))
121 * (((
122 2: yellow
123 )))
124 )))
125 * (((
126 {{{bell: bool}}}
127
128 * (((
129 true: on
130 )))
131 * (((
132 false: off
133 )))
134 )))
135 * (((
aas2 4.1 136 {{{points: bool[NUM_POINTS]}}}
stu115342 3.1 137
138 * (((
139 true: branch
140 )))
141 * (((
142 false: straight
143 )))
144 )))
145 * (((
146 {{{gate: bool}}}
147
148 * (((
149 true: down
150 )))
151 * (((
152 false: up
153 )))
154 )))
155 * (((
aas2 6.1 156 {{{reached: bool[NUM_TRAINS]}}}
stu115342 3.1 157
158 * (((
159 index: train number
160 )))
161 * (((
162 value: true: destination reached; false: destination not yet reached
163 )))
164 )))
165
stu115342 1.1 166 == Scheduler: ==
167
stu115342 3.1 168 * (((
aas2 6.1 169 {{{schedule: int[NUM_TRAINS]}}}
stu115342 1.1 170
stu115342 3.1 171 * (((
172 index: train number
173 )))
174 * (((
175 value: next save track on the way to destination
176 )))
177 )))
178
aas2 5.1 179 {{code language="sct" title="Controller-Environment Interface"}}
180 scchart environment {
181
182 //------------------------------------------------------------\\
183 //-- INPUTS --\\
184 //------------------------------------------------------------\\
185 // Initial track of the trains
186 input int train_setup[NUM_TRAINS];
187 // Speed of all tracks
aas2 12.1 188 input int track_speeds[NUM_TRACKS];
aas2 5.1 189 // State of all switches
190 input bool points[NUM_POINTS];
191 // State of all signals
aas2 12.1 192 input int signals[NUM_TRACKS][2];
aas2 5.1 193
194 //------------------------------------------------------------\\
195 //-- OUTPUTS --\\
196 //------------------------------------------------------------\\
197 // State of all contacts of the railway
aas2 12.1 198 output int track_contacts[NUM_TRACKS][2];
aas2 5.1 199
200 //------------------------------------------------------------\\
201 //-- RAILWAY CONSTANTS --\\
202 //------------------------------------------------------------\\
aas2 11.1 203 const int NUM_TRACKS = 48;
aas2 5.1 204 const int NUM_TRAINS = 11;
aas2 11.1 205 const int NUM_POINTS = 30;
stu115342 7.1 206 const int NUM_LAMPS = 24;
aas2 5.1 207 const int NO_TRACK = -1;
208
209 //------------------------------------------------------------\\
210 //-- RAILWAY INTERFACE --\\
211 //------------------------------------------------------------\\
212 const int OFF = 0, RED = 1, YELLOW = 2, GREEN = 4;
213 const int ON = 1, OFF = 0, FWD = 1, REV = 2, BRAKE = 3;
214
215 const int DOWN = 0, UP = 1;
216 const int NONE = 0, UNI = 3;
217
218 const int STRAIGHT = 0, BRANCH = 1;
219
220 const int IC_JCT_0 = 0 , IC_LN_0 = 1 , IC_LN_1 = 2 , IC_LN_2 = 3;
221 const int IC_LN_3 = 4 , IC_LN_4 = 5 , IC_LN_5 = 6 , IC_ST_0 = 7;
222 const int IC_ST_1 = 8 , IC_ST_2 = 9 , IC_ST_3 = 10, IC_ST_4 = 11;
223 const int IO_LN_0 = 12, IO_LN_1 = 13, IO_LN_2 = 14;
224
225 const int KH_LN_0 = 15, KH_LN_1 = 16, KH_LN_2 = 17, KH_LN_3 = 18;
226 const int KH_LN_4 = 19, KH_LN_5 = 20, KH_LN_6 = 21, KH_LN_7 = 22;
227 const int KH_LN_8 = 23, KH_ST_0 = 24, KH_ST_1 = 25, KH_ST_2 = 26;
228 const int KH_ST_3 = 27, KH_ST_4 = 28, KH_ST_5 = 29, KH_ST_6 = 30;
229 const int KIO_LN_0 = 31, KIO_LN_1 = 32;
230
231 const int OC_JCT_0 = 33, OC_LN_0 = 34, OC_LN_1 = 35, OC_LN_2 = 36;
232 const int OC_LN_3 = 37, OC_LN_4 = 38, OC_LN_5 = 39, OC_ST_0 = 40;
233 const int OC_ST_1 = 41, OC_ST_2 = 42, OC_ST_3 = 43, OC_ST_4 = 44;
234 const int OI_LN_0 = 45, OI_LN_1 = 46, OI_LN_2 = 47;
235
236 initial state init;
237 }
238 {{/code}}