smorgasbord Posted November 6 Posted November 6 (edited) I've read https://wiki.universal-devices.com/index.php?title=ISY-99i/ISY-26_INSTEON:Scope,_Precedence_and_Execution_Order#Boot/Startup_Sequence_and_Program_Execution_Order but still have questions. I have a program like this: If From 7:00:00AM To 10:00:00PM Then Repeat while $sOnVacay is not 0 (Actions) Else (No Actions) If the EISY reboots during the day, will this program get started (if enabled)? Or, should I set it to Run At Startup and let the "If Schedule" do its thing? The Repeat code essentially does a thing every 30 minutes (there's a Wait) during the From/To time period. I don't want to have two (or zero) copies of this routine running, naturally. EDIT: What I mean by that last comment is a question as to whether programs in EISY are re-entrant. That is, can you have multiple copies of the same program running in different threads at the same time? Basically, if a program is running, and say is at a long Wait, and another program directly invokes the Run(If) of that first program, what happens? And then, if a program is running and is at a long Wait, and one of the If conditions change, how is the program re-run? Does it wait for the first execution to complete or does it terminate what's running to run it again with the new conditions? TIA Edited November 6 by smorgasbord Quote
larryllix Posted November 6 Posted November 6 (edited) If you call the program (If, Then, or Else), previous execution will be cancelled as soon as it encounters a Wait or Repeat command line. There is no threading/multitasking of a program. Run at Startup will execute the If section and consequentially run Then or Else. The program will self start after power up at 7:00 AM and 10:00 PM and run Then or Else respectively. Edited November 6 by larryllix Quote
smorgasbord Posted November 6 Author Posted November 6 (edited) Thanks. What about calling other programs? Will something like this work as expected: Repeat while $sOnVacay is not 0 Run Program 'Prog2' (Then Path) $sOnVacay -= 1 I understand that if a single program gets called while it's already running the previous instance of that running program will stop at Wait or Repeat, but if a program calls another program (which could even call a third program), is that all "normal" as an old "C" programmer would expect, or is the execution stack somehow different? Edited November 6 by smorgasbord Quote
smorgasbord Posted November 7 Author Posted November 7 I have thought that the "If" statement should actually be a "When" statement to help programmers understand the program invocation process. But, maybe that's just me. Quote
apostolakisl Posted November 9 Posted November 9 On 11/6/2024 at 1:27 PM, smorgasbord said: Thanks. What about calling other programs? Will something like this work as expected: Repeat while $sOnVacay is not 0 Run Program 'Prog2' (Then Path) $sOnVacay -= 1 I understand that if a single program gets called while it's already running the previous instance of that running program will stop at Wait or Repeat, but if a program calls another program (which could even call a third program), is that all "normal" as an old "C" programmer would expect, or is the execution stack somehow different? Not sure the context of "work as expected". But ISY is event driven, which is not like C. It is not driven by unchanging conditions, it only triggers on events. Your if clause must contain an item that has experienced an event or it will sit idle. Things that will make an if clause go include: 1) IF Status . . the status of the device must CHANGE 2) IF control . . . the specific control command must have happened. "control on" for example means the on paddle was pressed. Dimming up, switching off, etc do nothing. 3) Run at startup . . . startup of course is the trigger 4) A different program can cause the execution of an if clause with a "run if" command Once the "if" clause is triggered, then all of the conditions contained are tested for true/false status. Understand that instantaneous conditions like "control switched on" will always evaluate to false unless the trigger itself was that event. For example, a program that contained two "control switched . . " lines would never be true. And there would be no point in having a "run at startup" for a program that had a "control switched . . . " command since it would always be false (unless for some reason you wanted that program to run the else at startup). The above "repeat while" command will only be repeating if the then/else clause got started somehow. Either by the programs on "if" clause being triggered, or by some other program sending a "run then/run else/run if". Or of course a run at startup. 1 Quote
smorgasbord Posted November 9 Author Posted November 9 (edited) 13 hours ago, apostolakisl said: But ISY is event driven, which is not like C. It is not driven by unchanging conditions, it only triggers on events. Yes, I understand that part, which is why I think of a program's "If" condition as a "When" condition. Instead of: "if a control is switched on," I think: "When a control is switched on." That help me, might or might not help others. What I was talking about, and have since figured out, is about how the execution/call stack works. Turns out the ISY/EISY does NOT have a stack. When a first program calls a second program, that second program starts and runs in its own "instance" or "context" (to use C programmer nomenclature). More importantly, the first program does not stop and wait for the second program to finish and "return" to the first program. Instead, both programs are now running simultaneously (or as close as the OS can support). BTW, using the Notification plug-in to send numerous notifications to my UD Mobile app revealed a lot to me about how programs run on the EISY. Edited Sunday at 04:21 AM by smorgasbord 1 Quote
xlurkr Posted November 10 Posted November 10 2 hours ago, smorgasbord said: Instead of: "if a control is switched on," I think: "When a control is switched on." That help me, might or might not help others. Helps me. I have an Omnipro, which uses "When" in its automation rules, and an Elk, which uses "Whenever". Both styles help me remember that nothing gets executed unless an event happens. -Tom Quote
oberkc Posted Sunday at 02:32 PM Posted Sunday at 02:32 PM 23 hours ago, apostolakisl said: For example, a program that contained two "control switched . . " lines would never be true. firther clarification….whether or not such a program would or could be true would be dependent upon the logical operator (and? Or?) and also upon whether there are other conditions within the IF statement. Quote
larryllix Posted Sunday at 06:42 PM Posted Sunday at 06:42 PM 4 hours ago, oberkc said: firther clarification….whether or not such a program would or could be true would be dependent upon the logical operator (and? Or?) and also upon whether there are other conditions within the IF statement. If I need to force Then to run on [Run at Startup] I use an Else line to redirect. If xxxx control switched on Then need these lines to run at startup Else Run 'this program' (Then) Of course there is always some instances where this isn't possible. This technique is good for lights that need to turned off and complex multi program logic that may need to be reset. Quote
apostolakisl Posted Thursday at 05:06 PM Posted Thursday at 05:06 PM On 11/10/2024 at 12:42 PM, larryllix said: If I need to force Then to run on [Run at Startup] I use an Else line to redirect. If xxxx control switched on Then need these lines to run at startup Else Run 'this program' (Then) Of course there is always some instances where this isn't possible. This technique is good for lights that need to turned off and complex multi program logic that may need to be reset. I'm pretty sure a blank "if" clause evaluates as true during a "run at startup" and hence, you get execution of the "then" without any "else" clause needed. Quote
apostolakisl Posted Thursday at 05:14 PM Posted Thursday at 05:14 PM On 11/10/2024 at 8:32 AM, oberkc said: firther clarification….whether or not such a program would or could be true would be dependent upon the logical operator (and? Or?) and also upon whether there are other conditions within the IF statement. Yeah, I should have been more clear. No two "control switched x" can ever be true simultaneously, but the "if" clause can be true if you connect them with "or". And for anyone new to ISY, a little trick is to connect two opposites with control. In this fashion, one program will be able to do 2 things. In this way, both hitting the on paddle and hitting the off paddle are triggers. The on paddle goes true, the off paddle goes false. If control switched on or not control switched off then do something else do something else 1 Quote
larryllix Posted 23 hours ago Posted 23 hours ago 11 hours ago, apostolakisl said: I'm pretty sure a blank "if" clause evaluates as true during a "run at startup" and hence, you get execution of the "then" without any "else" clause needed. Agreed, but the Else redirect is required if a Control On off is present in the If section. This avoids further program usage to permit [Run at Startup] to function since, as you above logic, a Control X condition will never be true unless that event called the evaluation. Run at Startup would always evaluate False and run Else, and not start any looping program lines. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.