...
A state machine enables the user to specify a set of modes, that each can take different mode values.
- For example
...
- We could have a "day" mode that can take the values "weekday" and "weekend", and a "time" mode that could take the "daytime" and "nighttime" values.
- Also, a set of states is chosen, each state taking different values.
- For example
...
- : We could have a "heating" state that could take one of the "normal" and "economical" values.
- As the modes and states are represented by blocks, they can be linked. This way the user will specify, that when the "day" is "weekend" the "heating" to be "economical".
Steps to create a state machine
...
3. To trigger the program to act as a "state machine" you will need to add the following marker tag to your program isStateMachine(see steps below)
- In folio the Folio app run a query for all of your existing programs by typing in 'program'
- add isStateMachine as a marker tag
Add the mode and state blocks
...
Each mode and state has an associated string variable that represent represents it.
Each mode and state can take one of a fixed set of values.
...
2. Drag a mode block out of the block library.
3. Write a the mode name in the input box found on the top of the block.
...
5. In a similar way, drag find finds the state block in the block library and drag it into the stage.
...
7. Add the state values.
In this example, we have one state named "heating" with two values "normal" and "economical"
...
Link the mode and state blocks
In this example, we link the daytime and weekend values to economical, and the daytime to normal. We want to have "normal" heating in the weekdays and daytime, and "economical" heating in weekends or nighttime, as it's an office building.
...
You can select the value you set to the mode from the drop-down list.
Edit the state block(s)
...
This makes the tabs associated to with the state values to became become visible. In this case "heating = normal" and "heating = economical" will show up.
...
The generated code is based on the following three parts:
Mode setup
In this part, the mode values are set.
After editing the mode blocks, for each mode block a setup while be generated. In our current example the equivalent of this pseudo-code will appear:
...