Skip to content

Commit

Permalink
Merge pull request #3184 from davidraker/handle_duplicate_point_names
Browse files Browse the repository at this point in the history
Handle duplicate point names
  • Loading branch information
craig8 authored May 22, 2024
2 parents 61278c8 + 72646ad commit 9205f03
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 11 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,17 @@ def setup_device(self):

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


# Warn if there is no registry:
if registry_config is None:
_log.warning(f'No registry was found for device: devices/{self.device_path}')
else:
# 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 devices/{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 9205f03

Please sign in to comment.