I have a tag value that I don’t want to show a negative value, example -5.96.( I only want the positive!
(Now I can correct in the PLC but I just thought until I can get to location I could fix in scada.)
I have tried adding a tag event script something like this.
if Tag(Path) < 0.00:
Tag(Path) = 0.00
I get no errors for the script but it does not work.
You would need to use system.tag.read() on that first line to do it that way. But the tag value change event already includes the value accessible via event.getValue() so there’s no reason to do a tag read. Have you tried the script as I posted above?
Use the button shown in dark grey near top right of this screen clipping to properly format code (you were close!):
You could also enable linear scaling on the tag to use the ‘Clamp Mode’ property. Set linear scaling with Raw = 0-100, Scaled = 0-100, and Clamp Mode = ‘Clamp_Low’. It doesn’t really matter what the high raw/scale values are if you don’t enable high clamping.
That’s because you were writing it back to itself. Every time the OPC driver supplied a new value, that would be propagated to subscribers, followed by the zero from the script. You would have to make a derived tag to hold the clamped value. The same race can occur in the PLC, too, if you are trying to overwrite the negatives in place. An OPC driver could read the negative just before the ladder replaced it. (Smaller race window in the PLC, though.)