跳到主要内容

Method 方法

OPC UA Method 节点是服务端暴露的 RPC 接口. 通过 Session::call(...) 调用.

子页跳转
  • 调用方法的完整签名 / 内存所有权 / 找方法 NodeId 请参考 Call.
  • 报警 Acknowledge 也通过 call 调用, 见 事件订阅.

一分钟示例

use darra_opcua::Variant;

let mut a = Variant::new(); a.set_i32(3);
let mut b = Variant::new(); b.set_i32(4);

let outputs = s.call(
"ns=2;s=Calculator",
"ns=2;s=Calculator.Add",
&[a, b],
)?;

for v in &outputs {
println!("sum = {}", v.try_get_i32().unwrap_or(0));
}

outputs: Vec<Variant> — 每个元素都实现 Drop, 离开作用域自动释放 native.

下一步