Changes for page Basic design

Last modified by nfl on 2025/01/30 12:05

From version 16.1
edited by sna
on 2014/08/13 02:41
Change comment: There is no comment for this version
To version 19.1
edited by sna
on 2014/08/20 23:21
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -43,6 +43,193 @@
43 43  
44 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 +=== Structure ===
47 +
48 +{{code linenumbers="true" language="sct"}}
49 +//
50 +// Structure of a train controller based on test case 2
51 +//
52 +scchart Test2 "Test of IC_JCT" {
53 +  // Set of request variables for all tracks for 11 trains
54 + bool IC_JCT_0_req[11], IC_LN_0_req[11], IC_LN_1_req[11], IC_LN_2_req[11];
55 + bool IC_LN_3_req[11], IC_LN_4_req[11], IC_LN_5_req[11], IC_ST_0_req[11];
56 + bool IC_ST_1_req[11], IC_ST_2_req[11], IC_ST_3_req[11], IC_ST_4_req[11];
57 + bool IO_LN_0_req[11], IO_LN_1_req[11], IO_LN_2_req[11], KH_LN_0_req[11];
58 + bool KH_LN_1_req[11], KH_LN_2_req[11], KH_LN_3_req[11], KH_LN_4_req[11];
59 + bool KH_LN_5_req[11], KH_LN_6_req[11], KH_LN_7_req[11], KH_LN_8_req[11];
60 + bool KH_ST_0_req[11], KH_ST_1_req[11], KH_ST_2_req[11], KH_ST_3_req[11];
61 + bool KH_ST_4_req[11], KH_ST_5_req[11], KH_ST_6_req[11], KIO_LN_0_req[11];
62 + bool KIO_LN_1_req[11], OC_JCT_0_req[11], OC_LN_0_req[11], OC_LN_1_req[11];
63 + bool OC_LN_2_req[11], OC_LN_3_req[11], OC_LN_4_req[11], OC_LN_5_req[11];
64 + bool OC_ST_0_req[11], OC_ST_1_req[11], OC_ST_2_req[11], OC_ST_3_req[11];
65 + bool OC_ST_4_req[11], OI_LN_0_req[11], OI_LN_1_req[11], OI_LN_2_req[11];
66 + bool req_in_R, req_out_R, req_in_L, req_out_L;
67 +
68 +  // Set of permission variables for all tracks
69 + int IC_JCT_0_perm, IC_LN_0_perm, IC_LN_1_perm, IC_LN_2_perm;
70 + int IC_LN_3_perm, IC_LN_4_perm, IC_LN_5_perm, IC_ST_0_perm;
71 + int IC_ST_1_perm, IC_ST_2_perm, IC_ST_3_perm, IC_ST_4_perm;
72 + int IO_LN_0_perm, IO_LN_1_perm, IO_LN_2_perm, KH_LN_0_perm;
73 + int KH_LN_1_perm, KH_LN_2_perm, KH_LN_3_perm, KH_LN_4_perm;
74 + int KH_LN_5_perm, KH_LN_6_perm, KH_LN_7_perm, KH_LN_8_perm;
75 + int KH_ST_0_perm, KH_ST_1_perm, KH_ST_2_perm, KH_ST_3_perm;
76 + int KH_ST_4_perm, KH_ST_5_perm, KH_ST_6_perm, KIO_LN_0_perm;
77 + int KIO_LN_1_perm, OC_JCT_0_perm, OC_LN_0_perm, OC_LN_1_perm;
78 + int OC_LN_2_perm, OC_LN_3_perm, OC_LN_4_perm, OC_LN_5_perm;
79 + int OC_ST_0_perm, OC_ST_1_perm, OC_ST_2_perm, OC_ST_3_perm;
80 + int OC_ST_4_perm, OI_LN_0_perm, OI_LN_1_perm, OI_LN_2_perm;
81 +  bool perm_in_R, perm_out_R, perm_in_L, perm_out_L;
82 +
83 + // Debug flag for additional output
84 + bool debug = false;
85 + // Cleanup flag for halting the trains at home station tracks
86 +  bool cleanup = false;
87 +  // Variable, that gives the number of trains to C-Controller for stability check
88 + int trainCount;
89 +
90 + // Set of constants for binding to referenced SCCharts
91 + const int c_EINS = 1;
92 + const int c_ZWEI = 2;
93 + const int c_DREI = 3;
94 + const int c_VIER = 4;
95 + const int c_FUENF = 5;
96 +
97 + // State initializing the trains on corresponding tracks
98 + initial state init references initRailway11Trains
99 + --> run;
100 +
101 + // State handling the train schedules
102 + state run {
103 + // Regions handling the mutual exclusion on the track segments
104 + region Mutexes:
105 +  // State referenced to the MutexController for 11 Trains
106 + initial state Mutexes references mutexRailway11Trains;
107 +
108 + region KH_Mutexes:
109 +  // State referenced to additional MutexController for KH
110 + initial state KH_Mutexes references kh_mutex;
111 +
112 + // Regions that contain the schedules for individual trains
113 + //--------------------------------------------------------------------------------------
114 +
115 + // Region with schedule for train 4
116 + region Train4 :
117 +  // State with the schedule for train 4
118 + initial state train4 {
119 +
120 + // Annotation for replacing following constant in the hostcode of referenced SCChart
121 + @alterHostcode
122 + // Number of the train for identifying on track segments
123 + const int trainNum = 4;
124 +  // Variable specifying the track, where the train arrives at,
125 + // and for transmitting the track number to next Station-2-Station controller
126 + int arrivalTrack = 3;
127 +
128 + // Schedule of train 4: train drives only in the IC, should use station track 3
129 + // State Round referenced to ICIC Station-2-Station controller
130 + initial state Round references ICIC
131 + bind depTrack to arrivalTrack,
132 + destTrack to c_DREI,
133 + arrTrack to arrivalTrack
134 +  // Transition to checking state
135 + >-> Choice;
136 +
137 + // State for checking, when the train should halt and if the train is on corresponding track
138 + state Choice
139 + // Transition for driving additional circle, if cleanup = false or wrong track used
140 + --> Round with !cleanup | !(arrivalTrack == 3)
141 + // Transition to final state
142 + --> Done;
143 +
144 + final state Done;
145 + };
146 +
147 +
148 + // Region with schedule for train 5, identical to region above
149 +  region Train5 :
150 + initial state train5 {
151 +
152 + @alterHostcode
153 + const int trainNum = 5;
154 + int arrivalTrack = 2;
155 +
156 + initial state Round references ICIC
157 + bind depTrack to arrivalTrack,
158 + destTrack to c_ZWEI,
159 + arrTrack to arrivalTrack
160 + >-> Choice;
161 +
162 + state Choice
163 + --> Round with !cleanup | !(arrivalTrack == 2)
164 + --> Done;
165 +
166 + final state Done;
167 +
168 + };
169 +
170 +
171 + // Region with schedule for train 9, identical to region above
172 + region Train9 :
173 + initial state train9 {
174 +
175 + @alterHostcode
176 + const int trainNum = 9;
177 + int arrivalTrack = 1;
178 +
179 + initial state Round references ICIC
180 + bind depTrack to arrivalTrack,
181 + destTrack to c_EINS,
182 + arrTrack to arrivalTrack
183 + >-> Choice;
184 +
185 + state Choice
186 + --> Round with !cleanup | !(arrivalTrack == 1)
187 + --> Done;
188 +
189 + final state Done;
190 + };
191 +
192 +
193 + // Region with schedule for train 7
194 + region Train7 :
195 + initial state train7 {
196 +
197 + @alterHostcode
198 + const int trainNum = 7;
199 + int arrivalTrack = 1;
200 +
201 + // Schedule of train 7: train drives from OC-Station track 1 to IC-Station track 2 and back
202 + // arrivalTrack used for transmitting the number of station track where train arrived on
203 + // to next controller where the train starts on
204 + initial state OCtoIC references OCIC
205 + bind depTrack to arrivalTrack,
206 + destTrack to c_ZWEI,
207 + arrTrack to arrivalTrack
208 +  // Transition to next Station-2-Station controller
209 + >-> ICtoOC;
210 +
211 + state ICtoOC references ICOC
212 + bind depTrack to arrivalTrack,
213 + destTrack to c_EINS,
214 + arrTrack to arrivalTrack
215 +  // Transition to checking state because train at home station
216 + >-> Choice;
217 +
218 + // State for checking, when the train should halt and if the train is on corresponding track
219 + state Choice
220 + // Transition for driving additional circle, if cleanup = false or wrong track used
221 +  --> OCtoIC with !cleanup | !(arrivalTrack == 1)
222 + // Transition to final state
223 + --> Done;
224 +
225 + final state Done;
226 + };
227 + };
228 +}
229 +{{/code}}
230 +
231 +
232 +
46 46  == Station-2-Station controller ==
47 47  
48 48  Each Station-2-Station controller realizes the movement from one of the stations (IC,OC,KH) to another 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.
... ... @@ -138,9 +138,9 @@
138 138  
139 139  
140 140  
141 - // .....................................................................................
328 + // ----------------------------------------------------------------------------------------------------------------
142 142   // Set of track segment controlling states such as follows
143 - // .....................................................................................
330 + // ----------------------------------------------------------------------------------------------------------------
144 144  
145 145   // Transition to next track segment, if contact is triggered
146 146   state *_LN_0 {
... ... @@ -212,7 +212,7 @@
212 212   // Transition to next track segment, if contact is triggered
213 213   --> *_LN_1 with 'railContact(*_LN_1,0)';
214 214  
215 - // ..................................................................................
402 + // ----------------------------------------------------------------------------------------------------------------
216 216  
217 217  
218 218  
... ... @@ -365,3 +365,185 @@
365 365   final state reallyDone;
366 366  }
367 367  {{/code}}
555 +
556 +== Dynamic Controller ==
557 +
558 +The dynamic controller handles all 11 Trains. For each train the controller has a region with a referenced dynamic scheduling. Thereby each train can follow an arbitrary schedule. Additionally the controller has a region for stable cleanup function.
559 +
560 +{{code linenumbers="true" language="sct"}}
561 +//
562 +// Dynamic controller for 11 trains
563 +//
564 +scchart DynamicController11 {
565 + // Set of request variables for all tracks for 11 trains
566 + bool IC_JCT_0_req[11], IC_LN_0_req[11], IC_LN_1_req[11], IC_LN_2_req[11];
567 + bool IC_LN_3_req[11], IC_LN_4_req[11], IC_LN_5_req[11], IC_ST_0_req[11];
568 + bool IC_ST_1_req[11], IC_ST_2_req[11], IC_ST_3_req[11], IC_ST_4_req[11];
569 + bool IO_LN_0_req[11], IO_LN_1_req[11], IO_LN_2_req[11], KH_LN_0_req[11];
570 + bool KH_LN_1_req[11], KH_LN_2_req[11], KH_LN_3_req[11], KH_LN_4_req[11];
571 + bool KH_LN_5_req[11], KH_LN_6_req[11], KH_LN_7_req[11], KH_LN_8_req[11];
572 + bool KH_ST_0_req[11], KH_ST_1_req[11], KH_ST_2_req[11], KH_ST_3_req[11];
573 + bool KH_ST_4_req[11], KH_ST_5_req[11], KH_ST_6_req[11], KIO_LN_0_req[11];
574 + bool KIO_LN_1_req[11], OC_JCT_0_req[11], OC_LN_0_req[11], OC_LN_1_req[11];
575 + bool OC_LN_2_req[11], OC_LN_3_req[11], OC_LN_4_req[11], OC_LN_5_req[11];
576 + bool OC_ST_0_req[11], OC_ST_1_req[11], OC_ST_2_req[11], OC_ST_3_req[11];
577 + bool OC_ST_4_req[11], OI_LN_0_req[11], OI_LN_1_req[11], OI_LN_2_req[11];
578 + bool req_in_R , req_out_R , req_in_L , req_out_L;
579 +  
580 + // Set of permission variables for all tracks
581 + int IC_JCT_0_perm, IC_LN_0_perm, IC_LN_1_perm, IC_LN_2_perm;
582 + int IC_LN_3_perm, IC_LN_4_perm, IC_LN_5_perm, IC_ST_0_perm;
583 + int IC_ST_1_perm, IC_ST_2_perm, IC_ST_3_perm, IC_ST_4_perm;
584 + int IO_LN_0_perm, IO_LN_1_perm, IO_LN_2_perm, KH_LN_0_perm;
585 + int KH_LN_1_perm, KH_LN_2_perm, KH_LN_3_perm, KH_LN_4_perm;
586 + int KH_LN_5_perm, KH_LN_6_perm, KH_LN_7_perm, KH_LN_8_perm;
587 + int KH_ST_0_perm, KH_ST_1_perm, KH_ST_2_perm, KH_ST_3_perm;
588 + int KH_ST_4_perm, KH_ST_5_perm, KH_ST_6_perm, KIO_LN_0_perm;
589 + int KIO_LN_1_perm, OC_JCT_0_perm, OC_LN_0_perm, OC_LN_1_perm;
590 + int OC_LN_2_perm, OC_LN_3_perm, OC_LN_4_perm, OC_LN_5_perm;
591 + int OC_ST_0_perm, OC_ST_1_perm, OC_ST_2_perm, OC_ST_3_perm;
592 + int OC_ST_4_perm, OI_LN_0_perm, OI_LN_1_perm, OI_LN_2_perm;
593 + bool perm_in_R , perm_out_R , perm_in_L , perm_out_L;
594 +
595 + // Flags needed for stable cleanup function
596 + //----------------------------------------------------------------------------------------
597 + // Flags for trains are ready and back at home
598 + bool trainDone[11];
599 + // Flags for trains are on their home circle
600 + bool circle[11];
601 + // Flag for trains 0 to 7 are back at home and trains 8 to 10 are on their home circle
602 +  bool mainDone;
603 + // Flag for all trains are back at home
604 +  bool allDone;
605 + //----------------------------------------------------------------------------------------
606 +
607 + // Debug flag for additional output
608 +  bool debug;
609 + // Cleanup flag for halting the trains at home station tracks
610 +  bool cleanup;
611 + // Variable, that gives the number of trains to C-Controller for stability check
612 +  int trainCount;
613 + // Constant needed for binding to referenced SCCharts
614 + const bool c_TRUE = true;
615 +
616 +
617 + // State initializing the trains on corresponding tracks
618 + initial state init references initRailway11Trains
619 + >-> run;
620 +
621 +
622 + // State handling the train schedules
623 +  state run {
624 +
625 +  // Region handling the cleanup function
626 + region Abort:
627 + initial state notDone
628 +  // Transition when trains 0 to 7 are back at home and trains 8 to 10 are on their home circle
629 + --> mainDone with trainDone[0] & trainDone[1] & trainDone[2]
630 + & trainDone[3] & trainDone[4] & trainDone[5]
631 + & trainDone[6] & trainDone[7]
632 + & circle[8] & circle[9] & circle[10];
633 +
634 + // State for allowing trains 8 to 10 to halt on the home track
635 + state mainDone
636 + --> quitCircle with / mainDone = true;
637 +
638 + // State waiting for trains 8 to 10 halt and setting flag for terminate the controller
639 + state quitCircle
640 + --> done with trainDone[8] & trainDone[9] & trainDone[10] / allDone = true;
641 +
642 + final state done;
643 +
644 + // Regions handling the mutual exclusion on the track segments
645 + region Mutexes:
646 + initial state Mutexes references mutexRailway11Trains
647 + // terminates with a strong abort when all trains are at home
648 + o-> done with allDone;
649 +
650 + final state done;
651 +
652 + region KH_Mutexes:
653 + initial state KH_Mutexes references kh_mutex
654 +  // terminates with a strong abort when all trains are at home
655 + o-> done with allDone;
656 +
657 + final state done;
658 +
659 + // Regions that contain the dynamic schedules for trains 0 to 7
660 + //--------------------------------------------------------------------------------------
661 +
662 + // Region with the dynamic schedule for train 0
663 + region Train0:
664 + initial state Train0 {
665 + @alterHostcode
666 + const int trainNum = 0
667 +  // Variable for saving the home track
668 + int homeTrack = 1;
669 + // Variable for saving the home station
670 + int homeStation = 1;
671 +
672 + // State referenced to dynamic scheduling
673 + initial state drive
674 + references DynamicSheduling
675 +  // Binding circleDone to true for halting at home if cleanup is set
676 + bind circleDone to c_TRUE
677 +  // Set a flag and a light for train at home
678 + >-> done with / 'railLight(10,1)'; trainDone[0] = true;
679 +
680 + final state done;
681 + }
682 + >-> done;
683 +
684 + final state done;
685 +
686 + // ... (other regions for trains 1 to 7 such as before)
687 +
688 +  //--------------------------------------------------------------------------------------
689 +
690 +
691 +
692 +
693 + // Regions that contain the dynamic schedules for trains 8 to 10
694 + // Differences to regions above is that the trains 8 to 10 circle at home station circle
695 + // until trains 0 to 7 are back at home station and track
696 + // For this circleDone binds mainDone flag
697 + //--------------------------------------------------------------------------------------
698 +
699 + // Region with the dynamic schedule for train 8
700 + region Train8:
701 + initial state Train8 {
702 + @alterHostcode
703 + const int trainNum = 8
704 + // Variable for saving the home track
705 +  int homeTrack = 5;
706 + // Variable for saving the home station
707 + int homeStation = 1;
708 +
709 + // State referenced to dynamic scheduling
710 + initial state drive
711 + references DynamicSheduling
712 +  // Binding circleDone to mainDone for halting at home only if cleanup is set
713 + // and trains 0 to 7 are at home and 8 to 10 on home circle
714 + bind circleDone to mainDone
715 + // Set a flag and a light for train at home 
716 + >-> done with / 'railLight(6,1)'; trainDone[8] = true;
717 +
718 + final state done;
719 + }
720 + >-> done;
721 +
722 + final state done;
723 +
724 + // ... (other regions for trains 9 and 10 such as before)
725 + //--------------------------------------------------------------------------------------
726 +
727 + }
728 + >-> flash;
729 +
730 + // State for flashing the lights at the end of the controller
731 + state flash
732 + --> done with / 'railFlashLight()';
733 +
734 + final state done;
735 +}
736 +{{/code}}
Confluence.Code.ConfluencePageClass[0]
Id
... ... @@ -1,1 +1,1 @@
1 -9471664
1 +9471750
URL
... ... @@ -1,1 +1,1 @@
1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/SS14Railway/pages/9471664/Basic design
1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/SS14Railway/pages/9471750/Basic design