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 to 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.

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 YAKINDU 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 YAKINDU Statechart Tools support code generation for the following programming languages:

YSCT also includes a statechart image generator.

Additionally, you can install a couple of code generators from the YAKINDU Labs update site. To do so, select Help → Install new software … in the main menu, and use as the site location. The following code generators are available; click on the link to find more information about the respective generator:

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