SafeClient

Struct SafeClient 

Source
pub struct SafeClient { /* private fields */ }
Available on crate feature safe-client-sync and (crate features tokio-rtu-sync or tokio-tcp-sync) only.
Expand description

A thread-safe synchronous client for the SDM72 energy meter.

Implementations§

Source§

impl SafeClient

Source

pub fn new(ctx: Context) -> Self

Creates a new SafeClient instance.

§Arguments
  • ctx: A synchronous Modbus client context, already connected.
Source

pub fn from_shared(ctx: Arc<Mutex<Context>>) -> Self

Creates a new SafeClient from an existing Arc<Mutex<Context>>.

This allows multiple SafeClient instances to share the exact same underlying connection context.

Source

pub fn clone_shared(&self) -> Arc<Mutex<Context>>

Clones and returns the underlying Arc<Mutex<Context>>.

This allows the shared context to be used by other parts of an application that may need direct access to the Modbus context.

Source

pub fn system_type(&mut self) -> Result<SystemType, Error>

Reads the proto::SystemType value from the Modbus holding register.

Source

pub fn set_system_type(&mut self, value: SystemType) -> Result<(), Error>

Writes the proto::SystemType value to the Modbus holding register.

Source

pub fn pulse_width(&mut self) -> Result<PulseWidth, Error>

Reads the proto::PulseWidth value from the Modbus holding register.

Source

pub fn set_pulse_width(&mut self, value: PulseWidth) -> Result<(), Error>

Writes the proto::PulseWidth value to the Modbus holding register.

Source

pub fn kppa(&mut self) -> Result<KPPA, Error>

Reads the proto::KPPA value from the Modbus holding register.

Source

pub fn set_kppa(&mut self, password: Password) -> Result<(), Error>

Sets the Key Parameter Programming Authorization (KPPA).

This is required to change settings on the meter.

Source

pub fn parity_and_stop_bit(&mut self) -> Result<ParityAndStopBit, Error>

Reads the proto::ParityAndStopBit value from the Modbus holding register.

Source

pub fn set_parity_and_stop_bit( &mut self, value: ParityAndStopBit, ) -> Result<(), Error>

Writes the proto::ParityAndStopBit value to the Modbus holding register.

Source

pub fn address(&mut self) -> Result<Address, Error>

Reads the proto::Address value from the Modbus holding register.

Source

pub fn set_address(&mut self, value: Address) -> Result<(), Error>

Source

pub fn pulse_constant(&mut self) -> Result<PulseConstant, Error>

Reads the proto::PulseConstant value from the Modbus holding register.

Source

pub fn set_pulse_constant(&mut self, value: PulseConstant) -> Result<(), Error>

Writes the proto::PulseConstant value to the Modbus holding register.

Source

pub fn password(&mut self) -> Result<Password, Error>

Reads the proto::Password value from the Modbus holding register.

Source

pub fn set_password(&mut self, value: Password) -> Result<(), Error>

Writes the proto::Password value to the Modbus holding register.

Source

pub fn baud_rate(&mut self) -> Result<BaudRate, Error>

Reads the proto::BaudRate value from the Modbus holding register.

Source

pub fn set_baud_rate(&mut self, value: BaudRate) -> Result<(), Error>

Writes the proto::BaudRate value to the Modbus holding register.

Source

pub fn auto_scroll_time(&mut self) -> Result<AutoScrollTime, Error>

Reads the proto::AutoScrollTime value from the Modbus holding register.

Source

pub fn set_auto_scroll_time( &mut self, value: AutoScrollTime, ) -> Result<(), Error>

Writes the proto::AutoScrollTime value to the Modbus holding register.

Source

pub fn backlight_time(&mut self) -> Result<BacklightTime, Error>

Reads the proto::BacklightTime value from the Modbus holding register.

Source

pub fn set_backlight_time(&mut self, value: BacklightTime) -> Result<(), Error>

Writes the proto::BacklightTime value to the Modbus holding register.

Source

pub fn pulse_energy_type(&mut self) -> Result<PulseEnergyType, Error>

Reads the proto::PulseEnergyType value from the Modbus holding register.

Source

pub fn set_pulse_energy_type( &mut self, value: PulseEnergyType, ) -> Result<(), Error>

Writes the proto::PulseEnergyType value to the Modbus holding register.

Source

pub fn reset_historical_data(&mut self) -> Result<(), Error>

Resets the historical data on the meter.

This requires KPPA authorization.

Source

pub fn serial_number(&mut self) -> Result<SerialNumber, Error>

Reads the proto::SerialNumber value from the Modbus holding register.

Source

pub fn meter_code(&mut self) -> Result<MeterCode, Error>

Reads the proto::MeterCode value from the Modbus holding register.

Source

pub fn software_version(&mut self) -> Result<SoftwareVersion, Error>

Reads the proto::SoftwareVersion value from the Modbus holding register.

Source

pub fn read_all_settings( &mut self, delay: &Duration, ) -> Result<AllSettings, Error>

Reads all settings from the meter in a single batch operation.

Source

pub fn read_all(&mut self, delay: &Duration) -> Result<AllValues, Error>

Reads all measurement values from the meter in a single batch operation.

Trait Implementations§

Source§

impl Clone for SafeClient

Source§

fn clone(&self) -> SafeClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.