mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Merge branch '2022'
This commit is contained in:
@@ -19,7 +19,8 @@ MechanismLigament2d::MechanismLigament2d(const wpi::Twine& name, double length,
|
||||
SetColor(color);
|
||||
}
|
||||
|
||||
void MechanismLigament2d::UpdateEntries(std::shared_ptr<NetworkTable> table) {
|
||||
void MechanismLigament2d::UpdateEntries(
|
||||
std::shared_ptr<nt::NetworkTable> table) {
|
||||
table->GetEntry(".type").SetString("line");
|
||||
|
||||
m_colorEntry = table->GetEntry("color");
|
||||
|
||||
@@ -13,7 +13,7 @@ const std::string& MechanismObject2d::GetName() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void MechanismObject2d::Update(std::shared_ptr<NetworkTable> table) {
|
||||
void MechanismObject2d::Update(std::shared_ptr<nt::NetworkTable> table) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
m_table = table;
|
||||
UpdateEntries(m_table);
|
||||
|
||||
@@ -23,7 +23,7 @@ void MechanismRoot2d::SetPosition(double x, double y) {
|
||||
Flush();
|
||||
}
|
||||
|
||||
void MechanismRoot2d::UpdateEntries(std::shared_ptr<NetworkTable> table) {
|
||||
void MechanismRoot2d::UpdateEntries(std::shared_ptr<nt::NetworkTable> table) {
|
||||
m_posEntry = table->GetEntry(kPosition);
|
||||
Flush();
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "frc/smartdashboard/SendableBase.h"
|
||||
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
SendableBase::SendableBase(bool addLiveWindow) {
|
||||
if (addLiveWindow) {
|
||||
SendableRegistry::GetInstance().AddLW(this, "");
|
||||
} else {
|
||||
SendableRegistry::GetInstance().Add(this, "");
|
||||
}
|
||||
}
|
||||
@@ -352,7 +352,7 @@ Sendable* SendableRegistry::GetSendable(UID uid) {
|
||||
}
|
||||
|
||||
void SendableRegistry::Publish(UID sendableUid,
|
||||
std::shared_ptr<NetworkTable> table) {
|
||||
std::shared_ptr<nt::NetworkTable> table) {
|
||||
std::scoped_lock lock(m_impl->mutex);
|
||||
if (sendableUid == 0 || (sendableUid - 1) >= m_impl->components.size() ||
|
||||
!m_impl->components[sendableUid - 1]) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <wpi/StringMap.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "frc/WPIErrors.h"
|
||||
#include "frc/Errors.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
|
||||
using namespace frc;
|
||||
@@ -85,9 +85,8 @@ nt::NetworkTableEntry SmartDashboard::GetEntry(wpi::StringRef key) {
|
||||
}
|
||||
|
||||
void SmartDashboard::PutData(wpi::StringRef key, Sendable* data) {
|
||||
if (data == nullptr) {
|
||||
wpi_setGlobalWPIErrorWithContext(NullParameter, "value");
|
||||
return;
|
||||
if (!data) {
|
||||
throw FRC_MakeError(err::NullParameter, "value");
|
||||
}
|
||||
auto& inst = Singleton::GetInstance();
|
||||
std::scoped_lock lock(inst.tablesToDataMutex);
|
||||
@@ -103,9 +102,8 @@ void SmartDashboard::PutData(wpi::StringRef key, Sendable* data) {
|
||||
}
|
||||
|
||||
void SmartDashboard::PutData(Sendable* value) {
|
||||
if (value == nullptr) {
|
||||
wpi_setGlobalWPIErrorWithContext(NullParameter, "value");
|
||||
return;
|
||||
if (!value) {
|
||||
throw FRC_MakeError(err::NullParameter, "value");
|
||||
}
|
||||
auto name = SendableRegistry::GetInstance().GetName(value);
|
||||
if (!name.empty()) {
|
||||
@@ -118,8 +116,7 @@ Sendable* SmartDashboard::GetData(wpi::StringRef key) {
|
||||
std::scoped_lock lock(inst.tablesToDataMutex);
|
||||
auto it = inst.tablesToData.find(key);
|
||||
if (it == inst.tablesToData.end()) {
|
||||
wpi_setGlobalWPIErrorWithContext(SmartDashboardMissingKey, key);
|
||||
return nullptr;
|
||||
throw FRC_MakeError(err::SmartDashboardMissingKey, key);
|
||||
}
|
||||
return SendableRegistry::GetInstance().GetSendable(it->getValue());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user