Wiki source code of Textual SCCharts Description Language (SCT)
Version 15.1 by cmot on 2014/06/28 13:16
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | [[image:attach:450px-Xtext_logo.png]] | ||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | {{panel title="Project Overview" borderStyle="dashed"}} | ||
| 6 | Responsible: | ||
| 7 | |||
| 8 | * [[Christian Motika>>url:http://www.informatik.uni-kiel.de/rtsys/kontakt/cmot/||shape="rect"]], [[Steven Smyth>>url:http://www.informatik.uni-kiel.de/rtsys/kontakt/ssm/||shape="rect"]] | ||
| 9 | |||
| 10 | Formerly Responsible / Previous Projects: | ||
| 11 | |||
| 12 | * [[Christian Schneider>>url:http://www.informatik.uni-kiel.de/rtsys/kontakt/christian-schneider/||shape="rect"]] (Textual SyncCharts (KITS)) | ||
| 13 | |||
| 14 | Related Theses: | ||
| 15 | |||
| 16 | * Mirko Wischer, //Textuelle Darstellung und strukturbasiertes Editieren von Statecharts//, February 2006 ([[pdf>>url:http://rtsys.informatik.uni-kiel.de/%7Ebiblio/downloads/theses/miwi-dt.pdf||shape="rect"]]) | ||
| 17 | * Özgün Bayramoglu, //KIELER Infrastructure for Textual Modeling//, December 2009 ([[pdf>>url:http://rtsys.informatik.uni-kiel.de/%7Ebiblio/downloads/theses/oba-dt.pdf||shape="rect"]]) | ||
| 18 | * Christian Schneider, //Integrating Graphical and Textual Modeling//, February 2011 ([[pdf>>url:http://rtsys.informatik.uni-kiel.de/%7Ebiblio/downloads/theses/chsch-dt.pdf||shape="rect"]]) | ||
| 19 | {{/panel}} | ||
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | SCCharts are typically modeled using the textual SCT language defined as an Xtext grammar in KIELER. Generally, if you do not know which elements can be placed at a certain cursor position you are assisted by a content-assist that can be called pressing <Ctrl>+<Space>. It will display all possible valid elements also considering scoping of variables. | ||
| 24 | |||
| 25 | |||
| 26 | |||
| 27 | In the following we will describe the basic elements using the famous ABRO example: | ||
| 28 | |||
| 29 | {{code linenumbers="true"}} | ||
| 30 | scchart ABRO { | ||
| 31 | input bool A; | ||
| 32 | input bool B; | ||
| 33 | input bool R; | ||
| 34 | output bool O = false; | ||
| 35 | region Main: | ||
| 36 | initial state ABO { | ||
| 37 | initial state WaitAB { | ||
| 38 | region HandleA: | ||
| 39 | initial state WA | ||
| 40 | --> DA with A; | ||
| 41 | final state DA; | ||
| 42 | region HandleB: | ||
| 43 | initial state WB | ||
| 44 | --> DB with B; | ||
| 45 | final state DB; | ||
| 46 | } | ||
| 47 | >-> Done with / O = true; | ||
| 48 | state Done; | ||
| 49 | } | ||
| 50 | o-> ABO with R; | ||
| 51 | } | ||
| 52 | {{/code}} | ||
| 53 | |||
| 54 | 1. In the first line you see how an SCChart is defined using the //scchart// keyword where the ID of the SCChart will be //ABRO//. An optional label can be inserted after //ABRO// using "<LABEL>". | ||
| 55 | 1. In the next three lines variables are declared, namely,// A//, //B//, //R// and //O//, where //O// is initialized with the value false.// A//, //B//, and //R// are inputs which must not be initialized and get there valued from the environment. | ||
| 56 | 1. An SCChart typically contains concurrent regions which are introduced with the keyword //region// as shown in Line 6. | ||
| 57 | 1. Every region must at least have one state, and every region must exactly have one initial state. An initial state //ABO// is defined for region //Main// in Line 7. | ||
| 58 | 1. Every state is terminated by a //;// as shown in line 11 for state //HandleA//. | ||
| 59 | 1. If you like to specify internal behavior of a state, you can add concurrent regions to a state in //{// <regions>// }// as done for state //ABO// or state //WaitAB//. | ||
| 60 | 1. Transitions outgoing from a state must be declared right before a state is terminated with// ;//. For example a transition from state //WA// to state //DA// is declared in Line 11. | ||
| 61 | 1. Transitions can have triggers and effects which are separated by a dash~:// <trigger>/<effects>//. Multiple sequential effects are separated by a //;//. The transition in Line 11 declares just a trigger //A// (a dash is not necessary in this case), while the transition from line 18 declares only an effect// O = true// (here the dash is mandatory). | ||
| 62 | 1. There are three types of transitions: 1. normal/weak abort transitions //~-~->//, 2. strong abort transitions //o->// and 3. termination/join transitions// >->//. | ||
| 63 | |||
| 64 | |||
| 65 | |||
| 66 | = Detailed Syntax of SCCharts Language Elements = | ||
| 67 | |||
| 68 | |||
| 69 | |||
| 70 | {{toc/}} | ||
| 71 | |||
| 72 | == SCCharts, Initial States, States, Transitions == | ||
| 73 | |||
| 74 | {{column width="50%"}} | ||
| 75 | {{code linenumbers="true"}} | ||
| 76 | scchart StateTransition { | ||
| 77 | initial state A | ||
| 78 | --> B; | ||
| 79 | state B | ||
| 80 | --> C; | ||
| 81 | state C | ||
| 82 | --> A immediate; | ||
| 83 | } | ||
| 84 | {{/code}} | ||
| 85 | {{/column}} | ||
| 86 | |||
| 87 | {{column width="50%"}} | ||
| 88 | [[image:attach:01statetransition.png]] | ||
| 89 | {{/column}} | ||
| 90 | |||
| 91 | |||
| 92 | |||
| 93 | == Variable == | ||
| 94 | |||
| 95 | {{column width="50%"}} | ||
| 96 | {{code linenumbers="true"}} | ||
| 97 | scchart Variable { | ||
| 98 | int var1; | ||
| 99 | bool var2; | ||
| 100 | int var3 = 3; | ||
| 101 | bool var4 = false; | ||
| 102 | input int var5; | ||
| 103 | output float var6; | ||
| 104 | input output bool var7; | ||
| 105 | initial state A | ||
| 106 | --> B; | ||
| 107 | state B; | ||
| 108 | } | ||
| 109 | {{/code}} | ||
| 110 | {{/column}} | ||
| 111 | |||
| 112 | {{column width="50%"}} | ||
| 113 | [[image:attach:02variable.png]] | ||
| 114 | {{/column}} | ||
| 115 | |||
| 116 | == Transition: Trigger & Effect == | ||
| 117 | |||
| 118 | {{column width="50%"}} | ||
| 119 | {{code linenumbers="true"}} | ||
| 120 | scchart TriggerEffect { | ||
| 121 | input int var1; | ||
| 122 | output bool var2; | ||
| 123 | initial state A | ||
| 124 | --> B with var1 == 3 / var2 = true; | ||
| 125 | state B; | ||
| 126 | } | ||
| 127 | {{/code}} | ||
| 128 | {{/column}} | ||
| 129 | |||
| 130 | {{column width="50%"}} | ||
| 131 | [[image:attach:03triggereffect.png]] | ||
| 132 | {{/column}} | ||
| 133 | |||
| 134 | == Super State == | ||
| 135 | |||
| 136 | {{column width="50%"}} | ||
| 137 | {{code linenumbers="true"}} | ||
| 138 | scchart SuperState { | ||
| 139 | initial state A | ||
| 140 | --> B; | ||
| 141 | state B { | ||
| 142 | initial state B1 | ||
| 143 | --> B2; | ||
| 144 | state B2; | ||
| 145 | }; | ||
| 146 | } | ||
| 147 | {{/code}} | ||
| 148 | {{/column}} | ||
| 149 | |||
| 150 | {{column width="50%"}} | ||
| 151 | [[image:attach:04superstate.png]] | ||
| 152 | {{/column}} | ||
| 153 | |||
| 154 | == Super State: Final States & Termination Transition == | ||
| 155 | |||
| 156 | {{column width="50%"}} | ||
| 157 | {{code linenumbers="true"}} | ||
| 158 | scchart FinalStateTermination { | ||
| 159 | initial state A | ||
| 160 | --> B; | ||
| 161 | state B { | ||
| 162 | initial state B1 | ||
| 163 | --> B2; | ||
| 164 | final state B2; | ||
| 165 | } | ||
| 166 | >-> C; | ||
| 167 | state C; | ||
| 168 | } | ||
| 169 | {{/code}} | ||
| 170 | {{/column}} | ||
| 171 | |||
| 172 | {{column width="50%"}} | ||
| 173 | [[image:attach:05finalstatetermination.png]] | ||
| 174 | {{/column}} | ||
| 175 | |||
| 176 | == Super State: Weak Abort Transition == | ||
| 177 | |||
| 178 | {{column width="50%"}} | ||
| 179 | {{code linenumbers="true"}} | ||
| 180 | scchart WeakAbort { | ||
| 181 | input bool W; | ||
| 182 | initial state A | ||
| 183 | --> B; | ||
| 184 | state B { | ||
| 185 | initial state B1 | ||
| 186 | --> B2; | ||
| 187 | state B2; | ||
| 188 | } | ||
| 189 | --> C with W; | ||
| 190 | state C; | ||
| 191 | } | ||
| 192 | {{/code}} | ||
| 193 | {{/column}} | ||
| 194 | |||
| 195 | {{column width="50%"}} | ||
| 196 | [[image:attach:06weakabort.png]] | ||
| 197 | {{/column}} | ||
| 198 | |||
| 199 | == Super State: Strong Abort Transition == | ||
| 200 | |||
| 201 | {{column width="50%"}} | ||
| 202 | {{code linenumbers="true"}} | ||
| 203 | scchart StrongAbort { | ||
| 204 | input bool S; | ||
| 205 | initial state A | ||
| 206 | --> B; | ||
| 207 | state B { | ||
| 208 | initial state B1 | ||
| 209 | --> B2; | ||
| 210 | state B2; | ||
| 211 | } | ||
| 212 | o-> C with S; | ||
| 213 | |||
| 214 | state C; | ||
| 215 | } | ||
| 216 | {{/code}} | ||
| 217 | {{/column}} | ||
| 218 | |||
| 219 | {{column width="50%"}} | ||
| 220 | [[image:attach:07strongabort.png]] | ||
| 221 | {{/column}} | ||
| 222 | |||
| 223 | == Concurrent Regions (inside a Super State) == | ||
| 224 | |||
| 225 | {{column width="50%"}} | ||
| 226 | {{code linenumbers="true"}} | ||
| 227 | scchart Regions { | ||
| 228 | input bool S; | ||
| 229 | initial state A | ||
| 230 | --> B; | ||
| 231 | state B { | ||
| 232 | region Region1 : | ||
| 233 | initial state B1 | ||
| 234 | --> B2; | ||
| 235 | state B2; region Region2 : | ||
| 236 | initial state B3; | ||
| 237 | }; | ||
| 238 | } | ||
| 239 | {{/code}} | ||
| 240 | {{/column}} | ||
| 241 | |||
| 242 | {{column width="50%"}} | ||
| 243 | [[image:attach:08regions.png]] | ||
| 244 | {{/column}} | ||
| 245 | |||
| 246 | == Entry Action, During Action, Exit Action == | ||
| 247 | |||
| 248 | {{column width="50%"}} | ||
| 249 | {{code linenumbers="true"}} | ||
| 250 | scchart Actions { | ||
| 251 | input bool var1; | ||
| 252 | output bool var2; | ||
| 253 | initial state A | ||
| 254 | --> B; | ||
| 255 | state B { | ||
| 256 | entry var1 / var2 = true; | ||
| 257 | during var1 / var2 = true; | ||
| 258 | immediate during var1 / var2 = true; | ||
| 259 | exit var1 / var2 = true; | ||
| 260 | initial state B1 | ||
| 261 | --> B2; | ||
| 262 | state B2; | ||
| 263 | }; | ||
| 264 | } | ||
| 265 | {{/code}} | ||
| 266 | {{/column}} | ||
| 267 | |||
| 268 | {{column width="50%"}} | ||
| 269 | [[image:attach:09actions.png]] | ||
| 270 | {{/column}} | ||
| 271 | |||
| 272 | == Shallow History Transition == | ||
| 273 | |||
| 274 | {{column width="50%"}} | ||
| 275 | {{code linenumbers="true"}} | ||
| 276 | scchart HistoryShallow { | ||
| 277 | input bool var1; | ||
| 278 | output bool var2; | ||
| 279 | initial state A | ||
| 280 | --> B shallow history with var1; | ||
| 281 | state B { | ||
| 282 | initial state B1 | ||
| 283 | --> B2; | ||
| 284 | state B2; | ||
| 285 | } | ||
| 286 | --> A with var1; | ||
| 287 | } | ||
| 288 | {{/code}} | ||
| 289 | {{/column}} | ||
| 290 | |||
| 291 | {{column width="50%"}} | ||
| 292 | [[image:attach:10historyshallow.png]] | ||
| 293 | {{/column}} | ||
| 294 | |||
| 295 | == Deep History Transition == | ||
| 296 | |||
| 297 | {{column width="50%"}} | ||
| 298 | {{code linenumbers="true"}} | ||
| 299 | scchart HistoryDeep { | ||
| 300 | input bool var1; | ||
| 301 | output bool var2; | ||
| 302 | initial state A | ||
| 303 | --> B history with var1; | ||
| 304 | state B { | ||
| 305 | initial state B1 | ||
| 306 | --> B2; | ||
| 307 | state B2; | ||
| 308 | } | ||
| 309 | --> A with var1; | ||
| 310 | } | ||
| 311 | {{/code}} | ||
| 312 | {{/column}} | ||
| 313 | |||
| 314 | {{column width="50%"}} | ||
| 315 | [[image:attach:11historydeep.png]] | ||
| 316 | {{/column}} | ||
| 317 | |||
| 318 | == Deferred Transition == | ||
| 319 | |||
| 320 | {{column width="50%"}} | ||
| 321 | {{code linenumbers="true"}} | ||
| 322 | scchart Deferred { | ||
| 323 | input bool var1; | ||
| 324 | output bool var2; | ||
| 325 | initial state A | ||
| 326 | --> B deferred with var1; | ||
| 327 | state B { | ||
| 328 | entry var1 / var2 = true; | ||
| 329 | } | ||
| 330 | --> A with var1; | ||
| 331 | } | ||
| 332 | {{/code}} | ||
| 333 | {{/column}} | ||
| 334 | |||
| 335 | {{column width="50%"}} | ||
| 336 | [[image:attach:12deferred.png]] | ||
| 337 | {{/column}} | ||
| 338 | |||
| 339 | == Transition with Count Delay == | ||
| 340 | |||
| 341 | {{column width="50%"}} | ||
| 342 | {{code linenumbers="true"}} | ||
| 343 | scchart CountDelay { | ||
| 344 | input bool var1; | ||
| 345 | output bool var2; | ||
| 346 | initial state A | ||
| 347 | --> B with 4 var1; | ||
| 348 | state B | ||
| 349 | --> A with var1; | ||
| 350 | } | ||
| 351 | {{/code}} | ||
| 352 | {{/column}} | ||
| 353 | |||
| 354 | {{column width="50%"}} | ||
| 355 | [[image:attach:13countdelay.png]] | ||
| 356 | {{/column}} | ||
| 357 | |||
| 358 | == Array == | ||
| 359 | |||
| 360 | {{column width="50%"}} | ||
| 361 | {{code linenumbers="true"}} | ||
| 362 | scchart Array { | ||
| 363 | int myArray[10][2]; | ||
| 364 | initial state init | ||
| 365 | --> done with myArray[1][0] == 1 / myArray[2][1] = 2; | ||
| 366 | final state done; | ||
| 367 | } | ||
| 368 | {{/code}} | ||
| 369 | {{/column}} | ||
| 370 | |||
| 371 | {{column width="50%"}} | ||
| 372 | [[image:attach:14array.png]] | ||
| 373 | {{/column}} | ||
| 374 | |||
| 375 | == Signal == | ||
| 376 | |||
| 377 | {{column width="50%"}} | ||
| 378 | {{code linenumbers="true"}} | ||
| 379 | scchart Signal { | ||
| 380 | input signal i; | ||
| 381 | output signal o | ||
| 382 | initial state init | ||
| 383 | --> done with i / o; | ||
| 384 | final state done; | ||
| 385 | } | ||
| 386 | {{/code}} | ||
| 387 | {{/column}} | ||
| 388 | |||
| 389 | {{column width="50%"}} | ||
| 390 | [[image:attach:15signal.png]] | ||
| 391 | {{/column}} | ||
| 392 | |||
| 393 | |||
| 394 | |||
| 395 | |||
| 396 | |||
| 397 | |||
| 398 | |||
| 399 | |||
| 400 | |||
| 401 | |||
| 402 | |||
| 403 | |||
| 404 | |||
| 405 | |||
| 406 | |||
| 407 | |||
| 408 | |||
| 409 | |||
| 410 | |||
| 411 | |||
| 412 | |||
| 413 | |||
| 414 | |||
| 415 | |||
| 416 | |||
| 417 | |||
| 418 | |||
| 419 | |||
| 420 | |||
| 421 | |||
| 422 | |||
| 423 | |||
| 424 | |||
| 425 | |||
| 426 | |||
| 427 |