robbudge Posted February 2, 2018 Share Posted February 2, 2018 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 More sharing options...
AzeoTech Posted February 4, 2018 Share Posted February 4, 2018 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 More sharing options...
robbudge Posted February 6, 2018 Author Share Posted February 6, 2018 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 More sharing options...
AzeoTech Posted February 6, 2018 Share Posted February 6, 2018 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.