Search in sources :

Example 6 with Variant

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);
}
Also used : Variant(com.prosysopc.ua.stack.builtintypes.Variant) UaVariable(com.prosysopc.ua.nodes.UaVariable) AASIdentifierTypeDataType(opc.i4aas.AASIdentifierTypeDataType) Mandatory(com.prosysopc.ua.nodes.Mandatory)

Example 7 with Variant

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);
}
Also used : Variant(com.prosysopc.ua.stack.builtintypes.Variant) UaVariable(com.prosysopc.ua.nodes.UaVariable) AASModelingKindDataType(opc.i4aas.AASModelingKindDataType) Mandatory(com.prosysopc.ua.nodes.Mandatory)

Example 8 with Variant

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);
}
Also used : Variant(com.prosysopc.ua.stack.builtintypes.Variant) UaVariable(com.prosysopc.ua.nodes.UaVariable) AASAssetKindDataType(opc.i4aas.AASAssetKindDataType) Mandatory(com.prosysopc.ua.nodes.Mandatory)

Example 9 with Variant

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);
}
Also used : DataValue(com.prosysopc.ua.stack.builtintypes.DataValue) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) UaVariable(com.prosysopc.ua.nodes.UaVariable) ArrayList(java.util.ArrayList) UaType(com.prosysopc.ua.nodes.UaType) AASKeyDataType(opc.i4aas.AASKeyDataType) Variant(com.prosysopc.ua.stack.builtintypes.Variant) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) ExpandedNodeId(com.prosysopc.ua.stack.builtintypes.ExpandedNodeId) RelativePathElement(com.prosysopc.ua.stack.core.RelativePathElement) BrowsePathTarget(com.prosysopc.ua.stack.core.BrowsePathTarget)

Example 10 with Variant

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());
}
Also used : RelativePath(com.prosysopc.ua.stack.core.RelativePath) BrowsePathResult(com.prosysopc.ua.stack.core.BrowsePathResult) DataValue(com.prosysopc.ua.stack.builtintypes.DataValue) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) ArrayList(java.util.ArrayList) Variant(com.prosysopc.ua.stack.builtintypes.Variant) 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

Variant (com.prosysopc.ua.stack.builtintypes.Variant)25 UaVariable (com.prosysopc.ua.nodes.UaVariable)21 Mandatory (com.prosysopc.ua.nodes.Mandatory)16 AASValueTypeDataType (opc.i4aas.AASValueTypeDataType)6 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)5 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)5 BrowsePathTarget (com.prosysopc.ua.stack.core.BrowsePathTarget)5 RelativePathElement (com.prosysopc.ua.stack.core.RelativePathElement)5 ArrayList (java.util.ArrayList)5 Optional (com.prosysopc.ua.nodes.Optional)4 BrowsePathResult (com.prosysopc.ua.stack.core.BrowsePathResult)4 RelativePath (com.prosysopc.ua.stack.core.RelativePath)4 AASModelingKindDataType (opc.i4aas.AASModelingKindDataType)4 DataValue (com.prosysopc.ua.stack.builtintypes.DataValue)3 ExpandedNodeId (com.prosysopc.ua.stack.builtintypes.ExpandedNodeId)3 UaClient (com.prosysopc.ua.client.UaClient)2 AASAssetKindDataType (opc.i4aas.AASAssetKindDataType)2 AASDataTypeIEC61360DataType (opc.i4aas.AASDataTypeIEC61360DataType)2 AASEntityTypeDataType (opc.i4aas.AASEntityTypeDataType)2 AASIdentifierTypeDataType (opc.i4aas.AASIdentifierTypeDataType)2