build: move the int/stream type mapping into a simdata module shared by the build script
This commit is contained in:
@@ -11,7 +11,7 @@ use nalgebra::{Vector2, Vector3};
|
||||
use log::*;
|
||||
use rmp::decode::{DecodeStringError, RmpRead, RmpReadErr, ValueReadError};
|
||||
|
||||
use crate::events::{Measurement, SensorSource, SensorState};
|
||||
use crate::{events::{Measurement, SensorSource, SensorState}, simdata::StreamType};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SharedFlash<S> {
|
||||
@@ -102,8 +102,8 @@ impl<S: ReadStorage + Clone + core::fmt::Debug> Iterator for SimDataTable<S> whe
|
||||
self.index += 1;
|
||||
debug!("Found type={this_type:?}");
|
||||
match this_type.typeid.try_into() {
|
||||
Err(()) => error!("Found unknown simulation data chunk {this_type:?}"),
|
||||
Ok(srcid) => return Some(SimDataReader::open(sensor_reader, srcid))
|
||||
Err(_) => error!("Found unknown simulation data chunk {this_type:?}"),
|
||||
Ok(stream_type) => return Some(SimDataReader::open(sensor_reader, stream_type))
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
@@ -205,13 +205,13 @@ impl<S: ReadStorage> From<DecodeStringError<'_, RangeReadError<S::Error>>> for S
|
||||
}
|
||||
|
||||
impl<S: ReadStorage> SimDataReader<S> where S::Error: core::fmt::Debug + 'static {
|
||||
pub fn open(mut reader: RangeReader<S>, srcid: SensorSource) -> Self {
|
||||
debug!("Opening {srcid:?} sim data chunk");
|
||||
pub fn open(mut reader: RangeReader<S>, stream_type: StreamType) -> Self {
|
||||
debug!("Opening {stream_type:?} sim data chunk");
|
||||
let event_count = rmp::decode::read_array_len(&mut reader).unwrap() as usize;
|
||||
debug!("Found {event_count} events!");
|
||||
Self {
|
||||
reader,
|
||||
srcid,
|
||||
srcid: stream_type.into(),
|
||||
runtime: Default::default(),
|
||||
event_count,
|
||||
index: 0
|
||||
|
||||
Reference in New Issue
Block a user