JoelBender / BACpypes3

BACnet communications library
33 stars 7 forks source link

Proprietary objects registration #16

Open ChristianTremblay opened 8 months ago

ChristianTremblay commented 8 months ago

What is the best way to register proprietray objects for a specific vendor ?

Let say I have a manufacturer vendor id and the implementation details on their object. In bacpypes, there was register_object_type

In bp3, I see a similar register_object_class but part of the VendorInfo class. Should I create a VendorInfo class ?

Or should I share what I have so it's part of bp3 as those infos are public ?

ChristianTremblay commented 8 months ago

I saw the custom example which looks interesting. Even if, I think it is meant for local objects (served by bacpypes app).

I think it would be nice to have something similar to load an existing vendor (or create if not in cache) to specify proprietary objects and properties.

# extract from what I would do to extend JCI objects
class ProprietaryPropertyIdentifier(PropertyIdentifier):
    """
    This is a list of the property identifiers that are used in custom object
    types or are used in custom properties of standard types.
    """
    # AV, AI, AO
    FLOW_SP_EEPROM = 3113
    Offset = 956
    Offline = 913
    SABusAddr = 3645
    PeerToPeer = 748
    P2P_ErrorStatus = 746
    InputRangeLow = 1293
    InputRangeHigh = 1294
    OutputRangeLow = 1295
    OutputRangeHigh = 1296
    MIN_OUT_VALUE = 652
    MAX_OUT_VALUE = 653
    #polarity = polarity
    stroketime = 3478

class AnalogInputObject(_AnalogInputObject):
    Offset: Real
    Offline: Boolean
    SABusAddr: Unsigned
    InputRangeLow: Real
    InputRangeHigh: Real
    OutputRangeLow: Real
    OutputRangeHigh: Real

class AnalogValueObject(_AnalogValueObject):
    FLOW_SP_EEPROM: Real
    Offset: Real
    Offline: Boolean
    SABusAddr: Unsigned
    PeerToPeer: Atomic
    P2P_ErrorStatus: Enumerated

class AnalogOutputObejt(_AnalogOutputObject):
    Offline: Boolean
    SABusAddr: Unsigned
    MIN_OUT_VALUE: Real
    MAX_OUT_VALUE: Real
    #polarity = polarity
    stroketime: Real
JoelBender commented 8 months ago

I saw the custom example which looks interesting. Even if, I think it is meant for local objects (served by bacpypes app).

It's for both clients and servers. For clients the module should import from the "vanilla" classes like AnalogValueObject from the bacpyes3.object module. For servers it inherits from the "local" classes to get the default behavior. The sample client application happens to not create instances of the objects which is a bit of a dodge.

I think it would be nice to have something similar to load an existing vendor (or create if not in cache) to specify proprietary objects and properties.

If the vendor wanted to distribute a Python module for their definitions that would be awesome, and a bit surprising! It's more likely that they would publish a CSML document, which could then be translated into Python and RDF classes. If you know any existing CSML documents we could try, double check the licensing for public consumption and we'll work on that.