mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Simplify Sendable interface (#1864)
This removes the name and subsystem from individual objects, and instead puts this data into a new singleton class, SendableRegistry. Much of LiveWindow has been refactored into SendableRegistry. In C++, a new CRTP helper class, SendableHelper, has been added to provide move and destruction functionality. Shims for GetName, SetName, GetSubsystem, and SetSubsystem have been added to Command and Subsystem (both old and new), and also to SendableHelper to prevent code breakage. This deprecates SendableBase in preparation for future removal.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "frc/DigitalInput.h"
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
@@ -26,7 +27,7 @@ Counter::Counter(Mode mode) {
|
||||
SetMaxPeriod(.5);
|
||||
|
||||
HAL_Report(HALUsageReporting::kResourceType_Counter, m_index, mode);
|
||||
SetName("Counter", m_index);
|
||||
SendableRegistry::GetInstance().AddLW(this, "Counter", m_index);
|
||||
}
|
||||
|
||||
Counter::Counter(int channel) : Counter(kTwoPulse) {
|
||||
@@ -95,7 +96,7 @@ Counter::~Counter() {
|
||||
void Counter::SetUpSource(int channel) {
|
||||
if (StatusIsFatal()) return;
|
||||
SetUpSource(std::make_shared<DigitalInput>(channel));
|
||||
AddChild(m_upSource);
|
||||
SendableRegistry::GetInstance().AddChild(this, m_upSource.get());
|
||||
}
|
||||
|
||||
void Counter::SetUpSource(AnalogTrigger* analogTrigger,
|
||||
@@ -159,7 +160,7 @@ void Counter::ClearUpSource() {
|
||||
void Counter::SetDownSource(int channel) {
|
||||
if (StatusIsFatal()) return;
|
||||
SetDownSource(std::make_shared<DigitalInput>(channel));
|
||||
AddChild(m_downSource);
|
||||
SendableRegistry::GetInstance().AddChild(this, m_downSource.get());
|
||||
}
|
||||
|
||||
void Counter::SetDownSource(AnalogTrigger* analogTrigger,
|
||||
|
||||
Reference in New Issue
Block a user