Use new NetworkTables across WPILib (C++ and Java).

Also make sure table listeners stop listening in their destructors.  This
might be better handled by moving the table itself into ITableListener and
providing cleanup functionality there.

A submodule is used to pull in ntcore.

Change-Id: I3031c1a768595cf0f8754c47e15cd423e2dbcce5
This commit is contained in:
Peter Johnson
2015-08-13 23:17:19 -07:00
committed by Brad Miller (WPI)
parent f65e697107
commit f89c5e150f
67 changed files with 512 additions and 1457 deletions

View File

@@ -81,6 +81,7 @@ Relay::~Relay() {
if (m_direction == kBothDirections || m_direction == kReverseOnly) {
relayChannels->Free(m_channel * 2 + 1);
}
if (m_table != nullptr) m_table->RemoveTableListener(this);
}
/**
@@ -189,16 +190,16 @@ Relay::Value Relay::Get() const {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
void Relay::ValueChanged(std::shared_ptr<ITable> source, const std::string &key,
EntryValue value, bool isNew) {
std::string *val = (std::string *)value.ptr;
if (*val == "Off")
void Relay::ValueChanged(ITable* source, llvm::StringRef key,
std::shared_ptr<nt::Value> value, bool isNew) {
if (!value->IsString()) return;
if (value->GetString() == "Off")
Set(kOff);
else if (*val == "On")
else if (value->GetString() == "On")
Set(kOn);
else if (*val == "Forward")
else if (value->GetString() == "Forward")
Set(kForward);
else if (*val == "Reverse")
else if (value->GetString() == "Reverse")
Set(kReverse);
}