Пример #1
0
        public virtual void Initialise(CustomNodeManager2 nodeManager)
        {
            ApplicationNodeManager = nodeManager;
            if (string.IsNullOrEmpty(ResourcePath))
            {
                return;
            }
            NamespaceUris = new List <string>();
            NodeStateCollection predefinedNodeStateCollection = new NodeStateCollection();
            Stream    stream    = new FileStream(ResourcePath, FileMode.Open);
            UANodeSet uaNodeSet = UANodeSet.Read(stream);

            NamespaceUris.AddRange(ApplicationNodeManager.NamespaceUris);
            // Update namespace table
            if (uaNodeSet.NamespaceUris != null)
            {
                foreach (string namespaceUri in uaNodeSet.NamespaceUris)
                {
                    NamespaceUris.Add(namespaceUri);
                    ApplicationNodeManager.SystemContext.NamespaceUris.GetIndexOrAppend(namespaceUri);
                }
            }
            // Update server table
            if (uaNodeSet.ServerUris != null)
            {
                foreach (string serverUri in uaNodeSet.ServerUris)
                {
                    ServerUris.Add(serverUri);
                    ApplicationNodeManager.SystemContext.ServerUris.GetIndexOrAppend(serverUri);
                }
            }
            uaNodeSet.Import(ApplicationNodeManager.SystemContext, predefinedNodeStateCollection);
            NodeStateCollection = predefinedNodeStateCollection;
        }
Пример #2
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;
            }
        }
Пример #3
0
        /// <inheritdoc/>
        public void LoadUaDefinedTypes(ISystemContext context)
        {
            if (m_uaTypesLoaded)
            {
                return;
            }

            NodeStateCollection predefinedNodes = new NodeStateCollection();
            var assembly = typeof(ArgumentCollection).GetTypeInfo().Assembly;

            predefinedNodes.LoadFromBinaryResource(context, "Opc.Ua.Stack.Generated.Opc.Ua.PredefinedNodes.uanodes", assembly, true);

            for (int ii = 0; ii < predefinedNodes.Count; ii++)
            {
                BaseTypeState type = predefinedNodes[ii] as BaseTypeState;

                if (type == null)
                {
                    continue;
                }

                type.Export(context, m_nodes);
            }
            m_uaTypesLoaded = true;
        }
Пример #4
0
        /// <summary>
        /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
        /// </summary>
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();

            predefinedNodes.LoadFromBinaryResource(context, "Opc.Ua.Sample.TCD.TCD.PredefinedNodes.uanodes", this.GetType().GetTypeInfo().Assembly, true);
            return(predefinedNodes);
        }
Пример #5
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]);
            }
        }
Пример #6
0
        /// <summary>
        /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
        /// </summary>
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();

            predefinedNodes.LoadFromBinaryResource(context, "Quickstarts.Servers.Boiler.Boiler.PredefinedNodes.uanodes", this.GetType().GetTypeInfo().Assembly, true);
            return(predefinedNodes);
        }
Пример #7
0
        /// <summary>
        /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
        /// </summary>
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();

            predefinedNodes.LoadFromBinaryResource(context, "Quickstarts.SimpleEvents.Server.Quickstarts.SimpleEvents.PredefinedNodes.uanodes", null, true);
            return(predefinedNodes);
        }
Пример #8
0
        /// <summary>
        /// Loads a node set from a file or resource and adds them to the set of predefined nodes.
        /// </summary>
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();

            predefinedNodes.LoadFromBinaryResource(context, "Opc.Ua.Gds.Server.Model.Opc.Ua.Gds.PredefinedNodes.uanodes", typeof(ApplicationsNodeManager).GetTypeInfo().Assembly, true);
            return(predefinedNodes);
        }
Пример #9
0
        private void ImportNodeset2Xml(IDictionary <NodeId, IList <IReference> > externalReferences, string resourcepath, int pass)
        {
            // workaround for bug https://github.com/dotnet/runtime/issues/67622
            File.WriteAllText(resourcepath, File.ReadAllText(resourcepath).Replace("<Value/>", "<Value xsi:nil='true' />"));

            using (Stream stream = new FileStream(resourcepath, FileMode.Open))
            {
                UANodeSet nodeSet = UANodeSet.Read(stream);

                NodeStateCollection predefinedNodes = new NodeStateCollection();
                nodeSet.Import(SystemContext, predefinedNodes);
# if DEBUG
                DebugOutput(nodeSet, predefinedNodes);
#endif
                for (int i = 0; i < predefinedNodes.Count; i++)
                {
                    try
                    {
                        AddPredefinedNode(SystemContext, predefinedNodes[i]);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Pass " + pass.ToString() + ": Importing node ns=" + predefinedNodes[i].NodeId.NamespaceIndex + ";i=" + predefinedNodes[i].NodeId.Identifier + " (" + predefinedNodes[i].DisplayName + ") failed with error: " + ex.Message);
                    }
                }
            }
Пример #10
0
        /// <summary>
        /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
        /// </summary>
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();

            predefinedNodes.LoadFromBinaryResource(context, "TutorialServer.Model.TutorialModel.PredefinedNodes.uanodes", null, true);
            return(predefinedNodes);
        }
Пример #11
0
        /// <summary>
        /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
        /// </summary>
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();

            predefinedNodes.LoadFromBinaryResource(context, "Opc.Ua.Com.Common.Opc.Ua.Com.PredefinedNodes.uanodes", null, true);
            return(predefinedNodes);
        }
        /// <summary>
        /// Loads a node set from a file or resource and address them to the set of predefined nodes.
        /// </summary>
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            // We know the model name to load but because this project is compiled for different environments we don't know
            // the assembly it is in. Therefor we search for it:
            var assembly     = this.GetType().GetTypeInfo().Assembly;
            var names        = assembly.GetManifestResourceNames();
            var resourcePath = String.Empty;

            foreach (var module in names)
            {
                if (module.Contains("SampleCompany.SampleServer.Model.PredefinedNodes.uanodes"))
                {
                    resourcePath = module;
                    break;
                }
            }

            if (resourcePath == String.Empty)
            {
                // No assembly found containing the nodes of the model. Behaviour here can differ but in this case we just return null.
                return(null);
            }

            var predefinedNodes = new NodeStateCollection();

            predefinedNodes.LoadFromBinaryResource(context, resourcePath, assembly, true);
            return(predefinedNodes);
        }
Пример #13
0
        public void SaveNodestateCollectionAsNodeSet2(ISystemContext context, NodeStateCollection nsc, Stream stream,
            bool filterSingleNodeIds)
        {
            Opc.Ua.Export.UANodeSet nodeSet = new Opc.Ua.Export.UANodeSet();
            nodeSet.LastModified = DateTime.UtcNow;
            nodeSet.LastModifiedSpecified = true;

            foreach (var n in nsc)
                nodeSet.Export(context, n);

            if (filterSingleNodeIds)
            {
                // MIHO: There might be DOUBLE nodeIds in the the set!!!!!!!!!! WTF!!!!!!!!!!!!!
                // Brutally eliminate them
                var nodup = new List<Opc.Ua.Export.UANode>();
                foreach (var it in nodeSet.Items)
                {
                    var found = false;
                    foreach (var it2 in nodup)
                        if (it.NodeId == it2.NodeId)
                            found = true;
                    if (found)
                        continue;
                    nodup.Add(it);
                }
                nodeSet.Items = nodup.ToArray();
            }

            nodeSet.Write(stream);
        }
Пример #14
0
        public NodeStateCollection GenerateInjectNodeStates()
        {
            // new list
            var res = new NodeStateCollection();

            // Missing Object Types
            res.Add(AasUaNodeHelper.CreateObjectType("BaseInterfaceType",
                                                     ObjectTypeIds.BaseObjectType, new NodeId(17602, 0)));
            res.Add(AasUaNodeHelper.CreateObjectType("DictionaryFolderType",
                                                     ObjectTypeIds.FolderType, new NodeId(17591, 0)));
            res.Add(AasUaNodeHelper.CreateObjectType("DictionaryEntryType",
                                                     ObjectTypeIds.BaseObjectType, new NodeId(17589, 0)));
            res.Add(AasUaNodeHelper.CreateObjectType("UriDictionaryEntryType",
                                                     new NodeId(17589, 0), new NodeId(17600, 0)));
            res.Add(AasUaNodeHelper.CreateObjectType("IrdiDictionaryEntryType",
                                                     new NodeId(17589, 0), new NodeId(17598, 0)));

            // Missing Reference Types
            res.Add(AasUaNodeHelper.CreateReferenceType("HasDictionaryEntry", "DictionaryEntryOf",
                                                        ReferenceTypeIds.NonHierarchicalReferences, new NodeId(17597, 0)));
            res.Add(AasUaNodeHelper.CreateReferenceType("HasInterface", "InterfaceOf",
                                                        ReferenceTypeIds.NonHierarchicalReferences, new NodeId(17603, 0)));
            res.Add(AasUaNodeHelper.CreateReferenceType("HasAddIn", "AddInOf",
                                                        ReferenceTypeIds.HasComponent, new NodeId(17604, 0)));

            // deliver list
            return(res);
        }
        /// <summary>
        /// Writes the collection to a stream using the NodeSet schema.
        /// </summary>
        public static void SaveAsNodeSet(this NodeStateCollection collection, Stream ostrm,
                                         ISystemContext context)
        {
            var nodeTable = new NodeTable(context.NamespaceUris, context.ServerUris, null);

            foreach (var node in collection)
            {
                node.Export(context, nodeTable);
            }
            var nodeSet = new NodeSet();

            foreach (ILocalNode node in nodeTable)
            {
                nodeSet.Add(node, nodeTable.NamespaceUris, nodeTable.ServerUris);
            }
            var settings = new XmlWriterSettings {
                Encoding         = Encoding.UTF8,
                CloseOutput      = true,
                ConformanceLevel = ConformanceLevel.Document,
                Indent           = true
            };

            using (var writer = XmlWriter.Create(ostrm, settings)) {
                var serializer = new DataContractSerializer(typeof(NodeSet));
                serializer.WriteObject(writer, nodeSet);
            }
        }
Пример #16
0
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();

            predefinedNodes.LoadFromBinaryResource(context, Resources.BinaryNodePath.ToString(), this.GetType().GetTypeInfo().Assembly, true);
            Console.WriteLine("***MyOPCServer: number of Node loaded from source " + predefinedNodes.Count.ToString() + "***");
            return(predefinedNodes);
        }
Пример #17
0
        /// <summary>
        /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
        /// </summary>
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();

            predefinedNodes.LoadFromBinaryResource(context, "Quickstarts.DataTypes.Types.Quickstarts.DataTypes.Types.PredefinedNodes.uanodes", typeof(Quickstarts.DataTypes.Types.VehicleType).Assembly, true);
            predefinedNodes.LoadFromBinaryResource(context, "Quickstarts.DataTypes.Instances.Quickstarts.DataTypes.Instances.PredefinedNodes.uanodes", null, true);

            return(predefinedNodes);
        }
Пример #18
0
 /// <summary>
 /// Imports a node from the set.
 /// </summary>
 public void Import(ISystemContext context, NodeStateCollection nodes)
 {
     for (int ii = 0; ii < this.Items.Length; ii++)
     {
         UANode    node         = this.Items[ii];
         NodeState importedNode = Import(context, node);
         nodes.Add(importedNode);
     }
 }
Пример #19
0
 protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
 {
     NodeStateCollection predefinedNodes = new NodeStateCollection();
     predefinedNodes.LoadFromBinaryResource(context,
         "MicrosoftOpcUa.PredefinedNodes.uanodes",
         typeof(MicrosoftOpcUaNodeManager).GetTypeInfo().Assembly,
         true);
     return predefinedNodes;
 }
Пример #20
0
        /// <summary>
        /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
        /// </summary>
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();

            predefinedNodes.LoadFromBinaryResource(context,
                                                   "SimpleEvent/SimpleEvents.PredefinedNodes.uanodes",
                                                   typeof(SimpleEventsNodeManager).GetTypeInfo().Assembly,
                                                   true);
            return(predefinedNodes);
        }
        /// <summary>
        /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
        /// </summary>
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            // Set your .uanodes file to Build Action = Embedded Resource
            // resourcePath parameter of LoadFromBinaryResource() is project name + directory + file name

            NodeStateCollection predefinedNodes = new NodeStateCollection();

            predefinedNodes.LoadFromBinaryResource(context, "OpcUaChatServer.Server." + "OpcUa.Model.Published." + "OpcUaChatServer.PredefinedNodes.uanodes", this.GetType().GetTypeInfo().Assembly, true);
            return(predefinedNodes);
        }
        /// <summary>
        /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
        /// </summary>
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            var type            = GetType().GetTypeInfo();
            var predefinedNodes = new NodeStateCollection();

            predefinedNodes.LoadFromBinaryResource(context,
                                                   $"{type.Assembly.GetName().Name}.Servers.{type.Namespace}.Design.{type.Namespace}.PredefinedNodes.uanodes",
                                                   type.Assembly, true);
            return(predefinedNodes);
        }
        /// <summary>
        /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
        /// </summary>
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();

            predefinedNodes.LoadFromBinaryResource(context,
                                                   "Quickstarts.HistoricalEvents.Server.Model.Quickstarts.HistoricalEvents.PredefinedNodes.uanodes",
                                                   typeof(HistoricalEventsNodeManager).GetTypeInfo().Assembly,
                                                   true);
            return(predefinedNodes);
        }
Пример #24
0
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            var nodeStateCollection = new NodeStateCollection();

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ConverterSystems.Test.PredefinedNodes.xml"))
            {
                var nodeset = UANodeSet.Read(stream);
                nodeset.Import(context, nodeStateCollection);
            }
            return(nodeStateCollection);
        }
Пример #25
0
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();

            predefinedNodes.LoadFromBinaryResource(context,
                                                   @"ModelDesignOutput\ITSOPCCourseCode.OPCUA.SampleServer.PredefinedNodes.uanodes",
                                                   typeof(SampleNodeManager).GetTypeInfo().Assembly,
                                                   true);

            return(predefinedNodes);
        }
Пример #26
0
        /// <summary>
        /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
        /// </summary>
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();

            predefinedNodes.LoadFromBinaryResource(context,
                                                   "Quickstarts.Boiler.Server.Opc.Ua.MTConnect.PredefinedNodes.uanodes",
                                                   typeof(BoilerNodeManager).GetTypeInfo().Assembly,
                                                   true);
            predefinedNodes.LoadFromBinaryResource(context,
                                                   "Quickstarts.Boiler.Server.Quickstarts.Boiler.PredefinedNodes.uanodes",
                                                   typeof(BoilerNodeManager).GetTypeInfo().Assembly,
                                                   true);
            return(predefinedNodes);
        }
Пример #27
0
        private void ImportNodeset2Xml(IDictionary <NodeId, IList <IReference> > externalReferences, string resourcepath)
        {
            using (Stream stream = new FileStream(resourcepath, FileMode.Open))
            {
                UANodeSet nodeSet = UANodeSet.Read(stream);

                NodeStateCollection predefinedNodes = new NodeStateCollection();
                nodeSet.Import(SystemContext, predefinedNodes);

                for (int i = 0; i < predefinedNodes.Count; i++)
                {
                    AddPredefinedNode(SystemContext, predefinedNodes[i]);
                }
            }
        }
Пример #28
0
        /// <summary>
        /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
        /// </summary>
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();

            for (int ix = 0; ix < m_allPredefinedNodes.Length; ix++)
            {
                FileInfo fiPredifinedNodes = CASConfiguration.PreparePathBasedOnBaseDirectory(m_allPredefinedNodes[ix].PredefinedNodes);
                using (Stream reader = File.Open(fiPredifinedNodes.FullName, FileMode.Open))
                {
                    predefinedNodes.LoadFromBinary(context, reader, true);
                }
                FileInfo csvFi = CASConfiguration.PreparePathBasedOnBaseDirectory(m_allPredefinedNodes[ix].CSVFile);
                m_DataBindings.LoadIdentifiersFromFile(csvFi.FullName);
            }
            return(predefinedNodes);
        }
Пример #29
0
        /// <summary>
        /// Loads the UA defined types into the cache.
        /// </summary>
        /// <param name="context">The context.</param>
        public void LoadUaDefinedTypes(ISystemContext context)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();

            predefinedNodes.LoadFromBinaryResource(context, "Opc.Ua.Stack.Generated.Opc.Ua.PredefinedNodes.uanodes", typeof(NodeState).Assembly, true);

            for (int ii = 0; ii < predefinedNodes.Count; ii++)
            {
                BaseTypeState type = predefinedNodes[ii] as BaseTypeState;

                if (type == null)
                {
                    continue;
                }

                type.Export(context, m_nodes);
            }
        }
 /// <summary>
 /// Writes collection as json
 /// </summary>
 /// <param name="collection"></param>
 /// <param name="context"></param>
 /// <param name="formatting"></param>
 /// <param name="ostrm"></param>
 public static void SaveAsJson(this NodeStateCollection collection, Stream ostrm,
                               Newtonsoft.Json.Formatting formatting, ISystemContext context)
 {
     using (var encoder = new JsonEncoderEx(ostrm, context.ToMessageContext(),
                                            JsonEncoderEx.JsonEncoding.Array, formatting)
     {
         UseAdvancedEncoding = true,
         IgnoreDefaultValues = true
     }) {
         foreach (var node in collection.ToNodeModels(context))
         {
             if (node != null)
             {
                 encoder.WriteEncodeable(null, new EncodeableNodeModel(node));
             }
         }
     }
 }
Пример #31
0
 /// <summary>
 /// Imports a node from the set.
 /// </summary>
 public void Import(ISystemContext context, NodeStateCollection nodes)
 {
     for (int ii = 0; ii < this.Items.Length; ii++)
     {
         UANode node = this.Items[ii];
         NodeState importedNode = Import(context, node);
         nodes.Add(importedNode);
     }
 }
        /// <summary>
        /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
        /// </summary>
        public virtual void LoadPredefinedNodes(
            ISystemContext context, 
            Assembly assembly,
            string resourcePath,
            IDictionary<NodeId,IList<IReference>> externalReferences)
        {
            // load the predefined nodes from an XML document.
            NodeStateCollection predefinedNodes = new NodeStateCollection();
            predefinedNodes.LoadFromResource(context, resourcePath, assembly, true);

            // add the predefined nodes to the node manager.
            for (int ii = 0; ii < predefinedNodes.Count; ii++)
            {
                AddPredefinedNode(context, predefinedNodes[ii]);
            }

            // ensure the reverse refernces exist.
            AddReverseReferences(externalReferences);
        }
Пример #33
0
 /// <summary>
 /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
 /// </summary>
 protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
 {
     NodeStateCollection predefinedNodes = new NodeStateCollection();
     predefinedNodes.LoadFromBinaryResource(context, "Quickstarts.ViewsServer.Model.Quickstarts.Views.PredefinedNodes.uanodes", null, true);
     return predefinedNodes;
 }
        /// <summary>
        /// Loads the UA defined types into the cache.
        /// </summary>
        /// <param name="context">The context.</param>
        public void LoadUaDefinedTypes(ISystemContext context)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();
            predefinedNodes.LoadFromBinaryResource(context, "Opc.Ua.Core.Stack.Generated.Opc.Ua.PredefinedNodes.uanodes", typeof(ArgumentCollection).GetTypeInfo().Assembly, true);
            
            for (int ii = 0; ii < predefinedNodes.Count; ii++)
            {
                BaseTypeState type = predefinedNodes[ii] as BaseTypeState;

                if (type == null)
                {
                    continue;
                }

                type.Export(context, m_nodes);
            }
        }
Пример #35
0
 /// <summary>
 /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
 /// </summary>
 protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
 {
     NodeStateCollection predefinedNodes = new NodeStateCollection();
     predefinedNodes.LoadFromBinaryResource(context, "Opc.Ua.Com.Common.Opc.Ua.Com.PredefinedNodes.uanodes", null, true);
     return predefinedNodes;
 }
Пример #36
0
        /// <summary>
        /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
        /// </summary>
        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
        {
            NodeStateCollection predefinedNodes = new NodeStateCollection();
            
            predefinedNodes.LoadFromBinaryResource(context, "Quickstarts.DataTypes.Types.Quickstarts.DataTypes.Types.PredefinedNodes.uanodes", typeof(Quickstarts.DataTypes.Types.VehicleType).Assembly, true);
            predefinedNodes.LoadFromBinaryResource(context, "Quickstarts.DataTypes.Instances.Quickstarts.DataTypes.Instances.PredefinedNodes.uanodes", null, true);

            return predefinedNodes;
        }
Пример #37
0
        /// <summary>
        /// Indexes the well known subtypes.
        /// </summary>
        private void IndexWellKnownTypes()
        {
            SystemContext context = new SystemContext();
            context.EncodeableFactory = m_session.MessageContext.Factory;
            context.NamespaceUris = m_session.NamespaceUris;
            context.ServerUris = m_session.ServerUris;

            NodeStateCollection predefinedNodes = new NodeStateCollection();
            predefinedNodes.LoadFromBinaryResource(context, "Opc.Ua.Stack.Generated.Opc.Ua.PredefinedNodes.uanodes", typeof(NodeState).Assembly, true);
            
            NodeIdDictionary<BaseTypeState> types = new NodeIdDictionary<BaseTypeState>();

            // collect the instance declarations for all types.
            for (int ii = 0; ii < predefinedNodes.Count; ii++)
            {
                BaseTypeState type = predefinedNodes[ii] as BaseTypeState;

                if (type != null)
                {
                    types.Add(type.NodeId, type);
                }
            }

            // index only those types which are subtypes of BaseEventType.
            foreach (BaseTypeState type in types.Values)
            {
                BaseTypeState subType = type;
                BaseTypeState superType = null;

                int eventType = 0;

                while (subType != null)
                {
                    if (subType.NodeId == Opc.Ua.ObjectTypeIds.ConditionType || subType.SuperTypeId == Opc.Ua.ObjectTypeIds.ConditionType)
                    {
                        eventType = OpcRcw.Ae.Constants.CONDITION_EVENT;
                    }

                    else if (subType.NodeId == Opc.Ua.ObjectTypeIds.AuditEventType || subType.SuperTypeId == Opc.Ua.ObjectTypeIds.AuditEventType)
                    {
                        eventType = OpcRcw.Ae.Constants.TRACKING_EVENT;
                    }

                    else if (subType.NodeId == Opc.Ua.ObjectTypeIds.BaseEventType || subType.SuperTypeId == Opc.Ua.ObjectTypeIds.BaseEventType)
                    {
                        eventType = OpcRcw.Ae.Constants.SIMPLE_EVENT;
                    }

                    // found an event, collect the attribute and index it.
                    if (eventType != 0)
                    {
                        List<AeEventAttribute> declarations = new List<AeEventAttribute>();
                        Dictionary<string, AeEventAttribute> map = new Dictionary<string, AeEventAttribute>();

                        ComAeUtils.CollectInstanceDeclarations(
                            m_session,
                            this,
                            type,
                            null,
                            declarations,
                            map);

                        AeEventCategory declaration = new AeEventCategory();
                        declaration.TypeId = type.NodeId;
                        declaration.SuperTypeId = type.SuperTypeId;
                        declaration.EventType = eventType;
                        declaration.Description = (LocalizedText.IsNullOrEmpty(type.DisplayName))?type.BrowseName.Name:type.DisplayName.Text;
                        declaration.Attributes = declarations;
                        m_eventTypes[declaration.TypeId] = declaration;
                        break;
                    }

                    // follow the tree to the parent.
                    if (!types.TryGetValue(subType.SuperTypeId, out superType))
                    {
                        break;
                    }

                    subType = superType;
                }
            }

            // hide the built in attributes.
            AeEventCategory category = GetCategory(Opc.Ua.ObjectTypeIds.BaseEventType);

            if (category != null)
            {
                for (int ii = 0; ii < category.Attributes.Count; ii++)
                {
                    switch (category.Attributes[ii].BrowsePathDisplayText)
                    {
                        case Opc.Ua.BrowseNames.Message:
                        case Opc.Ua.BrowseNames.Severity:
                        case Opc.Ua.BrowseNames.SourceName:
                        case Opc.Ua.BrowseNames.Time:
                        case Opc.Ua.BrowseNames.ReceiveTime:
                        case Opc.Ua.BrowseNames.LocalTime:
                        {
                            category.Attributes[ii].Hidden = true;
                            break;
                        }
                    }
                }
            }
        }
Пример #38
0
 /// <summary>
 /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
 /// </summary>
 protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
 {
     NodeStateCollection predefinedNodes = new NodeStateCollection();
     predefinedNodes.LoadFromBinaryResource(context, "DsatsDemoServer.Model.DsatsDemo.PredefinedNodes.uanodes", null, true);
     return predefinedNodes;
 }
 /// <summary>
 /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
 /// </summary>
 protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
 {
     NodeStateCollection predefinedNodes = new NodeStateCollection();
     predefinedNodes.LoadFromBinaryResource(context, "Opc.Ua.Sample.TestData.TestData.PredefinedNodes.uanodes", this.GetType().GetTypeInfo().Assembly, true);
     return predefinedNodes;
 }
Пример #40
0
 /// <summary>
 /// Loads a node set from a file or resource and addes them to the set of predefined nodes.
 /// </summary>
 protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
 {
     NodeStateCollection predefinedNodes = new NodeStateCollection();
     predefinedNodes.LoadFromBinaryResource(context, "Opc.Ua.Stack.Generated.Opc.Ua.PredefinedNodes.uanodes", typeof(NodeState).Assembly, true);
     return predefinedNodes;
 }