Skip to content

Commit

Permalink
Added warnings and error handling related to duplicate point names in…
Browse files Browse the repository at this point in the history
… device registries.
  • Loading branch information
davidraker committed May 17, 2024
1 parent 90d6f25 commit 21edda2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 7 additions & 1 deletion services/core/PlatformDriverAgent/platform_driver/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,13 @@ def setup_device(self):

self.heart_beat_point = config.get("heart_beat_point")


# Check for duplicate names in registry entries and warn if this will cause rows to be skipped.
point_names = [r['Volttron Point Name'] for r in registry_config]
seen = set(point_names)
duplicates = [n for n in point_names if n not in seen or seen.remove(n)]
if duplicates:
_log.warning(f'Duplicate point names detected in registry file for {self.device_path}. '
f'Only the last registry row will be used for points with names: {set(duplicates)}')

self.interface = self.get_interface(driver_type, driver_config, registry_config)
self.meta_data = {}
Expand Down
7 changes: 5 additions & 2 deletions volttron/platform/web/topic_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ def from_store(cls, platform, rpc_caller):
registry_config = registry_config if kwargs else registry_config.get(timeout=5)
for pnt in registry_config:
point_name = pnt.pop('Volttron Point Name')
n = device_tree.create_node(point_name, f"{d}/{point_name}", parent=d, data=pnt)
n.segment_type = 'POINT'
try:
n = device_tree.create_node(point_name, f"{d}/{point_name}", parent=d, data=pnt)
n.segment_type = 'POINT'
except DuplicatedNodeIdError:
_log.warning(f'Duplicate Voltron Point Name ({point_name}) found in registry: {reg_cfg_name}.')
return device_tree

0 comments on commit 21edda2

Please sign in to comment.