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

@@ -219,6 +219,9 @@ void Scheduler::ResetAll() {
m_additions.clear();
m_commands.clear();
m_table = nullptr;
m_namesEntry = nt::NetworkTableEntry();
m_idsEntry = nt::NetworkTableEntry();
m_cancelEntry = nt::NetworkTableEntry();
}
/**
@@ -228,7 +231,7 @@ void Scheduler::ResetAll() {
void Scheduler::UpdateTable() {
if (m_table != nullptr) {
// Get the list of possible commands to cancel
auto new_toCancel = m_table->GetValue("Cancel");
auto new_toCancel = m_cancelEntry.GetValue();
if (new_toCancel)
toCancel = new_toCancel->GetDoubleArray();
else
@@ -248,7 +251,7 @@ void Scheduler::UpdateTable() {
}
}
toCancel.resize(0);
m_table->PutValue("Cancel", nt::Value::MakeDoubleArray(toCancel));
m_cancelEntry.SetDoubleArray(toCancel);
}
// Set the running commands
@@ -261,8 +264,8 @@ void Scheduler::UpdateTable() {
commands.push_back(c->GetName());
ids.push_back(c->GetID());
}
m_table->PutValue("Names", nt::Value::MakeStringArray(commands));
m_table->PutValue("Ids", nt::Value::MakeDoubleArray(ids));
m_namesEntry.SetStringArray(commands);
m_idsEntry.SetDoubleArray(ids);
}
}
}
@@ -273,12 +276,22 @@ std::string Scheduler::GetType() const { return "Scheduler"; }
std::string Scheduler::GetSmartDashboardType() const { return "Scheduler"; }
void Scheduler::InitTable(std::shared_ptr<ITable> subTable) {
void Scheduler::InitTable(std::shared_ptr<nt::NetworkTable> subTable) {
m_table = subTable;
m_table->PutValue("Names", nt::Value::MakeStringArray(commands));
m_table->PutValue("Ids", nt::Value::MakeDoubleArray(ids));
m_table->PutValue("Cancel", nt::Value::MakeDoubleArray(toCancel));
if (m_table) {
m_namesEntry = m_table->GetEntry("Names");
m_idsEntry = m_table->GetEntry("Ids");
m_cancelEntry = m_table->GetEntry("Cancel");
m_namesEntry.SetStringArray(commands);
m_idsEntry.SetDoubleArray(ids);
m_cancelEntry.SetDoubleArray(toCancel);
} else {
m_namesEntry = nt::NetworkTableEntry();
m_idsEntry = nt::NetworkTableEntry();
m_cancelEntry = nt::NetworkTableEntry();
}
}
std::shared_ptr<ITable> Scheduler::GetTable() const { return m_table; }
std::shared_ptr<nt::NetworkTable> Scheduler::GetTable() const {
return m_table;
}