Jump to content

Creating a Timer in ISY


Recommended Posts

@apostolakisl  Thank you for the details on the colors.  I will have to catch it when it is hung next time and check that.  I did search for the variable in ALL programs and only found it in the two I post.  One changes it, once checks it, and we send the value in emails, which is how I caught that it had hung again.  By the time I caught it, it had already reset and started counting again.

Other than emailing, what other tools does ISY have for debugging things like this?  I can't be watching it for hours on end looking for when it hangs.

Thank you.

Link to comment

@IT Solutions

You could write another program that sends you an email if the counter stops counting.  Something like

If
$yourcountervariable is not 0
Then
wait 2 minutes
send notification that counter stopped counting
repeat every 10 seconds
   turn on some light
   wait 2 seconds
   turn off some light

This assumes you are using a state variable (not integer).

What will happen is that once per minute, the "if" clause will restart the program, so the "wait 2 minutes" will never complete.  But if the counter stops counting at any value above 0 for more than 2 minutes, you will get an email.

Link to comment

@apostolakisl  I am not following your suggestion.  With my understand of ISY, every time the counter variable changes, the IF will check if it is zero, which it will not be, then wait to minutes, then send the notification that it has stopped counting.  Am I missing something?

 

I think this might work:

If $counter is not 0

and $wait is not 0

then

Set $check = $counter

Set $wait = 1

wait 2 minutes

Run program compare

 

Compare:

If $check = $ counter 

then

email counter has stopped working.

else

$wait = 0

Link to comment
36 minutes ago, apostolakisl said:

 

image.png.3e28e7c407aa524df3aa7dfc63fbe7f9.png 

Anyway, if it is is solid green, and the counter is not moving, then this is basically impossible unless your system has hung.  ISY isn't like windows, it pretty much never "hangs", but I suppose it is possible.

I don't think folder conditions or anything else matters here.  If the icon is solid green, the "then" clause is running. 

 

After mis-reading what you typed here, I ran a test.  To clarify tho,  If a folder condition above the program changes to false, the program will stop running (changing from solid green to green stripe) and remain stopped when the folder becomes true again.  Only starting again when the programs IF is re-evaluated and true.

===================================================================================
test - [ID 0125][Parent 0001]

Folder Conditions for 'test'

If
        $stemp_test2 is 0
 
Then
   Allow the programs in this folder to run.


-----------------------------------------------------------------------------------
AAA TEST - [ID 00E8][Parent 0125]

If
        'Node Servers / #1704 / Downstairs Fireplace' Temperature is 0.0°F
 
Then
        Repeat Every  10 seconds
           $stemp_test += 1
 
Else
   - No Actions - (To add one, press 'Action')
 

(I choose that IF statement for the program because it will be evaluated true once every 60 seconds, the temp always changes by at least .1)

I manually changed $stemp_test2 from 0 to 1 and back to 0.

When I came back to dispute your post, reading it again I found out misread and you had not mis-stated anything, but I decided to add the test results anyway, just to clarify that a running loop will not survive a folder condition above becoming false for even 1 second.. the loop will be interrupted.

 

Link to comment

@IT Solutions

The "if" triggers every time the variable changes (state variable that is).  If your 1 minute counter is working properly, then after 1 minute (prior to completing the 2 minute wait listed in the "then"), the program will retrigger (start over), the wait clause will terminate prior to completion, and no notification will be sent.  This will continue to happen as long as the counter keeps changing by 1 in a period of time that is less than 2 minutes.  As soon as the counter stays constant for 2 minutes at a value greater than 0, it will complete the wait clause and send the notification.

I think your programs will do the same thing, just with a lot more complexity.

This will also send you a notification when it stops counting because the heater turned off, so you might want to put a "stop the program I wrote" clause in the program that stops the counter on purpose. 

Link to comment

I went back and looked at your screen shot below.

image.thumb.png.4ca89c4be778a7fd5eb29aa1c4b56178.png

Your program is not counting.  You see the green is only a stripe on the left edge, not the full icon.  This program can not stop running on its own.  You have some other program or you did something manually to stop the counter.  This program can not evaluate to "true" and be done on its own.  On its own, it either runs true and keeps running true indefinitely (full solid green icon), or it runs false and is just a red stripe on the left edge (it will be solid red for a split second first).  On its own, it can not run true and then quit.  The only way to stop this program would be to have a "stop" command given to it either manually or by another program.  Also if you make changes to it and save it that will also cause a "stop".

Link to comment

@apostolakisl   Okay, so in your example the change of the state variable will trigger the program, and each additional change will cause it to start over, terminating the 2 minute wait. Is this correct?

I was concerned that it would generate another instance of the program running, and the 1st instance would also continue to run thus sending the failure message when it had not failed. 

I will still want to add something so I don't get an email every two minutes until it resets (or I reset it).

Thank you for your assist!

Link to comment
1 minute ago, IT Solutions said:

@apostolakisl   Okay, so in your example the change of the state variable will trigger the program, and each additional change will cause it to start over, terminating the 2 minute wait. Is this correct?

I was concerned that it would generate another instance of the program running, and the 1st instance would also continue to run thus sending the failure message when it had not failed. 

I will still want to add something so I don't get an email every two minutes until it resets (or I reset it).

Thank you for your assist!

Correct, programs don't run with multiple instances.  But see my other post just before this one.

Link to comment

@apostolakisl  I went to add the code to alert when the counter stopped and I noticed it was stopped and we had not had an email from these programs since about 9;30 this morning.  I do have the Administrator Console open all the time.  Maybe that makes a difference.  I did get an an email around 2:30 that was generated from a different program, so we know the email is working.  I am going to add the code to generate an alert when the counter stops and see what happens.

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...