Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Each mode and state can take one of a fixed set of values.


1. Click edit the program.

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.

4. For each mode value that the current mode can take, add it on the bottom part of the block.

In this example we have a fist mode "day" that has the mode values "weekday" and "weekend" and a second mode "time" that has the mode values "daytime" and "nighttime"

5. In a similar way, drag find the state block in the block library and drag it into the stage.

6. Set the state name in the top input box.

7. Add the state values.

In this example we have one state named "heating" with two values "normal" and "economical"

...

You can select the value you set to the mode from the drop down list.


Edit the state block(s)

To edit a state block, first click on the pencil on the top of the block.

...

The generated code is based on the following three parts:

Mode setup

In this part the mode values are set.

...

Info
iconfalse
titlemacro setup

//day block

dayNumber = (dayNumber + 0.5) % 7;

if (dayNumber > 4) {

    day = "weekend";

}

else {

    day = "weekday";

}

//time block

hour = (hour + 0.5) % 24;

if (inRange(hour, 6, 18)) {

     time = "daytime";

}

else {

    time = "nightime"

}


Setting the state values

In this part the state values are set based on the linking done between the mode and state blocks.

...