use of com.prosysopc.ua.stack.builtintypes.NodeId in project FAAAST-Service by FraunhoferIOSB.
the class ValueConverter method convertValueTypeStringToNodeId.
/**
* Converts the AAS DataTypeDef into the corresponding OPC UA type (NodeId)
*
* @param valueType The desired valueType
* @return The corresponding OPC UA type (NodeId)
*/
public static NodeId convertValueTypeStringToNodeId(String valueType) {
NodeId retval = null;
try {
switch(valueType.toLowerCase()) {
case "bytestring":
retval = Identifiers.ByteString;
break;
case "boolean":
retval = Identifiers.Boolean;
break;
case "datetime":
retval = Identifiers.DateTime;
break;
case "decimal":
retval = Identifiers.Decimal;
break;
case "integer":
retval = Identifiers.Integer;
break;
case "int":
retval = Identifiers.Int32;
break;
case "unsignedint":
retval = Identifiers.UInt32;
break;
case "long":
retval = Identifiers.Int64;
break;
case "unsignedlong":
retval = Identifiers.Int64;
break;
case "short":
retval = Identifiers.Int16;
break;
case "unsignedshort":
retval = Identifiers.UInt16;
break;
case "byte":
retval = Identifiers.SByte;
break;
case "unsignedbyte":
retval = Identifiers.Byte;
break;
case "double":
retval = Identifiers.Double;
break;
case "float":
retval = Identifiers.Float;
break;
case "langstring":
retval = Identifiers.LocalizedText;
break;
case "string":
retval = Identifiers.String;
break;
case "time":
retval = Identifiers.UtcTime;
break;
default:
logger.warn("convertValueTypeStringToNodeId: Unknown type: " + valueType);
retval = NodeId.NULL;
break;
}
} catch (Throwable ex) {
logger.error("convertValueTypeStringToNodeId Exception", ex);
throw ex;
}
return retval;
}
use of com.prosysopc.ua.stack.builtintypes.NodeId in project FAAAST-Service by FraunhoferIOSB.
the class OpcUaEndpointTest method testOperatingManual.
/**
* Tests the SubodelElement OperatingManual from the Submodel Documentation
*
* @param client the OPC UA Client.
* @param node The desired OperatingManual
* @throws ServiceException If the operation fails
* @throws AddressSpaceException If the operation fails
* @throws StatusException If the operation fails
* @throws ServiceResultException If the operation fails
* @throws InterruptedException If a wait was interrupted
*/
private void testOperatingManual(UaClient client, NodeId node) throws ServiceException, AddressSpaceException, StatusException, ServiceResultException, InterruptedException {
TestUtils.checkDisplayName(client, node, TestDefines.OPERATING_MANUAL_NAME);
TestUtils.checkType(client, node, new NodeId(aasns, TestDefines.AAS_SUBMODEL_ELEM_COLL_TYPE_ID));
TestUtils.checkCategoryNode(client, node, aasns, "");
TestUtils.checkModelingKindNode(client, node, aasns, AASModelingKindDataType.Instance);
TestUtils.checkDataSpecificationNode(client, node, aasns);
TestUtils.checkQualifierNode(client, node, aasns, new ArrayList<>());
TestUtils.checkVariableBool(client, node, aasns, TestDefines.ALLOW_DUPLICATES_NAME, false);
// Skip LangString / LocalizedText test: not yet implemented in the service
// TestUtils.checkAasPropertyString(client, node, aasns, "Title", AASModelingKindDataType.Instance, "", AASValueTypeDataType.LocalizedText, "OperatingManual",
// new ArrayList<>());
TestUtils.checkAasPropertyFile(client, node, aasns, "DigitalFile_PDF", AASModelingKindDataType.Instance, "", "application/pdf", "/aasx/OperatingManual.pdf", 0);
}
use of com.prosysopc.ua.stack.builtintypes.NodeId in project FAAAST-Service by FraunhoferIOSB.
the class OpcUaEndpointTest method testWriteReferenceElementValue.
/**
* Test method for writing a property. 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 testWriteReferenceElementValue() 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("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_REF_ELEM_NAME)));
browsePath.add(new RelativePathElement(Identifiers.HierarchicalReferences, false, true, new QualifiedName(aasns, TestDefines.PROPERTY_VALUE_NAME)));
browsePath.add(new RelativePathElement(Identifiers.HasProperty, false, true, new QualifiedName(aasns, TestDefines.KEYS_VALUE_NAME)));
relPath.add(new RelativePath(browsePath.toArray(RelativePathElement[]::new)));
BrowsePathResult[] bpres = client.getAddressSpace().translateBrowsePathsToNodeIds(Identifiers.ObjectsFolder, relPath.toArray(RelativePath[]::new));
Assert.assertNotNull("testWriteReferenceElementValue Browse Result Null", bpres);
Assert.assertTrue("testWriteReferenceElementValue Browse Result: size doesn't match", bpres.length == 1);
Assert.assertTrue("testWriteReferenceElementValue Browse Result Good", bpres[0].getStatusCode().isGood());
BrowsePathTarget[] targets = bpres[0].getTargets();
Assert.assertNotNull("testWriteReferenceElementValue ValueType Null", targets);
Assert.assertTrue("testWriteReferenceElementValue ValueType empty", targets.length > 0);
NodeId writeNode = client.getAddressSpace().getNamespaceTable().toNodeId(targets[0].getTargetId());
List<AASKeyDataType> oldValue = new ArrayList<>();
oldValue.add(new AASKeyDataType(AASKeyElementsDataType.Submodel, TestDefines.SUBMODEL_TECH_DATA_NAME, AASKeyTypeDataType.IRI));
oldValue.add(new AASKeyDataType(AASKeyElementsDataType.Property, TestDefines.MAX_ROTATION_SPEED_NAME, AASKeyTypeDataType.IdShort));
// The DataElementValueMapper changes the order of the elements
List<AASKeyDataType> newValue = new ArrayList<>();
newValue.add(new AASKeyDataType(AASKeyElementsDataType.Submodel, TestDefines.SUBMODEL_TECH_DATA_NAME, AASKeyTypeDataType.IRI));
newValue.add(new AASKeyDataType(AASKeyElementsDataType.Property, "Another property", AASKeyTypeDataType.IdShort));
TestUtils.writeNewValueArray(client, writeNode, oldValue.toArray(AASKeyDataType[]::new), newValue.toArray(AASKeyDataType[]::new));
System.out.println("testWriteReferenceElementValue: disconnect client");
client.disconnect();
}
use of com.prosysopc.ua.stack.builtintypes.NodeId in project FAAAST-Service by FraunhoferIOSB.
the class OpcUaEndpointTest method testAsset.
/**
* Tests the given Asset Node.
*
* @param client The OPC UA> Client.
* @param assetNode The desired Asset Node.
* @throws ServiceException If the operation fails
* @throws AddressSpaceException If the operation fails
* @throws StatusException If the operation fails
* @throws ServiceResultException If the operation fails
*/
private void testAsset(UaClient client, NodeId assetNode) throws ServiceException, AddressSpaceException, StatusException, ServiceResultException {
TestUtils.checkDisplayName(client, assetNode, "Asset:" + TestDefines.SIMPLE_ASSET_NAME);
TestUtils.checkType(client, assetNode, new NodeId(aasns, TestDefines.AAS_ASSET_TYPE_ID));
TestUtils.checkIdentificationNode(client, assetNode, aasns, AASIdentifierTypeDataType.IRI, "http://customer.com/assets/KHBVZJSQKIY");
TestUtils.checkAdministrationNode(client, assetNode, aasns, null, null);
TestUtils.checkCategoryNode(client, assetNode, aasns, "");
TestUtils.checkDataSpecificationNode(client, assetNode, aasns);
}
use of com.prosysopc.ua.stack.builtintypes.NodeId in project FAAAST-Service by FraunhoferIOSB.
the class OpcUaEndpointTest method testSubmodelDoc.
/**
* Tests the given Submodel Documentation.
*
* @param client The OPC UA Client.
* @param submodelNode The desired Submodel
* @throws ServiceException If the operation fails
* @throws AddressSpaceException If the operation fails
* @throws StatusException If the operation fails
* @throws ServiceResultException If the operation fails
* @throws InterruptedException Id a wait was interrupted
*/
private void testSubmodelDoc(UaClient client, NodeId submodelNode) throws ServiceException, AddressSpaceException, StatusException, ServiceResultException, InterruptedException {
TestUtils.checkDisplayName(client, submodelNode, "Submodel:" + TestDefines.SUBMODEL_DOC_NODE_NAME);
TestUtils.checkType(client, submodelNode, new NodeId(aasns, TestDefines.AAS_SUBMODEL_TYPE_ID));
String submodelName = "SubmodelOperationalData";
NodeId operatingManualNode = null;
List<ReferenceDescription> refs = client.getAddressSpace().browse(submodelNode);
Assert.assertNotNull("Browse " + submodelName + " Refs Null", refs);
Assert.assertFalse("Browse " + submodelName + " Refs empty", refs.isEmpty());
for (ReferenceDescription ref : refs) {
NodeId nid = client.getAddressSpace().getNamespaceTable().toNodeId(ref.getNodeId());
switch(ref.getBrowseName().getName()) {
case TestDefines.OPERATING_MANUAL_NAME:
operatingManualNode = nid;
break;
default:
break;
}
}
Assert.assertNotNull(submodelName + " OperatingManual Node not found", operatingManualNode);
TestUtils.checkIdentificationNode(client, submodelNode, aasns, AASIdentifierTypeDataType.IRI, TestDefines.SUBMODEL_DOC_NAME);
TestUtils.checkAdministrationNode(client, submodelNode, aasns, "11", "159");
TestUtils.checkModelingKindNode(client, submodelNode, aasns, AASModelingKindDataType.Instance);
TestUtils.checkCategoryNode(client, submodelNode, aasns, "");
TestUtils.checkDataSpecificationNode(client, submodelNode, aasns);
TestUtils.checkQualifierNode(client, submodelNode, aasns, new ArrayList<>());
testOperatingManual(client, operatingManualNode);
}
Aggregations