mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +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:
@@ -8,49 +8,50 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <llvm/StringRef.h>
|
||||
#include <llvm/Twine.h>
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/NamedSendable.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
#include "SmartDashboard/Sendable.h"
|
||||
#include "SmartDashboard/SendableBase.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class Command;
|
||||
|
||||
class Subsystem : public ErrorBase, public NamedSendable {
|
||||
class Subsystem : public ErrorBase, public SendableBase {
|
||||
friend class Scheduler;
|
||||
|
||||
public:
|
||||
explicit Subsystem(const std::string& name);
|
||||
virtual ~Subsystem() = default;
|
||||
explicit Subsystem(const llvm::Twine& name);
|
||||
|
||||
void SetDefaultCommand(Command* command);
|
||||
Command* GetDefaultCommand();
|
||||
llvm::StringRef GetDefaultCommandName();
|
||||
void SetCurrentCommand(Command* command);
|
||||
Command* GetCurrentCommand() const;
|
||||
llvm::StringRef GetCurrentCommandName() const;
|
||||
virtual void Periodic();
|
||||
virtual void InitDefaultCommand();
|
||||
|
||||
void AddChild(const llvm::Twine& name, std::shared_ptr<Sendable> child);
|
||||
void AddChild(const llvm::Twine& name, Sendable* child);
|
||||
void AddChild(const llvm::Twine& name, Sendable& child);
|
||||
void AddChild(std::shared_ptr<Sendable> child);
|
||||
void AddChild(Sendable* child);
|
||||
void AddChild(Sendable& child);
|
||||
|
||||
private:
|
||||
void ConfirmCommand();
|
||||
|
||||
Command* m_currentCommand = nullptr;
|
||||
bool m_currentCommandChanged = true;
|
||||
Command* m_defaultCommand = nullptr;
|
||||
std::string m_name;
|
||||
bool m_initializedDefaultCommand = false;
|
||||
|
||||
public:
|
||||
std::string GetName() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
|
||||
protected:
|
||||
nt::NetworkTableEntry m_hasDefaultEntry;
|
||||
nt::NetworkTableEntry m_defaultEntry;
|
||||
nt::NetworkTableEntry m_hasCommandEntry;
|
||||
nt::NetworkTableEntry m_commandEntry;
|
||||
void InitSendable(SendableBuilder& builder) override;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
Reference in New Issue
Block a user