Generating statechart code

You have developed and tested your statechart model, and now you need it as a C, C++, or Java implementation? YAKINDU Statechart Tools can create it for you.

As an example, we will take the light switch statechart and generate Java source code from it. Please proceed as follows:

  1. In the project explorer, right-click on 01_lightSwitch.ysc and select New → Code generator model in the context menu.

    Creating a new code generator model

  2. In the dialog, replace Statechart.sgen by light_switch.sgen, then click Next >.
  3. In the next dialog, check the checkbox left from 01_lightSwitch.ysc under the 01_basic folder, then click Finish.
  4. Java classes implementing the statechart model are generated. You can find the generated source code in the folders src and src-gen.

    Generated Java source code

That’s it. If you want to know more, take the time and work through the Comprehensive Tutorial.