mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -20,7 +20,7 @@
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
#include "wpi/util/sendable/SendableRegistry.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
class Alert::PublishedAlert {
|
||||
public:
|
||||
@@ -37,12 +37,12 @@ class Alert::PublishedAlert {
|
||||
}
|
||||
};
|
||||
|
||||
class Alert::SendableAlerts : public nt::NTSendable,
|
||||
public wpi::SendableHelper<SendableAlerts> {
|
||||
class Alert::SendableAlerts : public wpi::nt::NTSendable,
|
||||
public wpi::util::SendableHelper<SendableAlerts> {
|
||||
public:
|
||||
SendableAlerts() { m_alerts.fill({}); }
|
||||
|
||||
void InitSendable(nt::NTSendableBuilder& builder) override {
|
||||
void InitSendable(wpi::nt::NTSendableBuilder& builder) override {
|
||||
builder.SetSmartDashboardType("Alerts");
|
||||
builder.AddStringArrayProperty(
|
||||
"errors", [this]() { return GetStrings(AlertType::kError); }, nullptr);
|
||||
@@ -70,7 +70,7 @@ class Alert::SendableAlerts : public nt::NTSendable,
|
||||
case AlertType::kError:
|
||||
return m_alerts[static_cast<int32_t>(type)];
|
||||
default:
|
||||
throw FRC_MakeError(frc::err::InvalidParameter,
|
||||
throw FRC_MakeError(wpi::err::InvalidParameter,
|
||||
"Invalid Alert Type: {}", type);
|
||||
}
|
||||
}
|
||||
@@ -84,14 +84,14 @@ class Alert::SendableAlerts : public nt::NTSendable,
|
||||
static SendableAlerts& ForGroup(std::string_view group) {
|
||||
SendableAlerts* salert = nullptr;
|
||||
try {
|
||||
auto* sendable = frc::SmartDashboard::GetData(group);
|
||||
auto* sendable = wpi::SmartDashboard::GetData(group);
|
||||
salert = dynamic_cast<SendableAlerts*>(sendable);
|
||||
} catch (frc::RuntimeError&) {
|
||||
} catch (wpi::RuntimeError&) {
|
||||
}
|
||||
if (!salert) {
|
||||
// this leaks if ResetSmartDashboardInstance is called, but that's fine
|
||||
salert = new Alert::SendableAlerts;
|
||||
frc::SmartDashboard::PutData(group, salert);
|
||||
wpi::SmartDashboard::PutData(group, salert);
|
||||
}
|
||||
return *salert;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ void Alert::Set(bool active) {
|
||||
}
|
||||
|
||||
if (active) {
|
||||
m_activeStartTime = frc::RobotController::GetTime();
|
||||
m_activeStartTime = wpi::RobotController::GetTime();
|
||||
m_activeAlerts->emplace(m_activeStartTime, m_text);
|
||||
} else {
|
||||
m_activeAlerts->erase({m_activeStartTime, m_text});
|
||||
@@ -173,7 +173,7 @@ void Alert::SetText(std::string_view text) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string frc::format_as(Alert::AlertType type) {
|
||||
std::string wpi::format_as(Alert::AlertType type) {
|
||||
switch (type) {
|
||||
case Alert::AlertType::kInfo:
|
||||
return "kInfo";
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "wpi/nt/StringTopic.hpp"
|
||||
#include "wpi/util/json.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
// The Preferences table name
|
||||
static constexpr std::string_view kTableName{"Preferences"};
|
||||
@@ -27,13 +27,13 @@ namespace {
|
||||
struct Instance {
|
||||
Instance();
|
||||
|
||||
std::shared_ptr<nt::NetworkTable> table{
|
||||
nt::NetworkTableInstance::GetDefault().GetTable(kTableName)};
|
||||
nt::StringPublisher typePublisher{table->GetStringTopic(".type").PublishEx(
|
||||
nt::StringTopic::kTypeString, {{"SmartDashboard", kSmartDashboardType}})};
|
||||
nt::MultiSubscriber tableSubscriber{nt::NetworkTableInstance::GetDefault(),
|
||||
std::shared_ptr<wpi::nt::NetworkTable> table{
|
||||
wpi::nt::NetworkTableInstance::GetDefault().GetTable(kTableName)};
|
||||
wpi::nt::StringPublisher typePublisher{table->GetStringTopic(".type").PublishEx(
|
||||
wpi::nt::StringTopic::kTypeString, {{"SmartDashboard", kSmartDashboardType}})};
|
||||
wpi::nt::MultiSubscriber tableSubscriber{wpi::nt::NetworkTableInstance::GetDefault(),
|
||||
{{fmt::format("{}/", table->GetPath())}}};
|
||||
nt::NetworkTableListener listener;
|
||||
wpi::nt::NetworkTableListener listener;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -43,11 +43,11 @@ static Instance& GetInstance() {
|
||||
}
|
||||
|
||||
#ifndef __FRC_SYSTEMCORE__
|
||||
namespace frc::impl {
|
||||
namespace wpi::impl {
|
||||
void ResetPreferencesInstance() {
|
||||
GetInstance() = Instance();
|
||||
}
|
||||
} // namespace frc::impl
|
||||
} // namespace wpi::impl
|
||||
#endif
|
||||
|
||||
std::vector<std::string> Preferences::GetKeys() {
|
||||
@@ -171,12 +171,12 @@ void Preferences::RemoveAll() {
|
||||
|
||||
Instance::Instance() {
|
||||
typePublisher.Set(kSmartDashboardType);
|
||||
listener = nt::NetworkTableListener::CreateListener(
|
||||
listener = wpi::nt::NetworkTableListener::CreateListener(
|
||||
tableSubscriber, NT_EVENT_PUBLISH | NT_EVENT_IMMEDIATE,
|
||||
[typeTopic = typePublisher.GetTopic().GetHandle()](auto& event) {
|
||||
if (auto topicInfo = event.GetTopicInfo()) {
|
||||
if (topicInfo->topic != typeTopic) {
|
||||
nt::SetTopicPersistent(topicInfo->topic, true);
|
||||
wpi::nt::SetTopicPersistent(topicInfo->topic, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/hal/PWM.h"
|
||||
#include "wpi/hal/Ports.h"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
int SensorUtil::GetDefaultCTREPCMModule() {
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user