Is there a way to refresh a tags OPC value? I have tags that are running in a 10 minute scan class, what I’m looking to do is when the user opens a window to view an individual tag, I want to update that tag’s OPC value faster than the 10 minutes. Think of it as going ‘live’ with a tag.
I can’t use a Leased or Driven Scan Class since there are numerous tags in the scan class and I am only looking to update the one tag that is being displayed in the window. Also, creating numerous scan classes isn’t an option.
That was a thought, but we couldn’t figure out a way to get the OPC Server and OPC Item Path from Ignition. It seems that system.tag.read() doesn’t give access to that information
I was wondering why a leased scan class wouldn’t work. Is this a case where it’s already visible in the client, but you want it to update faster in a different window?
A Leased Class won’t work because when any of the tags in the scan class are subscribed and visible then all the tags in the scan class run at the fast rate. Since there is going to be 100s of remote devices, updating all those tags at the fast rate isn’t what I’m looking to do and creating 100s of scan classes isn’t viable either.
In discussions with tech support they offered a way to get the tag’s OPC Item Path with system.tag.read("SomeTagPath.OPCItemPath").value So I’m going to test using system.tag.read() to get the OPC Item Path, then use system.opc.readValue() to get the OPC value, then system.tag.write() to update the tag’s value.
Using the following code I am able to obtain the OPC value directly from the OPC server for my Ignition tag
tagOPCServer = system.tag.read("MyIgnitionTag.OPCServer").value
tagOPCItemPath = system.tag.read("MyIgnitionTag.OPCItemPath").value
currentOPCValue = system.opc.readValue(tagOPCServer, tagOPCItemPath)
Interestingly there is an unexpected behavior, Kepserver is actually updating the Ignition tag that is subscribed to this OPC value. What appears to be happening is, MyIgnitionTag is subscribed to the Kepware’s MyOPCTag at a rate of 10 minutes. When system.opc.readValue() is call, Kepware gets a new value from the PLC and returns the new value to the function, Kepware also sees that MyIgnitionTag is subscribed to that value and also updates MyIgnitionTag with the new value even though the tag’s scan rate is only 10 minutes.