FindBlock() публичный Метод

Finds a block.
public FindBlock ( string blockId ) : UnderlyingSystemBlock
blockId string The block identifier.
Результат UnderlyingSystemBlock
        /// <summary>
        /// Used to receive notifications when the value attribute is read or written.
        /// </summary>
        public ServiceResult OnWriteTagValue(
            ISystemContext context,
            NodeState node,
            ref object value)
        {
            UnderlyingSystem system = context.SystemHandle as UnderlyingSystem;

            if (system == null)
            {
                return(StatusCodes.BadCommunicationError);
            }

            UnderlyingSystemBlock block = system.FindBlock(m_blockId);

            if (block == null)
            {
                return(StatusCodes.BadNodeIdUnknown);
            }

            uint error = block.WriteTagValue(node.SymbolicName, value);

            if (error != 0)
            {
                // the simulator uses UA status codes so there is no need for a mapping table.
                return(error);
            }

            return(ServiceResult.Good);
        }
        /// <summary>
        /// Starts the monitoring the block.
        /// </summary>
        /// <param name="context">The context.</param>
        public void StartMonitoring(ServerSystemContext context)
        {
            if (m_monitoringCount == 0)
            {
                UnderlyingSystem system = context.SystemHandle as UnderlyingSystem;

                if (system != null)
                {
                    UnderlyingSystemBlock block = system.FindBlock(m_blockId);

                    if (block != null)
                    {
                        block.StartMonitoring(OnTagsChanged);
                    }
                }
            }

            m_monitoringCount++;
        }
        /// <summary>
        /// Stop the monitoring the block.
        /// </summary>
        /// <param name="context">The context.</param>
        public bool StopMonitoring(ServerSystemContext context)
        {
            m_monitoringCount--;

            if (m_monitoringCount == 0)
            {
                UnderlyingSystem system = context.SystemHandle as UnderlyingSystem;

                if (system != null)
                {
                    UnderlyingSystemBlock block = system.FindBlock(m_blockId);

                    if (block != null)
                    {
                        block.StopMonitoring();
                    }
                }
            }

            return(m_monitoringCount != 0);
        }
Пример #4
0
        /// <summary>
        /// Returns the next child.
        /// </summary>
        private IReference NextChild()
        {
            UnderlyingSystem system = (UnderlyingSystem)this.SystemContext.SystemHandle;

            NodeId targetId = null;

            // check if a specific browse name is requested.
            if (!QualifiedName.IsNull(base.BrowseName))
            {
                // check if match found previously.
                if (m_position == Int32.MaxValue)
                {
                    return(null);
                }

                // browse name must be qualified by the correct namespace.
                if (m_source.BrowseName.NamespaceIndex != base.BrowseName.NamespaceIndex)
                {
                    return(null);
                }

                // look for matching segment.
                if (m_stage == Stage.Segments && m_segments != null)
                {
                    for (int ii = 0; ii < m_segments.Count; ii++)
                    {
                        if (base.BrowseName.Name == m_segments[ii].Name)
                        {
                            targetId = ModelUtils.ConstructIdForSegment(m_segments[ii].Id, m_source.NodeId.NamespaceIndex);
                            break;
                        }
                    }
                }

                // look for matching block.
                if (m_stage == Stage.Blocks && m_blocks != null)
                {
                    for (int ii = 0; ii < m_blocks.Count; ii++)
                    {
                        UnderlyingSystemBlock block = system.FindBlock(m_blocks[ii]);

                        if (block != null && base.BrowseName.Name == block.Name)
                        {
                            targetId = ModelUtils.ConstructIdForBlock(m_blocks[ii], m_source.NodeId.NamespaceIndex);
                            break;
                        }
                    }
                }

                m_position = Int32.MaxValue;
            }

            // return the child at the next position.
            else
            {
                // look for next segment.
                if (m_stage == Stage.Segments && m_segments != null)
                {
                    if (m_position >= m_segments.Count)
                    {
                        return(null);
                    }

                    targetId = ModelUtils.ConstructIdForSegment(m_segments[m_position++].Id, m_source.NodeId.NamespaceIndex);
                }

                // look for next block.
                else if (m_stage == Stage.Blocks && m_blocks != null)
                {
                    if (m_position >= m_blocks.Count)
                    {
                        return(null);
                    }

                    targetId = ModelUtils.ConstructIdForBlock(m_blocks[m_position++], m_source.NodeId.NamespaceIndex);
                }
            }

            // create reference.
            if (targetId != null)
            {
                return(new NodeStateReference(ReferenceTypeIds.Organizes, false, targetId));
            }

            return(null);
        }