1
0
mirror of https://github.com/JoelBender/bacpypes synced 2025-10-27 00:57:47 +08:00

hooks in the application to set/clear the _app value in the object

This commit is contained in:
Joel Bender
2016-01-23 21:18:34 -05:00
parent da161c0203
commit a2fe66ad00
3 changed files with 18 additions and 0 deletions

View File

@@ -186,6 +186,9 @@ class Application(ApplicationServiceElement, Logging):
# append the new object's identifier to the device's object list
self.localDevice.objectList.append(object_identifier)
# let the object know which application stack it belongs to
obj._app = self
def delete_object(self, obj):
"""Add an object to the local collection."""
if _debug: Application._debug("delete_object %r", obj)
@@ -202,6 +205,9 @@ class Application(ApplicationServiceElement, Logging):
indx = self.localDevice.objectList.index(object_identifier)
del self.localDevice.objectList[indx]
# make sure the object knows it's detached from an application
obj._app = None
def get_object_id(self, objid):
"""Return a local object or None."""
return self.objectIdentifier.get(objid, None)