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;
}
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;
}
}
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;
}
}
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;
}
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();
}
Aggregations