ccs: pl and tristar modules underneath controller

This commit is contained in:
Alex Janka 2025-01-10 09:28:06 +11:00
parent e914f2fd10
commit 2fbae49297
4 changed files with 7 additions and 6 deletions

View file

@ -1,3 +1,6 @@
mod pl;
mod tristar;
pub struct Controller { pub struct Controller {
name: String, name: String,
interval: std::time::Duration, interval: std::time::Duration,
@ -28,13 +31,13 @@ impl Controller {
)> { )> {
let inner = match config.variant { let inner = match config.variant {
crate::config::ChargeControllerVariant::Tristar => ControllerInner::Tristar( crate::config::ChargeControllerVariant::Tristar => ControllerInner::Tristar(
crate::tristar::Tristar::new(&config.name, &config.transport).await?, tristar::Tristar::new(&config.name, &config.transport).await?,
), ),
crate::config::ChargeControllerVariant::Pl { crate::config::ChargeControllerVariant::Pl {
timeout_milliseconds, timeout_milliseconds,
} => match &config.transport { } => match &config.transport {
crate::config::Transport::Serial { port, baud_rate } => ControllerInner::Pl( crate::config::Transport::Serial { port, baud_rate } => ControllerInner::Pl(
crate::pl::Pli::new(port, &config.name, *baud_rate, timeout_milliseconds)?, pl::Pli::new(port, &config.name, *baud_rate, timeout_milliseconds)?,
), ),
crate::config::Transport::Tcp { ip: _, port: _ } => { crate::config::Transport::Tcp { ip: _, port: _ } => {
return Err(eyre::eyre!("pl doesn't support tcp")) return Err(eyre::eyre!("pl doesn't support tcp"))
@ -138,8 +141,8 @@ impl MultiTx {
} }
pub enum ControllerInner { pub enum ControllerInner {
Pl(crate::pl::Pli), Pl(pl::Pli),
Tristar(crate::tristar::Tristar), Tristar(tristar::Tristar),
} }
impl ControllerInner { impl ControllerInner {

View file

@ -25,8 +25,6 @@ enum Commands {
mod controller; mod controller;
mod gauges; mod gauges;
mod pl;
mod tristar;
mod web; mod web;