mirror of
https://github.com/ivabus/speakersafetyd
synced 2024-11-22 16:25:06 +03:00
blackbox: Store state for all blocks
This lets us validate the model from blackbox dumps. Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
7fbb53df51
commit
368be9d7df
1 changed files with 24 additions and 13 deletions
|
@ -84,14 +84,22 @@ impl Blackbox {
|
||||||
t_ambient: self.globals.t_ambient,
|
t_ambient: self.globals.t_ambient,
|
||||||
t_safe_max: self.globals.t_safe_max,
|
t_safe_max: self.globals.t_safe_max,
|
||||||
t_hysteresis: self.globals.t_hysteresis,
|
t_hysteresis: self.globals.t_hysteresis,
|
||||||
state: null
|
blocks: null
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut state = json::JsonValue::new_array();
|
let mut blocks = json::JsonValue::new_array();
|
||||||
|
|
||||||
|
for block in self.blocks.iter() {
|
||||||
|
let mut info = object! {
|
||||||
|
sample_rate: block.sample_rate,
|
||||||
|
sample_count: block.data.len() / self.globals.channels,
|
||||||
|
speakers: null,
|
||||||
|
};
|
||||||
|
let mut speakers = json::JsonValue::new_array();
|
||||||
|
|
||||||
for group in self.blocks[0].state.iter() {
|
for group in self.blocks[0].state.iter() {
|
||||||
for speaker in group.iter() {
|
for speaker in group.iter() {
|
||||||
let _ = state.push(object! {
|
let _ = speakers.push(object! {
|
||||||
t_coil: speaker.t_coil,
|
t_coil: speaker.t_coil,
|
||||||
t_magnet: speaker.t_magnet,
|
t_magnet: speaker.t_magnet,
|
||||||
t_coil_hyst: speaker.t_coil_hyst,
|
t_coil_hyst: speaker.t_coil_hyst,
|
||||||
|
@ -101,8 +109,11 @@ impl Blackbox {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
info["speakers"] = speakers;
|
||||||
|
let _ = blocks.push(info);
|
||||||
|
}
|
||||||
|
|
||||||
meta["state"] = state;
|
meta["blocks"] = blocks;
|
||||||
|
|
||||||
metafd.write_all(meta.dump().as_bytes())?;
|
metafd.write_all(meta.dump().as_bytes())?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue