Skip to content

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, itemis CREATE uses a textual generator model called SGen. It can be created either by using the itemis CREATE 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 itemis CREATE 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., CREATE Statechart 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, itemis CREATE supports the following code generators out of the box:

  • create::c – Generator ID for the C code generator
  • create::cpp – Generator ID for the C++ code generator
  • create::python – Generator ID for the Python code generator
  • create::java – Generator ID for the Java code generator
  • create::scxml – Generator ID for the SCXML code generator
  • create::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:

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

See also chapter Generating SCTUnit source code for more information.