From cc7efba8870d35acd13a3da29ff20832e43a3116 Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Mon, 18 Aug 2025 16:30:33 -0300 Subject: [PATCH] SIENTIAPDE-1169 Refactor OPC data writing to improve success tracking - Updated the OPC class to store the success status of data writing operations for both prediction and confidence tags. - Added logging for successful and failed writes to the OPC server, enhancing traceability of data operations. --- laborious/activities/opc.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/laborious/activities/opc.py b/laborious/activities/opc.py index 4834288..e39a35d 100644 --- a/laborious/activities/opc.py +++ b/laborious/activities/opc.py @@ -141,7 +141,7 @@ class OPC(BaseActivity): if 'prediction_tags' in config: for tag, tag_config in config['prediction_tags'].items(): - success = success and self.write_data( + local_success = self.write_data( server_id=server_id, tag=tag, data=data.head(1)['prediction'].values[0], @@ -149,10 +149,15 @@ class OPC(BaseActivity): tag_type='prediction', metadata=metadata ) + if local_success: + self.info( + f"Prediction data written to OPC server {server_id} for tag {tag}.", metadata) + else: + success = success and local_success if 'confidence_tags' in config: for tag, tag_config in config['confidence_tags'].items(): - self.write_data( + local_success = self.write_data( server_id=server_id, tag=tag, data=data.head(1)['prediction_confidence'].values[0], @@ -160,6 +165,11 @@ class OPC(BaseActivity): tag_type='confidence', metadata=metadata ) + if local_success: + self.info( + f"Confidence data written to OPC server {server_id} for tag {tag}.", metadata) + else: + success = success and local_success return self.process_confidence(data, success, metadata)