ccs: actually follow primary! please be careful
This commit is contained in:
parent
296e1d0ccf
commit
46e23d1da1
3 changed files with 16 additions and 27 deletions
|
@ -72,13 +72,12 @@ impl Controller {
|
|||
let data = self.inner.refresh().await?;
|
||||
|
||||
if let Some(tx) = self.voltage_tx.as_mut() {
|
||||
if *crate::IS_PRINTING_TARGETS {
|
||||
log::error!(
|
||||
"tristar {}: primary: sending target voltage {}",
|
||||
self.name,
|
||||
data.target_voltage
|
||||
);
|
||||
}
|
||||
log::debug!(
|
||||
"tristar {}: primary: sending target voltage {}",
|
||||
self.name,
|
||||
data.target_voltage
|
||||
);
|
||||
|
||||
tx.send_to_all(VoltageCommand::Set(data.target_voltage));
|
||||
}
|
||||
|
||||
|
|
|
@ -65,9 +65,6 @@ async fn run() -> eyre::Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
static IS_PRINTING_TARGETS: std::sync::LazyLock<bool> =
|
||||
std::sync::LazyLock::new(|| std::env::var("SECONDARIES_PRINT_TARGET").is_ok());
|
||||
|
||||
async fn watch(args: Args) -> eyre::Result<()> {
|
||||
let config: config::Config = serde_json::from_reader(std::fs::File::open(args.config)?)?;
|
||||
if config
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use prometheus::core::{AtomicI64, GenericGauge};
|
||||
use tokio_modbus::client::Reader;
|
||||
use tokio_modbus::client::{Reader, Writer};
|
||||
|
||||
use crate::gauges::{
|
||||
BATTERY_TEMP, BATTERY_VOLTAGE, CHARGE_STATE, HEATSINK_TEMP, INPUT_CURRENT, TARGET_VOLTAGE,
|
||||
|
@ -328,15 +328,15 @@ 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??;
|
||||
if *crate::IS_PRINTING_TARGETS {
|
||||
log::error!(
|
||||
"tristar {} being set to voltage {target_voltage} (scaled: {scaled_voltage:#X?})",
|
||||
self.friendly_name
|
||||
);
|
||||
}
|
||||
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?})",
|
||||
self.friendly_name
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -352,13 +352,6 @@ impl Tristar {
|
|||
.modbus
|
||||
.read_holding_registers(0x0000, RAM_DATA_SIZE + 1)
|
||||
.await??;
|
||||
if *crate::IS_PRINTING_TARGETS {
|
||||
log::error!(
|
||||
"tristar {}: target voltage raw {:#X?}",
|
||||
self.friendly_name,
|
||||
data[TristarRamAddress::VbRef as usize]
|
||||
)
|
||||
}
|
||||
Ok(TristarState::from_ram(&data))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue