use of opc.i4aas.AASQualifierType 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 opc.i4aas.AASQualifierType in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addQualifier.
/**
* Creates and adds a Qualifier to the given Node.
*
* @param node The UA node in which the Qualifier should be created
* @param qualifier The desired Qualifier
* @param name The name of the qualifier
*/
private void addQualifier(UaNode node, Qualifier qualifier, String name) throws StatusException {
if (node == null) {
throw new IllegalArgumentException("node = null");
} else if (qualifier == null) {
throw new IllegalArgumentException("qualifier = null");
}
try {
logger.info("addQualifier " + name + "; to Node: " + node.toString());
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASQualifierType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
NodeId nid = createNodeId(node, browseName);
AASQualifierType qualifierNode = createInstance(AASQualifierType.class, nid, browseName, LocalizedText.english(name));
// Type
qualifierNode.setType(qualifier.getType());
// ValueType
qualifierNode.setValueType(ValueConverter.stringToValueType(qualifier.getValueType()));
// Value
if (qualifier.getValue() != null) {
if (qualifierNode.getValueNode() == null) {
addQualifierValueNode(qualifierNode);
}
qualifierNode.setValue(qualifier.getValue());
}
// ValueId
if (qualifier.getValueId() != null) {
addAasReferenceAasNS(qualifierNode, qualifier.getValueId(), AASQualifierType.VALUE_ID);
}
if (VALUES_READ_ONLY) {
if (qualifierNode.getValueNode() != null) {
qualifierNode.getValueNode().setAccessLevel(AccessLevelType.CurrentRead);
}
if (qualifierNode.getValueTypeNode() != null) {
qualifierNode.getValueTypeNode().setAccessLevel(AccessLevelType.CurrentRead);
}
if (qualifierNode.getTypeNode() != null) {
qualifierNode.getTypeNode().setAccessLevel(AccessLevelType.CurrentRead);
}
}
node.addComponent(qualifierNode);
} catch (Throwable ex) {
logger.error("addQualifier Exception", ex);
throw ex;
}
}
use of opc.i4aas.AASQualifierType in project FAAAST-Service by FraunhoferIOSB.
the class TestUtils method checkQualifierList.
// public static void checkFullManufacturerName(UaClient client, NodeId node) {
// 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(new RelativePathElement[0])));
//
// BrowsePathResult[] bpres = client.getAddressSpace().translateBrowsePathsToNodeIds(node, relPath.toArray(new RelativePath[0]));
// Assert.assertNotNull("checkAasPropertyString Browse Property Result Null", bpres);
// Assert.assertTrue("checkAasPropertyString Browse Property Result: size doesn't match", bpres.length == 1);
//
// BrowsePathTarget[] targets = bpres[0].getTargets();
// Assert.assertNotNull("checkAasPropertyString Property Null", targets);
// Assert.assertTrue("checkAasPropertyString Property empty", targets.length > 0);
// NodeId propertyNode = client.getAddressSpace().getNamespaceTable().toNodeId(targets[0].getTargetId());
//
// }
/**
* Checks the given Qualifier Lists
*
* @param listExpected The expected Qualifier List
* @param listCurrent The current Qualifier List
*/
private static void checkQualifierList(List<Qualifier> listExpected, List<AASQualifierType> listCurrent) {
Assert.assertEquals(listExpected.size(), listCurrent.size());
for (int i = 0; i < listExpected.size(); i++) {
Qualifier exp = listExpected.get(i);
AASQualifierType curr = listCurrent.get(i);
Assert.assertEquals("Qualifier Type not equal", exp.getType(), curr.getType());
Assert.assertEquals("Qualifier ValueType not equal", ValueConverter.stringToValueType(exp.getValueType()), curr.getValueType());
Assert.assertEquals("Qualifier Value not equal", exp.getValue(), curr.getValue());
}
}
Aggregations