コード例 #1
0
ファイル: BoilerFactory.cs プロジェクト: fcl-93/OPC-UA-Server
        private void CreateBoiler()
        {
            Boiler = new BoilerState(null);
            Boiler.Create(m_nodeManager.SystemContext, new NodeId(countBoilers, m_namespaceindex), new QualifiedName(m_BoilerName, m_nodeManager.NamespaceIndexes[0]), null, true);

            IList <BaseInstanceState> children = new List <BaseInstanceState>();

            Boiler.GetChildren(m_nodeManager.SystemContext, children);
            RecursiveNodeIdChanger(children);

            List <IReference> references = new List <IReference>();

            references.Add(new NodeStateReference(ReferenceTypeIds.Organizes, false, Boiler.NodeId));
            m_parentNode.AddChild(Boiler);
        }
コード例 #2
0
        /// <summary>
        /// Does any initialization required before the address space can be used.
        /// </summary>
        /// <remarks>
        /// The externalReferences is an out parameter that allows the node manager to link to nodes
        /// in other node managers. For example, the 'Objects' node is managed by the CoreNodeManager and
        /// should have a reference to the root folder node(s) exposed by this node manager.
        /// </remarks>
        public override void CreateAddressSpace(IDictionary <NodeId, IList <IReference> > externalReferences)
        {
            lock (Lock)
            {
                LoadPredefinedNodes(SystemContext, externalReferences);

                // find the untyped Boiler1 node that was created when the model was loaded.
                BaseObjectState passiveNode = (BaseObjectState)FindPredefinedNode(new NodeId(Objects.Boiler1, NamespaceIndexes[0]), typeof(BaseObjectState));

                // convert the untyped node to a typed node that can be manipulated within the server.
                m_boiler1 = new BoilerState(null);
                m_boiler1.Create(SystemContext, passiveNode);

                // replaces the untyped predefined nodes with their strongly typed versions.
                AddPredefinedNode(SystemContext, m_boiler1);

                // create a boiler node.
                m_boiler2 = new BoilerState(null);

                // initialize it from the type model and assign unique node ids.
                m_boiler2.Create(
                    SystemContext,
                    null,
                    new QualifiedName("Boiler #2", NamespaceIndexes[1]),
                    null,
                    true);

                // link root to objects folder.
                IList <IReference> references = null;

                if (!externalReferences.TryGetValue(Opc.Ua.ObjectIds.ObjectsFolder, out references))
                {
                    externalReferences[Opc.Ua.ObjectIds.ObjectsFolder] = references = new List <IReference>();
                }

                references.Add(new NodeStateReference(Opc.Ua.ReferenceTypeIds.Organizes, false, m_boiler2.NodeId));

                // store it and all of its children in the pre-defined nodes dictionary for easy look up.
                AddPredefinedNode(SystemContext, m_boiler2);

                // start a simulation that changes the values of the nodes.
                m_simulationTimer = new Timer(DoSimulation, null, 1000, 1000);
            }
        }
コード例 #3
0
ファイル: BoilerNodeManager.cs プロジェクト: yuriik83/UA-.NET
        /// <summary>
        /// Does any initialization required before the address space can be used.
        /// </summary>
        /// <remarks>
        /// The externalReferences is an out parameter that allows the node manager to link to nodes
        /// in other node managers. For example, the 'Objects' node is managed by the CoreNodeManager and
        /// should have a reference to the root folder node(s) exposed by this node manager.  
        /// </remarks>
        public override void CreateAddressSpace(IDictionary<NodeId, IList<IReference>> externalReferences)
        {
            lock (Lock)
            {
                LoadPredefinedNodes(SystemContext, externalReferences);
                
                // find the untyped Boiler1 node that was created when the model was loaded.
                BaseObjectState passiveNode = (BaseObjectState)FindPredefinedNode(new NodeId(Objects.Boiler1, NamespaceIndexes[0]), typeof(BaseObjectState));

                // convert the untyped node to a typed node that can be manipulated within the server.
                m_boiler1 = new BoilerState(null);
                m_boiler1.Create(SystemContext, passiveNode);

                // replaces the untyped predefined nodes with their strongly typed versions.
                AddPredefinedNode(SystemContext, m_boiler1);

                // create a boiler node.
                m_boiler2 = new BoilerState(null);

                // initialize it from the type model and assign unique node ids.
                m_boiler2.Create(
                    SystemContext,
                    null,
                    new QualifiedName("Boiler #2", NamespaceIndexes[1]),
                    null,
                    true);

                // link root to objects folder.
                IList<IReference> references = null;

                if (!externalReferences.TryGetValue(Opc.Ua.ObjectIds.ObjectsFolder, out references))
                {
                    externalReferences[Opc.Ua.ObjectIds.ObjectsFolder] = references = new List<IReference>();
                }

                references.Add(new NodeStateReference(Opc.Ua.ReferenceTypeIds.Organizes, false, m_boiler2.NodeId));

                // store it and all of its children in the pre-defined nodes dictionary for easy look up.
                AddPredefinedNode(SystemContext, m_boiler2);

                // start a simulation that changes the values of the nodes.
                m_simulationTimer = new Timer(DoSimulation, null, 1000, 1000);
            }
        }