OPCFoundation / UA-ModelCompiler

ModelCompiler converts XML files into C# and ANSI C
MIT License
151 stars 94 forks source link

ISA-95 model [question] #37

Closed rudoq32 closed 4 years ago

rudoq32 commented 5 years ago

Is it planned to add ISA-95 design model files (.csv, .xml) into Design folders?

randy-armstrong commented 5 years ago

Yes, when they are provided by the WG.

rudoq32 commented 5 years ago

Hi Randy, and by a chance do you have a rough idea, how much that could take? Why I am asking: I my university (Slovak University of Technology) we are trying to leverage OPC UA to some higher control functions and we want to follow the information interoperability and use companion specifications. To build a node set model we could also use UAModeler (which is capable to import node set), but some functionalities and default value setting of parent nodes cannot be done there. I evaluated the effort of "translating" node set to model design and it seems to be too high.

sixdiamants commented 5 years ago

Hi Rudolf, for what it's worth, I wrote a converter that translates UML into a design file. In fact, I used python and Enterprise Architect, a widespread UML tool, to convert UML class models into design XML that is subsequently translated into address space. A similar approach should be possible from other UML tooling. Regards, Bob

rudoq32 commented 5 years ago

Hi Bob, what I did so far is that I created C# classes from types XSD for Node Set and Mode Design. Like this:

.\xsd.exe C:\Projects\UA-Nodeset\Schema\Opc.Ua.Types.xsd C:\Projects\UA-Nodeset\Schema\UANodeSet.xsd C:\Projects\UA-Nodeset\ISA-95\OPC.ISA95.Types.xsd /o:C:\Projects\UA-Nodeset\ISA-95\Published\ /c
.\xsd.exe 'C:\tmp\UA-ModelCompiler\ModelCompiler\UA Model Design.xsd' /o:c:\Projects\WebMES\OpcUAModelDecompiler\ /c

For translation I do something like this:

public static explicit operator ua.ObjectTypeDesign(ISA95.UAObjectType obj)
{
            ua.ObjectTypeDesign output = new ua.ObjectTypeDesign();
            // copy properties

            // copy BrowseName
            output.BrowseName = obj.BrowseName;

            // copy DisplayName
            output.DisplayName = new ua.LocalizedText();
            if (!(obj.DisplayName is null) && obj.DisplayName.Length > 0)
            {                
                output.DisplayName.Value = obj.DisplayName[0].Value;
                output.DisplayName.Key = obj.DisplayName[0].Locale;
            }
            // Children            
            // TODO add Children property

            // References            
            List<ua.Reference> refList = new List<ua.Reference>();
            foreach (ISA95.Reference reference in obj.References)
            {
                ua.Reference uaRef = new ua.Reference() { IsInverse = !reference.IsForward };
                // TODO add node set
                uaRef.TargetId = new System.Xml.XmlQualifiedName(XmlConvert.EncodeName(reference.Value) );
                uaRef.ReferenceType = new System.Xml.XmlQualifiedName(XmlConvert.EncodeName(reference.ReferenceType));
                refList.Add(uaRef);
            }
            output.References = refList.ToArray();
...
}

What concerns me is the out put once I am serializing QualifiedNames into the XML (e.g. <q3:).

<?xml version="1.0" encoding="utf-8"?>
<ObjectTypeDesign xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:q1="1" SymbolicName="q1:ISA95ClassType" NumericId="4957" StringId="ns=1;i=4957" IsAbstract="true">
  <BrowseName xmlns="http://opcfoundation.org/UA/ModelDesign.xsd">1:ISA95ClassType</BrowseName>
  <DisplayName xmlns="http://opcfoundation.org/UA/ModelDesign.xsd">ISA95ClassType</DisplayName>
  <Description xmlns="http://opcfoundation.org/UA/ModelDesign.xsd">This abstract ObjectType is used to define groupings of functionality that is associated with an ISA95Object</Description>
  <References xmlns="http://opcfoundation.org/UA/ModelDesign.xsd">
    <Reference IsInverse="true">
      <q2:ReferenceType xmlns="" xmlns:q2="http://opcfoundation.org/UA/ModelDesign.xsd">HasSubtype</q2:ReferenceType>
      <q3:TargetId xmlns="" xmlns:q3="http://opcfoundation.org/UA/ModelDesign.xsd">i_x005F_x003D_58</q3:TargetId>
    </Reference>
  </References>
</ObjectTypeDesign>   

Frankly speaking, I am not so much familiar with XML and namespaces and therefore I am also failing with creating the final NodeSet.

rudoq32 commented 4 years ago

Issue moved to ISA95 model - missing Opc.ISA95.Model.xml file #49.

mpostol commented 4 years ago

Let me inform you that OPC UA Address Space Model Designer has been just published on GitHub:

OPC UA Address Space Model Designer

For now, it is a stand-alone project, but any ideas related to harmonization with your needs are welcome. Further development and priorities will be derived from community feedback. The old installation package is still available on the commsvr.com web-page:

http://www.commsvr.com/COInstal/UAModelDesignerPro/setup.exe

This version will not be maintained anymore. An official statement will be published just after releasing the public version.

I am also in the process of moving the CommServer software family to open source. The master plan is available here:

Any questions, suggestions, and proposals are welcome.