Creating Properties

HouseBot Plugin Development Discussions.
Post Reply
ericvic
Senior Member
Posts: 144
Joined: Thu Feb 26, 2004 11:06 am
Location: Irondale, AL
Contact:

Creating Properties

Post by ericvic »

Scott,



I've been creating properties in my plug-ins using the example you gave me a while back but now I need to create a property that has a range of 0-100 and I don't really want to enter gCallBackInfo.pHB_CreateDevicePropertyValue() 100 times. Is there a way to create a range of valid values?



Thanks,

Eric
ScottBot
Site Admin
Posts: 2787
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

Try using [0 - 100] for the value (brackets included).
Scott
ericvic
Senior Member
Posts: 144
Joined: Thu Feb 26, 2004 11:06 am
Location: Irondale, AL
Contact:

Post by ericvic »

Scott,



Thanks, I'll try that.



Eric
ericvic
Senior Member
Posts: 144
Joined: Thu Feb 26, 2004 11:06 am
Location: Irondale, AL
Contact:

Post by ericvic »

Scott,



Another question. I'm trying to reset a property to No during the processing when it is being set to Yes (like your messagebox example and I'm doing this:

Code: Select all

if ((pChangedValue->GetOwningProperty() == mGetStatus) &&
    (0 == strcmp( pChangedValue->GetPropertyValue(), "Yes")))
    {
    SendX10(mHouseCode->GetPropertyValueAsString(), mUnitCode->GetPropertyValueAsString(), "Status Request", 0);

    // Now change the value back to "No".
    CPropertyValue* pNoValue = mGetStatus->CreatePropertyValue("No");
    if (pNoValue)
        {
        pNoValue->ChangeRequestCompleted();
        delete pNoValue;
        }
    }
It doesn't work. Can you see what I'm doing wrong?



Thanks,

Eric
ScottBot
Site Admin
Posts: 2787
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

Eric,



The code looks fine to me.



Check out the "History" tab for the property to make sure that it is indeed NOT getting reset to "No".



I just fixed a bug in the sample MessageBox Device where the Device was changing the value to "No", but then after that resetting it back to "Yes" by committing the original Property Change request.
Scott
ericvic
Senior Member
Posts: 144
Joined: Thu Feb 26, 2004 11:06 am
Location: Irondale, AL
Contact:

Post by ericvic »

Scott,



I think that is my problem because later in the code it "commits" the original change.



What do I need to change to not have it do that. I wasn't sure if I could just delete the property change without "commiting" or "rollingback" the change.



Thanks,

Eric
ScottBot
Site Admin
Posts: 2787
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

Don't just delete it. It will cause a memory leak.



If using the CPropertyValue class, you can call:
  • ChangeRequestCompleted - Which will make the change stick.
  • ChangeRequestFailed - Which will not make the change stick and probably display an error of some kind.
  • ChangeRequestAbandoned - This just drops it. I think this is what you want, but I don't know off the top of my head what state it will leave the value in. I don't know if it will roll it back, or just leave it.
I generally just use ChangeRequestCompleted and then change it back again as in the MessageBox sample. It may seem a bit odd, but from a user/transaction standpoint it makes some sense since everything that begins also ends.



If you're not using the CPropertyValue class, there are also equivalent callback functions in the raw API.
Scott
ericvic
Senior Member
Posts: 144
Joined: Thu Feb 26, 2004 11:06 am
Location: Irondale, AL
Contact:

Post by ericvic »

Scott,



Thanks for the info. I have an idea of how I can change it and I will try that when I get home tonight.



Eric
Post Reply