SIENTIAPDE-1646
Refactor OPC and OpcRepository classes to remove logger dependency and streamline logging calls - Removed logger attribute from OPC and OpcRepository classes, replacing direct logger calls with class methods for logging. - Updated write_data method signatures to eliminate logger parameter, simplifying the interface. - Adjusted related tests to reflect changes in method signatures and logging behavior.
This commit is contained in:
@@ -32,7 +32,6 @@ class OPC(SientiaMonitoring):
|
||||
Attributes:
|
||||
opc_servers (dict): Configuration for multiple OPC servers
|
||||
opc_repository (dict): Active OPC repository connections
|
||||
logger (Logger): Logging and observability instance
|
||||
notification_handler (NotificationHandler): Notification management instance
|
||||
"""
|
||||
|
||||
@@ -43,8 +42,6 @@ class OPC(SientiaMonitoring):
|
||||
notification_handler: NotificationHandler,
|
||||
metrics_controller: MetricsController,
|
||||
):
|
||||
self.logger = logger
|
||||
self.notification_handler = notification_handler
|
||||
self.opc_servers = opc_servers
|
||||
|
||||
SientiaMonitoring.__init__(self, logger, notification_handler, metrics_controller)
|
||||
@@ -61,7 +58,7 @@ class OPC(SientiaMonitoring):
|
||||
are reported through the notification system.
|
||||
"""
|
||||
|
||||
self.logger.info('Initializing OPC servers...')
|
||||
self.info('Initializing OPC servers...')
|
||||
for opc_id, server in self.opc_servers.items():
|
||||
self.opc_repository[opc_id] = OpcRepository(
|
||||
opc_id=opc_id,
|
||||
@@ -91,8 +88,9 @@ class OPC(SientiaMonitoring):
|
||||
attachment_content=err.get('attachment_content', traceback.format_exc()),
|
||||
)
|
||||
else:
|
||||
self.logger.info(
|
||||
f'OPC server {opc_id}:{server["server_name"]} connected successfully.'
|
||||
self.info(
|
||||
f'OPC server {opc_id}:{server["server_name"]} connected successfully.',
|
||||
None,
|
||||
)
|
||||
|
||||
def write_data(
|
||||
@@ -120,7 +118,7 @@ class OPC(SientiaMonitoring):
|
||||
|
||||
try:
|
||||
is_success, info_data = self.opc_repository[server_id].write_data(
|
||||
tag, data, data_type, self.logger, metadata
|
||||
tag, data, data_type, metadata
|
||||
)
|
||||
if not is_success:
|
||||
self.send_notification(
|
||||
|
||||
Reference in New Issue
Block a user