Tag Quality with Perspective Expression Structure

Hi,

Is there a way to have Expression Structure Object members return a QualifiedValue object of the associated OPC tag?

image

I want to have it such that if the remote or local opc tags are of "bad quality", the data binding throws an error and the associated component overlay is active.

Is there a reason you are doing this in a structure binding instead of individual tag indirect bindings (the tag() expression function is the source of much grief) ?

The reason is: this data binding is tied to the text prop of a label. I want the label to display "Local" or "Remote" based on the state (1 or 0) of the individual tags. I am using a script transform to do the logic.

Eg. if (Local == True and Remote == False):
ret = "Local"
return ret

I also wanted the functionality where if the local or remote tag has a bad quality, the label will show a overlay indicating an error (bad data quality). This is why initially I placed it as a input (object member) into the expression structure but it does not work like that.

if (Local == True and Remote == False):
ret = "Local"
return ret

can be reduced to

if Local and !Remote:
    return "Local"
return "Remote"

but running a script transform is probably quite an inefficient way to do the job. One alternative is to create an expression tag to calculate the result. This has the advantage that it should pass through a quality error if there is one. Expression:

if(
	{[~]Local} && !{[~]Remote},
	"Local",
	"Remote"
)

Then just use a tag binding on the label and point it to the expression tag.

1 Like

As with others, definitely don't use tag(...) or a script transform for such a simple task. You should use script transforms only if you can't achieve the same thing with an expression binding, as they add more load to the gateway

1 Like