Suppress Watchdog's generic timeout message in MotorSafety (#1486)

This commit is contained in:
Tyler Veness
2018-12-14 10:53:33 -08:00
committed by Peter Johnson
parent 0c3b488e18
commit 41596608cc
5 changed files with 45 additions and 5 deletions

View File

@@ -19,12 +19,14 @@ using namespace frc;
MotorSafety::MotorSafety(MotorSafety&& rhs)
: ErrorBase(std::move(rhs)), m_enabled(std::move(rhs.m_enabled)) {
m_watchdog = Watchdog(rhs.m_watchdog.GetTimeout(), [this] { TimeoutFunc(); });
m_watchdog.SuppressTimeoutMessage(true);
}
MotorSafety& MotorSafety::operator=(MotorSafety&& rhs) {
ErrorBase::operator=(std::move(rhs));
m_watchdog = Watchdog(rhs.m_watchdog.GetTimeout(), [this] { TimeoutFunc(); });
m_watchdog.SuppressTimeoutMessage(true);
m_enabled = std::move(rhs.m_enabled);
return *this;

View File

@@ -51,10 +51,12 @@ void Watchdog::Thread::Main() {
auto now = hal::fpga_clock::now();
if (now - watchdog->m_lastTimeoutPrintTime > kMinPrintPeriod) {
watchdog->m_lastTimeoutPrintTime = now;
wpi::outs() << "Watchdog not fed within "
<< wpi::format("%.6f",
watchdog->m_timeout.count() / 1.0e6)
<< "s\n";
if (!watchdog->m_suppressTimeoutMessage) {
wpi::outs() << "Watchdog not fed within "
<< wpi::format("%.6f",
watchdog->m_timeout.count() / 1.0e6)
<< "s\n";
}
}
lock.unlock();
watchdog->m_callback();
@@ -159,6 +161,10 @@ void Watchdog::Disable() {
thr->m_cond.notify_all();
}
void Watchdog::SuppressTimeoutMessage(bool suppress) {
m_suppressTimeoutMessage = suppress;
}
bool Watchdog::operator>(const Watchdog& rhs) {
return m_expirationTime > rhs.m_expirationTime;
}