From 06524869e667f86bc11cecb398ef5086559ca813 Mon Sep 17 00:00:00 2001 From: Joel Bender Date: Thu, 31 Aug 2017 15:44:01 -0400 Subject: [PATCH 1/4] debug the components --- py25/bacpypes/service/cov.py | 21 +++++++++++++-------- py27/bacpypes/service/cov.py | 19 ++++++++++++------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/py25/bacpypes/service/cov.py b/py25/bacpypes/service/cov.py index 69b8dd3..e36b21e 100644 --- a/py25/bacpypes/service/cov.py +++ b/py25/bacpypes/service/cov.py @@ -431,7 +431,7 @@ class ActiveCOVSubscriptions(Property): cov_subscriptions = SequenceOf(COVSubscription)() # loop through the object and detection list - for obj, cov_detection in self.cov_detections.items(): + for obj, cov_detection in obj._app.cov_detections.items(): for cov in cov_detection.cov_subscriptions: # calculate time remaining if not cov.lifetime: @@ -443,15 +443,20 @@ class ActiveCOVSubscriptions(Property): if not time_remaining: time_remaining = 1 - recipient_process = RecipientProcess( - recipient=Recipient( - address=DeviceAddress( - networkNumber=cov.client_addr.addrNet or 0, - macAddress=cov.client_addr.addrAddr, - ), + recipient = Recipient( + address=DeviceAddress( + networkNumber=cov.client_addr.addrNet or 0, + macAddress=cov.client_addr.addrAddr, ), + ) + if _debug: ActiveCOVSubscriptions._debug(" - recipient: %r", recipient) + if _debug: ActiveCOVSubscriptions._debug(" - client MAC address: %r", cov.client_addr.addrAddr) + + recipient_process = RecipientProcess( + recipient=recipient, processIdentifier=cov.proc_id, ) + if _debug: ActiveCOVSubscriptions._debug(" - recipient_process: %r", recipient_process) cov_subscription = COVSubscription( recipient=recipient_process, @@ -642,4 +647,4 @@ class ChangeOfValueServices(Capability): # return the result self.response(response) -bacpypes_debugging(ChangeOfValueServices) \ No newline at end of file +bacpypes_debugging(ChangeOfValueServices) diff --git a/py27/bacpypes/service/cov.py b/py27/bacpypes/service/cov.py index d8630d7..ed395d3 100644 --- a/py27/bacpypes/service/cov.py +++ b/py27/bacpypes/service/cov.py @@ -429,7 +429,7 @@ class ActiveCOVSubscriptions(Property): cov_subscriptions = SequenceOf(COVSubscription)() # loop through the object and detection list - for obj, cov_detection in self.cov_detections.items(): + for obj, cov_detection in obj._app.cov_detections.items(): for cov in cov_detection.cov_subscriptions: # calculate time remaining if not cov.lifetime: @@ -441,15 +441,20 @@ class ActiveCOVSubscriptions(Property): if not time_remaining: time_remaining = 1 - recipient_process = RecipientProcess( - recipient=Recipient( - address=DeviceAddress( - networkNumber=cov.client_addr.addrNet or 0, - macAddress=cov.client_addr.addrAddr, - ), + recipient = Recipient( + address=DeviceAddress( + networkNumber=cov.client_addr.addrNet or 0, + macAddress=cov.client_addr.addrAddr, ), + ) + if _debug: ActiveCOVSubscriptions._debug(" - recipient: %r", recipient) + if _debug: ActiveCOVSubscriptions._debug(" - client MAC address: %r", cov.client_addr.addrAddr) + + recipient_process = RecipientProcess( + recipient=recipient, processIdentifier=cov.proc_id, ) + if _debug: ActiveCOVSubscriptions._debug(" - recipient_process: %r", recipient_process) cov_subscription = COVSubscription( recipient=recipient_process, From f7182450cd3e0e7a2c572ba13a398ce1a5173050 Mon Sep 17 00:00:00 2001 From: Joel Bender Date: Thu, 31 Aug 2017 17:06:03 -0400 Subject: [PATCH 2/4] debug the components --- py34/bacpypes/service/cov.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/py34/bacpypes/service/cov.py b/py34/bacpypes/service/cov.py index 8da0c92..d1b88b2 100644 --- a/py34/bacpypes/service/cov.py +++ b/py34/bacpypes/service/cov.py @@ -429,7 +429,7 @@ class ActiveCOVSubscriptions(Property): cov_subscriptions = SequenceOf(COVSubscription)() # loop through the object and detection list - for obj, cov_detection in self.cov_detections.items(): + for obj, cov_detection in obj._app.cov_detections.items(): for cov in cov_detection.cov_subscriptions: # calculate time remaining if not cov.lifetime: @@ -441,15 +441,20 @@ class ActiveCOVSubscriptions(Property): if not time_remaining: time_remaining = 1 - recipient_process = RecipientProcess( - recipient=Recipient( - address=DeviceAddress( - networkNumber=cov.client_addr.addrNet or 0, - macAddress=cov.client_addr.addrAddr, - ), + recipient = Recipient( + address=DeviceAddress( + networkNumber=cov.client_addr.addrNet or 0, + macAddress=cov.client_addr.addrAddr, ), + ) + if _debug: ActiveCOVSubscriptions._debug(" - recipient: %r", recipient) + if _debug: ActiveCOVSubscriptions._debug(" - client MAC address: %r", cov.client_addr.addrAddr) + + recipient_process = RecipientProcess( + recipient=recipient, processIdentifier=cov.proc_id, ) + if _debug: ActiveCOVSubscriptions._debug(" - recipient_process: %r", recipient_process) cov_subscription = COVSubscription( recipient=recipient_process, From 97212596ba90c0c920090162da5dd00d9585651b Mon Sep 17 00:00:00 2001 From: Joel Bender Date: Tue, 5 Sep 2017 11:44:41 -0400 Subject: [PATCH 3/4] fix the status command --- samples/COVServer.py | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/samples/COVServer.py b/samples/COVServer.py index 1c909bf..68ef311 100755 --- a/samples/COVServer.py +++ b/samples/COVServer.py @@ -45,27 +45,17 @@ class COVConsoleCmd(ConsoleCmd): if _debug: COVConsoleCmd._debug("do_status %r", args) global test_application - # reference the list of active subscriptions - active_subscriptions = test_application.active_cov_subscriptions - if _debug: COVConsoleCmd._debug(" - %d active subscriptions", len(active_subscriptions)) + # dump from the COV detections dict + for obj_ref, cov_detection in test_application.cov_detections.items(): + print("{} {}".format(obj_ref.objectIdentifier, obj_ref)) - # dump then out - for subscription in active_subscriptions: - print("{} {} {} {} {}".format( - subscription.client_addr, - subscription.proc_id, - subscription.obj_id, - subscription.confirmed, - subscription.lifetime, - )) - - # reference the object to algorithm map - object_detections = test_application.object_detections - for objref, cov_detection in object_detections.items(): - print("{} {}".format( - objref.objectIdentifier, - cov_detection, - )) + for cov_subscription in cov_detection.cov_subscriptions: + print(" {} proc_id={} confirmed={} lifetime={}".format( + cov_subscription.client_addr, + cov_subscription.proc_id, + cov_subscription.confirmed, + cov_subscription.lifetime, + )) def do_trigger(self, args): """trigger object_name""" From 3242556a12d03894e0e6e218c5c1365816397b55 Mon Sep 17 00:00:00 2001 From: Joel Bender Date: Tue, 5 Sep 2017 11:59:02 -0400 Subject: [PATCH 4/4] sync the versions --- py25/bacpypes/service/cov.py | 13 +++++++++---- py27/bacpypes/service/cov.py | 3 --- py34/bacpypes/service/cov.py | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/py25/bacpypes/service/cov.py b/py25/bacpypes/service/cov.py index e36b21e..0ed7bdf 100644 --- a/py25/bacpypes/service/cov.py +++ b/py25/bacpypes/service/cov.py @@ -304,7 +304,8 @@ class COVIncrementCriteria(COVDetection): # continue COVDetection.send_cov_notifications(self) -bacpypes_debugging(COVDetection) +bacpypes_debugging(COVIncrementCriteria) + class AccessDoorCriteria(COVDetection): @@ -319,6 +320,7 @@ class AccessDoorCriteria(COVDetection): 'doorAlarmState', ) + class AccessPointCriteria(COVDetection): properties_tracked = ( @@ -335,6 +337,7 @@ class AccessPointCriteria(COVDetection): ) monitored_property_reference = 'accessEvent' + class CredentialDataInputCriteria(COVDetection): properties_tracked = ( @@ -347,6 +350,7 @@ class CredentialDataInputCriteria(COVDetection): 'updateTime', ) + class LoadControlCriteria(COVDetection): properties_tracked = ( @@ -366,6 +370,7 @@ class LoadControlCriteria(COVDetection): 'dutyWindow', ) + class PulseConverterCriteria(COVDetection): properties_tracked = ( @@ -377,6 +382,7 @@ class PulseConverterCriteria(COVDetection): 'statusFlags', ) + # mapping from object type to appropriate criteria class criteria_type_map = { 'accessPoint': AccessPointCriteria, @@ -481,6 +487,7 @@ class ActiveCOVSubscriptions(Property): bacpypes_debugging(ActiveCOVSubscriptions) + # # ChangeOfValueServices # @@ -491,9 +498,6 @@ class ChangeOfValueServices(Capability): if _debug: ChangeOfValueServices._debug("__init__") Capability.__init__(self) - # list of active subscriptions - self.active_cov_subscriptions = [] - # map from an object to its detection algorithm self.cov_detections = {} @@ -648,3 +652,4 @@ class ChangeOfValueServices(Capability): self.response(response) bacpypes_debugging(ChangeOfValueServices) + diff --git a/py27/bacpypes/service/cov.py b/py27/bacpypes/service/cov.py index ed395d3..d1b88b2 100644 --- a/py27/bacpypes/service/cov.py +++ b/py27/bacpypes/service/cov.py @@ -472,9 +472,6 @@ class ActiveCOVSubscriptions(Property): # add the list cov_subscriptions.append(cov_subscription) - # add the list - cov_subscriptions.append(cov_subscription) - return cov_subscriptions def WriteProperty(self, obj, value, arrayIndex=None, priority=None): diff --git a/py34/bacpypes/service/cov.py b/py34/bacpypes/service/cov.py index d1b88b2..03115ec 100644 --- a/py34/bacpypes/service/cov.py +++ b/py34/bacpypes/service/cov.py @@ -243,6 +243,7 @@ class COVDetection(DetectionAlgorithm): "(" + ','.join(self.properties_tracked) + ')' + \ ">" + class GenericCriteria(COVDetection): properties_tracked = (