mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
[wpilib] Change Watchdog to use HAL notifier (#2602)
This makes it follow simulation timing instead of wall clock time.
This commit is contained in:
@@ -7,13 +7,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
|
||||
#include <hal/cpp/fpga_clock.h>
|
||||
#include <units/time.h>
|
||||
#include <wpi/SafeThread.h>
|
||||
#include <wpi/StringRef.h>
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
@@ -67,8 +64,8 @@ class Watchdog {
|
||||
|
||||
~Watchdog();
|
||||
|
||||
Watchdog(Watchdog&&) = default;
|
||||
Watchdog& operator=(Watchdog&&) = default;
|
||||
Watchdog(Watchdog&& rhs);
|
||||
Watchdog& operator=(Watchdog&& rhs);
|
||||
|
||||
/**
|
||||
* Returns the time in seconds since the watchdog was last fed.
|
||||
@@ -149,25 +146,25 @@ class Watchdog {
|
||||
|
||||
private:
|
||||
// Used for timeout print rate-limiting
|
||||
static constexpr std::chrono::milliseconds kMinPrintPeriod{1000};
|
||||
static constexpr units::second_t kMinPrintPeriod = 1_s;
|
||||
|
||||
hal::fpga_clock::time_point m_startTime;
|
||||
std::chrono::nanoseconds m_timeout;
|
||||
hal::fpga_clock::time_point m_expirationTime;
|
||||
units::second_t m_startTime = 0_s;
|
||||
units::second_t m_timeout;
|
||||
units::second_t m_expirationTime = 0_s;
|
||||
std::function<void()> m_callback;
|
||||
hal::fpga_clock::time_point m_lastTimeoutPrintTime = hal::fpga_clock::epoch();
|
||||
units::second_t m_lastTimeoutPrintTime = 0_s;
|
||||
|
||||
Tracer m_tracer;
|
||||
bool m_isExpired = false;
|
||||
|
||||
bool m_suppressTimeoutMessage = false;
|
||||
|
||||
class Thread;
|
||||
wpi::SafeThreadOwner<Thread>* m_owner;
|
||||
class Impl;
|
||||
Impl* m_impl;
|
||||
|
||||
bool operator>(const Watchdog& rhs);
|
||||
|
||||
static wpi::SafeThreadOwner<Thread>& GetThreadOwner();
|
||||
static Impl* GetImpl();
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
Reference in New Issue
Block a user