Skip to content

Generating state machine code

Ultimately, you will need your state machine not only as a nice graphical statechart model. This chapter explains how to generate it as executable code.

You can integrate the generated code with your software project as a component. You can send events to the state machine, receive events from it, retrieve information regarding the currently active state (or states), set and get state machine variables, and have the state machine invoke specific behavior that is external to it.

itemis CREATE, formerly known as YAKINDU Statechart Tools, comes with a couple of code generators that save you from the time-consuming and error-prone task of coding your state machine manually. The itemis CREATE code generators transform your statechart into source code of a target programming language in an instant. The generated code is always correct, at least in the sense that it is a true one-to-one mapping of your statechart – and at least unless a code generator is buggy itself.

Use SCTUnit in order to test whether your state machine is also correct in the sense that it does what it is intended to do.

Currently itemis CREATE support code generation for the following programming languages:

YSCT also includes a statechart image generator.

If you want to generate SCXML files, see also chapter SCXML code generation.

Additionally, you can install a couple of code generators from the itemis CREATE Labs update site. To do so, select Help → Install new software … in the main menu, and use https://updates.yakindu.com/statecharts/labs/ as the site location.

Please note: Code generators in itemis CREATE Labs are still in their beta phase and might well contain some rough edges. If you encounter any problems, please let us know!