Ejemplo n.º 1
0
        private static void ImportServer(CASLibOPCAddressSpace.AddressSpaceDataBase.ServersTableRow svr, string targetNamespace, UniqueName uniqueName, List <OpcUaModelCompiler.NodeDesign> nodes)
        {
            string           name    = NewName;
            XmlQualifiedName sftName = new XmlQualifiedName(NewName, targetNamespace);

            OpcUaModelCompiler.ObjectDesign sft = CreateFolder(sftName, svr.URLString, svr.URL.Path);
            sft.References = new OpcUaModelCompiler.Reference[] { new OpcUaModelCompiler.Reference()
                                                                  {
                                                                      IsInverse     = true,
                                                                      ReferenceType = CreateXmlQualifiedName(Opc.Ua.BrowseNames.Organizes),
                                                                      TargetId      = CreateXmlQualifiedName("ObjectsFolder")
                                                                  } };
            nodes.Add(sft);
            List <OpcUaModelCompiler.InstanceDesign> cldrn = new List <OpcUaModelCompiler.InstanceDesign>();

            foreach (CASLibOPCAddressSpace.AddressSpaceDataBase.TagsTableRow item in svr.GetTagsTableRows())
            {
                ImportTag(item, targetNamespace, uniqueName, sft.SymbolicName, nodes, cldrn);
            }
            sft.Children = new OpcUaModelCompiler.ListOfChildren()
            {
                Items = cldrn.ToArray()
            };
        }
Ejemplo n.º 2
0
 private static void ImportTag
 (
     CASLibOPCAddressSpace.AddressSpaceDataBase.TagsTableRow parentItem,
     string targetNamespace,
     UniqueName uniqueName,
     XmlQualifiedName parentObject,
     List <OpcUaModelCompiler.NodeDesign> nodes,
     List <OpcUaModelCompiler.InstanceDesign> parentChildren
 )
 {
     Opc.Da.BrowseElement pbe = parentItem.GetBrowseElement();
     if (pbe.IsItem)
     {
         OpcUaModelCompiler.VariableDesign var = new OpcUaModelCompiler.VariableDesign()
         {
             SymbolicName = new XmlQualifiedName(uniqueName.GetUniqueName(pbe.Name), targetNamespace),
             DisplayName  = new OpcUaModelCompiler.LocalizedText()
             {
                 Value = pbe.Name
             },
             DataType       = GetBaseDataType(),
             TypeDefinition = GetBaseDataVariableType(),
             Description    = new OpcUaModelCompiler.LocalizedText()
             {
                 Value = pbe.ItemName
             },
             AccessLevel          = OpcUaModelCompiler.AccessLevel.ReadWrite,
             AccessLevelSpecified = true,
             ValueRank            = OpcUaModelCompiler.ValueRank.Scalar,
             ValueRankSpecified   = true,
             WriteAccess          = 0
         };
         parentChildren.Add(var);
         SortedDictionary <int, Opc.Da.ItemProperty> prprts = new SortedDictionary <int, Opc.Da.ItemProperty>();
         foreach (Opc.Da.ItemProperty item in pbe.Properties)
         {
             prprts.Add(item.ID.Code, item);
         }
         if (prprts.ContainsKey(Opc.Da.Property.DATATYPE.Code))
         {
             GetDATATYPE(var, prprts[Opc.Da.Property.DATATYPE.Code]);
         }
         GetEUTYPE(var, prprts);
         if (prprts.ContainsKey(Opc.Da.Property.ACCESSRIGHTS.Code))
         {
             GetACCESSRIGHTS(var, prprts[Opc.Da.Property.ACCESSRIGHTS.Code]);
         }
     }
     else
     {
         OpcUaModelCompiler.ObjectDesign sf = CreateFolder(new XmlQualifiedName(uniqueName.GetUniqueName(pbe.Name), targetNamespace), pbe.ItemName, pbe.Name);
         nodes.Add(sf);
         List <OpcUaModelCompiler.InstanceDesign> myChildren = new List <OpcUaModelCompiler.InstanceDesign>();
         foreach (CASLibOPCAddressSpace.AddressSpaceDataBase.TagsTableRow item in parentItem.GetTagsTableRows())
         {
             ImportTag(item, targetNamespace, uniqueName, sf.SymbolicName, nodes, myChildren);
         }
         sf.Children = new OpcUaModelCompiler.ListOfChildren()
         {
             Items = myChildren.ToArray()
         };
         sf.References = new OpcUaModelCompiler.Reference[]
         { new OpcUaModelCompiler.Reference()
           {
               IsInverse     = true,
               ReferenceType = CreateXmlQualifiedName(Opc.Ua.BrowseNames.Organizes),
               TargetId      = parentObject
           } };
     }
 }