meas: finish porting to a concrete type.
this will in future let me more easily test each individual measurement type
This commit is contained in:
@@ -2,7 +2,7 @@ use crate::geom::Index;
|
||||
use crate::real::ToFloat as _;
|
||||
use crate::cross::vec::{Vec2, Vec3};
|
||||
use crate::sim::{AbstractSim, GenericSim, Sample};
|
||||
use crate::meas::{self, AbstractMeasurement};
|
||||
use crate::meas::{self, AbstractMeasurement, Measurement};
|
||||
use crossterm::{cursor, QueueableCommand as _};
|
||||
use crossterm::style::{style, Color, PrintStyledContent, Stylize as _};
|
||||
use font8x8::{BASIC_FONTS, GREEK_FONTS, UnicodeFonts as _};
|
||||
@@ -592,7 +592,7 @@ pub struct SerializedFrame<S> {
|
||||
pub state: S,
|
||||
/// although not generally necessary to load the sim, saving the measurements is beneficial for
|
||||
/// post-processing.
|
||||
pub measurements: Vec<meas::Evaluated>,
|
||||
pub measurements: Vec<Measurement>,
|
||||
}
|
||||
|
||||
impl<S: AbstractSim> SerializedFrame<S> {
|
||||
@@ -633,7 +633,7 @@ impl SerializerRenderer {
|
||||
}
|
||||
|
||||
impl SerializerRenderer {
|
||||
fn serialize<S: AbstractSim + Serialize>(&self, state: &S, measurements: Vec<meas::Evaluated>) {
|
||||
fn serialize<S: AbstractSim + Serialize>(&self, state: &S, measurements: Vec<Measurement>) {
|
||||
let frame = SerializedFrame {
|
||||
state,
|
||||
measurements,
|
||||
@@ -656,9 +656,9 @@ impl<S: AbstractSim + Serialize> Renderer<S> for SerializerRenderer {
|
||||
}
|
||||
fn render(&self, state: &S, measurements: &[&dyn AbstractMeasurement<S>], _config: RenderConfig) {
|
||||
if self.prefer_generic {
|
||||
self.serialize(&state.to_generic(), meas::eval_to_vec(state, measurements));
|
||||
self.serialize(&state.to_generic(), meas::eval_multiple_kv(state, measurements));
|
||||
} else {
|
||||
self.serialize(state, meas::eval_to_vec(state, measurements));
|
||||
self.serialize(state, meas::eval_multiple_kv(state, measurements));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -732,13 +732,13 @@ impl<S: AbstractSim> Renderer<S> for CsvRenderer {
|
||||
file.set_len(0).unwrap();
|
||||
let mut writer = csv::Writer::from_writer(BufWriter::new(file));
|
||||
// write the header
|
||||
writer.write_record(row.keys()).unwrap();
|
||||
writer.write_record(row.iter().map(|m| m.name())).unwrap();
|
||||
writer
|
||||
}
|
||||
},
|
||||
CsvState::Writing(writer) => writer,
|
||||
};
|
||||
writer.write_record(row.values()).unwrap();
|
||||
writer.write_record(row.iter().map(|m| m.str_value())).unwrap();
|
||||
writer.flush().unwrap();
|
||||
*lock = Some(CsvState::Writing(writer));
|
||||
}
|
||||
|
Reference in New Issue
Block a user