Changes for page Basic design
Last modified by nfl on 2025/01/30 12:05
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -34,7 +34,7 @@ 34 34 35 35 == Train controller == 36 36 37 -Each train controller is set in a separate region with a referenced state. This state has the following interface :37 +Each train controller is set in a separate region with a referenced state. This state has the following interface 38 38 39 39 40 40 \\\\\\\\ ... ... @@ -41,469 +41,897 @@ 41 41 42 42 {{{   input int *_perm;        # All permission variables (Tracks) input bool *_perm # KH permission variables  input int trainNum;   input bool cleanup; input bool debug; output bool *_req[]; # All request variables}}} 43 43 44 -The train controller is composed of several //Station-2-Station// controllers. These are combined to form a complete schedule. Additionally ,the cleanup signal has to be watched to abort the schedule and return back to the initial position.44 +The train controller is composed of several //Station-2-Station// controllers. These are combined to form a complete schedule. Additionally the cleanup signal has to be watched to abort the schedule and return back to the initial position. 45 45 46 +== Station-2-Station controller == 47 + 48 +Each station-2-station controller realizes the movement from one of the stations (IC,OC,KH) to a second station. All controllers using IC or OC parts have to respect the traveling directions. For the Kicking Horse Pass two separate controllers, forwards and backwards, are used. 49 + 50 +The controllers starting from Kicking Horse Pass Station make an assumption of the direction of the train. These are dependent of the directions of the inner or outer circle, e.g. the KHIC controller starts backwards because this is the only valid direction to travel this path. To drive a train from the Kicking Horse Station (facing forward) to the Inner Circle we have to combine the KHOC and OCIC controllers. 51 + 52 +[[image:attach:ICIC.png]] 53 + 54 +When arriving on a station the train controller **must** first call the function //void railArrival(int train, int station)//. This starts the waiting timer for the train. 55 +Next the train **must** wait for// int railDeparture(int train)// to return 1. 56 +After the waiting has finished the controller can reach a final state and pass the control back to the train controller. 57 + 46 46 === Structure === 47 47 48 -{{code linenumbers="true" language="sct"}} 49 -scchart Test2b "Test of IC_JCT" { 50 - bool IC_JCT_0_req[11], IC_LN_0_req[11], IC_LN_1_req[11], IC_LN_2_req[11]; 51 - bool IC_LN_3_req[11], IC_LN_4_req[11], IC_LN_5_req[11], IC_ST_0_req[11]; 52 - bool IC_ST_1_req[11], IC_ST_2_req[11], IC_ST_3_req[11], IC_ST_4_req[11]; 53 - bool IO_LN_0_req[11], IO_LN_1_req[11], IO_LN_2_req[11], KH_LN_0_req[11]; 54 - bool KH_LN_1_req[11], KH_LN_2_req[11], KH_LN_3_req[11], KH_LN_4_req[11]; 55 - bool KH_LN_5_req[11], KH_LN_6_req[11], KH_LN_7_req[11], KH_LN_8_req[11]; 56 - bool KH_ST_0_req[11], KH_ST_1_req[11], KH_ST_2_req[11], KH_ST_3_req[11]; 57 - bool KH_ST_4_req[11], KH_ST_5_req[11], KH_ST_6_req[11], KIO_LN_0_req[11]; 58 - bool KIO_LN_1_req[11], OC_JCT_0_req[11], OC_LN_0_req[11], OC_LN_1_req[11]; 59 - bool OC_LN_2_req[11], OC_LN_3_req[11], OC_LN_4_req[11], OC_LN_5_req[11]; 60 - bool OC_ST_0_req[11], OC_ST_1_req[11], OC_ST_2_req[11], OC_ST_3_req[11]; 61 - bool OC_ST_4_req[11], OI_LN_0_req[11], OI_LN_1_req[11], OI_LN_2_req[11]; 62 - bool req_in_R, req_out_R, req_in_L, req_out_L, perm_in_R, perm_out_R, perm_in_L, perm_out_L; 63 - int IC_JCT_0_perm, IC_LN_0_perm, IC_LN_1_perm, IC_LN_2_perm; 64 - int IC_LN_3_perm, IC_LN_4_perm, IC_LN_5_perm, IC_ST_0_perm; 65 - int IC_ST_1_perm, IC_ST_2_perm, IC_ST_3_perm, IC_ST_4_perm; 66 - int IO_LN_0_perm, IO_LN_1_perm, IO_LN_2_perm, KH_LN_0_perm; 67 - int KH_LN_1_perm, KH_LN_2_perm, KH_LN_3_perm, KH_LN_4_perm; 68 - int KH_LN_5_perm, KH_LN_6_perm, KH_LN_7_perm, KH_LN_8_perm; 69 - int KH_ST_0_perm, KH_ST_1_perm, KH_ST_2_perm, KH_ST_3_perm; 70 - int KH_ST_4_perm, KH_ST_5_perm, KH_ST_6_perm, KIO_LN_0_perm; 71 - int KIO_LN_1_perm, OC_JCT_0_perm, OC_LN_0_perm, OC_LN_1_perm; 72 - int OC_LN_2_perm, OC_LN_3_perm, OC_LN_4_perm, OC_LN_5_perm; 73 - int OC_ST_0_perm, OC_ST_1_perm, OC_ST_2_perm, OC_ST_3_perm; 74 - int OC_ST_4_perm, OI_LN_0_perm, OI_LN_1_perm, OI_LN_2_perm; 75 - 76 - bool debug = false; 77 - bool cleanup = false; 78 - int trainCount; 60 +---- 61 + 62 + 79 79 80 - const int c_EINS = 1; 81 - const int c_ZWEI = 2; 82 - const int c_DREI = 3; 83 - const int c_VIER = 4; 84 - const int c_FUENF = 5; 85 - 86 - initial state init references initRailway11Trains 87 - --> run; 88 - 89 - state run { 90 - region Mutexes: 91 - initial state Mutexes references mutexRailway11Trains; 92 - 93 - region KH_Mutexes: 94 - initial state KH_Mutexes references kh_mutex; 95 - 96 - region Train4 : 97 - initial state train4 { 98 - 99 - @alterHostcode 100 - const int trainNum = 4; 101 - int arrivalTrack = 3; 102 - 103 - initial state Round references ICIC 104 - bind depTrack to arrivalTrack, 105 - destTrack to c_DREI, 106 - arrTrack to arrivalTrack 107 - >-> Choice; 108 - 109 - state Choice 110 - --> Round with !cleanup | !(arrivalTrack == 3) 111 - --> Done; 112 - 113 - final state Done; 114 - 115 - }; 116 - region Train5 : 117 - initial state train5 { 118 - 119 - @alterHostcode 120 - const int trainNum = 5; 121 - int arrivalTrack = 2; 122 - 123 - initial state Round references ICIC 124 - bind depTrack to arrivalTrack, 125 - destTrack to c_ZWEI, 126 - arrTrack to arrivalTrack 127 - >-> Choice; 128 - 129 - state Choice 130 - --> Round with !cleanup | !(arrivalTrack == 2) 131 - --> Done; 132 - 133 - final state Done; 134 - 135 - }; 136 - 137 - region Train9 : 138 - initial state train9 { 139 - 140 - @alterHostcode 141 - const int trainNum = 9; 142 - int arrivalTrack = 1; 143 - 144 - initial state Round references ICIC 145 - bind depTrack to arrivalTrack, 146 - destTrack to c_EINS, 147 - arrTrack to arrivalTrack 148 - >-> Choice; 149 - 150 - state Choice 151 - --> Round with !cleanup | !(arrivalTrack == 1) 152 - --> Done; 153 - 154 - final state Done; 155 - }; 156 - 157 - region Train7 : 158 - initial state train7 { 159 - 160 - @alterHostcode 161 - const int trainNum = 7; 162 - int arrivalTrack = 1; 163 - 164 - initial state OCtoIC references OCIC 165 - bind depTrack to arrivalTrack, 166 - destTrack to c_ZWEI, 167 - arrTrack to arrivalTrack 168 - >-> ICtoOC; 169 - 170 - state ICtoOC references ICOC 171 - bind depTrack to arrivalTrack, 172 - destTrack to c_EINS, 173 - arrTrack to arrivalTrack 174 - >-> Choice; 175 - 176 - state Choice 177 - --> OCtoIC with !cleanup | !(arrivalTrack == 1) 178 - --> Done; 179 - 180 - final state Done; 181 - }; 182 - }; 183 -} 184 -{{/code}} 185 185 65 +|=((( 66 +{{{input int *_perm;}}} 67 + 68 +{{{output bool *_req[11];}}} 69 + 70 +{{{input int trainNum;}}} 71 + 72 +{{{input int depTrack;}}} 73 + 74 +{{{input int destTrack;}}} 75 + 76 +{{{input bool cleanup;}}} 77 + 78 +{{{input bool debug;}}} 79 + 80 +{{{output int arrTrack;}}} 81 + 82 +{{{int i_arrOnTrack;}}} 83 + 84 +{{{ }}} 85 + 86 +{{{initial state *_ST {}}} 87 + 88 +{{{   entry debug / 'println([trainNum][ST-ST] ... )';}}} 89 + 90 +{{{ }}} 91 + 92 +{{{   initial state waitForPerm {}}} 93 + 94 +{{{       entry / *_ST_4_req[trainNum] = true;}}} 95 + 96 +{{{       entry / *_LN_0_req[trainNum] = true;}}} 97 + 98 +{{{   }}}} 99 + 100 +{{{   --> gotPerm with (*_ST_4_perm == trainNum) & (*_LN_0_perm == trainNum)}}} 101 + 102 +{{{   --> backOff with (*_ST_4_perm == trainNum) | (*_LN_0_perm == trainNum);}}} 103 + 104 +{{{ }}} 105 + 106 +{{{   state backOff}}} 107 + 108 +{{{   --> backOff1;}}} 109 + 110 +{{{ }}} 111 + 112 +{{{   state backOff1 {}}} 113 + 114 +{{{entry / *_ST_4_req[trainNum] = false;}}} 115 + 116 +{{{entry / *_LN_0_req[trainNum] = false;}}} 117 + 118 +{{{   }}}} 119 + 120 +{{{   --> waitForPerm;}}} 121 + 122 +{{{ }}} 123 + 124 +{{{final state gotPerm;}}} 125 + 126 +{{{}}}} 127 + 128 +{{{>-> Dep_*_ST;}}} 129 + 130 +{{{ }}} 131 + 132 +{{{state Dep_IC_ST {}}} 133 + 134 +{{{   entry / 'railPoint(*,STRAIGHT)';}}} 135 + 136 +{{{   entry / 'railSignal(*_LN_0, FWD, RED)';}}} 137 + 138 +{{{   entry / 'railTrack(*_LN_0,FWD,trainNum,NORMAL)';}}} 139 + 140 +{{{   entry / 'railTrack(*_ST_4,FWD,trainNum,NORMAL)';}}} 141 + 142 +{{{   entry depTrack == 1 / 'railSignal(*_ST_1, FWD, GREEN)';}}} 143 + 144 +{{{   entry depTrack == 2 / 'railSignal(*_ST_2, FWD, GREEN)';}}} 145 + 146 +{{{   entry depTrack == 3 / 'railSignal(*_ST_3, FWD, GREEN)';}}} 147 + 148 +{{{   ..........}}} 149 + 150 +{{{ } --> *_LN_0 with 'railContact(*_LN_0,0)';}}} 151 + 152 +{{{ }}} 153 + 154 +{{{ state *_LN_0 {}}} 155 + 156 +{{{   entry / 'println("[trainNum][ST-ST] Entering *_LN_0")';}}} 157 + 158 +{{{   entry debug / 'println("[trainNum][ST-ST] Requesting permission for *_LN_1")';}}} 159 + 160 +{{{   entry depTrack == 1 / 'railSignal(*_ST_1, FWD, RED)';}}} 161 + 162 +{{{   entry depTrack == 2 / 'railSignal(*_ST_2, FWD, RED)';}}} 163 + 164 +{{{   entry depTrack == 3 / 'railSignal(*_ST_3, FWD, RED)';}}} 165 + 166 +{{{   entry / *_LN_1_req[trainNum] = true;}}} 167 + 168 +{{{ }}} 169 + 170 +{{{   region Travel:}}} 171 + 172 +{{{     initial state Entry}}} 173 + 174 +{{{     --> Continue with 'railContact(*_LN_0,0)' & (*_LN_1_perm == trainNum)}}} 175 + 176 +{{{     --> Slowdown with 'railContact(*_LN_0,0)';}}} 177 + 178 +{{{ }}} 179 + 180 +{{{     state Slowdown {}}} 181 + 182 +{{{       entry debug / 'println("[trainNum][ST-ST] Slowing down on *_LN_0")';}}} 183 + 184 +{{{       entry / 'railTrack(*_LN_0,FWD,trainNum,CAUTION)';}}} 185 + 186 +{{{     }}}} 187 + 188 +{{{     --> Waiting with 'railContact(*_LN_0,1)'}}} 189 + 190 +{{{     --> Continue with *_LN_1_perm == trainNum;}}} 191 + 192 +{{{ }}} 193 + 194 +{{{     state Waiting {}}} 195 + 196 +{{{       entry debug / 'println("[trainNum][ST-ST] Stopping on *_LN_0")';}}} 197 + 198 +{{{       entry / 'railTrackBrake(*_LN_0)';}}} 199 + 200 +{{{     }}}} 201 + 202 +{{{     --> Continue with *_LN_1_perm == trainNum;}}} 203 + 204 +{{{ }}} 205 + 206 +{{{     final state Continue {}}} 207 + 208 +{{{       entry debug / 'println("[trainNum][ST-ST] Continuing on *_LN_0")';}}} 209 + 210 +{{{       entry / 'railSignal(*_LN_0,FWD,GREEN)';}}} 211 + 212 +{{{       entry / 'railTrack(*_LN_0,FWD,trainNum,NORMAL)';}}} 213 + 214 +{{{       entry / 'railTrack(*_LN_1,FWD,trainNum,NORMAL)';}}} 215 + 216 +{{{       entry / 'railSignal(*_LN_1, FWD, RED)';}}} 217 + 218 +{{{     };}}} 219 + 220 +{{{ }}} 221 + 222 +{{{   region Cleanup:}}} 223 + 224 +{{{     initial state Entry}}} 225 + 226 +{{{     --> cleanup with 'railContact(*_LN_0,0)';}}} 227 + 228 +{{{ }}} 229 + 230 +{{{     final state cleanup {}}} 231 + 232 +{{{     entry debug / 'println("[trainNum][ST-ST] Entered *_LN_0 completely")';}}} 233 + 234 +{{{     entry / 'railTrackOff(*_ST_4)';}}} 235 + 236 +{{{     entry / *_ST_4_req[trainNum] = false;}}} 237 + 238 +{{{     };}}} 239 + 240 +{{{ }>-> *_LN_0_*_LN_1;}}} 241 + 242 +{{{ }}} 243 + 244 +{{{ state IC_LN_0_IC_LN_1}}} 245 + 246 +{{{ --> IC_LN_1 with 'railContact(IC_LN_1,0)';}}} 247 + 248 +{{{ }}} 249 + 250 +{{{// ...................}}} 251 + 252 +{{{// Set of track segment controlling states such as before}}} 253 + 254 +{{{// ...................}}} 255 + 256 +{{{ }}} 257 + 258 +{{{state *_LN_5 {}}} 259 + 260 +{{{   int perm_all_next_segments = false;}}} 261 + 262 +{{{   entry / 'println("[trainNum][ST-ST] Entering *_LN_5")';}}} 263 + 264 +{{{   entry / 'railSignal(*_LN_4, FWD, RED)';}}} 265 + 266 +{{{ }}} 267 + 268 +{{{   region Travel:}}} 269 + 270 +{{{     initial state Entry}}} 271 + 272 +{{{     --> Continue with 'railContact(*_LN_5,0)' & perm_all_next_segments}}} 273 + 274 +{{{     --> Slowdown with 'railContact(*_LN_5,0)';}}} 275 + 276 +{{{ }}} 277 + 278 +{{{     state Slowdown {}}} 279 + 280 +{{{       entry debug / 'println("[trainNum][ST-ST] Slowing down on *_LN_5")';}}} 281 + 282 +{{{       entry / 'railTrack(*_LN_5,FWD,trainNum,CAUTION)';}}} 283 + 284 +{{{     }}}} 285 + 286 +{{{     --> Waiting with 'railContact(*_LN_5,1)'}}} 287 + 288 +{{{     --> Continue with perm_all_next_segments;}}} 289 + 290 +{{{ }}} 291 + 292 +{{{     state Waiting {}}} 293 + 294 +{{{       entry debug / 'println("[trainNum][ST-ST] Stopping on *_LN_5")';}}} 295 + 296 +{{{       entry / 'railTrackBrake(*_LN_5)';}}} 297 + 298 +{{{     }}}} 299 + 300 +{{{     --> Continue with perm_all_next_segments;}}} 301 + 302 +{{{ }}} 303 + 304 +{{{     final state Continue {}}} 305 + 306 +{{{       entry debug / 'println("[trainNum][ST-ST] Continuing on *_LN_5")';       }}} 307 + 308 +{{{       entry i_arrOnTrack == 1 / 'railTrack(*_ST_1,FWD,trainNum,NORMAL)';}}} 309 + 310 +{{{       entry i_arrOnTrack == 2 / 'railTrack(*_ST_2,FWD,trainNum,NORMAL)';}}} 311 + 312 +{{{       entry i_arrOnTrack == 3 / 'railTrack(*_ST_3,FWD,trainNum,NORMAL)';}}} 313 + 314 +{{{       ----------}}} 315 + 316 +{{{       entry / arrTrack = i_arrOnTrack;}}} 317 + 318 +{{{     };}}} 319 + 320 +{{{ }}} 321 + 322 +{{{   region Cleanup:}}} 323 + 324 +{{{     initial state Entry}}} 325 + 326 +{{{     --> cleanup with 'railContact(*_LN_5,0)';}}} 327 + 328 +{{{ }}} 329 + 330 +{{{     final state cleanup {}}} 331 + 332 +{{{       entry debug / 'println("[trainNum][ST-ST] Entered *_LN_5 completely")';}}} 333 + 334 +{{{       entry / 'railTrackOff(*_LN_4)';}}} 335 + 336 +{{{       entry / *_LN_4_req[trainNum] = false;}}} 337 + 338 +{{{     };}}} 339 + 340 +{{{ }}} 341 + 342 +{{{   region Permissions:}}} 343 + 344 +{{{     initial state checking {}}} 345 + 346 +{{{       entry / *_ST_0_req[trainNum] = true;}}} 347 + 348 +{{{       entry destTrack == 1 | !cleanup / *_ST_1_req[trainNum] = true;}}} 349 + 350 +{{{       entry destTrack == 2 | !cleanup / *_ST_2_req[trainNum] = true;}}} 351 + 352 +{{{       entry destTrack == 3 | !cleanup / *_ST_3_req[trainNum] = true;}}} 353 + 354 +{{{     }}}} 355 + 356 +\\ 357 + 358 +{{{     --> success with destTrack == 1 & *_ST_0_perm == trainNum & *_ST_1_perm == trainNum / i_arrOnTrack = 1}}} 359 + 360 +\\ 361 + 362 +{{{     --> success with destTrack == 2 & *_ST_0_perm == trainNum & *_ST_2_perm == trainNum / i_arrOnTrack = 2}}} 363 + 364 +\\ 365 + 366 +{{{     --> success with destTrack == 3 & *_ST_0_perm == trainNum & *_ST_3_perm == trainNum / i_arrOnTrack = 3}}} 367 + 368 +{{{     --> success with *_ST_0_perm == trainNum & *_ST_1_perm == trainNum / i_arrOnTrack = 1}}} 369 + 370 +{{{     --> success with *_ST_0_perm == trainNum & *_ST_2_perm == trainNum / i_arrOnTrack = 2}}} 371 + 372 +{{{     --> success with *_ST_0_perm == trainNum & *_ST_3_perm == trainNum / i_arrOnTrack = 3}}} 373 + 374 + 375 +\\ 376 + 377 +{{{     --> resolving with *_ST_0_perm == trainNum | *_ST_3_perm == trainNum | *_ST_2_perm == trainNum | *_ST_1_perm == trainNum;}}} 378 + 379 +{{{ }}} 380 + 381 +{{{     state resolving}}} 382 + 383 +{{{     --> resolving1;}}} 384 + 385 +{{{ }}} 386 + 387 +{{{     state resolving1 {}}} 388 + 389 +{{{       entry / *_ST_0_req[trainNum] = false;}}} 390 + 391 +{{{       entry / *_ST_1_req[trainNum] = false;}}} 392 + 393 +{{{       entry / *_ST_2_req[trainNum] = false;}}} 394 + 395 +{{{       entry / *_ST_3_req[trainNum] = false;}}} 396 + 397 +{{{     }}}} 398 + 399 +{{{     --> checking;}}} 400 + 401 +{{{ }}} 402 + 403 +{{{     state success}}} 404 + 405 +{{{     --> success1;}}} 406 + 407 +{{{ }}} 408 + 409 +{{{     final state success1 {}}} 410 + 411 +{{{       entry !(i_arrOnTrack == 1) / *_ST_1_req[trainNum] = false;     }}} 412 + 413 +{{{       entry !(i_arrOnTrack == 2) / *_ST_2_req[trainNum] = false;}}} 414 + 415 +{{{       entry !(i_arrOnTrack == 3) / *_ST_3_req[trainNum] = false;}}} 416 + 417 +{{{       entry / perm_all_next_segments = true;}}} 418 + 419 +{{{     };}}} 420 + 421 +{{{ }>-> *_LN_5_*_ST;}}} 422 + 423 +{{{ }}} 424 + 425 +{{{ state *_LN_5_*_ST}}} 426 + 427 +{{{ --> Arr_*_ST with i_arrOnTrack == 1 & 'railContact(*_ST_1,0)'}}} 428 + 429 +{{{ --> Arr_*_ST with i_arrOnTrack == 2 & 'railContact(*_ST_2,0)'}}} 430 + 431 +{{{ --> Arr_*_ST with i_arrOnTrack == 3 & 'railContact(*_ST_3,0)';}}} 432 + 433 +{{{ }}} 434 + 435 +{{{ state Arr_*_ST {}}} 436 + 437 +{{{   entry / 'railSignal(*_LN_5, FWD, RED)';}}} 438 + 439 +{{{   entry / 'railTrackOff(*C_LN_5)';}}} 440 + 441 +{{{   entry / 'railTrack(*_ST_0,FWD,trainNum,SLOW)';}}} 442 + 443 +{{{   entry i_arrOnTrack == 1 / 'railTrack(*_ST_1,FWD,trainNum,SLOW)';}}} 444 + 445 +{{{   entry i_arrOnTrack == 2 / 'railTrack(*_ST_2,FWD,trainNum,SLOW)';}}} 446 + 447 +{{{   entry i_arrOnTrack == 3 / 'railTrack(*_ST_3,FWD,trainNum,SLOW)';}}} 448 + 449 +{{{   entry / *_LN_5_req[trainNum] = false;}}} 450 + 451 +{{{ }}} 452 + 453 +{{{   initial state SlowEntry}}} 454 + 455 +{{{   --> Slow with i_arrOnTrack == 1 & 'railContact(*_ST_1,0)'}}} 456 + 457 +{{{   --> Slow with i_arrOnTrack == 2 & 'railContact(*_ST_2,0)'}}} 458 + 459 +{{{   --> Slow with i_arrOnTrack == 3 & 'railContact(*_ST_3,0)';}}} 460 + 461 +{{{ }}} 462 + 463 +{{{   state Slow {}}} 464 + 465 +{{{     entry / 'railTrackOff(*_ST_0)';}}} 466 + 467 +{{{     entry / *_ST_0_req[trainNum] = false;}}} 468 + 469 +{{{   }}}} 470 + 471 +{{{   --> Halt with i_arrOnTrack == 1 & 'railContact(*_ST_1,1)'}}} 472 + 473 +{{{   --> Halt with i_arrOnTrack == 2 & 'railContact(*_ST_2,1)'}}} 474 + 475 +{{{   --> Halt with i_arrOnTrack == 3 & 'railContact(*_ST_3,1)';}}} 476 + 477 +{{{ }}} 478 + 479 +{{{   final state Halt {}}} 480 + 481 +{{{     entry i_arrOnTrack == 1 / 'railTrackBrake(*_ST_1)';}}} 482 + 483 +{{{     entry i_arrOnTrack == 2 / 'railTrackBrake(*_ST_2)';}}} 484 + 485 +{{{     entry i_arrOnTrack == 3 / 'railTrackBrake(*_ST_3)';}}} 486 + 487 +{{{     entry i_arrOnTrack == 1 / 'railArrival(trainNum, *_ST_1)';}}} 488 + 489 +{{{     entry i_arrOnTrack == 2 / 'railArrival(trainNum, *_ST_2)';}}} 490 + 491 +{{{     entry i_arrOnTrack == 3 / 'railArrival(trainNum, *_ST_3)';}}} 492 + 493 +{{{   };}}} 494 + 495 +{{{ }}}} 496 + 497 +{{{ >-> done;}}} 498 + 499 +{{{ }}} 500 + 501 +{{{ state done}}} 502 + 503 +{{{ --> reallyDone with 'railDeparture(trainNum)';}}} 504 + 505 +{{{ }}} 506 + 507 +{{{ final state reallyDone;}}} 508 +)))|=((( 509 +~/~/ All permissiions variables 510 + 511 +~/~/ All request variables 512 + 513 +~/~/ Train number 514 + 515 +~/~/ Departure track number 516 + 517 +~/~/ Destination track number 518 + 519 +~/~/ Cleanup flag for selecting the track of destination 520 + 521 +~/~/ Debug flag for additional output 522 + 523 +~/~/ Arrival track 524 + 525 +~/~/ Variable (arrival track) for selecting correct station elements 526 + 186 186 187 187 188 - ==Station-2-Stationcontroller==529 +~/~/ Handles departing from a station 189 189 190 - EachStation-2-Stationcontroller realizesthe movement from one of the stations (IC,OC,KH) to anotherstation. All controllersusingIC or OC parts have to respect the travelingdirections. For the KickingHorse Pass two separate controllers, forwards and backwards, are used.531 +~/~/ Additional output for debugging 191 191 192 - Thecontrollers starting from Kicking Horse Pass Station make an assumption of the direction of the train. These are dependent on the directions of the inner or outer circle, e.g. the KHIC controller starts backwards because this is the only valid direction to travel this path. To drive a train from the Kicking Horse Station (facing forward) to the Inner Circle we have to combine the KHOC and OCIC controllers.533 + 193 193 194 - [[image:attach:ICIC.png]]535 +~/~/ State, which set requests for needed tracks 195 195 196 -When arriving on a station the train controller **must** first call the function //void railArrival(int train, int station)//. This starts the waiting timer for the train. 197 -Next the train **must** wait for// int railDeparture(int train)// to return 1. 198 -After the waiting has finished the controller can reach a final state and pass the control back to the train controller. 537 + 199 199 200 - ===Structure ===539 + 201 201 202 -{{code linenumbers="true" language="sct"}} 203 -// 204 -// Structure of a Station-2-Station controller from Station * to Station * 205 -// 206 -scchart STST " * to * Controller " { 541 + 207 207 208 - // Set of permission variables for required tracks 209 - input int *_perm; 543 +~/~/ Transition for received **all** needed permissions 210 210 211 - // Set of request variables for required tracks for 11 trains 212 - output bool *_req[11]; 545 +~/~/ Tranisition for received **some** needed permissions 213 213 214 - // Train number 215 - input int trainNum; 547 + 216 216 217 - // Number of the departure track in a station 218 - input int depTrack; 549 +~/~/ State for waiting an additional Tick 219 219 220 - // Number of the destination track in a station 221 - input int destTrack; 551 + 222 222 223 - // Cleanup flag for selecting the destination track 224 - input bool cleanup; 553 + 225 225 226 - // Debug flag for additional output 227 - input bool debug; 555 +~/~/ State, which releases the requests for needed tracks 228 228 229 - // Arrival track 230 - output int arrTrack; 557 + 231 231 232 - // Variable with value for arrTrack for selecting correct station elements 233 - int i_arrOnTrack; 234 234 235 - // Handles departing from a station * 236 - initial state *_ST { 237 - // hostcode call for additional output when debug 238 - entry debug / 'println([trainNum][ST-ST] ... )'; 560 + 239 239 240 - // State, which sets requests for needed tracks 241 - initial state waitForPerm { 242 - entry / *_ST_4_req[trainNum] = true; 243 - entry / *_LN_0_req[trainNum] = true; 244 - } 245 - // Transition is taken, if all permissions are received 246 - --> gotPerm with (*_ST_4_perm == trainNum) & (*_LN_0_perm == trainNum) 247 - // Transition is taken, if some (not all) permissions are received 248 - --> backOff with (*_ST_4_perm == trainNum) | (*_LN_0_perm == trainNum); 562 + 563 +~/~/ Transition to trying the requesting again 564 + 249 249 250 - // State for waiting an additional tick when not all permissions are received 251 - state backOff 252 - --> backOff1; 566 + 253 253 254 - // State, which releases the requests for needed tracks 255 - state backOff1 { 256 - entry / *_ST_4_req[trainNum] = false; 257 - entry / *_LN_0_req[trainNum] = false; 258 - } 259 - // Transition to repeat requesting permissions procedure 260 - --> waitForPerm; 568 + 261 261 262 - final state gotPerm; 263 - } 264 - // Transition to the departure state 265 - >-> Dep_*_ST; 570 + 571 +~/~/ Transition to the departure state 572 + 266 266 267 - // State, which handles the departure of a train 268 - state Dep_*_ST { 269 - // Set of entry-Actions with hostcode calls to set tracks, points and signals according to depTrack 270 - entry / 'railPoint(*,STRAIGHT)'; 271 - entry / 'railSignal(*_LN_0, FWD, RED)'; 272 - entry / 'railTrack(*_LN_0,FWD,trainNum,NORMAL)'; 273 - entry / 'railTrack(*_ST_4,FWD,trainNum,NORMAL)'; 274 - entry depTrack == 1 / 'railSignal(*_ST_1, FWD, GREEN)'; 275 - entry depTrack == 2 / 'railSignal(*_ST_2, FWD, GREEN)'; 276 - entry depTrack == 3 / 'railSignal(*_ST_3, FWD, GREEN)'; 277 - //... 278 - // Transition to next track segment, if contact is triggered 279 - } --> *_LN_0 with 'railContact(*_LN_0,0)'; 574 + 575 +~/~/ State, which handles the train departure 576 + 577 +~/~/ Set of entry-Actions to set tracks, points and signals according to depTrack 578 + 280 280 281 281 282 282 283 - // ..................................................................................... 284 - // Set of track segment controlling states such as follows 285 - // ..................................................................................... 286 286 287 - // Transition to next track segment, if contact is triggered 288 - state *_LN_0 { 289 - // Hostcode calls for outputs 290 - entry / 'println("[trainNum][ST-ST] Entering *_LN_0")'; 291 - entry debug / 'println("[trainNum][ST-ST] Requesting permission for *_LN_1")'; 292 - // Entry-Actions with hostcode calls to set previous signal according to depTrack to RED 293 - entry depTrack == 1 / 'railSignal(*_ST_1, FWD, RED)'; 294 - entry depTrack == 2 / 'railSignal(*_ST_2, FWD, RED)'; 295 - entry depTrack == 3 / 'railSignal(*_ST_3, FWD, RED)'; 296 - // Requesting the next track segment 297 - entry / *_LN_1_req[trainNum] = true; 583 + 298 298 299 - // Region for handling train driving 300 - region Travel: 301 - initial state Entry 302 - // Transition to continuing state, if permitted 303 - --> Continue with 'railContact(*_LN_0,0)' & (*_LN_1_perm == trainNum) 304 - // Transition to slowing down else 305 - --> Slowdown with 'railContact(*_LN_0,0)'; 585 + 306 306 307 - // State for slowing down the train 308 - state Slowdown { 309 - entry debug / 'println("[trainNum][ST-ST] Slowing down on *_LN_0")'; 310 - // Entry-Action with hostcode calls for slowing down the train 311 - entry / 'railTrack(*_LN_0,FWD,trainNum,CAUTION)'; 312 - } 313 - // Transition to waiting state 314 - --> Waiting with 'railContact(*_LN_0,1)' 315 - // Transition to continuing state, if permitted 316 - --> Continue with *_LN_1_perm == trainNum; 587 + 317 317 318 - // State for train waiting on permission 319 - state Waiting { 320 - entry debug / 'println("[trainNum][ST-ST] Stopping on *_LN_0")'; 321 - // Entry-Action with hostcode call for stopping the train 322 - entry / 'railTrackBrake(*_LN_0)'; 323 - } 324 - --> Continue with *_LN_1_perm == trainNum; 589 + 325 325 326 - // State to continuing driving on the track 327 - final state Continue { 328 - entry debug / 'println("[trainNum][ST-ST] Continuing on *_LN_0")'; 329 - // Entry-Actions with hostcode calls to set tracks and signals for driving 330 - entry / 'railSignal(*_LN_0,FWD,GREEN)'; 331 - entry / 'railTrack(*_LN_0,FWD,trainNum,NORMAL)'; 332 - entry / 'railTrack(*_LN_1,FWD,trainNum,NORMAL)'; 333 - entry / 'railSignal(*_LN_1, FWD, RED)'; 334 - }; 591 + 592 +~/~/ Transition to next track segment, if contact is readed 593 + 335 335 336 - // Region for handling cleanup functionalities337 - regionCleanup:338 - initial state Entry339 - //Transitiontocleanup state340 - --> cleanup with 'railContact(*_LN_0,0)';595 + 596 +~/~/ State for handling the train on track *_LN_0 597 + 598 +~/~/ Outputs for debugging 599 + 341 341 342 - // State for cleaning up the previous track segments 343 - final state cleanup { 344 - entry debug / 'println("[trainNum][ST-ST] Entered *_LN_0 completely")'; 345 - // Entry-Action with hostcode call to switching off the previous track 346 - entry / 'railTrackOff(*_ST_4)'; 347 - // Entry-Action to release the previous track 348 - entry / *_ST_4_req[trainNum] = false; 349 - }; 350 - // Transition to transitional state 351 - }>-> *_LN_0_*_LN_1; 601 + 602 +~/~/ Entry-Actions to set the previous signals to RED 603 + 352 352 353 - state *_LN_0_*_LN_1 354 - // Transition to next track segment, if contact is triggered 355 - --> *_LN_1 with 'railContact(*_LN_1,0)'; 605 + 356 356 357 - // .................................................................................. 358 358 608 +~/~/ Requesting the next segment 359 359 610 + 360 360 361 - // State for entering a station 362 - state *_LN_5 { 363 - // Variable for checking all needed permissions 364 - int perm_all_next_segments = false; 365 - entry / 'println("[trainNum][ST-ST] Entering *_LN_5")'; 366 - entry / 'railSignal(*_LN_4, FWD, RED)'; 612 +~/~/ Region for handling train driving 613 + 367 367 368 - // Region for handling train driving such as above, 369 - // only with perm_all_next_segments for permitting more than one track 370 - region Travel: 371 - initial state Entry 372 - --> Continue with 'railContact(*_LN_5,0)' & perm_all_next_segments 373 - --> Slowdown with 'railContact(*_LN_5,0)'; 615 + 616 +~/~/ Transition to continuing state, if permitted 617 + 618 +~/~/ Transition to slowing down else 619 + 374 374 375 - state Slowdown { 376 - entry debug / 'println("[trainNum][ST-ST] Slowing down on *_LN_5")'; 377 - entry / 'railTrack(*_LN_5,FWD,trainNum,CAUTION)'; 378 - } 379 - --> Waiting with 'railContact(*_LN_5,1)' 380 - --> Continue with perm_all_next_segments; 621 + 622 +~/~/ State for slowing down 623 + 624 +~/~/ Addtitional output for debugging 625 + 626 +~/~/ Entry-Action for slowing down the train 627 + 381 381 382 - state Waiting {383 - entry debug/'println("[trainNum][ST-ST]Stoppingon *_LN_5")';384 - entry / 'railTrackBrake(*_LN_5)';385 - }386 - --> Continue with perm_all_next_segments;629 + 630 +~/~/ Transition to waiting state 631 + 632 +~/~/ Transition to continuing state, if permitted 633 + 387 387 388 - final state Continue { 389 - entry debug / 'println("[trainNum][ST-ST] Continuing on *_LN_5")'; 390 - entry i_arrOnTrack == 1 / 'railTrack(*_ST_1,FWD,trainNum,NORMAL)'; 391 - entry i_arrOnTrack == 2 / 'railTrack(*_ST_2,FWD,trainNum,NORMAL)'; 392 - entry i_arrOnTrack == 3 / 'railTrack(*_ST_3,FWD,trainNum,NORMAL)'; 393 - //... 394 - entry / arrTrack = i_arrOnTrack; 395 - }; 635 + 636 +~/~/ Waiting state 637 + 638 +~/~/ Addtitional output for debugging 639 + 640 +~/~/ Entry-Action for stopping the train 641 + 396 396 397 - // Region for handling cleanup-functionalities such as above 398 - region Cleanup: 399 - initial state Entry 400 - --> cleanup with 'railContact(*_LN_5,0)'; 643 + 644 +~/~/ Tranisition to continuing state 645 + 401 401 402 - final state cleanup { 403 - entry debug / 'println("[trainNum][ST-ST] Entered *_LN_5 completely")'; 404 - entry / 'railTrackOff(*_LN_4)'; 405 - entry / *_LN_4_req[trainNum] = false; 406 - }; 647 + 648 +~/~/ State to continuing driving on the track 649 + 650 +~/~/ Addtitional output for debugging 651 + 652 +~/~/ Entry-Actions to set tracks and signals for driving 653 + 407 407 408 - // Region for handling permissions of all needed tracks 409 - region Permissions: 410 - // State for requesting all needed tracks according to destination track and cleanup-Flag 411 - initial state checking { 412 - entry / *_ST_0_req[trainNum] = true; 413 - entry destTrack == 1 | !cleanup / *_ST_1_req[trainNum] = true; 414 - entry destTrack == 2 | !cleanup / *_ST_2_req[trainNum] = true; 415 - entry destTrack == 3 | !cleanup / *_ST_3_req[trainNum] = true; 416 - } 417 - // Transitions for permitted tracks match wished tracks 418 - --> success with destTrack == 1 & *_ST_0_perm == trainNum & *_ST_1_perm == trainNum / i_arrOnTrack = 1 419 - --> success with destTrack == 2 & *_ST_0_perm == trainNum & *_ST_2_perm == trainNum / i_arrOnTrack = 2 420 - --> success with destTrack == 3 & *_ST_0_perm == trainNum & *_ST_3_perm == trainNum / i_arrOnTrack = 3 421 - // Transitions for permitted tracks don't match wished tracks 422 - --> success with *_ST_0_perm == trainNum & *_ST_1_perm == trainNum / i_arrOnTrack = 1 423 - --> success with *_ST_0_perm == trainNum & *_ST_2_perm == trainNum / i_arrOnTrack = 2 424 - --> success with *_ST_0_perm == trainNum & *_ST_3_perm == trainNum / i_arrOnTrack = 3 425 - // Transition for not all tracks permitted 426 - --> resolving with *_ST_0_perm == trainNum | *_ST_3_perm == trainNum | *_ST_2_perm == trainNum | *_ST_1_perm == trainNum; 655 + 427 427 428 - // State for waiting an additional tick 429 - state resolving 430 - --> resolving1; 431 - 432 - // State for releasing track requests 433 - state resolving1 { 434 - entry / *_ST_0_req[trainNum] = false; 435 - entry / *_ST_1_req[trainNum] = false; 436 - entry / *_ST_2_req[trainNum] = false; 437 - entry / *_ST_3_req[trainNum] = false; 438 - } 439 - // Transition for trying the requesting again 440 - --> checking; 657 + 441 441 442 - // State for waiting an additional tick 443 - state success 444 - --> success1; 445 445 446 - // State for releasing not used track requests 447 - final state success1 { 448 - entry !(i_arrOnTrack == 1) / *_ST_1_req[trainNum] = false; 449 - entry !(i_arrOnTrack == 2) / *_ST_2_req[trainNum] = false; 450 - entry !(i_arrOnTrack == 3) / *_ST_3_req[trainNum] = false; 451 - // Settting perm_all_next_segments to true 452 - entry / perm_all_next_segments = true; 453 - }; 454 - // Transition to station entry states 455 - }>-> *_LN_5_*_ST; 456 456 457 - // State waiting for station entry 458 - state *_LN_5_*_ST 459 - --> Arr_*_ST with i_arrOnTrack == 1 & 'railContact(*_ST_1,0)' 460 -  --> Arr_*_ST with i_arrOnTrack == 2 & 'railContact(*_ST_2,0)' 461 - --> Arr_*_ST with i_arrOnTrack == 3 & 'railContact(*_ST_3,0)'; 661 + 462 462 463 - // State for setting tracks, points and signals according to i_arrOnTrack 464 - // and releasing previous track request 465 - state Arr_*_ST { 466 - entry / 'railSignal(*_LN_5, FWD, RED)'; 467 - entry / 'railTrackOff(*_LN_5)'; 468 - entry / 'railTrack(*_ST_0,FWD,trainNum,SLOW)'; 469 - entry i_arrOnTrack == 1 / 'railTrack(*_ST_1,FWD,trainNum,SLOW)'; 470 - entry i_arrOnTrack == 2 / 'railTrack(*_ST_2,FWD,trainNum,SLOW)'; 471 - entry i_arrOnTrack == 3 / 'railTrack(*_ST_3,FWD,trainNum,SLOW)'; 472 - entry / *_LN_5_req[trainNum] = false; 663 + 664 +~/~/ Region for handling cleanup-functionalities 665 + 473 473 474 - initial state SlowEntry 475 - --> Slow with i_arrOnTrack == 1 & 'railContact(*_ST_1,0)' 476 - --> Slow with i_arrOnTrack == 2 & 'railContact(*_ST_2,0)' 477 - --> Slow with i_arrOnTrack == 3 & 'railContact(*_ST_3,0)'; 667 + 668 +~/~/ Transition to cleanup state 669 + 478 478 479 - // State for switching off previous track and releasing the request480 - stateSlow {481 - entry / 'railTrackOff(*_ST_0)';482 - entry/*_ST_0_req[trainNum]=false;483 - }484 - //Transitionstohaltstate,whentrainisatsecondcontact of a tracksegment485 - --> Halt with i_arrOnTrack == 1 & 'railContact(*_ST_1,1)'486 - --> Haltwithi_arrOnTrack==2 & 'railContact(*_ST_2,1)'487 - --> Halt with i_arrOnTrack == 3 & 'railContact(*_ST_3,1)';671 + 672 +~/~/ Cleanup state 673 + 674 +~/~/ Addtitional output for debugging 675 + 676 +~/~/ Entry-Action to switching off the previous track 677 + 678 +~/~/ Entry-Action to release the previous track 679 + 488 488 489 - 490 - final state Halt { 491 - // Entry-Actions for braking the train on correct track 492 - entry i_arrOnTrack == 1 / 'railTrackBrake(*_ST_1)'; 493 - entry i_arrOnTrack == 2 / 'railTrackBrake(*_ST_2)'; 494 - entry i_arrOnTrack == 3 / 'railTrackBrake(*_ST_3)'; 495 - // Entry-Actions for waiting for timer on correct track 496 - entry i_arrOnTrack == 1 / 'railArrival(trainNum, *_ST_1)'; 497 - entry i_arrOnTrack == 2 / 'railArrival(trainNum, *_ST_2)'; 498 - entry i_arrOnTrack == 3 / 'railArrival(trainNum, *_ST_3)'; 499 - }; 500 - } 501 - >-> done; 681 + 682 +~/~/ Transition to transitional state 683 + 502 502 503 - state done 504 - // Transition to final state, if timer is ready 505 - --> reallyDone with 'railDeparture(trainNum)'; 685 + 686 +~/~/ Transitional state 687 + 688 +~/~/ Transition to next track segment, if contact is readed 689 + 506 506 507 - final state reallyDone; 508 -} 509 -{{/code}} 691 + 692 + 693 + 694 + 695 + 696 + 697 + 698 + 699 + 700 +~/~/ State for entering a station 701 + 702 +~/~/ Variable for checking all needed permissions 703 + 704 +~/~/ Output 705 + 706 +~/~/ Setting signal to RED 707 + 708 + 709 + 710 +~/~/ Region for handling train driving 711 + 712 + 713 + 714 +~/~/ Transition to continuing state, if permitted 715 + 716 +~/~/ Transition to slowing down else 717 + 718 + 719 + 720 +~/~/ State for slowing down 721 + 722 +~/~/ Addtitional output for debugging 723 + 724 +~/~/ Entry-Action for slowing down the train 725 + 726 + 727 + 728 +~/~/ Transition to waiting state 729 + 730 +~/~/ Transition to continuing state, if permitted 731 + 732 + 733 + 734 +~/~/ Waiting state 735 + 736 +~/~/ Addtitional output for debugging 737 + 738 +~/~/ Entry-Action for stopping the train 739 + 740 + 741 + 742 +~/~/ Tranisition to continuing state 743 + 744 + 745 + 746 +~/~/ State to continuing driving on the track 747 + 748 +~/~/ Addtitional output for debugging 749 + 750 +~/~/ Set of entry-Actions for setting tracks, points and signals according to i_arrOnTrack 751 + 752 + 753 + 754 + 755 + 756 + 757 + 758 +~/~/ Setting the arrival track (output) 759 + 760 + 761 + 762 + 763 + 764 +~/~/ Region for handling cleanup-functionalities 765 + 766 + 767 + 768 +~/~/ Transition to cleanup state 769 + 770 + 771 + 772 +~/~/ Cleanup state 773 + 774 +~/~/ Addtitional output for debugging 775 + 776 +~/~/ Entry-Action to switching off the previous tracks 777 + 778 +~/~/ Entry-Action to release the previous tracks 779 + 780 + 781 + 782 + 783 + 784 +~/~/ Region for handling permissions of all needed tracks 785 + 786 +~/~/ State for requesting all needed tracks according to destination track and cleanup-Flag 787 + 788 + 789 + 790 + 791 + 792 + 793 + 794 + 795 + 796 + 797 + 798 +~/~/ Transitions for permitted tracks match wished tracks 799 + 800 + 801 + 802 + 803 + 804 +~/~/ Transitions for permitted tracks don't match wished tracks 805 + 806 + 807 + 808 + 809 + 810 +~/~/ Transition for not all tracks permitted 811 + 812 + 813 + 814 +~/~/ State for waiting an additional tick 815 + 816 + 817 + 818 + 819 + 820 +~/~/ State for releasing track requests 821 + 822 + 823 + 824 + 825 + 826 + 827 + 828 + 829 + 830 + 831 + 832 +~/~/ Transition for trying the requesting again 833 + 834 + 835 + 836 +~/~/ State for waiting an additional tick 837 + 838 + 839 + 840 + 841 + 842 +~/~/ State for releasing not used track requests and 843 + 844 + 845 + 846 + 847 + 848 + 849 + 850 +~/~/ Settting perm_all_next_segments to true 851 + 852 + 853 + 854 +~/~/ Transition to station entry states 855 + 856 + 857 + 858 +~/~/ State waiting for station entry 859 + 860 + 861 + 862 + 863 + 864 + 865 + 866 + 867 + 868 +~/~/ State for setting tracks, points and signals according to i_arrOnTrack 869 + 870 +~/~/ and releasing previous track request 871 + 872 + 873 + 874 + 875 + 876 + 877 + 878 + 879 + 880 + 881 + 882 + 883 + 884 + 885 + 886 +~/~/ State for slowing down, if train completely on track 887 + 888 + 889 + 890 + 891 + 892 + 893 + 894 + 895 + 896 +~/~/ State for switching off previous track and releasing the request 897 + 898 + 899 + 900 + 901 + 902 + 903 + 904 +~/~/ Transitions to halt states, if train at second contact of a track 905 + 906 + 907 + 908 + 909 + 910 + 911 + 912 + 913 + 914 +~/~/ Entry-Actions for braking the train on correct track 915 + 916 + 917 + 918 + 919 + 920 +~/~/ Entry-Actions for waiting for timer on correct track 921 + 922 + 923 + 924 + 925 + 926 + 927 + 928 + 929 + 930 + 931 + 932 + 933 + 934 + 935 + 936 +~/~/ Transition to final state, if timer is ready 937 +)))
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -94716 661 +9471640 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/SS14Railway/pages/94716 66/Basic design1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/SS14Railway/pages/9471640/Basic design