datadaddy Posted February 1, 2017 Posted February 1, 2017 I'm a relative newbie using the programs feature in the admin console (still) I want to do something like this (simplified for explanation) Start Program1 based on some event Do some stuff in Program1 Have Program1 call Program2 Do some stuff in Program2 Have Program1 call Program3 Do some stuff in Program3 Both Program2 and Program3 have the need for a timer/delay Can they execute at the same time ? It feels like the natural behavior would be the Program2 would finish before Program3 is called and starts thanks
oberkc Posted February 1, 2017 Posted February 1, 2017 It is my understanding that such programs could run simultaneously, and that there is nothing that would temporarily halt program 1 while progrsms 2 or 3 are running. (Perhaps this is the difference between single-, and multi-threaded code?). Do not think of programs 2 and 3 as subroutines to program 1.
stusviews Posted February 1, 2017 Posted February 1, 2017 If programs 2 & 3 are disabled, then they won't run until/unless they're triggered by another program.
andyf0 Posted February 1, 2017 Posted February 1, 2017 If programs 2 & 3 are disabled, then they won't run until/unless they're triggered by another program. That not what the OP asked. You can still run a program from within a program whether it is disabled or not.
datadaddy Posted February 1, 2017 Author Posted February 1, 2017 okay, this statement from oberkc is what I'm really asking... "It is my understanding that such programs could run simultaneously, and that there is nothing that would temporarily halt program 1 while progrsms 2 or 3 are running." Is this true ? in other words after program 1 calls program 2 it doesn't wait for program 2 to return before continuing (and calling program 3) Any expert that can verify this ? I suppose I could cobble together a test to verify it
andyf0 Posted February 1, 2017 Posted February 1, 2017 oberkc is correct. Programs that are run from within programs will be spawned off and execution on the original program will continue.
oberkc Posted February 1, 2017 Posted February 1, 2017 Any expert that can verify this ? While I am unsure what one must be to be considered an "expert", I can say that I generally do not reply with guesses. One cannot help but learn a few things by hanging around smart people. Consider, too, that within individual programs, steps are indeed executed in order. Many have referred to this as "atomic", I believe. Given this, it should be possible to achieve what I assume is your desired effect. Consider a slight modification to your logic: Start Program1 based on some event Do some stuff in Program1 Have Program1 call Program2 Do some stuff in Program2 Have Program2 call Program3 <<note the change here Do some stuff in Program3
MikeD Posted February 1, 2017 Posted February 1, 2017 I'm a relative newbie using the programs feature in the admin console (still) I want to do something like this (simplified for explanation) Start Program1 based on some event Do some stuff in Program1 Have Program1 call Program2 Do some stuff in Program2 Have Program1 call Program3 Do some stuff in Program3 Both Program2 and Program3 have the need for a timer/delay Can they execute at the same time ? It feels like the natural behavior would be the Program2 would finish before Program3 is called and starts thanks Both programs would be called essentially at the same time. Although one follows the other in Program1's Then or Else clause, Program1 does not wait for Program2 to finish before Program3 runs. You also must decide how you are going to run the programs, Run(If), Run(Then), or Run(Else) of Program2 & Program3. A Run(If) will allow you to trigger the program to run based on a condition, while Run(Then) or Run(Else) will execute the statements regardless of a condition.
datadaddy Posted February 1, 2017 Author Posted February 1, 2017 Thanks guys...oberkc, I didn't mean to imply you weren't an "expert" when you started with "It is my understanding..." I wasn't sure of your confidence level thanks again....
oberkc Posted February 1, 2017 Posted February 1, 2017 when you started with "It is my understanding..." I wasn't sure of your confidence level No apology needed. I recognize that my responses indicate some level of uncertainty (and intended to do so). I just hate to suggest that I have first-hand knowledge of the innards of the ISY, since I do not work for them, and have no special inside knowledge. I am simply a fan and interested in how things work.
stusviews Posted February 2, 2017 Posted February 2, 2017 That not what the OP asked. You can still run a program from within a program whether it is disabled or not. But it's pertinent to what the OP seems to want, that is, running programs sequentially rather than concurrently.
jtara92101 Posted February 2, 2017 Posted February 2, 2017 I thought OP WANTED to run simultaneously? If you want to run two programs sequentially, set some variable at the end of the first program, and have the second program test for it in if. If you want to run several programs sequentially, you might step a variable. See also recent discussion on implementing a state machine. Again, running a program is NOT calling a function or subroutine. When you start a program it is off to the races, on it's own. It does not block the invoking (NOT "calling") program from continuing. ISY programs (IMO) should be very small and very atomic. Do one thing. One very small thing.
stusviews Posted February 2, 2017 Posted February 2, 2017 The closest to getting programs to run concurrently is to use a single variable as a trigger for both programs, as you indicated, but it should be a state variable, not an integer variable.
larryllix Posted February 2, 2017 Posted February 2, 2017 No apology needed. I recognize that my responses indicate some level of uncertainty (and intended to do so). I just hate to suggest that I have first-hand knowledge of the innards of the ISY, since I do not work for them, and have no special inside knowledge. I am simply a fan and interested in how things work. ....but his fan is plugged into an OnOff module, and can control that too.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.