Show last authors
1 [[image:attach:graphic_.png]]
2
3 == Environment: ==
4
5 * (((
6 {{{track_contacts: int[NUM_TRACKS][2]}}}
7
8 * (((
9 0: no signal
10 )))
11 * (((
12 1: forwards
13 )))
14 * (((
15 2: backwards
16 )))
17 * (((
18 3: uni
19 )))
20 )))
21 * (((
22 {{{cross_contacts: int[]}}}
23
24 * (((
25 0: no signal
26 )))
27 * (((
28 1: closing
29 )))
30 * (((
31 2: opening
32 )))
33 )))
34
35 == User: ==
36
37 * (((
38 {{{train_setup: int[NUM_TRAINS] }}}
39
40 * (((
41 index: train number
42 )))
43 * (((
44 value: track number, (negative: train stands against main travel direction)
45 )))
46 )))
47 * (((
48 {{{destination: int[NUM_TRAINS]}}}
49
50 * (((
51 index. train number
52 )))
53 * (((
54 value: track number
55 )))
56 )))
57 * (((
58 {{{speeds: int[NUM_TRAINS][4]}}}
59
60 * (((
61 index: train number
62 )))
63 * (((
64 index: 0-3
65 )))
66 * (((
67 value: 1-127
68 )))
69 )))
70
71 == Controller: ==
72
73 * (((
74 {{{track_speeds: int[NUM_TRACKS]}}}
75
76 * (((
77 0: off
78 )))
79 * (((
80 1 to 127: forward speed
81 )))
82 * (((
83 -1 to -127: backward speed
84 )))
85 )))
86 * (((
87 {{{signals: int[NUM_TRACKS][2]}}}
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 * (((
113 {{{cross_light: int}}}
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 * (((
136 {{{points: bool[NUM_POINTS]}}}
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 * (((
156 {{{reached: bool[NUM_TRAINS]}}}
157
158 * (((
159 index: train number
160 )))
161 * (((
162 value: true: destination reached; false: destination not yet reached
163 )))
164 )))
165
166 == Scheduler: ==
167
168 * (((
169 {{{schedule: int[NUM_TRAINS]}}}
170
171 * (((
172 index: train number
173 )))
174 * (((
175 value: next save track on the way to destination
176 )))
177 )))
178
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
188 input int track_speeds[NUM_TRACKS];
189 // State of all switches
190 input bool points[NUM_POINTS];
191 // State of all signals
192 input int signals[NUM_TRACKS][2];
193
194 //------------------------------------------------------------\\
195 //-- OUTPUTS --\\
196 //------------------------------------------------------------\\
197 // State of all contacts of the railway
198 output int track_contacts[NUM_TRACKS][2];
199
200 //------------------------------------------------------------\\
201 //-- RAILWAY CONSTANTS --\\
202 //------------------------------------------------------------\\
203 const int NUM_TRACKS = 48;
204 const int NUM_TRAINS = 11;
205 const int NUM_POINTS = 30;
206 const int NUM_LAMPS = 24;
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}}