Jump to content

Does a program get executed once, or multiple times?


SteveKlos

Recommended Posts

Folks,

Having a few hiccups when it comes to programming the ISY (mostly to do with Variables not being set in Firmware V 5.0.15A), but I have a fundamental question on the programming.

If I have a program that says:

    If:
        From Sunset
        to 10:25:00 PM (same day)
    Then
        wait 10 minutes (random)
        ....

does the then clause get executed multiple times between sunset and 10:25 PM, or only once when sunset occurs (and then again, possibly if the ISY is rebooted due to a power outage)?

My old programming style used to be something more like:
 

    If
        10:25 PM 
    Then
        wait 10 minutes (random)
        ....

I didn't find that to be as robust as providing a bracketed time.  I do recognize that there may be some overlap (the 10 minute random period), but that's the reason I'm asking the question - does the if statement get evaluated on every "loop" of the ISY, or is it only once (presumably once the clock hits 10:25).

Cheers,

SK

Link to comment

Hi SK

As written, it will only execute once. The From/To construct is designed to be used with other logic in the if, example adding this:

And Garage light is switched on.

That would cause the program to only run in the time boundaries when the garage light is turned on

Paul

Link to comment

To further Paul's explanation...
ISY is an event/trigger based engine. It does not loop process as some object oriented engines do.

With your time bracketed conditional/trigger/If section:
 If
        From Sunset
        to 10:25:00 PM (same day)
Then
        wait 10 minutes (random) ...this will run at sunset (every day)
Else
    
...this will run at 10:25 PM (every day)

If Enable is unchecked the triggers will not  initiate processing and it only becomes a permissive window. Calling it from  another program it can act as a permissive filter only, without any self triggers.
    

Link to comment


    If:
        From Sunset
        to 10:25:00 PM (same day)
    Then
        wait 10 minutes (random)
        ....


And to expand a little on what Larryllix said...

If you were to add other triggering conditions to the If clause - then when that triggering condition occurs outside of the timebox, the Else will execute. Within the time-box, then either Then or Else will execute based on the logic of the other triggering condition you added to the If clause.

Adding a Wait complicates things as well - the Wait will be terminated if any triggering condition in the If changes.
Link to comment

What the heck, let's expand just a little bit more...

Only one instance of a particular program ever runs.  So if you use a WAIT or REPEAT within a program, and the WAIT or REPEAT is terminated because the conditions of the IF are triggered, then the current instance of the program is terminated and a new instance begins to run.  Likewise, if a particular program is running when another program executes a RUN command for that particular program, then the currently executing instance is terminated and a new instance begins to run.

Link to comment

Thanks folks - that clarifies the issue for me.  I figured the system had to be event based, but was having some struggle wrapping my head around time based events - especially the from-to condition...  

Now, I just need to understand why my State variables are updating for some programs, but not for others.  I think I have more than enough to work with based on the replies provided!

Link to comment
On 9/4/2019 at 9:53 AM, SteveKlos said:

Thanks folks - that clarifies the issue for me.  I figured the system had to be event based, but was having some struggle wrapping my head around time based events - especially the from-to condition...  

Now, I just need to understand why my State variables are updating for some programs, but not for others.  I think I have more than enough to work with based on the replies provided!

You may notice that others prefix (at least) their status variables. Integer variables do NOT cause triggered events and confusing the usage of the two can cause you a lot of grief.

Some use $s.Variable,  and $i.Variable. I use $sVariable and $variable (no prefix for integer types) I also use $cCONSTANT for integer variable names to identify a variable value that is preset and never changes.
eg.    $sLogicVariable = $cTRUE
      $sGathRm.mode = $cDIM

 

 

Link to comment

Archived

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


×
×
  • Create New...