Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions diagnostic_updater/diagnostic_updater/_update_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ def run(self, stat):
stat.summary(DiagnosticStatus.ERROR,
'Timestamps too far in past seen.')
self.late_count += 1
if self.zero_seen:
stat.summary(DiagnosticStatus.ERROR,
'Zero timestamp seen.')
self.zero_count += 1
if self.zero_seen:
stat.summary(DiagnosticStatus.ERROR,
'Zero timestamp seen.')
self.zero_count += 1

stat.add('Earliest timestamp delay:', '%f' % self.min_delta)
stat.add('Latest timestamp delay:', '%f' % self.max_delta)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,11 @@ class TimeStampStatus : public DiagnosticTask
stat.summary(2, "Timestamps too far in past seen.");
late_count_++;
}
}

if (zero_seen_) {
stat.summary(2, "Zero timestamp seen.");
zero_count_++;
}
if (zero_seen_) {
stat.summary(2, "Zero timestamp seen.");
zero_count_++;
}

stat.addf("Earliest timestamp delay:", "%f", min_delta_);
Expand Down
15 changes: 15 additions & 0 deletions diagnostic_updater/test/diagnostic_updater_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,18 @@ TEST(DiagnosticUpdater, testTimeStampStatus) {
EXPECT_STREQ("Timestamp Status", ts.getName().c_str()) <<
"Name should be \"Timestamp Status\"";
}

TEST(DiagnosticUpdater, testTimeStampStatusZeroOnly) {
diagnostic_updater::TimeStampStatus ts(
diagnostic_updater::DefaultTimeStampStatusParam);

diagnostic_updater::DiagnosticStatusWrapper stat[2];
ts.tick(0.0);
ts.run(stat[0]);
ts.run(stat[1]);

EXPECT_EQ(2, stat[0].level) << "zero timestamps alone should be reported as an error";
EXPECT_STREQ("Zero timestamp seen.", stat[0].message.c_str()) <<
"zero timestamps alone should not be reported as no data";
EXPECT_EQ(1, stat[1].level) << "no data after zero timestamps should return a warning";
}
14 changes: 14 additions & 0 deletions diagnostic_updater/test/diagnostic_updater_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,20 @@ def testTimeStampStatus(self):
self.assertEqual('Timestamp Status', ts.getName(),
'Name should be Timestamp Status')

def testTimeStampStatusZeroOnly(self):
ts = TimeStampStatus()

ts.tick(0.0)
stat = ts.run(DiagnosticStatusWrapper())
self.assertEqual(DiagnosticStatus.ERROR, stat.level,
'zero timestamps alone should be reported as an error')
self.assertEqual('Zero timestamp seen.', stat.message,
'zero timestamps alone should not be reported as no data')

stat = ts.run(DiagnosticStatusWrapper())
self.assertEqual(DiagnosticStatus.WARN, stat.level,
'no data after zero timestamps should return a warning')


@pytest.mark.launch_test
def generate_test_description():
Expand Down