提交 66c0aaa2 authored 作者: Serhij S's avatar Serhij S

0.1.28

上级 d1c3dc64
[package]
name = "roboplc"
version = "0.1.27"
version = "0.1.28"
edition = "2021"
authors = ["Serhij S. <div@altertech.com>"]
license = "Apache-2.0"
......
//!
//! [EAPI communication example](https://github.com/eva-ics/roboplc/blob/main/examples/eapi.rs)
use binrw::BinWrite;
use busrt::rpc::{RpcError, RpcEvent, RpcHandlers, RpcResult};
use busrt::{async_trait, QoS};
......@@ -61,6 +63,7 @@ impl DataDeliveryPolicy for PushPayload {
}
}
/// EAPI connection configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EAPIConfig<D, V>
where
......@@ -147,7 +150,9 @@ where
}
}
/// Action handler functions type
pub type ActionHandlerFn<D, V> = fn(&mut Action, context: &Context<D, V>) -> ActionResult;
/// The result type of action handler functions
pub type ActionResult = std::result::Result<(), Box<dyn std::error::Error>>;
type ActionHandlers<D, V> = Arc<BTreeMap<OID, ActionHandlerFn<D, V>>>;
......@@ -276,6 +281,7 @@ where
}
}
/// EAPI connector, requires to be run in a separate thread manually
pub struct EAPI<D, V>
where
D: DataDeliveryPolicy + Clone + Send + Sync + 'static,
......
//!
//! The module provides mapping for various protocols. Structural mapping is built on top of
//! the [binrw](https://crates.io/search?q=binrw) crate.
pub use binrw;
use binrw::{BinRead, BinWrite};
use crate::Result;
#[cfg(feature = "eapi")]
/// EVA ICS local bus API
pub mod eapi;
#[cfg(feature = "modbus")]
/// Modbus communication
pub mod modbus;
/// Raw UDP communication
pub mod raw_udp;
#[allow(clippy::module_name_repetitions)]
......
//!
//! Contains Modbus client/server implementations.
//!
//! Examples: [modbus
//! master(client)](https://github.com/eva-ics/roboplc/blob/main/examples/modbus-master.rs),
//! [modbus slave(server)](https://github.com/eva-ics/roboplc/blob/main/examples/modbus-slave.rs)
use std::io::Cursor;
use crate::comm::{Client, Protocol};
......@@ -22,6 +28,7 @@ pub mod prelude {
};
}
/// Swaps endianess of floating point numbers in case of non-standard IEEE 754 layout.
pub trait SwapModbusEndianess {
fn to_swapped_modbus_endianness(&self) -> Self;
}
......@@ -49,6 +56,7 @@ impl From<Protocol> for ModbusProto {
}
}
/// Mapping options for Modbus client
#[allow(clippy::module_name_repetitions)]
#[derive(Clone)]
pub struct ModbusMappingOptions {
......@@ -71,6 +79,7 @@ impl Default for ModbusMappingOptions {
}
}
/// Mapping for Modbus client
#[allow(clippy::module_name_repetitions)]
pub struct ModbusMapping {
client: Client,
......
......@@ -2,6 +2,7 @@ use std::str::FromStr;
use crate::{Error, Result};
/// A Modbus register kind.
#[derive(Eq, PartialEq, Copy, Clone, Debug)]
pub enum Kind {
Coil,
......@@ -10,6 +11,7 @@ pub enum Kind {
Holding,
}
/// A Modbus register type, contains the kind and the offset.
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub struct Register {
pub kind: Kind,
......
......@@ -65,6 +65,7 @@ fn handle_client<
Ok(())
}
/// Modbus server. Requires to be run in a separate thread manually.
#[allow(clippy::module_name_repetitions)]
pub struct ModbusServer<const C: usize, const D: usize, const I: usize, const H: usize> {
storage: Arc<Mutex<ModbusStorage<C, D, I, H>>>,
......@@ -145,6 +146,7 @@ fn prepare_tcp_stream(stream: &TcpStream, timeout: Duration) -> Result<()> {
Ok(())
}
/// Server storage context mapping.
pub struct ModbusServerMapping<const C: usize, const D: usize, const I: usize, const H: usize> {
storage: Arc<Mutex<ModbusStorage<C, D, I, H>>>,
register: ModbusRegister,
......
//!
//! Can be used to communicate between processes on different machines or with various 3rd party
//! devices and software, such as Matlab, LabView, etc.
//!
//! [Raw UDP example](https://github.com/eva-ics/roboplc/blob/main/examples/raw-udp.rs)
use binrw::{BinRead, BinWrite};
use std::{
io::Cursor,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论