Read Only Properties

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

Read Only Properties

Post by ericvic »

Is there the ability to have read only properties for devices, so that the user wouldn't be able to even try to change the value from the GUI.



I know the device could just return false when something tried to change the property but it would be nice to have the GUI disallow and try to change the value.



Eric
Circe640
Advanced Member
Posts: 206
Joined: Tue Oct 07, 2003 10:01 am
Location: Columbus, OH
Contact:

Set them up in the GUI so they are Property Labels

Post by Circe640 »

If you set them up in the GUI as property label controls, the user cannot change them~!!! IF you use a property edit controls, then they can change them.
ericvic
Senior Member
Posts: 144
Joined: Thu Feb 26, 2004 11:06 am
Location: Irondale, AL
Contact:

Post by ericvic »

That's good to know. You are talking about in a theme, correct? What I was referring to was the main HouseBot GUI.



Thanks,

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

Post by ScottBot »

No, the standard Property Values do not support read-only. In my grand design, you could specify whether a Property value was input, output, or both (you can see this in the register property function). The idea was that you could restrict the UI based on the type of property and it might also help when creating Task conditions and even Theme control assignments.



But I never implemented it. :(



One thing you could do for your thermostat control, is register a Property Button and then show your own UI for setting up the Device. This would allow you to display a graphical representation of the time/temperature schedule (if you really want to get into it) and would allow you to make properties read-only if you would like. Unfortunately, if you keep your own settings, the values won't be accessible from Tasks or Theme controls.
Scott
ScottBot
Site Admin
Posts: 2787
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

Eric,



How bad do you need a read-only property, and would you want it to always be read-only or would it sometimes be read/write?



It might be easy enough to simply lock the Property Control for that value and use the 'eIOType' setting to indicate its read-only state. You wouldn't be able to change to to read/write later though.



Scott
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 reply. I think I will use the standard property interface for the thermostat control (I don't think I will have any read only properties for that device anyway). I was mainly asking out of curiosity and for future reference if I end up making the LynX-10 PLC plug-in. That device has some interesting info that you can get from it like how many X-10 collisions/retries, etc... I wanted to be able to present it to the GUI as a property but as read only.



Eric
Circe640
Advanced Member
Posts: 206
Joined: Tue Oct 07, 2003 10:01 am
Location: Columbus, OH
Contact:

Here's a little cheat around it

Post by Circe640 »

In the pluging you can receive property change notifications if a property in your plugin is changed in housebot. It is the way your plugin reacts to HouseBot. If you receive a change on a property you consider Read-Only simply react and change it back to the value in the pluging itself.
ericvic
Senior Member
Posts: 144
Joined: Thu Feb 26, 2004 11:06 am
Location: Irondale, AL
Contact:

Post by ericvic »

I figured that I could just let the device chage it back once it got the notification. That what the system time device seems to do with the weekday property but to me it is cleaner if the GUI keeps you from changing read only properties.



Sorry for dragging this thread out but this is what I do all day for a job and I'm kinda picky about the GUI. That is one reason I'm trying to make the switch from HomeSeer.



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

Post by ericvic »

Scott,



It's not a major issue, I can keep it from being set when I get notified that it changed.



For the read only properties that I'm thinking of they would always be read only externally and only changed inside the plug-in.



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

Post by ScottBot »

No, no... now you've got me engaged. I've already made the changes to the server to handle this.



Next I'm going to update all of the Device Properties to correctly flag their read-only devices. Unfortunately it will only take effect for new Devices created, since the ioFlag is stored in the DB when the Device is first created.



I'll have to update the help as well, but I like the read-only effect. I've never really liked the fact that you could change these. It added to the confusion, which is what 2.0 is supposed to be solving. The System Time Device that you mentioned is the biggest and most visible example of where it doesn't make sense to change the values, but it seems as though you can.
Scott
ericvic
Senior Member
Posts: 144
Joined: Thu Feb 26, 2004 11:06 am
Location: Irondale, AL
Contact:

Post by ericvic »

Scott,



Would a device still be able to set the value for it's own read only properties?



Also where do you set the 'eIOType'? I looked through a few of tghe classes and didn't see anything.



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

Post by ScottBot »

ericvic wrote:Would a device still be able to set the value for it's own read only properties?
Yes. It's only read-only from the 'user' side. The Property Control won't even give you the opportunity to change it, but it can be changed by the Device. For example, I've changed the System Time Device to have all read-only properties. They continue to update as before, but the UI no longer allows you to modify them (a small lock is shown next to the read-only properties).
ericvic wrote:Also where do you set the 'eIOType'? I looked through a few of tghe classes and didn't see anything.
When registering Device properties you can set it. Look at the pHB_RegisterDeviceProperty() and pHB_RegisterDevicePropertyUsingWizard() callback functions in DeviceAPI.h and you will see it as an argument. If you set it to ioInputOnly, it will be read-only. It's not called 'read-only' because my original model had the idea of a graphical method of connecting properties, so the inputs would go to the outputs. It's the same idea, just represented a bit differently than you might think. Note that this is for the Device SDK only. The Hardware SDK is not consistent with the way it handle Properties, since they are really a different kind of property.



This may not actually help you at all if you are thinking of showing the properties in the Hardware Property view. If you have the hardware propagate the values along to all its Devices (through subscription notifications), you can show the data from the interface in your Devices.
Scott
ericvic
Senior Member
Posts: 144
Joined: Thu Feb 26, 2004 11:06 am
Location: Irondale, AL
Contact:

Post by ericvic »

Scott,



I'm confused on the use of pHB_RegisterDeviceProperty and pHB_CreateDeviceProperty. Can you explain a bit more about how properties are created and stored or direct me to some documentation that I can read.



Thanks,

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

Post by ScottBot »

It's probably not documented clearly anywhere :oops:



The system comes with a slew of stock Properties you can use when creating your own Device. You can see these from the Property Manager (Settings/Property Manager... from the main menu). Devices can share the same Property, but can only have a maximum one of each property (as defined by its Name).



So generally, you should look through the list of Properties and see if you can find one that has a type like the type you need and a name that somewhat expresses the purpose of the Property. If you find stock properties, you won't need to create them yourself, which saves a step. If you don't find a stock property that you want to use, you can create your own dynamically with pHB_CreateDeviceProperty().



When doing this, you only want to create the Property the first time, so you will need code in your ::RegisterProperties method that goes something like below that first tries to register the property. If the registration fails, it can assume that it is because the property doesn't exist. It can then create the property and try to register it again.

Code: Select all

if (!m_CallBackInfo.pHB_RegisterDevicePropertyUsingWizard( m_CallBackInfo.m_hModuleHandle, nDeviceNumber, "New Property", ...))
{
   if (!m_CallBackInfo.pHB_CreateDeviceProperty( "New Property", ... ))
      return( FALSE );

   if (!m_CallBackInfo.pHB_RegisterDevicePropertyUsingWizard( m_CallBackInfo.m_hModuleHandle, nDeviceNumber, "New Property", ... ))
      return( FALSE );

   return( TRUE );
}


So the bottom line is to try an use an existing Property if you can with pHB_RegisterDeviceProperty (or pHB_RegisterDevicePropertyUsingWizard if you want the Wizard to prompt for the value during Device creating).
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.



It is probably staring me in the face but how to I add what the valid values are for a property? i.e. I'm going to have a fan property that should have 'on' and 'auto'.



Also I am going to need a read-only property for the thermostat for the current temp so I'll get beta 4 tonight and try it out.



Eric
Post Reply