Compare commits
5 commits
v1.9.9-pre
...
main
Author | SHA1 | Date | |
---|---|---|---|
7ffdfd1fc3 | |||
9d12bce452 | |||
b549ceebab | |||
b28026820c | |||
ab3cd28f83 |
14 changed files with 47 additions and 32 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -239,7 +239,7 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
|||
|
||||
[[package]]
|
||||
name = "charge-controller-supervisor"
|
||||
version = "1.9.9-pre-29"
|
||||
version = "1.9.9-pre-30"
|
||||
dependencies = [
|
||||
"bitflags 2.7.0",
|
||||
"chrono",
|
||||
|
@ -2205,7 +2205,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tesla-charge-controller"
|
||||
version = "1.9.9-pre-29"
|
||||
version = "1.9.9-pre-30"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"clap",
|
||||
|
|
|
@ -4,7 +4,7 @@ default-members = ["charge-controller-supervisor"]
|
|||
resolver = "2"
|
||||
|
||||
[workspace.package]
|
||||
version = "1.9.9-pre-29"
|
||||
version = "1.9.9-pre-30"
|
||||
|
||||
[workspace.lints.clippy]
|
||||
pedantic = "warn"
|
||||
|
|
|
@ -101,19 +101,19 @@ impl Controller {
|
|||
let data = self.inner.refresh().await?;
|
||||
|
||||
if let Some(tx) = self.voltage_tx.as_mut() {
|
||||
// if crate::config::access_config()
|
||||
// .await
|
||||
// .enable_secondary_control
|
||||
// {
|
||||
let target = data.common().target_voltage;
|
||||
log::debug!(
|
||||
"tristar {}: primary: sending target voltage {}",
|
||||
self.name,
|
||||
target
|
||||
);
|
||||
if crate::config::access_config()
|
||||
.await
|
||||
.enable_secondary_control
|
||||
{
|
||||
let target = data.common().target_voltage;
|
||||
log::debug!(
|
||||
"tristar {}: primary: sending target voltage {}",
|
||||
self.name,
|
||||
target
|
||||
);
|
||||
|
||||
tx.send(VoltageCommand::Set(target))?;
|
||||
// }
|
||||
tx.send(VoltageCommand::Set(target))?;
|
||||
}
|
||||
}
|
||||
|
||||
*self.data.write_state().await = Some(data);
|
||||
|
@ -137,7 +137,7 @@ impl Controller {
|
|||
}
|
||||
|
||||
pub fn name(&self) -> &str {
|
||||
&self.name
|
||||
self.name.as_str()
|
||||
}
|
||||
|
||||
pub fn set_tx_to_secondary(&mut self, tx: tokio::sync::watch::Sender<VoltageCommand>) {
|
||||
|
|
|
@ -840,9 +840,9 @@ impl Tristar {
|
|||
|
||||
pub async fn set_target_voltage(&mut self, target_voltage: f64) -> eyre::Result<()> {
|
||||
let scaled_voltage: u16 = self.scale_voltage(target_voltage);
|
||||
// self.modbus
|
||||
// .write_single_register(TristarRamAddress::VbRefSlave as u16, scaled_voltage)
|
||||
// .await??;
|
||||
self.modbus
|
||||
.write_single_register(TristarRamAddress::VbRefSlave as u16, scaled_voltage)
|
||||
.await??;
|
||||
|
||||
log::debug!(
|
||||
"tristar {} being set to voltage {target_voltage} (scaled: {scaled_voltage:#X?})",
|
||||
|
|
|
@ -150,6 +150,7 @@ async fn watch(args: Args) -> eyre::Result<()> {
|
|||
follow_voltage_tx,
|
||||
));
|
||||
let server_task = tokio::task::spawn(server.launch());
|
||||
log::warn!("...started!");
|
||||
|
||||
tokio::select! {
|
||||
v = controller_tasks.next() => {
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
[toolchain]
|
||||
channel = "nightly"
|
||||
channel = "nightly-2025-01-16"
|
||||
targets = ["aarch64-unknown-linux-musl"]
|
||||
|
|
|
@ -95,6 +95,7 @@ impl Vehicle {
|
|||
Ok(state.charge_state)
|
||||
}
|
||||
|
||||
#[expect(dead_code, reason = "active charge control not yet implemented")]
|
||||
pub async fn set_charging_amps(&self, charging_amps: i64) -> eyre::Result<()> {
|
||||
self.client
|
||||
.post(format!(
|
||||
|
|
|
@ -42,11 +42,11 @@ impl Car {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn vehicle(&self) -> &http::Vehicle {
|
||||
pub const fn vehicle(&self) -> &http::Vehicle {
|
||||
&self.vehicle
|
||||
}
|
||||
|
||||
pub fn state(&self) -> &tokio::sync::RwLock<CarState> {
|
||||
pub const fn state(&self) -> &tokio::sync::RwLock<CarState> {
|
||||
&self.state
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ impl ChargeState {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum ChargingState {
|
||||
Charging,
|
||||
Stopped,
|
||||
|
|
|
@ -60,7 +60,7 @@ impl ConfigWatcher {
|
|||
async fn overwrite_config(config: Config) -> eyre::Result<()> {
|
||||
*CONFIG
|
||||
.get()
|
||||
.ok_or(eyre::eyre!("could not get config"))?
|
||||
.ok_or_else(|| eyre::eyre!("could not get config"))?
|
||||
.write()
|
||||
.await = config;
|
||||
Ok(())
|
||||
|
|
|
@ -4,6 +4,7 @@ pub struct VehicleController {
|
|||
control_state: ChargeRateControllerState,
|
||||
}
|
||||
|
||||
#[expect(dead_code, reason = "not all states are currently in use")]
|
||||
pub enum ChargeRateControllerState {
|
||||
Inactive,
|
||||
Charging { rate_amps: i64 },
|
||||
|
@ -14,7 +15,7 @@ pub enum InterfaceRequest {
|
|||
}
|
||||
|
||||
impl VehicleController {
|
||||
pub fn new(
|
||||
pub const fn new(
|
||||
car: std::sync::Arc<crate::api::Car>,
|
||||
requests: tokio::sync::mpsc::UnboundedReceiver<InterfaceRequest>,
|
||||
) -> Self {
|
||||
|
@ -50,7 +51,10 @@ impl VehicleController {
|
|||
}
|
||||
match self.control_state {
|
||||
ChargeRateControllerState::Inactive => {
|
||||
if let Some(state) = self.car.state().read().await.charge_state().await {
|
||||
let car_state = self.car.state().read().await;
|
||||
let state = car_state.charge_state().await;
|
||||
|
||||
if let Some(state) = state {
|
||||
if state.is_charging() {
|
||||
self.control_state = ChargeRateControllerState::Charging {
|
||||
rate_amps: state.charge_amps,
|
||||
|
@ -58,10 +62,14 @@ impl VehicleController {
|
|||
}
|
||||
}
|
||||
}
|
||||
ChargeRateControllerState::Charging { rate_amps } => todo!(),
|
||||
ChargeRateControllerState::Charging { rate_amps: _ } => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(
|
||||
clippy::needless_pass_by_ref_mut,
|
||||
reason = "this will eventually need to mutate self"
|
||||
)]
|
||||
pub async fn process_requests(&mut self, req: InterfaceRequest) {
|
||||
if let Err(e) = match req {
|
||||
InterfaceRequest::FlashLights => self.car.vehicle().flash_lights().await,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(clippy::significant_drop_tightening)]
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use clap::Parser;
|
||||
|
|
|
@ -27,7 +27,7 @@ pub struct ServerState {
|
|||
}
|
||||
|
||||
impl ServerState {
|
||||
pub fn new(car: Arc<Car>, api_requests: UnboundedSender<InterfaceRequest>) -> Self {
|
||||
pub const fn new(car: Arc<Car>, api_requests: UnboundedSender<InterfaceRequest>) -> Self {
|
||||
Self { car, api_requests }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,10 +52,12 @@ impl Handler for UiStatic {
|
|||
data: v.contents().to_vec(),
|
||||
name: p,
|
||||
})
|
||||
.or(UI_DIR_FILES.get_file(&plus_index).map(|v| RawHtml {
|
||||
data: v.contents().to_vec(),
|
||||
name: plus_index,
|
||||
}));
|
||||
.or_else(|| {
|
||||
UI_DIR_FILES.get_file(&plus_index).map(|v| RawHtml {
|
||||
data: v.contents().to_vec(),
|
||||
name: plus_index,
|
||||
})
|
||||
});
|
||||
file.respond_to(req).or_forward((data, Status::NotFound))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue