run keyword if 报错,Keyword 'BuiltIn.Log' expected 1 to 5 arguments, got 12.



错误原因:上面红色框中的ELSE IF/ELSE大写才能识别。


很抱歉,我可能误导了你。在我的前一个答案中,我假设 `DataType` 属性返回的是一个 `NodeId` 对象,但实际上它返回的是一个 `UnsignedShort` 对象,因此你需要将其转换为 `NodeId` 对象才能使用。以下是修改后的代码示例: ```java import org.eclipse.milo.opcua.sdk.client.OpcUaClient; import org.eclipse.milo.opcua.stack.core.AttributeId; import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn; import java.util.concurrent.CompletableFuture; public class ReadNodeDataType { public static void main(String[] args) throws Exception { // 创建 OPC UA 客户端 OpcUaClient client = OpcUaClient.create(endpointUrl); // 连接到 OPC UA 服务器 client.connect().get(); // 读取节点的 DataType 属性 NodeId nodeId = new NodeId(namespaceIndex, nodeIdString); CompletableFuture<DataValue> future = client.readValue( 0, TimestampsToReturn.Both, nodeId, AttributeId.DataType); // 处理读取结果 DataValue dataValue = future.get(); int dataTypeValue = (int) dataValue.getValue().getValue(); NodeId dataTypeNodeId = new NodeId(dataTypeValue); System.out.println("Node data type: " + dataTypeNodeId.getIdentifier()); // 断开连接 client.disconnect().get(); } } ``` 在上面的代码中,我们将 `UnsignedShort` 对象转换为 `int` 类型,然后使用 `int` 类型的值创建一个 `NodeId` 对象,这样就可以获取到节点的类型了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值