Dynamic variable error - two nearly identical pistons, one works, one doesn't


#1

1) Give a description of the problem
The Washer Monitor works great, the dryer monitor not so much. The variables are set the same – dynamic, no initial value. The Washer shows all three critical variables at: /* 0 / but the dryer piston displays it as / */ This is causing null errors when the piston starts counting from a command to:

Set variable {HighWattsCount} = {HighWattsCount+1};

However, setting it to start at 0 initially seems to keep it at 0.

2) What is the expected behavior?
the variable displays /* 0 */ so it can begin counting.

3) What is happening/not happening?
see above

4) Post a Green Snapshot of the pistonimage
(

Full piston here:

5) Attach any logs (From ST IDE and by turning logging level to Full)

3/29/2018, 11:12:19 AM +56ms
+1ms	╔Received event [Laundry Monitor].button = pushed with a delay of 532ms
+10265ms	║RunTime Analysis CS > 17ms > PS > 10160ms > PE > 89ms > CE
+10278ms	║Piston waited at a semaphore for 10102ms
+10281ms	║Runtime (50679 bytes) successfully initialized in 10160ms (v0.3.104.20180323) (10279ms)
+10281ms	║╔Execution stage started
+10291ms	║║Comparison (enum) pushed gets (string) pushed = true (1ms)
+10292ms	║║Cancelling condition #32's schedules...
+10293ms	║║Condition #32 evaluated true (5ms)
+10294ms	║║Cancelling condition #1's schedules...
+10294ms	║║Condition group #1 evaluated true (state changed) (7ms)
+10296ms	║║Cancelling statement #8's schedules...
+10301ms	║║An error occurred while executing the event: java.lang.NullPointerException: Cannot execute null+null
+10303ms	║╚Execution stage complete. (21ms)
+10304ms	╚Event processed successfully (10304ms)



3/29/2018, 11:14:48 AM +537ms
+1ms	╔Received event [Laundry Monitor].button = pushed with a delay of 60ms
+176ms	║RunTime Analysis CS > 17ms > PS > 58ms > PE > 102ms > CE
+179ms	║Runtime (50594 bytes) successfully initialized in 58ms (v0.3.104.20180323) (178ms)
+180ms	║╔Execution stage started
+188ms	║║Comparison (enum) pushed gets (string) pushed = true (1ms)
+189ms	║║Cancelling condition #32's schedules...
+190ms	║║Condition #32 evaluated true (5ms)
+191ms	║║Cancelling condition #1's schedules...
+191ms	║║Condition group #1 evaluated true (state changed) (7ms)
+193ms	║║Cancelling statement #8's schedules...
+198ms	║║An error occurred while executing the event: java.lang.NullPointerException: Cannot execute null+null
+200ms	║╚Execution stage complete. (20ms)
+201ms	╚Event processed successfully (201ms)

#2

Hey there, @Robin, really hate to bother you, but acknowledge your expertise and am very appreciative of your efforts across the platform. This has been confounding me for a while – any ideas? What am I doing wrong?


#3

Please use numeric types like integer for your counters rather than dynamic.

I also recommend using >= for your loop conditions to ensure that the piston does not repeat infinitely if any unexpected sequence of events results in the counter starting off greater than your target value.


#4

Thank you, thank you, thank you, @ipaterson. Very grateful for taking a look at this.