Contact change is canceling piston execution


#1

1) Give a description of the problem

I have a piston that reacts when a door is opened. When the door is opened, the piston sends a command that moves a PTZ camera to a specific preset. It should wait 30 seconds and then drop into another if statement that determines if the camera should be returned to its original position. The piston successfully fires when the door is opened. If the door is left open, the piston runs as expected and evaluates the subsequent if statement. If the door is closed before 30 seconds have elapsed, evaluation of the subsequent if statement is canceled and the piston ends prematurely. I have set the task cancellation policy to Never Cancel Tasks.

2) What is the expected behaviour?
The piston should not cancel subsequent statements when the contact changes back to closed.

3) What is happening/not happening?
The piston runs when the door is opened but ends prematurely when the door is closed. If the door is left open for the duration of the wait time, the piston works properly and executes all statements. Never Cancel Tasks is selected, so I don’t understand why the change in sensor state from open to a closed is cancelling execution of the piston.

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full

+1ms â•”Received event [Home].time = 1561329637565 with a delay of -1364ms
+393ms â•‘RunTime Analysis CS > 142ms > PS > 204ms > PE > 47ms > CE
+396ms â•‘Runtime (42957 bytes) successfully initialized in 204ms (v0.3.108.20180906) (394ms)
+398ms â•‘â•”Execution stage started
+399ms ║╚Execution stage complete. (2ms)
+401ms ╚Event processed successfully (401ms)
6/23/2019, 4:40:23 PM +305ms
+2ms â•”Received event [xxx].contact = closed with a delay of 167ms
+124ms â•‘RunTime Analysis CS > 23ms > PS > 66ms > PE > 35ms > CE
+127ms â•‘Runtime (42957 bytes) successfully initialized in 66ms (v0.3.108.20180906) (125ms)
+128ms â•‘â•”Execution stage started
+138ms â•‘â•‘Comparison (enum) closed changes_to (string) open = false (1ms)
+140ms ║║Cancelling condition #2’s schedules…
+142ms â•‘â•‘Condition #2 evaluated false (7ms)
+143ms ║║Cancelling condition #1’s schedules…
+144ms â•‘â•‘Condition group #1 evaluated false (state changed) (10ms)
+147ms ║╚Execution stage complete. (19ms)
+148ms ╚Event processed successfully (148ms)
6/23/2019, 4:40:07 PM +394ms
+1ms â•”Received event [Home].wc_async_reply = httpRequest with a delay of 0ms
+122ms â•‘RunTime Analysis CS > 22ms > PS > 66ms > PE > 33ms > CE
+124ms â•‘Runtime (42951 bytes) successfully initialized in 66ms (v0.3.108.20180906) (123ms)
+126ms â•‘â•”Execution stage started
+145ms â•‘â•‘Calculating (string) Gate was opened. PTZ started recording on + (string) Sun, Jun 23 2019 @ 4:40:07 PM MDT >> (string) Gate was opened. PTZ started recording on Sun, Jun 23 2019 @ 4:40:07 PM MDT
+148ms â•‘â•‘Calculating (string) Gate was opened. PTZ started recording on Sun, Jun 23 2019 @ 4:40:07 PM MDT + (string) . >> (string) Gate was opened. PTZ started recording on Sun, Jun 23 2019 @ 4:40:07 PM MDT.
+165ms â•‘â•‘Executed virtual command sendPushNotification (12ms)
+169ms â•‘â•‘Executed virtual command wait (0ms)
+170ms â•‘â•‘Requesting a wake up for Sun, Jun 23 2019 @ 4:40:37 PM MDT (in 30.0s)
+175ms ║╚Execution stage complete. (50ms)
+177ms â•‘Setting up scheduled job for Sun, Jun 23 2019 @ 4:40:37 PM MDT (in 29.995s)
+189ms ╚Event processed successfully (188ms)
6/23/2019, 4:40:06 PM +592ms
+1ms â•”Received event [xxx].contact = open with a delay of 122ms
+112ms â•‘RunTime Analysis CS > 19ms > PS > 53ms > PE > 41ms > CE
+115ms â•‘Runtime (42963 bytes) successfully initialized in 53ms (v0.3.108.20180906) (114ms)
+116ms â•‘â•”Execution stage started
+127ms â•‘â•‘Comparison (enum) open changes_to (string) open = true (1ms)
+129ms ║║Cancelling condition #2’s schedules…
+130ms â•‘â•‘Condition #2 evaluated true (8ms)
+131ms ║║Cancelling condition #1’s schedules…
+132ms â•‘â•‘Condition group #1 evaluated true (state changed) (10ms)
+135ms ║║Cancelling statement #3’s schedules…
+140ms â•‘â•‘Executed virtual command setVariable (1ms)
+150ms â•‘â•‘Sending internal web request to: 192.168.1.x:xxx/admin?camera=PTZ&preset=3&user=xx&pw=xxx
+154ms â•‘â•‘Executed virtual command httpRequest (5ms)
+156ms â•‘â•‘Requesting a wake up for Sun, Jun 23 2019 @ 4:40:26 PM MDT (in 20.0s)
+161ms ║╚Execution stage complete. (45ms)
+163ms â•‘Setting up scheduled job for Sun, Jun 23 2019 @ 4:40:26 PM MDT (in 19.994s)
+172ms ╚Event processed successfully (173ms)

Clear

Full

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

Just a quick question, when and where do you change your global variable @returncamtopreset back to false?


#3

The variable returncamtopreset is set to true via a virtual ST switch. It’s usually true but there’s another piston that sets it to false if certain events happen that suggest the camera should park itself and monitor one position indefinitely.

I was trying to troubleshoot things so I took out all of the variables and just left 4 statements. The piston still stops when the sensor state changes to closed even with TCP set to never. I’m stumped.


#4

I figured it out. I was setting TCP to never on the if statement. When you edit the piston, you can access TCP for the with location statement that’s nested under the if statement. I set TCP to never on the with location statement and the piston continues even if the contact sensor’s state changes. I thought TCP applied to everything under the if statement. Evidently it doesn’t.


#5

I think specifically, the TCP set to Never should be on the WITH with a WAIT…
(although I usually place it on subsequent WITHs as well)