Update wpilibc to use new NetworkTables package and interfaces.

This commit is contained in:
Peter Johnson
2017-09-02 00:17:43 -07:00
parent 4e80570c4c
commit 040a8c6bcc
74 changed files with 937 additions and 721 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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

View File

@@ -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