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