Skip to content

Commit

Permalink
add device keyword arg to control reconnect-on-failure
Browse files Browse the repository at this point in the history
  • Loading branch information
gnmerritt committed Dec 9, 2020
1 parent 93a4c03 commit bff1746
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions BAC0/core/devices/Device.py
Expand Up @@ -136,7 +136,8 @@ def __init__(
auto_save=False,
save_resampling="1s",
clear_history_on_save=False,
history_size=None
history_size=None,
reconnect_on_failure=True,
):

self.properties = DeviceProperties()
Expand All @@ -155,6 +156,7 @@ def __init__(
self.properties.save_resampling = save_resampling
self.properties.clear_history_on_save = clear_history_on_save
self.properties.default_history_size = history_size
self._reconnect_on_failure = reconnect_on_failure

self.segmentation_supported = segmentation_supported
self.custom_object_list = object_list
Expand Down Expand Up @@ -540,8 +542,11 @@ def _buildPointList(self):
self.segmentation_supported = False
self.new_state(DeviceDisconnected)
except IndexError as error:
self._log.error("Device creation failed... disconnecting")
self.new_state(DeviceDisconnected)
if self._reconnect_on_failure:
self._log.error("Device creation failed... re-connecting")
self.new_state(DeviceDisconnected)
else:
self._log.error("Device creation failed... disconnecting")

def __getitem__(self, point_name):
"""
Expand Down Expand Up @@ -751,6 +756,8 @@ def update_bacnet_properties(self):
prop_id_required=True,
)
for each in res:
if not each:
continue
v, prop = each
self.properties.bacnet_properties[prop] = v

Expand Down
2 changes: 2 additions & 0 deletions BAC0/core/devices/Points.py
Expand Up @@ -202,6 +202,8 @@ def update_bacnet_properties(self):
prop_id_required=True,
)
for each in res:
if not each:
continue
v, prop = each
self.properties.bacnet_properties[prop] = v

Expand Down

0 comments on commit bff1746

Please sign in to comment.