[wpilib] Add AlertSim function to get only active alerts (#8732)

This commit is contained in:
Sam Freund
2026-04-10 00:25:26 -05:00
committed by GitHub
parent 02c6030251
commit ece8001b1e
7 changed files with 105 additions and 2 deletions

View File

@@ -4,6 +4,7 @@
#include "wpi/simulation/AlertSim.hpp"
#include <algorithm>
#include <string>
#include <vector>
@@ -35,6 +36,12 @@ std::vector<AlertSim::AlertInfo> AlertSim::GetAll() {
return infos;
}
std::vector<AlertSim::AlertInfo> AlertSim::GetActive() {
auto infos = GetAll();
std::erase_if(infos, [](const AlertInfo& info) { return !info.isActive(); });
return infos;
}
void AlertSim::ResetData() {
HALSIM_ResetAlertData();
}

View File

@@ -55,12 +55,19 @@ class AlertSim final {
static int32_t GetCount();
/**
* Gets detailed information about each alert.
* Gets detailed information about each alert (including inactive ones).
*
* @return Alerts
*/
static std::vector<AlertInfo> GetAll();
/**
* Gets detailed information about all active alerts.
*
* @return Alerts
*/
static std::vector<AlertInfo> GetActive();
/**
* Resets all alert simulation data.
*/