Estimate the distributed clock with boots accounted for
Route the current boot through both the noncausal filter, and the
timestamp solver code. This gets us 1 step closer to exposing boots
to the user.
This stops before changing log_reader though. We still CHECK on the way
into the SimulatedEventLoopFactory that actually runs reading. This
felt like a reasonable intermediate point.
Change-Id: I85d0735c449a2aacf8cc457bdbcdbd667f1809ef
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/network/testing_time_converter.cc b/aos/network/testing_time_converter.cc
index 0dd0cb3..9558033 100644
--- a/aos/network/testing_time_converter.cc
+++ b/aos/network/testing_time_converter.cc
@@ -16,7 +16,7 @@
TestingTimeConverter ::TestingTimeConverter(size_t node_count)
: InterpolatedTimeConverter(node_count),
- last_monotonic_(node_count, monotonic_clock::epoch()) {
+ last_monotonic_(node_count, logger::BootTimestamp::epoch()) {
CHECK_GE(node_count, 1u);
}
@@ -37,7 +37,7 @@
CHECK_EQ(times.size(), last_monotonic_.size());
for (size_t i = 0; i < times.size(); ++i) {
CHECK_GT(times[i].count(), 0);
- last_monotonic_[i] += times[i];
+ last_monotonic_[i].time += times[i];
}
chrono::nanoseconds dt(0);
if (!first_) {
@@ -51,14 +51,15 @@
}
chrono::nanoseconds TestingTimeConverter::AddMonotonic(
- std::vector<monotonic_clock::time_point> times) {
+ std::vector<logger::BootTimestamp> times) {
CHECK_EQ(times.size(), last_monotonic_.size());
chrono::nanoseconds dt(0);
if (!first_) {
- dt = times[0] - last_monotonic_[0];
+ CHECK_EQ(times[0].boot, last_monotonic_[0].boot);
+ dt = times[0].time - last_monotonic_[0].time;
for (size_t i = 0; i < times.size(); ++i) {
CHECK_GT(times[i], last_monotonic_[i]);
- dt = std::max(dt, times[i] - times[0]);
+ dt = std::max(dt, times[i].time - times[0].time);
}
last_distributed_ += dt;
last_monotonic_ = times;
@@ -72,7 +73,7 @@
void TestingTimeConverter::AddNextTimestamp(
distributed_clock::time_point time,
- std::vector<monotonic_clock::time_point> times) {
+ std::vector<logger::BootTimestamp> times) {
CHECK_EQ(times.size(), last_monotonic_.size());
if (!first_) {
CHECK_GT(time, last_distributed_);
@@ -89,7 +90,7 @@
}
std::optional<std::tuple<distributed_clock::time_point,
- std::vector<monotonic_clock::time_point>>>
+ std::vector<logger::BootTimestamp>>>
TestingTimeConverter::NextTimestamp() {
CHECK(!first_) << ": Tried to pull a timestamp before one was added. This "
"is unlikely to be what you want.";