public async Task ReadNodesAsync() { if (ReferenceDescriptions == null) { await BrowseFullAddressSpace(null).ConfigureAwait(false); } NodeIdCollection nodes = new NodeIdCollection( ReferenceDescriptions.Take(MaxReferences).Select(reference => ExpandedNodeId.ToNodeId(reference.NodeId, Session.NamespaceUris)) ); (IList <Node> nodeCollection, IList <ServiceResult> errors) = await Session.ReadNodesAsync(nodes).ConfigureAwait(false); Assert.NotNull(nodeCollection); Assert.NotNull(errors); Assert.AreEqual(nodes.Count, nodeCollection.Count); Assert.AreEqual(nodes.Count, errors.Count); int ii = 0; var variableNodes = new NodeIdCollection(); foreach (Node node in nodeCollection) { Assert.NotNull(node); Assert.AreEqual(ServiceResult.Good, errors[ii]); TestContext.Out.WriteLine("NodeId: {0} Node: {1}", node.NodeId, node); if (node is VariableNode) { try { variableNodes.Add(node.NodeId); var value = await Session.ReadValueAsync(node.NodeId).ConfigureAwait(false); Assert.NotNull(value); TestContext.Out.WriteLine("-- Value {0} ", value); } catch (ServiceResultException sre) { TestContext.Out.WriteLine("-- Read Value {0} ", sre.Message); } } ii++; } DataValueCollection values; (values, errors) = await Session.ReadValuesAsync(nodes).ConfigureAwait(false); Assert.NotNull(values); Assert.NotNull(errors); Assert.AreEqual(nodes.Count, values.Count); Assert.AreEqual(nodes.Count, errors.Count); (values, errors) = await Session.ReadValuesAsync(variableNodes).ConfigureAwait(false); Assert.NotNull(values); Assert.NotNull(errors); Assert.AreEqual(variableNodes.Count, values.Count); Assert.AreEqual(variableNodes.Count, errors.Count); }
public async Task ReadNodeAsync() { if (ReferenceDescriptions == null) { await BrowseFullAddressSpace(null).ConfigureAwait(false); } foreach (var reference in ReferenceDescriptions.Take(MaxReferences)) { var nodeId = ExpandedNodeId.ToNodeId(reference.NodeId, Session.NamespaceUris); INode node = await Session.ReadNodeAsync(nodeId).ConfigureAwait(false); Assert.NotNull(node); TestContext.Out.WriteLine("NodeId: {0} Node: {1}", nodeId, node); if (node is VariableNode) { try { var value = await Session.ReadValueAsync(nodeId).ConfigureAwait(false); Assert.NotNull(value); TestContext.Out.WriteLine("-- Value {0} ", value); } catch (ServiceResultException sre) { TestContext.Out.WriteLine("-- Read Value {0} ", sre.Message); } } } }
public async Task NodeCache_Read() { if (ReferenceDescriptions == null) { await BrowseFullAddressSpace(null).ConfigureAwait(false); } foreach (var reference in ReferenceDescriptions.Take(MaxReferences)) { var nodeId = ExpandedNodeId.ToNodeId(reference.NodeId, Session.NamespaceUris); var node = Session.NodeCache.Find(reference.NodeId); TestContext.Out.WriteLine("NodeId: {0} Node: {1}", nodeId, node); } }
public void NodeCacheFetchNode() { if (ReferenceDescriptions == null) { BrowseFullAddressSpace(); } foreach (var reference in ReferenceDescriptions.Take(MaxReferences)) { var nodeId = ExpandedNodeId.ToNodeId(reference.NodeId, Session.NamespaceUris); var node = Session.NodeCache.FetchNode(reference.NodeId); TestContext.Out.WriteLine("NodeId: {0} Node: {1}", nodeId, node); } }
public void NodeCacheFetchNodes() { if (ReferenceDescriptions == null) { BrowseFullAddressSpace(); } var testSet = ReferenceDescriptions.Take(MaxReferences).Select(r => r.NodeId).ToList(); IList <Node> nodeCollection = Session.NodeCache.FetchNodes(testSet); foreach (var node in nodeCollection) { var nodeId = ExpandedNodeId.ToNodeId(node.NodeId, Session.NamespaceUris); TestContext.Out.WriteLine("NodeId: {0} Node: {1}", nodeId, node); } }
public void NodeCacheFindReferences() { if (ReferenceDescriptions == null) { BrowseFullAddressSpace(); } var testSet = ReferenceDescriptions.Take(MaxReferences).Select(r => r.NodeId).ToList(); IList <INode> nodes = Session.NodeCache.FindReferences(testSet, new NodeIdCollection() { ReferenceTypeIds.NonHierarchicalReferences }, false, true); foreach (var node in nodes) { var nodeId = ExpandedNodeId.ToNodeId(node.NodeId, Session.NamespaceUris); TestContext.Out.WriteLine("NodeId: {0} Node: {1}", nodeId, node); } }