Variable seems to get "stuck" so my piston won't run. Am I "resetting" it properly?


#1

1) Give a description of the problem
Can’t get piston to work reliably. Variable gets “stuck”.

2) What is the expected behaviour?
on an event of any of multiple sensors/devices, change global variable to true, which will turn on a light (through a different piston monitoring that variable.) The light will stay on for a certain prion of time then turn off. That piston will also reset the variable to false as the other piston relies on the variable change.
3) What is happening/not happening?
The variable will get “stuck” on true, so the other piston will not fire as it is monitoring for the variable state change.
Sometimes it works, until it doesn’t.
And add to this there are two different lights that rely on many of the same sensors to activate in the same manner. I have attached all the pistons. I did them as separate pistons as it’s easier for me to wrap my head around them that way.

**4) Post a Green Snapshot of the piston!
5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)

REMOVE BELOW AFTER READING


#2

Three thoughts:

  1. Global variables are cached by pistons. As you have a wait of over five seconds the pistons will exit and restart between changes causing any updates to be written back. So that looks good.
  2. When you use changes to you must make sure the trigger condition can always be reached when the event of interest happens. As yours appear at the start of condition groups and are combined with an or they should be fine. So that looks good.
  3. I see the second and third pistons have traces showing the condition group has returned false. That could be an indicator of the problem. If one of your sensors goes inactive or off during the ten second wait, the global variable will not be set back to false because the Task Cancellation Policy will “cancel” the wait. You may well need to set the TCP on the action/task to Never Cancel.

#3

Okay-I’ll try that. I think you may be on to something because the problem appears random, but the state of those sensors may take a short or long time depending on what sent them off.
Thanks!


#4

Would you be kind enough to tell me what lines in the pistons need to have the tcp changes? I’m pretty sure I know but it will save me some experimenting.
Thanks again.


#5

Click on the statement you want to change its policy, clicking the gear cog, and then [Task Cancellation Policy] should be the 2nd drop-down menu available.


#6

It’s hard to see the images on my mobile - a long standing quirk of the forum software is that the click you need to zoom in also switches to the next image. Also the line numbers can be different in edit mode. However when in edit mode you should see something like

With
  Location
Do
  Set variable
  Wait 10 seconds
  Set variable
End with

You can set the TCP either by clicking on the with (the action) or the wait itself (the task). It shouldn’t matter which.

It is also possible to set TCP on if statements. I’ve never seen any good come of that.


#7

Thank You!


#8

The TCP already had been set on “never cancel”.