<link href="../../css/bootstrap.css" rel="stylesheet" />
<link href="../../css/custom.css" rel="stylesheet" /> 

h1. Tasks

h2. Generating Code

For configuring the code generation process, YAKINDU Statechart Tools uses a textual generator model called *SGen*. It can be created either by using the provided wizard *Yakindu Statechart Generator Model* or by creating a new text file with the file extension '.sgen'.
To create a generator model with the wizard,

# Click *File* > *New* > *Other...* > *Yakindu Statechart Generator Model*
# Type a name and click *Next*
# Choose the desired generator, i.e. *YAKINDU Java Code Generator*
# Check the model(s) to generate code from and click *Finish*

!images/genmodelwizardchooselanguage.jpg!

The result is an .sgen file of the following format: 

bc.. 
GeneratorModel for [GeneratorId] {
	statechart [StatechartReference] {
		feature [Feature] {
			[ParameterName] = [ParameterValue]
		}
	}
}
p. The [GeneratorId] is the unique id of the Generator. Currently, the following Generators are supported 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::xpand - Generator ID for custom Xpand based Code Generators
# yakindu::generic - Generator ID for custom Java based Code Generators  

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].
 
The Generator Model is executed by a builder. Thus, the artifacts are generated automatically if *Project* > *Build Automatically* is checked. If you want to execute your Generator Model by hand, select *Generate Statechart Artifacts* from the *Package Explorer's* context menu.




