Skip to content

Commit

Permalink
remove do_SubscribeCOVRequest to get better git-diff
Browse files Browse the repository at this point in the history
  • Loading branch information
Damien Picard committed Apr 6, 2021
1 parent 3fcfa40 commit 37a6e48
Showing 1 changed file with 0 additions and 77 deletions.
77 changes: 0 additions & 77 deletions py34/bacpypes/service/cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,83 +680,6 @@ def cov_abort(self, cov, request, response):

### delete the rest of the pending requests for this client

def do_SubscribeCOVRequest(self, apdu):
if _debug: ChangeOfValueServices._debug("do_SubscribeCOVRequest %r", apdu)

# extract the pieces
client_addr = apdu.pduSource
proc_id = apdu.subscriberProcessIdentifier
obj_id = apdu.monitoredObjectIdentifier
confirmed = apdu.issueConfirmedNotifications
lifetime = apdu.lifetime

# request is to cancel the subscription
cancel_subscription = (confirmed is None) and (lifetime is None)

# find the object
obj = self.get_object_id(obj_id)
if _debug: ChangeOfValueServices._debug(" - object: %r", obj)
if not obj:
raise ExecutionError(errorClass='object', errorCode='unknownObject')

# check to see if the object supports COV
if not obj._object_supports_cov:
raise ExecutionError(errorClass='services', errorCode='covSubscriptionFailed')

# look for an algorithm already associated with this object
cov_detection = self.cov_detections.get(obj, None)

# if there isn't one, make one and associate it with the object
if not cov_detection:
# look for an associated class and if it's not there it's not supported
criteria_class = criteria_type_map.get(obj_id[0], None)
if not criteria_class:
raise ExecutionError(errorClass='services', errorCode='covSubscriptionFailed')

# make one of these and bind it to the object
cov_detection = criteria_class(obj)

# keep track of it for other subscriptions
self.cov_detections[obj] = cov_detection
if _debug: ChangeOfValueServices._debug(" - cov_detection: %r", cov_detection)

# can a match be found?
cov = cov_detection.cov_subscriptions.find(client_addr, proc_id, obj_id)
if _debug: ChangeOfValueServices._debug(" - cov: %r", cov)

# if a match was found, update the subscription
if cov:
if cancel_subscription:
if _debug: ChangeOfValueServices._debug(" - cancel the subscription")
self.cancel_subscription(cov)
else:
if _debug: ChangeOfValueServices._debug(" - renew the subscription")
cov.renew_subscription(lifetime)
else:
if cancel_subscription:
if _debug: ChangeOfValueServices._debug(" - cancel a subscription that doesn't exist")
else:
if _debug: ChangeOfValueServices._debug(" - create a subscription")

# make a subscription
cov = Subscription(obj, client_addr, proc_id, obj_id, confirmed, lifetime)
if _debug: ChangeOfValueServices._debug(" - cov: %r", cov)

# add it to our subscriptions lists
self.add_subscription(cov)

# success
response = SimpleAckPDU(context=apdu)

# return the result
self.response(response)

# if the subscription is not being canceled, it is new or renewed,
# so send it a notification when you get a chance.
if not cancel_subscription:
if _debug: ChangeOfValueServices._debug(" - send a notification")
deferred(cov_detection.send_cov_notifications, cov)

def do_SubscribeCOVPropertyRequest(self, apdu):
if _debug: ChangeOfValueServices._debug("do_SubscribeCOVPropertyRequest %r", apdu)

Expand Down

0 comments on commit 37a6e48

Please sign in to comment.