Setting up a code generator project

In order to deploy a code generator and actually generate code, you have to set up a code generator project. This is described in the following subsections.

For configuring the code generation process, YAKINDU Statechart Tools uses a textual generator model called SGen. It can be created either by using the YAKINDU Statechart generator model wizard or by creating a text file with the filename extension .sgen.

To create a generator model using the wizard, proceed as follows:

  1. In the project explorer view, right-click on your project. The context menu opens.
  2. In the context menu, select New → Code generator model.
  3. The New YAKINDU SGen model wizard opens.
  4. Select an appropriate folder and specify the filename of your SGen model. The filename must have the extension .sgen.
  5. Click on Next >.
  6. From the Generator drop-down menu, choose the code generator you want to use, e.g., YAKINDU SCT Java code generator.
  7. Check the statechart(s) to generate code from.
  8. Click on Finish.

Selecting code generator and statecharts

Selecting code generator and statecharts

The result is the specified .sgen file. It has the following format:

GeneratorModel for [GeneratorId] {
	statechart [StatechartReference] {
		feature [Feature] {
			[ParameterName] = [ParameterValue]
		}
	}
}

The [GeneratorId] represents the unique ID of the chosen generator. Currently, YAKINDU Statechart Tools supports the following code generators out of the box:

  • yakindu::c – Generator ID for the C code generator
  • yakindu::cpp – Generator ID for the C++ code generator
  • yakindu::python – Generator ID for the Python code generator
  • yakindu::java – Generator ID for the Java code generator
  • yakindu::scxml – Generator ID for the SCXML code generator
  • yakindu::images – Generator ID for the statechart image generator

A single generator model may contain multiple statechart … { … } blocks and thus specify the code generation for multiple statecharts. For each statechart, the generator process can be configured with Features. Each feature has one or more parameters. These parameters can be configured with ParameterName = ParameterValue.

Besides generating code from a statechart model, it is also possible to generate code from a test file written in the SCTUnit language. The SCTUnit code generators translate SCTUnit tests into a unit test framework of the target langauge. The following generators are available:

* sctunit::c – Generator ID for the SCTUnit C code generator
* sctunit::cpp – Generator ID for the SCTUnit C++ code generator
* sctunit::python – Generator ID for the SCTUnit Python code generator
* sctunit::java – Generator ID for the SCTUnit Java code generator
* sctunit::scxml::qt – Generator ID for the SCTUnit SCXML Qt code generator

See also chapter Generating SCTUnit source code for more information.