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 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 ... ... @@ -13,7 +13,7 @@ 13 13 14 14 == Required Software == 15 15 16 -As you're going to develop for KIELER SCCharts we recommend to use the semanticOomph 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.16 +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. 17 17 {{/layout-cell}} 18 18 {{/layout-section}} 19 19 ... ... @@ -102,21 +102,30 @@ 102 102 103 103 ==== Model Task ==== 104 104 105 -1. Answer the following questions 106 -11. How do you describe a superstate in the model? 107 -11. Outline the relationship between states, regions, transitions, and valued objects.\\ 108 -11. Name the class of the root element of an SCChart. 109 -11. What is a valued object? 110 -11. How do you get the type of an interface variable? 111 -11. What other metamodels are needed for the SCCharts metamodel and write down which one is needed for what? 112 -1. Write down (on paper, text editor, etc) how the following SCChart models look like 113 -11. Open the wiki page that explains the [[doc:KIELER.Textual SCCharts Language SCT]]. 114 -11. Search the //SCChart, Initial State, State, Transition and Immediate Transition //example and ... 115 -111. write down (on paper or text editor, etc) how the model of that SCChart looks like. 116 -111. The user now marks C as final. What has to be changed in the model? What semantic problem do you see? 117 -11. Now, navigate to the //Super State: Strong Abort Transition //example. Write down (on paper) how the model of that SCCharts looks like. 118 -11. And finally a more sophisticated model: Write down the model of ABO (from [[doc:KIELER.Examples]]). 105 +{{task-list}} 106 +{{task id="1" status="incomplete"}} 107 +(% style="line-height: 1.42857;" %)Answer the following questions 119 119 109 +1. How do you describe a superstate in the model? 110 +1. Outline the relationship between states, regions, transitions, and valued objects.\\ 111 +1. Name the class of the root element of an SCChart. 112 +1. What is a valued object? 113 +1. How do you get the type of an interface variable? 114 +1. What other metamodels are needed for the SCCharts metamodel and write down which one is needed for what? 115 +{{/task}} 116 + 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 + 120 120 121 121 122 122 {{info title="KLighD Screenshots"}} ... ... @@ -239,24 +239,42 @@ 239 239 240 240 You are now equipped with the fundamentals you need to create models programmatically. Let's try it: 241 241 242 -1. 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. 243 -11. Run the {{code language="none"}}main(){{/code}} method by right-clicking its class and selecting (% style="line-height: 1.42857;" %)//Run as//(%%) -> (% style="line-height: 1.42857;" %)//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. 244 -11. Execute the main method. 245 -11. ((( 246 -Inspect your SCT file. (Press F5 to refresh your file view.) 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. 247 247 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. ((( 258 +(% style="line-height: 1.42857;" %)Inspect your SCT file. (Press F5 to refresh your file view.) 259 + 248 248 {{note title="Kext Warning"}} 249 249 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. 250 250 {{/note}} 251 251 ))) 252 -1. Now, create a new Java class and proceed as before to generate a model of ABO in the {{code language="none"}}main(){{/code}} method. 253 -1. Start your SCChart Editor Eclipse instance and load your SCT file. KLighD should now be able to visualize your ABO correctly. 254 -11. For this, open tab //Run// and select// Run Configurations...// 255 -11. Create a new //Eclipse Application// and name it appropriately. 256 -11. As product select {{code language="none"}}de.cau.cs.kieler.core.product.product{{/code}}. 257 -11. Click //Run// (or //Debug// if you opened// Debug Configuration...//) 258 -11. Create a new project and add you generated model. 264 +{{/task}} 259 259 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 + 260 260 261 261 {{/layout-cell}} 262 262 ... ... @@ -276,21 +276,31 @@ 276 276 {{layout-cell}} 277 277 = Model-to-Model Transformations with KiCo = 278 278 279 -You can use the 306 +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. 280 280 281 281 == Creating a new Transformation == 282 282 283 -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. :) 310 +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. :) 311 +{{/layout-cell}} 284 284 285 - 313 +{{layout-cell}} 314 +[[image:attach:KielerSCTEditor.png]] 315 +{{/layout-cell}} 316 +{{/layout-section}} 286 286 318 +{{layout-section ac:type="two_right_sidebar"}} 319 +{{layout-cell}} 287 287 ==== Transformation Creation Task ==== 288 288 289 -1. Therefore, create a new project within your tutorial working set as before. 290 -1. Add plugin dependencies to {{code language="none"}}de.cau.cs.kieler.kico{{/code}} and {{code language="none"}}de.cau.cs.kieler.sccharts{{/code}}. 291 -1. Create a new //Xtend class// in you package and name it "DoubleStates" and use {{code language="none"}}AbstractProductionTransformation{{/code}} as superclass. 292 -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. 293 -1. Click on //Add unimplemented methods//. 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//. 294 294 1. ((( 295 295 Now, you should have a class similar to the following one. 296 296 ... ... @@ -320,29 +320,67 @@ 320 320 * 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... 321 321 {{/info}} 322 322 ))) 323 -1. ((( 324 -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**. 360 +{{/task}} 325 325 362 +{{task id="7" status="incomplete"}} 363 +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**. 364 + 326 326 {{info title="Programming Guidelines"}} 327 327 You should really think about some constants here. You can also look at the sccharts transformation and features constants in the sccharts plugin. 328 328 {{/info}} 329 -))) 330 -1. KiCo must know about the new feature and also about your new transformation. 331 -11. Add a new Xtend class with Feature as superclass. Add all unimplemented methods. Also set** sccharts.doubleStates** as Id. 332 -11. Go to the Extension tab inside your plugin configuration. 333 -111. Add a new Extension Point de.cau.cs.kieler.kico.feature. Create a new featureClass and point it to your new feature class. 334 -111. Also add a new Extension Point de.cau.cs.kieler.kico.transformation. Create a new productionTransformationClass and point it to your transformation class. 335 -111. 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: 336 -1111. editor: de.cau.cs.kieler.sccharts.text.sct.Sct 337 -1111. features: sccharts.doubleStates 338 -1111. label: Tutorial Compilation 339 -1111. priority: 101 340 -1111. preferred: (leave it blank) 341 -11. {{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. 342 -1. If you want to rename your feature in the Compiler Selection (without changing its Id), override the getName method and return a new name. Rename your feature appropriately. 343 -1. Now, fill your transformation with life: 344 -11. Inside your transformation class, add a new method with the following signature: def State transform(State rootState, KielerCompilerContext context). This transformation will be executed if the feature is selected in the Compiler Selection. 345 -11. ((( 368 +{{/task}} 369 +{{/task-list}} 370 +{{/layout-cell}} 371 + 372 +{{layout-cell}} 373 + 374 +{{/layout-cell}} 375 +{{/layout-section}} 376 + 377 +{{layout-section ac:type="two_right_sidebar"}} 378 +{{layout-cell}} 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}} 406 +{{/layout-cell}} 407 + 408 +{{layout-cell}} 409 +[[image:attach:KielerSCTEditorOwnTransformation.png]] 410 +{{/layout-cell}} 411 +{{/layout-section}} 412 + 413 +{{layout-section ac:type="two_right_sidebar"}} 414 +{{layout-cell}} 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. ((( 346 346 Add thew following body to the function and try to understand the Xtend code. Import unknown class via code assist. 347 347 348 348 {{code language="java" title="transform"}} ... ... @@ -358,24 +358,43 @@ 358 358 } 359 359 {{/code}} 360 360 ))) 361 -11. When selecting your transformation, the SCChart gets transformed and looks like the version on the right. 362 -1. 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. 363 -1. ((( 364 -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. 436 +1. When selecting your transformation, the SCChart gets transformed and looks like the version on the right. 437 +{{/task}} 365 365 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"}} 444 +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. 445 + 366 366 {{code language="java" title="Code injection"}} 367 367 @Inject 368 368 extension SCChartsExtension 369 369 {{/code}} 370 370 371 -There are several Extensions classes within the KIELER project that extend the functionality of various classes. Basically, there are one or more for each metamodel (e.g. SCCharts, SCG, KExpressions, etc). You don't want to invent the wheel again. Use these methods. For example: there is a method that gives you all contained states of a state in a list: 451 +There are several Extensions classes within the KIELER project that extend the functionality of various classes. Basically, there are one or more for each metamodel (e.g. SCCharts, SCG, KExpressions, etc). You don't want to invent the wheel again. Use these methods. For example: there is a method that gives you all contained states of a state in a list: {{code language="none"}}getAllContainedStatesList{{/code}}. You can use it on your {{code language="none"}}rootState{{/code}}: {{code language="none"}}rootState.allContainedStatesList{{/code}}. There are also several convenient methods for creating model elements so that you don't have to use the factories directly. 372 372 373 373 {{note title="Extensions Naming Scheme"}} 374 374 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. 375 375 {{/note}} 376 -))) 377 -1. 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. 456 +{{/task}} 457 +{{/task-list}} 458 +{{/layout-cell}} 378 378 460 +{{layout-cell}} 461 +[[image:attach:KielerSCTEditorOwnTransformationOlolo.png]] 462 +{{/layout-cell}} 463 +{{/layout-section}} 464 + 465 +{{layout-section ac:type="two_right_sidebar"}} 466 +{{layout-cell}} 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}} 472 + 379 379 == The existing Compilation Chain == 380 380 381 381 Congratulations. You added and executed your own KiCo transformation. Nevertheless, often you want to extend the existing compilation chain. To do this, you proceed as before but instead of creating your own compilation chain, you must modify the existing chains (e.g. the netlist compilation in de.cau.cs.kieler.sccharts.ui). To add a specific transformation at a specific point in the chain, you must tell KiCo what features are required for the transformation. For that you must override the method getRequiredFeatureIds and return a set with all required features. ... ... @@ -388,7 +388,7 @@ 388 388 {{/layout-cell}} 389 389 390 390 {{layout-cell}} 391 -[[image:attach: KielerSCTEditor.png]]485 +[[image:attach:ABODoubleStates.png]] 392 392 393 393 394 394 ... ... @@ -395,64 +395,6 @@ 395 395 396 396 397 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 - 428 - 429 - 430 - 431 - 432 - 433 - 434 - 435 - 436 - 437 - 438 - 439 -[[image:attach:KielerSCTEditorOwnTransformation.png]] 440 - 441 -[[image:attach:KielerSCTEditorOwnTransformationOlolo.png]] 442 - 443 - 444 - 445 - 446 - 447 - 448 - 449 - 450 - 451 - 452 - 453 - 454 - 455 -[[image:attach:ABODoubleStates.png]] 456 456 {{/layout-cell}} 457 457 {{/layout-section}} 458 458 ... ... @@ -514,14 +514,36 @@ 514 514 515 515 Write a transformation that transforms your normalized version of ABO's HandleA into its corresponding SCG. 516 516 517 -1. 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. 518 -1. Write a transformation that is able to transform {{code language="none"}}ABO_norm_HandleA{{/code}} into its corresponding SCG. 519 -1. **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. 520 -1. Check your SCG semantically. Is there anything you could improve/optimize? 521 -11. Write a second transformation (just as before) and add it to the transformation chain right after the transformation you already added. 522 -11. Optimize the given SCG and compare the result with the previous one. 523 -11. 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}} 524 524 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 + 581 + 582 + 525 525 Congratulations! You finished the SCCharts Development Tutorial. Ask your supervisor for further instructions! 526 526 527 527
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -1681037 61 +16810379 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/TUT/pages/1681037 6/SCCharts Development1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/TUT/pages/16810379/SCCharts Development