ccs: tristar: remove useless Option around scaling
This commit is contained in:
parent
9d8b4b23b1
commit
20a7ad6ddd
1 changed files with 5 additions and 4 deletions
|
@ -55,9 +55,9 @@ pub struct Tristar {
|
||||||
scaling: Option<Scaling>,
|
scaling: Option<Scaling>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct TristarState {
|
pub struct TristarState {
|
||||||
scaling: Option<Scaling>,
|
scaling: Scaling,
|
||||||
battery_voltage: f64,
|
battery_voltage: f64,
|
||||||
target_voltage: f64,
|
target_voltage: f64,
|
||||||
input_current: f64,
|
input_current: f64,
|
||||||
|
@ -86,7 +86,7 @@ impl TristarState {
|
||||||
fn from_ram(ram: &[u16]) -> Self {
|
fn from_ram(ram: &[u16]) -> Self {
|
||||||
let scaling = Scaling::from(ram);
|
let scaling = Scaling::from(ram);
|
||||||
Self {
|
Self {
|
||||||
scaling: Some(scaling),
|
scaling,
|
||||||
battery_voltage: scaling.get_voltage(ram[TristarRamAddress::AdcVbFMed]),
|
battery_voltage: scaling.get_voltage(ram[TristarRamAddress::AdcVbFMed]),
|
||||||
target_voltage: scaling.get_voltage(ram[TristarRamAddress::VbRef]),
|
target_voltage: scaling.get_voltage(ram[TristarRamAddress::VbRef]),
|
||||||
input_current: scaling.get_current(ram[TristarRamAddress::AdcIaFShadow]),
|
input_current: scaling.get_current(ram[TristarRamAddress::AdcIaFShadow]),
|
||||||
|
@ -266,6 +266,7 @@ impl Tristar {
|
||||||
let modbus_serial = tokio_serial::SerialStream::open(
|
let modbus_serial = tokio_serial::SerialStream::open(
|
||||||
&tokio_serial::new(port, *baud_rate).timeout(std::time::Duration::from_secs(3)),
|
&tokio_serial::new(port, *baud_rate).timeout(std::time::Duration::from_secs(3)),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
tokio_modbus::client::rtu::attach_slave(modbus_serial, slave)
|
tokio_modbus::client::rtu::attach_slave(modbus_serial, slave)
|
||||||
}
|
}
|
||||||
crate::config::Transport::Tcp { ip, port } => {
|
crate::config::Transport::Tcp { ip, port } => {
|
||||||
|
@ -287,7 +288,7 @@ impl Tristar {
|
||||||
pub async fn refresh(&mut self) -> eyre::Result<crate::controller::CommonData> {
|
pub async fn refresh(&mut self) -> eyre::Result<crate::controller::CommonData> {
|
||||||
let new_state = self.get_data().await?;
|
let new_state = self.get_data().await?;
|
||||||
|
|
||||||
self.scaling = new_state.scaling;
|
self.scaling = Some(new_state.scaling);
|
||||||
self.consecutive_errors = 0;
|
self.consecutive_errors = 0;
|
||||||
BATTERY_VOLTAGE
|
BATTERY_VOLTAGE
|
||||||
.with_label_values(&[&self.friendly_name])
|
.with_label_values(&[&self.friendly_name])
|
||||||
|
|
Loading…
Add table
Reference in a new issue