Search in sources :

Example 56 with UaVariable

use of com.prosysopc.ua.nodes.UaVariable 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 57 with UaVariable

use of com.prosysopc.ua.nodes.UaVariable in project FAAAST-Service by FraunhoferIOSB.

the class AASSubmodelTypeImplBase method setModelingKind.

@Mandatory
@Override
public void setModelingKind(AASModelingKindDataType value) throws StatusException {
    UaVariable node = getModelingKindNode();
    if (node == null) {
        throw new RuntimeException("Setting ModelingKind failed, the Optional node does not exist)");
    }
    node.setValue(value);
}
Also used : UaVariable(com.prosysopc.ua.nodes.UaVariable) Mandatory(com.prosysopc.ua.nodes.Mandatory)

Example 58 with UaVariable

use of com.prosysopc.ua.nodes.UaVariable in project FAAAST-Service by FraunhoferIOSB.

the class AASSubmodelTypeImplBase method getModelingKind.

@Mandatory
@Override
public AASModelingKindDataType getModelingKind() {
    UaVariable node = getModelingKindNode();
    if (node == null) {
        return null;
    }
    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 59 with UaVariable

use of com.prosysopc.ua.nodes.UaVariable in project FAAAST-Service by FraunhoferIOSB.

the class AASPropertyTypeImplBase method getValue.

@Optional
@Override
public Object getValue() {
    UaVariable node = getValueNode();
    if (node == null) {
        return null;
    }
    Object value = node.getValue().getValue().getValue();
    return (Object) value;
}
Also used : UaVariable(com.prosysopc.ua.nodes.UaVariable) Optional(com.prosysopc.ua.nodes.Optional)

Example 60 with UaVariable

use of com.prosysopc.ua.nodes.UaVariable in project FAAAST-Service by FraunhoferIOSB.

the class AASPropertyTypeImplBase method setValue.

@Optional
@Override
public void setValue(Object value) throws StatusException {
    UaVariable node = getValueNode();
    if (node == null) {
        throw new RuntimeException("Setting Value failed, the Optional node does not exist)");
    }
    node.setValue(value);
}
Also used : UaVariable(com.prosysopc.ua.nodes.UaVariable) Optional(com.prosysopc.ua.nodes.Optional)

Aggregations

UaVariable (com.prosysopc.ua.nodes.UaVariable)127 Mandatory (com.prosysopc.ua.nodes.Mandatory)69 Optional (com.prosysopc.ua.nodes.Optional)57 Variant (com.prosysopc.ua.stack.builtintypes.Variant)21 AASValueTypeDataType (opc.i4aas.AASValueTypeDataType)6 ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)4 AASModelingKindDataType (opc.i4aas.AASModelingKindDataType)4 AASAssetKindDataType (opc.i4aas.AASAssetKindDataType)2 AASDataTypeIEC61360DataType (opc.i4aas.AASDataTypeIEC61360DataType)2 AASEntityTypeDataType (opc.i4aas.AASEntityTypeDataType)2 AASIdentifierTypeDataType (opc.i4aas.AASIdentifierTypeDataType)2 AASLevelTypeDataType (opc.i4aas.AASLevelTypeDataType)2 UaType (com.prosysopc.ua.nodes.UaType)1 DataValue (com.prosysopc.ua.stack.builtintypes.DataValue)1 ExpandedNodeId (com.prosysopc.ua.stack.builtintypes.ExpandedNodeId)1 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)1 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)1 BrowsePathTarget (com.prosysopc.ua.stack.core.BrowsePathTarget)1 RelativePathElement (com.prosysopc.ua.stack.core.RelativePathElement)1 ArrayList (java.util.ArrayList)1