Once the controller class and state machine are modeled, you can generate state machine code for the controller and state machine. With the generated state machine, you can run instant generator to produce other classes, like the model and view classes, and incooperate with the state machine code.
To generate state machine code:
- Select Tools > Code > Generate State Machine Code… from the toolbar.
- In the Generate State Machine dialog box, select the controller class for generating state machine.
- Select the state machine in the drop down menu State Diagram for generating code.
- Select the programming language of the code.
- Specify the output path to save the generated code to.
- Optionally configure the generator options.
- Click OK to generate.
Note: There must be at least one class that contain sub state machine diagram in order to open the Generate State Machine Code window.
An overview of Generate State Machine Code window
|1||Class||The controller class for generating state machine.|
|2||State Diagram||The state machine (in the form of state machine diagram) to generate. It must be a sub-class of the chosen controller class.|
|3||Language||The programming language of code to generate.|
|4||Output Path||The output path of state machine code.|
|5||Options||Options for code generation. Below is a description:
Synchronized transition methods – By checking, it causes the generated code to:
Generate try/catch – Uncheck to not generate try/catch code. You are recommended to keep this checked. Uncheck only in C++ applications where exceptions are not used.
Generate debug message – Adds debug output messages to the generated code.
Re-generate transition methods – Check to overwrite the transition methods in code, including the implementation.
Browse output directory after generate – Open the output path.
Auto create transition operations – If a transition is named, but does not have Operation assigned. By checking this option operation will be created to the parent class, named as the transition name.
Generate sample – Generate sample files to guide you how to work with the generated file.
Generate diagram image – Generate PNG image for chosen state machine diagram.
|6||OK||Click to start code generation.|
|7||Cancel||Click to close the Generate State Machine Code window.|