Please login or register.

Login with username, password and session length
Pages: 1 [2]

Author Topic: ELSE confusion and Flag Trouble  (Read 63757 times)

Walt2

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 28
  • Posts: 787
Re: ELSE confusion and Flag Trouble
« Reply #15 on: January 01, 2007, 08:01:36 AM »

I just want to be sure that people understand that an "ELSE" clause is not a true programming, logical else.  I have been writting code for over 30 years in many languages and believe me, a "True" else is from the "IF - Then - Else" mathematical reasoning (Originally established in boolean algebra, hopefully thats lost to history....).   A True Else has NO Options.  It Can ONLY execute if the "THEN" clause doesn't execute. 

If the macros contain an initial Delay statement

Then it is perceived as "IF ... THEN {Delay ...}; IF ... THEN {...};" statement.

Else it is perceived as "IF ... THEN {...}  ELSE IF ... THEN {....}" statement.
Logged
* Sears Home Control System, Radio Shack Plug 'n Power, NuTone, Stanley LightMaker, BSR, HomeLink.
* Tecmar Device Master, CP290 (LightHouse), CM11A (AH), CM14A (AH2), CM15A (AHPro).

Walt2

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 28
  • Posts: 787
Re: ELSE confusion and Flag Trouble
« Reply #16 on: January 01, 2007, 02:57:16 PM »

The firing even seems to be intermittant.  I am going to run a few test cases, but the amount of macros and timers loaded seems to have an effect on how intermittant this really is.  

In thinking about this a bit more, possibly one needs to always re-check conditions of the (first) "Then" macro, in the "Else" macro, and not simply assume that if the "Else" macro is running, they are false.  This should help handle those intermittent cases when both the "Then" macro is triggered and so is the "Else" macro.

Though, rechecking all conditions, in every level of "Else" macro(s), could lead to too many conditions ? ? ? ?
Logged
* Sears Home Control System, Radio Shack Plug 'n Power, NuTone, Stanley LightMaker, BSR, HomeLink.
* Tecmar Device Master, CP290 (LightHouse), CM11A (AH), CM14A (AH2), CM15A (AHPro).

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 283
  • Posts: 10509
  • I don't work for X10, I use it successfuly!
Re: ELSE confusion and Flag Trouble
« Reply #17 on: January 01, 2007, 03:44:07 PM »

What I want to do...

If M1 On AND Nighttime Then A1 On /* If motion and it is dark, turn on outside lights */

If M1 On Then A2 On /* If motion always ring the announce chime */

AHPro will "link" the second macro to the first, as the first's "ELSE" no?   And my announce chime will
only ring when it is not Nighttime?

I am so confused....   ???
I think Art and I are reading this differently!

Do you walt want the chime to always ring ?
only when it isn't dark?
only when it is day time?

You Don't need to use the delay function for any of this!
Infact if you do and X10 does see the delay as a bug and removes it you'll wonder why your macros stopped working the way thay had in the past. ;) :D
Depending on what you want to do will dictate the wording in the macros!
The way you have it worded now the chime only will trigger when it is not night time.
To have it always ring add the "A2 On" to the first macro as well.

Art: I realize your not trying to destroy the elses!
Your trying to figure how to get the most out of a bug(hidden command  ???) as you can!
I look forward to reading all your findings! ;) :D ;D
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

EL34

  • Hero Member
  • *****
  • Helpful Post Rating: 21
  • Posts: 278
    • My X-10 projects
Re: ELSE confusion and Flag Trouble
« Reply #18 on: January 07, 2007, 06:34:53 AM »

I too do some programmimg and I assumed AHP's else worked properly when I bought the smart marcro plug-in.  >:(
Just trying to nail down how the else really works, cause I have had problems with it.

In programming
first statement is tested-> if true-do this statement
If not true do else.

if the else has a condition it's an elsif not an else and this stement is tested for true.

Exactly what does having a delay at the beginning of the else do or don't do?
Could someone nail this down/define ir for me?
appreciate it.
Logged
W10 - CM15A - AHP 3.301 - i Witness - MyHouse online - Smart Macros - SDK using Visual Basic express 2008
My X10 page-> http://www.el34world.com/Misc/home/X10_0.htm

Walt2

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 28
  • Posts: 787
Re: ELSE confusion and Flag Trouble
« Reply #19 on: January 07, 2007, 08:54:07 AM »

Could someone nail this down/define ir for me?
appreciate it.

I don't think that one can nail it down, such that is works the exact same way 100% of the time.
Logged
* Sears Home Control System, Radio Shack Plug 'n Power, NuTone, Stanley LightMaker, BSR, HomeLink.
* Tecmar Device Master, CP290 (LightHouse), CM11A (AH), CM14A (AH2), CM15A (AHPro).

EL34

  • Hero Member
  • *****
  • Helpful Post Rating: 21
  • Posts: 278
    • My X-10 projects
Re: ELSE confusion and Flag Trouble
« Reply #20 on: January 07, 2007, 09:28:46 AM »

Boy that sucks!
How can AHP get away with crap like that?

I'm going to go set up a couple simple macros and see what kind of behavior I get with and without a delay as the first instruction.
Logged
W10 - CM15A - AHP 3.301 - i Witness - MyHouse online - Smart Macros - SDK using Visual Basic express 2008
My X10 page-> http://www.el34world.com/Misc/home/X10_0.htm

ArtClark

  • Guest
Re: ELSE Confusion and Flag Trouble
« Reply #21 on: January 07, 2007, 06:28:39 PM »

Just so you can look at some tests that have been already done, try reading through the Empty ELSE Oddity thread.  Some testing with DELAYs has been done there.  Of course, much more needs to be posted as to these tests.  (I went quite nuts and have far too many pages of results to try to post here.  Much of it is obvious anyway....)

The simple result for the delay effect that Puck observed is:

  • ELSE clauses execute if the previous clause does not (Normal) unless there is a DELAY as the first command of an executed ELSE.  If there is a DELAY, *ALL* ELSE clauses execute according to their individual conditions, but NOT requiring the previous clause to have failed.

    I.E.  If you have a Macro with 5 ELSE clauses and all 5 conditions are met and a DELAY as the first command in the Macros, then *ALL* 5 Macros will execute.  (Neat little option for multiple macro triggering....)

I know of no posted complete test to check on macros executed from the PC or any of the multiple options with both CM15A and PC in operation, but this first part is tested and verified.

Good Luck.  There are many related posts that when added together gives a very solid definition of the ELSE's behavior.


[TTA Edit: Replaced reference to another thread with LINK to thread; formatted.]
« Last Edit: April 26, 2007, 08:59:46 AM by TakeTheActive »
Logged

Walt2

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 28
  • Posts: 787
Re: ELSE confusion and Flag Trouble
« Reply #22 on: January 08, 2007, 08:34:28 AM »


The simple result for the delay effect that Puck observed is:
  Else clauses execute if the previous clause does not (Normal) unless there is a delay as the first command of an executed else.  If there is a delay, ALL else clauses execute according to their individual conditions, but NOT requiring the previous clause to have failed.


Though, apparently one also needs a delay (1 second) if the macro deals with a security sensor (OnAlert plugin).  So, it might not always be that clean with adding a delay or not (competing requirements between Smart Macro plugin and OnAlert plugin work arounds).

There is also the problem I ran into, were two separately coded up macros (didn't use the "add Else" function) get executed as if they were a Then ... Else pair anyway. 
Logged
* Sears Home Control System, Radio Shack Plug 'n Power, NuTone, Stanley LightMaker, BSR, HomeLink.
* Tecmar Device Master, CP290 (LightHouse), CM11A (AH), CM14A (AH2), CM15A (AHPro).

Puck

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 171
  • Posts: 1799
Re: ELSE confusion and Flag Trouble
« Reply #23 on: January 08, 2007, 09:17:25 AM »

Though, apparently one also needs a delay (1 second) if the macro deals with a security sensor (OnAlert plugin).

I recently re-did my whole setup due to the addition of OnAlert, and I did not need 1 second delays in my security macros. The only times I've found that I needed to add a delay at the start of a macro is when the first thing that macro does is call a phantom module (I.E. another macro). If that macro is part of an ELSE string, then I do something real before the delay. Right now, I clear unused Flag 16 before the delay. This has been working for me.

Quote
There is also the problem I ran into, were two separately coded up macros (didn't use the "add Else" function) get executed as if they were a Then ... Else pair anyway. 

Are the two macros using the same address / trigger?
When you edit one, does the other appear with it in an ELSE link?
Logged

Walt2

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 28
  • Posts: 787
Re: ELSE confusion and Flag Trouble
« Reply #24 on: January 08, 2007, 12:56:46 PM »

I recently re-did my whole setup due to the addition of OnAlert, and I did not need 1 second delays in my security macros. The only times I've found that I needed to add a delay at the start of a macro is when the first thing that macro does is call a phantom module (I.E. another macro). If that macro is part of an ELSE string, then I do something real before the delay. Right now, I clear unused Flag 16 before the delay. This has been working for me.

Actually, I was referring to one of your own thread references.  :D

Re: sensor won't trigger modules
Logged
* Sears Home Control System, Radio Shack Plug 'n Power, NuTone, Stanley LightMaker, BSR, HomeLink.
* Tecmar Device Master, CP290 (LightHouse), CM11A (AH), CM14A (AH2), CM15A (AHPro).

Walt2

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 28
  • Posts: 787
Re: ELSE confusion and Flag Trouble
« Reply #25 on: January 08, 2007, 01:02:07 PM »

Are the two macros using the same address / trigger?
When you edit one, does the other appear with it in an ELSE link?

Yep.

Yep.

However, answering the question posed of how AH Pro programming relates to "real" programming, in "real" programming, a second "IF" statement doesn't automatically become the "ELSE" to the preceding first "IF" statement.  In AH Pro, it can.

In other words, in AH Pro, one gets an implied "ELSE" even when one does not use the Create Else link.

I know that tripped me up, and I am sure it trips up other "real" programmers.  Maybe it falls into the "inconsistent with the rest of the world" bucket, instead of the "bug" bucket.
Logged
* Sears Home Control System, Radio Shack Plug 'n Power, NuTone, Stanley LightMaker, BSR, HomeLink.
* Tecmar Device Master, CP290 (LightHouse), CM11A (AH), CM14A (AH2), CM15A (AHPro).

Puck

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 171
  • Posts: 1799
Re: ELSE confusion and Flag Trouble
« Reply #26 on: January 08, 2007, 01:32:04 PM »

Actually, I was referring to one of your own thread references.  :D

Re: sensor won't trigger modules

You had me confused here for a minute  :D
My reference came from this post Re: How to get a DS10A to trigger a Macro? to direct thutch to KDR's hi-lighted example. At the bottom of that thread, JMac did mention the 1 second delay which in this case, solved jimnfl problem. I just stated here that my security macros are triggering without the initial delay.  ;)  :)

Quote
... in "real" programming, a second "IF" statement doesn't automatically become the "ELSE" to the preceding first "IF" statement.  In AH Pro, it can.

In other words, in AH Pro, one gets an implied "ELSE" even when one does not use the Create Else link.

You are correct here, but one thing people have to keep in mind when using AHP software, is that the true operating system (the firmware) is hard-coded inside the CM15A. The add on plug-ins' abilities are limited by this, and that's probably why so many programming techniques are so unconventional. Not to mention, so many users are doing things that the programmers of these software packages never thought of or intended. If the firmware in the CM15A could be field upgraded, I'm sure a lot of these headaches could be eliminated.


« Last Edit: January 08, 2007, 02:06:35 PM by Puck »
Logged
Pages: 1 [2]
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.