tasks.html 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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="SimulatingOperationsWithCustomJavaCode">Simulating Operations With Custom Java Code</h2>
  11. <p>To simulate a model with operations it is possible to use custom Java code that mocks the desired behavior or even to simulate against an existing java backend.
  12. <br/>For that to work, it is required to provide one or more custom java classes having a method with a matching signature.
  13. </p>
  14. <p>
  15. <img border="0" src="images/operationsExample.png"/>
  16. </p>
  17. <p>To simulate the statechart above, a new Java Class must be created matching the method signature defined in the statechart. This class must be placed onto the classpath of the
  18. <br/>statecharts project.
  19. </p>
  20. <pre class="prettyprint"><code>package example;
  21. public class Calculator {
  22. public int add(int param1, int param2) {
  23. return param1 + param2;
  24. }
  25. }
  26. </code></pre>
  27. <p>This custom class can be passed to the run configuration as
  28. <strong>Operation Class</strong>, shown in the figure below. It is possible to pass multiple java classes seperated by a comma.
  29. <br/>If the simulation is executed, the variable result gets the value 2.
  30. </p>
  31. <p>
  32. <img border="0" src="images/runConfiguration.png"/>
  33. </p>
  34. <h2 id="GeneratingCode">Generating Code</h2>
  35. <p>For configuring the code generation process, YAKINDU Statechart Tools uses a textual generator model called
  36. <strong>SGen</strong>. It can be created either by using the provided wizard
  37. <strong>Yakindu Statechart Generator Model</strong> or by creating a new text file with the file extension &#8218;.sgen&#8217;.
  38. <br/>To create a generator model with the wizard,
  39. </p>
  40. <ol>
  41. <li>Click
  42. <strong>File</strong> &gt;
  43. <strong>New</strong> &gt;
  44. <strong>Other...</strong> &gt;
  45. <strong>Yakindu Statechart Generator Model</strong>
  46. </li>
  47. <li>Type a name and click
  48. <strong>Next</strong>
  49. </li>
  50. <li>Choose the desired generator, i.e.
  51. <strong>YAKINDU Java Code Generator</strong>
  52. </li>
  53. <li>Check the model(s) to generate code from and click
  54. <strong>Finish</strong>
  55. </li>
  56. </ol>
  57. <p>
  58. <img border="0" src="images/genmodelwizardchooselanguage.jpg"/>
  59. </p>
  60. <p>The result is an .sgen file of the following format: </p>
  61. <pre class="prettyprint"><code>GeneratorModel for [GeneratorId] {
  62. statechart [StatechartReference] {
  63. feature [Feature] {
  64. [ParameterName] = [ParameterValue]
  65. }
  66. }
  67. }
  68. </code></pre>
  69. <p>The [GeneratorId] is the unique id of the Generator. Currently, the following Generators are supported out of the box:</p>
  70. <ol>
  71. <li>yakindu::java &#8211; Generator ID for the Java Code Generator </li>
  72. <li>yakindu::c &#8211; Generator ID for the C Code Generator</li>
  73. <li>yakindu::xpand &#8211; Generator ID for custom Xpand based Code Generators</li>
  74. <li>yakindu::generic &#8211; Generator ID for custom Java based Code Generators </li>
  75. </ol>
  76. <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>
  77. <p>The Generator Model is executed by a builder. Thus, the artifacts are generated automatically if
  78. <strong>Project</strong> &gt;
  79. <strong>Build Automatically</strong> is checked. If you want to execute your Generator Model by hand, select
  80. <strong>Generate Statechart Artifacts</strong> from the
  81. <strong>Package Explorer&#8217;s</strong> context menu.
  82. </p>
  83. </body>
  84. </html>