SIENTIAPDE-988
Refactor OpcManager initialization and unsubscribe method; enhance logging - Removed the `initialize_from_config` method from `OpcManager` class and adjusted the constructor to handle configuration directly. - Improved the `unsubscribe` method to include detailed logging for non-existent subscriptions. - Updated tests in `test_opc_manager.py` to reflect changes in the `OpcManager` class. - Commented out Docker-related fixtures in `conftest.py` for potential future use. - Enhanced test coverage in `test_single_node.py` and `test_data_manager.py` with additional scenarios and assertions. - Introduced new methods in `Ingestor` and `IngestorManager` classes to manage server subscriptions and leases more effectively. - Added new tests for `Ingestor` class to validate initialization and slot management logic. - Implemented logging improvements across various classes to ensure better traceability of actions and errors.
This commit is contained in:
@@ -31,21 +31,6 @@ class OpcManager():
|
||||
return f"OpcManager(name={self.name}, url={self.url}, server_uri={self.server_uri})\n" \
|
||||
f"nodes={self.nodes}, subscriptions={self.subscriptions}"
|
||||
|
||||
def initialize_from_config(self, server_config: dict, data_manager: DataManager, logger: Logger):
|
||||
"""
|
||||
Initializes the OpcManager instance using a server configuration dictionary.
|
||||
Args:
|
||||
server_config (dict): A dictionary containing server configuration details.
|
||||
data_manager (DataManager): An instance of DataManager for data handling.
|
||||
logger (Logger): Logger instance for logging information.
|
||||
"""
|
||||
self.__init__(
|
||||
server_config['name'], server_config['url'], data_manager, logger, server_config['server_uri'],
|
||||
server_config.get('cert_path'), server_config.get(
|
||||
'private_key_path'), server_config.get('server_cert_path')
|
||||
)
|
||||
self.config = server_config
|
||||
|
||||
def set_security(self):
|
||||
"""
|
||||
Configures the security settings for the OPC UA client.
|
||||
@@ -161,10 +146,22 @@ class OpcManager():
|
||||
self.subscriptions[subscription].subscribe_data_change(self.addr_nodes)
|
||||
|
||||
def unsubscribe(self, subscription: str):
|
||||
"""
|
||||
Unsubscribes from a given subscription.
|
||||
Args:
|
||||
subscription (str): The name of the subscription to unsubscribe from.
|
||||
Logs:
|
||||
- A warning if the specified subscription does not exist.
|
||||
- An info message upon successful unsubscription.
|
||||
Behavior:
|
||||
- If the subscription exists, it is deleted and removed from the
|
||||
subscriptions dictionary.
|
||||
- If the subscription does not exist, no action is taken.
|
||||
"""
|
||||
|
||||
if not self.subscriptions.get(subscription):
|
||||
self.logger.warning(
|
||||
f"Subscription {subscription} not found. Cannot unsubscribe.")
|
||||
f"Subscription '{subscription}' not found. Cannot unsubscribe.")
|
||||
return
|
||||
self.subscriptions[subscription].delete()
|
||||
del self.subscriptions[subscription]
|
||||
|
||||
Reference in New Issue
Block a user