I would like to be able to indirection in an OPC Tag, is there any way to do this? I have another OPC tag that is reading a tag path across the OPC to Ignition (XX\AT_P7), I want to then be able to have another OPC tag in Ignition in which I can use that tag path and read a parameter from that tag. Any ideas? Any help would be appreciated!
I also have a dumber question. If that the path on that other OPC tag is XX\AT_P7, how can I remove the XX. I tried using the Replace function in an expression tag and couldn't get it to work.
Not easily, no. The simplest solution would be to use a tag valueChange event that constructs the correct path from the updated value of the path tag, and writes to the .opcItemPath configuration property of the indirect tag.
If you want the fastest possible behavior, subscribe to all of the possible OPC items as OPC tags, and use a reference tag. Then have the valueChange event write to the reference tag's .source configuration property.
You could do what @pturmel suggested, or in a very similar fashion, if you have a parameter on the 2nd tag that you use in the expression for the OPC item path, you could write to the parameter the new value and the OPC item would rebind to the new path also. Both are accomplishing the same thing, just 2 slightly different ways about it.
If you're needing to do a one-shot read of an OPC tag that is based on the value in your first tag, there's always the system.opc.readValue scripting function:
First off, you should be using the preformatted text to paste your code (go back and edit your posts) to make it more readable.
Most likely your value you get from your first tag isn't going to be a correctly formatted OPC item path, but could be a tag name or an index value of an array. Let's say for fun that it returns the name of the base tag in the PLC that you need to get the value from, your script to update the OPC Item Path parameter on the second tag would look something like this:
Hi! I'm still trying to modify a tag name I'm pulling from an OPC Tag. The Tag returns the string "XX\AT_P7". I want to make a new expression tag that just keeps the "AT_P7". I tried using the replace function but I keep getting errors, any help would be appreciated, thanks!
Hey! I use tabs....but when I'm writing code directly in the pre-formatted text it wouldn't let me tab it over, so used spaces instead. (I guess I could have copy/pasted to a text editor then put it back, but was taking a shortcut).