UModel can generate executable code from State Machine diagrams (C++, C#, Java, VB.NET). Almost all of the State Machine diagram elements and features are supported:
•CompositeState, with any hierarchical level
•OrthogonalState, with any number of regions
State Machine code generation is integrated into the "normal" round-trip engineering process. This means that State Machine code can be automatically updated on every forward-engineering process.
The screenshot above shows the AirCondition State Machine diagram which is available in the ..\StateMachineCodeGeneration directory under ...\UModelExamples. A separate directory exists for each of the code generation languages supported by UModel.
Each directory contains an AirCondition and Complex folder, which contains the respective UModel project, programming language project files, as well as the generated source files. The Complex.ump project file contains almost all of the modeling elements and functionality that UModel supports when generating code from State Machine diagrams.
Each directory also contains a test application, e.g. TestSTMAirCondition.sln for C#, allowing you to work with the generated source files immediately.
To generate code from a State Machine diagram:
•Right-click in the State Machine diagram and select "Generate State Machine code", or
•Select the menu option Project | Generate State Machine Code
The default settings are shown above. Click OK to generate the code.
State Machine code is automatically updated when you start the forward engineering process. You can however change this setting by clicking on the State Machine diagram background and clicking the "Automatic Update Code" check box.
Changes should not be made manually in the generated code, as these changes are not reflected in the State Machine diagram during the reverse-engineering process.
Clicking the icon of the Automatic Update field, opens the Generate State Machine Code dialog box, allowing you to change the code generation settings.
To perform a syntax check on a State Machine diagram:
•Right-click the diagram and selecting Check State Machine Syntax from the context menu.