tasks.html 4.1 KB

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