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.
This commit is contained in:
@@ -141,7 +141,7 @@ class OPC(BaseActivity):
|
|||||||
|
|
||||||
if 'prediction_tags' in config:
|
if 'prediction_tags' in config:
|
||||||
for tag, tag_config in config['prediction_tags'].items():
|
for tag, tag_config in config['prediction_tags'].items():
|
||||||
success = success and self.write_data(
|
local_success = self.write_data(
|
||||||
server_id=server_id,
|
server_id=server_id,
|
||||||
tag=tag,
|
tag=tag,
|
||||||
data=data.head(1)['prediction'].values[0],
|
data=data.head(1)['prediction'].values[0],
|
||||||
@@ -149,10 +149,15 @@ class OPC(BaseActivity):
|
|||||||
tag_type='prediction',
|
tag_type='prediction',
|
||||||
metadata=metadata
|
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:
|
if 'confidence_tags' in config:
|
||||||
for tag, tag_config in config['confidence_tags'].items():
|
for tag, tag_config in config['confidence_tags'].items():
|
||||||
self.write_data(
|
local_success = self.write_data(
|
||||||
server_id=server_id,
|
server_id=server_id,
|
||||||
tag=tag,
|
tag=tag,
|
||||||
data=data.head(1)['prediction_confidence'].values[0],
|
data=data.head(1)['prediction_confidence'].values[0],
|
||||||
@@ -160,6 +165,11 @@ class OPC(BaseActivity):
|
|||||||
tag_type='confidence',
|
tag_type='confidence',
|
||||||
metadata=metadata
|
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)
|
return self.process_confidence(data, success, metadata)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user