Property readonly
Property readonly
How to prohibit editing of property by the user in Device Plugin?
Re: Property readonly
If you are creating your own Device using the SDK, set the 'eIOType ioType' parameter of the 'pHB_RegisterDeviceProperty' call to 'ioInputOnly'.
Scott
Re: Property readonly
Thanks. Still a question. How to set restriction of entered values, for example from 0 to 100?
Re: Property readonly
If you have derived a class from the CHardwareInterface class, you just need to call or pHB_SetPropertyLimits if not using CHardwareInterface. Call it right after you register the Property (RegisterHardwareModuleProperty).
Code: Select all
CHardwareInstance::SetPropertyLimits( const char* szPropertyName, int nLowLimit, int nHighLimit )
Scott
Re: Property readonly
It in Hardware Interface Plugin. I have not found the same function in Device Plugin?
Re: Property readonly
You're right. Sorry I was confused.DsA wrote:It in Hardware Interface Plugin. I have not found the same function in Device Plugin?
You can't restrict what a user will enter for a Property Value. The best you can do is to offer suggestions by associating Property Values to a Property by calling pHB_CreateDevicePropertyValue() when registering a new Property for the first time.
You can still generate an error or just refuse to change the Device Property in the plugin if the user tries to change the Property to an invalid value.
Scott
Re: Property readonly
I create properties calling pHB_CreateDevicePropertyValue () but how thus to set values of properties? It is possible a code example?
Re: Property readonly
Here's a snippet from the ::RegisterProperties() method of a Device plugin.
Code: Select all
// First attempt to register the Property (wizard version of registration that has prompt)
if (!m_CallBackInfo.pHB_RegisterDevicePropertyUsingWizard( m_CallBackInfo.m_hModuleHandle,
nDeviceNumber,
"Insteon Group",
"Group", FALSE,
"1",
ioInputAndOutput,
TRUE,
TRUE,
FALSE,
FALSE,
"Enter the group number" ))
{
// The registration failed. This is probably because this is the first time the property is being registered.
// Attempt to create the new "Insteon Group" Property.
if (!m_CallBackInfo.pHB_CreateDeviceProperty( "Insteon Group", "Group", ptNumeric ))
return( FALSE );
// The Property created successfully. We can optionally add values to the Property.
// This example creates numeric values from 1 to 256
m_CallBackInfo.pHB_CreateDevicePropertyValue( "Insteon Group", "[1 - 256]" );
// If not adding a sequential numeric range like above, call pHB_CreateDevicePropertyValue() for
// each value to be added to the Property.
// m_CallBackInfo.pHB_CreateDevicePropertyValue( "Insteon Group", "1" );
// m_CallBackInfo.pHB_CreateDevicePropertyValue( "Insteon Group", "2" );
// m_CallBackInfo.pHB_CreateDevicePropertyValue( "Insteon Group", "3" );
// Now that the Property has been created, we can try and register it again (same call as at the top)
if (!m_CallBackInfo.pHB_RegisterDevicePropertyUsingWizard( m_CallBackInfo.m_hModuleHandle,
nDeviceNumber,
"Insteon Group",
"Group",
FALSE,
"1",
ioInputAndOutput,
TRUE,
TRUE,
FALSE,
FALSE,
"Enter the group number" ))
return( FALSE );
}
Scott
Re: Property readonly
I thank, all works =)
Re: Property readonly
I've attached a dll with the read-only Temperature property (ioInputOnly). I believe the device has to be recreated for ioInputOnly (should it not be rather called ioOutputOnly ?) to take effect.
- Attachments
-
- TemperPlugin.rar
- (13.24 KiB) Downloaded 1404 times
Re: Property readonly
Scott,
Just an FYI;
The comments in DeviceAPI.h say "ioType - Not currently used, but can/should be set correctly."
- Ed
Just an FYI;
The comments in DeviceAPI.h say "ioType - Not currently used, but can/should be set correctly."
- Ed