ccs: clippy
This commit is contained in:
parent
51aec2ce00
commit
a1a80276c9
2 changed files with 10 additions and 10 deletions
|
@ -98,14 +98,13 @@ impl Controller {
|
||||||
&mut self,
|
&mut self,
|
||||||
tx: Vec<tokio::sync::mpsc::UnboundedSender<VoltageCommand>>,
|
tx: Vec<tokio::sync::mpsc::UnboundedSender<VoltageCommand>>,
|
||||||
) {
|
) {
|
||||||
if self.voltage_rx.is_some() {
|
assert!(
|
||||||
panic!(
|
self.voltage_rx.is_none(),
|
||||||
"trying to set {} as primary when it is also a secondary!",
|
"trying to set {} as primary when it is also a secondary!",
|
||||||
self.name
|
self.name
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
self.voltage_tx = Some(MultiTx(tx))
|
self.voltage_tx = Some(MultiTx(tx));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_rx(&mut self) -> Option<&mut tokio::sync::mpsc::UnboundedReceiver<VoltageCommand>> {
|
pub fn get_rx(&mut self) -> Option<&mut tokio::sync::mpsc::UnboundedReceiver<VoltageCommand>> {
|
||||||
|
@ -125,7 +124,7 @@ struct MultiTx(Vec<tokio::sync::mpsc::UnboundedSender<VoltageCommand>>);
|
||||||
|
|
||||||
impl MultiTx {
|
impl MultiTx {
|
||||||
fn send_to_all(&mut self, command: VoltageCommand) {
|
fn send_to_all(&mut self, command: VoltageCommand) {
|
||||||
for sender in self.0.iter_mut() {
|
for sender in &mut self.0 {
|
||||||
if let Err(e) = sender.send(command) {
|
if let Err(e) = sender.send(command) {
|
||||||
log::error!("failed to send command {command:?}: {e:?}");
|
log::error!("failed to send command {command:?}: {e:?}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,8 @@ impl Scaling {
|
||||||
f64::from(data) * self.v_scale * self.i_scale * f64::powf(2., -17.)
|
f64::from(data) * self.v_scale * self.i_scale * f64::powf(2., -17.)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_voltage(&self, voltage: f64) -> u16 {
|
#[expect(clippy::cast_sign_loss)]
|
||||||
|
fn inverse_voltage(&self, voltage: f64) -> u16 {
|
||||||
(voltage / (self.v_scale * f64::powf(2., -15.))) as u16
|
(voltage / (self.v_scale * f64::powf(2., -15.))) as u16
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -344,7 +345,7 @@ impl Tristar {
|
||||||
let Some(scaling) = &self.scaling else {
|
let Some(scaling) = &self.scaling else {
|
||||||
return Err(eyre::eyre!("no scaling data present"));
|
return Err(eyre::eyre!("no scaling data present"));
|
||||||
};
|
};
|
||||||
Ok(scaling.from_voltage(voltage))
|
Ok(scaling.inverse_voltage(voltage))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_data(&mut self) -> eyre::Result<TristarState> {
|
async fn get_data(&mut self) -> eyre::Result<TristarState> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue