mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
Update wpilibc to use new NetworkTables package and interfaces.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user