12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?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">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <title>tasks</title>
- <link type="text/css" rel="stylesheet" href="../style.css"/>
- </head>
- <body>
- <p><link href="../../css/bootstrap.css" rel="stylesheet" />
- <br/><link href="../../css/custom.css" rel="stylesheet" />
- </p>
- <h1 id="Tasks">Tasks</h1>
- <h2 id="SimulatingOperationsWithCustomJavaCode">Simulating Operations With Custom Java Code</h2>
- <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.
- <br/>For that to work, it is required to provide one or more custom java classes having a method with a matching signature.
- </p>
- <p>
- <img border="0" src="images/operationsExample.png"/>
- </p>
- <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
- <br/>statecharts project.
- </p>
- <pre><code>package example;
- public class Calculator {
- public int add(int param1, int param2) {
- return param1 + param2;
- }
- }
- </code></pre>
- <p>This custom class can be passed to the run configuration as
- <strong>Operation Class</strong>, shown in the figure below. It is possible to pass multiple java classes seperated by a comma.
- <br/>If the simulation is executed, the variable result gets the value 2.
- </p>
- <p>
- <img border="0" src="images/runConfiguration.png"/>
- </p>
- <h2 id="GeneratingCode">Generating Code</h2>
- <p>For configuring the code generation process, YAKINDU Statechart Tools uses a textual generator model called
- <strong>SGen</strong>. It can be created either by using the provided wizard
- <strong>Yakindu Statechart Generator Model</strong> or by creating a new text file with the file extension ‚.sgen’.
- <br/>To create a generator model with the wizard,
- </p>
- <ol>
- <li>Click
- <strong>File</strong> >
- <strong>New</strong> >
- <strong>Other...</strong> >
- <strong>Yakindu Statechart Generator Model</strong>
- </li>
- <li>Type a name and click
- <strong>Next</strong>
- </li>
- <li>Choose the desired generator, i.e.
- <strong>YAKINDU Java Code Generator</strong>
- </li>
- <li>Check the model(s) to generate code from and click
- <strong>Finish</strong>
- </li>
- </ol>
- <p>
- <img border="0" src="images/genmodelwizardchooselanguage.jpg"/>
- </p>
- <p>The result is an .sgen file of the following format: </p>
- <pre><code>GeneratorModel for [GeneratorId] {
- statechart [StatechartReference] {
- feature [Feature] {
- [ParameterName] = [ParameterValue]
- }
- }
- }
- </code></pre>
- <p>The [GeneratorId] is the unique id of the Generator. Currently, the following Generators are supported out of the box:</p>
- <ol>
- <li>yakindu::java – Generator ID for the Java Code Generator </li>
- <li>yakindu::c – Generator ID for the C Code Generator</li>
- <li>yakindu::cpp – Generator ID for the C++ Code Generator</li>
- <li>yakindu::xpand – Generator ID for custom Xpand based Code Generators</li>
- <li>yakindu::generic – Generator ID for custom Java based Code Generators </li>
- </ol>
- <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>
- <p>The Generator Model is executed by a builder. Thus, the artifacts are generated automatically if
- <strong>Project</strong> >
- <strong>Build Automatically</strong> is checked. If you want to execute your Generator Model by hand, select
- <strong>Generate Statechart Artifacts</strong> from the
- <strong>Package Explorer’s</strong> context menu.
- </p>
- </body>
- </html>
|