pub struct Control<'a>(/* private fields */);Expand description
Borrow a pinned client for explicit value writes and method calls.
Each call dispatches at most once. A dropped future after dispatch retires the session. If the reply is lost, inspect application state on a new session before deciding what to do.
use opcua_kit::{Client, Control, ControlError, NodeId};
let status = Control::new(client).write_scalar(node, 42_u32).await?;
if status != 0 {
eprintln!("write returned 0x{status:08X}");
}Implementations§
Source§impl Control<'_>
impl Control<'_>
Sourcepub async fn acknowledge_condition(
&self,
condition: &NodeId,
event_id: &[u8],
comment: Option<ConditionComment<'_>>,
) -> Result<CallOutcome, ConditionError>
pub async fn acknowledge_condition( &self, condition: &NodeId, event_id: &[u8], comment: Option<ConditionComment<'_>>, ) -> Result<CallOutcome, ConditionError>
Acknowledge the reported branch state by its condition instance and opaque EventId. Supply the ConditionId and EventId from the same notification on this server where AckedState/Id was false. The separate BranchId identifies a retained branch. A server can reject an unknown EventId or an already acknowledged state.
use opcua_kit::{Client, ConditionComment, ConditionError, Control, NodeId};
async fn acknowledge(client: &Client, condition: &NodeId, event_id: &[u8])
-> Result<u32, ConditionError>
{
let comment = ConditionComment { locale: "en", text: "Operator reviewed" };
let result = Control::new(client)
.acknowledge_condition(condition, event_id, Some(comment))
.await?;
Ok(result.status)
}Sourcepub async fn confirm_condition(
&self,
condition: &NodeId,
event_id: &[u8],
comment: Option<ConditionComment<'_>>,
) -> Result<CallOutcome, ConditionError>
pub async fn confirm_condition( &self, condition: &NodeId, event_id: &[u8], comment: Option<ConditionComment<'_>>, ) -> Result<CallOutcome, ConditionError>
Confirm the reported branch state by its condition instance and opaque EventId. Use the EventId for the state whose ConfirmedState/Id was false, including when the server issued a new EventId after acknowledgement. Confirm requires server support.
Source§impl<'a> Control<'a>
impl<'a> Control<'a>
Sourcepub const fn new(client: &'a Client) -> Self
pub const fn new(client: &'a Client) -> Self
Use the existing session’s credentials, authority, namespace map and service guard.
Sourcepub async fn write_scalar<T: Scalar>(
&self,
node: &NodeId,
value: T,
) -> Result<u32, ControlError>
pub async fn write_scalar<T: Scalar>( &self, node: &NodeId, value: T, ) -> Result<u32, ControlError>
Write one Rust scalar with its exact OPC UA type and return the full operation status.
Sourcepub async fn write_value(
&self,
node: &NodeId,
value: &Variant,
) -> Result<u32, ControlError>
pub async fn write_value( &self, node: &NodeId, value: &Variant, ) -> Result<u32, ControlError>
Write the Value attribute only. The Variant retains its exact type and dimensions. The request supplies no data quality or timestamps. Limit: 128 KiB encoded Variant.
Sourcepub async fn call_method(
&self,
object: &NodeId,
method: &NodeId,
inputs: &[Variant],
) -> Result<CallOutcome, ControlError>
pub async fn call_method( &self, object: &NodeId, method: &NodeId, inputs: &[Variant], ) -> Result<CallOutcome, ControlError>
Call one method on the supplied object. The wire inputs and outputs may be heterogeneous. Up to 64 arguments and 128 KiB in aggregate encoded Variant data are accepted per direction. Returns the server’s operation status even for a rejected method or invalid input argument.
use opcua_kit::{Client, Control, NodeId, Scalar};
let args = [42_u64.into_variant()?];
let reply = Control::new(client).call_method(object, method, &args).await?;
if reply.status == 0 && let [result] = reply.outputs.as_slice() {
let value = u64::from_variant(result)?;
println!("method returned {value:?}");
}