tasks.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <?xml version='1.0' encoding='utf-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  5. <title>tasks</title>
  6. <link type="text/css" rel="stylesheet" href="../style.css"/>
  7. </head>
  8. <body>
  9. <h1 id="Tasks">Tasks</h1>
  10. <h2 id="Modelingastatemachine">Modeling a statemachine</h2>
  11. <ol>
  12. <li>Make sure the YAKINDU Modeling perspective is active.</li>
  13. <li>Create a new project.</li>
  14. <li>Click
  15. <strong>File</strong> &gt;
  16. <strong>New</strong> &gt;
  17. <strong>Other...</strong> &gt;
  18. <strong>YAKINDU</strong> &gt;
  19. <strong>YAKINDU Statechart Model</strong>.
  20. </li>
  21. <li>Click
  22. <strong>Next</strong> name the sct file and click
  23. <strong>Finish</strong>
  24. </li>
  25. <li>The YAKINDU statechart editor opens on the statechart model. It already has an initial state and an unnamed simple state connected by a transition.</li>
  26. <li>Now you can add states and transitions from the palette.</li>
  27. </ol>
  28. <p>To edit the states and transitions you can use the properties view. It has an integrated Xtext support. This makes correct editing easier. You can also change the appearance of the model elements. </p>
  29. <p>On the palette you will also find a composite submachine state. This is a state that contains a complete statemachine. You can choose an existing statemachine or create a new one.</p>
  30. <h3 id="Relatedtopics">Related topics</h3>
  31. <p>
  32. <a href="../05_Reference/reference.html#Statechartelements">Statemachine Elements reference</a>
  33. <br/>
  34. <a href="../05_Reference/reference.html#Statechartdescriptionlanguage">Textual modeling lanuage Reference</a>
  35. </p>
  36. <h2 id="Validatingastatemachine">Validating a statemachine</h2>
  37. <p>The statemachine is validated automatically during build. The elements that cause problems get error markers. You can find the details about the problems on the problems view.</p>
  38. <h2 id="Simulatingastatemachine">Simulating a statemachine</h2>
  39. <p>The YAKINDU simulation engine supports simulation modes:</p>
  40. <ul>
  41. <li>event driven</li>
  42. <li>cycle based</li>
  43. </ul>
  44. <p>The default setting is
  45. <em>cycle based</em> with a cycle period of 200 ms. In this mode the simulation engine processes the state machine transitions in steps of the given cycle duration. The following statechart illustrates this. It is simulated cycle based with a cycle period of 3 seconds.
  46. </p>
  47. <p>
  48. <img border="0" src="images/cycleBasedVsEventDriven.png"/>
  49. </p>
  50. <p>What happend during simulation is the following:</p>
  51. <ol>
  52. <li>After 3s
  53. <strong>init</strong> switches to
  54. <strong>pre1</strong>
  55. </li>
  56. <li>After 3 further seconds recursive transition to
  57. <strong>pre1</strong> is processed (not after 2s the transition says)
  58. </li>
  59. <li>After 3 further seconds recursive transition to
  60. <strong>pre1</strong> is processed again and the condition becomes
  61. <strong>true</strong> so
  62. <strong>result</strong> gets activated
  63. </li>
  64. </ol>
  65. <p>In contrast to cycle based the event driven simulation mode concentrates on the events of a state machine. The same state machine above could be simulated as follows:</p>
  66. <ol>
  67. <li>Immediately
  68. <strong>init</strong> switches to
  69. <strong>pre1</strong>
  70. </li>
  71. <li>Immediately the event
  72. <strong>touch</strong> is raised twice
  73. </li>
  74. <li>The condition becomes true so that the
  75. <strong>result</strong> state is reached after 2 or 3 seconds instead of 9
  76. </li>
  77. </ol>
  78. <p>Start a simulation with the different modes as follows</p>
  79. <ol>
  80. <li>Make sure the YAKINDU Simulation Perspectiv is opened.</li>
  81. <li>Start the simulation by clicking
  82. <strong>Run</strong> &gt;
  83. <strong>Run Configurations...</strong>.
  84. </li>
  85. <li>Select the statechart you want to simulate and the simulation mode.</li>
  86. <li>
  87. <strong>Apply</strong> the setting and
  88. <strong>Run</strong> the simulation.
  89. </li>
  90. </ol>
  91. <p>
  92. <img border="0" src="images/simulationRunConfiguration.png"/>
  93. </p>
  94. <p>
  95. <a href="../03_Concepts/concepts.html#Simulation">Simulation Concept</a>
  96. <br/>
  97. <a href="../03_Concepts/concepts.html#YakinduSCSimulationperspective">Simulation perspective</a>
  98. <br/>
  99. <a href="../03_Concepts/concepts.html#SimulationView">Simulation View</a>
  100. </p>
  101. <h2 id="GeneratingCode">Generating Code</h2>
  102. <p>For configuring the code generation process, YAKINDU Statechart Tools uses a textual generator model called
  103. <strong>SGen</strong>. It can be created either by using the provided wizard
  104. <strong>Yakindu Statechart Generator Model</strong> or by creating a new text file with the file extension &#8218;.sgen&#8217;.
  105. <br/>To create a generator model with the wizard,
  106. </p>
  107. <ol>
  108. <li>Click
  109. <strong>File</strong> &gt;
  110. <strong>New</strong> &gt;
  111. <strong>Other...</strong> &gt;
  112. <strong>Yakindu Statechart Generator Model</strong>
  113. </li>
  114. <li>Type a name and click
  115. <strong>Next</strong>
  116. </li>
  117. <li>Choose the desired generator, i.e.
  118. <strong>YAKINDU Java Code Generator</strong>
  119. </li>
  120. <li>Check the model(s) to generate code from and click
  121. <strong>Finish</strong>
  122. </li>
  123. </ol>
  124. <p>
  125. <img border="0" src="images/genmodelwizardchooselanguage.jpg"/>
  126. </p>
  127. <p>The result is an .sgen file of the following format: </p>
  128. <pre><code>GeneratorModel for [GeneratorId] {
  129. statechart [StatechartReference] {
  130. feature [Feature] {
  131. [ParameterName] = [ParameterValue]
  132. }
  133. }
  134. }
  135. </code></pre>
  136. <p>The [GeneratorId] is the unique id of the Generator. Currently, the following Generators are supported out of the box:</p>
  137. <ol>
  138. <li>yakindu::java &#8211; Generator ID for the Java Code Generator </li>
  139. <li>yakindu::c &#8211; Generator ID for the C Code Generator</li>
  140. <li>yakindu::cpp &#8211; Generator ID for the C++ Code Generator</li>
  141. <li>yakindu::xpand &#8211; Generator ID for custom Xpand based Code Generators</li>
  142. <li>yakindu::generic &#8211; Generator ID for custom Java based Code Generators </li>
  143. </ol>
  144. <p>One GeneratorModel can contain several [StatechartReference]s. These are cross references to statechart models for which the code should be generated. For each reference, the generator process can be configured with [Feature]s. Each Feature consists of several parameters. These parameters can be configured with [ParameterName] = [ParameterValue].</p>
  145. <p>The Generator Model is executed by a builder. Thus, the artifacts are generated automatically if
  146. <strong>Project</strong> &gt;
  147. <strong>Build Automatically</strong> is checked. If you want to execute your Generator Model by hand, select
  148. <strong>Generate Statechart Artifacts</strong> from the
  149. <strong>Package Explorer&#8217;s</strong> context menu.
  150. </p>
  151. <h2 id="CoreFeatures">Core Features</h2>
  152. <p>The following section describes the
  153. <strong>Core Features</strong> which are available for all code generators:
  154. </p>
  155. <p><!-- Start sgen_feature_outlet --></p>
  156. <h4 id="Outlet">Outlet</h4>
  157. <p>The
  158. <strong>Outlet</strong> feature specifies the target project and folder for the generated artifacts. It is a
  159. <strong>required</strong> feature and consists of the following parameters:
  160. </p>
  161. <ol>
  162. <li>
  163. <i>targetProject</i> (String, required): The project to store the generated artifacts
  164. </li>
  165. <li>
  166. <i>targetFolder</i> (String, required): The folder to store the generated artifacts
  167. </li>
  168. </ol>
  169. <p>Example configuration:</p>
  170. <pre><code>feature Outlet {
  171. targetProject = "ExampleProject"
  172. targetFolder = "src-gen"
  173. }
  174. </code></pre>
  175. <p><!-- End sgen_feature_outlet -->
  176. <br/><!-- Start sgen_feature_licenseheader -->
  177. </p>
  178. <h4 id="LicenseHeader">LicenseHeader</h4>
  179. <p>The
  180. <strong>LicenseHeader</strong> feature specifies the license text that should be added as a header to the generated artifacts. It is an
  181. <strong>optional</strong> feature and consists of the following parameters:
  182. </p>
  183. <ol>
  184. <li>
  185. <i>licenseText</i> (String, required): The license text to add as a header
  186. </li>
  187. </ol>
  188. <p>Example configuration:</p>
  189. <pre><code>feature LicenseHeader {
  190. licenseText = "Copyright (c) 2012 committers of YAKINDU and others."
  191. }
  192. </code></pre>
  193. <p><!-- End sgen_feature_licenseheader -->
  194. <br/><!-- Start sgen_feature_functioninlining -->
  195. </p>
  196. <h4 id="FunctionInlining">FunctionInlining</h4>
  197. <p>The
  198. <strong>FunctionInlining</strong> feature allows the inlining of expressions instead of generating separate functions or methods. This might reduce the readability of the generated code, but increases performance because less operation calls are necessary.
  199. <br/>It is an
  200. <strong>optinal</strong> feature and consists of the following parameters:
  201. </p>
  202. <ol>
  203. <li>
  204. <i>inlineReactions</i> (Boolean, optional): Inlines the expression for reactions
  205. </li>
  206. <li>
  207. <i>inlineEntryActions</i> (Boolean, optional): Inlines the expression for entry actions
  208. </li>
  209. <li>
  210. <i>inlineExitActions</i> (Boolean, optional): Inlines the expression for exit actions
  211. </li>
  212. <li>
  213. <i>inlineEnterSequences</i> (Boolean, optional): Inlines the expression for enter sequences
  214. </li>
  215. <li>
  216. <i>inlineExitSequences</i> (Boolean, optional): Inlines the expression for exit sequences
  217. </li>
  218. <li>
  219. <i>inlineChoices</i> (Boolean, optional): Inlines the expression for choices
  220. </li>
  221. <li>
  222. <i>inlineEnterRegion</i> (Boolean, optional): Inlines the expression for enter regions
  223. </li>
  224. <li>
  225. <i>inlineExitRegion</i> (Boolean, optional): Inlines the expression for exit regions
  226. </li>
  227. <li>
  228. <i>inlineEntries</i> (Boolean, optional): Inlines the expression for entries
  229. </li>
  230. </ol>
  231. <p>Example configuration:</p>
  232. <pre><code>feature FunctionInlining {
  233. inlineChoices = false
  234. inlineEnterRegion = true
  235. inlineEntries = true
  236. }
  237. </code></pre>
  238. <p><!-- End sgen_feature_functioninlining -->
  239. <br/><!-- Start sgen_feature_debug -->
  240. </p>
  241. <h4 id="Debug">Debug</h4>
  242. <p>The
  243. <strong>Debug</strong> feature dumps the Execution Model to the target folder as xmi model. It is an
  244. <strong>optional</strong> feature and consists of the following parameters:
  245. </p>
  246. <ol>
  247. <li>
  248. <i>dumpSexec</i> (Boolean, required): The license text to add as a header
  249. </li>
  250. </ol>
  251. <p>Example configuration:</p>
  252. <pre><code>feature Debug {
  253. dumpSexec = true
  254. }
  255. </code></pre>
  256. <p><!-- End sgen_feature_debug --></p>
  257. <h2 id="JavaGeneratorFeatures">Java Generator Features</h2>
  258. <p><!-- Start sgen_feature_naming --></p>
  259. <h4 id="Naming">Naming</h4>
  260. <p>The
  261. <strong>Naming</strong> feature allows the configuration of package names as well as class name prefix / suffix.
  262. <br/>It is an
  263. <strong>optional</strong> feature and consists of the following parameters:
  264. </p>
  265. <ol>
  266. <li>
  267. <i>basePackage</i> (Boolean, required): The package to create for the generated java classes
  268. </li>
  269. <li>
  270. <i>implementationSuffix</i> (Boolean, optional): The suffix for the implementing classes
  271. </li>
  272. </ol>
  273. <p>Example configuration:</p>
  274. <pre><code>feature Naming {
  275. basePackage = "org.yakindu.sct"
  276. implementationSuffix = "Impl"
  277. }
  278. </code></pre>
  279. <p><!-- End sgen_feature_naming -->
  280. <br/><!-- Start sgen_feature_generalfeatures -->
  281. </p>
  282. <h4 id="GeneralFeatures">GeneralFeatures</h4>
  283. <p>The
  284. <strong>GeneralFeatures</strong> feature allows to configure additional services to generate with the statemachine. Per default, all parameters are configured to
  285. <i>false</i> It is an
  286. <strong>optional</strong> feature and consists of the following parameters:
  287. </p>
  288. <ol>
  289. <li>
  290. <i>EventBasedStatemachine</i> (Boolean, optional): Enables/disables the generation of a cycle based statemachine implementation
  291. </li>
  292. <li>
  293. <i>InterfaceObserverSupport</i> (Boolean, optional): Enables/disables the generation of listener interfaces for the statemachine
  294. </li>
  295. <li>
  296. <i>RuntimeService</i> (Boolean, optional): Enables/disables the generation of a runtime service that triggers the runcycle of a cycle based statemachine
  297. </li>
  298. <li>
  299. <i>TimerService</i> (Boolean, optional): Enables/disables the generation of a timer service implementation using
  300. <i>java.util.Timer</i>
  301. </li>
  302. <li>
  303. <i>GenericInterfaceSupport</i> (Boolean, optional): Enables/disables the generation of generic interfaces
  304. </li>
  305. <li>
  306. <i>StatemachineFactorySupport</i> (Boolean, optional): Enables/disables the generation of a factory class
  307. </li>
  308. </ol>
  309. <p>Example configuration:</p>
  310. <pre><code>feature GeneralFeatures {
  311. EventBasedStatemachine = true
  312. InterfaceObserverSupport = true
  313. RuntimeService = true
  314. TimerService = true
  315. GenericInterfaceSupport = true
  316. StatemachineFactorySupport = true
  317. }
  318. </code></pre>
  319. <p><!-- End sgen_feature_generalfeatures --> </p>
  320. <h2 id="CGeneratorFeatures">C Generator Features</h2>
  321. <p><!-- Start sgen_feature_ccodefeature --> </p>
  322. <h4 id="CCodeFeature">CCodeFeature</h4>
  323. <p>The
  324. <strong>CCodeFeature</strong> feature allows to configure c code specific generator properties. It is an
  325. <strong>optional</strong> feature and consists of the following parameters:
  326. </p>
  327. <ol>
  328. <li>
  329. <i>InterfaceEventListener</i> (Boolean, mandatory): generates listener interface for notification of outgoing events.
  330. </li>
  331. <li>
  332. <i>Singleton</i> (Boolean, mandatory): generates a statically allocated singleton variant of the state machine that does not allow multiple instances.
  333. </li>
  334. <li>
  335. <i>DebugType</i> (String, optional): don&#8217;t use this property &#8211; it will be removed
  336. </li>
  337. </ol>
  338. <p>Example configuration:</p>
  339. <pre><code>feature CCodeFeature {
  340. InterfaceEventListerner = true
  341. Singleton = true
  342. }
  343. </code></pre>
  344. <p><!-- End sgen_feature_ccodefeature --> </p>
  345. <h2 id="CreateCustomCodeGenerators">Create Custom Code Generators</h2>
  346. <p>YAKINDU Statechart Tools provides a rich feature set to supports custom code generators out of the box. These code generators can be either written in Java,
  347. <a href="http://www.eclipse.org/xtend/">Xtend</a> or in
  348. <a href="http://www.eclipse.org/modeling/m2t/?project=xpand">Xpand</a>
  349. </p>
  350. <h3 id="WritingacustomcodegeneratorwithXtend2Java">Writing a custom code generator with Xtend2/Java</h3>
  351. <p>First, you have to create a new Xtend2 generator project. Click
  352. <strong>File</strong> &gt;
  353. <strong>New</strong> &gt;
  354. <strong>Other...</strong> &gt;
  355. <strong>YAKINDU</strong> &gt;
  356. <strong>YAKINDU Xtend2/Java Generator Project</strong> to create a new Xtend2 Generator Project.
  357. </p>
  358. <p>
  359. <img border="0" src="images/xtendGenerator.png"/>
  360. </p>
  361. <p>The wizards asks for a
  362. <strong>Project name</strong> and the name of the
  363. <strong>Generator class</strong>, where you have to specify a full qualified class name. If you check the
  364. <strong>Use Xtend</strong> checkbox, the Generator class will be initially created as an
  365. <a href="http://www.eclipse.org/xtend/">Xtend</a> class. Otherwise, Java will be used for the generator.
  366. </p>
  367. <p>The check box
  368. <strong>Configure for Plugin Export</strong> adds all required extension point registrations to the new project for exporting as a plugin The Generator Model can refer to the new Generator Plugin via its unique
  369. <strong>Generator ID</strong>. If you want to contribute custom generator features for your code generator, check the
  370. <strong>Create Feature Library</strong> check box.
  371. </p>
  372. <p>After click on
  373. <strong>Finish</strong> a new project is created in your workspace. All required plugin dependencies and extension points are registered and you can start to write your code generator based on the ExecutionFlow meta model [Link].
  374. </p>
  375. <h3 id="ExecutingacustomXtend2Javacodegenerator">Executing a custom Xtend2/Java code generator</h3>
  376. <p>YAKINDU Statechart Tools provide a convenient way to execute your generator while you are developing it.
  377. <br/>Therefore, you have to create a new
  378. <strong>Generator Model</strong> with the generator id
  379. <strong>yakindu::generic</strong>, either by using the
  380. <strong>New Statechart Generator Model</strong> wizard or by simple creating a new text file with the file extension
  381. <strong>.sgen</strong>. the following feature allows to configure your code generator.
  382. </p>
  383. <p><!-- Start sgen_feature_generator --></p>
  384. <h4 id="Generator">Generator</h4>
  385. <p>The
  386. <strong>Generator</strong> feature allows the configuration of a custom code generator located in the workspace and written in Java or another JVM language. It is a
  387. <strong>required</strong> feature and consists of the following parameters:
  388. </p>
  389. <ol>
  390. <li>
  391. <i>generatorProject</i> (String, required): The name of the generator project
  392. </li>
  393. <li>
  394. <i>generatorClass</i> (String, required): The full qualified class name of the code generator class.
  395. </li>
  396. <li>
  397. <i>configurationModule</i> (String, optional): The full qualified class name for a guice module to configure the code generator
  398. </li>
  399. </ol>
  400. <p>Example configuration:</p>
  401. <pre><code>feature Generator {
  402. generatorProject = "org.yakindu.sct.mygenerator"
  403. generatorClass = "org.yakindu.sct.MyGenerator"
  404. }
  405. </code></pre>
  406. <p><!-- End sgen_feature_generator --></p>
  407. <h3 id="ExecutingacustomXpandcodegenerator">Executing a custom Xpand code generator</h3>
  408. <p>to execute an xpand based custom code generator, you have to create a new
  409. <strong>Generator Model</strong> with the generator id
  410. <strong>yakindu::xpand</strong>, either by using the
  411. <strong>New Statechart Generator Model</strong> wizard or by simple creating a new text file with the file extension
  412. <strong>.sgen</strong>. the following feature allows to configure your code generator.
  413. </p>
  414. <p><!-- Start sgen_feature_template --></p>
  415. <h4 id="Template">Template</h4>
  416. <p>The
  417. <strong>Generator</strong> feature allows the configuration of a custom code generator located in the workspace and written in Java or another JVM language. It is a
  418. <strong>required</strong> feature and consists of the following parameters:
  419. </p>
  420. <ol>
  421. <li>
  422. <i>templateProject</i> (String, required): The name of the generator project
  423. </li>
  424. <li>
  425. <i>templatePath</i> (String, required): The full qualified template path to the main template.
  426. </li>
  427. </ol>
  428. <p>Example configuration:</p>
  429. <pre><code>feature Template {
  430. templateProject = "ExampleProject"
  431. templatePath = "org::yakindu::sct::generator::xpand::Main::main"
  432. }
  433. </code></pre>
  434. <p><!-- End sgen_feature_template --></p>
  435. </body>
  436. </html>