Search in sources :

Example 1 with ByteString

use of com.prosysopc.ua.stack.builtintypes.ByteString in project FAAAST-Service by FraunhoferIOSB.

the class AASBlobTypeImplBase method getValue.

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

Example 2 with ByteString

use of com.prosysopc.ua.stack.builtintypes.ByteString in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method addBlobValueNode.

/**
 * Adds a Value Property to the given Blob Node.
 *
 * @param node The desired Blob Node
 */
private void addBlobValueNode(UaNode node) {
    try {
        NodeId myPropertyId = new NodeId(getNamespaceIndex(), node.getNodeId().getValue().toString() + "." + AASBlobType.VALUE);
        PlainProperty<ByteString> myProperty = new PlainProperty<>(this, myPropertyId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASBlobType.getNamespaceUri(), AASBlobType.VALUE).toQualifiedName(getNamespaceTable()), LocalizedText.english(AASBlobType.VALUE));
        myProperty.setDataTypeId(Identifiers.ByteString);
        myProperty.setDescription(new LocalizedText("", ""));
        node.addProperty(myProperty);
    } catch (Throwable ex) {
        logger.error("addBlobValueNode Exception", ex);
        throw ex;
    }
}
Also used : PlainProperty(com.prosysopc.ua.server.nodes.PlainProperty) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) LocalizedText(com.prosysopc.ua.stack.builtintypes.LocalizedText)

Example 3 with ByteString

use of com.prosysopc.ua.stack.builtintypes.ByteString in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method addQualifierValueNode.

/**
 * Adds a Value Property to the given Qualifier Node.
 *
 * @param node The desired Blob Node
 */
private void addQualifierValueNode(UaNode node) {
    try {
        NodeId myPropertyId = new NodeId(getNamespaceIndex(), node.getNodeId().getValue().toString() + "." + AASQualifierType.VALUE);
        PlainProperty<ByteString> myProperty = new PlainProperty<>(this, myPropertyId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASQualifierType.getNamespaceUri(), AASQualifierType.VALUE).toQualifiedName(getNamespaceTable()), LocalizedText.english(AASQualifierType.VALUE));
        myProperty.setDataTypeId(Identifiers.String);
        if (VALUES_READ_ONLY) {
            myProperty.setAccessLevel(AccessLevelType.CurrentRead);
        }
        myProperty.setDescription(new LocalizedText("", ""));
        node.addProperty(myProperty);
    } catch (Throwable ex) {
        logger.error("addQualifierValueNode Exception", ex);
        throw ex;
    }
}
Also used : PlainProperty(com.prosysopc.ua.server.nodes.PlainProperty) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) LocalizedText(com.prosysopc.ua.stack.builtintypes.LocalizedText)

Example 4 with ByteString

use of com.prosysopc.ua.stack.builtintypes.ByteString in project FAAAST-Service by FraunhoferIOSB.

the class AASBlobTypeNodeBase method getValue.

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

Example 5 with ByteString

use of com.prosysopc.ua.stack.builtintypes.ByteString in project FAAAST-Service by FraunhoferIOSB.

the class OpcUaEndpointTest method testWriteBlobValue.

/**
 * Test method for writing a range. Writes the property in the OPC UA
 * Server and checks the new value in the server.
 *
 * @throws SecureIdentityException If the operation fails
 * @throws IOException If the operation fails
 * @throws ServiceException If the operation fails
 * @throws StatusException If the operation fails
 * @throws InterruptedException If the operation fails
 * @throws ServiceResultException If the operation fails
 */
@Test
public void testWriteBlobValue() throws SecureIdentityException, IOException, ServiceException, StatusException, InterruptedException, ServiceResultException {
    UaClient client = new UaClient(ENDPOINT_URL);
    client.setSecurityMode(SecurityMode.NONE);
    TestUtils.initialize(client);
    client.connect();
    System.out.println("testWriteBlobValue: client connected");
    aasns = client.getAddressSpace().getNamespaceTable().getIndex(VariableIds.AASAssetAdministrationShellType_AssetInformation_AssetKind.getNamespaceUri());
    List<RelativePath> relPath = new ArrayList<>();
    List<RelativePathElement> browsePath = new ArrayList<>();
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.AAS_ENVIRONMENT_NAME)));
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.SUBMODEL_OPER_DATA_NODE_NAME)));
    browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.TEST_BLOB_NAME)));
    browsePath.add(new RelativePathElement(Identifiers.HasProperty, false, true, new QualifiedName(aasns, TestDefines.PROPERTY_VALUE_NAME)));
    relPath.add(new RelativePath(browsePath.toArray(RelativePathElement[]::new)));
    BrowsePathResult[] bpres = client.getAddressSpace().translateBrowsePathsToNodeIds(Identifiers.ObjectsFolder, relPath.toArray(RelativePath[]::new));
    Assert.assertNotNull("testWriteBlobValue Browse Result Null", bpres);
    Assert.assertTrue("testWriteBlobValue Browse Result: size doesn't match", bpres.length == 1);
    Assert.assertTrue("testWriteBlobValue Browse Result Good", bpres[0].getStatusCode().isGood());
    BrowsePathTarget[] targets = bpres[0].getTargets();
    Assert.assertNotNull("testWriteBlobValue ValueType Null", targets);
    Assert.assertTrue("testWriteBlobValue ValueType empty", targets.length > 0);
    NodeId writeNode = client.getAddressSpace().getNamespaceTable().toNodeId(targets[0].getTargetId());
    // byte[] oldValue = Base64.getDecoder().decode("AQIDBAU=");
    ByteString oldValue = ByteString.valueOf(Base64.getDecoder().decode("AQIDBAU="));
    ByteString newValue = ByteString.valueOf(Base64.getDecoder().decode("QUJDREU="));
    TestUtils.writeNewValueIntern(client, writeNode, oldValue, newValue);
    System.out.println("disconnect client");
    client.disconnect();
}
Also used : RelativePath(com.prosysopc.ua.stack.core.RelativePath) BrowsePathResult(com.prosysopc.ua.stack.core.BrowsePathResult) ByteString(com.prosysopc.ua.stack.builtintypes.ByteString) QualifiedName(com.prosysopc.ua.stack.builtintypes.QualifiedName) ArrayList(java.util.ArrayList) UaClient(com.prosysopc.ua.client.UaClient) RelativePathElement(com.prosysopc.ua.stack.core.RelativePathElement) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) BrowsePathTarget(com.prosysopc.ua.stack.core.BrowsePathTarget) Test(org.junit.Test)

Aggregations

ByteString (com.prosysopc.ua.stack.builtintypes.ByteString)5 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)3 Optional (com.prosysopc.ua.nodes.Optional)2 UaVariable (com.prosysopc.ua.nodes.UaVariable)2 PlainProperty (com.prosysopc.ua.server.nodes.PlainProperty)2 LocalizedText (com.prosysopc.ua.stack.builtintypes.LocalizedText)2 UaClient (com.prosysopc.ua.client.UaClient)1 QualifiedName (com.prosysopc.ua.stack.builtintypes.QualifiedName)1 BrowsePathResult (com.prosysopc.ua.stack.core.BrowsePathResult)1 BrowsePathTarget (com.prosysopc.ua.stack.core.BrowsePathTarget)1 RelativePath (com.prosysopc.ua.stack.core.RelativePath)1 RelativePathElement (com.prosysopc.ua.stack.core.RelativePathElement)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1