Please login or register.

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

Author Topic: When are flags recognized  (Read 28954 times)

spam4us

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 152
When are flags recognized
« on: September 27, 2007, 03:46:01 PM »

I want to turn a light on for 4 minutes then turn it off based on Trigger B1 (ActiveEye Motion Sensor).
I also want to sound a chime once every 10 seconds while motion is being sensed at the B1 ActiveEye.
I also have 2 monitored Housecode switches. One that's On if it's OK to turn on the light(D1 On).  Another if it's OK to sound the chime(D2 On).
I'm confused at to "when" a flag status gets recognized.
 Will this work?

Trigger B1 On
   If D1 On And If Flag2 Off
   Set Flag2 On (doesn't get turned off until Macro L1 below)
   Set F1 On (turn on light)
   Set C1 On (trigger for chime macro)
 else
  If Flag2 On    (will flag2 be recognized as ON the 1st time thru this execution or not until B1 is triggered again for a 2nd time?)
  OR D1 Off
   Set C1 On (trigger the chime module)
     (I only want the above else to execute if the light has already been turned on or if it's not OK to turn the light on (D1 is Off))

Trigger C1 On
   If D2 On And If flag3 off
    Set Flag3 On
    Set C9 On  (sound the Chime)
    Set L1 On (light disposition)
    delay 10 sec (so the chime doesn't continually sound)
    Set Flag3 Off
   Else
    If Flag3 On   (will flag3 be recognized as ON the 1st time thru this execution or when C1 gets triggered again for a 2nd time?)
   OR D2 OFF
     Set L1 On (light disposition)
         (I only want the above else to execute if the chime macro is in delay mode Or it's not OK to sound the chime (D2 is Off))

 
Trigger L1 On
    If flag5 off
     set Flag5 On
     Delay 4 minutes
     Set F1 Off (turn off the flood)
     Set Flag2 Off
     Set Flag5 Off

I've also read in an old post that flags are not recognized when running a macro on the PC.  Is this still true?

Thanks

Logged

Puck

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 171
  • Posts: 1799
Re: When are flags recognized
« Reply #1 on: September 27, 2007, 06:09:46 PM »

I've also read in an old post that flags are not recognized when running a macro on the PC.  Is this still true?

I have not had any problem with setting flags on Run from PC macros and using that flag's status with Store in Interface macros, and vise-versa.

I would like to see a macro posting of a problem that someone is having with this to do some experimenting. (Probably another firmware date code difference issue.)

I use OnAlert macros to set flags and use lots of store in interface macros to do different actions based on the status of those flags when normal active-eye motion sensors are triggered.

Quote
Trigger B1 On
   If D1 On And If Flag2 Off
   Set Flag2 On (doesn't get turned off until Macro L1 below)
   Set F1 On (turn on light)
   Set C1 On (trigger for chime macro)
 else
  If Flag2 On    (will flag2 be recognized as ON the 1st time thru this execution or not until B1 is triggered again for a 2nd time?)
  OR D1 Off
   Set C1 On (trigger the chime module)
     (I only want the above else to execute if the light has already been turned on or if it's not OK to turn the light on (D1 is Off))


Trigger C1 On
   If D2 On And If flag3 off
    Set Flag3 On
    Set C9 On  (sound the Chime)
    Set L1 On (light disposition)
    delay 10 sec (so the chime doesn't continually sound)
    Set Flag3 Off
   Else
    If Flag3 On   (will flag3 be recognized as ON the 1st time thru this execution or when C1 gets triggered again for a 2nd time?)
   OR D2 OFF
     Set L1 On (light disposition)
         (I only want the above else to execute if the chime macro is in delay mode Or it's not OK to sound the chime (D2 is Off))

 
Trigger L1 On
    If flag5 off
     set Flag5 On
     Delay 4 minutes
     Set F1 Off (turn off the flood)
     Set Flag2 Off
     Set Flag5 Off

1) Flag 2 should not be recognized as On the first time through for the ELSE. The key word is "should not"; if you are having problems just move the set Flag 2 On after the Set F1 ON. (Same principle for the C1 Macro.)

2) Keep in mind that the motion sensor has an ~10 second reset time between ON triggers, so to get repeating chimes you don't really need a delayed macro.

3)  What you are doing here seems more complex than need be; definitely hard to follow through and think of all possibilities. Basically you have 2 variables (conditions) D1 & D2 to decide what to do when B1 ON is triggered. I suggest that you make one macro string of Else's based on the different combinations of these  2 variables. Then you can use just a single Flag to prevent re-entry of ones that are not to occur during the 4 minute delay and no dummy modules (C1 & L1).
Logged

spam4us

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 152
Re: When are flags recognized
« Reply #2 on: October 09, 2007, 02:01:59 AM »

fyi

After some experimenting, in my example below, Flag2 is recognized as ON the first time thru the macro and because of this, both the initial if and the else statements are both executed the first time thru.

Trigger B1 On
   If D1 On And If Flag2 Off
   Set Flag2 On (doesn't get turned off until Macro L1 below)
   Set F1 On (turn on light)
   Set C1 On (trigger for chime macro)
 else
  If Flag2 On    (flag2 is recognized as ON the 1st time thru this execution)
      OR D1 Off
   Set C1 On (trigger the chime module)
     (I only want the above else to execute if the light has already been turned on or if it's not OK to turn the light on (D1 is Off))
Logged

Puck

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 171
  • Posts: 1799
Re: When are flags recognized
« Reply #3 on: October 09, 2007, 08:59:18 AM »

1) Flag 2 should not be recognized as On the first time through for the ELSE. The key word is "should not"; if you are having problems just move the set Flag 2 On after the Set F1 ON. (Same principle for the C1 Macro.)

Try moving the Set Flag 2 away from the start of the macro as suggested. This will prevent the ELSE macro from running 1st time through. Since there are no delays in the macro, maybe just put it as the last step.
Logged

spam4us

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 152
Re: When are flags recognized
« Reply #4 on: October 09, 2007, 10:36:32 AM »

I'll give it a try BUT moving the flag later in the macro opens it up to having it execute more often than needed thereby causing  more powerline activity.  B1 is an ActiveEye that will send multiple ONs when it detects motion. 

Another interesting thing that is happening is if I trigger B1 to run again during the 4 minute delay of Macro L1,  Macro C1 will not execute again UNTIL macro L1 has completed thru the delay. I've tried this with & without the 10 sec delay in Macro C1.  In the Activity monitor, the else statement of Macro B1 gets executed because I see it Set C1 On (trigger for chime macro) but Macro C1 itself does not execute.  Once Macro L1 has completed, then all the macros function as if it's the 1st time thru (which they should at this point).   It seems that Flag3 does not get cleared until Macro L1 is finished.

Thanks

Logged

Puck

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 171
  • Posts: 1799
Re: When are flags recognized
« Reply #5 on: October 09, 2007, 10:58:32 AM »

I'll give it a try BUT moving the flag later in the macro opens it up to having it execute more often than needed thereby causing  more powerline activity.  B1 is an ActiveEye that will send multiple ONs when it detects motion. 

The complete macro will take 1 to 2 seconds to complete and set the flag; the cycle time of the motion detector is longer than this. The lowest I have measured my ActiveEye's re-trigger rate was 6 seconds. So you should not get any re-triggering of that macro while it is executing.

Quote
Another interesting thing that is happening is if I trigger B1 to run again during the 4 minute delay of Macro L1,  Macro C1 will not execute again UNTIL macro L1 has completed thru the delay. I've tried this with & without the 10 sec delay in Macro C1.  In the Activity monitor, the else statement of Macro B1 gets executed because I see it Set C1 On (trigger for chime macro) but Macro C1 itself does not execute.  Once Macro L1 has completed, then all the macros function as if it's the 1st time thru (which they should at this point).   It seems that Flag3 does not get cleared until Macro L1 is finished.

This is why a real-time flag status monitor is needed. ;)
Logged

spam4us

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 152
Re: When are flags recognized
« Reply #6 on: October 09, 2007, 11:18:32 AM »

Puck,

     Thanks for the replies.  This is turning out to be hit or miss programming.  I wouldn't really call it programming either since things are so unpredictable :-[.  No wonder people get frustrated & want their money back or switch to another vendor. 

thanks again
Logged

spam4us

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 152
Re: When are flags recognized
« Reply #7 on: October 10, 2007, 10:57:46 AM »

Even more interesting......
     I set Flag3 Off in the L1 Macro just to see if it had any effect.  I ran a status report during the 4 minute delay and it showed Flag3 as being off YET, macro C1 did not trigger until AFTER the 4 minute delay in Macro L1.  It didn't matter where I cleared Flag3.  AHP waited until Macro L1 completed.

Trigger L1 On
    If flag5 off
     set Flag5 On
    set Flag3 Off
     Delay 4 minutes
     Set F1 Off (turn off the flood)
     Set Flag2 Off
     Set Flag5 Off

It seems like AHP is stacking all of the "Flag Off" commands until it gets to the end of a processing cycle.  I define a processing cycle as AHP following a sequential series of macros from beginning to end.  Seems as though it's doing something like this:


Trigger B1.....Trigger C1........Trigger L1......Flags2,3,5  off. 
instead of
Trigger B1.....Trigger C1....Flag3 off....Trigger L1.....Flag2 Off...Flag5 Off

Looks like the Flags On are processed during the processing cycle but the flags off are not processed until the cycle ends.


   
Logged

spam4us

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 152
Re: When are flags recognized
« Reply #8 on: October 11, 2007, 09:03:08 PM »

OK!  I did more testing (read hunting in the dark) and here's what is happening.
Here is the macro
Trigger B1 On
   If D1 On And If Flag2 Off
   Set Flag2 On (doesn't get turned off until Macro L1 below)
   Set F1 On (turn on light)
   Set C1 On (trigger for chime macro)
   If I "Set Flag2 Off" right here then this If statement always executes and the chime always sounds. If I take the "Set Flag2 Off" out & let it clear in Macro L1, then the chime doesn't sound until Macro L1 has completed. When I don't have the "Set Flag2 OFF" here, the else part of this macro executes and I can see in the Activity Monitor that C1 gets set On but the chime doesn't sound. else
  If Flag2 On    (will flag2 be recognized as ON the 1st time thru this execution or not until B1 is triggered again for a 2nd time?)
  OR D1 Off
   Set C1 On (trigger the chime module)
     (I only want the above else to execute if the light has already been turned on or if it's not OK to turn the light on (D1 is Off))


Trigger C1 On
   If D2 On And If flag3 off
    Set Flag3 On
    Set C9 On  (sound the Chime)
    Set L1 On (light disposition)
    delay 10 sec (so the chime doesn't continually sound)
    Set Flag3 Off
   Else
    If Flag3 On   (will flag3 be recognized as ON the 1st time thru this execution or when C1 gets triggered again for a 2nd time?)
   OR D2 OFF
     Set L1 On (light disposition)
         (I only want the above else to execute if the chime macro is in delay mode Or it's not OK to sound the chime (D2 is Off))

 
Trigger L1 On
    If flag5 off
     set Flag5 On
     Delay 4 minutes
     Set F1 Off (turn off the flood)
     Set Flag2 Off
     Set Flag5 Off

Can anyone explain why the chime Macro C1 doesn't run when it is triggered by the else statement in Macro B1?
Or
Can anyone explain why the Chime Macro C1 does run when I clear flag2 in blue above in the B1 Macro?

Is my CM15A defective???

Thanks

« Last Edit: October 11, 2007, 09:10:05 PM by spam4us »
Logged

Boiler

  • Guest
Re: When are flags recognized
« Reply #9 on: October 11, 2007, 10:32:59 PM »

spam4us,

What version of AHP are you running and what macros are being stored in the interface/PC. 

I'm running AHP 3.204 (OnAlert not installed) and have had similar problems setting flags from the PC.  I believe you replied to my post : Link-Macros calling Macros that set flags

I read Pucks post and don't doubt for an second that he has been successful in running macros from the PC and CM15a.  Possibly a difference in AHP (Puck is running 3.206 with OnAlert)?

If you are mixing your macro source (CM15a/PC) try downloading everything to the interface.





Logged

spam4us

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 152
Re: When are flags recognized
« Reply #10 on: October 11, 2007, 10:42:39 PM »

I'm running version 3.206.  All my macros are run from the interface. 
Logged

Puck

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 171
  • Posts: 1799
Re: When are flags recognized
« Reply #11 on: October 11, 2007, 11:27:38 PM »

Boiler: I am using 3.206 (OnAlert).

spam4us: (Just thinking out loud here)... You have a macro that calls a macro that calls another macro. We know that AHP does not treat each macro call as a subroutine, instead it attempts to run all of them simultaneously.  Even though the first macro call is the last command listed, that macro probably does not end (internally) do to software handling overhead, before the called macro tries to start executing. Maybe trying to get AHP to do too much at the same time causes these types of problems.  ??? On paper your macros are logical and correct, but it appears the way AHP handles them is not with the same logic. You may have to add a delay to the first macro to alter how & when it ends.  ???

Logged

spam4us

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 152
Re: When are flags recognized
« Reply #12 on: October 12, 2007, 02:17:17 AM »

Thanks to everyone who has replied and also Bill & Dave for your help in the chat room.  I now have this working.  In macro 1 (trigger B1) it would process correctly according to what I saw in the Activity monitor.  Once the flag was set the first time thru the macro, it would take the ELSE path the second time thru and set C1 on BUT the C1 macro would not run (the chime never made a sound). The Activity monitor showed the C1 being set ON.  Per Pucks suggestion, I put a delay into the ELSE path (see below) and also turned off a dummy module since putting the delay as the 1st step of the macro would always cause the else to execute when it shouldn't.  So now, Macro 1 (trigger B1) looks like this. (the 2 statements in maroon are the ones I added).

Trigger B1 On
   If D1 On And If Flag2 Off
   Set Flag2 On (doesn't get turned off until Macro L1 below)
   Set F1 On (turn on light)
   Set C1 On (trigger for chime macro)
   else
  If Flag2 On    (will flag2 be recognized as ON the 1st time thru this execution or not until B1 is triggered again for a 2nd time?)
  OR D1 Off
   Set P3 Off
   Delay 1 Second
   
   Set C1 On (trigger the chime module)
     
Now, Macro C1 sounds the chime and all is well.

I thank everyone for their help and I also hope this helps someone else out.  This shouldn't be this hard. It should have worked the way I originally had it.  It's hard to debug AHP macros because your not sure if you have a logic problem or you are dealing with a quirk (read.....undocumented feature.......  ;D) in AHP.

thanks again

Logged

Boiler

  • Guest
Re: When are flags recognized
« Reply #13 on: October 12, 2007, 08:59:16 PM »

spam4us,
Congratulations on your success and kudos for your persistence.

As Puck indicated, nothing obvious wrong with the logic in your previous post.  Unfortunately AHP does have it's quirks and execution flow is one of them.

I routinely use Delay 0 commands to separate various commands and logic functions.  I'm not sure if this is a AHP equivalent of a NOP (assembly language - no operation) but, like your delay 1, it works.

If you've ever tried programming in a graphical language (Labview for instance), you come to understand that order of execution is not at all obvious.  The same may be true with AHP.
Logged

spam4us

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 152
Re: When are flags recognized
« Reply #14 on: October 12, 2007, 10:27:07 PM »

Boiler,
Quote
NOP (assembly language - no operation)
you're showing your age......pretty soon we can talk about autocoder and hardwiring logic boards. ;D ;D ;D
I guess you can recognize the following
12
11
0
1
2
3
4
5
6
7
8
9
and you might even know who Grace Murray Hopper is and that the above is a 5081.
 :D ;D ;D ;D ;)
Logged
Pages: [1] 2
 

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