Beispiel #1
0
        private void ImportXml(IDictionary <NodeId, IList <IReference> > externalReferences, string resourcepath)
        {
            NodeState mnode = null;

            try
            {
                NodeStateCollection predefinedNodes = new NodeStateCollection();

                Stream stream = new FileStream(resourcepath, FileMode.Open);
                Opc.Ua.Export.UANodeSet nodeSet = Opc.Ua.Export.UANodeSet.Read(stream);

                foreach (string namespaceUri in nodeSet.NamespaceUris)
                {
                    SystemContext.NamespaceUris.GetIndexOrAppend(namespaceUri);
                }
                nodeSet.Import(SystemContext, predefinedNodes);

                for (int ii = 0; ii < predefinedNodes.Count; ii++)
                {
                    // die gefundenen Knoten in Hauptspeicher-Struktur laden
                    AddPredefinedNode(SystemContext, predefinedNodes[ii]);
                }


                // ensure the reverse refernces exist.
                AddReverseReferences(externalReferences);
            }
            catch (Exception fehler)
            {
                Console.WriteLine("Fehler in ImportXML: --> \n" + fehler.Message);
                throw;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Import NodeSets from xml
        /// </summary>
        /// <param name="path">String to path of XML</param>
        public void ImportXml(string resourcepath)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();

            Stream stream = new FileStream(resourcepath, FileMode.Open);

            Opc.Ua.Export.UANodeSet nodeSet = Opc.Ua.Export.UANodeSet.Read(stream);

            /*
             * if (nodeSet.NamespaceUris != null)
             * {
             *  foreach (string namespaceUri in nodeSet.NamespaceUris)
             *  {
             *      //SystemContext.NamespaceUris.GetIndexOrAppend(namespaceUri);
             *      SystemContext.NamespaceUris.Append(namespaceUri);
             *  }
             * }
             */

            nodeSet.Import(SystemContext, predefinedNodes);

            for (int ii = 0; ii < predefinedNodes.Count; ii++)
            {
                AddPredefinedNode(SystemContext, predefinedNodes[ii]);
            }
        }