locka99 / opcua

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

NodeId seems not to be set for MonitoredItemCreateResult #226

Open nachtmam opened 1 year ago

nachtmam commented 1 year ago

I tried to create some monitored items for a subscription. Code snipped attached, but it looks like the MonitoredItemCreateResult containing the result does not contain the NodeId.

Code:

let node_ids = vec![1007, 1002];

let items_to_create: Vec<MonitoredItemCreateRequest> = node_ids
            .iter()
            .map(|v| NodeId::new(ns, *v).into())
            .collect();

let results = session
            .create_monitored_items(id, TimestampsToReturn::Both, &items_to_create)
            .unwrap();
debug!("status_code {:?}", results);

Output :

status_code [
MonitoredItemCreateResult { 
status_code: HISTORICAL_RAW | Good, monitored_item_id: 1, revised_sampling_interval: 100.0, revised_queue_size: 1, filter_result: ExtensionObject { 
node_id: NodeId { namespace: 0, identifier: Numeric(0) }, body: None } }, 

MonitoredItemCreateResult { 
status_code: HISTORICAL_RAW | Good, monitored_item_id: 2, revised_sampling_interval: 100.0, revised_queue_size: 1, filter_result: ExtensionObject {
node_id: NodeId { namespace: 0, identifier: Numeric(0) }, body: None } }
]

Has anyone seen a similar issue ?

milgner commented 1 year ago

The node_id you're looking at is part of the filter_result. But since you don't have any filters, it's empty. The message itself doesn't contain any node id. Often in OPC UA, one is expected to keep state from the invocation in order to interpret the response: the Read service response can only be interpreted if you know what ReadValueIds you used to invoke it.