Changes for page SCCharts Development
Last modified by Richard Kreissig on 2023/09/14 10:04
<
>
edited by Alexander Schulz-Rosengarten
on 2023/09/11 15:41
on 2023/09/11 15:41
edited by Alexander Schulz-Rosengarten
on 2023/07/11 10:37
on 2023/07/11 10:37
Change comment:
Renamed back-links.
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,3 +1,6 @@ 1 +{{layout}} 2 +{{layout-section ac:type="single"}} 3 +{{layout-cell}} 1 1 This is a light-weight tutorial for developing transformations/additions for SCCharts in KIELER. It will use Eclipse, EMF, and Xtend and therefore, finishing the corresponding tutorials could prove useful. However, they are not a strict requirement for this tutorial. 2 2 3 3 {{warning title="Outdated!"}} ... ... @@ -17,8 +17,11 @@ 17 17 == Required Software == 18 18 19 19 As you're going to develop for KIELER SCCharts, we recommend to use the Oomph setup as described in [[doc:KIELER.Getting Eclipse]] (Oomph Setup). However, you could also install all componentes by yourself. Please consult the other tutorials if you want to do that. You would need to install the Modeling Tools and the Xtext SDK. 23 +{{/layout-cell}} 24 +{{/layout-section}} 20 20 21 - 26 +{{layout-section ac:type="three_equal"}} 27 +{{layout-cell}} 22 22 \\ 23 23 24 24 Additionally, install the** EcoreViz** from the **Ecore Model Visualization** category from the **OpenKieler** update site: [[http:~~/~~/rtsys.informatik.uni-kiel.de/~~~~kieler/updatesite/nightly-openkieler/>>url:http://rtsys.informatik.uni-kiel.de/~~kieler/updatesite/nightly-openkieler/||rel="nofollow" shape="rect"]]. For this, choose //Install New Software...// in the //Help// tab. ... ... @@ -29,16 +29,25 @@ 29 29 * KIELER Lightweight Diagrams Generic Diagram View. 30 30 31 31 (This step should be obsolete in the near future.) 38 +{{/layout-cell}} 32 32 40 +{{layout-cell}} 33 33 \\ 34 34 35 35 [[image:attach:InstallEcoreViz.png]] 36 36 37 37 \\ 46 +{{/layout-cell}} 47 + 48 +{{layout-cell}} 38 38 \\ 39 39 40 40 [[image:attach:InstallKLighDFeatures.png]] 52 +{{/layout-cell}} 53 +{{/layout-section}} 41 41 55 +{{layout-section ac:type="single"}} 56 +{{layout-cell}} 42 42 == Recommended Tutorials == 43 43 44 44 We recommend that you have completed the following tutorials before diving into this one (or at least sweep over them). However, this is not a strict requirement. ... ... @@ -76,7 +76,11 @@ 76 76 (% style="color: rgb(0,0,0);" %)Reinhard von Hanxleden and Björn Duderstadt and Christian Motika and Steven Smyth and Michael Mendler and Joaquín Aguado and Stephen Mercer and Owen O’Brien. SCCharts: Sequentially Constructive Statecharts for Safety-Critical Applications. Technical Report 1311, Christian-Albrechts-Universität zu Kiel, Department of Computer Science, December 2013. ISSN 2192-6247. (%%)[[pdf>>url:http://rtsys.informatik.uni-kiel.de/~~biblio/downloads/papers/report-1311.pdf||shape="rect"]](% style="color: rgb(0,0,0);" %), (%%)[[bib>>url:http://rtsys.informatik.uni-kiel.de/~~biblio/cgi-bin/bibcgi.cgi?key=vonHanxledenDM+13b||shape="rect"]] 77 77 78 78 \\ 94 +{{/layout-cell}} 95 +{{/layout-section}} 79 79 97 +{{layout-section ac:type="two_right_sidebar"}} 98 +{{layout-cell}} 80 80 = The SCCharts Metamodel = 81 81 82 82 Navigate to the {{code language="none"}}models{{/code}} folder of the plugin {{code language="none"}}de.cau.cs.kieler.sccharts{{/code}}. Here, open the {{code language="none"}}sccharts.ecore{{/code}} and right-click on the {{code language="none"}}sccharts.ecore{{/code}} file and select //Visualize Ecore Model//. Since you also installed **EcoreViz** from the OpenKieler Suite, you should now see a graphical representation of the SCCharts metamodel. Every SCChart will be a model of this metamodel. ... ... @@ -112,13 +112,19 @@ 112 112 {{info title="KLighD Screenshots"}} 113 113 By the way: You can //right-click// on the Diagram View surface and select //Save as image...// to create a screenshot! 114 114 {{/info}} 134 +{{/layout-cell}} 115 115 136 +{{layout-cell}} 116 116 [[image:attach:sccharts_metamodel.png]] 117 117 118 118 [[image:attach:sccharts_metamodel_treeEditor.png]] 119 119 120 120 [[image:attach:KLighDSaveAsImage.png]] 142 +{{/layout-cell}} 143 +{{/layout-section}} 121 121 145 +{{layout-section ac:type="single"}} 146 +{{layout-cell}} 122 122 = Creating SCCharts Models Programmatically = 123 123 124 124 == Creating a Test Project == ... ... @@ -214,7 +214,11 @@ 214 214 File extensions are important! They define the parser/serializer that EMF uses. Always use the file extension that is defined for a particular model. 215 215 {{/info}} 216 216 ))) 242 +{{/layout-cell}} 243 +{{/layout-section}} 217 217 245 +{{layout-section ac:type="two_right_sidebar"}} 246 +{{layout-cell}} 218 218 ==== Model Creation Task ==== 219 219 220 220 You are now equipped with the fundamentals you need to create models programmatically. Let's try it: ... ... @@ -238,7 +238,9 @@ 238 238 *1. Create a new project and add you generated model. 239 239 240 240 \\ 270 +{{/layout-cell}} 241 241 272 +{{layout-cell}} 242 242 {{code language="java" title="Root.sct"}} 243 243 scchart Root { 244 244 initial state Init ... ... @@ -247,7 +247,11 @@ 247 247 {{/code}} 248 248 249 249 [[image:attach:RunConfiguration.png]] 281 +{{/layout-cell}} 282 +{{/layout-section}} 250 250 284 +{{layout-section ac:type="two_right_sidebar"}} 285 +{{layout-cell}} 251 251 = Model-to-Model Transformations with KiCo = 252 252 253 253 You can use the [[Kieler Compiler>>url:http://rtsys.informatik.uni-kiel.de/confluence/display/KIELER/Kieler+Compiler||shape="rect"]] (KiCo) to handle all the model input/output tasks and concentrate on the actual transformation. If you executed the **Model Creation Task correctly**, you should now have a complete running SCT Editor instance that looks like the one on the right. You should see the //KIELER Compiler Selection// n the lower right part of the working space. Here you can select specific transformations that will be applied to the actual model. Simply select a transformation to test it. ... ... @@ -255,9 +255,15 @@ 255 255 == Creating a new Transformation == 256 256 257 257 Now, you're going to write your own transformation with **Xtend** *drumroll*, a programming language that looks very similar to Java, but which adds some very convenient features. Xtend code compiles to Java and and was developed using Xtext. In fact, once you gain experience working with Xtend you will probably appreciate the power of Xtext even more. Xtend is particularly useful to browse & modify EMF models. You get the point... we like it. :) 293 +{{/layout-cell}} 258 258 295 +{{layout-cell}} 259 259 [[image:attach:KielerSCTEditor.png]] 297 +{{/layout-cell}} 298 +{{/layout-section}} 260 260 300 +{{layout-section ac:type="two_right_sidebar"}} 301 +{{layout-cell}} 261 261 ==== Transformation Creation Task ==== 262 262 263 263 * Create your first transformation... ... ... @@ -302,8 +302,15 @@ 302 302 You should really think about some constants here. You can also look at the sccharts transformation and features constants in the sccharts plugin. 303 303 {{/info}} 304 304 ))) 346 +{{/layout-cell}} 305 305 348 +{{layout-cell}} 349 +\\ 350 +{{/layout-cell}} 351 +{{/layout-section}} 306 306 353 +{{layout-section ac:type="two_right_sidebar"}} 354 +{{layout-cell}} 307 307 * KiCo must know about the new feature and also about your new transformation. 308 308 *1. Add a new Xtend class with Feature as superclass. Add all unimplemented methods. Also set** sccharts.doubleStates** as Id. 309 309 *1. Go to the Extension tab inside your plugin configuration. ... ... @@ -317,9 +317,15 @@ 317 317 *111. preferred: (leave it blank) 318 318 *1. {{note title="Plugin Tasks"}}In general it is bad to mix non-ui plugins/tasks with ui plugin/tasks because (in the context of KiCo) even if you're not working with an active UI your transformations should work (e.g. a command line compiler). To keep this tutorial simple, you can add this dependency to your plugin nevertheless. However, you shouldn't do this in real products. Always keep the UI separated.{{/note}}If you start your KIELER instance now, you should get a new compilation chain which has only one transformation: yours, which doesn't do anything. 319 319 * If you want to rename your feature in the Compiler Selection (without changing its Id), override the {{code language="none"}}getName{{/code}} method and return a new name. Rename your feature appropriately. 368 +{{/layout-cell}} 320 320 370 +{{layout-cell}} 321 321 [[image:attach:KielerSCTEditorOwnTransformation.png]] 372 +{{/layout-cell}} 373 +{{/layout-section}} 322 322 375 +{{layout-section ac:type="two_right_sidebar"}} 376 +{{layout-cell}} 323 323 * Now, fill your transformation with life: 324 324 *1. Inside your transformation class, add a new method with the following signature: {{code language="none"}}def State transform(State rootState, KielerCompilerContext context){{/code}}. This transformation will be executed if the feature is selected in the Compiler Selection. 325 325 *1. ((( ... ... @@ -354,12 +354,15 @@ 354 354 Extensions are also just classes. You can add your own to improve the structure of your own projects. In KIELER all extensions end with "Extensions"; except SCChartsExtension for legacy reasons. This will be renamed in after the next snapshot to SCChartsExtensions. So, if you're going to add new extensions to the project, please name them accordingly. 355 355 {{/note}} 356 356 ))) 411 +{{/layout-cell}} 357 357 358 - 413 +{{layout-cell}} 359 359 [[image:attach:KielerSCTEditorOwnTransformationOlolo.png]] 415 +{{/layout-cell}} 416 +{{/layout-section}} 360 360 361 - 362 - 418 +{{layout-section ac:type="two_right_sidebar"}} 419 +{{layout-cell}} 363 363 * Extend your transformation so that it is applied on all states (except the root state). Try your new transformation with ABO. The result should look like the example on the right. 364 364 365 365 == The existing Compilation Chain == ... ... @@ -371,7 +371,9 @@ 371 371 //We will add more content to this subsection in the future...// 372 372 373 373 \\ 431 +{{/layout-cell}} 374 374 433 +{{layout-cell}} 375 375 [[image:attach:ABODoubleStates.png]] 376 376 377 377 \\ ... ... @@ -378,6 +378,12 @@ 378 378 379 379 \\ 380 380 440 +\\ 441 +{{/layout-cell}} 442 +{{/layout-section}} 443 + 444 +{{layout-section ac:type="single"}} 445 +{{layout-cell}} 381 381 = Model-to-Model Transformations between Metamodels = 382 382 383 383 Transformations from one model to another may be performed within the same metamodel or from metamodel to a different metamodel. Both methods are used in KIELER and in principle they do not really differ in implementation. Nevertheless, if working within the same metamodel you should keep in mind that you're potentially changing the actual model instead of changing another instance (after copying). When transforming to another metamodel, you're always generating a new model. So there is no in-place transformation. Both is possible. Just make sure that you know what you're doing. ... ... @@ -423,13 +423,23 @@ 423 423 [[image:attach:abo_scg_HandleA.png]] 424 424 ))) 425 425 ))) 491 +{{/layout-cell}} 492 +{{/layout-section}} 426 426 494 +{{layout-section ac:type="two_equal"}} 495 +{{layout-cell}} 427 427 The next figure depicts the direct mapping from normalized SCCharts to their corresponding SCG. 428 428 429 429 Inspect the metamodel of the SCGs in plugin de.cau.cs.kieler.scg. SCGs are used for analyses and optimization and include a lot of additional elements. However, for this tutorial it should be sufficient to look at the SCGraph class, its nodes attribute, the important node classes and the controlflow class. Important nodes for this SCG are entry, exit, assignment, conditional, 499 +{{/layout-cell}} 430 430 501 +{{layout-cell}} 431 431 [[image:attach:sccharts-scg.png]] 503 +{{/layout-cell}} 504 +{{/layout-section}} 432 432 506 +{{layout-section ac:type="two_right_sidebar"}} 507 +{{layout-cell}} 433 433 ==== Transformation Creation Task 2 ==== 434 434 435 435 Write a transformation that transforms your normalized version of ABO's HandleA into its corresponding SCG. ... ... @@ -447,3 +447,10 @@ 447 447 Congratulations! You finished the SCCharts Development Tutorial. Ask your supervisor for further instructions! 448 448 449 449 \\ 525 +{{/layout-cell}} 526 + 527 +{{layout-cell}} 528 +\\ 529 +{{/layout-cell}} 530 +{{/layout-section}} 531 +{{/layout}}