Changes for page SCCharts Development
Last modified by Richard Kreissig on 2023/09/14 10:04
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,7 +1,7 @@ 1 1 {{layout}} 2 2 {{layout-section ac:type="single"}} 3 3 {{layout-cell}} 4 - 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.4 +is 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. 5 5 6 6 7 7 ... ... @@ -102,7 +102,8 @@ 102 102 103 103 ==== Model Task ==== 104 104 105 -* ((( 105 +{{task-list}} 106 +{{task id="1" status="complete"}} 106 106 (% style="line-height: 1.42857;" %)Answer the following questions 107 107 108 108 1. How do you describe a superstate in the model? ... ... @@ -111,15 +111,20 @@ 111 111 1. What is a valued object? 112 112 1. How do you get the type of an interface variable? 113 113 1. What other metamodels are needed for the SCCharts metamodel and write down which one is needed for what? 114 -))) 115 -* Write down (on paper, text editor, etc) how the following SCChart models look like 116 -*1. Open the wiki page that explains the [[doc:KIELER.Textual SCCharts Language SCT]]. 117 -*1. Search the //SCChart, Initial State, State, Transition and Immediate Transition //example and ... 118 -*11. write down (on paper or text editor, etc) how the model of that SCChart looks like. 119 -*11. The user now marks C as final. What has to be changed in the model? What semantic problem do you see? 120 -*1. Now, navigate to the //Super State: Strong Abort Transition //example. Write down (on paper) how the model of that SCCharts looks like. 121 -*1. And finally a more sophisticated model: Write down the model of ABO (from [[doc:KIELER.Examples]]). 115 +{{/task}} 122 122 117 +{{task id="2" status="incomplete"}} 118 +Write down (on paper, text editor, etc) how the following SCChart models look like 119 + 120 +1. Open the wiki page that explains the [[doc:KIELER.Textual SCCharts Language SCT]]. 121 +1. Search the //SCChart, Initial State, State, Transition and Immediate Transition //example and ... 122 +11. write down (on paper or text editor, etc) how the model of that SCChart looks like. 123 +11. The user now marks C as final. What has to be changed in the model? What semantic problem do you see? 124 +1. Now, navigate to the //Super State: Strong Abort Transition //example. Write down (on paper) how the model of that SCCharts looks like. 125 +1. And finally a more sophisticated model: Write down the model of ABO (from [[doc:KIELER.Examples]]). 126 +{{/task}} 127 +{{/task-list}} 128 + 123 123 124 124 125 125 {{info title="KLighD Screenshots"}} ... ... @@ -144,10 +144,10 @@ 144 144 145 145 We need a project for testing. Do the following: 146 146 147 - *If you used the standard KIELER Oomph installation setup, create a new Working Set named Tutorial in the Package Explorer. Then...148 - *Create a new empty //Plug-In Project//.149 - *Add the project that contains the sccharts metamodel as a dependency of your new project through the //Plugin Manifest Editor//.150 - *Create a simple Java class that implements a main method. Hint: In a new Java class, simply type main and hit Ctrl+Space. Eclipse content assist will create the method for you.153 +1. If you used the standard KIELER Oomph installation setup, create a new Working Set named Tutorial in the Package Explorer. Then... 154 +1. Create a new empty //Plug-In Project//. 155 +1. Add the project that contains the sccharts metamodel as a dependency of your new project through the //Plugin Manifest Editor//. 156 +1. Create a simple Java class that implements a main method. Hint: In a new Java class, simply type main and hit Ctrl+Space. Eclipse content assist will create the method for you. 151 151 152 152 == Creating a Model == 153 153 ... ... @@ -193,7 +193,7 @@ 193 193 194 194 EMF uses the [[Eclipse Resource concept>>url:http://help.eclipse.org/juno/topic/org.eclipse.platform.doc.isv/guide/resInt.htm?cp=2_0_10||rel="nofollow" shape="rect" class="external-link"]] to save models to files and load models from files. It can use different //Resource Factories// that determine how exactly models are serialized. We will use the [[XMIResourceFactoryImpl>>url:http://download.eclipse.org/modeling/emf/emf/javadoc/2.8.0/org/eclipse/emf/ecore/xmi/impl/XMIResourceFactoryImpl.html||rel="nofollow" shape="rect" class="external-link"]] to save our models to XML files: 195 195 196 - *(((202 +1. ((( 197 197 Add a dependency to the {{code language="none"}}com.google.inject, org.eclipse.core.resources, {{/code}}and{{code language="none"}} de.cau.cs.kieler.sccharts.text{{/code}} plug-ins. 198 198 199 199 {{info title="Additional Dependencies"}} ... ... @@ -200,7 +200,7 @@ 200 200 Don't worry. You will be experienced enough to add mandatory dependencies quickly in the future. However, for now just add the dependencies to proceed with the tutorial. 201 201 {{/info}} 202 202 ))) 203 - *(((209 +1. ((( 204 204 Use something like the following code to save the model from above: 205 205 206 206 {{code language="java"}} ... ... @@ -242,10 +242,13 @@ 242 242 243 243 You are now equipped with the fundamentals you need to create models programmatically. Let's try it: 244 244 245 -* (% style="line-height: 1.42857;" %)The code fragments listed above do not suffice to create a grammatically correct model. Try to generate a model that corresponds with the serialized model listed on the right side. 246 -*1. (% style="line-height: 1.42857;" %)Run the {{code language="none"}}main(){{/code}} method by right-clicking its class and selecting //Run as// -> //Java Application//. Note that this runs your {{code language="none"}}main(){{/code}} method as a simple Java program, not a complete Eclipse application. EMF models can be used in any simple Java context, not just in Eclipse applications. 247 -*1. Execute the main method. 248 -*1. ((( 251 +{{task-list}} 252 +{{task id="3" status="incomplete"}} 253 +(% style="line-height: 1.42857;" %)The code fragments listed above do not suffice to create a grammatically correct model. Try to generate a model that corresponds with the serialized model listed on the right side. 254 + 255 +1. (% style="line-height: 1.42857;" %)Run the {{code language="none"}}main(){{/code}} method by right-clicking its class and selecting //Run as// -> //Java Application//. Note that this runs your {{code language="none"}}main(){{/code}} method as a simple Java program, not a complete Eclipse application. EMF models can be used in any simple Java context, not just in Eclipse applications. 256 +1. Execute the main method. 257 +1. ((( 249 249 (% style="line-height: 1.42857;" %)Inspect your SCT file. (Press F5 to refresh your file view.) 250 250 251 251 {{note title="Kext Warning"}} ... ... @@ -252,14 +252,29 @@ 252 252 It is possible that kext generates a Null Pointer Exception when you save your model this way. This is a known issue. We're working on it. Just ignore it for now. 253 253 {{/note}} 254 254 ))) 255 -* Now, create a new Java class and proceed as before to generate a model of ABO in the {{code language="none"}}main(){{/code}} method. 256 -* (% style="line-height: 1.42857;" %)Start your SCChart Editor Eclipse instance and load your SCT file. KLighD should now be able to visualize your ABO correctly.(%%)\\ 257 -*1. For this, open tab //Run// and select// Run Configurations...// 258 -*1. Create a new //Eclipse Application// and name it appropriately. 259 -*1. As product select {{code language="none"}}de.cau.cs.kieler.core.product.product{{/code}}. 260 -*1. Click //Run// (or //Debug// if you opened// Debug Configuration...//) 261 -*1. Create a new project and add you generated model. 264 +{{/task}} 262 262 266 +{{task id="4" status="incomplete"}} 267 +Now, create a new Java class and proceed as before to generate a model of ABO in the 268 + 269 +{{code language="none"}} 270 +main() 271 +{{/code}} 272 + 273 + method. 274 +{{/task}} 275 + 276 +{{task id="5" status="incomplete"}} 277 +(% style="line-height: 1.42857;" %)Start your SCChart Editor Eclipse instance and load your SCT file. KLighD should now be able to visualize your ABO correctly.(%%)\\ 278 + 279 +1. For this, open tab //Run// and select// Run Configurations...// 280 +1. Create a new //Eclipse Application// and name it appropriately. 281 +1. As product select {{code language="none"}}de.cau.cs.kieler.core.product.product{{/code}}. 282 +1. Click //Run// (or //Debug// if you opened// Debug Configuration...//) 283 +1. Create a new project and add you generated model. 284 +{{/task}} 285 +{{/task-list}} 286 + 263 263 264 264 {{/layout-cell}} 265 265 ... ... @@ -295,13 +295,16 @@ 295 295 {{layout-cell}} 296 296 ==== Transformation Creation Task ==== 297 297 298 -* Create your first transformation... 299 -*1. Create a new project within your tutorial working set as before. 300 -*1. Add plugin dependencies to {{code language="none"}}de.cau.cs.kieler.kico{{/code}} and {{code language="none"}}de.cau.cs.kieler.sccharts{{/code}}. 301 -*1. Create a new //Xtend class// in you package and name it "DoubleStates" and use {{code language="none"}}AbstractProductionTransformation{{/code}} as superclass. 302 -*1. Here, you can automatically add the missing Xtend files by using the quickfix //Add Xtend lib to class path. //Alternatively you can simply add {{code language="none"}}com.google.guava{{/code}}, {{code language="none"}}org.eclipse.xtext.xbase.lib{{/code}}, {{code language="none"}}org.eclipse.xtend.lib{{/code}}, and {{code language="none"}}org.eclipse.xtend.lib.macro{{/code}} to you plugin dependencies. 303 -*1. Click on //Add unimplemented methods//. 304 -*1. ((( 322 +{{task-list}} 323 +{{task id="6" status="incomplete"}} 324 +Create your first transformation... 325 + 326 +1. Create a new project within your tutorial working set as before. 327 +1. Add plugin dependencies to {{code language="none"}}de.cau.cs.kieler.kico{{/code}} and {{code language="none"}}de.cau.cs.kieler.sccharts{{/code}}. 328 +1. Create a new //Xtend class// in you package and name it "DoubleStates" and use {{code language="none"}}AbstractProductionTransformation{{/code}} as superclass. 329 +1. Here, you can automatically add the missing Xtend files by using the quickfix //Add Xtend lib to class path. //Alternatively you can simply add {{code language="none"}}com.google.guava{{/code}}, {{code language="none"}}org.eclipse.xtext.xbase.lib{{/code}}, {{code language="none"}}org.eclipse.xtend.lib{{/code}}, and {{code language="none"}}org.eclipse.xtend.lib.macro{{/code}} to you plugin dependencies. 330 +1. Click on //Add unimplemented methods//. 331 +1. ((( 305 305 Now, you should have a class similar to the following one. 306 306 307 307 {{code language="java"}} ... ... @@ -330,13 +330,16 @@ 330 330 * You may be tempted to add a few global variables that hold things like a global input variable or a pointer to the current state. While you could to that, {{code language="none"}}def create {{/code}}methods might offer a better alternative... 331 331 {{/info}} 332 332 ))) 333 -* ((( 360 +{{/task}} 361 + 362 +{{task id="7" status="incomplete"}} 334 334 As you can see, it is mandatory to add an id for the transformation and another id of the feature that this transformation produces. Name your transformation **tutorial.doubleStates **and the id of feature you want to produce is **sccharts.doubleStates**. 335 335 336 336 {{info title="Programming Guidelines"}} 337 337 You should really think about some constants here. You can also look at the sccharts transformation and features constants in the sccharts plugin. 338 338 {{/info}} 339 -))) 368 +{{/task}} 369 +{{/task-list}} 340 340 {{/layout-cell}} 341 341 342 342 {{layout-cell}} ... ... @@ -346,19 +346,33 @@ 346 346 347 347 {{layout-section ac:type="two_right_sidebar"}} 348 348 {{layout-cell}} 349 -* KiCo must know about the new feature and also about your new transformation. 350 -*1. Add a new Xtend class with Feature as superclass. Add all unimplemented methods. Also set** sccharts.doubleStates** as Id. 351 -*1. Go to the Extension tab inside your plugin configuration. 352 -*11. Add a new Extension Point de.cau.cs.kieler.kico.feature. Create a new featureClass and point it to your new feature class. 353 -*11. Also add a new Extension Point de.cau.cs.kieler.kico.transformation. Create a new productionTransformationClass and point it to your transformation class. 354 -*11. Finally, you have to link your transformation to the SCT Editor. Add the Extension point de.cau.cs.kieler.kico.ui.transformation. Create an editor link and fill in the following values: 355 -*111. editor: {{code language="none"}}de.cau.cs.kieler.sccharts.text.sct.Sct{{/code}} 356 -*111. features: sccharts.doubleStates 357 -*111. label: Tutorial Compilation 358 -*111. priority: 101 359 -*111. preferred: (leave it blank) 360 -*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. 361 -* 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. 379 +{{task-list}} 380 +{{task id="8" status="incomplete"}} 381 +KiCo must know about the new feature and also about your new transformation. 382 + 383 +1. Add a new Xtend class with Feature as superclass. Add all unimplemented methods. Also set** sccharts.doubleStates** as Id. 384 +1. Go to the Extension tab inside your plugin configuration. 385 +11. Add a new Extension Point de.cau.cs.kieler.kico.feature. Create a new featureClass and point it to your new feature class. 386 +11. Also add a new Extension Point de.cau.cs.kieler.kico.transformation. Create a new productionTransformationClass and point it to your transformation class. 387 +11. Finally, you have to link your transformation to the SCT Editor. Add the Extension point de.cau.cs.kieler.kico.ui.transformation. Create an editor link and fill in the following values: 388 +111. editor: {{code language="none"}}de.cau.cs.kieler.sccharts.text.sct.Sct{{/code}} 389 +111. features: sccharts.doubleStates 390 +111. label: Tutorial Compilation 391 +111. priority: 101 392 +111. preferred: (leave it blank) 393 +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. 394 +{{/task}} 395 + 396 +{{task id="9" status="incomplete"}} 397 +If you want to rename your feature in the Compiler Selection (without changing its Id), override the 398 + 399 +{{code language="none"}} 400 +getName 401 +{{/code}} 402 + 403 + method and return a new name. Rename your feature appropriately. 404 +{{/task}} 405 +{{/task-list}} 362 362 {{/layout-cell}} 363 363 364 364 {{layout-cell}} ... ... @@ -368,9 +368,12 @@ 368 368 369 369 {{layout-section ac:type="two_right_sidebar"}} 370 370 {{layout-cell}} 371 -* Now, fill your transformation with life: 372 -*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. 373 -*1. ((( 415 +{{task-list}} 416 +{{task id="10" status="incomplete"}} 417 +Now, fill your transformation with life: 418 + 419 +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. 420 +1. ((( 374 374 Add thew following body to the function and try to understand the Xtend code. Import unknown class via code assist. 375 375 376 376 {{code language="java" title="transform"}} ... ... @@ -386,9 +386,14 @@ 386 386 } 387 387 {{/code}} 388 388 ))) 389 -*1. When selecting your transformation, the SCChart gets transformed and looks like the version on the right. 390 -* Extend the transformation so that the transition is split up in two and connected via a transient state meaning that the original transformation should point to the new state and a new immediate transformation then points to the original target state. Try it out. 391 -* ((( 436 +1. When selecting your transformation, the SCChart gets transformed and looks like the version on the right. 437 +{{/task}} 438 + 439 +{{task id="11" status="incomplete"}} 440 +Extend the transformation so that the transition is split up in two and connected via a transient state meaning that the original transformation should point to the new state and a new immediate transformation then points to the original target state. Try it out. 441 +{{/task}} 442 + 443 +{{task id="12" status="incomplete"}} 392 392 Xtend supports extensions that can be used to extend the function set of you classes (i.e. models). Add {{code language="none"}}com.google.inject{{/code}} to the dependencies of your plugin. Now, add the following code fragment to the beginning of your class. 393 393 394 394 {{code language="java" title="Code injection"}} ... ... @@ -401,7 +401,8 @@ 401 401 {{note title="Extensions Naming Scheme"}} 402 402 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. 403 403 {{/note}} 404 -))) 456 +{{/task}} 457 +{{/task-list}} 405 405 {{/layout-cell}} 406 406 407 407 {{layout-cell}} ... ... @@ -411,7 +411,11 @@ 411 411 412 412 {{layout-section ac:type="two_right_sidebar"}} 413 413 {{layout-cell}} 414 -* 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. 467 +{{task-list}} 468 +{{task id="13" status="incomplete"}} 469 +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. 470 +{{/task}} 471 +{{/task-list}} 415 415 416 416 == The existing Compilation Chain == 417 417 ... ... @@ -493,14 +493,34 @@ 493 493 494 494 Write a transformation that transforms your normalized version of ABO's HandleA into its corresponding SCG. 495 495 496 -* Proceed as before. Create a new plugin (or copy your last one) Make sure, you also add de.cau.cs.kieler.scg to your dependencies. 497 -* Write a transformation that is able to transform {{code language="none"}}ABO_norm_HandleA{{/code}} into its corresponding SCG. 498 -* **Verify your generated SCG**. If you added your transformation correctly, the SCG should be displayed automatically as soon as selected. If your SCG looks like the SCG depicted earlier, then everything is fine. 499 -* Check your SCG semantically. Is there anything you could improve/optimize? 500 -*1. Write a second transformation (just as before) and add it to the transformation chain right after the transformation you already added. 501 -*1. Optimize the given SCG and compare the result with the previous one. 502 -*1. Make sure that the two SCGs are still semantically identical. 553 +{{task-list}} 554 +{{task id="14" status="incomplete"}} 555 +Proceed as before. Create a new plugin (or copy your last one) Make sure, you also add de.cau.cs.kieler.scg to your dependencies. 556 +{{/task}} 503 503 558 +{{task id="15" status="incomplete"}} 559 +Write a transformation that is able to transform 560 + 561 +{{code language="none"}} 562 +ABO_norm_HandleA 563 +{{/code}} 564 + 565 + into its corresponding SCG. 566 +{{/task}} 567 + 568 +{{task id="16" status="incomplete"}} 569 +**Verify your generated SCG**. If you added your transformation correctly, the SCG should be displayed automatically as soon as selected. If your SCG looks like the SCG depicted earlier, then everything is fine. 570 +{{/task}} 571 + 572 +{{task id="17" status="incomplete"}} 573 +Check your SCG semantically. Is there anything you could improve/optimize? 574 + 575 +1. Write a second transformation (just as before) and add it to the transformation chain right after the transformation you already added. 576 +1. Optimize the given SCG and compare the result with the previous one. 577 +1. Make sure that the two SCGs are still semantically identical. 578 +{{/task}} 579 +{{/task-list}} 580 + 504 504 505 505 506 506 Congratulations! You finished the SCCharts Development Tutorial. Ask your supervisor for further instructions!
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -168104 261 +16810384 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/TUT/pages/168104 26/SCCharts Development1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/TUT/pages/16810384/SCCharts Development