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_light_switch.sct and select New → Code generator model in the context menu.

    Creating a new code generator model

  2. In the dialog, replace default.sgen by light_switch.sgen, then click Next >.
  3. In the next dialog, check the checkbox left from 01_light_switch.sct 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 within the org.yakindu.sct.examples.basic.tutorial project.

    Generated Java source code

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