1
0
mirror of https://github.com/JoelBender/bacpypes synced 2025-09-28 22:15:23 +08:00

add default support for I-Am and use decorators for debugging

This commit is contained in:
Joel Bender 2015-09-16 14:44:53 -04:00
parent 341c4aba3a
commit 4ebcbd8c79

View File

@ -4,7 +4,7 @@
Application Module Application Module
""" """
from .debugging import ModuleLogger, Logging from .debugging import bacpypes_debugging, ModuleLogger
from .comm import ApplicationServiceElement, bind from .comm import ApplicationServiceElement, bind
from .pdu import Address from .pdu import Address
@ -86,7 +86,8 @@ class CurrentTimeProperty(Property):
# LocalDeviceObject # LocalDeviceObject
# #
class LocalDeviceObject(DeviceObject, Logging): @bacpypes_debugging
class LocalDeviceObject(DeviceObject):
properties = \ properties = \
[ CurrentTimeProperty('localTime') [ CurrentTimeProperty('localTime')
@ -142,7 +143,8 @@ class LocalDeviceObject(DeviceObject, Logging):
# Application # Application
# #
class Application(ApplicationServiceElement, Logging): @bacpypes_debugging
class Application(ApplicationServiceElement):
def __init__(self, localDevice, localAddress, aseID=None): def __init__(self, localDevice, localAddress, aseID=None):
if _debug: Application._debug("__init__ %r %r aseID=%r", localDevice, localAddress, aseID) if _debug: Application._debug("__init__ %r %r aseID=%r", localDevice, localAddress, aseID)
@ -299,6 +301,10 @@ class Application(ApplicationServiceElement, Logging):
# away it goes # away it goes
self.request(iAm) self.request(iAm)
def do_IAmRequest(self, apdu):
"""Respond to an I-Am request."""
if _debug: Application._debug("do_IAmRequest %r", apdu)
def do_ReadPropertyRequest(self, apdu): def do_ReadPropertyRequest(self, apdu):
"""Return the value of some property of one of our objects.""" """Return the value of some property of one of our objects."""
if _debug: Application._debug("do_ReadPropertyRequest %r", apdu) if _debug: Application._debug("do_ReadPropertyRequest %r", apdu)
@ -588,7 +594,8 @@ class Application(ApplicationServiceElement, Logging):
# BIPSimpleApplication # BIPSimpleApplication
# #
class BIPSimpleApplication(Application, Logging): @bacpypes_debugging
class BIPSimpleApplication(Application):
def __init__(self, localDevice, localAddress, aseID=None): def __init__(self, localDevice, localAddress, aseID=None):
if _debug: BIPSimpleApplication._debug("__init__ %r %r aseID=%r", localDevice, localAddress, aseID) if _debug: BIPSimpleApplication._debug("__init__ %r %r aseID=%r", localDevice, localAddress, aseID)
@ -627,7 +634,8 @@ class BIPSimpleApplication(Application, Logging):
# BIPForeignApplication # BIPForeignApplication
# #
class BIPForeignApplication(Application, Logging): @bacpypes_debugging
class BIPForeignApplication(Application):
def __init__(self, localDevice, localAddress, bbmdAddress, bbmdTTL, aseID=None): 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) if _debug: BIPForeignApplication._debug("__init__ %r %r %r %r aseID=%r", localDevice, localAddress, bbmdAddress, bbmdTTL, aseID)
@ -666,7 +674,8 @@ class BIPForeignApplication(Application, Logging):
# BIPNetworkApplication # BIPNetworkApplication
# #
class BIPNetworkApplication(NetworkServiceElement, Logging): @bacpypes_debugging
class BIPNetworkApplication(NetworkServiceElement):
def __init__(self, localAddress, eID=None): def __init__(self, localAddress, eID=None):
if _debug: BIPNetworkApplication._debug("__init__ %r eID=%r", localAddress, eID) if _debug: BIPNetworkApplication._debug("__init__ %r eID=%r", localAddress, eID)