OPC Auto Channel Creation


Recommended Posts

Due to having large projects 5000+ Tags, 

Codesys OPC Configuration is via a Symbol XML file this is a structured file with Class types and class instances.

We use another HMI Package to Import the Codesys OPC Symbol File and basically turn it into a flat list.

We then export the flat list as a CSV file.

We have built a Sequence with DAQ that deletes the channel table and rebuilds it from the CSV file, Placing each Class instance in its own Group.

We pre-specify the OPC Connection path

 

This works really well but is very cumbersome.

We are looking into building a Sequence from scratch to parse the Codesys XML directly, but before we spend a week designing and testing.

Has this already been done ?

is there a easier way ??

I was looking if i could browse the OPC Server Directly  from with a Sequence almost like channel.ListAll , But OPC.ListAll ??

 

 

92780517-18.Controller.Application.xml

Link to comment
Share on other sites

I don't know that it has been done, but DAQFactory does have a built in JSON parser, so I would use a tool to convert XML to JSON (I found one in about 3 minutes that was able to convert your file once you remove the first line), then you can write some script to load the json and parse it into a DAQFactory object tree.  Then you can just use script to parse through the objects and add channels.  Should be pretty easy for someone with scripting experience like yourself.

Link to comment
Share on other sites

On 2018-02-04 at 12:18 AM, AzeoTech said:

I don't know that it has been done, but DAQFactory does have a built in JSON parser, so I would use a tool to convert XML to JSON (I found one in about 3 minutes that was able to convert your file once you remove the first line), then you can write some script to load the json and parse it into a DAQFactory object tree.  Then you can just use script to parse through the objects and add channels.  Should be pretty easy for someone with scripting experience like yourself.

Wa Already looking into Json Conversion,

DO you have a Sample Json, or Sequence ????

On a Initial test I get a Class_Not_Found Error.

Also I can't find a command to request the class members / Sub members  to start building the channel table.

 

I have also started to build the class list directly from the XML, with the hope of building the Channel table that way

Link to comment
Share on other sites

You can't use fromJson() globally.  That expects a class type (in the "_ClassName" field) so it can create the class for you.  That is more for when you do toJson() to create a json representation of your object, then want to recreate the object.

To do it from a raw json file, you need to create a blank class, instantiate it as an object, then call fromJson() on it.  Something like this:

private handle = file.Open("c:\robbudge.json",1,0,0,0)
private string datain = file.Read(handle, file.GetLength(handle))
file.Close(handle)

class myClass
endclass

global xml = new(myClass)
xml.fromJson(datain)
 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share