Changes for page SCCharts Development
Last modified by Richard Kreissig on 2023/09/14 10:04
Summary
-
Page properties (3 modified, 0 added, 0 removed)
-
Attachments (0 modified, 0 added, 13 removed)
- ABODoubleStates.png
- InstallEcoreViz.png
- InstallKLighDFeatures.png
- KLighDSaveAsImage.png
- KielerSCTEditor.png
- KielerSCTEditorOwnTransformation.png
- KielerSCTEditorOwnTransformationOlolo.png
- RunConfiguration.png
- abo_norm_HandleA.png
- abo_scg_HandleA.png
- sccharts-scg.png
- sccharts_metamodel.png
- sccharts_metamodel_treeEditor.png
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Parent
-
... ... @@ -1,1 +1,0 @@ 1 -KIELER and SCCharts - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. nbw1 +XWiki.ssm - Content
-
... ... @@ -1,16 +1,10 @@ 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 +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. 5 5 6 -{{warning title="Outdated!"}} 7 -The KiCo part "Model-to-Model Transformations with KiCo" is outdated. We will update this tutorials in the near future. 8 -{{/warning}} 9 9 10 -\\ 11 11 12 - 13 - 14 14 {{toc/}} 15 15 16 16 = Preliminaries = ... ... @@ -19,13 +19,13 @@ 19 19 20 20 == Required Software == 21 21 22 -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.16 +As you're going to develop for KIELER SCCharts we recommend to use the semantic 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 23 {{/layout-cell}} 24 24 {{/layout-section}} 25 25 26 26 {{layout-section ac:type="three_equal"}} 27 27 {{layout-cell}} 28 - \\22 + 29 29 30 30 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. 31 31 ... ... @@ -38,15 +38,15 @@ 38 38 {{/layout-cell}} 39 39 40 40 {{layout-cell}} 41 - \\35 + 42 42 43 43 [[image:attach:InstallEcoreViz.png]] 44 44 45 - \\39 + 46 46 {{/layout-cell}} 47 47 48 48 {{layout-cell}} 49 - \\43 + 50 50 51 51 [[image:attach:InstallKLighDFeatures.png]] 52 52 {{/layout-cell}} ... ... @@ -58,8 +58,8 @@ 58 58 59 59 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. 60 60 61 -1. [[doc: TUT.Tutorials.Eclipse.EclipsePlug-ins and Extension Points.WebHome]]62 -1. [[doc: TUT.Tutorials.Eclipse.EclipseModeling Framework (EMF).WebHome]]55 +1. [[doc:Eclipse Plug-ins and Extension Points]] 56 +1. [[doc:Eclipse Modeling Framework (EMF)]] 63 63 11. This tutorial needs the turingmachine.ecore and the controller you've implemented in the EMF tutorial. If you did not complete the EMF tutorial, you may download a working turing machine here... (in the future). 64 64 1. ((( 65 65 (% class="with-breadcrumbs" %) ... ... @@ -71,11 +71,11 @@ 71 71 When developing within the KIELER semantics team, you will most likely be confronted with Xtext and [[doc:KIELER.Lightweight Diagrams (KLighD)]]. The following tutorials may be helpful but not required for this tutorial. 72 72 73 73 1. [[doc:Xtext 2 - Creating a Grammar from Scratch]] 74 -1. [[doc: TUT.Tutorials.Diagrams andLayout.Lightweight Diagrams (KLighD).WebHome]]68 +1. [[doc:Lightweight Diagrams (KLighD)]] 75 75 76 76 == Finding Documentation == 77 77 78 -You can find additional documentation to the aforementioned topics in the corresponding tutorials. If you get stuck with a particular topic, please consult that tutorial. For SCCharts, you should read the SCCharts confluence page in our wiki: [[doc:KIELER.SCCharts (pre 1\.0)]]72 +You can find additional documentation to the aforementioned topics in the corresponding tutorials. If you get stuck with a particular topic, please consult that tutorial. For SCCharts, you should read the SCCharts confluence page in our wiki: [[doc:KIELER.SCCharts]] 79 79 80 80 As usual, documentation often gets obsolete or wrong if not maintained regularly, so please, if you find missing, misleading, or outdated information, please let us know. 81 81 ... ... @@ -82,15 +82,15 @@ 82 82 Additionally, the following list will give a short overview over the most important publications: 83 83 84 84 * (% style="color: rgb(0,0,0);" %)**Main paper:** 85 -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. In (% class="cmti-10" %)Proc. ACM SIGPLAN Conference on Programming Language Design(%%) (% class="cmti-10" %)and Implementation (PLDI’14)(%%), Edinburgh, UK, June 2014. ACM. [[pdf>>url:http://rtsys.informatik.uni-kiel.de/~~biblio/downloads/papers/pldi14.pdf||shape="rect"]](% style="color: rgb(0,0,0);" %), (%%)[[talk>>url:http://rtsys.informatik.uni-kiel.de/~~biblio/downloads/talks/pldi14-talk.pdf||shape="rect"]](% style="color: rgb(0,0,0);" %), (%%)[[bib>>url:http://rtsys.informatik.uni-kiel.de/~~biblio/cgi-bin/bibcgi.cgi?key=vonHanxledenDM+14||shape="rect"]] 79 +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. In (% class="cmti-10" %)Proc. ACM SIGPLAN Conference on Programming Language Design(%%) (% class="cmti-10" %)and Implementation (PLDI’14)(%%), Edinburgh, UK, June 2014. ACM. (%%)[[pdf>>url:http://rtsys.informatik.uni-kiel.de/~~biblio/downloads/papers/pldi14.pdf||shape="rect"]](% style="color: rgb(0,0,0);" %), (%%)[[talk>>url:http://rtsys.informatik.uni-kiel.de/~~biblio/downloads/talks/pldi14-talk.pdf||shape="rect"]](% style="color: rgb(0,0,0);" %), (%%)[[bib>>url:http://rtsys.informatik.uni-kiel.de/~~biblio/cgi-bin/bibcgi.cgi?key=vonHanxledenDM+14||shape="rect"]] 86 86 * **SLIC Compilation:** 87 -(% style="color: rgb(0,0,0);" %)Christian Motika and Steven Smyth and Reinhard von Hanxleden. Compiling SCCharts—A Case-Study on Interactive Model-Based Compilation. In (% class="cmti-10" %)Proceedings of(%%) (% class="cmti-10" %)the 6th International Symposium on Leveraging Applications of Formal(%%) (% class="cmti-10" %)Methods, Verification and Validation (ISoLA 2014)(%%), volume 8802 of (% class="cmti-10" %)LNCS(%%), page 443–462, Corfu, Greece, October 2014. The [[original publication>>url:http://dx.doi.org/10.1007/978-3-662-45234-9||shape="rect"]](% style="color: rgb(0,0,0);" %) is available at (%%)[[http:~~/~~/link.springer.com>>url:http://link.springer.com/||shape="rect"]](% style="color: rgb(0,0,0);" %). (%%)[[pdf>>url:http://rtsys.informatik.uni-kiel.de/~~biblio/downloads/papers/isola14.pdf||shape="rect"]](% style="color: rgb(0,0,0);" %), (%%)[[bib>>url:http://rtsys.informatik.uni-kiel.de/~~biblio/cgi-bin/bibcgi.cgi?key=MotikaSvH14||shape="rect"]] 81 +(% style="color: rgb(0,0,0);" %)Christian Motika and Steven Smyth and Reinhard von Hanxleden. Compiling SCCharts—A Case-Study on Interactive Model-Based Compilation. In (% class="cmti-10" %)Proceedings of(%%) (% class="cmti-10" %)the 6th International Symposium on Leveraging Applications of Formal(%%) (% class="cmti-10" %)Methods, Verification and Validation (ISoLA 2014)(%%), volume 8802 of (% class="cmti-10" %)LNCS(%%), page 443–462, Corfu, Greece, October 2014. The (%%)[[original publication>>url:http://dx.doi.org/10.1007/978-3-662-45234-9||shape="rect"]](% style="color: rgb(0,0,0);" %) is available at (%%)[[http:~~/~~/link.springer.com>>url:http://link.springer.com/||shape="rect"]](% style="color: rgb(0,0,0);" %). (%%)[[pdf>>url:http://rtsys.informatik.uni-kiel.de/~~biblio/downloads/papers/isola14.pdf||shape="rect"]](% style="color: rgb(0,0,0);" %), (%%)[[bib>>url:http://rtsys.informatik.uni-kiel.de/~~biblio/cgi-bin/bibcgi.cgi?key=MotikaSvH14||shape="rect"]] 88 88 * **Theoretical Foundations:** 89 -(% style="color: rgb(0,0,0);" %)Reinhard von Hanxleden and Michael Mendler and Joaquín Aguado and Björn Duderstadt and Insa Fuhrmann and Christian Motika and Stephen Mercer and Owen O’Brien and Partha Roop. Sequentially Constructive Concurrency—A Conservative Extension of the Synchronous Model of Computation. (% class="cmti-10" %)ACM Transactions on Embedded Computing(%%) (% class="cmti-10" %)Systems, Special Issue on Applications of Concurrency to System Design(%%), 13(4s):144:1–144:26, July 2014. [[pdf>>url:http://rtsys.informatik.uni-kiel.de/~~biblio/downloads/papers/tecs14.pdf||shape="rect"]](% style="color: rgb(0,0,0);" %), (%%)[[bib>>url:http://rtsys.informatik.uni-kiel.de/~~biblio/cgi-bin/bibcgi.cgi?key=vonHanxledenMA+14||shape="rect"]] 83 +(% style="color: rgb(0,0,0);" %)Reinhard von Hanxleden and Michael Mendler and Joaquín Aguado and Björn Duderstadt and Insa Fuhrmann and Christian Motika and Stephen Mercer and Owen O’Brien and Partha Roop. Sequentially Constructive Concurrency—A Conservative Extension of the Synchronous Model of Computation. (% class="cmti-10" %)ACM Transactions on Embedded Computing(%%) (% class="cmti-10" %)Systems, Special Issue on Applications of Concurrency to System Design(%%), 13(4s):144:1–144:26, July 2014. (%%)[[pdf>>url:http://rtsys.informatik.uni-kiel.de/~~biblio/downloads/papers/tecs14.pdf||shape="rect"]](% style="color: rgb(0,0,0);" %), (%%)[[bib>>url:http://rtsys.informatik.uni-kiel.de/~~biblio/cgi-bin/bibcgi.cgi?key=vonHanxledenMA+14||shape="rect"]] 90 90 * **Overview and High-Level Transformations in Detail:** 91 91 (% 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"]] 92 92 93 - \\87 + 94 94 {{/layout-cell}} 95 95 {{/layout-section}} 96 96 ... ... @@ -108,26 +108,23 @@ 108 108 109 109 ==== Model Task ==== 110 110 111 -* ((( 112 -(% style="line-height: 1.42857;" %)Answer the following questions 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]]). 113 113 114 -1. How do you describe a superstate in the model? 115 -1. Outline the relationship between states, regions, transitions, and valued objects.\\ 116 -1. Name the class of the root element of an SCChart. 117 -1. What is a valued object? 118 -1. How do you get the type of an interface variable? 119 -1. What other metamodels are needed for the SCCharts metamodel and write down which one is needed for what? 120 -))) 121 -* Write down (on paper, text editor, etc) how the following SCChart models look like 122 -*1. Open the wiki page that explains the [[doc:KIELER.Textual SCCharts Language SCT]]. 123 -*1. Search the //SCChart, Initial State, State, Transition and Immediate Transition //example and ... 124 -*11. write down (on paper or text editor, etc) how the model of that SCChart looks like. 125 -*11. The user now marks C as final. What has to be changed in the model? What semantic problem do you see? 126 -*1. Now, navigate to the //Super State: Strong Abort Transition //example. Write down (on paper) how the model of that SCCharts looks like. 127 -*1. And finally a more sophisticated model: Write down the model of ABO (from [[doc:KIELER.Examples]]). 120 + 128 128 129 -\\ 130 - 131 131 {{info title="KLighD Screenshots"}} 132 132 By the way: You can //right-click// on the Diagram View surface and select //Save as image...// to create a screenshot! 133 133 {{/info}} ... ... @@ -150,10 +150,10 @@ 150 150 151 151 We need a project for testing. Do the following: 152 152 153 - *If you used the standard KIELER Oomph installation setup, create a new Working Set named Tutorial in the Package Explorer. Then...154 - *Create a new empty //Plug-In Project//.155 - *Add the project that contains the sccharts metamodel as a dependency of your new project through the //Plugin Manifest Editor//.156 - *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.144 +1. If you used the standard KIELER Oomph installation setup, create a new Working Set named Tutorial in the Package Explorer. Then... 145 +1. Create a new empty //Plug-In Project//. 146 +1. Add the project that contains the sccharts metamodel as a dependency of your new project through the //Plugin Manifest Editor//. 147 +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. 157 157 158 158 == Creating a Model == 159 159 ... ... @@ -161,8 +161,8 @@ 161 161 162 162 {{code language="java"}} 163 163 SCChartsFactory sccFactory = SCChartsFactory.eINSTANCE; 164 -State state = sccFactory.createState(); 165 -Transition transition = sccFactory.createTransition(); 155 +State state = sccFactory .createState(); 156 +Transition transition = sccFactory .createTransition(); 166 166 {{/code}} 167 167 168 168 Important: The SCCharts grammar is build on top of several other grammars. Therefore, not all language objects can be found in the SCCharts factory. For example, all expression elements are part of the KExpressions grammar and hence, have their own factory. If you need other factories, don't forget to add the corresponding plugin to your plugin dependency list. ... ... @@ -175,7 +175,7 @@ 175 175 For all simple attributes, there are getter and setter methods: 176 176 177 177 {{code language="java"}} 178 -state.setId(" Init");169 +state.setId("Root"); 179 179 boolValue.setValue(true); 180 180 {{/code}} 181 181 ... ... @@ -199,14 +199,8 @@ 199 199 200 200 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: 201 201 202 -* ((( 203 -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. 204 - 205 -{{info title="Additional Dependencies"}} 206 -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. 207 -{{/info}} 208 -))) 209 -* ((( 193 +1. Add a dependency to the {{code language="none"}}org.eclipse.emf.ecore.xmi{{/code}} plug-in. 194 +1. ((( 210 210 Use something like the following code to save the model from above: 211 211 212 212 {{code language="java"}} ... ... @@ -213,10 +213,10 @@ 213 213 // Create a resource set. 214 214 ResourceSet resourceSet = new ResourceSetImpl(); 215 215 216 -// Register the resource factory -- only needed for stand-alone! 217 - SctStandaloneSetup.doSetup();218 - 219 - 201 +// Register the default resource factory -- only needed for stand-alone! 202 +// this tells EMF to use XML to save the model 203 +resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put( 204 + Resource.Factory.Registry.DEFAULT_EXTENSION, new SCTResourceFactoryImpl()); 220 220 // Get the URI of the model file. 221 221 URI fileURI = URI.createFileURI(new File("myABO.sct").getAbsolutePath()); 222 222 ... ... @@ -223,7 +223,7 @@ 223 223 // Create a resource for this file. 224 224 Resource resource = resourceSet.createResource(fileURI); 225 225 226 -// Add the model objects to the contents. Usually, this is the root node of the model.211 +// Add the model objects to the contents. 227 227 resource.getContents().add(myModel); 228 228 229 229 // Save the contents of the resource to the file system. ... ... @@ -234,298 +234,270 @@ 234 234 /* error handling */ 235 235 } 236 236 {{/code}} 237 - 238 -{{info title="File Extensions"}} 239 -File extensions are important! They define the parser/serializer that EMF uses. Always use the file extension that is defined for a particular model. 240 -{{/info}} 241 241 ))) 242 -{{/layout-cell}} 243 -{{/layout-section}} 244 244 245 -{{layout-section ac:type="two_right_sidebar"}} 246 -{{layout-cell}} 247 247 ==== Model Creation Task ==== 248 248 249 - Youare now equippedwiththefundamentalsyouneedtocreatemodelsprogrammatically. Let's try it:226 +With these information out of the way, on we go to some model creation: 250 250 251 -* (% 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. 252 -*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. 253 -*1. Execute the main method. 254 -*1. ((( 255 -(% style="line-height: 1.42857;" %)Inspect your SCT file. (Press F5 to refresh your file view.) 256 - 257 -{{note title="Kext Warning"}} 258 -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. 259 -{{/note}} 260 -))) 261 -* Now, create a new Java class and proceed as before to generate a model of ABO in the {{code language="none"}}main(){{/code}} method. 262 -* (% 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.(%%)\\ 263 -*1. For this, open tab //Run// and select// Run Configurations...// 264 -*1. Create a new //Eclipse Application// and name it appropriately. 265 -*1. As product select {{code language="none"}}de.cau.cs.kieler.core.product.product{{/code}}. 266 -*1. Click //Run// (or //Debug// if you opened// Debug Configuration...//) 267 -*1. Create a new project and add you generated model. 268 - 269 -\\ 228 +1. Programmatically create a valid model of ABO in the {{code language="none"}}main(){{/code}} method. 229 +1. 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. 230 +1. Execute the main method. 231 +1. Inspect your SCT file. 232 +1. Start your SCChart Editor Eclipse instance and load your SCT file. KLighD should now be able to visualize your ABO correctly. 270 270 {{/layout-cell}} 234 +{{/layout-section}} 271 271 236 +{{layout-section ac:type="single"}} 272 272 {{layout-cell}} 273 -{{code language="java" title="Root.sct"}} 274 -scchart Root { 275 - initial state Init 276 - --> Init with true; 277 -} 278 -{{/code}} 279 - 280 -[[image:attach:RunConfiguration.png]] 238 + 281 281 {{/layout-cell}} 282 282 {{/layout-section}} 283 283 284 -{{layout-section ac:type=" two_right_sidebar"}}242 +{{layout-section ac:type="single"}} 285 285 {{layout-cell}} 286 -= Model-to-ModelTransformationswithKiCo=244 += Transforming SCCharts = 287 287 288 - You canuse the [[Kieler Compiler>>url:http://rtsys.informatik.uni-kiel.de/confluence/display/KIELER/Kieler+Compiler||shape="rect"]] (KiCo)tohandleall themodelinput/outputtasks and concentrate on the actualtransformation.Ifyouexecuted the **ModelCreationTaskcorrectly**,you shouldnowhavea completerunningSCTEditorinstance that looks like the oneonheright. You shouldseethe //KIELERCompiler Selection// ntheowerright part oftheworking space.Here youcanselectspecifictransformationsthatwillbeappliedto the actual model.Simplyselect atransformation to testit.246 +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). Both is possible. Just make sure that you know what you're doing. 289 289 290 - ==Creatinga newTransformation==248 +Now, you're going to transform the normalized form of HandleA from ABO to an SCG. The Sequentially Constructive Graph is a control-flow graph which can be seen as another representation of the same program. The SCG of the normalized version of ABO's HandleA is depicted on the right. 291 291 292 -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}} 250 +|((( 251 +{{code}} 252 +scchart ABO_norm_HandleA { 253 + input output bool A; 254 + input output bool B; 255 + output bool O1; 256 + output bool O2; 257 + region HandleA: 258 + initial state WaitA 259 + --> _S immediate with A 260 + --> _Pause immediate; 261 + final state DoneA; 262 + state _S 263 + --> _S2 immediate with / B = true; 264 + state _S2 265 + --> DoneA immediate with / O1 = true; 266 + state _Pause 267 + --> _Depth; 268 + state _Depth 269 + --> _S immediate with A 270 + --> _Pause immediate; 271 +} 272 +{{/code}} 273 +)))|((( 274 +[[image:attach:abo_norm_HandleA.png]] 275 +)))|(% colspan="1" %)(% colspan="1" %) 276 +((( 277 +[[image:attach:abo_scg_HandleA.png]] 278 +))) 294 294 295 -{{layout-cell}} 296 -[[image:attach:KielerSCTEditor.png]] 297 -{{/layout-cell}} 298 -{{/layout-section}} 280 +The next figure depicts the direct mapping from normalized SCCharts to their corresponding SCG. 299 299 300 -{{layout-section ac:type="two_right_sidebar"}} 301 -{{layout-cell}} 302 -==== Transformation Creation Task ==== 282 +[[image:attach:sccharts-scg.png]] 303 303 304 -* Create your first transformation... 305 -*1. Create a new project within your tutorial working set as before. 306 -*1. Add plugin dependencies to {{code language="none"}}de.cau.cs.kieler.kico{{/code}} and {{code language="none"}}de.cau.cs.kieler.sccharts{{/code}}. 307 -*1. Create a new //Xtend class// in you package and name it "DoubleStates" and use {{code language="none"}}AbstractProductionTransformation{{/code}} as superclass. 308 -*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. 309 -*1. Click on //Add unimplemented methods//. 310 -*1. ((( 311 -Now, you should have a class similar to the following one. 284 +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, 312 312 313 -{{code language="java"}} 314 -package tutorial.transformation 286 +==== Transformation Task ==== 315 315 316 - importde.cau.cs.kieler.kico.transformation.AbstractProductionTransformation288 +Write a transformation that transforms your normalized version of ABO's HandleA into its corresponding SCG. 317 317 318 -class DoubleStates extends AbstractProductionTransformation { 319 - 320 - override getProducedFeatureId() { 321 - throw new UnsupportedOperationException("TODO: auto-generated method stub") 322 - } 323 - 324 - override getId() { 325 - throw new UnsupportedOperationException("TODO: auto-generated method stub") 326 - } 327 - 328 -} 329 -{{/code}} 290 +1. ((( 291 +**Writing a Model Transformation** 330 330 331 -{{info title="Xtend Infos"}} 332 -* Lines in Xtend code don't have to and with a semicolon. 333 -* We have been explicit about the method's return type, but we could have easily omitted it, letting Xtend infer the return type. 334 -* The keyword {{code language="none"}}val{{/code}} declares a constant, while {{code language="none"}}var{{/code}} declares a variable. Try to make do with constants where possible. 335 -* The methods you call should be declared as {{code language="none"}}def private{{/code}} since they are implementation details and shouldn't be called by other classes. 336 -* 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... 337 -{{/info}} 338 -))) 339 -* ((( 340 -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**. 293 +This time we want you to integrate your transformation into your SCCharts Editor instance. Therefore,... 294 +(% style="color: rgb(51,51,51);line-height: 1.66667;" %)\\ 341 341 342 -{{info title="Programming Guidelines"}} 343 -You should really think about some constants here. You can also look at the sccharts transformation and features constants in the sccharts plugin. 344 -{{/info}} 345 -))) 346 -{{/layout-cell}} 296 +1. Add a new package 347 347 348 -{{layout-cell}} 349 -\\ 350 -{{/layout-cell}} 351 -{{/layout-section}} 298 +{{code language="none"}} 299 +<project>.transformations 300 +{{/code}} to your project. 301 +1. Add an //Xtend Class// to the new package. 302 +1. If you notice that your new class is marked with an error marker because of a missing dependency of the new plug-in project to 352 352 353 -{{layout-section ac:type="two_right_sidebar"}} 354 -{{layout-cell}} 355 -* KiCo must know about the new feature and also about your new transformation. 356 -*1. Add a new Xtend class with Feature as superclass. Add all unimplemented methods. Also set** sccharts.doubleStates** as Id. 357 -*1. Go to the Extension tab inside your plugin configuration. 358 -*11. Add a new Extension Point de.cau.cs.kieler.kico.feature. Create a new featureClass and point it to your new feature class. 359 -*11. Also add a new Extension Point de.cau.cs.kieler.kico.transformation. Create a new productionTransformationClass and point it to your transformation class. 360 -*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: 361 -*111. editor: {{code language="none"}}de.cau.cs.kieler.sccharts.text.sct.Sct{{/code}} 362 -*111. features: sccharts.doubleStates 363 -*111. label: Tutorial Compilation 364 -*111. priority: 101 365 -*111. preferred: (leave it blank) 366 -*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. 367 -* 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}} 304 +{{code language="none"}} 305 +org.eclipse.xtext.xbase.lib, 306 +{{/code}}you can hover over the error with your mouse and have Eclipse add all libraries required by Xtend to your project. 307 +1. 369 369 370 -{{layout-cell}} 371 -[[image:attach:KielerSCTEditorOwnTransformation.png]] 372 -{{/layout-cell}} 373 -{{/layout-section}} 309 +Define an entry method for the transformation that takes an SCChart program instance as an argument and returns an SCG {{code language="none"}}Program{{/code}}. You can use the following (incomplete) method as a starting point: 374 374 375 -{{layout-section ac:type="two_right_sidebar"}} 376 -{{layout-cell}} 377 -* Now, fill your transformation with life: 378 -*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. 379 -*1. ((( 380 -Add thew following body to the function and try to understand the Xtend code. Import unknown class via code assist. 311 +((( 312 +(% class="syntaxhighlighter sh-confluence nogutter java" %) 313 +((( 314 + 381 381 382 -{{code language="java" title="transform"}} 383 - def State transform(State rootState, KielerCompilerContext context) { 384 - val newState = SCChartsFactory.eINSTANCE.createState => [ 385 - id = "ololo" 386 - label = "ololo" 387 - ] 316 +|((( 317 +(% class="container" title="Hint: double-click to select code" %) 318 +((( 319 +(% class="line number1 index0 alt2" %) 320 +((( 321 +{{code language="none"}} 322 +/** 323 +{{/code}} 324 +))) 388 388 389 - rootState.regions.filter(ControlflowRegion).head.states += newState 326 +(% class="line number2 index1 alt1" %) 327 +((( 328 +{{code language="none"}} 329 + 330 +{{/code}} 390 390 391 - rootState392 - }332 +{{code language="none"}} 333 +* Transforms a given SCCharts program into an SCG. 393 393 {{/code}} 394 394 ))) 395 -*1. When selecting your transformation, the SCChart gets transformed and looks like the version on the right. 396 -* 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. 397 -* ((( 398 -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. 399 399 400 -{{code language="java" title="Code injection"}} 401 - @Inject 402 - extension SCChartsExtension 337 +(% class="line number3 index2 alt2" %) 338 +((( 339 +{{code language="none"}} 340 + 403 403 {{/code}} 404 404 405 -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. 343 +{{code language="none"}} 344 +* 345 +{{/code}} 346 +))) 406 406 407 -{{note title="Extensions Naming Scheme"}} 408 -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. 409 -{{/note}} 348 +(% class="line number4 index3 alt1" %) 349 +((( 350 +{{code language="none"}} 351 +*/ 352 +{{/code}} 410 410 ))) 411 -{{/layout-cell}} 412 412 413 -{{layout-cell}} 414 -[[image:attach:KielerSCTEditorOwnTransformationOlolo.png]] 415 -{{/layout-cell}} 416 -{{/layout-section}} 355 +(% class="line number8 index7 alt1" %) 356 +((( 357 +{{code language="none"}} 358 +def SCGraph transform(State rootState) { 359 +{{/code}} 360 +))) 417 417 418 -{{layout-section ac:type="two_right_sidebar"}} 419 -{{layout-cell}} 420 -* 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. 362 +(% class="line number9 index8 alt2" %) 363 +((( 364 +{{code language="none"}} 365 + 366 +{{/code}} 421 421 422 -== The existing Compilation Chain == 368 +{{code language="none"}} 369 +// Create the SCG 370 +{{/code}} 371 +))) 423 423 424 -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. 373 +(% class="line number10 index9 alt1" %) 374 +((( 375 +{{code language="none"}} 376 + 377 +{{/code}} 425 425 426 -Also, if you're developing for the master chain, you should obey the package structure. Look at the sccharts plugins. All features, transformation, extensions, the metamodel, ui elements, etc are separated from each other. You should always do the same! 379 +{{code language="none"}} 380 +val scg = SCGraphFactory::eINSTANCE.createSCGraph() 381 +{{/code}} 382 +))) 427 427 428 -//We will add more content to this subsection in the future...// 384 +(% class="line number11 index10 alt2" %) 385 +((( 386 +{{code language="none"}} 387 + 388 +{{/code}} 389 +))) 429 429 430 -\\ 431 -{{/layout-cell}} 391 +(% class="line number12 index11 alt1" %) 392 +((( 393 +{{code language="none"}} 394 + 395 +{{/code}} 432 432 433 -{{layout-cell}} 434 -[[image:attach:ABODoubleStates.png]] 397 +{{code language="none"}} 398 +// TODO: Your transformation code 399 +{{/code}} 400 +))) 435 435 436 -\\ 402 +(% class="line number13 index12 alt2" %) 403 +((( 404 +{{code language="none"}} 405 + 406 +{{/code}} 407 +))) 437 437 438 -\\ 409 +(% class="line number14 index13 alt1" %) 410 +((( 411 +{{code language="none"}} 412 + 413 +{{/code}} 439 439 440 -\\ 441 -{{/layout-cell}} 442 -{{/layout-section}} 415 +{{code language="none"}} 416 +// Return the transformed program 417 +{{/code}} 418 +))) 443 443 444 -{{layout-section ac:type="single"}} 445 -{{layout-cell}} 446 -= Model-to-Model Transformations between Metamodels = 420 +(% class="line number15 index14 alt2" %) 421 +((( 422 +{{code language="none"}} 423 + scg 424 +{{/code}} 425 +))) 447 447 448 -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. 449 - 450 -Now, you're going to transform the normalized form of HandleA from ABO to an SCG. The Sequentially Constructive Graph is a control-flow graph which can be seen as another representation of the same program. The SCG of the normalized version of ABO's HandleA is depicted on the right. 451 - 452 -(% class="wrapped" %) 453 -|((( 454 -(% class="content-wrapper" %) 427 +(% class="line number16 index15 alt1" %) 455 455 ((( 456 -{{code}} 457 -scchart ABO_norm_HandleA { 458 - input output bool A; 459 - input output bool B; 460 - output bool O1; 461 - output bool O2; 462 - region HandleA: 463 - initial state WaitA 464 - --> _S immediate with A 465 - --> _Pause immediate; 466 - final state DoneA; 467 - state _S 468 - --> _S2 immediate with / B = true; 469 - state _S2 470 - --> DoneA immediate with / O1 = true; 471 - state _Pause 472 - --> _Depth; 473 - state _Depth 474 - --> _S immediate with A 475 - --> _Pause immediate; 429 +{{code language="none"}} 476 476 } 477 477 {{/code}} 478 478 ))) 479 -)))|((( 480 -(% class="content-wrapper" %) 481 -((( 482 -[[image:attach:abo_norm_HandleA.png]] 483 483 ))) 484 -)))|(% colspan="1" %)(% colspan="1" %) 434 +))) 435 + 436 + 437 +))) 438 +))) 439 + 485 485 ((( 486 -(% class=" content-wrapper" %)441 +(% class="syntaxhighlighter nogutter java" %) 487 487 ((( 488 - [[image:attach:abo_scg_HandleA.png]]443 +There's a few points to note here: 489 489 ))) 490 490 ))) 491 -{{/layout-cell}} 492 -{{/layout-section}} 493 493 494 -{{layout-section ac:type="two_equal"}} 495 -{{layout-cell}} 496 -The next figure depicts the direct mapping from normalized SCCharts to their corresponding SCG. 447 +\\ 497 497 498 -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}} 449 +1. 450 +1*. Lines in Xtend code don't have to and with a semicolon. 451 +1*. We have been explicit about the method's return type, but we could have easily omitted it, letting Xtend infer the return type. 452 +1*. The keyword 500 500 501 -{{layout-cell}} 502 -[[image:attach:sccharts-scg.png]] 503 -{{/layout-cell}} 504 -{{/layout-section}} 454 +{{code language="none"}} 455 +val 456 +{{/code}} declares a constant, while 505 505 506 -{{layout-section ac:type="two_right_sidebar"}} 507 -{{layout-cell}} 508 -==== Transformation Creation Task 2 ==== 458 +{{code language="none"}} 459 +var 460 +{{/code}} declares a variable. Try to make do with constants where possible. 461 +1*. The methods you call should be declared as 509 509 510 -Write a transformation that transforms your normalized version of ABO's HandleA into its corresponding SCG. 463 +{{code language="none"}} 464 +def private 465 +{{/code}} since they are implementation details and shouldn't be called by other classes. 466 +1*. 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, 511 511 512 -* 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. 513 -* Write a transformation that is able to transform {{code language="none"}}ABO_norm_HandleA{{/code}} into its corresponding SCG. 514 -* **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. 515 -* Check your SCG semantically. Is there anything you could improve/optimize? 516 -*1. Write a second transformation (just as before) and add it to the transformation chain right after the transformation you already added. 517 -*1. Optimize the given SCG and compare the result with the previous one. 518 -*1. Make sure that the two SCGs are still semantically identical. 519 - 468 +{{code language="none"}} 469 +def create 470 +{{/code}}methods might offer a better alternative... 520 520 \\ 472 +1. Replace the TODO with an transformation code that takes an extended BF program and transforms it into an semantically equivalent BF program that only uses standard BF instructions. 473 +HINT: Some of the extended BF commands can only be expressed by standard operations if you can write to other cells. Therefore you are allowed to perform side effects on the tape. 474 +1. Open the //Plug-In Manifest Editor// and switch to the Runtime tab. Add the package containing your transformation to the list of exported packages. (You may have to check the //Show non-Java packages// option in the //Exported Packages// dialog to see the package.) 475 +\\ 476 +))) 477 +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. 478 +1. Check your SCG semantically. Is there anything you could improve/optimize? 479 +11. Write a second transformation (just as before) and add it to the transformation chain right after the transformation you already added. 480 +11. Optimize the given SCG and compare the result with the previous one. 481 +11. Make sure that the two SCGs are still semantically identical. 521 521 522 522 Congratulations! You finished the SCCharts Development Tutorial. Ask your supervisor for further instructions! 523 523 524 - \\485 + 525 525 {{/layout-cell}} 526 - 527 -{{layout-cell}} 528 -\\ 529 -{{/layout-cell}} 530 530 {{/layout-section}} 531 531 {{/layout}}
- ABODoubleStates.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.XWikiGuest - Size
-
... ... @@ -1,1 +1,0 @@ 1 -38.4 KB - Content
- InstallEcoreViz.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.XWikiGuest - Size
-
... ... @@ -1,1 +1,0 @@ 1 -42.2 KB - Content
- InstallKLighDFeatures.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.XWikiGuest - Size
-
... ... @@ -1,1 +1,0 @@ 1 -48.9 KB - Content
- KLighDSaveAsImage.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.XWikiGuest - Size
-
... ... @@ -1,1 +1,0 @@ 1 -10.5 KB - Content
- KielerSCTEditor.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.XWikiGuest - Size
-
... ... @@ -1,1 +1,0 @@ 1 -95.0 KB - Content
- KielerSCTEditorOwnTransformation.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.XWikiGuest - Size
-
... ... @@ -1,1 +1,0 @@ 1 -91.1 KB - Content
- KielerSCTEditorOwnTransformationOlolo.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.XWikiGuest - Size
-
... ... @@ -1,1 +1,0 @@ 1 -96.9 KB - Content
- RunConfiguration.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.XWikiGuest - Size
-
... ... @@ -1,1 +1,0 @@ 1 -73.3 KB - Content
- abo_norm_HandleA.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.XWikiGuest - Size
-
... ... @@ -1,1 +1,0 @@ 1 -57.1 KB - Content
- abo_scg_HandleA.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.XWikiGuest - Size
-
... ... @@ -1,1 +1,0 @@ 1 -20.8 KB - Content
- sccharts-scg.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.XWikiGuest - Size
-
... ... @@ -1,1 +1,0 @@ 1 -75.5 KB - Content
- sccharts_metamodel.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.XWikiGuest - Size
-
... ... @@ -1,1 +1,0 @@ 1 -291.3 KB - Content
- sccharts_metamodel_treeEditor.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.XWikiGuest - Size
-
... ... @@ -1,1 +1,0 @@ 1 -40.7 KB - Content
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -168101 991 +16810318 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/TUT/pages/168101 99/SCCharts Development1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/TUT/pages/16810318/SCCharts Development