[Pro] Coffee Machine with C++ integration
This is a example for the deep C++ integration of CREATE
statecharts. It shows how C++ classes can be used as variables and is based on the C example:

The statechart consists of two
major states "ON" and "OFF". The "ON" state is a composite state with
several substates and substate machines for the different modes.
Using deep C++ integration
Imported classes can be referenced by declaring a variable and using the
class as the type of it.
Within the example two classes are referenced:
- var cm : Coffee_Machine
- var hmi : CM_HMI
They can be used to access members of the class, like functions, variables, typedefs, etc.
For example the class Coffe_Machine, which is declared as the variable cm, includes a function called stop heating:
Simulation
The declared variables can be used and changed in the simulation view.
Generate state machine code
If you have changed the model you can generate state machine code by
right-click on 'CoffeeMachine.sgen' and choose 'Generate Code Artefacts'.
This will generate:
- CoffeeMachineCpp.hpp
- CoffeeMachineCpp.cpp