pub struct ModbusDevice { /* private fields */ }Expand description
Modbus device implementation.
Implementations§
Source§impl ModbusDevice
impl ModbusDevice
Sourcepub fn new(config: ModbusDeviceConfig) -> Self
pub fn new(config: ModbusDeviceConfig) -> Self
Create a new Modbus device.
Sourcepub fn registers(&self) -> &Arc<RegisterStore>
pub fn registers(&self) -> &Arc<RegisterStore>
Get the register store.
Sourcepub fn add_point(&mut self, def: DataPointDef, address: ModbusAddress)
pub fn add_point(&mut self, def: DataPointDef, address: ModbusAddress)
Add a data point definition.
Sourcepub fn add_holding_register(
&mut self,
id: impl Into<String>,
name: impl Into<String>,
address: u16,
data_type: DataType,
)
pub fn add_holding_register( &mut self, id: impl Into<String>, name: impl Into<String>, address: u16, data_type: DataType, )
Add a holding register point.
Sourcepub fn add_input_register(
&mut self,
id: impl Into<String>,
name: impl Into<String>,
address: u16,
data_type: DataType,
)
pub fn add_input_register( &mut self, id: impl Into<String>, name: impl Into<String>, address: u16, data_type: DataType, )
Add an input register point.
Trait Implementations§
Source§impl Device for ModbusDevice
impl Device for ModbusDevice
Source§fn info(&self) -> &DeviceInfo
fn info(&self) -> &DeviceInfo
Get device information.
Source§fn initialize<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn initialize<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Initialize the device.
Source§fn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Start the device.
Source§fn stop<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stop the device.
Source§fn tick<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn tick<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Process one tick (for simulation updates).
Source§fn point_definitions(&self) -> Vec<&DataPointDef>
fn point_definitions(&self) -> Vec<&DataPointDef>
Get all data point definitions.
Source§fn point_definition(&self, point_id: &str) -> Option<&DataPointDef>
fn point_definition(&self, point_id: &str) -> Option<&DataPointDef>
Get a data point definition by ID.
Source§fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
point_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<DataPoint>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read<'life0, 'life1, 'async_trait>(
&'life0 self,
point_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<DataPoint>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Read a data point value.
Source§fn write<'life0, 'life1, 'async_trait>(
&'life0 mut self,
point_id: &'life1 str,
value: Value,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn write<'life0, 'life1, 'async_trait>(
&'life0 mut self,
point_id: &'life1 str,
value: Value,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Write a data point value.
Source§fn subscribe(&self) -> Option<Receiver<DataPoint>>
fn subscribe(&self) -> Option<Receiver<DataPoint>>
Subscribe to value changes (returns a receiver).
Source§fn statistics(&self) -> DeviceStatistics
fn statistics(&self) -> DeviceStatistics
Get device statistics.
Source§fn state(&self) -> DeviceState
fn state(&self) -> DeviceState
Get device state.
Source§fn read_multiple<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
point_ids: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<DataPoint>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn read_multiple<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
point_ids: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<DataPoint>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Read multiple data point values.
Source§fn read_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<DataPoint>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn read_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<DataPoint>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Read all data points.
Source§fn write_multiple<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
values: &'life1 [(&'life2 str, Value)],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn write_multiple<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
values: &'life1 [(&'life2 str, Value)],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Write multiple data point values.
Auto Trait Implementations§
impl !Freeze for ModbusDevice
impl !RefUnwindSafe for ModbusDevice
impl Send for ModbusDevice
impl Sync for ModbusDevice
impl Unpin for ModbusDevice
impl UnsafeUnpin for ModbusDevice
impl !UnwindSafe for ModbusDevice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more