mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Update LiveWindow to provide continuous telemetry. (#771)
LiveWindow.updateValues() is now called from IterativeRobotBase on every loop iteration. Telemetry for all WPILib classes is enabled by default; it can be disabled for specific classes using LiveWindow.disableTelemetry(), or all telemetry can be disabled using LiveWindow.disableAllTelemetry(). This necessitated changing the hook methodology into other classes to be more property-based rather than each class providing multiple functions. This had the benefit of reducing boilerplate and increasing consistency. - Remove NamedSendable, add name to Sendable. - Provide SendableBase abstract class. - Deprecate LiveWindow addSensor/addActuator interfaces. - Add LiveWindow support to drive classes. - Add addChild() helper functions to Subsystem. - Fix inheritance hierarchy. Now only sensors inherit from SensorBase. Other devices inherit from some combination of SendableBase, ErrorBase, or nothing.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "AnalogTrigger.h"
|
||||
#include "DigitalInput.h"
|
||||
#include "SmartDashboard/SendableBuilder.h"
|
||||
#include "WPIErrors.h"
|
||||
|
||||
using namespace frc;
|
||||
@@ -36,6 +37,7 @@ Counter::Counter(Mode mode) {
|
||||
SetMaxPeriod(.5);
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_Counter, m_index, mode);
|
||||
SetName("Counter", m_index);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,6 +183,7 @@ Counter::~Counter() {
|
||||
void Counter::SetUpSource(int channel) {
|
||||
if (StatusIsFatal()) return;
|
||||
SetUpSource(std::make_shared<DigitalInput>(channel));
|
||||
AddChild(m_upSource);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,6 +290,7 @@ void Counter::ClearUpSource() {
|
||||
void Counter::SetDownSource(int channel) {
|
||||
if (StatusIsFatal()) return;
|
||||
SetDownSource(std::make_shared<DigitalInput>(channel));
|
||||
AddChild(m_downSource);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -603,21 +607,7 @@ void Counter::SetReverseDirection(bool reverseDirection) {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
void Counter::UpdateTable() {
|
||||
if (m_valueEntry) m_valueEntry.SetDouble(Get());
|
||||
}
|
||||
|
||||
void Counter::StartLiveWindowMode() {}
|
||||
|
||||
void Counter::StopLiveWindowMode() {}
|
||||
|
||||
std::string Counter::GetSmartDashboardType() const { return "Counter"; }
|
||||
|
||||
void Counter::InitTable(std::shared_ptr<nt::NetworkTable> subTable) {
|
||||
if (subTable) {
|
||||
m_valueEntry = subTable->GetEntry("Value");
|
||||
UpdateTable();
|
||||
} else {
|
||||
m_valueEntry = nt::NetworkTableEntry();
|
||||
}
|
||||
void Counter::InitSendable(SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Counter");
|
||||
builder.AddDoubleProperty("Value", [=]() { return Get(); }, nullptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user