Skip to content

Commit

Permalink
thermostat-eem stream format [wip]
Browse files Browse the repository at this point in the history
  • Loading branch information
jordens committed Feb 12, 2024
1 parent d9f51f6 commit 9018698
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/de/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,35 @@ impl Payload for Fls {
fn traces(&self) -> &[Vec<f32>] {
&self.traces
}

fn traces_mut(&mut self) -> &mut [Vec<f32>] {
&mut self.traces
}
}

pub struct ThermostatEem {
traces: Vec<Vec<f32>>,
}

impl Payload for ThermostatEem {
fn new(batches: usize, data: &[u8]) -> Result<Self, FormatError> {
let data: &[[f32; 16 + 4]] = bytemuck::cast_slice(data);
assert_eq!(batches, data.len());
let traces = [0, 8, 13, 16]
.into_iter()
.map(|i| data.iter().map(|b| b[i]).collect())
.collect();
Ok(Self { traces })
}

fn labels(&self) -> &[&str] {
&["T00", "T20", "I0", "I1"]
}

fn traces(&self) -> &[Vec<f32>] {
&self.traces
}

fn traces_mut(&mut self) -> &mut [Vec<f32>] {
&mut self.traces
}
Expand Down
1 change: 1 addition & 0 deletions src/de/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl Frame {
let data: Box<dyn Payload + Send> = match header.format {
Format::AdcDac => Box::new(data::AdcDac::new(header.batches as _, data)?),
Format::Fls => Box::new(data::Fls::new(header.batches as _, data)?),
Format::ThermostatEem => Box::new(data::ThermostatEem::new(header.batches as _, data)?),
};
Ok(Self { header, data })
}
Expand Down
1 change: 1 addition & 0 deletions src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub use frame::*;
pub enum Format {
AdcDac = 1,
Fls = 2,
ThermostatEem = 3,
}

#[derive(Debug, Clone, Error)]
Expand Down

0 comments on commit 9018698

Please sign in to comment.