Parts of piston sometimes not triggering - "variable changes to"


#1

1) Give a description of the problem
Hello again, I have some code which in the first half of the code sets some variables depending on button presses, and a second half which is reacting to changes to the variables. I was hoping to make the code a bit more modular this way. However, sometimes the code which should be triggered on “variable changes to” isn’t executed. I must be missing some basic concept?

2) What is the expected behaviour?
A change to the colorIndex variable should also trigger a change in actual color.

3) What is happening/not happening?
The colorIndex variable is changing to the correct value, but the IF statements at the lower half are not consistently triggering, thus sometimes skipping some colors that I am cycling through.

4) Post a Green Snapshot of the piston

Here is also a screenshot from the Trace, you can see here that the “changes to 4” condition is not fulfilled. Note, these are two seperate IF statements.

5) Attach logs after turning logging level to Full
|+1ms|╔Received event [Dining Dimmer right button].button = pushed with a delay of 48ms|
|—|---|
|+64ms|║RunTime Analysis CS > 16ms > PS > 5ms > PE > 43ms > CE|
|+67ms|║Runtime (56763 bytes) successfully initialized in 5ms (v0.3.110.20191009) (65ms)|
|+68ms|║╔Execution stage started|
|+79ms|║║Condition #2 evaluated false (6ms)|
|+80ms|║║Condition group #1 evaluated false (state did not change) (7ms)|
|+87ms|║║Condition #33 evaluated false (7ms)|
|+88ms|║║Condition group #32 evaluated false (state did not change) (8ms)|
|+96ms|║║Condition #66 evaluated false (7ms)|
|+97ms|║║Condition group #64 evaluated false (state did not change) (9ms)|
|+100ms|║║Comparison (enum) pushed gets (string) pushed = true (1ms)|
|+101ms|║║Condition #68 evaluated true (3ms)|
|+102ms|║║Condition group #65 evaluated true (state did not change) (5ms)|
|+107ms|║║Comparison (integer) 3 is_equal_to (integer) 0 = false (1ms)|
|+108ms|║║Condition #102 evaluated false (4ms)|
|+109ms|║║Condition group #97 evaluated false (state did not change) (5ms)|
|+113ms|║║Comparison (integer) 3 is_equal_to (integer) 1 = false (1ms)|
|+114ms|║║Condition #103 evaluated false (4ms)|
|+115ms|║║Condition group #98 evaluated false (state did not change) (5ms)|
|+119ms|║║Comparison (integer) 3 is_equal_to (integer) 2 = false (1ms)|
|+121ms|║║Cancelling condition #107’s schedules…|
|+122ms|║║Condition #107 evaluated false (5ms)|
|+123ms|║║Cancelling condition #99’s schedules…|
|+123ms|║║Condition group #99 evaluated false (state changed) (7ms)|
|+128ms|║║Comparison (integer) 3 is_equal_to (integer) 3 = true (1ms)|
|+129ms|║║Cancelling condition #111’s schedules…|
|+130ms|║║Condition #111 evaluated true (5ms)|
|+131ms|║║Cancelling condition #100’s schedules…|
|+131ms|║║Condition group #100 evaluated true (state changed) (7ms)|
|+133ms|║║Cancelling statement #158’s schedules…|
|+139ms|║║Executed virtual command setVariable (3ms)|
|+144ms|║║Comparison (integer) 2 changes_to (integer) 0 = false (0ms)|
|+146ms|║║Condition #179 evaluated false (3ms)|
|+146ms|║║Condition group #176 evaluated false (state did not change) (4ms)|
|+150ms|║║Comparison (integer) 2 changes_to (integer) 1 = false (1ms)|
|+151ms|║║Condition #180 evaluated false (4ms)|
|+152ms|║║Condition group #177 evaluated false (state did not change) (5ms)|
|+156ms|║║Comparison (integer) 2 changes_to (integer) 2 = false (1ms)|
|+157ms|║║Condition #183 evaluated false (4ms)|
|+158ms|║║Condition group #178 evaluated false (state did not change) (5ms)|
|+162ms|║║Comparison (integer) 4 changes_to (integer) 0 = false (0ms)|
|+163ms|║║Condition #193 evaluated false (3ms)|
|+164ms|║║Condition group #188 evaluated false (state did not change) (4ms)|
|+167ms|║║Comparison (integer) 4 changes_to (integer) 1 = false (1ms)|
|+168ms|║║Condition #194 evaluated false (3ms)|
|+169ms|║║Condition group #189 evaluated false (state did not change) (4ms)|
|+172ms|║║Comparison (integer) 4 changes_to (integer) 2 = false (1ms)|
|+173ms|║║Condition #200 evaluated false (3ms)|
|+174ms|║║Condition group #190 evaluated false (state did not change) (4ms)|
|+177ms|║║Comparison (integer) 4 changes_to (integer) 3 = false (0ms)|
|+178ms|║║Cancelling condition #206’s schedules…|
|+179ms|║║Condition #206 evaluated false (3ms)|
|+179ms|║║Cancelling condition #191’s schedules…|
|+180ms|║║Condition group #191 evaluated false (state changed) (6ms)|
|+183ms|║║Comparison (integer) 4 changes_to (integer) 4 = false (1ms)|
|+184ms|║║Cancelling condition #212’s schedules…|
|+185ms|║║Condition #212 evaluated false (4ms)|
|+186ms|║║Cancelling condition #192’s schedules…|
|+187ms|║║Condition group #192 evaluated false (state changed) (5ms)|
|+189ms|║╚Execution stage complete. (120ms)|
|+190ms|╚Event processed successfully (189ms)|


#2

Changes to local variables do not trigger the piston so ‘changes to’ will always be false.


#3

That’s weird, why not? In that case I don’t understand why it’s working 4 out of 5 times. What would be the correct solution?