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,12 +1,10 @@ 1 1 {{layout}} 2 2 {{layout-section ac:type="single"}} 3 3 {{layout-cell}} 4 + 5 + 4 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 - 7 - 8 -{{toc/}} 9 - 10 10 = Preliminaries = 11 11 12 12 There's a few things to do before we dive into the tutorial itself. For example, to do Eclipse programming, you will have to get your hands on an Eclipse installation first. Read through the following sections to get ready for the tutorial tasks. ... ... @@ -19,8 +19,6 @@ 19 19 20 20 {{layout-section ac:type="three_equal"}} 21 21 {{layout-cell}} 22 - 23 - 24 24 Additionally, install the** EcoreViz** from the **Ecore Model Visualization** category from the **OpenKieler** update site: [[http:~~/~~/rtsys.informatik.uni-kiel.de/~~~~kieler/updatesite/nightly-openkieler/>>url:http://rtsys.informatik.uni-kiel.de/~~kieler/updatesite/nightly-openkieler/||rel="nofollow" shape="rect"]]. For this, choose //Install New Software...// in the //Help// tab. 25 25 26 26 Due to the ongoing migration you have to install a workaround for EcoreViz to function. You have to install the KLighD diagram view directly from [[http:~~/~~/rtsys.informatik.uni-kiel.de/~~~~kieler/updatesite/release_pragmatics_2016-02/>>url:http://rtsys.informatik.uni-kiel.de/~~kieler/updatesite/release_pragmatics_2016-02/||shape="rect"]]. Select the features ... ... @@ -32,16 +32,10 @@ 32 32 {{/layout-cell}} 33 33 34 34 {{layout-cell}} 35 - 36 - 37 37 [[image:attach:InstallEcoreViz.png]] 38 - 39 - 40 40 {{/layout-cell}} 41 41 42 42 {{layout-cell}} 43 - 44 - 45 45 [[image:attach:InstallKLighDFeatures.png]] 46 46 {{/layout-cell}} 47 47 {{/layout-section}} ... ... @@ -83,8 +83,6 @@ 83 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"]] 84 84 * **Overview and High-Level Transformations in Detail:** 85 85 (% 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"]] 86 - 87 - 88 88 {{/layout-cell}} 89 89 {{/layout-section}} 90 90 ... ... @@ -94,20 +94,16 @@ 94 94 95 95 Navigate to the {{code language="none"}}models{{/code}} folder of the plugin {{code language="none"}}de.cau.cs.kieler.sccharts{{/code}}. Here, open the {{code language="none"}}sccharts.ecore{{/code}} and right-click on the {{code language="none"}}sccharts.ecore{{/code}} file and select //Visualize Ecore Model//. Since you also installed **EcoreViz** from the OpenKieler Suite, you should now see a graphical representation of the SCCharts metamodel. Every SCChart will be a model of this metamodel. 96 96 97 -To see all class information check //Attributes/Literals// in the Diagram Options on the right. 98 - 99 -EcoreViz gives you an overview over the selected Ecore diagram. However, Ecore model definitions may depend on other Ecore definitions that are not displayed in the diagram. You can open new diagrams for these Ecore files as described before or use the Ecore tree editor to inspect all classes. 100 - 101 101 Try to understand most parts of the metamodel. You don't have to understand every detail but you should get the idea. 102 102 103 103 ==== Model Task ==== 104 104 105 105 1. Answer the following questions 90 +11. Name the class of the root element of an SCChart 106 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 109 11. What is a valued object? 110 110 11. How do you get the type of an interface variable? 94 +11. Outline the relationship between states, regions, transitions, and valued objects 111 111 11. What other metamodels are needed for the SCCharts metamodel and write down which one is needed for what? 112 112 1. Write down (on paper, text editor, etc) how the following SCChart models look like 113 113 11. Open the wiki page that explains the [[doc:KIELER.Textual SCCharts Language SCT]]. ... ... @@ -120,15 +120,25 @@ 120 120 121 121 122 122 {{info title="KLighD Screenshots"}} 123 -By the way: You can //right-click// on the Diagram View surface andselect //Save as image...// to create a screenshot!107 +By the way: You can //right-click// on the Diagram View surface to select //Save as image...// to create a screenshot! 124 124 {{/info}} 125 125 {{/layout-cell}} 126 126 127 127 {{layout-cell}} 112 + 113 + 114 + 115 + 128 128 [[image:attach:sccharts_metamodel.png]] 129 129 130 - [[image:attach:sccharts_metamodel_treeEditor.png]]118 + 131 131 120 + 121 + 122 + 123 + 124 + 125 + 132 132 [[image:attach:KLighDSaveAsImage.png]] 133 133 {{/layout-cell}} 134 134 {{/layout-section}} ... ... @@ -135,6 +135,20 @@ 135 135 136 136 {{layout-section ac:type="single"}} 137 137 {{layout-cell}} 132 + 133 + 134 + 135 +{{/layout-cell}} 136 +{{/layout-section}} 137 + 138 +{{layout-section ac:type="single"}} 139 +{{layout-cell}} 140 + 141 +{{/layout-cell}} 142 +{{/layout-section}} 143 + 144 +{{layout-section ac:type="single"}} 145 +{{layout-cell}} 138 138 = Creating SCCharts Models Programmatically = 139 139 140 140 == Creating a Test Project == ... ... @@ -141,7 +141,6 @@ 141 141 142 142 We need a project for testing. Do the following: 143 143 144 -1. If you used the standard KIELER Oomph installation setup, create a new Working Set named Tutorial in the Package Explorer. Then... 145 145 1. Create a new empty //Plug-In Project//. 146 146 1. Add the project that contains the sccharts metamodel as a dependency of your new project through the //Plugin Manifest Editor//. 147 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. ... ... @@ -148,12 +148,12 @@ 148 148 149 149 == Creating a Model == 150 150 151 -To create a model 158 +To create a model programmatically you cannot directly use the Java classes generated for the model. Instead, the main package contains interfaces for all of your model object classes. The {{code language="none"}}impl{{/code}} package contains the actual implementation and the {{code language="none"}}util{{/code}} package contains some helper classes. Do not instantiate objects directly by manually calling {{code language="none"}}new{{/code}}. EMF generates a Factory to create new objects. The factory itself uses the singleton pattern to get access to it: 152 152 153 153 {{code language="java"}} 154 154 SCChartsFactory sccFactory = SCChartsFactory.eINSTANCE; 155 -State state = sccFactory.createState(); 156 -Transition transition = sccFactory.createTransition(); 162 +State state = sccFactory .createState(); 163 +Transition transition = sccFactory .createTransition(); 157 157 {{/code}} 158 158 159 159 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. ... ... @@ -160,13 +160,13 @@ 160 160 161 161 {{code language="java"}} 162 162 KExpressionsFactory kFactory = KExpressionsFactory.eINSTANCE; 163 -BoolValue boolValue = kFactory.createBoolValue(); 170 +BooleanValue boolValue = kFactory.createBooleanValue(); 164 164 {{/code}} 165 165 166 166 For all simple attributes, there are getter and setter methods: 167 167 168 168 {{code language="java"}} 169 -state.setId(" Init");176 +state.setId("Root"); 170 170 boolValue.setValue(true); 171 171 {{/code}} 172 172 ... ... @@ -179,25 +179,15 @@ 179 179 List references (multiplicity of > 1) have only a list getter, which is used to manipulate the list: 180 180 181 181 {{code language="java"}} 182 -state. getOutgoingTransitions().add(transition);189 +state.outgoingTransitions.add(transition); 183 183 {{/code}} 184 184 185 -{{info title="Plugin Dependencies"}} 186 -You may have noticed that is was not necessary to add a dependency for the kexpressions classes. The SCCharts plugin reexports the dependencies of the other EMF metamodels. Look at the plugin.xml in the SCCharts plugin in the dependency tab for more information. 187 -{{/info}} 188 - 189 189 == Saving a Model == 190 190 191 191 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: 192 192 196 +1. Add a dependency to the {{code language="none"}}org.eclipse.emf.ecore.xmi{{/code}} plug-in. 193 193 1. ((( 194 -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. 195 - 196 -{{info title="Additional Dependencies"}} 197 -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. 198 -{{/info}} 199 -))) 200 -1. ((( 201 201 Use something like the following code to save the model from above: 202 202 203 203 {{code language="java"}} ... ... @@ -204,10 +204,10 @@ 204 204 // Create a resource set. 205 205 ResourceSet resourceSet = new ResourceSetImpl(); 206 206 207 -// Register the resource factory -- only needed for stand-alone! 208 - SctStandaloneSetup.doSetup();209 - 210 - 204 +// Register the default resource factory -- only needed for stand-alone! 205 +// this tells EMF to use XML to save the model 206 +resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put( 207 + Resource.Factory.Registry.DEFAULT_EXTENSION, new SCTResourceFactoryImpl()); 211 211 // Get the URI of the model file. 212 212 URI fileURI = URI.createFileURI(new File("myABO.sct").getAbsolutePath()); 213 213 ... ... @@ -225,172 +225,18 @@ 225 225 /* error handling */ 226 226 } 227 227 {{/code}} 228 - 229 -{{info title="File Extensions"}} 230 -File extensions are important! They define the parser/serializer that EMF uses. Always use the file extension that is defined for a particular model. 231 -{{/info}} 232 232 ))) 233 -{{/layout-cell}} 234 -{{/layout-section}} 235 235 236 -{{layout-section ac:type="two_right_sidebar"}} 237 -{{layout-cell}} 238 238 ==== Model Creation Task ==== 239 239 240 - Youare now equippedwiththefundamentalsyouneedtocreatemodelsprogrammatically. Let's try it:229 +With these information out of the way, on we go to some model creation: 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.) 247 - 248 -{{note title="Kext Warning"}} 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 -{{/note}} 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. 231 +1. Programmatically create a valid model of ABO in the {{code language="none"}}main(){{/code}} method. 232 +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. 233 +1. Execute the main method. 234 +1. Inspect your SCT file. 253 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. 259 259 260 - 261 -{{/layout-cell}} 262 - 263 -{{layout-cell}} 264 -{{code language="java" title="Root.sct"}} 265 -scchart Root { 266 - initial state Init 267 - --> Init with true; 268 -} 269 -{{/code}} 270 - 271 -[[image:attach:RunConfiguration.png]] 272 -{{/layout-cell}} 273 -{{/layout-section}} 274 - 275 -{{layout-section ac:type="two_right_sidebar"}} 276 -{{layout-cell}} 277 -= Model-to-Model Transformation with KiCo = 278 - 279 -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 - 281 -== Creating a new Transformation == 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. :) 284 - 285 - 286 - 287 -Transformation Creation Task 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//. 294 -1. ((( 295 -Now, you should have a class similar to the following one. 296 - 297 -{{code language="java"}} 298 -package tutorial.transformation 299 - 300 -import de.cau.cs.kieler.kico.transformation.AbstractProductionTransformation 301 - 302 -class DoubleStates extends AbstractProductionTransformation { 303 - 304 - override getProducedFeatureId() { 305 - throw new UnsupportedOperationException("TODO: auto-generated method stub") 306 - } 307 - 308 - override getId() { 309 - throw new UnsupportedOperationException("TODO: auto-generated method stub") 310 - } 311 - 312 -} 313 -{{/code}} 314 -))) 315 -1. ((( 316 -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**. 317 - 318 -{{info title="Programming Guidelines"}} 319 -You should really think about some constants here. You can also look at the sccharts transformation and features constants in the sccharts plugin. 320 -{{/info}} 321 -))) 322 -1. KiCo must know about the new feature and also about your new transformation. 323 -11. Add a new Xtend class with Feature as superclass. Add all unimplemented methods. Also set sccharts.doubleStates as Id. 324 -11. Go to the Extension tab inside your plugin configuration. 325 -111. Add a new Extension Point de.cau.cs.kieler.kico.feature. Create a new featureClass and point it to your new feature class. 326 -111. Also add a new Extension Point de.cau.cs.kieler.kico.transformation. Create a new productionTransformationClass and point it to your transformation class. 327 -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: 328 -1111. editor: de.cau.cs.kieler.sccharts.text.sct.Sct 329 -1111. features: sccharts.doubleStates 330 -1111. label: Tutorial Compilation 331 -1111. priority: 101 332 -1111. preferred: (leave it blank) 333 -11. 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. 334 -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. 335 - 336 - 337 -{{/layout-cell}} 338 - 339 -{{layout-cell}} 340 -[[image:attach:KielerSCTEditor.png]] 341 - 342 - 343 - 344 - 345 - 346 - 347 - 348 - 349 - 350 - 351 - 352 - 353 - 354 - 355 - 356 - 357 - 358 - 359 - 360 - 361 - 362 - 363 - 364 - 365 - 366 - 367 - 368 - 369 - 370 - 371 - 372 - 373 - 374 - 375 - 376 - 377 - 378 - 379 - 380 - 381 - 382 - 383 - 384 - 385 - 386 - 387 - 388 -[[image:attach:KielerSCTEditorOwnTransformation.png]] 389 -{{/layout-cell}} 390 -{{/layout-section}} 391 - 392 -{{layout-section ac:type="single"}} 393 -{{layout-cell}} 394 394 = Transforming SCCharts = 395 395 396 396 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.
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -168103 681 +16810301 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/TUT/pages/168103 68/SCCharts Development1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/TUT/pages/16810301/SCCharts Development