X10 Community Forum

🖥️ActiveHome Pro => SDK => Topic started by: jeff on September 30, 2008, 12:12:14 PM

Title: Flags in SDK
Post by: jeff on September 30, 2008, 12:12:14 PM
How can I check flag status with SDK?

Does "queryplc", "flag1 on" work or is there something else?
Title: Re: Flags in SDK
Post by: EL34 on October 19, 2008, 07:15:05 AM
Not unless the flag are some sort of extended code.

Have a look at the SDK docs and see if there's something in there.
Title: Re: Flags in SDK
Post by: USdangerboy on December 28, 2008, 01:58:13 AM
Why use flags at all, you don't need them anymore!  You have an unlimited amount of them by using arrays now!  Just create an 4x integer array with Col0 = HouseCode, col1 = UnitID, col2 = Status, col3 = LightLevel (of course this could be three, as LightLevel 0 could mean OFF, but I'm only 5 hours into the SDK so I'll streamline it later) then make a function in your code to do array management and you only need a few lines of code to write and read the array and get/put all the data you need!

I put all my units in an array and track everything in there, so no need for flags at all!!  YAHOO!!  I connected it to an SQL DB and can now control everyting with ASP.NET on my little XP box ... excellent!!

My only trouble now is filtering all the many, many commands that are transmitted on event triggers; a motion sensor ON command seems to sometimes trigger up to 7 different transmissions.  I'm still looking around, but if anyone knows in this thread, hit me up pls!!!  THANKS!
Title: Re: Flags in SDK
Post by: EL34 on January 24, 2009, 07:14:40 AM
That's what I do also.

I have one array that just keeps track of on/off module status

if OnOff(a,10) = true then
'module is on
end if
Title: Re: Flags in SDK
Post by: USdangerboy on January 29, 2009, 04:31:53 PM
I actually setup two Arrays, one for units and one for comments/notes.

Code: [Select]
    Dim aryMyUnitStatus(31, 17) As Short
    Dim aryMyUnitNotes(31, 17) As String

This keeps the arrays small and I use the ASC function for the integer value of the housecode instead of using strings, considerably faster for large setups.

So basically, 65 is A, so i start with five and then use a 60 sub/add handler, so for example, if I want to add a note for unit C6, I use

Code: [Select]
aryMyUnitNotes(Asc("C") - 60), 6) = "EE facing SE on back pool deck"

So, of course, I have a function for processing data in and out of the arrays and everytime something fires, I see the note in the window (those notes are stored in the DB and I have an INIT procedure for that on startup that grabs a recordset and writes it to the array).  This way, I have unlimited If/Then potential in my logic.  Of course, I do ASSUME many of the units are actually in the state that was last set ... since I don't have all of my uints as two-way, so it's not flawless, I'm slowly replacing them, but time is not growing on trees at present :-)

Seems to work well so far, not totally perfected yet.  I really need to mark it against I/O on the database and see which is more stable/faster, but for now, it's doin the job ... more to come for sure!!