Bulk editing UDT OPC tag paths for new OPC server

I have to convert an installation from using CoDeSys' OPC-DA driver to using KepserverEx. There are a load of UDTs for hundreds of tags.

Changing the OPC server isn't too bad as I can group select the OPC tags, right-click, Edit Tags (in the UDT editor) and set the OPC Server to KepserverEX all at once.

I have to change each OPC Item Path from something of the form,
ABCD_{Machine}.{OtherStuff}TmpHmiRO.StationFault[3]
to

nsu=KEPServerEX;s=ABCD_CODESYS.{Machine}.{OtherStuff}TmpHmiRO.StationFault[3]

(KepserverEx requires setting a channel for the brand of PLC and this has to be added to the nsu. The previous driver was CoDeSys only so didn't need a channel.)

How should I be doing this in a manner to preserve sanity and save time? Exporting the UDT seems to give only a summary of the UDT without the OPC Item Paths.

Many thanks.

Edit the definition, where the OPC Item Path is defined with parameter substitutions. You can probably fix it entirely there.

I have done it this way, but it was removing Kepserver due to poor performance.
Just changed all the UDT references and all the instances updated.

Sorry if it wasn't clear, but there are hundreds of tags in the UDT definition. Phil, even with parameter substitutions I'd have to edit each tag in the UDT, wouldn't I?

Ah. I'd export the UDT definition as JSON, use regexp in a smart editor to fix those patterns, and re-import the definition.

I go to Tag Browser, UDT Definitions, right-click on the UDT, Export Tags and I get this in the tags.json file:

tags.json
{
  "name": "FrontLeft",
  "typeId": "ABCD_UDT_Folder/Punchers/Punching/PunchParams_5-8",
  "parameters": {
    "Side": {
      "dataType": "String",
      "value": "Left"
    },
    "PosSide": {
      "dataType": "String",
      "value": "FL"
    },
    "Machine": {
      "dataType": "String",
      "value": {
        "bindType": "parameter",
        "binding": "{Machine}"
      }
    },
    "TagStructure": {
      "dataType": "String",
      "value": {
        "bindType": "parameter",
        "binding": "{TagStructure}"
      }
    },
    "Position": {
      "dataType": "String",
      "value": "Front"
    }
  },
  "tagType": "UdtInstance",
  "tags": [
    {
      "name": "NoContinuityCnt",
      "tagType": "AtomicTag"
    },
    {
      "name": "Ph3_GenOffDelay",
      "tagType": "AtomicTag"
    },
    {
      "name": "Ph3_MaxPunchPosition",
      "tagType": "AtomicTag"
    },
    {
      "name": "FeedbackPOS_PH2Start",
      "tagType": "AtomicTag"
    },
    {
      "name": "Ph1_Force2Position",
      "tagType": "AtomicTag"
    },
    {
      "name": "Ph3_Force3",
      "tagType": "AtomicTag"
    },
    {
      "name": "Ph1_GeneratorOnPos",
      "tagType": "AtomicTag"
    },
    {
      "name": "MandrelContactPos",
      "tagType": "AtomicTag"
    },
    {
      "name": "Ph1_GeneratorAmp",
      "tagType": "AtomicTag"
    },
    {
      "name": "FeedbackGripperPositionScaled",
      "tagType": "AtomicTag"
    },
    {
      "name": "FeedbackGripperPosition",
      "tagType": "AtomicTag"
    },
    {
      "name": "FeedbackPOS_PH1Start",
      "tagType": "AtomicTag"
    },
    {
      "name": "Ph1_Force1",
      "tagType": "AtomicTag"
    },
    {
      "name": "FeedbackGripperForce",
      "tagType": "AtomicTag"
    },
    {
      "name": "Ph3_HoldPostPunching",
      "tagType": "AtomicTag"
    },
    {
      "name": "Ph3_GeneratorAmp",
      "tagType": "AtomicTag"
    },
    {
      "sourceDataType": "Float4",
      "name": "WeldingTime",
      "tagType": "AtomicTag"
    }
  ]
}

No details on the tags.
I'm missing something fundamental here, I suspect.

Do you have a screenshot of that same UDT showing expression bindings on those tags? If not, I suspect someone created the UDT but then manually modified each instance and tagged each one separately. If so....you may be exporting all tags and changing it on every single tag with some scripting and regex if you can find a good pattern.

That isn't a UDT definition.

Right click on the UDT definition and Copy JSON.

That was the problem. I was copying an instance of the UDT in another UDT.
Examining the Parent Data Type got me to the actual UDT definition. JSON looks good and I can easily search and replace.

I presume that I just paste the modified JSON back onto the UTD icon?

Thanks, guys.

No, paste it onto the folder in which that definition exists. It'll be replaced.

Job done using Find and Replace in the text editor.
Thanks guys.

2 Likes