Wiki source code of Tutorial 1 - csp
Last modified by Richard Kreissig on 2025/01/30 12:05
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | |||
2 | = T1A1 = | ||
3 | |||
4 | == a) == | ||
5 | |||
6 | The pace of the controller-system is given by the events in the railway-system and the laws of physics. If there's a calculation running, the controller can't stop the real world until the calculation is finished, rather it has to finish in time e.g. before a train runs over a point switch. | ||
7 | |||
8 | Furthermore the controller-system has to take the continuity of the real world into account. Values read from sensors may be discretized and therefore may not represent the actual state or may slightly differ from each other, even if you might consider two states equal from sense of proportion. | ||
9 | |||
10 | == b) == | ||
11 | |||
12 | The controlling units are no computers you would find on an office desk. They have no monitor or mouse and keyboard. But especially they are restricted in resources like CPU power or RAM size. | ||
13 | |||
14 | == c) == | ||
15 | |||
16 | If the controller of the railway-system produces erroneous control-commands or doesn't finish in time, trains may crash. It's therefore important to get the right result in the right moment. | ||
17 | |||
18 | |||
19 | |||
20 | = T1A2 = | ||
21 | |||
22 | === First part: KH_ST_1 → IC_ST_1 === | ||
23 | |||
24 | Point switches to be set: | ||
25 | |||
26 | |=((( | ||
27 | Point switch | ||
28 | )))|=((( | ||
29 | value | ||
30 | ))) | ||
31 | |(% colspan="1" %)(% colspan="1" %) | ||
32 | ((( | ||
33 | 4 | ||
34 | )))|(% colspan="1" %)(% colspan="1" %) | ||
35 | ((( | ||
36 | STRAIGHT | ||
37 | ))) | ||
38 | |(% colspan="1" %)(% colspan="1" %) | ||
39 | ((( | ||
40 | 3 | ||
41 | )))|(% colspan="1" %)(% colspan="1" %) | ||
42 | ((( | ||
43 | STRAIGHT | ||
44 | ))) | ||
45 | |(% colspan="1" %)(% colspan="1" %) | ||
46 | ((( | ||
47 | 2 | ||
48 | )))|(% colspan="1" %)(% colspan="1" %) | ||
49 | ((( | ||
50 | STRAIGHT | ||
51 | ))) | ||
52 | |(% colspan="1" %)(% colspan="1" %) | ||
53 | ((( | ||
54 | 1 | ||
55 | )))|(% colspan="1" %)(% colspan="1" %) | ||
56 | ((( | ||
57 | BRANCH | ||
58 | ))) | ||
59 | |(% colspan="1" %)(% colspan="1" %) | ||
60 | ((( | ||
61 | 0 | ||
62 | )))|(% colspan="1" %)(% colspan="1" %) | ||
63 | ((( | ||
64 | BRANCH | ||
65 | ))) | ||
66 | |(% colspan="1" %)(% colspan="1" %) | ||
67 | ((( | ||
68 | 16 | ||
69 | )))|(% colspan="1" %)(% colspan="1" %) | ||
70 | ((( | ||
71 | BRANCH | ||
72 | ))) | ||
73 | |(% colspan="1" %)(% colspan="1" %) | ||
74 | ((( | ||
75 | 17 | ||
76 | )))|(% colspan="1" %)(% colspan="1" %) | ||
77 | ((( | ||
78 | BRANCH | ||
79 | ))) | ||
80 | |(% colspan="1" %)(% colspan="1" %) | ||
81 | ((( | ||
82 | 18 | ||
83 | )))|(% colspan="1" %)(% colspan="1" %) | ||
84 | ((( | ||
85 | BRANCH | ||
86 | ))) | ||
87 | |(% colspan="1" %)(% colspan="1" %) | ||
88 | ((( | ||
89 | 20 | ||
90 | )))|(% colspan="1" %)(% colspan="1" %) | ||
91 | ((( | ||
92 | STRAIGHT | ||
93 | ))) | ||
94 | |||
95 | Tracks: | ||
96 | |||
97 | |=((( | ||
98 | Block | ||
99 | )))|=((( | ||
100 | Direction | ||
101 | ))) | ||
102 | |(% colspan="1" %)(% colspan="1" %) | ||
103 | ((( | ||
104 | KH_ST_1 | ||
105 | )))|(% colspan="1" %)(% colspan="1" %) | ||
106 | ((( | ||
107 | REV | ||
108 | ))) | ||
109 | |(% colspan="1" %)(% colspan="1" %) | ||
110 | ((( | ||
111 | KH_ST_0 | ||
112 | )))|(% colspan="1" %)(% colspan="1" %) | ||
113 | ((( | ||
114 | REV | ||
115 | ))) | ||
116 | |(% colspan="1" %)(% colspan="1" %) | ||
117 | ((( | ||
118 | KIO_LN_0 | ||
119 | )))|(% colspan="1" %)(% colspan="1" %) | ||
120 | ((( | ||
121 | REV | ||
122 | ))) | ||
123 | |(% colspan="1" %)(% colspan="1" %) | ||
124 | ((( | ||
125 | OC_ST_4 | ||
126 | )))|(% colspan="1" %)(% colspan="1" %) | ||
127 | ((( | ||
128 | REV | ||
129 | ))) | ||
130 | |(% colspan="1" %)(% colspan="1" %) | ||
131 | ((( | ||
132 | IC_ST_0 | ||
133 | )))|(% colspan="1" %)(% colspan="1" %) | ||
134 | ((( | ||
135 | FWD | ||
136 | ))) | ||
137 | |(% colspan="1" %)(% colspan="1" %) | ||
138 | ((( | ||
139 | IC_ST_1 | ||
140 | )))|(% colspan="1" %)(% colspan="1" %) | ||
141 | ((( | ||
142 | FWD | ||
143 | ))) | ||
144 | |||
145 | === Second part: IC_ST_1 → KH_ST_1 === | ||
146 | |||
147 | Point switches to be set: | ||
148 | |||
149 | |=((( | ||
150 | Point switch | ||
151 | )))|=((( | ||
152 | value | ||
153 | ))) | ||
154 | |(% colspan="1" %)(% colspan="1" %) | ||
155 | ((( | ||
156 | 24 | ||
157 | )))|(% colspan="1" %)(% colspan="1" %) | ||
158 | ((( | ||
159 | STRAIGHT | ||
160 | ))) | ||
161 | |(% colspan="1" %)(% colspan="1" %) | ||
162 | ((( | ||
163 | 29 | ||
164 | )))|(% colspan="1" %)(% colspan="1" %) | ||
165 | ((( | ||
166 | BRANCH | ||
167 | ))) | ||
168 | |(% colspan="1" %)(% colspan="1" %) | ||
169 | ((( | ||
170 | 27 | ||
171 | )))|(% colspan="1" %)(% colspan="1" %) | ||
172 | ((( | ||
173 | STRAIGHT | ||
174 | ))) | ||
175 | |(% colspan="1" %)(% colspan="1" %) | ||
176 | ((( | ||
177 | 28 | ||
178 | )))|(% colspan="1" %)(% colspan="1" %) | ||
179 | ((( | ||
180 | STRAIGHT | ||
181 | ))) | ||
182 | |(% colspan="1" %)(% colspan="1" %) | ||
183 | ((( | ||
184 | 9 | ||
185 | )))|(% colspan="1" %)(% colspan="1" %) | ||
186 | ((( | ||
187 | BRANCH | ||
188 | ))) | ||
189 | |(% colspan="1" %)(% colspan="1" %) | ||
190 | ((( | ||
191 | 8 | ||
192 | )))|(% colspan="1" %)(% colspan="1" %) | ||
193 | ((( | ||
194 | STRAIGHT | ||
195 | ))) | ||
196 | |||
197 | Tracks: | ||
198 | |||
199 | |=((( | ||
200 | Block | ||
201 | )))|=((( | ||
202 | Direction | ||
203 | ))) | ||
204 | |(% colspan="1" %)(% colspan="1" %) | ||
205 | ((( | ||
206 | IC_ST_1 | ||
207 | )))|(% colspan="1" %)(% colspan="1" %) | ||
208 | ((( | ||
209 | FWD | ||
210 | ))) | ||
211 | |(% colspan="1" %)(% colspan="1" %) | ||
212 | ((( | ||
213 | IC_ST_4 | ||
214 | )))|(% colspan="1" %)(% colspan="1" %) | ||
215 | ((( | ||
216 | FWD | ||
217 | ))) | ||
218 | |(% colspan="1" %)(% colspan="1" %) | ||
219 | ((( | ||
220 | OC_ST_0 | ||
221 | )))|(% colspan="1" %)(% colspan="1" %) | ||
222 | ((( | ||
223 | REV | ||
224 | ))) | ||
225 | |(% colspan="1" %)(% colspan="1" %) | ||
226 | ((( | ||
227 | KIO_LN_1 | ||
228 | )))|(% colspan="1" %)(% colspan="1" %) | ||
229 | ((( | ||
230 | REV | ||
231 | ))) | ||
232 | |(% colspan="1" %)(% colspan="1" %) | ||
233 | ((( | ||
234 | KH_ST_6 | ||
235 | )))|(% colspan="1" %)(% colspan="1" %) | ||
236 | ((( | ||
237 | REV | ||
238 | ))) | ||
239 | |(% colspan="1" %)(% colspan="1" %) | ||
240 | ((( | ||
241 | KH_ST_1 | ||
242 | )))|(% colspan="1" %)(% colspan="1" %) | ||
243 | ((( | ||
244 | REV | ||
245 | ))) | ||
246 | |||
247 | == Plan == | ||
248 | |||
249 | * Set points and tracks and (busy) wait for a entry contact event on target block. | ||
250 | * Lower speed and wait for the target contact event and brake the train. | ||
251 | * Wait 5 seconds and repeat for the way back. | ||
252 | |||
253 | == Implementation == | ||
254 | |||
255 | |||
256 | [[SampleController.c>>attach:SampleController.c]] | ||
257 | |||
258 | = T1A3 = | ||
259 | |||
260 | |||
261 | |||
262 | == Differences from initial expectation == | ||
263 | |||
264 | |||
265 | |||
266 | ((( | ||
267 | * In opposite to points 16/17, points 27/28 have to be set STRAIGHT to cross the track. | ||
268 | * Numbering of contacts and signals. | ||
269 | * Waiting for only one entry-block-event isn't sufficient. The speed might be lowered before the train's locomotive fully entered the block (backwards travelling train) and raise a speed-mismatch-exception. Although not critical, it may produce unexpected results on the real railway-system. | ||
270 | * Events are buffered and must be "cleared" before waiting on a specific contact event. | ||
271 | |||
272 | == Further expected differences == | ||
273 | |||
274 | * Trains don't stop immediately. | ||
275 | * Contacts may not be triggered. | ||
276 | * Points may not switch correctly or even block. | ||
277 | ))) | ||
278 | |||
279 |