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
-
... ... @@ -120,7 +120,7 @@ 120 120 121 121 122 122 {{info title="KLighD Screenshots"}} 123 -By the way: You can //right-click// on the Diagram View surface toselect //Save as image...// to create a screenshot!123 +By the way: You can //right-click// on the Diagram View surface and select //Save as image...// to create a screenshot! 124 124 {{/info}} 125 125 {{/layout-cell}} 126 126 ... ... @@ -135,18 +135,6 @@ 135 135 136 136 {{layout-section ac:type="single"}} 137 137 {{layout-cell}} 138 - 139 -{{/layout-cell}} 140 -{{/layout-section}} 141 - 142 -{{layout-section ac:type="single"}} 143 -{{layout-cell}} 144 - 145 -{{/layout-cell}} 146 -{{/layout-section}} 147 - 148 -{{layout-section ac:type="single"}} 149 -{{layout-cell}} 150 150 = Creating SCCharts Models Programmatically = 151 151 152 152 == Creating a Test Project == ... ... @@ -153,6 +153,7 @@ 153 153 154 154 We need a project for testing. Do the following: 155 155 144 +1. If you used the standard KIELER Oomph installation setup, create a new Working Set named Tutorial in the Package Explorer. Then... 156 156 1. Create a new empty //Plug-In Project//. 157 157 1. Add the project that contains the sccharts metamodel as a dependency of your new project through the //Plugin Manifest Editor//. 158 158 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. ... ... @@ -159,12 +159,12 @@ 159 159 160 160 == Creating a Model == 161 161 162 -To create a model 151 +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: 163 163 164 164 {{code language="java"}} 165 165 SCChartsFactory sccFactory = SCChartsFactory.eINSTANCE; 166 -State state = sccFactory 167 -Transition transition = sccFactory 155 +State state = sccFactory.createState(); 156 +Transition transition = sccFactory.createTransition(); 168 168 {{/code}} 169 169 170 170 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. ... ... @@ -171,13 +171,13 @@ 171 171 172 172 {{code language="java"}} 173 173 KExpressionsFactory kFactory = KExpressionsFactory.eINSTANCE; 174 -Bool eanValue boolValue = kFactory.createBooleanValue();163 +BoolValue boolValue = kFactory.createBoolValue(); 175 175 {{/code}} 176 176 177 177 For all simple attributes, there are getter and setter methods: 178 178 179 179 {{code language="java"}} 180 -state.setId(" Root");169 +state.setId("Init"); 181 181 boolValue.setValue(true); 182 182 {{/code}} 183 183 ... ... @@ -190,15 +190,25 @@ 190 190 List references (multiplicity of > 1) have only a list getter, which is used to manipulate the list: 191 191 192 192 {{code language="java"}} 193 -state. outgoingTransitions.add(transition);182 +state.getOutgoingTransitions().add(transition); 194 194 {{/code}} 195 195 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 + 196 196 == Saving a Model == 197 197 198 198 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: 199 199 200 -1. Add a dependency to the {{code language="none"}}org.eclipse.emf.ecore.xmi{{/code}} plug-in. 201 201 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. ((( 202 202 Use something like the following code to save the model from above: 203 203 204 204 {{code language="java"}} ... ... @@ -205,10 +205,10 @@ 205 205 // Create a resource set. 206 206 ResourceSet resourceSet = new ResourceSetImpl(); 207 207 208 -// Register the defaultresource factory -- only needed for stand-alone!209 - //thistells EMF touseXML to savehe model210 - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(211 - Resource.Factory.Registry.DEFAULT_EXTENSION, new SCTResourceFactoryImpl());207 +// Register the resource factory -- only needed for stand-alone! 208 +SctStandaloneSetup.doSetup(); 209 + 210 + 212 212 // Get the URI of the model file. 213 213 URI fileURI = URI.createFileURI(new File("myABO.sct").getAbsolutePath()); 214 214 ... ... @@ -227,17 +227,47 @@ 227 227 } 228 228 {{/code}} 229 229 ))) 229 +{{/layout-cell}} 230 +{{/layout-section}} 230 230 232 +{{layout-section ac:type="two_right_sidebar"}} 233 +{{layout-cell}} 231 231 ==== Model Creation Task ==== 232 232 233 - Withtheseinformationoutoftheway,onwegotosome modelcreation:236 +You are now equipped with the fundamentals you need to create models programmatically. Let's try it: 234 234 235 -1. Programmatically create a valid model of ABO in the {{code language="none"}}main(){{/code}} method. 236 -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. 237 -1. Execute the main method. 238 -1. Inspect your SCT file. 238 +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. 239 +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. 240 +11. Execute the main method. 241 +11. Inspect your SCT file. (Press F5 to refresh your file view.) 242 +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. 239 239 1. Start your SCChart Editor Eclipse instance and load your SCT file. KLighD should now be able to visualize your ABO correctly. 240 240 245 + 246 +{{/layout-cell}} 247 + 248 +{{layout-cell}} 249 +{{code language="java" title="Root.sct"}} 250 +scchart Root { 251 + initial state Init 252 + --> Init with true; 253 +} 254 +{{/code}} 255 +{{/layout-cell}} 256 +{{/layout-section}} 257 + 258 +{{layout-section ac:type="two_right_sidebar"}} 259 +{{layout-cell}} 260 + 261 +{{/layout-cell}} 262 + 263 +{{layout-cell}} 264 + 265 +{{/layout-cell}} 266 +{{/layout-section}} 267 + 268 +{{layout-section ac:type="single"}} 269 +{{layout-cell}} 241 241 = Transforming SCCharts = 242 242 243 243 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 121 +16810366 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/TUT/pages/168103 12/SCCharts Development1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/TUT/pages/16810366/SCCharts Development