Wiki source code of Examples

Version 12.1 by ssm on 2015/06/23 16:55

Hide last authors
cmot 10.1 1 [[~[~[image:attach:SCCharts@download.png~]~]>>url:http://rtsys.informatik.uni-kiel.de/confluence/display/KIELER/SCCharts#SCCharts-Downloads||shape="rect"]] [[~[~[image:attach:SCCharts@onlinecompiler.png~]~]>>url:http://www.sccharts.com||shape="rect"]] (% class="confluence-link" %)[[image:attach:Command Line Compiler@commandlinecompiler2.png]][[doc:Command Line Compiler]](%%) [[image:attach:SCCharts@quickstart.png]][[doc:Quick Start Guide]]
2
cmot 9.1 3 = SCCharts Examples =
cmot 4.1 4
ssm 12.1 5 A few SCCharts examples...
6
7 |=(((
8 Example
9 )))|=(((
10
11 )))|=(((
12 SCChart  (Graphical)
13 )))|=(% colspan="1" %)(% colspan="1" %)
14 (((
15 SCChart (Textual SCT)
16 )))
17 |(% colspan="1" %)(% colspan="1" %)
18 (((
19 = clock =
20
21 (Referenced SCCharts Example)
22
23 **To enable the referenced SCCharts feature,**
24
25 **activate the Xtext nature for your project!**
26 )))|(% colspan="1" %)(% colspan="1" %)
27 (((
28
29 )))|(% colspan="1" %)(% colspan="1" %)
30 (((
31 [[image:attach:delay.png]]
32
33 [[image:attach:emitter.png]]
34
35 [[image:attach:clock2h.png]]
36 )))|(% colspan="1" %)(% colspan="1" %)
37 (((
38 {{code title="shifter3.sct" language="sct"}}
39 scchart delay {
40 input int ticksToWait;
41 input bool clock;
42 int counter = 0;
43 initial state init
44 --> done immediate with
45 counter >= ticksToWait
46 --> init with
47 clock / counter = counter + 1;
48 final state done;
49 }
50 {{/code}}
51
52 {{code title="shifter3.sct" language="sct"}}
53 scchart emitter {
54 input bool clock;
55 input bool delay;
56 output bool emit = false;
57 initial state wait
58 references delay
59 bind clock to clock,
60 ticksToWait to delay
61 >-> emit;
62
63 state emit {
64 entry / emit = true;
65 exit / emit = false;
66 }
67 --> wait;
68 }
69 {{/code}}
70
71 {{code title="shifter3.sct" language="sct"}}
72 scchart clock {
73 input bool msClock;
74 output bool second;
75 output bool minute;
76 output bool hour;
77 const int SEC = 1000;
78 const int MIN = 60;
79 const int HOUR = 60;
80 region seconds:
81 initial state seconds
82 references emitter
83 bind clock to msClock,
84 metrum to SEC,
85 emit to second
86 >-> seconds;
87
88 region minutes:
89 initial state minutes
90 references emitter
91 bind clock to second,
92 metrum to MIN,
93 emit to minute
94 >-> minutes;
95
96 region hours:
97 initial state hours
98 references emitter
99 bind clock to minute,
100 metrum to HOUR,
101 emit to hour
102 >-> hours;
103 }
104 {{/code}}
105 )))
106
107 = SCCharts Evaluation Examples =
108
cmot 7.1 109 In the following, you find some examples used for evaluation. Be advised that there currently is no tool integrated evaluation possible. Please refer to the SCCharts superpage for the [[project status>>doc:SCCharts]] and [[known limitations>>doc:SCCharts]]. You may use our [[online compiler>>doc:Online Compiler]] or the [[command line compiler >>doc:Command Line Compiler]]to play around with the following SCCharts. On the right side you'll find the textual SCChart (SCT) description, on the left side you see the equivalent synthesized SCChart diagram for it. You can use our [[online SCChart synthesis>>doc:Command Line Rendering]] for rendering SCCharts diagrams from textual SCCharts descriptions.
cmot 4.1 110
111 |=(((
112 Example
113 )))|=(((
114
115 )))|=(((
116 SCChart  (Graphical)
117 )))|=(% colspan="1" %)(% colspan="1" %)
118 (((
119 SCChart (Textual SCT)
120 )))
121 |(% colspan="1" %)(% colspan="1" %)
122 (((
123 = shifter3 =
124 )))|(% colspan="1" %)(% colspan="1" %)
125 (((
126
127 )))|(% colspan="1" %)(% colspan="1" %)
128 (((
129 [[image:attach:PLDI'14 Artifact on SCCharts@shifter3.png]]
130 )))|(% colspan="1" %)(% colspan="1" %)
131 (((
Alexander Schulz-Rosengarten 11.1 132 {{code title="shifter3.sct" language="sct"}}
cmot 4.1 133 scchart shifter3 {
134 input signal int I = 1;
135 signal int S0;
136 signal int S1;
137 output signal int O;
138 region R1:
139 initial state I2
140 --> I2 with pre(S0) / S1(pre(val(S0)));
141 region R0:
142 initial state I1
143 --> I1 with pre(I) / S0(pre(val(I)));
144 region R2:
145 initial state I3
146 --> I3 with pre(S1) / O(pre(val(S1)));
147 }
148 {{/code}}
149 )))
150 |(((
151 = reincarnation =
152 )))|(((
153
154 )))|(((
155 [[image:attach:PLDI'14 Artifact on SCCharts@reincarnation.png]]
156 )))|(% colspan="1" %)(% colspan="1" %)
157 (((
Alexander Schulz-Rosengarten 11.1 158 {{code title="reincarnation.sct" language="sct"}}
cmot 4.1 159 scchart reincarnation {
160 input signal A;
161 output signal gotS;
162 region R0:
163 initial state Reincarnation {
164 signal S;
165 region R0:
166 initial state I
167 --> C1 immediate;
168 state p;
169 final state r;
170 state q
171 --> r with A / S;
172 state C1
173 --> p immediate with S / gotS
174 --> q immediate;
175 }
176 >-> Reincarnation;
177 }
178 {{/code}}
179 )))
180 |(((
181 = cabin =
182 )))|(((
183
184 )))|(((
185 [[image:attach:PLDI'14 Artifact on SCCharts@cabin.png]]
186 )))|(% colspan="1" %)(% colspan="1" %)
187 (((
Alexander Schulz-Rosengarten 11.1 188 {{code title="cabin.sct" language="sct"}}
cmot 4.1 189 scchart Cabin {
190 input signal Stop;
191 input signal CabinStopped;
192 input signal DoorIsOpen;
193 input signal DoorOpen;
194 input signal DoorSensor;
195 input signal DoorIsClosed;
196 input signal DoorClose;
197 input signal TimerExpired;
198 output signal StartOK;
199 output signal OpenDoorMotorOff;
200 output signal OpenDoorMotorOn;
201 output signal StartTimer;
202 output signal CloseDoorMotorOn;
203 output signal CloseDoorMotorOff;
204 region R0:
205 initial state I
206 --> Open immediate with / OpenDoorMotorOn;
207 state Open
208 --> S0 with DoorIsOpen / OpenDoorMotorOff;
209 state S0 {
210 region R0:
211 initial state Initial
212 --> S0 immediate with / StartTimer;
213 state S0
214 --> S1 with TimerExpired | DoorClose / CloseDoorMotorOn;
215 state S1
216 --> S2 with DoorIsClosed / StartOK;
217 final state S2;
218 }
219 o-> I with DoorOpen | DoorSensor / CloseDoorMotorOff
220 >-> S1 with / CloseDoorMotorOff;
221 state S1
222 --> S2 with Stop;
223 state S2
224 --> I with CabinStopped;
225 }
226 {{/code}}
227 )))
228 |(((
229 = reactor control =
230 )))|(((
231
232 )))|(((
233 [[image:attach:PLDI'14 Artifact on SCCharts@reactor-control.png]]
234 )))|(% colspan="1" %)(% colspan="1" %)
235 (((
Alexander Schulz-Rosengarten 11.1 236 {{code title="reactor-control.sct" language="sct"}}
cmot 4.1 237 scchart Module_ReactorControl {
238 output signal PullOutRods;
239 output signal PushInRods;
240 input signal Start;
241 input signal OverHeated;
242 input signal CooledDown;
243 signal unsafe;
244 region main:
245 initial state init0 "I"
246 --> ParallelStatementList40state immediate;
247 state ParallelStatementList40state {
248 region R0:
249 initial state init1 "I"
250 --> Await43state immediate;
251 state Await43state {
252 region R0:
253 initial state init2 "I"
254 --> S18 immediate;
255 state S18 "18"
256 --> S23 with Start / PullOutRods;
257 state S23 "23";
258 }
259 o-> Await43state with unsafe;
260 region R1:
261 initial state init3 "I"
262 --> S94 immediate;
263 state S94 "94"
264 --> S134 immediate with unsafe / PushInRods;
265 state S134 "134"
266 --> S94 with !unsafe;
267 region R2:
268 initial state init4 "I"
269 --> S193 immediate;
270 state S193 "193"
271 --> Sustain68state immediate with OverHeated;
272 state Sustain68state {
273 region R0:
274 initial state init5 "I"
275 --> S227 immediate with / unsafe;
276 state S227 "227"
277 --> S227 with / unsafe;
278 }
279 o-> S193 with CooledDown;
280 };
281 }
282 {{/code}}
283 )))