Announcement

Collapse
No announcement yet.

AbstractHsDevice vs HS.GetPropertyByRef

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    AbstractHsDevice vs HS.GetPropertyByRef

    Can anybody explain when I should use AbstractHsDevice to get/set properties vs HS.GetPropertyByRef?

    I.e if I want to set device Name/Address/Location, etc. It looks like AbstractHsDevice is only for creating new devices?

    And to work with existing devices I still use the HS interface? I was hoping that HST finally created proper OO class, but it doesn't seem to be the case?

    As I understand, say in my plugins I get device Name or Value etc. often - for each request it has to communicate with HS via remoting which creates a lot of overhead.

    So I created a base library for HS3 to avoid this and also simplify plugin creation. So my hope was that in HS4 it would be done in the new Plugin SDK.

    But it looks like it's not?

    I don't get when to use AbstractHsDevice.PlugExtraData vs HS.GetPropertyByRef(@ref, EProperty.PlugExtraData)?

    #2
    My experience is that working directly on the device object is hit and miss. Letting HS marshal the activities via Get and Update work for me.

    Comment


      #3
      And also, HS.UpdateFeatureValueStringByRef(@ref, value) vs. HS.UpdatePropertyByRef(@ref, EProperty.Status, value)?
      spud?

      Comment


        #4
        AbstractHsDevice (or rather HsDevice and Hsfeature) is used as a local copy of a device/feature in your plugin. The changes you make to this object are never sent to HS unless you call UpdateFeatureByRef,/UpdateDeviceByRef to send them in one call.

        to get a copy of the current device state from HS use GetDeviceByRef/GetFeatureByRef:

        Code:
        HsDevice hsDevice = HS.GetDeviceByRef(ref);
        then to change several properties and send them back to HS:

        Code:
        hsDevice.Name = "New Name";
        hsDevice.Location = "New Location";
        
        HS.UpdateDeviceByRef(hsDevice.Ref, hsDevice.Changes);
        To be honest I rarely use UpdateDeviceByRef/UpdateFeatureByRef in my plugins and tend to use UpdatePropertyByRef instead when I have to change one property like Name or PlugExtraData, but I see how it could be useful if you want to send multiple changes as one bundle.


        HS.UpdateFeatureValueStringByRef(@ref, value) is equivalent to HS3 HS.SetDeviceString(@ref, value, true)
        whereas
        HS.UpdatePropertyByRef(@ref, EProperty.Status, value) is equivalent to HS3 HS.SetDeviceString(@ref, value, false)

        same thing for UpdateFeatureValueByRef vs UpdatePropertyByRef

        I think I always use UpdateFeatureValueByRef / UpdateFeatureValueStringByRef to update a value / status because I don't see when you would want to update a value/status without triggering the associated events.

        Comment


          #5
          Thank you spud for detailed info.

          Comment

          Working...
          X