Please login or register.

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

Author Topic: Need more than 16 flags?  (Read 16909 times)

troll334

  • Hero Member
  • *****
  • Helpful Post Rating: 11
  • Posts: 159
Need more than 16 flags?
« on: January 31, 2011, 10:56:53 AM »

Hey Guys,
I've run out of flags. Needing more, I walked into the think-tank.
Remember that binary numbering system?  Someone back in '05 eluded
to using multiple flags for testing conditions. So I thought I'd
expand on that for anyone that needs more than 16 flags.
Admittedly, this will require you to document your macros lest ye
be caught in a whirlpool of numbers downing in your own creativity :)
Switch your mindset to binary and realize up to 65,536 flags (2^16)!
Though I don't think I've experienced this...for those of you
concerned about AHP using flags 15,16 for dawn/dusk, that would
still leave you with 14 flags (16,384) with which to apply to the
binary method.
So, here we go:
Flag 1 remains flag 1.
Flag 2 remains flag 2.
This is where it starts to change.
The third new flag (binary 0011) is now Flags 1 and 2 both set.
The fouth new flag (binary 0100) is now Flag 4 (only) set.
The fifth is now Flags 4 and 1 both set.
And so on...ad infinitum (well, almost)
Decimal to binary conversion is beyond the scope of this posting.
Suffice it to say, if you want to learn some binary, you'll get
all the flags you'll ever need and then some.
And yes, you could use some dummy modules along with the binary
thing and work more pseudo flags than your PC's addressing system
can likely handle; at least in our lifetimes :). Another story...
have fun!
Logged
AHP 3.236. CM15A. XTB-IIR. XTBM. Hauppauge 950Q.

Noam

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 51
  • Posts: 2818
Re: Need more than 16 flags?
« Reply #1 on: January 31, 2011, 11:10:54 AM »

Hey Guys,
I've run out of flags. Needing more, I walked into the think-tank.
Remember that binary numbering system?  Someone back in '05 eluded
to using multiple flags for testing conditions. So I thought I'd
expand on that for anyone that needs more than 16 flags.
Admittedly, this will require you to document your macros lest ye
be caught in a whirlpool of numbers downing in your own creativity :)
Switch your mindset to binary and realize up to 65,536 flags (2^16)!
Though I don't think I've experienced this...for those of you
concerned about AHP using flags 15,16 for dawn/dusk, that would
still leave you with 14 flags (16,384) with which to apply to the
binary method.
So, here we go:
Flag 1 remains flag 1.
Flag 2 remains flag 2.
This is where it starts to change.
The third new flag (binary 0011) is now Flags 1 and 2 both set.
The fouth new flag (binary 0100) is now Flag 4 (only) set.
The fifth is now Flags 4 and 1 both set.
And so on...ad infinitum (well, almost)
Decimal to binary conversion is beyond the scope of this posting.
Suffice it to say, if you want to learn some binary, you'll get
all the flags you'll ever need and then some.
And yes, you could use some dummy modules along with the binary
thing and work more pseudo flags than your PC's addressing system
can likely handle; at least in our lifetimes :). Another story...
have fun!


That sounds like a great idea, but I've heard some people recommend avoiding flag #1, too (leaving you with only 13 usable flags - or 8192 possible binary numbers - which should still be plenty).

However, what happens if you need to use more than one flag at the same time?
How would you represent, for example, that flags #1 and 2 are on?

binary 01 is flag 1, and binary 10 is flag 2. If both are on, you get binary 11, which is the same as binary flag 3.

That could be a problem.

Have you thought of a way to overcome this?
Logged

HA Dave

  • Hero Member
  • *****
  • Helpful Post Rating: 175
  • Posts: 7127
Re: Need more than 16 flags?
« Reply #2 on: January 31, 2011, 11:39:31 AM »

I've run out of flags. Needing more, I walked into the think-tank.
Remember that binary numbering system?  ..................
Flag 1 remains flag 1.
Flag 2 remains flag 2.
This is where it starts to change.
The third new flag (binary 0011) is now Flags 1 and 2 both set.
The fouth new flag (binary 0100) is now Flag 4 (only) set.
The fifth is now Flags 4 and 1 both set.
And so on...ad infinitum (well, almost)

troll334 that is brillant!!! Of course... a HELPFUL from me. It would be nice to see some tests and more details about setting this up... for those of us like myself that went to state run schools. And... is there anyway I could spend some time in your think-tank?  It sounds like the place to be. This reminds me of.... relays and punch cards?

I think this may be just the idea needed to get S.A.R.A. moving.
Logged
Home Automation is an always changing technology

Brandt

  • Hero Member
  • *****
  • Helpful Post Rating: 11
  • Posts: 728
  • Sorry miss, I was giving myself an oil-job.
Re: Need more than 16 flags?
« Reply #3 on: January 31, 2011, 12:15:05 PM »

You would have to set multiple flags for each condition

Example to use "Flag" 25: ( 00011001 ):

IF ( Flag1 && Flag4 && Flag5 ) isSet; THEN turn on TV;

So you need to take care of un-setting the flags after you are done checking them.
Logged

Noam

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 51
  • Posts: 2818
Re: Need more than 16 flags?
« Reply #4 on: January 31, 2011, 12:37:15 PM »

You would have to set multiple flags for each condition

Example to use "Flag" 25: ( 00011001 ):

IF ( Flag1 && Flag4 && Flag5 ) isSet; THEN turn on TV;

So you need to take care of un-setting the flags after you are done checking them.

How do you tell is 00011001 is flag "25" or if it it both flag "24" (00011000) and flag "1" (00000001) both being on at the same time?
Logged

troll334

  • Hero Member
  • *****
  • Helpful Post Rating: 11
  • Posts: 159
Re: Need more than 16 flags?
« Reply #5 on: January 31, 2011, 01:25:57 PM »

Hey Noam, Dave.
Talk about brilliant...I need Noam in the think-tank as well :)
You are correct about that flaw. I just fired the guys in the think-tank (me).  B:(
It doesn't matter what you try, there always seems to be the possibility of a duplicate...e,g,. if you want to use
new flag 81 (binary 01010001) and test on new flag 17 (binary 00010001), it'll be true. Even if you tried using the
AND operator (xor) to test for "Flags Set AND Flags Cleared", you'll still end up with conflicts.
So, we're back to 16 flags but still able to use phantom modules (on the monitored HC) in conjunction. So, what does
that give us? 256 possibilities (assuming you've got no real devices on the monitored HC)? Nope, not even...
Back to the drawing board on this one.
Noam  #:)
sorry Dave. Take back that Helpful. I screwed the pooch on that one.
« Last Edit: January 31, 2011, 01:31:53 PM by troll334 »
Logged
AHP 3.236. CM15A. XTB-IIR. XTBM. Hauppauge 950Q.

Brandt

  • Hero Member
  • *****
  • Helpful Post Rating: 11
  • Posts: 728
  • Sorry miss, I was giving myself an oil-job.
Re: Need more than 16 flags?
« Reply #6 on: January 31, 2011, 01:59:03 PM »

since when does AND = XOR? it doesn't. If you AND them all together properly, I don't see why it wouldn't work...


You would have to do something like this (not exact syntax):

FLAG25=((Flag1 && Flag4 && Flag5 ) && (!(Flag2 && Flag3 && Flag6 && Flag7 && Flag8)))

FLAG25 being some sort of environment variable in Windows.
Logged

HA Dave

  • Hero Member
  • *****
  • Helpful Post Rating: 175
  • Posts: 7127
Re: Need more than 16 flags?
« Reply #7 on: January 31, 2011, 02:56:55 PM »

.......  sorry Dave. Take back that Helpful. I screwed the pooch on that one.

I only feel sorry for the pooch. And... I think Brandt has a point as well.

I use a pencil and paper as well as a calculator just to balance my checkbook.... and that requires far smaller and fewer numbers. So I am sure the math is over my head. But if only 4 of the 16 monitored addresses was used in combination with the 16 flags with the "and"... in my mind... that sounds like 16X4 new addresses right there. Not that they haven't ALWAYS been there. Just not thought of as a method to use them.
« Last Edit: January 31, 2011, 03:01:34 PM by Dave_x10_L »
Logged
Home Automation is an always changing technology

Noam

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 51
  • Posts: 2818
Re: Need more than 16 flags?
« Reply #8 on: January 31, 2011, 02:58:48 PM »

since when does AND = XOR? it doesn't. If you AND them all together properly, I don't see why it wouldn't work...


You would have to do something like this (not exact syntax):

FLAG25=((Flag1 && Flag4 && Flag5 ) && (!(Flag2 && Flag3 && Flag6 && Flag7 && Flag8)))

FLAG25 being some sort of environment variable in Windows.

If you don't mind leaving your CM15A tethered to the PC, and leave AHP running all the time, then you CAN, theoretically, have an unlimited number of flags.
Instead of using flags, just create macros that set environment variables (easier to do now that we can pass command line parameters from a macro).
Then, write a scrip that uses those environment variables, and have it run whatever commands you want (either calling other AHP macros, or just send them one at a time using AHCMD).
Logged

Brandt

  • Hero Member
  • *****
  • Helpful Post Rating: 11
  • Posts: 728
  • Sorry miss, I was giving myself an oil-job.
Re: Need more than 16 flags?
« Reply #9 on: January 31, 2011, 03:00:43 PM »

+1 on that Noam. I'm all about scripts ;)
Logged

HA Dave

  • Hero Member
  • *****
  • Helpful Post Rating: 175
  • Posts: 7127
Re: Need more than 16 flags?
« Reply #10 on: January 31, 2011, 03:16:59 PM »

..........  If you don't mind leaving your CM15A tethered to the PC, and leave AHP running all the time, then you CAN, theoretically, have an unlimited number of flags.
Instead of using flags, just create macros that set environment variables (easier to do now that we can pass command line parameters from a macro). Then, write a scrip that uses those environment variables,...

+1 on that Noam. I'm all about scripts ;)

Didn't someone... ihouse(?) already include an all X10 addresses monitoring in their software? Or... is this a new software opportunity? I know there was a time when many people bulked at running a PC 24/7... or hesitated at trusting HA functions to a computer. But I think... those days are behind us. Software products and Home Automation... are one and the same... IMHO.
Logged
Home Automation is an always changing technology

troll334

  • Hero Member
  • *****
  • Helpful Post Rating: 11
  • Posts: 159
Re: Need more than 16 flags?
« Reply #11 on: January 31, 2011, 04:28:17 PM »

Hey Gents,
Brandt, I'm sure AND = XOR on the other side of some worm-hole :) But, in our world, of course, AND != XOR.
Having said that, my use of XOR was a lame attempt at implying the use of a masking technique by including
"AND Flags x,y,z NOT SET" along with the ones of interest. But that still doesn't cut it, thanks to Noam's exploration
of the idea. Further, I was attempting to keep flag usage inside of AHP w/o shelling out the the OS. Should
have stated that. Further, the idea of using monitored HC's / phantom modules does not appear to work either.
It's logic too, fails almost immediately.
I'll shut up until I have something good and proven to work (inside AHP w/o shelling out).
have a great day!
Logged
AHP 3.236. CM15A. XTB-IIR. XTBM. Hauppauge 950Q.

Fan of Zappa

  • Jr. Member
  • **
  • Helpful Post Rating: 1
  • Posts: 20
Re: Need more than 16 flags?
« Reply #12 on: May 14, 2011, 04:32:49 PM »

Hey guys,
We all seem to be running out of flags. I've been working on a batch file, but I don't know how to implement it into AHP. To use it the command is FLAG SET/CHECK/CLEAR FLAGNUMBER . Make sure you set the drive and directory in the Flag.bat file before running from the command line. Flag.bat must reside in the parent directory of \flags. If you guys can figure out how to pass the flag info to AHP we can all have all the flags we want.

@echo off
Rem Flag.bat  by Bob Barr (Fan of Zappa)

set Flagdrv=C:
set flagdir=\House stuff\flags\

rem if %1 == NUL Goto usage - not working yet.... I'm stupid sometimes
if %1 == set Goto set
if %1 == clear Goto clear
if %1 == check goto check

:set
cd %flagdir%
copy flag0.txt flag%2.txt
goto end

:clear
cd %flagdir%
del flag%2.txt
goto end

:check
cd %flagdir%
rem if exist flag%2.txt (echo Flag%2 is set) else echo flag%2 is clear.
if exist flag%2.txt goto true else goto false

:false
echo flag%2 is clear
goto end

:true
echo flag%2 is set
goto end

:usage
echo flag set/clear/check num (1-256)

:end
cd..



Well that's it. It may be amateurish but it will set a flag, clear a flag, and check the state of a flag.

-Bob
Logged
Fan of Zappa - His music was way before it's time and died way before his time!

Fan of Zappa

  • Jr. Member
  • **
  • Helpful Post Rating: 1
  • Posts: 20
Re: Need more than 16 flags?
« Reply #13 on: May 14, 2011, 04:41:11 PM »

Forgot one very important thing. Sorry! The file "flag0.txt which must be in the flags directory was created in notepad and contains only the word "set". But it could contain anything as long as there is a file there names flag0.txt
Logged
Fan of Zappa - His music was way before it's time and died way before his time!

ITguy

  • Sr. Member
  • ****
  • Helpful Post Rating: 8
  • Posts: 105
Re: Need more than 16 flags?
« Reply #14 on: May 14, 2011, 05:26:55 PM »

Very creative!

Another option is to just switch to iHouse!  An UNLIMITED number of flags, and allows flag "values" of anything you want, instead of just on or off!  It's open-source and available for download FREE at: http://www.ihousehomeautomation.com/phpBB/viewforum.php?f=33

And Dave_x10_L, you're right about the monitoring! 

ITguy
Logged
Pages: [1] 2
 

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