mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
[wpilib] Add AlertSim function to get only active alerts (#8732)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user