Skip to content

Commit 7060850

Browse files
committed
verify chronological order
Signed-off-by: Guillaume W. Bres <[email protected]>
1 parent 87a164e commit 7060850

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

cggtts/src/track/scheduler.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ impl SVTracker {
8585

8686
// verify tracking completion
8787
// complete if we're centered on midpoint
88-
let (first, _) = self.buffer.first_key_value().unwrap(); // infaillible at this point
89-
let (last, _) = self.buffer.last_key_value().unwrap(); // infaillible at this point
88+
let (first, _) = self.buffer.first_key_value().unwrap();
89+
90+
let (last, _) = self.buffer.last_key_value().unwrap();
91+
9092
if !((*first < trk_midpoint) && (*last > trk_midpoint)) {
9193
return Err(FitError::NotCenteredOnTrackMidpoint);
9294
}
@@ -265,6 +267,12 @@ impl SVTracker {
265267
/// Latch a new measurement at given UTC Epoch.
266268
/// You can then use .fit() to try to fit a track.
267269
pub fn latch_measurement(&mut self, utc_t: Epoch, data: FitData) {
270+
if let Some((last_t, _)) = self.buffer.last_key_value() {
271+
assert!(
272+
utc_t > *last_t,
273+
"samples should be streamed in chronological order"
274+
);
275+
}
268276
self.buffer.insert(utc_t, data);
269277
}
270278

0 commit comments

Comments
 (0)