14 #include <hal/cpp/fpga_clock.h>
15 #include <units/units.h>
16 #include <wpi/SafeThread.h>
17 #include <wpi/StringMap.h>
18 #include <wpi/StringRef.h>
19 #include <wpi/deprecated.h>
41 WPI_DEPRECATED(
"Use unit-safe version instead")
42 Watchdog(
double timeout, std::function<
void()> callback);
51 Watchdog(units::second_t timeout, std::function<
void()> callback);
53 template <
typename Callable,
typename Arg,
typename... Args>
54 WPI_DEPRECATED(
"Use unit-safe version instead")
55 Watchdog(
double timeout, Callable&& f, Arg&& arg, Args&&... args)
56 :
Watchdog(units::second_t{timeout}, arg, args...) {}
58 template <
typename Callable,
typename Arg,
typename... Args>
59 Watchdog(units::second_t timeout, Callable&& f, Arg&& arg, Args&&... args)
61 std::bind(std::forward<Callable>(f), std::forward<Arg>(arg),
62 std::forward<Args>(args)...)) {}
80 WPI_DEPRECATED(
"Use unit-safe version instead")
145 static constexpr std::chrono::milliseconds kMinPrintPeriod{1000};
147 hal::fpga_clock::time_point m_startTime;
148 std::chrono::nanoseconds m_timeout;
149 hal::fpga_clock::time_point m_expirationTime;
150 std::function<void()> m_callback;
151 hal::fpga_clock::time_point m_lastTimeoutPrintTime = hal::fpga_clock::epoch();
152 hal::fpga_clock::time_point m_lastEpochsPrintTime = hal::fpga_clock::epoch();
155 bool m_isExpired =
false;
157 bool m_suppressTimeoutMessage =
false;
162 bool operator>(
const Watchdog& rhs);