use of org.eclipse.milo.opcua.sdk.client.nodes.UaObjectTypeNode in project milo by eclipse.
the class AddressSpace method newObjectTypeNode.
private UaObjectTypeNode newObjectTypeNode(NodeId nodeId, List<DataValue> attributeValues) throws UaException {
DataValue nodeIdDataValue = attributeValues.get(0);
StatusCode nodeIdStatusCode = nodeIdDataValue.getStatusCode();
if (nodeIdStatusCode != null && nodeIdStatusCode.isBad()) {
throw new UaException(nodeIdStatusCode);
}
try {
NodeClass nodeClass = NodeClass.from((Integer) attributeValues.get(1).getValue().getValue());
Preconditions.checkArgument(nodeClass == NodeClass.ObjectType, "expected NodeClass.ObjectType, got NodeClass." + nodeClass);
QualifiedName browseName = (QualifiedName) attributeValues.get(2).getValue().getValue();
LocalizedText displayName = (LocalizedText) attributeValues.get(3).getValue().getValue();
LocalizedText description = getAttributeOrNull(attributeValues.get(4), LocalizedText.class);
UInteger writeMask = getAttributeOrNull(attributeValues.get(5), UInteger.class);
UInteger userWriteMask = getAttributeOrNull(attributeValues.get(6), UInteger.class);
Boolean isAbstract = (Boolean) attributeValues.get(7).getValue().getValue();
return new UaObjectTypeNode(client, nodeId, nodeClass, browseName, displayName, description, writeMask, userWriteMask, isAbstract);
} catch (Throwable t) {
throw UaException.extract(t).orElse(new UaException(StatusCodes.Bad_UnexpectedError, t));
}
}
use of org.eclipse.milo.opcua.sdk.client.nodes.UaObjectTypeNode in project milo by eclipse.
the class UaObjectNodeTest method getTypeDefinition.
@Test
public void getTypeDefinition() throws UaException {
UaObjectNode objectNode = client.getAddressSpace().getObjectNode(Identifiers.Server);
UaObjectTypeNode objectTypeNode = objectNode.getTypeDefinition();
assertEquals(Identifiers.ServerType, objectTypeNode.getNodeId());
}
use of org.eclipse.milo.opcua.sdk.client.nodes.UaObjectTypeNode in project milo by eclipse.
the class AddressSpace method createObjectTypeNodeFromBaseAttributes.
private CompletableFuture<UaObjectTypeNode> createObjectTypeNodeFromBaseAttributes(NodeId nodeId, List<DataValue> baseAttributeValues) {
Set<AttributeId> remainingAttributes = Sets.difference(AttributeId.OBJECT_TYPE_ATTRIBUTES, AttributeId.BASE_ATTRIBUTES);
CompletableFuture<ReadResponse> attributesFuture = readAttributes(nodeId, remainingAttributes);
return attributesFuture.thenCompose(response -> {
List<DataValue> attributeValues = new ArrayList<>(baseAttributeValues);
Collections.addAll(attributeValues, response.getResults());
try {
UaObjectTypeNode node = newObjectTypeNode(nodeId, attributeValues);
nodeCache.put(node.getNodeId(), node);
return completedFuture(node);
} catch (UaException e) {
return failedFuture(e);
}
});
}
Aggregations