Page 1 of 1
Creating Properties
Posted: Tue Mar 16, 2004 8:01 pm
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
Posted: Tue Mar 16, 2004 9:41 pm
by ScottBot
Try using [0 - 100] for the value (brackets included).
Posted: Tue Mar 16, 2004 9:44 pm
by ericvic
Scott,
Thanks, I'll try that.
Eric
Posted: Tue Mar 16, 2004 10:06 pm
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
Posted: Wed Mar 17, 2004 9:33 am
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.
Posted: Wed Mar 17, 2004 10:06 am
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
Posted: Wed Mar 17, 2004 10:16 am
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.
Posted: Wed Mar 17, 2004 10:26 am
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