use of com.prosysopc.ua.stack.builtintypes.Variant in project FAAAST-Service by FraunhoferIOSB.
the class AASIdentifierTypeImplBase method getIdType.
@Mandatory
@Override
public AASIdentifierTypeDataType getIdType() {
UaVariable node = getIdTypeNode();
if (node == null) {
return null;
}
Variant value = node.getValue().getValue();
return (AASIdentifierTypeDataType) value.asEnum(AASIdentifierTypeDataType.class);
}
use of com.prosysopc.ua.stack.builtintypes.Variant in project FAAAST-Service by FraunhoferIOSB.
the class AASSubmodelElementTypeNodeBase method getModelingKind.
@Mandatory
@Override
public AASModelingKindDataType getModelingKind() {
UaVariable node = getModelingKindNode();
if (node == null) {
throw new RuntimeException("Mandatory node ModelingKind does not exist");
}
Variant value = node.getValue().getValue();
return (AASModelingKindDataType) value.asEnum(AASModelingKindDataType.class);
}
use of com.prosysopc.ua.stack.builtintypes.Variant in project FAAAST-Service by FraunhoferIOSB.
the class AASAssetInformationTypeImplBase method getAssetKind.
@Mandatory
@Override
public AASAssetKindDataType getAssetKind() {
UaVariable node = getAssetKindNode();
if (node == null) {
return null;
}
Variant value = node.getValue().getValue();
return (AASAssetKindDataType) value.asEnum(AASAssetKindDataType.class);
}
use of com.prosysopc.ua.stack.builtintypes.Variant in project FAAAST-Service by FraunhoferIOSB.
the class TestUtils method checkAasReference.
/**
* Checks the given Reference Node
*
* @param client The OPC UA Client
* @param node The desired Node
* @param aasns The namespace index of the AAS namespace.
* @param refKeys The expected list of Keys
* @throws ServiceException If the operation fails
* @throws AddressSpaceException If the operation fails
* @throws ServiceResultException If the operation fails
* @throws StatusException If the operation fails
*/
private static void checkAasReference(UaClient client, NodeId node, int aasns, List<AASKeyDataType> refKeys) throws ServiceException, AddressSpaceException, ServiceResultException, StatusException {
checkType(client, node, new NodeId(aasns, TestDefines.AAS_REFERENCE_TYPE_ID));
List<RelativePathElement> browsePath = new ArrayList<>();
browsePath.add(new RelativePathElement(Identifiers.HasProperty, false, true, new QualifiedName(aasns, "Keys")));
BrowsePathTarget[] targetsProp = client.getAddressSpace().translateBrowsePathToNodeId(node, browsePath.toArray(RelativePathElement[]::new));
Assert.assertNotNull("Property Keys Null", targetsProp);
Assert.assertTrue("Property Keys empty", targetsProp.length > 0);
checkType(client, targetsProp[0].getTargetId(), Identifiers.PropertyType);
UaVariable variable = (UaVariable) client.getAddressSpace().getNode(targetsProp[0].getTargetId());
UaType dataType = variable.getDataType();
Assert.assertNotNull("DataType null", dataType);
Assert.assertEquals("DataType not equal", new NodeId(aasns, TestDefines.AAS_KEY_DATA_TYPE_ID), dataType.getNodeId());
DataValue value = client.readValue(targetsProp[0].getTargetId());
Assert.assertEquals(StatusCode.GOOD, value.getStatusCode());
Assert.assertNotNull("Value null", value.getValue());
Variant var = value.getValue();
Object o = var.getValue();
Assert.assertTrue("Keys no array", var.isArray());
// Assert.assertEquals(AASKeyDataType.class, o.getClass());
AASKeyDataType[] arr = (AASKeyDataType[]) o;
Assert.assertEquals(refKeys.size(), arr.length);
Assert.assertArrayEquals(refKeys.toArray(), arr);
}
use of com.prosysopc.ua.stack.builtintypes.Variant in project FAAAST-Service by FraunhoferIOSB.
the class TestUtils method checkAasPropertyObject.
/**
* Checks the String Property with the given Name
*
* @param client The OPC UA Client
* @param node The Node where the desired property is located
* @param aasns The namespace index of the AAS namespace
* @param name The name of the desired property
* @param kind The expected ModelingKind
* @param category The expected Category
* @param valueType The expected ValueType
* @param propValue The expected Value
* @param qualifierList The list of qualifiers
* @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 checkAasPropertyObject(UaClient client, NodeId node, int aasns, String name, AASModelingKindDataType kind, String category, AASValueTypeDataType valueType, Object propValue, List<Qualifier> qualifierList) throws ServiceException, AddressSpaceException, StatusException, ServiceResultException {
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(node, relPath.toArray(RelativePath[]::new));
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());
checkDisplayName(client, propertyNode, name);
checkCategoryNode(client, propertyNode, aasns, category);
checkModelingKindNode(client, propertyNode, aasns, kind);
checkDataSpecificationNode(client, propertyNode, aasns);
checkQualifierNode(client, propertyNode, aasns, qualifierList);
relPath.clear();
browsePath.clear();
browsePath.add(new RelativePathElement(Identifiers.HasProperty, false, true, new QualifiedName(aasns, TestDefines.PROPERTY_VALUE_TYPE_NAME)));
relPath.add(new RelativePath(browsePath.toArray(RelativePathElement[]::new)));
browsePath.clear();
browsePath.add(new RelativePathElement(Identifiers.HasProperty, false, true, new QualifiedName(aasns, TestDefines.PROPERTY_VALUE_NAME)));
relPath.add(new RelativePath(browsePath.toArray(RelativePathElement[]::new)));
bpres = client.getAddressSpace().translateBrowsePathsToNodeIds(propertyNode, relPath.toArray(RelativePath[]::new));
Assert.assertNotNull("checkAasPropertyString Browse Value & Type Result Null", bpres);
Assert.assertTrue("checkAasPropertyString Browse Value & Type Result: size doesn't match", bpres.length == 2);
targets = bpres[0].getTargets();
Assert.assertNotNull("checkAasPropertyString ValueType Null", targets);
Assert.assertTrue("checkAasPropertyString ValueType empty", targets.length > 0);
DataValue value = client.readValue(targets[0].getTargetId());
Assert.assertEquals(StatusCode.GOOD, value.getStatusCode());
Assert.assertEquals(valueType.ordinal(), value.getValue().intValue());
targets = bpres[1].getTargets();
Assert.assertNotNull("checkAasPropertyString Value Null", targets);
Assert.assertTrue("checkAasPropertyString value empty", targets.length > 0);
value = client.readValue(targets[0].getTargetId());
Assert.assertEquals(StatusCode.GOOD, value.getStatusCode());
Variant var = new Variant(propValue);
Assert.assertEquals(var, value.getValue());
}
Aggregations