示例#1
0
文件: UaClient.cs 项目: zzlc/h-opc
        /// <summary>
        /// Explore a folder on the Opc Server
        /// </summary>
        /// <param name="tag">The fully-qualified identifier of the tag. You can specify a subfolder by using a comma delimited name.
        /// E.g: the tag `foo.bar` finds the sub nodes of `bar` on the folder `foo`</param>
        /// <returns>The list of sub-nodes</returns>
        public IEnumerable <UaNode> ExploreFolder(string tag)
        {
            IList <UaNode> nodes;

            _folderCache.TryGetValue(tag, out nodes);
            if (nodes != null)
            {
                return(nodes);
            }

            var folder = FindNode(tag);

            nodes = ClientUtils.Browse(_session, folder.NodeId)
                    .GroupBy(n => n.NodeId) //this is to select distinct
                    .Select(n => n.First())
                    .Where(n => n.NodeClass == NodeClass.Variable || n.NodeClass == NodeClass.Object)
                    .Select(n => n.ToHylaNode(folder))
                    .ToList();

            //add nodes to cache
            if (!_folderCache.ContainsKey(tag))
            {
                _folderCache.Add(tag, nodes);
            }
            foreach (var node in nodes)
            {
                AddNodeToCache(node);
            }

            return(nodes);
        }
示例#2
0
        /// <summary>
        /// Explore a folder on the Opc Server
        /// </summary>
        /// <param name="tag">The fully-qualified identifier of the tag. You can specify a subfolder by using a comma delimited name.
        /// E.g: the tag `foo.bar` finds the sub nodes of `bar` on the folder `foo`</param>
        /// <returns>The list of sub-nodes</returns>
        public IEnumerable <UaNode> ExploreFolder(string tag)
        {
            var folder = FindNode(tag);
            var nodes  = ClientUtils.Browse(_session, folder.NodeId)
                         .GroupBy(n => n.NodeId) //this is to select distinct
                         .Select(n => n.First())
                         .Where(n => n.NodeClass == NodeClass.Variable || n.NodeClass == NodeClass.Object)
                         .Select(n => n.ToHylaNode(this, folder))
                         .ToList();

            //add nodes to cache
            foreach (var node in nodes)
            {
                AddNodeToCache(node);
            }

            return(nodes);
        }