From 1bb8f4b5558c2ffb30f6cffd17f43641833b4d9b Mon Sep 17 00:00:00 2001 From: MEFThunders7035 <95276965+kytpbs@users.noreply.github.com> Date: Sat, 4 May 2024 19:53:25 +0300 Subject: [PATCH] expose printWatchdogEpochs with string consumer --- .../edu/wpi/first/wpilibj2/command/CommandScheduler.java | 4 ++++ .../src/main/native/cpp/frc2/command/CommandScheduler.cpp | 4 ++++ .../main/native/include/frc2/command/CommandScheduler.h | 7 +++++++ wpilibc/src/main/native/cpp/Watchdog.cpp | 4 ++++ wpilibc/src/main/native/include/frc/Watchdog.h | 7 +++++++ wpilibj/src/main/java/edu/wpi/first/wpilibj/Watchdog.java | 5 +++++ 6 files changed, 31 insertions(+) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java index 9f040523d14..fba1056bb45 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/CommandScheduler.java @@ -530,6 +530,10 @@ public void enable() { m_disabled = false; } + public void printWatchdogEpochs(Consumer output) { + m_watchdog.printEpochs(output); + } + /** * Adds an action to perform on the initialization of any command by the scheduler. * diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp index efeee4e6449..fd9b96962cb 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandScheduler.cpp @@ -428,6 +428,10 @@ void CommandScheduler::Enable() { m_impl->disabled = false; } +void CommandScheduler::PrintWatchdogEpochs(wpi::raw_ostream& os) { + m_watchdog.PrintEpochs(os); +} + void CommandScheduler::OnCommandInitialize(Action action) { m_impl->initActions.emplace_back(std::move(action)); } diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h index 1f8d74297ad..046d5318a2d 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandScheduler.h @@ -333,6 +333,13 @@ class CommandScheduler final : public wpi::Sendable, */ void Enable(); + /** + * Prints list of epochs added so far and their times to a stream. + * + * @param os output stream + */ + void PrintWatchdogEpochs(wpi::raw_ostream& os); + /** * Adds an action to perform on the initialization of any command by the * scheduler. diff --git a/wpilibc/src/main/native/cpp/Watchdog.cpp b/wpilibc/src/main/native/cpp/Watchdog.cpp index 37e253616e9..e0dfcda5713 100644 --- a/wpilibc/src/main/native/cpp/Watchdog.cpp +++ b/wpilibc/src/main/native/cpp/Watchdog.cpp @@ -200,6 +200,10 @@ void Watchdog::PrintEpochs() { m_tracer.PrintEpochs(); } +void Watchdog::PrintEpochs(wpi::raw_ostream& os) { + m_tracer.PrintEpochs(os); +} + void Watchdog::Reset() { Enable(); } diff --git a/wpilibc/src/main/native/include/frc/Watchdog.h b/wpilibc/src/main/native/include/frc/Watchdog.h index d85674d8c6f..91c0bd7247a 100644 --- a/wpilibc/src/main/native/include/frc/Watchdog.h +++ b/wpilibc/src/main/native/include/frc/Watchdog.h @@ -83,6 +83,13 @@ class Watchdog { */ void PrintEpochs(); + /** + * Prints list of epochs added so far and their times to a stream. + * + * @param os output stream + */ + void PrintEpochs(wpi::raw_ostream& os); + /** * Resets the watchdog timer. * 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 e1860e38db3..d5bcc7cc71e 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Watchdog.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Watchdog.java @@ -8,6 +8,7 @@ import java.io.Closeable; import java.util.PriorityQueue; import java.util.concurrent.locks.ReentrantLock; +import java.util.function.Consumer; /** * A class that's a wrapper around a watchdog timer. @@ -159,6 +160,10 @@ public void printEpochs() { m_tracer.printEpochs(); } + public void printEpochs(Consumer output) { + m_tracer.printEpochs(output); + } + /** * Resets the watchdog timer. *