mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
Update wpilibc to use new NetworkTables package and interfaces.
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "I2C.h"
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "interfaces/Accelerometer.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -71,9 +72,9 @@ class ADXL345_I2C : public Accelerometer, public LiveWindowSendable {
|
||||
virtual AllAxes GetAccelerations();
|
||||
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
|
||||
void UpdateTable() override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
void StartLiveWindowMode() override {}
|
||||
void StopLiveWindowMode() override {}
|
||||
|
||||
@@ -81,7 +82,10 @@ class ADXL345_I2C : public Accelerometer, public LiveWindowSendable {
|
||||
I2C m_i2c;
|
||||
|
||||
private:
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_xEntry;
|
||||
nt::NetworkTableEntry m_yEntry;
|
||||
nt::NetworkTableEntry m_zEntry;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "SPI.h"
|
||||
#include "SensorBase.h"
|
||||
#include "interfaces/Accelerometer.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -73,9 +74,9 @@ class ADXL345_SPI : public Accelerometer, public LiveWindowSendable {
|
||||
virtual AllAxes GetAccelerations();
|
||||
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
|
||||
void UpdateTable() override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
void StartLiveWindowMode() override {}
|
||||
void StopLiveWindowMode() override {}
|
||||
|
||||
@@ -83,7 +84,10 @@ class ADXL345_SPI : public Accelerometer, public LiveWindowSendable {
|
||||
SPI m_spi;
|
||||
|
||||
private:
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_xEntry;
|
||||
nt::NetworkTableEntry m_yEntry;
|
||||
nt::NetworkTableEntry m_zEntry;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "SPI.h"
|
||||
#include "SensorBase.h"
|
||||
#include "interfaces/Accelerometer.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -52,9 +53,9 @@ class ADXL362 : public Accelerometer, public LiveWindowSendable {
|
||||
virtual AllAxes GetAccelerations();
|
||||
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
|
||||
void UpdateTable() override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
void StartLiveWindowMode() override {}
|
||||
void StopLiveWindowMode() override {}
|
||||
|
||||
@@ -62,7 +63,10 @@ class ADXL362 : public Accelerometer, public LiveWindowSendable {
|
||||
SPI m_spi;
|
||||
double m_gsPerLSB = 0.001;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_xEntry;
|
||||
nt::NetworkTableEntry m_yEntry;
|
||||
nt::NetworkTableEntry m_zEntry;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "PIDSource.h"
|
||||
#include "SensorBase.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -41,8 +42,8 @@ class AnalogAccelerometer : public SensorBase,
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable) override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
|
||||
private:
|
||||
void InitAccelerometer();
|
||||
@@ -51,7 +52,8 @@ class AnalogAccelerometer : public SensorBase,
|
||||
double m_voltsPerG = 1.0;
|
||||
double m_zeroGVoltage = 2.5;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_valueEntry;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "PIDSource.h"
|
||||
#include "SensorBase.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -81,8 +82,8 @@ class AnalogInput : public SensorBase,
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable) override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
|
||||
private:
|
||||
int m_channel;
|
||||
@@ -90,7 +91,8 @@ class AnalogInput : public SensorBase,
|
||||
HAL_AnalogInputHandle m_port;
|
||||
int64_t m_accumulatorOffset;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_valueEntry;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "SensorBase.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -33,14 +34,15 @@ class AnalogOutput : public SensorBase, public LiveWindowSendable {
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable) override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
|
||||
protected:
|
||||
int m_channel;
|
||||
HAL_AnalogOutputHandle m_port;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_valueEntry;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "AnalogInput.h"
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "interfaces/Potentiometer.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -71,9 +72,9 @@ class AnalogPotentiometer : public Potentiometer, public LiveWindowSendable {
|
||||
* Live Window code, only does anything if live window is activated.
|
||||
*/
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
|
||||
void UpdateTable() override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
|
||||
/**
|
||||
* AnalogPotentiometers don't have to do anything special when entering the
|
||||
@@ -90,7 +91,8 @@ class AnalogPotentiometer : public Potentiometer, public LiveWindowSendable {
|
||||
private:
|
||||
std::shared_ptr<AnalogInput> m_analog_input;
|
||||
double m_fullRange, m_offset;
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_valueEntry;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "SensorBase.h"
|
||||
#include "interfaces/Accelerometer.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -35,14 +36,17 @@ class BuiltInAccelerometer : public Accelerometer,
|
||||
double GetZ() override;
|
||||
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
void InitTable(std::shared_ptr<NetworkTable> subtable) override;
|
||||
void UpdateTable() override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
void StartLiveWindowMode() override {}
|
||||
void StopLiveWindowMode() override {}
|
||||
|
||||
private:
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_xEntry;
|
||||
nt::NetworkTableEntry m_yEntry;
|
||||
nt::NetworkTableEntry m_zEntry;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -8,23 +8,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <llvm/StringRef.h>
|
||||
|
||||
#include "Buttons/Button.h"
|
||||
#include "networktables/NetworkTable.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class NetworkButton : public Button {
|
||||
public:
|
||||
NetworkButton(const std::string& tableName, const std::string& field);
|
||||
NetworkButton(std::shared_ptr<ITable> table, const std::string& field);
|
||||
NetworkButton(llvm::StringRef tableName, llvm::StringRef field);
|
||||
NetworkButton(std::shared_ptr<nt::NetworkTable> table, llvm::StringRef field);
|
||||
virtual ~NetworkButton() = default;
|
||||
|
||||
virtual bool Get();
|
||||
|
||||
private:
|
||||
std::shared_ptr<ITable> m_netTable;
|
||||
std::string m_field;
|
||||
nt::NetworkTableEntry m_entry;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "SmartDashboard/Sendable.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -43,12 +44,13 @@ class Trigger : public Sendable {
|
||||
void CancelWhenActive(Command* command);
|
||||
void ToggleWhenActive(Command* command);
|
||||
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
|
||||
protected:
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_pressedEntry;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -293,7 +293,7 @@ class CameraServer : public ErrorBase {
|
||||
private:
|
||||
CameraServer();
|
||||
|
||||
std::shared_ptr<ITable> GetSourceTable(CS_Source source);
|
||||
std::shared_ptr<nt::NetworkTable> GetSourceTable(CS_Source source);
|
||||
std::vector<std::string> GetSinkStreamValues(CS_Sink sink);
|
||||
std::vector<std::string> GetSourceStreamValues(CS_Source source);
|
||||
void UpdateStreamValues();
|
||||
@@ -305,8 +305,8 @@ class CameraServer : public ErrorBase {
|
||||
std::string m_primarySourceName;
|
||||
llvm::StringMap<cs::VideoSource> m_sources;
|
||||
llvm::StringMap<cs::VideoSink> m_sinks;
|
||||
llvm::DenseMap<CS_Source, std::shared_ptr<ITable>> m_tables;
|
||||
std::shared_ptr<NetworkTable> m_publishTable;
|
||||
llvm::DenseMap<CS_Source, std::shared_ptr<nt::NetworkTable>> m_tables;
|
||||
std::shared_ptr<nt::NetworkTable> m_publishTable;
|
||||
cs::VideoListener m_videoListener;
|
||||
int m_tableListener;
|
||||
int m_nextPort;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/NamedSendable.h"
|
||||
#include "tables/ITableListener.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -49,7 +49,7 @@ class Subsystem;
|
||||
* @see CommandGroup
|
||||
* @see Subsystem
|
||||
*/
|
||||
class Command : public ErrorBase, public NamedSendable, public ITableListener {
|
||||
class Command : public ErrorBase, public NamedSendable {
|
||||
friend class CommandGroup;
|
||||
friend class Scheduler;
|
||||
|
||||
@@ -160,14 +160,17 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
|
||||
|
||||
public:
|
||||
std::string GetName() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew) override;
|
||||
|
||||
protected:
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
|
||||
private:
|
||||
nt::NetworkTableEntry m_runningEntry;
|
||||
nt::NetworkTableEntry m_isParentedEntry;
|
||||
NT_EntryListener m_runningListener = 0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -54,7 +54,7 @@ class PIDCommand : public Command, public PIDOutput, public PIDSource {
|
||||
std::shared_ptr<PIDController> m_controller;
|
||||
|
||||
public:
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
};
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
|
||||
std::shared_ptr<PIDController> m_controller;
|
||||
|
||||
public:
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "SmartDashboard/NamedSendable.h"
|
||||
#include "SmartDashboard/SmartDashboard.h"
|
||||
#include "networktables/NetworkTable.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -42,8 +43,8 @@ class Scheduler : public ErrorBase, public NamedSendable {
|
||||
|
||||
void UpdateTable();
|
||||
std::string GetSmartDashboardType() const;
|
||||
void InitTable(std::shared_ptr<ITable> subTable);
|
||||
std::shared_ptr<ITable> GetTable() const;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable);
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const;
|
||||
std::string GetName() const;
|
||||
std::string GetType() const;
|
||||
|
||||
@@ -67,7 +68,10 @@ class Scheduler : public ErrorBase, public NamedSendable {
|
||||
std::vector<std::string> commands;
|
||||
std::vector<double> ids;
|
||||
std::vector<double> toCancel;
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_namesEntry;
|
||||
nt::NetworkTableEntry m_idsEntry;
|
||||
nt::NetworkTableEntry m_cancelEntry;
|
||||
bool m_runningCommandsChanged = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/NamedSendable.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -42,12 +43,16 @@ class Subsystem : public ErrorBase, public NamedSendable {
|
||||
|
||||
public:
|
||||
std::string GetName() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
|
||||
protected:
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_hasDefaultEntry;
|
||||
nt::NetworkTableEntry m_defaultEntry;
|
||||
nt::NetworkTableEntry m_hasCommandEntry;
|
||||
nt::NetworkTableEntry m_commandEntry;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "SensorBase.h"
|
||||
#include "tables/ITableListener.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -31,13 +31,11 @@ namespace frc {
|
||||
* loop control. You can only turn off closed loop control, thereby stopping
|
||||
* the compressor from operating.
|
||||
*/
|
||||
class Compressor : public SensorBase,
|
||||
public LiveWindowSendable,
|
||||
public ITableListener {
|
||||
class Compressor : public SensorBase, public LiveWindowSendable {
|
||||
public:
|
||||
// Default PCM ID is 0
|
||||
explicit Compressor(int pcmID = GetDefaultSolenoidModule());
|
||||
virtual ~Compressor() = default;
|
||||
virtual ~Compressor();
|
||||
|
||||
void Start();
|
||||
void Stop();
|
||||
@@ -62,10 +60,8 @@ class Compressor : public SensorBase,
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew) override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable) override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
|
||||
protected:
|
||||
HAL_CompressorHandle m_compressorHandle;
|
||||
@@ -74,7 +70,10 @@ class Compressor : public SensorBase,
|
||||
void SetCompressor(bool on);
|
||||
int m_module;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_enabledEntry;
|
||||
nt::NetworkTableEntry m_pressureSwitchEntry;
|
||||
NT_EntryListener m_enabledListener = 0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "CounterBase.h"
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "SensorBase.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -98,8 +99,8 @@ class Counter : public SensorBase,
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable) override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
|
||||
protected:
|
||||
// Makes the counter count up.
|
||||
@@ -112,7 +113,8 @@ class Counter : public SensorBase,
|
||||
private:
|
||||
int m_index = 0; ///< The index of this counter.
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_valueEntry;
|
||||
friend class DigitalGlitchFilter;
|
||||
};
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "DigitalSource.h"
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -41,14 +42,15 @@ class DigitalInput : public DigitalSource, public LiveWindowSendable {
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable) override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
|
||||
private:
|
||||
int m_channel;
|
||||
HAL_DigitalHandle m_handle;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_valueEntry;
|
||||
friend class DigitalGlitchFilter;
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "DigitalSource.h"
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "tables/ITableListener.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -24,9 +24,7 @@ namespace frc {
|
||||
* elsewhere will allocate channels automatically so for those devices it
|
||||
* shouldn't be done here.
|
||||
*/
|
||||
class DigitalOutput : public DigitalSource,
|
||||
public ITableListener,
|
||||
public LiveWindowSendable {
|
||||
class DigitalOutput : public DigitalSource, public LiveWindowSendable {
|
||||
public:
|
||||
explicit DigitalOutput(int channel);
|
||||
virtual ~DigitalOutput();
|
||||
@@ -45,21 +43,21 @@ class DigitalOutput : public DigitalSource,
|
||||
AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
|
||||
bool IsAnalogTrigger() const override;
|
||||
|
||||
void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew) override;
|
||||
void UpdateTable() override;
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable) override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
|
||||
private:
|
||||
int m_channel;
|
||||
HAL_DigitalHandle m_handle;
|
||||
HAL_DigitalPWMHandle m_pwmGenerator;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_valueEntry;
|
||||
NT_EntryListener m_valueListener = 0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "SolenoidBase.h"
|
||||
#include "tables/ITableListener.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -25,9 +25,7 @@ namespace frc {
|
||||
* The DoubleSolenoid class is typically used for pneumatics solenoids that
|
||||
* have two positions controlled by two separate channels.
|
||||
*/
|
||||
class DoubleSolenoid : public SolenoidBase,
|
||||
public LiveWindowSendable,
|
||||
public ITableListener {
|
||||
class DoubleSolenoid : public SolenoidBase, public LiveWindowSendable {
|
||||
public:
|
||||
enum Value { kOff, kForward, kReverse };
|
||||
|
||||
@@ -39,14 +37,12 @@ class DoubleSolenoid : public SolenoidBase,
|
||||
bool IsFwdSolenoidBlackListed() const;
|
||||
bool IsRevSolenoidBlackListed() const;
|
||||
|
||||
void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew);
|
||||
void UpdateTable();
|
||||
void StartLiveWindowMode();
|
||||
void StopLiveWindowMode();
|
||||
std::string GetSmartDashboardType() const;
|
||||
void InitTable(std::shared_ptr<ITable> subTable);
|
||||
std::shared_ptr<ITable> GetTable() const;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable);
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const;
|
||||
|
||||
private:
|
||||
int m_forwardChannel; ///< The forward channel on the module to control.
|
||||
@@ -56,7 +52,9 @@ class DoubleSolenoid : public SolenoidBase,
|
||||
HAL_SolenoidHandle m_forwardHandle = HAL_kInvalidHandle;
|
||||
HAL_SolenoidHandle m_reverseHandle = HAL_kInvalidHandle;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_valueEntry;
|
||||
NT_EntryListener m_valueListener = 0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "PIDSource.h"
|
||||
#include "SensorBase.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -88,8 +89,8 @@ class Encoder : public SensorBase,
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable) override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
|
||||
int GetFPGAIndex() const;
|
||||
|
||||
@@ -103,7 +104,10 @@ class Encoder : public SensorBase,
|
||||
std::unique_ptr<DigitalSource> m_indexSource = nullptr;
|
||||
HAL_EncoderHandle m_encoder = HAL_kInvalidHandle;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_speedEntry;
|
||||
nt::NetworkTableEntry m_distanceEntry;
|
||||
nt::NetworkTableEntry m_distancePerTickEntry;
|
||||
friend class DigitalGlitchFilter;
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "PIDSource.h"
|
||||
#include "SensorBase.h"
|
||||
#include "interfaces/Gyro.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -35,11 +36,12 @@ class GyroBase : public Gyro,
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable) override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_valueEntry;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
|
||||
#include "Commands/Scheduler.h"
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "tables/ITable.h"
|
||||
#include "networktables/NetworkTable.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -75,8 +76,9 @@ class LiveWindow {
|
||||
std::map<std::shared_ptr<LiveWindowSendable>, LiveWindowComponent>
|
||||
m_components;
|
||||
|
||||
std::shared_ptr<ITable> m_liveWindowTable;
|
||||
std::shared_ptr<ITable> m_statusTable;
|
||||
std::shared_ptr<nt::NetworkTable> m_liveWindowTable;
|
||||
std::shared_ptr<nt::NetworkTable> m_statusTable;
|
||||
nt::NetworkTableEntry m_enabledEntry;
|
||||
|
||||
Scheduler* m_scheduler;
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2012-2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "tables/ITable.h"
|
||||
#include "tables/ITableListener.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class LiveWindowStatusListener : public ITableListener {
|
||||
public:
|
||||
virtual void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew);
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "PIDInterface.h"
|
||||
#include "PIDSource.h"
|
||||
#include "Timer.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -36,9 +37,7 @@ class PIDOutput;
|
||||
* in the integral and derivative calculations. Therefore, the sample rate
|
||||
* affects the controller's behavior for a given set of PID constants.
|
||||
*/
|
||||
class PIDController : public LiveWindowSendable,
|
||||
public PIDInterface,
|
||||
public ITableListener {
|
||||
class PIDController : public LiveWindowSendable, public PIDInterface {
|
||||
public:
|
||||
PIDController(double p, double i, double d, PIDSource* source,
|
||||
PIDOutput* output, double period = 0.05);
|
||||
@@ -82,13 +81,26 @@ class PIDController : public LiveWindowSendable,
|
||||
|
||||
void Reset() override;
|
||||
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
|
||||
|
||||
protected:
|
||||
PIDSource* m_pidInput;
|
||||
PIDOutput* m_pidOutput;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_pEntry;
|
||||
nt::NetworkTableEntry m_iEntry;
|
||||
nt::NetworkTableEntry m_dEntry;
|
||||
nt::NetworkTableEntry m_fEntry;
|
||||
nt::NetworkTableEntry m_setpointEntry;
|
||||
nt::NetworkTableEntry m_enabledEntry;
|
||||
NT_EntryListener m_pListener = 0;
|
||||
NT_EntryListener m_iListener = 0;
|
||||
NT_EntryListener m_dListener = 0;
|
||||
NT_EntryListener m_fListener = 0;
|
||||
NT_EntryListener m_setpointListener = 0;
|
||||
NT_EntryListener m_enabledListener = 0;
|
||||
|
||||
virtual void Calculate();
|
||||
virtual double CalculateFeedForward();
|
||||
double GetContinuousError(double error) const;
|
||||
@@ -142,13 +154,12 @@ class PIDController : public LiveWindowSendable,
|
||||
std::unique_ptr<Notifier> m_controlLoop;
|
||||
Timer m_setpointTimer;
|
||||
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew) override;
|
||||
void UpdateTable() override;
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
void RemoveListeners();
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "SensorBase.h"
|
||||
#include "tables/ITableListener.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -37,9 +37,7 @@ namespace frc {
|
||||
* - 1 = minimum pulse width (currently .5ms)
|
||||
* - 0 = disabled (i.e. PWM output is held low)
|
||||
*/
|
||||
class PWM : public SensorBase,
|
||||
public ITableListener,
|
||||
public LiveWindowSendable {
|
||||
class PWM : public SensorBase, public LiveWindowSendable {
|
||||
public:
|
||||
/**
|
||||
* Represents the amount to multiply the minimum servo-pulse pwm period by.
|
||||
@@ -80,16 +78,16 @@ class PWM : public SensorBase,
|
||||
int GetChannel() const { return m_channel; }
|
||||
|
||||
protected:
|
||||
void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew) override;
|
||||
void UpdateTable() override;
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable) override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_valueEntry;
|
||||
NT_EntryListener m_valueListener = 0;
|
||||
|
||||
private:
|
||||
int m_channel;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "SensorBase.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -37,11 +38,14 @@ class PowerDistributionPanel : public SensorBase, public LiveWindowSendable {
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable) override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_chanEntry[16];
|
||||
nt::NetworkTableEntry m_voltageEntry;
|
||||
nt::NetworkTableEntry m_totalCurrentEntry;
|
||||
int m_module;
|
||||
};
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include "networktables/NetworkTable.h"
|
||||
#include "tables/ITableListener.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -58,16 +57,8 @@ class Preferences : public ErrorBase {
|
||||
virtual ~Preferences() = default;
|
||||
|
||||
private:
|
||||
std::shared_ptr<ITable> m_table;
|
||||
class Listener : public ITableListener {
|
||||
public:
|
||||
void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew) override;
|
||||
void ValueChangedEx(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value,
|
||||
uint32_t flags) override;
|
||||
};
|
||||
Listener m_listener;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
NT_EntryListener m_listener;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "MotorSafety.h"
|
||||
#include "SensorBase.h"
|
||||
#include "tables/ITable.h"
|
||||
#include "tables/ITableListener.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -34,10 +33,7 @@ class MotorSafetyHelper;
|
||||
* independently for something that does not care about voltage polarity (like
|
||||
* a solenoid).
|
||||
*/
|
||||
class Relay : public MotorSafety,
|
||||
public SensorBase,
|
||||
public ITableListener,
|
||||
public LiveWindowSendable {
|
||||
class Relay : public MotorSafety, public SensorBase, public LiveWindowSendable {
|
||||
public:
|
||||
enum Value { kOff, kOn, kForward, kReverse };
|
||||
enum Direction { kBothDirections, kForwardOnly, kReverseOnly };
|
||||
@@ -57,16 +53,17 @@ class Relay : public MotorSafety,
|
||||
void SetSafetyEnabled(bool enabled) override;
|
||||
void GetDescription(llvm::raw_ostream& desc) const override;
|
||||
|
||||
void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew) override;
|
||||
void UpdateTable() override;
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable) override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
protected:
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_valueEntry;
|
||||
NT_EntryListener m_valueListener = 0;
|
||||
|
||||
private:
|
||||
int m_channel;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "SafePWM.h"
|
||||
#include "SpeedController.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -34,16 +35,17 @@ class Servo : public SafePWM {
|
||||
static double GetMaxAngle() { return kMaxServoAngle; }
|
||||
static double GetMinAngle() { return kMinServoAngle; }
|
||||
|
||||
void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew) override;
|
||||
void UpdateTable() override;
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable) override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
protected:
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_valueEntry;
|
||||
NT_EntryListener m_valueListener = 0;
|
||||
|
||||
private:
|
||||
double GetServoAngleRange() const { return kMaxServoAngle - kMinServoAngle; }
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "tables/ITable.h"
|
||||
#include "networktables/NetworkTable.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -20,12 +20,12 @@ class Sendable {
|
||||
* Initializes a table for this sendable object.
|
||||
* @param subtable The table to put the values in.
|
||||
*/
|
||||
virtual void InitTable(std::shared_ptr<ITable> subtable) = 0;
|
||||
virtual void InitTable(std::shared_ptr<nt::NetworkTable> subtable) = 0;
|
||||
|
||||
/**
|
||||
* @return the table that is currently associated with the sendable
|
||||
*/
|
||||
virtual std::shared_ptr<ITable> GetTable() const = 0;
|
||||
virtual std::shared_ptr<nt::NetworkTable> GetTable() const = 0;
|
||||
|
||||
/**
|
||||
* @return the string representation of the named data type that will be used
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <llvm/StringRef.h>
|
||||
|
||||
#include "SmartDashboard/SendableChooserBase.h"
|
||||
#include "tables/ITable.h"
|
||||
#include "networktables/NetworkTable.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -53,7 +53,7 @@ class SendableChooser : public SendableChooserBase {
|
||||
|
||||
auto GetSelected() -> decltype(_unwrap_smart_ptr(m_choices[""]));
|
||||
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subtable) override;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -68,7 +68,7 @@ auto SendableChooser<T>::GetSelected()
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void SendableChooser<T>::InitTable(std::shared_ptr<ITable> subtable) {
|
||||
void SendableChooser<T>::InitTable(std::shared_ptr<nt::NetworkTable> subtable) {
|
||||
std::vector<std::string> keys;
|
||||
m_table = subtable;
|
||||
if (m_table != nullptr) {
|
||||
@@ -79,8 +79,9 @@ void SendableChooser<T>::InitTable(std::shared_ptr<ITable> subtable) {
|
||||
// Unlike std::map, llvm::StringMap elements are not sorted
|
||||
std::sort(keys.begin(), keys.end());
|
||||
|
||||
m_table->PutValue(kOptions, nt::Value::MakeStringArray(std::move(keys)));
|
||||
m_table->PutString(kDefault, m_defaultChoice);
|
||||
m_table->GetEntry(kOptions).SetValue(
|
||||
nt::Value::MakeStringArray(std::move(keys)));
|
||||
m_table->GetEntry(kDefault).SetString(m_defaultChoice);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "SmartDashboard/Sendable.h"
|
||||
#include "tables/ITable.h"
|
||||
#include "networktables/NetworkTable.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -25,7 +25,7 @@ class SendableChooserBase : public Sendable {
|
||||
public:
|
||||
virtual ~SendableChooserBase() = default;
|
||||
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
|
||||
protected:
|
||||
@@ -34,7 +34,7 @@ class SendableChooserBase : public Sendable {
|
||||
static const char* kSelected;
|
||||
|
||||
std::string m_defaultChoice;
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -7,18 +7,18 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "SensorBase.h"
|
||||
#include "SmartDashboard/NamedSendable.h"
|
||||
#include "SmartDashboard/Sendable.h"
|
||||
#include "tables/ITable.h"
|
||||
#include "networktables/NetworkTableValue.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class NamedSendable;
|
||||
class Sendable;
|
||||
|
||||
class SmartDashboard : public SensorBase {
|
||||
public:
|
||||
static void init();
|
||||
@@ -86,15 +86,6 @@ class SmartDashboard : public SensorBase {
|
||||
|
||||
private:
|
||||
virtual ~SmartDashboard() = default;
|
||||
|
||||
/** The {@link NetworkTable} used by {@link SmartDashboard} */
|
||||
static std::shared_ptr<ITable> m_table;
|
||||
|
||||
/**
|
||||
* A map linking tables in the SmartDashboard to the
|
||||
* {@link SmartDashboardData} objects they came from.
|
||||
*/
|
||||
static std::map<std::shared_ptr<ITable>, Sendable*> m_tablesToData;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "SolenoidBase.h"
|
||||
#include "tables/ITableListener.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -24,9 +24,7 @@ namespace frc {
|
||||
* The Solenoid class is typically used for pneumatics solenoids, but could be
|
||||
* used for any device within the current spec of the PCM.
|
||||
*/
|
||||
class Solenoid : public SolenoidBase,
|
||||
public LiveWindowSendable,
|
||||
public ITableListener {
|
||||
class Solenoid : public SolenoidBase, public LiveWindowSendable {
|
||||
public:
|
||||
explicit Solenoid(int channel);
|
||||
Solenoid(int moduleNumber, int channel);
|
||||
@@ -35,19 +33,19 @@ class Solenoid : public SolenoidBase,
|
||||
virtual bool Get() const;
|
||||
bool IsBlackListed() const;
|
||||
|
||||
void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew);
|
||||
void UpdateTable();
|
||||
void StartLiveWindowMode();
|
||||
void StopLiveWindowMode();
|
||||
std::string GetSmartDashboardType() const;
|
||||
void InitTable(std::shared_ptr<ITable> subTable);
|
||||
std::shared_ptr<ITable> GetTable() const;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable);
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const;
|
||||
|
||||
private:
|
||||
HAL_SolenoidHandle m_solenoidHandle = HAL_kInvalidHandle;
|
||||
int m_channel; ///< The channel on the module to control.
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_valueEntry;
|
||||
NT_EntryListener m_valueListener = 0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "PIDSource.h"
|
||||
#include "SensorBase.h"
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -69,8 +70,8 @@ class Ultrasonic : public SensorBase,
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable) override;
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() const override;
|
||||
|
||||
private:
|
||||
void Initialize();
|
||||
@@ -96,7 +97,8 @@ class Ultrasonic : public SensorBase,
|
||||
Counter m_counter;
|
||||
DistanceUnit m_units;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
nt::NetworkTableEntry m_valueEntry;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
Reference in New Issue
Block a user