Struct ur20_modbus::Coupler [−][src]
pub struct Coupler { /* fields omitted */ }
A Modbus TCP fieldbus coupler (UR20-FBC-MOD-TCP
) implementation.
Example:
extern crate futures; extern crate tokio_core; extern crate ur20_modbus; use futures::Future; use tokio_core::reactor::Core; use ur20_modbus::Coupler; let mut core = Core::new().unwrap(); let handle = core.handle(); let addr = "192.168.178.3:502".parse().unwrap(); let client = Coupler::connect(addr, handle); let task = client.and_then(|client|{ println!("Connected to {}", client.id()); Ok(()) }); core.run(task).unwrap();
Methods
impl Coupler
[src]
impl Coupler
pub fn connect(
addr: SocketAddr,
handle: Handle
) -> impl Future<Item = Coupler, Error = Error>
[src]
pub fn connect(
addr: SocketAddr,
handle: Handle
) -> impl Future<Item = Coupler, Error = Error>
Connect to the coupler.
pub fn id(&self) -> &str
[src]
pub fn id(&self) -> &str
The actual coupler ID.
pub fn inputs(&self) -> HashMap<Address, ChannelValue>
[src]
pub fn inputs(&self) -> HashMap<Address, ChannelValue>
Current input state.
pub fn outputs(&self) -> HashMap<Address, ChannelValue>
[src]
pub fn outputs(&self) -> HashMap<Address, ChannelValue>
Current output state.
pub fn modules(&self) -> &[ModuleType]
[src]
pub fn modules(&self) -> &[ModuleType]
List of modules.
pub fn set_output(&self, addr: &Address, val: ChannelValue) -> Result<(), Error>
[src]
pub fn set_output(&self, addr: &Address, val: ChannelValue) -> Result<(), Error>
Set the value of an output channel.
pub fn read_input_data(&self) -> HashMap<Address, Option<Vec<u8>>>
[src]
pub fn read_input_data(&self) -> HashMap<Address, Option<Vec<u8>>>
Read binary input data.
pub fn tick<'a>(
&'a self
) -> impl Future<Item = (), Error = Error> + 'a
[src]
pub fn tick<'a>(
&'a self
) -> impl Future<Item = (), Error = Error> + 'a
Run an I/O cycle. This reads all process input registers and writes to process output registers.
pub fn tick_and_consume(
self
) -> impl Future<Item = Self, Error = Error>
[src]
pub fn tick_and_consume(
self
) -> impl Future<Item = Self, Error = Error>
This method behaves like Coupler::tick but it consumes the Coupler and returns it as Future::Item.