Changes for page Basic design

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

From version 17.1
edited by sna
on 2014/08/13 02:54
Change comment: There is no comment for this version
To version 20.2
edited by nfl
on 2023/07/13 12:23
Change comment: Update document after refactoring.

Summary

Details

Page properties
Parent
... ... @@ -1,0 +1,1 @@
1 +SS14Railway.Railway Project (summer term 2014).Documentation.SCChart Controller.WebHome
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.sna
1 +XWiki.nfl
Content
... ... @@ -46,7 +46,11 @@
46 46  === Structure ===
47 47  
48 48  {{code linenumbers="true" language="sct"}}
49 -scchart Test2b "Test of IC_JCT" {
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
50 50   bool IC_JCT_0_req[11], IC_LN_0_req[11], IC_LN_1_req[11], IC_LN_2_req[11];
51 51   bool IC_LN_3_req[11], IC_LN_4_req[11], IC_LN_5_req[11], IC_ST_0_req[11];
52 52   bool IC_ST_1_req[11], IC_ST_2_req[11], IC_ST_3_req[11], IC_ST_4_req[11];
... ... @@ -59,7 +59,9 @@
59 59   bool OC_LN_2_req[11], OC_LN_3_req[11], OC_LN_4_req[11], OC_LN_5_req[11];
60 60   bool OC_ST_0_req[11], OC_ST_1_req[11], OC_ST_2_req[11], OC_ST_3_req[11];
61 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;
66 + bool req_in_R, req_out_R, req_in_L, req_out_L;
67 +
68 +  // Set of permission variables for all tracks
63 63   int IC_JCT_0_perm, IC_LN_0_perm, IC_LN_1_perm, IC_LN_2_perm;
64 64   int IC_LN_3_perm, IC_LN_4_perm, IC_LN_5_perm, IC_ST_0_perm;
65 65   int IC_ST_1_perm, IC_ST_2_perm, IC_ST_3_perm, IC_ST_4_perm;
... ... @@ -72,11 +72,16 @@
72 72   int OC_LN_2_perm, OC_LN_3_perm, OC_LN_4_perm, OC_LN_5_perm;
73 73   int OC_ST_0_perm, OC_ST_1_perm, OC_ST_2_perm, OC_ST_3_perm;
74 74   int OC_ST_4_perm, OI_LN_0_perm, OI_LN_1_perm, OI_LN_2_perm;
75 -
81 +  bool perm_in_R, perm_out_R, perm_in_L, perm_out_L;
82 +
83 + // Debug flag for additional output
76 76   bool debug = false;
77 - bool cleanup = 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
78 78   int trainCount;
79 -
89 +
90 + // Set of constants for binding to referenced SCCharts
80 80   const int c_EINS = 1;
81 81   const int c_ZWEI = 2;
82 82   const int c_DREI = 3;
... ... @@ -83,37 +83,59 @@
83 83   const int c_VIER = 4;
84 84   const int c_FUENF = 5;
85 85  
97 + // State initializing the trains on corresponding tracks
86 86   initial state init references initRailway11Trains
87 87   --> run;
88 88  
101 + // State handling the train schedules
89 89   state run {
103 + // Regions handling the mutual exclusion on the track segments
90 90   region Mutexes:
105 +  // State referenced to the MutexController for 11 Trains
91 91   initial state Mutexes references mutexRailway11Trains;
92 92  
93 93   region KH_Mutexes:
109 +  // State referenced to additional MutexController for KH
94 94   initial state KH_Mutexes references kh_mutex;
95 95  
112 + // Regions that contain the schedules for individual trains
113 + //--------------------------------------------------------------------------------------
114 +
115 + // Region with schedule for train 4
96 96   region Train4 :
117 +  // State with the schedule for train 4
97 97   initial state train4 {
98 98  
120 + // Annotation for replacing following constant in the hostcode of referenced SCChart
99 99   @alterHostcode
122 + // Number of the train for identifying on track segments
100 100   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
101 101   int arrivalTrack = 3;
102 102  
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
103 103   initial state Round references ICIC
104 104   bind depTrack to arrivalTrack,
105 105   destTrack to c_DREI,
106 106   arrTrack to arrivalTrack
134 +  // Transition to checking state
107 107   >-> Choice;
108 -
136 +
137 + // State for checking, when the train should halt and if the train is on corresponding track
109 109   state Choice
139 + // Transition for driving additional circle, if cleanup = false or wrong track used
110 110   --> Round with !cleanup | !(arrivalTrack == 3)
141 + // Transition to final state
111 111   --> Done;
112 112  
113 - final state Done;
114 -
144 + final state Done;
115 115   };
116 - region Train5 :
146 +
147 +
148 + // Region with schedule for train 5, identical to region above
149 +  region Train5 :
117 117   initial state train5 {
118 118  
119 119   @alterHostcode
... ... @@ -134,6 +134,8 @@
134 134  
135 135   };
136 136  
170 +
171 + // Region with schedule for train 9, identical to region above
137 137   region Train9 :
138 138   initial state train9 {
139 139  
... ... @@ -153,7 +153,9 @@
153 153  
154 154   final state Done;
155 155   };
156 -
191 +
192 +
193 + // Region with schedule for train 7
157 157   region Train7 :
158 158   initial state train7 {
159 159  
... ... @@ -161,10 +161,14 @@
161 161   const int trainNum = 7;
162 162   int arrivalTrack = 1;
163 163  
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
164 164   initial state OCtoIC references OCIC
165 165   bind depTrack to arrivalTrack,
166 166   destTrack to c_ZWEI,
167 167   arrTrack to arrivalTrack
208 +  // Transition to next Station-2-Station controller
168 168   >-> ICtoOC;
169 169  
170 170   state ICtoOC references ICOC
... ... @@ -171,10 +171,14 @@
171 171   bind depTrack to arrivalTrack,
172 172   destTrack to c_EINS,
173 173   arrTrack to arrivalTrack
215 +  // Transition to checking state because train at home station
174 174   >-> Choice;
175 175  
218 + // State for checking, when the train should halt and if the train is on corresponding track
176 176   state Choice
177 - --> OCtoIC with !cleanup | !(arrivalTrack == 1)
220 + // Transition for driving additional circle, if cleanup = false or wrong track used
221 +  --> OCtoIC with !cleanup | !(arrivalTrack == 1)
222 + // Transition to final state
178 178   --> Done;
179 179  
180 180   final state Done;
... ... @@ -280,9 +280,9 @@
280 280  
281 281  
282 282  
283 - // .....................................................................................
328 + // ----------------------------------------------------------------------------------------------------------------
284 284   // Set of track segment controlling states such as follows
285 - // .....................................................................................
330 + // ----------------------------------------------------------------------------------------------------------------
286 286  
287 287   // Transition to next track segment, if contact is triggered
288 288   state *_LN_0 {
... ... @@ -354,7 +354,7 @@
354 354   // Transition to next track segment, if contact is triggered
355 355   --> *_LN_1 with 'railContact(*_LN_1,0)';
356 356  
357 - // ..................................................................................
402 + // ----------------------------------------------------------------------------------------------------------------
358 358  
359 359  
360 360  
... ... @@ -507,3 +507,193 @@
507 507   final state reallyDone;
508 508  }
509 509  {{/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}}
737 +
738 +=== Dynamic Scheduling ===
739 +
740 +Each train has the same dynamic scheduling. The basic idea are 4 station-states (KH, KHr, IC, OC). Each time a train is one of these states, the next target station is looked up. Depending on the current station there are 4 different travel paths available each leading into in of the 4 station-states. This way the dynamic scheduling can handle every possible schedule for each train.
741 +
742 +In addition to the travel paths each station-state has a cleanup-transition. A train can only enter cleanup mode, when he arrived at his target station. Each train has a homestation and a hometrack, which he travels to once cleanup is started. Upon arriving at their hometrack, the train shuts down. Once every train is shut down, cleanup finished and every train is back at his starting position. Every station has one track, which does not allow the train, who wants to travel to that track, to shut down. These are KH_ST_5, IC_ST_1 and OC_ST_3. The trains traveling to these stations have to drive circles at KH_LN, IC_LN or OC_LN. Once these are the only trains driving, they are allowed to shut down too. This way a station can not block trains to drive through this station by shutting down all trains in that station.
743 +
744 +[[image:attach:DynamicScheduling.png]]
DynamicScheduling.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +2.1 MB
Content
ICIC.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +824.1 KB
Content
Mutex.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +24.9 KB
Content
Mutex_KH.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +398.9 KB
Content
T2A3.sct
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.XWikiGuest
Size
... ... @@ -1,0 +1,1 @@
1 +518 bytes
Content
... ... @@ -1,0 +1,19 @@
1 +scchart rail {
2 + input bool second;
3 + input bool contact0,contact1;
4 + output int track;
5 +
6 + initial state stat "station controller" {
7 + region "go" : A;
8 +
9 + initial state init --> running immediate with /track=60;
10 + state running;
11 +
12 + region "platform" : B;
13 +
14 + initial state waiting --> slowdown immediate with contact0 / track = 20;
15 + state slowdown --> stop immediate with contact1 / track = 0;
16 + state stop --> waiting with 5 second / track = 60;
17 +
18 + };
19 +}
Confluence.Code.ConfluencePageClass[0]
Id
... ... @@ -1,1 +1,1 @@
1 -9471666
1 +9471005
URL
... ... @@ -1,1 +1,1 @@
1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/SS14Railway/pages/9471666/Basic design
1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/SS14Railway/pages/9471005/Basic design