Simply trying to directly address a value property in a numeric label to an OPC path. Not a problem when a tag is created in the project, but I want to read tags directly without having to add them in the project.
Tried to use this in the expression property binding, but from what I can tell it isn’t supported? (might be wrong here) Looks like scripting allows for this, but there has to be an event to trigger the scripting which I’d like to avoid. Here is the syntax I was using:
system.opc.readvalue(“Ignition OPC UA”,"[Controller_Example]Tag_Name_Example])
What am I missing here?
It looks like you just have the syntax wrong
system.opc.readValue('Ignition OPC-UA Server','[Controller]TagAddress').value
That syntax does not work for expressions.
Scan Error: Illegal character .> (Line 1, Char 7)
You would need to use the runScript
expression function to do this. You can’t mix and match expression language with scripting language.
https://docs.inductiveautomation.com:8443/display/DOC79/runScript
Any reasoning behind having two different languages?
So basically, no, an OPC tag cannot be directly addressed in a numeric value quickly?
Ahh didn’t see the expression part.
If you want to do this, just create a script in Project scope
def LabelOPC(tag):
server = "Ignition OPC-UA Server"
path = tag
return system.opc.readValue(server, path).value
The in your expression call it like
runScript("project.SctiptContainerName.LabelOPC('[Controller]Tag')",2000)
I would recommend against this though, as system.opc.readValue doesn’t create a tag subscription to the PLC.
It will be slow and affect your client performance.