use crate::PlcValue;
#[derive(Debug, Clone)]
pub enum BatchOperation {
Read { tag_name: String },
Write { tag_name: String, value: PlcValue },
}
#[derive(Debug, Clone)]
pub struct BatchResult {
pub operation: BatchOperation,
pub result: std::result::Result<Option<PlcValue>, BatchError>,
pub execution_time_us: u64,
}
#[derive(Debug, Clone, thiserror::Error)]
#[non_exhaustive]
pub enum BatchError {
#[error("Tag not found: {0}")]
TagNotFound(String),
#[error("Data type mismatch: expected {expected}, got {actual}")]
DataTypeMismatch { expected: String, actual: String },
#[error("Network error: {0}")]
NetworkError(String),
#[error("CIP error (0x{status:02X}): {message}")]
CipError { status: u8, message: String },
#[error("Tag path error: {0}")]
TagPathError(String),
#[error("Serialization error: {0}")]
SerializationError(String),
#[error("Operation timeout")]
Timeout,
#[error("Error: {0}")]
Other(String),
}
#[derive(Debug, Clone)]
pub struct BatchConfig {
pub max_operations_per_packet: usize,
pub max_packet_size: usize,
pub packet_timeout_ms: u64,
pub continue_on_error: bool,
pub optimize_packet_packing: bool,
}
impl Default for BatchConfig {
fn default() -> Self {
Self {
max_operations_per_packet: 20,
max_packet_size: 504, packet_timeout_ms: 3000,
continue_on_error: true,
optimize_packet_packing: true,
}
}
}