I have a variety of sensors connected to the gateway OPC UA server through the TCP driver. I’m trying to figure out how to parse the values written into the tags with the Instrument Interface, ultimately.
The instrument interface is really for parsing data from serial devices or files. If you are using the TCP driver you already have the values as tags. You can create expression tags to perform string manipulations on the values for some simple parsing.
If you have an example of the string you can post it and we can help you out.
Ok, you can make expression tags that have an expression like this:try(split({[~]RawTag}, " ")[0,0], "Unknown")That will get out the id of the device. Replace the {[~]RawTag} with the path to your string tag. To get the type of the device:try(split({[~]RawTag}, " ")[1,0], "Unknown")Lastly, to get the value:try(split({[~]RawTag}, " ")[3,0], 0.0)
Awesome. Thanks. One more question. Let’s say I have a thermometer component. I want to update it on a Tag Change event. How do I reference the thermometer (let’s say it’s in the main window) within the event script?
Thanks a lot. I’ve been reading the forum all morning and it really is full of helpful info.
You don’t need to do anything with scripts. Just simply bind the thermometer property to the tag. There is a bind button to the right of each property. You can also drag the tag you created to the appropriate property of the thermometer and it wil do the same thing.
But then how do I set the thermometer to the parsed value from the tag? Do I create a second tag from the parsed values from the tag created by the TCP Driver and use that new tag for the thermometer?
Sorry if I sound like an idiot. I’m somewhat of a noob.
Yes, you create a second tag that is an expression tag with one of the expressions I mentioned earlier. You can bind the component to the new expression tag. Expression tags are used just like OPC tags except the values come from a calculation which in this case is the parsed value.
Try inserting the tag paths with the built in “insert tag” button on the right side of the expression window, those should give you the correct path references for your tags.