Search in sources :

Example 1 with ObjectNodeConstructor

use of org.eclipse.milo.opcua.sdk.client.ObjectTypeManager.ObjectNodeConstructor in project milo by eclipse.

the class AddressSpace method newObjectNode.

private UaObjectNode newObjectNode(NodeId nodeId, NodeId typeDefinitionId, 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.Object, "expected NodeClass.Object, 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);
        UByte eventNotifier = (UByte) attributeValues.get(7).getValue().getValue();
        ObjectNodeConstructor constructor = client.getObjectTypeManager().getNodeConstructor(typeDefinitionId).orElse(UaObjectNode::new);
        return constructor.apply(client, nodeId, nodeClass, browseName, displayName, description, writeMask, userWriteMask, eventNotifier);
    } catch (Throwable t) {
        throw UaException.extract(t).orElse(new UaException(StatusCodes.Bad_UnexpectedError, t));
    }
}
Also used : UByte(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UByte) NodeClass(org.eclipse.milo.opcua.stack.core.types.enumerated.NodeClass) UaObjectNode(org.eclipse.milo.opcua.sdk.client.nodes.UaObjectNode) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) UaException(org.eclipse.milo.opcua.stack.core.UaException) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) UInteger(org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger) ObjectNodeConstructor(org.eclipse.milo.opcua.sdk.client.ObjectTypeManager.ObjectNodeConstructor) StatusCode(org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode) LocalizedText(org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText)

Aggregations

ObjectNodeConstructor (org.eclipse.milo.opcua.sdk.client.ObjectTypeManager.ObjectNodeConstructor)1 UaObjectNode (org.eclipse.milo.opcua.sdk.client.nodes.UaObjectNode)1 UaException (org.eclipse.milo.opcua.stack.core.UaException)1 DataValue (org.eclipse.milo.opcua.stack.core.types.builtin.DataValue)1 LocalizedText (org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText)1 QualifiedName (org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName)1 StatusCode (org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode)1 UByte (org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UByte)1 UInteger (org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger)1 NodeClass (org.eclipse.milo.opcua.stack.core.types.enumerated.NodeClass)1