/// <summary>
        /// Returns a unique handle for the node.
        /// </summary>
        protected override NodeHandle GetManagerHandle(ServerSystemContext context, NodeId nodeId, IDictionary <NodeId, NodeState> cache)
        {
            lock (Lock) {
                // quickly exclude nodes that are not in the namespace.
                if (!IsNodeIdInNamespace(nodeId))
                {
                    return(null);
                }

                NodeState node = null;

                // check cache (the cache is used because the same node id can appear many times in a single request).
                if (cache != null)
                {
                    if (cache.TryGetValue(nodeId, out node))
                    {
                        return(new NodeHandle(nodeId, node));
                    }
                }

                // look up predefined node.
                if (PredefinedNodes.TryGetValue(nodeId, out node))
                {
                    var handle = new NodeHandle(nodeId, node);

                    cache?.Add(nodeId, node);

                    return(handle);
                }

                // node not found.
                return(null);
            }
        }
        /// <summary>
        /// Returns a unique handle for the node.
        /// </summary>
        protected override NodeHandle GetManagerHandle(ServerSystemContext context, NodeId nodeId, IDictionary <NodeId, NodeState> cache)
        {
            lock (Lock)
            {
                // quickly exclude nodes that are not in the namespace.
                if (!IsNodeIdInNamespace(nodeId))
                {
                    return(null);
                }

                NodeState node = null;

                if (!PredefinedNodes.TryGetValue(nodeId, out node))
                {
                    return(null);
                }

                NodeHandle handle = new NodeHandle();

                handle.NodeId    = nodeId;
                handle.Node      = node;
                handle.Validated = true;

                return(handle);
            }
        }
        protected override NodeHandle GetManagerHandle(
            ServerSystemContext context,
            NodeId nodeId,
            IDictionary<NodeId, NodeState> cache)
        {
            lock (Lock)
            {
                if (!IsNodeIdInNamespace(nodeId))
                {
                    return null;
                }
                if (PredefinedNodes != null)
                {

                    if (PredefinedNodes.TryGetValue(nodeId, out NodeState node))
                    {
                        NodeHandle handle = new NodeHandle
                        {
                            NodeId = nodeId,
                            Validated = true,
                            Node = node
                        };
                        return handle;
                    }
                }
                return null;
            }
        }
Example #4
0
        /// <summary>
        /// Returns a unique handle for the node.
        /// </summary>
        protected override NodeHandle GetManagerHandle(ServerSystemContext context, NodeId nodeId, IDictionary <NodeId, NodeState> cache)
        {
            lock (Lock) {
                // quickly exclude nodes that are not in the namespace.
                if (!IsNodeIdInNamespace(nodeId))
                {
                    return(null);
                }

                // check for predefined nodes.
                if (PredefinedNodes != null)
                {
                    if (PredefinedNodes.TryGetValue(nodeId, out var node))
                    {
                        var handle = new NodeHandle {
                            NodeId    = nodeId,
                            Validated = true,
                            Node      = node
                        };

                        return(handle);
                    }
                }

                return(null);
            }
        }
Example #5
0
        /// <summary>
        /// Returns a unique handle for the node.
        /// </summary>
        protected override NodeHandle GetManagerHandle(ServerSystemContext context, NodeId nodeId, IDictionary <NodeId, NodeState> cache)
        {
            lock (Lock)
            {
                // quickly exclude nodes that are not in the namespace.
                if (!IsNodeIdInNamespace(nodeId))
                {
                    return(null);
                }

                // check for check for nodes that are being currently monitored.
                MonitoredNode monitoredNode = null;

                if (MonitoredNodes.TryGetValue(nodeId, out monitoredNode))
                {
                    NodeHandle handle = new NodeHandle();

                    handle.NodeId    = nodeId;
                    handle.Validated = true;
                    handle.Node      = monitoredNode.Node;

                    return(handle);
                }

                if (nodeId.IdType != IdType.String)
                {
                    NodeState node = null;

                    if (PredefinedNodes.TryGetValue(nodeId, out node))
                    {
                        NodeHandle handle = new NodeHandle();

                        handle.NodeId    = nodeId;
                        handle.Node      = node;
                        handle.Validated = true;

                        return(handle);
                    }
                }

                // parse the identifier.
                ParsedNodeId parsedNodeId = ParsedNodeId.Parse(nodeId);

                if (parsedNodeId != null)
                {
                    NodeHandle handle = new NodeHandle();

                    handle.NodeId       = nodeId;
                    handle.Validated    = false;
                    handle.Node         = null;
                    handle.ParsedNodeId = parsedNodeId;

                    return(handle);
                }

                return(null);
            }
        }
        /// <summary>
        /// Returns a unique handle for the node.
        /// </summary>
        protected override NodeHandle GetManagerHandle(ServerSystemContext context, NodeId nodeId, IDictionary <NodeId, NodeState> cache)
        {
            lock (Lock)
            {
                // quickly exclude nodes that are not in the namespace.
                if (!IsNodeIdInNamespace(nodeId))
                {
                    return(null);
                }

                NodeState node = null;

                // check cache (the cache is used because the same node id can appear many times in a single request).
                if (cache != null)
                {
                    if (cache.TryGetValue(nodeId, out node))
                    {
                        return(new NodeHandle(nodeId, node));
                    }
                }

                // look up predefined node.
                if (PredefinedNodes.TryGetValue(nodeId, out node))
                {
                    NodeHandle handle = new NodeHandle(nodeId, node);

                    if (cache != null)
                    {
                        cache.Add(nodeId, node);
                    }

                    return(handle);
                }


                #region Task #A5 - Add Support for External Nodes
                // parse the node id and return an unvalidated handle.
                if (nodeId.IdType == IdType.String)
                {
                    NodeHandle handle = new NodeHandle();
                    handle.NodeId       = nodeId;
                    handle.Validated    = false;
                    handle.ParsedNodeId = ParsedNodeId.Parse(nodeId);
                    return(handle);
                }
                #endregion

                // node not found.
                return(null);
            }
        }
        /// <summary>
        /// Returns a unique handle for the node.
        /// </summary>
        protected override NodeHandle GetManagerHandle(ServerSystemContext context, NodeId nodeId, IDictionary<NodeId, NodeState> cache)
        {
            lock (Lock)
            {
                // quickly exclude nodes that are not in the namespace.
                if (!IsNodeIdInNamespace(nodeId))
                {
                    return null;
                }

                // check for predefined nodes.
                if (PredefinedNodes != null)
                {
                    NodeState node = null;

                    if (PredefinedNodes.TryGetValue(nodeId, out node))
                    {
                        NodeHandle handle = new NodeHandle();

                        handle.NodeId = nodeId;
                        handle.Validated = true;
                        handle.Node = node;

                        return handle;
                    }
                }

                // parse the identifier.
                DaParsedNodeId parsedNodeId = DaParsedNodeId.Parse(nodeId);

                if (parsedNodeId != null)
                {
                    NodeHandle handle = new NodeHandle();

                    handle.NodeId = nodeId;
                    handle.Validated = false;
                    handle.Node = null;
                    handle.ParsedNodeId = parsedNodeId;

                    return handle;
                }
                
                return null;
            }
        }
        /// <summary>
        /// Returns a unique handle for the node.
        /// </summary>
        protected override NodeHandle GetManagerHandle(ServerSystemContext context, NodeId nodeId, IDictionary <NodeId, NodeState> cache)
        {
            lock (Lock)
            {
                // quickly exclude nodes that are not in the namespace.
                if (!IsNodeIdInNamespace(nodeId))
                {
                    return(null);
                }

                // check cache.
                if (cache != null)
                {
                    NodeState node = null;

                    if (cache.TryGetValue(nodeId, out node))
                    {
                        return(new NodeHandle(nodeId, node));
                    }
                }

                NodeHandle handle = null;

                try
                {
                    // check if node already being monitored.
                    if (MonitoredNodes != null)
                    {
                        MonitoredNode2 monitoredNode2 = null;

                        if (MonitoredNodes.TryGetValue(nodeId, out monitoredNode2))
                        {
                            handle = new NodeHandle(nodeId, monitoredNode2.Node);
                            handle.MonitoredNode = monitoredNode2;
                            return(handle);
                        }
                    }

                    // check for predefined nodes.
                    if (PredefinedNodes != null)
                    {
                        NodeState node = null;

                        if (PredefinedNodes.TryGetValue(nodeId, out node))
                        {
                            return(handle = new NodeHandle(nodeId, node));
                        }
                    }

                    // parse the identifier.
                    AeParsedNodeId parsedNodeId = AeParsedNodeId.Parse(nodeId);

                    if (parsedNodeId != null)
                    {
                        if (parsedNodeId.RootType == AeModelUtils.AeEventTypeMapping && m_typeCache != null)
                        {
                            AeEventTypeMappingState mappingNode = m_typeCache.GetMappingNode(SystemContext, nodeId);

                            if (mappingNode != null)
                            {
                                return(handle = new NodeHandle(nodeId, mappingNode));
                            }

                            return(null);
                        }

                        handle = new NodeHandle();

                        handle.NodeId       = nodeId;
                        handle.Validated    = false;
                        handle.Node         = null;
                        handle.ParsedNodeId = parsedNodeId;

                        return(handle);
                    }
                }
                finally
                {
                    if (handle != null && handle.Node != null && cache != null)
                    {
                        cache.Add(nodeId, handle.Node);
                    }
                }

                return(null);
            }
        }