Wiki source code of Examples

Version 13.1 by ssm on 2016/04/18 15:24

Show last authors
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 (pre 0\.13)]]
2
3 = SCCharts Examples =
4
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 = ABO =
20 )))|(% colspan="1" %)(% colspan="1" %)
21 (((
22
23 )))|(% colspan="1" %)(% colspan="1" %)
24 (((
25 [[image:attach:abo.png]]
26 )))|(% colspan="1" %)(% colspan="1" %)
27 (((
28 {{code title="ABO.sct"}}
29 @VHLayout
30 scchart ABO {
31 input output bool A;
32 input output bool B;
33 output bool O1;
34 output bool O2;
35 region:
36
37 initial state Init
38 --> WaitAB immediate with / O1 = false; O2 = false;
39 state WaitAB {
40 region HandleA:
41 initial state WaitA
42 --> DoneA immediate with A / B = true; O1 = true;
43 final state DoneA;
44 region HandleB:
45 initial state WaitB
46 --> DoneB with B / O1 = true;
47 final state DoneB;
48 }
49 >-> GotAB with / O1 = false; O2 = true;
50 state GotAB;
51 }
52 {{/code}}
53 )))
54 |(% colspan="1" %)(% colspan="1" %)
55 (((
56 = clock =
57
58 (Referenced SCCharts Example)
59
60 **To enable the referenced SCCharts feature,**
61
62 **activate the Xtext nature for your project!**
63 )))|(% colspan="1" %)(% colspan="1" %)
64 (((
65
66 )))|(% colspan="1" %)(% colspan="1" %)
67 (((
68 [[image:attach:delay.png]]
69
70 [[image:attach:emitter.png]]
71
72 [[image:attach:clock2h.png]]
73 )))|(% colspan="1" %)(% colspan="1" %)
74 (((
75 {{code language="sct" title="shifter3.sct"}}
76 scchart delay {
77 input int ticksToWait;
78 input bool clock;
79 int counter = 0;
80 initial state init
81 --> done immediate with
82 counter >= ticksToWait
83 --> init with
84 clock / counter = counter + 1;
85 final state done;
86 }
87 {{/code}}
88
89 {{code language="sct" title="shifter3.sct"}}
90 scchart emitter {
91 input bool clock;
92 input bool delay;
93 output bool emit = false;
94 initial state wait
95 references delay
96 bind clock to clock,
97 ticksToWait to delay
98 >-> emit;
99
100 state emit {
101 entry / emit = true;
102 exit / emit = false;
103 }
104 --> wait;
105 }
106 {{/code}}
107
108 {{code language="sct" title="shifter3.sct"}}
109 scchart clock {
110 input bool msClock;
111 output bool second;
112 output bool minute;
113 output bool hour;
114 const int SEC = 1000;
115 const int MIN = 60;
116 const int HOUR = 60;
117 region seconds:
118 initial state seconds
119 references emitter
120 bind clock to msClock,
121 metrum to SEC,
122 emit to second
123 >-> seconds;
124
125 region minutes:
126 initial state minutes
127 references emitter
128 bind clock to second,
129 metrum to MIN,
130 emit to minute
131 >-> minutes;
132
133 region hours:
134 initial state hours
135 references emitter
136 bind clock to minute,
137 metrum to HOUR,
138 emit to hour
139 >-> hours;
140 }
141 {{/code}}
142 )))
143
144 = SCCharts Evaluation Examples =
145
146 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.
147
148 |=(((
149 Example
150 )))|=(((
151
152 )))|=(((
153 SCChart  (Graphical)
154 )))|=(% colspan="1" %)(% colspan="1" %)
155 (((
156 SCChart (Textual SCT)
157 )))
158 |(% colspan="1" %)(% colspan="1" %)
159 (((
160 = shifter3 =
161 )))|(% colspan="1" %)(% colspan="1" %)
162 (((
163
164 )))|(% colspan="1" %)(% colspan="1" %)
165 (((
166 [[image:attach:PLDI'14 Artifact on SCCharts@shifter3.png]]
167 )))|(% colspan="1" %)(% colspan="1" %)
168 (((
169 {{code language="sct" title="shifter3.sct"}}
170 scchart shifter3 {
171 input signal int I = 1;
172 signal int S0;
173 signal int S1;
174 output signal int O;
175 region R1:
176 initial state I2
177 --> I2 with pre(S0) / S1(pre(val(S0)));
178 region R0:
179 initial state I1
180 --> I1 with pre(I) / S0(pre(val(I)));
181 region R2:
182 initial state I3
183 --> I3 with pre(S1) / O(pre(val(S1)));
184 }
185 {{/code}}
186 )))
187 |(((
188 = reincarnation =
189 )))|(((
190
191 )))|(((
192 [[image:attach:PLDI'14 Artifact on SCCharts@reincarnation.png]]
193 )))|(% colspan="1" %)(% colspan="1" %)
194 (((
195 {{code language="sct" title="reincarnation.sct"}}
196 scchart reincarnation {
197 input signal A;
198 output signal gotS;
199 region R0:
200 initial state Reincarnation {
201 signal S;
202 region R0:
203 initial state I
204 --> C1 immediate;
205 state p;
206 final state r;
207 state q
208 --> r with A / S;
209 state C1
210 --> p immediate with S / gotS
211 --> q immediate;
212 }
213 >-> Reincarnation;
214 }
215 {{/code}}
216 )))
217 |(((
218 = cabin =
219 )))|(((
220
221 )))|(((
222 [[image:attach:PLDI'14 Artifact on SCCharts@cabin.png]]
223 )))|(% colspan="1" %)(% colspan="1" %)
224 (((
225 {{code language="sct" title="cabin.sct"}}
226 scchart Cabin {
227 input signal Stop;
228 input signal CabinStopped;
229 input signal DoorIsOpen;
230 input signal DoorOpen;
231 input signal DoorSensor;
232 input signal DoorIsClosed;
233 input signal DoorClose;
234 input signal TimerExpired;
235 output signal StartOK;
236 output signal OpenDoorMotorOff;
237 output signal OpenDoorMotorOn;
238 output signal StartTimer;
239 output signal CloseDoorMotorOn;
240 output signal CloseDoorMotorOff;
241 region R0:
242 initial state I
243 --> Open immediate with / OpenDoorMotorOn;
244 state Open
245 --> S0 with DoorIsOpen / OpenDoorMotorOff;
246 state S0 {
247 region R0:
248 initial state Initial
249 --> S0 immediate with / StartTimer;
250 state S0
251 --> S1 with TimerExpired | DoorClose / CloseDoorMotorOn;
252 state S1
253 --> S2 with DoorIsClosed / StartOK;
254 final state S2;
255 }
256 o-> I with DoorOpen | DoorSensor / CloseDoorMotorOff
257 >-> S1 with / CloseDoorMotorOff;
258 state S1
259 --> S2 with Stop;
260 state S2
261 --> I with CabinStopped;
262 }
263 {{/code}}
264 )))
265 |(((
266 = reactor control =
267 )))|(((
268
269 )))|(((
270 [[image:attach:PLDI'14 Artifact on SCCharts@reactor-control.png]]
271 )))|(% colspan="1" %)(% colspan="1" %)
272 (((
273 {{code language="sct" title="reactor-control.sct"}}
274 scchart Module_ReactorControl {
275 output signal PullOutRods;
276 output signal PushInRods;
277 input signal Start;
278 input signal OverHeated;
279 input signal CooledDown;
280 signal unsafe;
281 region main:
282 initial state init0 "I"
283 --> ParallelStatementList40state immediate;
284 state ParallelStatementList40state {
285 region R0:
286 initial state init1 "I"
287 --> Await43state immediate;
288 state Await43state {
289 region R0:
290 initial state init2 "I"
291 --> S18 immediate;
292 state S18 "18"
293 --> S23 with Start / PullOutRods;
294 state S23 "23";
295 }
296 o-> Await43state with unsafe;
297 region R1:
298 initial state init3 "I"
299 --> S94 immediate;
300 state S94 "94"
301 --> S134 immediate with unsafe / PushInRods;
302 state S134 "134"
303 --> S94 with !unsafe;
304 region R2:
305 initial state init4 "I"
306 --> S193 immediate;
307 state S193 "193"
308 --> Sustain68state immediate with OverHeated;
309 state Sustain68state {
310 region R0:
311 initial state init5 "I"
312 --> S227 immediate with / unsafe;
313 state S227 "227"
314 --> S227 with / unsafe;
315 }
316 o-> S193 with CooledDown;
317 };
318 }
319 {{/code}}
320 )))