Skip to content

Commit

Permalink
bring up-to-date with the 0.16.7 release
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelBender committed Feb 17, 2018
1 parent 86d0f1c commit e07ab58
Show file tree
Hide file tree
Showing 15 changed files with 1,033 additions and 221 deletions.
13 changes: 9 additions & 4 deletions py25/bacpypes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ class BIPSimpleApplication(ApplicationIOController, WhoIsIAmServices, ReadWriteP

def __init__(self, localDevice, localAddress, deviceInfoCache=None, aseID=None):
if _debug: BIPSimpleApplication._debug("__init__ %r %r deviceInfoCache=%r aseID=%r", localDevice, localAddress, deviceInfoCache, aseID)
ApplicationIOController.__init__(self, localDevice, deviceInfoCache, aseID=aseID)
ApplicationIOController.__init__(self, localDevice, localAddress, deviceInfoCache, aseID=aseID)

# local address might be useful for subclasses
if isinstance(localAddress, Address):
Expand Down Expand Up @@ -528,9 +528,14 @@ def close_socket(self):

class BIPForeignApplication(ApplicationIOController, WhoIsIAmServices, ReadWritePropertyServices):

def __init__(self, localDevice, localAddress, bbmdAddress, bbmdTTL, aseID=None):
if _debug: BIPForeignApplication._debug("__init__ %r %r %r %r aseID=%r", localDevice, localAddress, bbmdAddress, bbmdTTL, aseID)
ApplicationIOController.__init__(self, localDevice, aseID=aseID)
def __init__(self, localDevice, localAddress, bbmdAddress, bbmdTTL, deviceInfoCache=None, aseID=None):
if _debug:
BIPForeignApplication._debug(
"__init__ %r %r %r %r deviceInfoCache=%r aseID=%r",
localDevice, localAddress, bbmdAddress, bbmdTTL,
deviceInfoCache, aseID,
)
ApplicationIOController.__init__(self, localDevice, localAddress, deviceInfoCache, aseID=aseID)

# local address might be useful for subclasses
if isinstance(localAddress, Address):
Expand Down
41 changes: 27 additions & 14 deletions py25/bacpypes/basetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,16 @@ class ErrorType(Sequence):
, Element('errorCode', ErrorCode)
]

class LightingCommand(Sequence):
sequenceElements = \
[ Element('operation', LightingOperation, 0)
, Element('targetLevel', Real, 1, True)
, Element('rampRate', Real, 2, True)
, Element('stepIncrement', Real, 3, True)
, Element('fadeTime', Unsigned, 4, True)
, Element('priority', Unsigned, 5, True)
]

class ObjectPropertyReference(Sequence):
sequenceElements = \
[ Element('objectIdentifier', ObjectIdentifier, 0)
Expand Down Expand Up @@ -1792,8 +1802,21 @@ class CalendarEntry(Choice):
]

class ChannelValue(Choice):
choiceElements = [
### needs help
choiceElements = \
[ Element('null', Null)
, Element('real', Real)
, Element('enumerated', Enumerated)
, Element('unsigned', Unsigned)
, Element('boolean', Boolean)
, Element('integer', Integer)
, Element('double', Double)
, Element('time', Time)
, Element('characterString', CharacterString)
, Element('octetString', OctetString)
, Element('bitString', BitString)
, Element('date', Date)
, Element('objectidentifier', ObjectIdentifier)
, Element('lightingCommand', LightingCommand, 0)
]

class ClientCOV(Choice):
Expand Down Expand Up @@ -2068,16 +2091,6 @@ class KeyIdentifier(Sequence):
, Element('keyId', Unsigned, 1)
]

class LightingCommand(Sequence):
sequenceElements = \
[ Element('operation', LightingOperation, 0)
, Element('targetLevel', Real, 1) ### optional
, Element('rampRate', Real, 2) ### optional
, Element('stepIncrement', Real, 3) ### optional
, Element('fadeTime', Unsigned, 4) ### optional
, Element('priority', Unsigned, 5) ### optional
]

class LogDataLogData(Choice):
choiceElements = \
[ Element('booleanValue', Boolean, 0)
Expand Down Expand Up @@ -2336,14 +2349,14 @@ class PriorityValue(Choice):
, Element('enumerated', Enumerated)
, Element('unsigned', Unsigned)
, Element('boolean', Boolean)
, Element('signed', Integer)
, Element('integer', Integer)
, Element('double', Double)
, Element('time', Time)
, Element('characterString', CharacterString)
, Element('octetString', OctetString)
, Element('bitString', BitString)
, Element('date', Date)
, Element('objectid', ObjectIdentifier)
, Element('objectidentifier', ObjectIdentifier)
, Element('constructedValue', Any, 0)
, Element('datetime', DateTime, 1)
]
Expand Down
120 changes: 108 additions & 12 deletions py25/bacpypes/bvllservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,54 @@ def confirmation(self, pdu):
# send it upstream
self.response(xpdu)

elif isinstance(pdu, WriteBroadcastDistributionTable):
# build a response
xpdu = Result(code=0x0010, user_data=pdu.pduUserData)
xpdu.pduDestination = pdu.pduSource

# send it downstream
self.request(xpdu)

elif isinstance(pdu, ReadBroadcastDistributionTable):
# build a response
xpdu = Result(code=0x0020, user_data=pdu.pduUserData)
xpdu.pduDestination = pdu.pduSource

# send it downstream
self.request(xpdu)

elif isinstance(pdu, RegisterForeignDevice):
# build a response
xpdu = Result(code=0x0030, user_data=pdu.pduUserData)
xpdu.pduDestination = pdu.pduSource

# send it downstream
self.request(xpdu)

elif isinstance(pdu, ReadForeignDeviceTable):
# build a response
xpdu = Result(code=0x0040, user_data=pdu.pduUserData)
xpdu.pduDestination = pdu.pduSource

# send it downstream
self.request(xpdu)

elif isinstance(pdu, DeleteForeignDeviceTableEntry):
# build a response
xpdu = Result(code=0x0050, user_data=pdu.pduUserData)
xpdu.pduDestination = pdu.pduSource

# send it downstream
self.request(xpdu)

elif isinstance(pdu, DistributeBroadcastToNetwork):
# build a response
xpdu = Result(code=0x0060, user_data=pdu.pduUserData)
xpdu.pduDestination = pdu.pduSource

# send it downstream
self.request(xpdu)

else:
BIPSimple._warning("invalid pdu type: %s", type(pdu))

Expand Down Expand Up @@ -446,11 +494,6 @@ def __init__(self, addr=None, ttl=None, sapID=None, cid=None, sid=None):
def indication(self, pdu):
if _debug: BIPForeign._debug("indication %r", pdu)

# check the BBMD registration status, we may not be registered
if self.registrationStatus != 0:
if _debug: BIPForeign._debug(" - packet dropped, unregistered")
return

# check for local stations
if pdu.pduDestination.addrType == Address.localStationAddr:
# make an original unicast PDU
Expand All @@ -462,6 +505,11 @@ def indication(self, pdu):

# check for broadcasts
elif pdu.pduDestination.addrType == Address.localBroadcastAddr:
# check the BBMD registration status, we may not be registered
if self.registrationStatus != 0:
if _debug: BIPForeign._debug(" - packet dropped, unregistered")
return

# make an original broadcast PDU
xpdu = DistributeBroadcastToNetwork(pdu, user_data=pdu.pduUserData)
xpdu.pduDestination = self.bbmdAddress
Expand Down Expand Up @@ -498,6 +546,13 @@ def confirmation(self, pdu):

return

elif isinstance(pdu, OriginalUnicastNPDU):
# build a vanilla PDU
xpdu = PDU(pdu.pduData, source=pdu.pduSource, destination=pdu.pduDestination, user_data=pdu.pduUserData)

# send it upstream
self.response(xpdu)

# check the BBMD registration status, we may not be registered
if self.registrationStatus != 0:
if _debug: BIPForeign._debug(" - packet dropped, unregistered")
Expand All @@ -511,20 +566,61 @@ def confirmation(self, pdu):
# send this to the service access point
self.sap_response(pdu)

elif isinstance(pdu, OriginalUnicastNPDU):
# build a vanilla PDU
xpdu = PDU(pdu.pduData, source=pdu.pduSource, destination=pdu.pduDestination, user_data=pdu.pduUserData)

# send it upstream
self.response(xpdu)

elif isinstance(pdu, ForwardedNPDU):
# build a PDU with the source from the real source
xpdu = PDU(pdu.pduData, source=pdu.bvlciAddress, destination=LocalBroadcast(), user_data=pdu.pduUserData)

# send it upstream
self.response(xpdu)

elif isinstance(pdu, WriteBroadcastDistributionTable):
# build a response
xpdu = Result(code=0x0010, user_data=pdu.pduUserData)
xpdu.pduDestination = pdu.pduSource

# send it downstream
self.request(xpdu)

elif isinstance(pdu, ReadBroadcastDistributionTable):
# build a response
xpdu = Result(code=0x0020, user_data=pdu.pduUserData)
xpdu.pduDestination = pdu.pduSource

# send it downstream
self.request(xpdu)

elif isinstance(pdu, RegisterForeignDevice):
# build a response
xpdu = Result(code=0x0030, user_data=pdu.pduUserData)
xpdu.pduDestination = pdu.pduSource

# send it downstream
self.request(xpdu)

elif isinstance(pdu, ReadForeignDeviceTable):
# build a response
xpdu = Result(code=0x0040, user_data=pdu.pduUserData)
xpdu.pduDestination = pdu.pduSource

# send it downstream
self.request(xpdu)

elif isinstance(pdu, DeleteForeignDeviceTableEntry):
# build a response
xpdu = Result(code=0x0050, user_data=pdu.pduUserData)
xpdu.pduDestination = pdu.pduSource

# send it downstream
self.request(xpdu)

elif isinstance(pdu, DistributeBroadcastToNetwork):
# build a response
xpdu = Result(code=0x0060, user_data=pdu.pduUserData)
xpdu.pduDestination = pdu.pduSource

# send it downstream
self.request(xpdu)

else:
BIPForeign._warning("invalid pdu type: %s", type(pdu))

Expand Down
10 changes: 6 additions & 4 deletions py25/bacpypes/service/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,15 @@ def __init__(self, **kwargs):
if 'objectIdentifier' not in kwargs:
raise RuntimeError("objectIdentifier is required")

# coerce the object identifier
object_identifier = kwargs['objectIdentifier']
if isinstance(object_identifier, (int, long)):
object_identifier = ('device', object_identifier)

# the object list is provided
if 'objectList' in kwargs:
raise RuntimeError("objectList is provided by LocalDeviceObject and cannot be overridden")
else:
kwargs['objectList'] = ArrayOf(ObjectIdentifier)([
kwargs['objectIdentifier'],
])
kwargs['objectList'] = ArrayOf(ObjectIdentifier)([object_identifier])

# check for a minimum value
if kwargs['maxApduLengthAccepted'] < 50:
Expand Down
6 changes: 4 additions & 2 deletions py25/bacpypes/service/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
# CurrentPropertyList
#

@bacpypes_debugging
class CurrentPropertyList(Property):

def __init__(self):
Expand Down Expand Up @@ -60,17 +59,20 @@ def ReadProperty(self, obj, arrayIndex=None):
def WriteProperty(self, obj, value, arrayIndex=None, priority=None, direct=False):
raise ExecutionError(errorClass='property', errorCode='writeAccessDenied')

bacpypes_debugging(CurrentPropertyList)

#
# CurrentPropertyListMixIn
#

@bacpypes_debugging
class CurrentPropertyListMixIn(Object):

properties = [
CurrentPropertyList(),
]

bacpypes_debugging(CurrentPropertyListMixIn)

#
# ReadProperty and WriteProperty Services
#
Expand Down
13 changes: 9 additions & 4 deletions py27/bacpypes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ class BIPSimpleApplication(ApplicationIOController, WhoIsIAmServices, ReadWriteP

def __init__(self, localDevice, localAddress, deviceInfoCache=None, aseID=None):
if _debug: BIPSimpleApplication._debug("__init__ %r %r deviceInfoCache=%r aseID=%r", localDevice, localAddress, deviceInfoCache, aseID)
ApplicationIOController.__init__(self, localDevice, deviceInfoCache, aseID=aseID)
ApplicationIOController.__init__(self, localDevice, localAddress, deviceInfoCache, aseID=aseID)

# local address might be useful for subclasses
if isinstance(localAddress, Address):
Expand Down Expand Up @@ -524,9 +524,14 @@ def close_socket(self):
@bacpypes_debugging
class BIPForeignApplication(ApplicationIOController, WhoIsIAmServices, ReadWritePropertyServices):

def __init__(self, localDevice, localAddress, bbmdAddress, bbmdTTL, aseID=None):
if _debug: BIPForeignApplication._debug("__init__ %r %r %r %r aseID=%r", localDevice, localAddress, bbmdAddress, bbmdTTL, aseID)
ApplicationIOController.__init__(self, localDevice, aseID=aseID)
def __init__(self, localDevice, localAddress, bbmdAddress, bbmdTTL, deviceInfoCache=None, aseID=None):
if _debug:
BIPForeignApplication._debug(
"__init__ %r %r %r %r deviceInfoCache=%r aseID=%r",
localDevice, localAddress, bbmdAddress, bbmdTTL,
deviceInfoCache, aseID,
)
ApplicationIOController.__init__(self, localDevice, localAddress, deviceInfoCache, aseID=aseID)

# local address might be useful for subclasses
if isinstance(localAddress, Address):
Expand Down
Loading

0 comments on commit e07ab58

Please sign in to comment.