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 meu 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::java – Generator ID for the Java code generator
  • yakindu::c – Generator ID for the C code generator
  • yakindu::cpp – Generator ID for the C++ code generator
  • yakindu::generic – Generator ID for custom Java-based code generators
  • sctunit::c – Generator ID for SCTUnit/C code 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.