use of com.prosysopc.ua.stack.core.BrowsePathTarget in project FAAAST-Service by FraunhoferIOSB.
the class TestUtils method checkQualifierNode.
/**
* Searches for the Qualifier Node in the given Node.
*
* @param client The OPC UA client
* @param node The desired node
* @param aasns The namespace index of the AAS namespace
* @param qualifierList The list of qualifiers
* @throws ServiceException If the operation fails
* @throws ServiceResultException If the operation fails
* @throws AddressSpaceException If the operation fails
* @throws StatusException If the operation fails
*/
public static void checkQualifierNode(UaClient client, NodeId node, int aasns, List<Qualifier> qualifierList) 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, TestDefines.QUALIFIER_NAME)));
relPath.add(new RelativePath(browsePath.toArray(RelativePathElement[]::new)));
BrowsePathResult[] bpres = client.getAddressSpace().translateBrowsePathsToNodeIds(node, relPath.toArray(RelativePath[]::new));
Assert.assertNotNull("checkQualifierNode Browse Result Null", bpres);
Assert.assertTrue("checkQualifierNode Browse Result: size doesn't match", bpres.length == 1);
BrowsePathTarget[] targets = bpres[0].getTargets();
Assert.assertNotNull("checkQualifierNode Node Targets Null", targets);
Assert.assertTrue("checkQualifierNode Node targets empty", targets.length > 0);
// Currently we only check that the NodeId is not null and we have the correct type
NodeId qualNode = client.getAddressSpace().getNamespaceTable().toNodeId(targets[0].getTargetId());
Assert.assertFalse("checkQualifierNode Node not found", NodeId.isNull(qualNode));
checkType(client, qualNode, new NodeId(aasns, TestDefines.AAS_QUALIFIER_LIST_ID));
List<AASQualifierType> nodeList = new ArrayList<>();
List<ReferenceDescription> refs = client.getAddressSpace().browse(qualNode);
for (ReferenceDescription ref : refs) {
NodeId nid = client.getAddressSpace().getNamespaceTable().toNodeId(ref.getNodeId());
checkType(client, nid, new NodeId(aasns, TestDefines.AAS_QUALIFIER_TYPE_ID));
UaNode qnode = client.getAddressSpace().getNode(nid);
if (qnode instanceof AASQualifierType) {
nodeList.add((AASQualifierType) qnode);
}
}
checkQualifierList(qualifierList, nodeList);
// Assert.assertArrayEquals(qualifierList.toArray(), nodeList.toArray());
}
use of com.prosysopc.ua.stack.core.BrowsePathTarget in project FAAAST-Service by FraunhoferIOSB.
the class TestUtils method checkAasReferenceNode.
/**
* Searches for a Reference Node with the given Name and checks the
* corresponding values.
*
* @param client The OPC UA Client
* @param baseNode The base node where the Reference Node is searched.
* @param aasns The namespace index of the AAS namespace.
* @param name The desired Name
* @param refKeys The expected list of Keys
* @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 checkAasReferenceNode(UaClient client, NodeId baseNode, int aasns, String name, List<AASKeyDataType> refKeys) 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("checkAasReferenceNode Browse Result Null", bpres);
Assert.assertTrue("checkAasReferenceNode Browse Result: size doesn't match", bpres.length == 1);
BrowsePathTarget[] targets = bpres[0].getTargets();
Assert.assertNotNull("checkAasReferenceNode Browse Target Node Null", targets);
Assert.assertTrue("checkAasReferenceNode Browse targets empty", targets.length > 0);
NodeId refNode = client.getAddressSpace().getNamespaceTable().toNodeId(targets[0].getTargetId());
Assert.assertNotNull("checkAasReferenceNode Ref Node Null", refNode);
Assert.assertNotEquals("checkAasReferenceNode Ref Node Null", NodeId.NULL, refNode);
checkAasReference(client, refNode, aasns, refKeys);
}
use of com.prosysopc.ua.stack.core.BrowsePathTarget in project FAAAST-Service by FraunhoferIOSB.
the class TestUtils method checkSubmodelRef.
/**
* Searches for the Submodel reference Node with the given name
*
* @param client The OPC UA Client
* @param baseNode The base node where the AssetInformation Node is
* searched.
* @param aasns The namespace index of the AAS namespace.
* @param name The name of the desired Node
* @param submodelNode The Submodel Node
* @throws ServiceException If the operation fails
* @throws ServiceResultException If the operation fails
* @throws AddressSpaceException If the operation fails
* @throws StatusException If the operation fails
*/
public static void checkSubmodelRef(UaClient client, NodeId baseNode, int aasns, String name, NodeId submodelNode) 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("checkSubmodelRef Browse Result Null", bpres);
Assert.assertTrue("checkSubmodelRef Browse Result: size doesn't match", bpres.length == 1);
Assert.assertTrue("checkSubmodelRef Browse Result Good", bpres[0].getStatusCode().isGood());
BrowsePathTarget[] targets = bpres[0].getTargets();
Assert.assertNotNull("checkSubmodelRef Target Null", targets);
Assert.assertTrue("checkSubmodelRef Target empty", targets.length > 0);
NodeId refNode = client.getAddressSpace().getNamespaceTable().toNodeId(targets[0].getTargetId());
Assert.assertNotNull("checkSubmodelRef RefNode Null", refNode);
checkType(client, refNode, new NodeId(aasns, TestDefines.AAS_REFERENCE_TYPE_ID));
// check AAS Reference
List<AASKeyDataType> refKeys = new ArrayList<>();
refKeys.add(new AASKeyDataType(AASKeyElementsDataType.Submodel, name, AASKeyTypeDataType.IRI));
checkAasReference(client, refNode, aasns, refKeys);
// check Reference to Submodel
List<ReferenceDescription> refs = client.getAddressSpace().browse(refNode, BrowseDirection.Forward, Identifiers.HasAddIn);
Assert.assertEquals(1, refs.size());
NodeId smNode = client.getAddressSpace().getNamespaceTable().toNodeId(refs.get(0).getNodeId());
Assert.assertEquals(smNode, submodelNode);
}
use of com.prosysopc.ua.stack.core.BrowsePathTarget in project FAAAST-Service by FraunhoferIOSB.
the class TestUtils method checkVariableBool.
/**
* Searches for a Variable (as Property) with the given Name and checks the
* boolean Value
*
* @param client The OPC UA client
* @param node The desired node
* @param aasns The namespace index of the AAS namespace
* @param name The Name of the desired Property
* @param propValue The expected value of the Property.
* @throws ServiceException If the operation fails
* @throws StatusException If the operation fails
*/
public static void checkVariableBool(UaClient client, NodeId node, int aasns, String name, boolean propValue) throws ServiceException, StatusException {
List<RelativePath> relPath = new ArrayList<>();
List<RelativePathElement> browsePath = new ArrayList<>();
browsePath.add(new RelativePathElement(Identifiers.HasProperty, false, true, new QualifiedName(aasns, name)));
relPath.add(new RelativePath(browsePath.toArray(RelativePathElement[]::new)));
BrowsePathResult[] bpres = client.getAddressSpace().translateBrowsePathsToNodeIds(node, relPath.toArray(RelativePath[]::new));
Assert.assertNotNull("checkPropertyBool Browse Result Null", bpres);
Assert.assertTrue("checkPropertyBool Browse Result: size doesn't match", bpres.length == 1);
BrowsePathTarget[] targets = bpres[0].getTargets();
Assert.assertNotNull("checkPropertyBool Node Targets Null", targets);
Assert.assertTrue("checkPropertyBool Node targets empty", targets.length > 0);
DataValue value = client.readValue(targets[0].getTargetId());
Assert.assertEquals(StatusCode.GOOD, value.getStatusCode());
Assert.assertEquals(propValue, value.getValue().booleanValue());
}
use of com.prosysopc.ua.stack.core.BrowsePathTarget in project FAAAST-Service by FraunhoferIOSB.
the class TestUtils method checkModelingKindNode.
/**
* Searches for the ModelingKind Node in the given Node and checks the
* ModelingKind value.
*
* @param client The OPC UA Client
* @param baseNode The base node where the ModelingKind Node is searched.
* @param aasns The namespace index of the AAS namespace.
* @param modelingKind The expected ModelingKind Value
* @throws ServiceException If the operation fails
* @throws AddressSpaceException If the operation fails
* @throws StatusException If the operation fails
* @throws ServiceResultException If the operation fails
*/
public static void checkModelingKindNode(UaClient client, NodeId baseNode, int aasns, AASModelingKindDataType modelingKind) throws ServiceException, AddressSpaceException, StatusException, ServiceResultException {
List<RelativePath> relPath = new ArrayList<>();
List<RelativePathElement> browsePath = new ArrayList<>();
browsePath.add(new RelativePathElement(Identifiers.HasProperty, false, true, new QualifiedName(aasns, TestDefines.MODELING_KIND_NAME)));
relPath.add(new RelativePath(browsePath.toArray(RelativePathElement[]::new)));
BrowsePathResult[] bpres = client.getAddressSpace().translateBrowsePathsToNodeIds(baseNode, relPath.toArray(RelativePath[]::new));
Assert.assertNotNull("checkModelingKind Browse Result Null", bpres);
Assert.assertTrue("checkModelingKind Browse Result: size doesn't match", bpres.length == 1);
BrowsePathTarget[] targets = bpres[0].getTargets();
Assert.assertNotNull("checkModelingKind Browse Target Node Null", targets);
Assert.assertTrue("checkModelingKind Browse targets empty", targets.length > 0);
checkModelingKind(client, client.getAddressSpace().getNamespaceTable().toNodeId(targets[0].getTargetId()), modelingKind);
}
Aggregations