SDM72

Struct SDM72 

Source
pub struct SDM72;
Available on crate features tokio-rtu-sync or tokio-tcp-sync only.
Expand description

A synchronous client for the SDM72 energy meter.

This struct provides a high-level interface for interacting with the SDM72 energy meter. It uses a synchronous tokio-modbus context for communication. An instance of this client can be created using the new method.

Implementations§

Source§

impl SDM72

Source

pub fn system_type(ctx: &mut Context) -> Result<SystemType, Error>

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

Source

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

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

Source

pub fn pulse_width(ctx: &mut Context) -> Result<PulseWidth, Error>

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

Source

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

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

Source

pub fn kppa(ctx: &mut Context) -> Result<KPPA, Error>

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

Source

pub fn set_kppa(ctx: &mut Context, 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(ctx: &mut Context) -> Result<ParityAndStopBit, Error>

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

Source

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

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

Source

pub fn address(ctx: &mut Context) -> Result<Address, Error>

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

Source

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

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

Source

pub fn pulse_constant(ctx: &mut Context) -> Result<PulseConstant, Error>

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

Source

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

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

Source

pub fn password(ctx: &mut Context) -> Result<Password, Error>

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

Source

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

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

Source

pub fn baud_rate(ctx: &mut Context) -> Result<BaudRate, Error>

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

Source

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

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

Source

pub fn auto_scroll_time(ctx: &mut Context) -> Result<AutoScrollTime, Error>

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

Source

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

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

Source

pub fn backlight_time(ctx: &mut Context) -> Result<BacklightTime, Error>

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

Source

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

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

Source

pub fn pulse_energy_type(ctx: &mut Context) -> Result<PulseEnergyType, Error>

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

Source

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

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

Source

pub fn reset_historical_data(ctx: &mut Context) -> Result<(), Error>

Resets the historical data on the meter.

This requires KPPA authorization.

Source

pub fn serial_number(ctx: &mut Context) -> Result<SerialNumber, Error>

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

Source

pub fn meter_code(ctx: &mut Context) -> Result<MeterCode, Error>

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

Source

pub fn software_version(ctx: &mut Context) -> Result<SoftwareVersion, Error>

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

Source

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

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

This method is more efficient than reading each setting individually because it minimizes the number of Modbus requests by batching them. The SDM72 meter has a limit of 30 parameters per request, so this function splits the reads into multiple batches.

§Arguments
  • delay - The delay to be inserted between Modbus requests. This is necessary for some Modbus devices, which may need a short pause to process a request before they are ready to accept the next one. A typical value is 100 milliseconds, but this may vary depending on the device and network conditions.
Source

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

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

This method is more efficient than reading each value individually because it minimizes the number of Modbus requests by batching them. The SDM72 meter has a limit of 30 parameters per request, so this function splits the reads into multiple batches.

§Arguments
  • delay - The delay to be inserted between Modbus requests. This is necessary for some Modbus devices, which may need a short pause to process a request before they are ready to accept the next one. A typical value is 100 milliseconds, but this may vary depending on the device and network conditions.

Auto Trait Implementations§

§

impl Freeze for SDM72

§

impl RefUnwindSafe for SDM72

§

impl Send for SDM72

§

impl Sync for SDM72

§

impl Unpin for SDM72

§

impl UnwindSafe for SDM72

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> 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, 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.