mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilib] LiveWindow: Add enableAllTelemetry() (#4480)
This commit is contained in:
@@ -114,6 +114,18 @@ void LiveWindow::DisableAllTelemetry() {
|
||||
});
|
||||
}
|
||||
|
||||
void LiveWindow::EnableAllTelemetry() {
|
||||
auto& inst = ::GetInstance();
|
||||
std::scoped_lock lock(inst.mutex);
|
||||
inst.telemetryEnabled = true;
|
||||
wpi::SendableRegistry::ForeachLiveWindow(inst.dataHandle, [&](auto& cbdata) {
|
||||
if (!cbdata.data) {
|
||||
cbdata.data = std::make_shared<Component>();
|
||||
}
|
||||
std::static_pointer_cast<Component>(cbdata.data)->telemetryEnabled = true;
|
||||
});
|
||||
}
|
||||
|
||||
bool LiveWindow::IsEnabled() {
|
||||
auto& inst = ::GetInstance();
|
||||
std::scoped_lock lock(inst.mutex);
|
||||
|
||||
@@ -51,6 +51,11 @@ class LiveWindow final {
|
||||
*/
|
||||
static void DisableAllTelemetry();
|
||||
|
||||
/**
|
||||
* Enable ALL telemetry.
|
||||
*/
|
||||
static void EnableAllTelemetry();
|
||||
|
||||
static bool IsEnabled();
|
||||
|
||||
/**
|
||||
|
||||
@@ -150,6 +150,19 @@ public final class LiveWindow {
|
||||
});
|
||||
}
|
||||
|
||||
/** Enable ALL telemetry. */
|
||||
public static synchronized void enableAllTelemetry() {
|
||||
telemetryEnabled = true;
|
||||
SendableRegistry.foreachLiveWindow(
|
||||
dataHandle,
|
||||
cbdata -> {
|
||||
if (cbdata.data == null) {
|
||||
cbdata.data = new Component();
|
||||
}
|
||||
((Component) cbdata.data).m_telemetryEnabled = true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell all the sensors to update (send) their values.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user