Hello,
I am curious as to how much other users are checking for errors in their expressions.
At the moment, I am doing a startup of a project remotely before I head on site. Thus, every tag has an OPC error. This makes testing difficult, as labels which display numeric values will show 0, or strings which are dependent on values will not evaluate correctly / always return errors.
For example, I have this expression which creates a status word based off the fault bit and the run bit coming back from the plc:
// Inspect digital signals and create string format
// First checks to see if the tag values are null
if(
// If the first tag value is null - an error message is returned
isNull({[.]../Digital/DIND_CP2_BLWR_2A_FaultExists}), "Error (Tag Value null)",
if(
// If the second tag value is null - an error message is returned
isNull({[.]../Digital/DIND_CP2_BLWR_2A_RUN_IND}), "Error (Tag Value null)",
// If neither tags are null - proceed with the case statement
case(
// Create an integer from the three boolean tags (LSB -> MSB)
binEnc( // bit 0 // bit 1
{[.]../Digital/DIND_CP2_BLWR_2A_FaultExists}, {[.]../Digital/DIND_CP2_BLWR_2A_RUN_IND}
),
// If the value is = 0 (binary 00), return "Stopped"
0, "Stopped",
// If the value is = 1 (binary 10), return "Fault"
1, "Fault", // 100 (Binary representation)
// If the value is = 2 (binary 01), return "Running"
2, "Running",
// If the value is = 3 (binary 11), return "Fault"
4, "Fault",
// Default Case
// If the value is anything else e.g. >4, return "Error"
"Error"
)
)
)
I added the error checking specifically to this expression because otherwise a value of "Stopped" is returned. In this case - I'd prefer a value of error to be returned since the tags which the expression evaluates all have error_configuration quality codes at the moment.
My big question is this: how much error handling do you do in expressions?