Jump to content

New ISY99i User - WAIT programming


f11

Recommended Posts

My apologies if this has been discussed already... I did a Search and didn't come up with quite enough detail. I'm a new ISY99i user trying to get my first programs running. I have sufficient programming experience in my past to get me over the beginner stuff, but the details of ISY-specific programming were a little "thin" in the User Guide.

 

Anyway, I wrote what I thought was a basic program:

 

If

On Mon, Tue, Wed, Thu

Time is 6:50:00AM

And (

Status 'MBRM - 00.65.BE.1' is Off

)

 

Then

Set 'MBRM - 00.65.BE.1' On

Wait 5 minutes

Set 'Fireplace - 00.47.B5.1' On

Wait 5 minutes

Set 'Stairs - 00.65.8F.1' On

 

Else

- No Actions - (To add one, press 'Action')

 

I assumed the WAIT command would cause the THEN section to continue executing until the timers ran out (10 minutes later). But it doesn't. The program runs at 6:50AM, turns on the MBRM light and thats it.

 

What is the rule with the WAIT command? Am I using it incorrectly, or had I misinterpreted what its supposed to do?

 

THanks for the help!

Rod

Link to comment

Hi Rod [f11--cool handle 8) ], welcome to the forum!

 

The problem isn't the Wait, but rather that your MBRM device is part of the If condition, and is also changed within your program. When it is changed, the If becomes False, and the program immediately stops.

 

To achieve your goal, you can use two programs, similar to:

 

Program 'Part I'
If
       On Mon, Tue, Wed, Thu
       Time is 6:50:00AM
   And Status 'MBRM - 00.65.BE.1' is Off
Then
   Run program 'Part II'
Else
   - No Actions - (To add one, press 'Action')

Program 'Part II'
If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
Then
   Set 'MBRM - 00.65.BE.1' On
   Wait 5 minutes
   Set 'Fireplace - 00.47.B5.1' On
   Wait 5 minutes
   Set 'Stairs - 00.65.8F.1' On
Else
   - No Actions - (To add one, press 'Action')

 

Hope this helps!

Link to comment

So the IF conditional expression is evaluated, the THEN segment is initiated, but the WAIT does not cause the execution to idle in the THEN segment - instead the IF segment is continually being evaluated and when it goes false, the THEN segment is halted regardless of the WAIT command.

 

I think of WAIT in the context of a multi-threaded multi-tasking OS like QNX when I coded in C (showing my age) - I can't recall what the actual command was, but you could block/idle a thread waiting for some condition to go true or a timer to expire before continuing in that segment.

 

But as you say, the relationship between the IF and the THEN/ELSE isn't sequential, its parallel - the IF is always being evaluated, so a WAIT command in the THEN segment of a program with a quickly changing conditional in the IF segment may never get a chance to execute. So I have to dissociate my IF from my THEN statements to avoid that situation, or as you say, break the program into two pieces as you show. Thanks!!!

 

My "f11" handle (or my alternate, "feleven") is all over the internet, in most of the forums I've joined since about 1999. It short, easy to spell, and was originally related to my fascination with the F111-F fighter jet.

 

Rod

Link to comment
So the IF conditional expression is evaluated, the THEN segment is initiated, but the WAIT does not cause the execution to idle in the THEN segment - instead the IF segment is continually being evaluated and when it goes false, the THEN segment is halted regardless of the WAIT command.

Yes, you are correct. The If is (re-)evaluated each time one of the conditions changes.

 

I think of WAIT in the context of a multi-threaded multi-tasking OS like QNX when I coded in C (showing my age) - I can't recall what the actual command was, but you could block/idle a thread waiting for some condition to go true or a timer to expire before continuing in that segment.

 

But as you say, the relationship between the IF and the THEN/ELSE isn't sequential, its parallel - the IF is always being evaluated, so a WAIT command in the THEN segment of a program with a quickly changing conditional in the IF segment may never get a chance to execute. So I have to dissociate my IF from my THEN statements to avoid that situation, or as you say, break the program into two pieces as you show. Thanks!!!

There is some discussion in this thread about adding some programming capabilities in a future version of the firmware.

 

My "f11" handle (or my alternate, "feleven") is all over the internet, in most of the forums I've joined since about 1999.

Yep, I've seen ya, fellow Canuck :wink: !

 

It short, easy to spell, and was originally related to my fascination with the F111-F fighter jet.

 

Aw, shucks! So it didn't originate in going IBM one better with the original PC keyboard (which had only F1 - F10 keys). :lol:

Link to comment

Ah! That thread on programming you pointed me to is something I should have read before I started coding... it does explain what I had to find out the hard way regarding the If-Then-Else construct execution.

 

As impressed as I already am with the diminutive ISY pkg (I also come from a long history of X10 use, starting with a VIC-20 running a BASIC program controlling an expansion card to manage my house lights in the mid-80s, then that was replaced with a CP290 controller, and later the flakey X10 programmable wall modules and their frustrating software), the User Guide sure could use better sections on the command structure, including non-trivial examples. Also, there is virtually no discussion on the purpose of Folders vs Programs, or examples where one would be used instead of the other. And I may have missed it in the UG, but I don't remember reading that I have to "Save" my programs to the ISY after creation or changes, something I figured out for myself.

 

Rod

Link to comment

feleven!

 

You are 100% correct vis-a-vis the user guide. Since user guide is embedded in ISY thus it will not reflect all the changes/additions that our loyal forum members are contributing on a daily basis to our Wiki site. I think/hope you will find most of the information that you are looking for in our Wiki site (Help->UDI Wiki).

 

With kind regards,

Michel

 

Ah! That thread on programming you pointed me to is something I should have read before I started coding... it does explain what I had to find out the hard way regarding the If-Then-Else construct execution.

 

As impressed as I already am with the diminutive ISY pkg (I also come from a long history of X10 use, starting with a VIC-20 running a BASIC program controlling an expansion card to manage my house lights in the mid-80s, then that was replaced with a CP290 controller, and later the flakey X10 programmable wall modules and their frustrating software), the User Guide sure could use better sections on the command structure, including non-trivial examples. Also, there is virtually no discussion on the purpose of Folders vs Programs, or examples where one would be used instead of the other. And I may have missed it in the UG, but I don't remember reading that I have to "Save" my programs to the ISY after creation or changes, something I figured out for myself.

 

Rod

Link to comment

Michel, pls don't misunderstand - I know this product is evolving and things are still being done for it... and I really like it!!

 

But a product that is essentially a programmable controller with a non-standard programming syntax needs good docs to be useful. At least the essential components of the syntax HAVE to be spelled out properly and illustrated with non-trivial examples. And I shouldn't have to go looking to find them.

 

I'd expect on or two "2-Lamp Configuration Examples" somewhere in the docs for a new user, where you show a complete working configuration for two lamplinc'd lights, one using just programs, and another showing how a folder might be useful. The official doc'n should either contain that complete configuration, or point new users to the "wiki" location where it can be viewed and printed off without effort. At least that's my expectation in regard to programmable equipment doc's.

 

Anyway, I'll review the "wiki" site and see what I can learn there. I still don't understand why or when I'd use a Program vs a Folder or vice versa.

 

BTW, the IF-THEN-ELSE construct is more like WHILE-ELSE-WEND I've seen in other environments... at least the WHILE gives a better idea how that segment works vs IF.

 

Rod

Link to comment

BTW, the IF-THEN-ELSE construct is more like WHILE-ELSE-WEND I've seen in other environments... at least the WHILE gives a better idea how that segment works vs IF.

 

We may change the terms in the GUI at some point, but the best way to think of it is as follows:

 

Think of Then as Becomes True.

Think of Else as Becomes False.

 

In other words, when the IF condition changes:

1) If the program is currently running it is stopped,

2) either the Then or the Else will start from the beginning depending on whether the condition is True or False

Link to comment

Well, when I see WHILE, I think "there is an element of time involved here". So I assume that the conditional is constantly being re-evaluated and that the subsequent action is tied to its being TRUE or FALSE, as in:

 

iVar=1

While (iVar)

Do [TRUE action

Some other actions

iVar=0]

Else [FALSE action]

Wend

 

WHILE constructs always reminded me of checking the gas gauge in the car - you keep checking and as long as the gauge shows fuel, you keep driving the car. If it shows empty, then you have to stop driving and pick up fuel. IF-THEN-ELSE always seemed more like a fork in the road I'm driving on, a decision taken just once and then you go on your way.

 

Anyway, I get your message - IF-THEN-ELSE aren't used the same as I recall from other environments. Thanks!

 

Rod

Link to comment

The problem isn't the Wait, but rather that your MBRM device is part of the If condition, and is also changed within your program. When it is changed, the If becomes False, and the program immediately stops.

 

To achieve your goal, you can use two programs, similar to:

 

Program 'Part I'
If
       On Mon, Tue, Wed, Thu
       Time is 6:50:00AM
   And Status 'MBRM - 00.65.BE.1' is Off
Then
   Run program 'Part II'
Else
   - No Actions - (To add one, press 'Action')

Program 'Part II'
If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
Then
   Set 'MBRM - 00.65.BE.1' On
   Wait 5 minutes
   Set 'Fireplace - 00.47.B5.1' On
   Wait 5 minutes
   Set 'Stairs - 00.65.8F.1' On
Else
   - No Actions - (To add one, press 'Action')

 

Might another alternate be


If
       On Mon, Tue, Wed, Thu
       Time is 6:50:00AM
   And Status 'MBRM - 00.65.BE.1' is Off
Then
   Set 'MBRM - 00.65.BE.1' On
Else
Wait 5 minutes
   Set 'Fireplace - 00.47.B5.1' On
   Wait 5 minutes
   Set 'Stairs - 00.65.8F.1' On


 

where the first condition is true and executes the 'then' which in turn effectively makes the first condition false and the program then reverts to the 'else'?

Link to comment
Might another alternate be


If
       On Mon, Tue, Wed, Thu
       Time is 6:50:00AM
   And Status 'MBRM - 00.65.BE.1' is Off
Then
   Set 'MBRM - 00.65.BE.1' On
Else
Wait 5 minutes
   Set 'Fireplace - 00.47.B5.1' On
   Wait 5 minutes
   Set 'Stairs - 00.65.8F.1' On


 

where the first condition is true and executes the 'then' which in turn effectively makes the first condition false and the program then reverts to the 'else'?

 

Zellerman, that's cool 8) ! I haven't tested it, but it looks like it should work. Maybe Chris or Michel could confirm?

Link to comment

I tested it, and it does work, up to a point.

 

It works fine when the 'MBRM' is off, otherwise it always runs the Else. Not the intention of the original program.

 

Any time the Status of 'MBRM' changes the program runs again.

 

'MBRM' = 'Family Room Swag Lamp' in this example:

 

If
       Time is  5:15:00PM
   And Status  'Family Room Swag Lamp' is Off

Then
       Set 'Family Room Swag Lamp' Fast On

Else
       Wait  30 seconds
       Set 'Family Room Lava Lamp' Fast On
       Wait  30 seconds
       Set 'Family Room Track Lights' Fast On



 

Every time the Status of the watched device changes it seems that all programs that are watching for a Status changes in that device are run. Since the Time in this program is not often true the program runs the Else.

 

Rand

Link to comment

I guess a program is really always running, unless it's some how by-passed, contrary to my own 'personal logic' where it would only start if the 'if' were true. :)

I don't have my ISY yet, so technically I'm not even a newbie yet, but I'm trying to get a head start on the learning curve. Thanks for running the test.

Link to comment
I guess a program is really always running, unless it's some how by-passed, contrary to my own 'personal logic' where it would only start if the 'if' were true. :)

I don't have my ISY yet, so technically I'm not even a newbie yet, but I'm trying to get a head start on the learning curve. Thanks for running the test.

 

I think that you are confusing "Run" with "Enabled". I believe that in the ISY terminology, "Run" means "Executing the Then or Else statements".

 

"Enable" means "constantly evaluate the 'IF' statement to determine when the Run or Else statements need to be Run".

 

Best wishes,

Link to comment
I guess a program is really always running, unless it's some how by-passed, contrary to my own 'personal logic' where it would only start if the 'if' were true. :)

....

 

Yes, that bothers me too. I thought the program would only run at 5:15:00PM. I have been playing with this. I can put it in a folder that has a time condition and then it will only run during that time window (For 10 minutes) but the same thing happens for 10 minutes. Every time I change the Status of 'MBRM' the Else executes. I have to limit the time window to about 5 seconds.

 

Rand

Link to comment

Archived

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


  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

  • Forum Statistics

    • Total Topics
      36.9k
    • Total Posts
      370.2k
×
×
  • Create New...