SIENTIAPDE-1110

Refactor OpcManager to improve node subscription handling

- Simplified the address node assignment in the OpcManager class by directly using a local variable instead of an instance variable.
- Enhanced debug logging to provide clearer insights into the nodes being subscribed to.
This commit is contained in:
vitor-aignosi
2025-07-08 12:32:21 -03:00
parent 7391ed3ba5
commit 1512ca98bd

View File

@@ -157,9 +157,9 @@ class OpcManager():
self.logger.info(f"Subscribing to {subscription} on {self.name}...") self.logger.info(f"Subscribing to {subscription} on {self.name}...")
self.logger.info(f"Subscribing to nodes: {nodes}") self.logger.info(f"Subscribing to nodes: {nodes}")
self.addr_nodes = [self.client.get_node( addr_nodes = [self.client.get_node(
n) for n in nodes if n not in self.nodes] n) for n in nodes]
self.logger.debug(f"Addr nodes: {self.addr_nodes}") self.logger.debug(f"Addr nodes: {addr_nodes}")
self.nodes.update(nodes) self.nodes.update(nodes)
self.logger.debug(f"Nodes: {self.nodes}") self.logger.debug(f"Nodes: {self.nodes}")
metrics.OPC_TAGS_SUBSCRIBED.labels( metrics.OPC_TAGS_SUBSCRIBED.labels(
@@ -172,7 +172,7 @@ class OpcManager():
'cycle_count': 0 'cycle_count': 0
} }
self.subscriptions[subscription].subscribe_data_change(self.addr_nodes) self.subscriptions[subscription].subscribe_data_change(addr_nodes)
def unsubscribe(self, subscription: str): def unsubscribe(self, subscription: str):
""" """