From 2fbae49297da70643429ad9decb6e4ecd4d28e5a Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Fri, 10 Jan 2025 09:28:06 +1100 Subject: [PATCH] ccs: pl and tristar modules underneath controller --- charge-controller-supervisor/src/controller.rs | 11 +++++++---- .../src/{ => controller}/pl.rs | 0 .../src/{ => controller}/tristar.rs | 0 charge-controller-supervisor/src/main.rs | 2 -- 4 files changed, 7 insertions(+), 6 deletions(-) rename charge-controller-supervisor/src/{ => controller}/pl.rs (100%) rename charge-controller-supervisor/src/{ => controller}/tristar.rs (100%) diff --git a/charge-controller-supervisor/src/controller.rs b/charge-controller-supervisor/src/controller.rs index c89da12..f24aeae 100644 --- a/charge-controller-supervisor/src/controller.rs +++ b/charge-controller-supervisor/src/controller.rs @@ -1,3 +1,6 @@ +mod pl; +mod tristar; + pub struct Controller { name: String, interval: std::time::Duration, @@ -28,13 +31,13 @@ impl Controller { )> { let inner = match config.variant { 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 { timeout_milliseconds, } => match &config.transport { 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: _ } => { return Err(eyre::eyre!("pl doesn't support tcp")) @@ -138,8 +141,8 @@ impl MultiTx { } pub enum ControllerInner { - Pl(crate::pl::Pli), - Tristar(crate::tristar::Tristar), + Pl(pl::Pli), + Tristar(tristar::Tristar), } impl ControllerInner { diff --git a/charge-controller-supervisor/src/pl.rs b/charge-controller-supervisor/src/controller/pl.rs similarity index 100% rename from charge-controller-supervisor/src/pl.rs rename to charge-controller-supervisor/src/controller/pl.rs diff --git a/charge-controller-supervisor/src/tristar.rs b/charge-controller-supervisor/src/controller/tristar.rs similarity index 100% rename from charge-controller-supervisor/src/tristar.rs rename to charge-controller-supervisor/src/controller/tristar.rs diff --git a/charge-controller-supervisor/src/main.rs b/charge-controller-supervisor/src/main.rs index fc0c4db..2748c57 100644 --- a/charge-controller-supervisor/src/main.rs +++ b/charge-controller-supervisor/src/main.rs @@ -25,8 +25,6 @@ enum Commands { mod controller; mod gauges; -mod pl; -mod tristar; mod web;