From 7c35355d29746cf5beb51f67adf7fb355312c845 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 29 Dec 2018 16:19:04 -0800 Subject: [PATCH] Revert "Suppress Watchdog's generic timeout message in MotorSafety (#1486)" This reverts commit 41596608cc06b60690f02a633aa87e62ed6b3c42. --- wpilibc/src/main/native/cpp/MotorSafety.cpp | 2 -- wpilibc/src/main/native/cpp/Watchdog.cpp | 14 ++++---------- wpilibc/src/main/native/include/frc/Watchdog.h | 12 ------------ .../edu/wpi/first/wpilibj/MotorSafety.java | 4 ---- .../java/edu/wpi/first/wpilibj/Watchdog.java | 18 +----------------- 5 files changed, 5 insertions(+), 45 deletions(-) diff --git a/wpilibc/src/main/native/cpp/MotorSafety.cpp b/wpilibc/src/main/native/cpp/MotorSafety.cpp index f9488ddc70..56c846fcd4 100644 --- a/wpilibc/src/main/native/cpp/MotorSafety.cpp +++ b/wpilibc/src/main/native/cpp/MotorSafety.cpp @@ -19,14 +19,12 @@ 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; diff --git a/wpilibc/src/main/native/cpp/Watchdog.cpp b/wpilibc/src/main/native/cpp/Watchdog.cpp index af83617e46..f63b3fd61c 100644 --- a/wpilibc/src/main/native/cpp/Watchdog.cpp +++ b/wpilibc/src/main/native/cpp/Watchdog.cpp @@ -51,12 +51,10 @@ void Watchdog::Thread::Main() { auto now = hal::fpga_clock::now(); if (now - watchdog->m_lastTimeoutPrintTime > kMinPrintPeriod) { watchdog->m_lastTimeoutPrintTime = now; - if (!watchdog->m_suppressTimeoutMessage) { - wpi::outs() << "Watchdog not fed within " - << wpi::format("%.6f", - watchdog->m_timeout.count() / 1.0e6) - << "s\n"; - } + wpi::outs() << "Watchdog not fed within " + << wpi::format("%.6f", + watchdog->m_timeout.count() / 1.0e6) + << "s\n"; } lock.unlock(); watchdog->m_callback(); @@ -161,10 +159,6 @@ 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; } diff --git a/wpilibc/src/main/native/include/frc/Watchdog.h b/wpilibc/src/main/native/include/frc/Watchdog.h index e15da1fe42..2439c843a1 100644 --- a/wpilibc/src/main/native/include/frc/Watchdog.h +++ b/wpilibc/src/main/native/include/frc/Watchdog.h @@ -104,16 +104,6 @@ class Watchdog { */ void Disable(); - /** - * Enable or disable suppression of the generic timeout message. - * - * This may be desirable if the user-provided callback already prints a more - * specific message. - * - * @param suppress Whether to suppress generic timeout message. - */ - void SuppressTimeoutMessage(bool suppress); - private: // Used for timeout print rate-limiting static constexpr std::chrono::milliseconds kMinPrintPeriod{1000}; @@ -128,8 +118,6 @@ class Watchdog { wpi::StringMap m_epochs; bool m_isExpired = false; - bool m_suppressTimeoutMessage = false; - class Thread; wpi::SafeThreadOwner* m_owner; diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/MotorSafety.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/MotorSafety.java index 04949c2e33..be455e6bb1 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/MotorSafety.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/MotorSafety.java @@ -20,10 +20,6 @@ public abstract class MotorSafety { private boolean m_enabled; private final Object m_thisMutex = new Object(); - public MotorSafety() { - m_watchdog.suppressTimeoutMessage(true); - } - /** * Feed the motor safety object. * diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Watchdog.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Watchdog.java index 1a6af68511..1af081470e 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Watchdog.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Watchdog.java @@ -23,7 +23,6 @@ import java.util.concurrent.locks.ReentrantLock; * *

The watchdog is initialized disabled, so the user needs to call enable() before use. */ -@SuppressWarnings("PMD.TooManyMethods") public class Watchdog implements Closeable, Comparable { // Used for timeout print rate-limiting private static final long kMinPrintPeriod = 1000000; // us @@ -39,8 +38,6 @@ public class Watchdog implements Closeable, Comparable { private final Map m_epochs = new HashMap<>(); boolean m_isExpired; - boolean m_suppressTimeoutMessage; - static { startDaemonThread(() -> schedulerFunc()); } @@ -204,17 +201,6 @@ public class Watchdog implements Closeable, Comparable { } } - /** - * Enable or disable suppression of the generic timeout message. - * - *

This may be desirable if the user-provided callback already prints a more specific message. - * - * @param suppress Whether to suppress generic timeout message. - */ - public void suppressTimeoutMessage(boolean suppress) { - m_suppressTimeoutMessage = suppress; - } - private static Thread startDaemonThread(Runnable target) { Thread inst = new Thread(target); inst.setDaemon(true); @@ -243,9 +229,7 @@ public class Watchdog implements Closeable, Comparable { long now = RobotController.getFPGATime(); if (now - watchdog.m_lastTimeoutPrintTime > kMinPrintPeriod) { watchdog.m_lastTimeoutPrintTime = now; - if (!watchdog.m_suppressTimeoutMessage) { - System.out.format("Watchdog not fed within %.6fs\n", watchdog.m_timeout / 1.0e6); - } + System.out.format("Watchdog not fed within %.6fs\n", watchdog.m_timeout / 1.0e6); } m_queueMutex.unlock(); watchdog.m_callback.run();