locka99 / opcua

A client and server implementation of the OPC UA specification written in Rust
Mozilla Public License 2.0
475 stars 128 forks source link

Reading Method's arguments #272

Open abdawoud opened 1 year ago

abdawoud commented 1 year ago

First, thank you for your continuous support.

I would appreciate it if you could guide me to get a method's arguments in OPCUA. I have the following snippet that reads the InputArguments's node_id:

let nodes_to_read = [
    ReadValueId {
        node_id: input_arguments_node_id.clone(),
        attribute_id: AttributeId::Value as u32,
        index_range: UAString::null(),
        data_encoding: QualifiedName::null()
    }
];

let read_data = session.read(&nodes_to_read, TimestampsToReturn::Both, 1.0);
match read_data {
    Ok(vv) => {
        for v in vv {
            let v_unwraped = v.value.unwrap();
            println!("{:?}", v_unwraped);
        }
    }
}

which prints: Array(Array { value_type: ExtensionObject, values: [ExtensionObject(ExtensionObject { node_id: NodeId { namespace: x, identifier: Numeric(x) }, body: ByteString(ByteString { value: Some([10, 0, 0, 0, ....]) }) })], dimensions: [] })

I assume if I can decode the body, I would be able to see the argument details, but how can I do that?