Search in sources :

Example 6 with ReferenceDescription

use of com.prosysopc.ua.stack.core.ReferenceDescription in project FAAAST-Service by FraunhoferIOSB.

the class TestUtils method checkIdentifierKeyValuePairListNode.

/**
 * Searches for an IdentifierKeyValuePairList Node with the given Name and
 * checks the corresponding values.
 *
 * @param client The OPC UA Client
 * @param baseNode The base node where the desired Node is searched.
 * @param aasns The namespace index of the AAS namespace.
 * @param name The desired Name of the Node
 * @param map The expected values.
 * @throws ServiceException If the operation fails
 * @throws ServiceResultException If the operation fails
 * @throws AddressSpaceException If the operation fails
 * @throws StatusException If the operation fails
 */
private static void checkIdentifierKeyValuePairListNode(UaClient client, NodeId baseNode, int aasns, String name, Map<String, String> map) throws ServiceException, ServiceResultException, AddressSpaceException, StatusException {
    List<RelativePath> relPath = new ArrayList<>();
    List<RelativePathElement> browsePath = new ArrayList<>();
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, name)));
    relPath.add(new RelativePath(browsePath.toArray(RelativePathElement[]::new)));
    BrowsePathResult[] bpres = client.getAddressSpace().translateBrowsePathsToNodeIds(baseNode, relPath.toArray(RelativePath[]::new));
    Assert.assertNotNull("checkIdentifierKeyValuePairListNode Browse Result Null", bpres);
    Assert.assertTrue("checkIdentifierKeyValuePairListNode Browse Result: size doesn't match", bpres.length == 1);
    BrowsePathTarget[] targets = bpres[0].getTargets();
    Assert.assertNotNull("checkIdentifierKeyValuePairListNode Browse Target Node Null", targets);
    Assert.assertTrue("checkIdentifierKeyValuePairListNode Browse targets empty", targets.length > 0);
    NodeId listNode = client.getAddressSpace().getNamespaceTable().toNodeId(targets[0].getTargetId());
    Assert.assertNotNull("checkIdentifierKeyValuePairListNode Ref Node Null", listNode);
    Assert.assertNotEquals("checkIdentifierKeyValuePairListNode Ref Node Null", NodeId.NULL, listNode);
    checkType(client, listNode, new NodeId(aasns, TestDefines.AAS_ID_KEY_VALUE_PAIR_LIST_ID));
    List<NodeId> nodeList = new ArrayList<>();
    List<ReferenceDescription> refs = client.getAddressSpace().browse(listNode);
    for (ReferenceDescription ref : refs) {
        NodeId nid = client.getAddressSpace().getNamespaceTable().toNodeId(ref.getNodeId());
        nodeList.add(nid);
    }
    for (NodeId node : nodeList) {
        checkIdentifierKeyValuePairNode(client, node, aasns, map);
    }
}
Also used : RelativePath(com.prosysopc.ua.stack.core.RelativePath) BrowsePathResult(com.prosysopc.ua.stack.core.BrowsePathResult) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) ArrayList(java.util.ArrayList) ReferenceDescription(com.prosysopc.ua.stack.core.ReferenceDescription) RelativePathElement(com.prosysopc.ua.stack.core.RelativePathElement) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) ExpandedNodeId(com.prosysopc.ua.stack.builtintypes.ExpandedNodeId) BrowsePathTarget(com.prosysopc.ua.stack.core.BrowsePathTarget)

Aggregations

NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)6 ReferenceDescription (com.prosysopc.ua.stack.core.ReferenceDescription)6 ExpandedNodeId (com.prosysopc.ua.stack.builtintypes.ExpandedNodeId)3 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)3 BrowsePathResult (com.prosysopc.ua.stack.core.BrowsePathResult)3 BrowsePathTarget (com.prosysopc.ua.stack.core.BrowsePathTarget)3 RelativePath (com.prosysopc.ua.stack.core.RelativePath)3 RelativePathElement (com.prosysopc.ua.stack.core.RelativePathElement)3 ArrayList (java.util.ArrayList)3 UaClient (com.prosysopc.ua.client.UaClient)2 DataValue (com.prosysopc.ua.stack.builtintypes.DataValue)2 Test (org.junit.Test)2 UaNode (com.prosysopc.ua.nodes.UaNode)1 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)1 LangString (io.adminshell.aas.v3.model.LangString)1 AASKeyDataType (opc.i4aas.AASKeyDataType)1 AASQualifierType (opc.i4aas.AASQualifierType)1