I am trying to get data from a UDT (with OPC tags connected to a PLC) to dynamically load interlocks for a perspective view. Part of this UDT has a bool value “Used” which is true when that interlock is being used in the PLC.
To display this, I am trying to bring in the UDT via tag binding (direct for now, indirect later) and use a script transform to filter out the objects where “Used” is false. I have it pretty much figured out, except that my result is just a PyString and not an object and I cannot seem to figure out how to cast this correctly so that I can use each interlock’s object values as params for a view repeater.
Here is the script:
import json dict = system.util.jsonDecode(str(value)) for key in dict: if dict[key]["Used"] == 0: del dict[key] newValue = json.dumps(dict, indent = 4) return newValue