Jump to content

Program doesn't run specified programs in order ?


telljcl

Recommended Posts

Posted

I've got a program which calls for the running of other programs - maybe 10 or 12 in a specific order, calculating and verifying in a way that requires the order to be proper.

 

I use the "move up / down" button to organize the programs.

 

Example:

 

If:

$A = 1

 

Then:

Run First program

Run Second program

Run Third program...

 

 

I'm getting some unpredictable results, and I notice in the "Summary" page of "Programs", the time of execution does not seem to be in the same order the programs were listed to be run.

 

They all run sometimes in the same second, or very close, but are not listed in the proper order even after sorting by time (execution or finished time).

 

Is there some reason WHY the programs wouldn't run in the order you specify?

 

Do I need to put a "wait 1 second" command between listed programs to get it to order them properly ?

 

I've been fairly frustrated with the ISY programming logic lately - This appears to be another thing I just don't understand.

 

Any help would be appreciated - Thanks!

 

Posted (edited)

Programs run independently. The order of invocation does not matter. Programs do not function as subroutines. Program one can Run Program two as the last Action. Program two can Run Program three as the last action.

 

 

EDIT: from the ISY Wiki

 

In all cases, the order in which the programs run is determined by ISY's internal algorithms, and is not user predictable; specifically, schedules do not necessarily run in chronological order.

 

Link to Wiki segment that covers this

 

http://wiki.universal-devices.com/index.php?title=ISY-99i/ISY-26_INSTEON:Scope,_Precedence_and_Execution_Order

Edited by LeeG
Posted (edited)

Thanks - my fault for not understanding how the programming works.

 

If programs don't / can't function as subroutines, what would be the proper way to run a "subroutine" or the ISY equivalent?

 

So you are saying that there is no way to perform actions (say, check status of this before changing the value of that) in any sort of order, other than a simple "IF: $A=5   THEN:  make $B=2" ?

 

All the programs I want to run in order are "disabled", which (seems) like they would run only when you called them to run.  

 

I guess I'm trying to perform an equation, and that's tough to do if you can't control the order in which various parts of it are calculated.  The results are different every time.

 

In trying to control and sync multiple thermostats there are a lot of conditions to check and they are constantly changing - maybe it just isn't possible to accomplish with the ISY, but I could do it manually if I ran around and set this to that if this other setting was set a certain way etc...  Which is what I always assumed the ISY could do.

 

I still have to assume that it must be possible - It appears I just probably don't have the kind of time needed to acquire the programming skills required to do it (even though I've had an ISY for 4 or 5 years and have lots of (simpler) programs that run constantly and without issue.

 

A little frustrated but I appreciate your help. Any suggestions appreciated.

Edited by telljcl
Posted

Hi LeeG, thanks so very much as always.

 

Hi telljcl,

 

Let me try to clarify:

1. The sequence of execution of each program is based on the order of the programs as you have them listed

2. The issue arises when the program you are calling has interruptible constructs (such as Wait or Repeat) or that it depends on some condition that has not yet been met at the time of the call. Or, it's calling network resources, email notification, updating variables (which may cause other programs that depend on the variable to run), etc. which go in a queue and are processed independently

 

So, if all your programs simply turn on/off a device (WITH a condition that's always true), then the sequence of execution will be the same as you have listed them in your programs. Now, going back to LeeG's comments, and what I have outlined above, it would not be a good practice to depend on the sequence simply because there are too many variables that may contribute to the sequence to be broken.

 

So, of course you can do if $A=5 the set $B=2 ... If A is a state variable, then B is set to 2 as soon as A is changed to 5. Now if B is also a state variable then any programs that depend on B will start getting evaluated and may run.

 

If you need help with your programs, please don't hesitate to contact our tech support (links below).

 

With kind regards,

Michel

Posted

A Program that uses

 

Then

Run Program 'A'

Run Program 'B'

Run program 'C'

......

 

will not know the order Programs A,B,C actually execute. Having the Programs Disabled only means an Event will not trigger the Programs. The Run Actions happen quickly, not waiting for A to complete before the Run 'B' executes, and so on. Basically A,B,C and the sample Program logically Run at the same time. Of course only one Program is physically executing statements at a time but how far A runs before B is given a time slice to execute is under ISY control.

 

A simple way to have each Program run in sequence would be

 

Program 1

 

Then

....

....

....

Run Program2

Else

 

 

Program 2

 

Then

....

....

....

Run Program3

Else

 

 

Program 3

 

Then

....

....

....

Run Program4

Else

 

If the subroutines are tracking different thermostats, for example, they could be Event driven, setting Variables with current conditions with a single Program using the Variable values to develop a conclusion/action.

 

There may well be a better way to create Subroutine like sequences. I'll have to give that some thought as I have not tried to create a Subroutine environment. Lots of good folks participate here so if there is simple or best practices way to create a Subroutine structure I'm sure they will jump in.

Posted

Of course, if we were able to test for a program that is currently running (then or else?) ......... (and trigger on the state change?) :).

 

Oh! and include that state in a  WAIT command, like WAIT until Program 1 is idle.

 

Just a feature request ....... :)

Posted (edited)

Elaborating on LeeG's ideas...

 

Create a state variable "$sSequence" and use the event driven sequencing engine in ISY.

 

Program 1

--------------

If

   whatever trigger

Then

   ...do some stuff

    Run (if) Program 1a

Else

   ---

 

Program 1a

---------------

If

   condition to insure Program 1 tasks are complete

Then

   Set $sSequence = 2

Else

   --

 

 

Program 2

--------------

If

   $sSequence = 2

Then

   do some stuff

   Wait to be sure tasks are done

   Set $sSequence = 3

Else

   --

 

Program 3

---------------

If

    $sSequence = 3

Then

    do some stuff

    iWait or other complete insurance.

    Set $sSequence = 1

Else

   --

Edited by larryllix
Posted (edited)

So I've tried to incorporate a few of the above suggestions but wanted to see if someone could check these 2 program screen shots and see what is wrong with them.

 

One program is supposed to determine a "Flag" value (state variable in this case) of 0 or 1 depending on the 3 state variables in the "If" part.

 

The second program is supposed to start a long, multi-program chain (run program 1 - program 1 runs program 2, etc...) based on the variable value set in the 1st program.

 

If the "Flag" variable somehow changes during the long execution of multiple programs, will the execution stop or does it continue regardless once the "Then run program 1..." starts?

 

I'm getting either unpredictable behavior or when I tried using integer variables I was having trouble getting the programs to run when conditions warranted.

 

Thanks for any help - I'm trying to get this but I just must be thick-headed I guess.

 

post-2091-0-17350600-1415231308_thumb.jpg

 

post-2091-0-88396800-1415231316_thumb.jpg

Edited by telljcl
Posted

When a State Variable changes value the Program(s) that have that variable in the If section will trigger. A Program that is currently executing statements will trigger when the current clause finishes unless the clause is in a Wait or Repeat or runs into a Wait or Repeat. The program will trigger immediately if in a Wait or Repeat. This trigger can be stopped by having the Program Disabled. Being Disabled does not stop the Program from being invoked by a Run Program but does stop events such as variables changing values from triggering the Program. Also using an Integer variable in the If prevents an event trigger.

Posted (edited)

Thanks.

 

Major point I discovered is that the ISY was causing either all or most of the issues.  I have spent so much time studying this I'm about to pull my hair out.  Finally ran tiny bits of programs and it wasn't controlling network resources (thermostat) properly or at all.  I was getting completely random (and at odd times) commands, or mostly - no commands working.  I could (until the very end) "Test" the network resource (which have been set up and working fine for many months) and they would work - but not in programs reliably or at all.  I put "wait" periods in between the commands to no avail.  Then the "test" button would not work - couldn't even click it eventually.

 

Short answer is I killed power to ISY and re-booted and all of a sudden I don't seem quite so stupid.  Everything works, or if it doesn't a little bit of study will find it.

 

I wasted probably 8 hours trying to figure out why all of a sudden I couldn't seem to understand things before realizing this.  I'm sure I had some errors still as well, but this was clearly the thing that was causing me not to be able to zero in on it.

 

Whole thing was like trying to solve a complex equation with a calculator that was overclocked by 200% and was spewing bogus data most of the time but I assumed it had to be correct.

 

Live and learn.

 

Thanks for all the help - I'm still no expert, but I've used this thing for quite a while and things have gone just fine.

Edited by telljcl
Posted

Get a beer, sit back, and pat yourself on the back for being so smart.  It was a tough day.

 

Did you ever have one of the lives where nothing seemed to go right? :D

Guest
This topic is now closed to further replies.

×
×
  • Create New...