Skip to content

Commit 06d97ec

Browse files
davidv1992rnijveld
authored andcommitted
Split algorithm traits and measurement struct into internal and
external. This will enable us to more easily change the external ones.
1 parent 6362e0e commit 06d97ec

File tree

3 files changed

+248
-64
lines changed

3 files changed

+248
-64
lines changed

ntp-proto/src/algorithm/kalman/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{
1515

1616
use self::{combiner::combine, config::AlgorithmConfig, source::KalmanState};
1717

18-
use super::{ObservableSourceTimedata, StateUpdate, TimeSyncController};
18+
use super::{InternalTimeSyncController, ObservableSourceTimedata, StateUpdate};
1919

2020
mod combiner;
2121
pub(super) mod config;
@@ -365,7 +365,7 @@ impl<C: NtpClock> KalmanClockController<C> {
365365
}
366366
}
367367

368-
impl<C: NtpClock> TimeSyncController for KalmanClockController<C> {
368+
impl<C: NtpClock> InternalTimeSyncController for KalmanClockController<C> {
369369
type Clock = C;
370370
type AlgorithmConfig = AlgorithmConfig;
371371
type ControllerMessage = KalmanControllerMessage;
@@ -467,8 +467,7 @@ mod tests {
467467

468468
use matrix::{Matrix, Vector};
469469

470-
use crate::SourceController;
471-
use crate::algorithm::Measurement;
470+
use crate::algorithm::{InternalMeasurement, InternalSourceController};
472471
use crate::config::StepThreshold;
473472

474473
use super::*;
@@ -549,7 +548,7 @@ mod tests {
549548
algo.clock.current_time += NtpDuration::from_seconds(1.0);
550549
noise += 1e-9;
551550

552-
let message = source.handle_measurement(Measurement {
551+
let message = source.handle_measurement(InternalMeasurement {
553552
delay: NtpDuration::from_seconds(0.001 + noise),
554553
offset: NtpDuration::from_seconds(1700.0 + noise),
555554
localtime: algo.clock.current_time,
@@ -797,7 +796,7 @@ mod tests {
797796
algo.clock.current_time += NtpDuration::from_seconds(1800.0);
798797
noise += 1e-9;
799798

800-
let message = source.handle_measurement(Measurement {
799+
let message = source.handle_measurement(InternalMeasurement {
801800
delay: NtpDuration::from_seconds(0.001 + noise),
802801
offset: NtpDuration::from_seconds(1700.0 + noise),
803802
localtime: algo.clock.current_time,
@@ -852,7 +851,7 @@ mod tests {
852851
algo.clock.current_time += NtpDuration::from_seconds(1.0);
853852
noise *= -1.0;
854853

855-
let message = source.handle_measurement(Measurement {
854+
let message = source.handle_measurement(InternalMeasurement {
856855
delay: NtpDuration::from_seconds(0.001 + noise),
857856
offset: NtpDuration::from_seconds(-3600.0 + noise),
858857
localtime: algo.clock.current_time,

0 commit comments

Comments
 (0)