1
0
mirror of https://github.com/JoelBender/bacpypes synced 2025-09-28 22:15:23 +08:00
This commit is contained in:
Joel Bender 2017-09-06 22:51:17 -04:00
commit a6ceef3f67
4 changed files with 57 additions and 49 deletions

View File

@ -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,
@ -431,7 +437,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 +449,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,
@ -476,6 +487,7 @@ class ActiveCOVSubscriptions(Property):
bacpypes_debugging(ActiveCOVSubscriptions)
#
# ChangeOfValueServices
#
@ -486,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 = {}
@ -642,4 +651,5 @@ class ChangeOfValueServices(Capability):
# return the result
self.response(response)
bacpypes_debugging(ChangeOfValueServices)
bacpypes_debugging(ChangeOfValueServices)

View File

@ -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,
@ -467,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):

View File

@ -243,6 +243,7 @@ class COVDetection(DetectionAlgorithm):
"(" + ','.join(self.properties_tracked) + ')' + \
">"
class GenericCriteria(COVDetection):
properties_tracked = (
@ -429,7 +430,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 +442,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,

View File

@ -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"""