SCRIPT namespace replacements

This commit is contained in:
PJ Reiniger
2025-11-07 20:00:05 -05:00
committed by Peter Johnson
parent ae6c043632
commit 9aca8e0fd6
2622 changed files with 22275 additions and 22275 deletions

View File

@@ -10,7 +10,7 @@
#include "wpi/util/sendable/SendableBuilder.hpp"
#include "wpi/util/sendable/SendableRegistry.hpp"
using namespace frc;
using namespace wpi;
Compressor::Compressor(int busId, int module, PneumaticsModuleType moduleType)
: m_module{PneumaticsBase::GetForType(busId, module, moduleType)},
@@ -22,7 +22,7 @@ Compressor::Compressor(int busId, int module, PneumaticsModuleType moduleType)
m_module->EnableCompressorDigital();
m_module->ReportUsage("Compressor", "");
wpi::SendableRegistry::Add(this, "Compressor", module);
wpi::util::SendableRegistry::Add(this, "Compressor", module);
}
Compressor::Compressor(int busId, PneumaticsModuleType moduleType)
@@ -43,15 +43,15 @@ bool Compressor::GetPressureSwitchValue() const {
return m_module->GetPressureSwitch();
}
units::ampere_t Compressor::GetCurrent() const {
wpi::units::ampere_t Compressor::GetCurrent() const {
return m_module->GetCompressorCurrent();
}
units::volt_t Compressor::GetAnalogVoltage() const {
wpi::units::volt_t Compressor::GetAnalogVoltage() const {
return m_module->GetAnalogVoltage(0);
}
units::pounds_per_square_inch_t Compressor::GetPressure() const {
wpi::units::pounds_per_square_inch_t Compressor::GetPressure() const {
return m_module->GetPressure(0);
}
@@ -63,13 +63,13 @@ void Compressor::EnableDigital() {
m_module->EnableCompressorDigital();
}
void Compressor::EnableAnalog(units::pounds_per_square_inch_t minPressure,
units::pounds_per_square_inch_t maxPressure) {
void Compressor::EnableAnalog(wpi::units::pounds_per_square_inch_t minPressure,
wpi::units::pounds_per_square_inch_t maxPressure) {
m_module->EnableCompressorAnalog(minPressure, maxPressure);
}
void Compressor::EnableHybrid(units::pounds_per_square_inch_t minPressure,
units::pounds_per_square_inch_t maxPressure) {
void Compressor::EnableHybrid(wpi::units::pounds_per_square_inch_t minPressure,
wpi::units::pounds_per_square_inch_t maxPressure) {
m_module->EnableCompressorHybrid(minPressure, maxPressure);
}
@@ -77,7 +77,7 @@ CompressorConfigType Compressor::GetConfigType() const {
return m_module->GetCompressorConfigType();
}
void Compressor::InitSendable(wpi::SendableBuilder& builder) {
void Compressor::InitSendable(wpi::util::SendableBuilder& builder) {
builder.SetSmartDashboardType("Compressor");
builder.AddBooleanProperty(
"Enabled", [this] { return IsEnabled(); }, nullptr);

View File

@@ -13,7 +13,7 @@
#include "wpi/util/sendable/SendableBuilder.hpp"
#include "wpi/util/sendable/SendableRegistry.hpp"
using namespace frc;
using namespace wpi;
DoubleSolenoid::DoubleSolenoid(int busId, int module,
PneumaticsModuleType moduleType,
@@ -52,7 +52,7 @@ DoubleSolenoid::DoubleSolenoid(int busId, int module,
fmt::format("Solenoid[{},{}]", m_forwardChannel, m_reverseChannel),
"DoubleSolenoid");
wpi::SendableRegistry::Add(this, "DoubleSolenoid",
wpi::util::SendableRegistry::Add(this, "DoubleSolenoid",
m_module->GetModuleNumber(), m_forwardChannel);
}
@@ -123,12 +123,12 @@ bool DoubleSolenoid::IsRevSolenoidDisabled() const {
return (m_module->GetSolenoidDisabledList() & m_reverseMask) != 0;
}
void DoubleSolenoid::InitSendable(wpi::SendableBuilder& builder) {
void DoubleSolenoid::InitSendable(wpi::util::SendableBuilder& builder) {
builder.SetSmartDashboardType("Double Solenoid");
builder.SetActuator(true);
builder.AddSmallStringProperty(
"Value",
[=, this](wpi::SmallVectorImpl<char>& buf) -> std::string_view {
[=, this](wpi::util::SmallVectorImpl<char>& buf) -> std::string_view {
switch (Get()) {
case kForward:
return "Forward";

View File

@@ -23,24 +23,24 @@
#include "wpi/util/SensorUtil.hpp"
#include "wpi/util/StackTrace.hpp"
using namespace frc;
using namespace wpi;
/** Converts volts to PSI per the REV Analog Pressure Sensor datasheet. */
units::pounds_per_square_inch_t VoltsToPSI(units::volt_t sensorVoltage,
units::volt_t supplyVoltage) {
return units::pounds_per_square_inch_t{
wpi::units::pounds_per_square_inch_t VoltsToPSI(wpi::units::volt_t sensorVoltage,
wpi::units::volt_t supplyVoltage) {
return wpi::units::pounds_per_square_inch_t{
250 * (sensorVoltage.value() / supplyVoltage.value()) - 25};
}
/** Converts PSI to volts per the REV Analog Pressure Sensor datasheet. */
units::volt_t PSIToVolts(units::pounds_per_square_inch_t pressure,
units::volt_t supplyVoltage) {
return units::volt_t{supplyVoltage.value() *
wpi::units::volt_t PSIToVolts(wpi::units::pounds_per_square_inch_t pressure,
wpi::units::volt_t supplyVoltage) {
return wpi::units::volt_t{supplyVoltage.value() *
(0.004 * pressure.value() + 0.1)};
}
wpi::mutex PneumaticHub::m_handleLock;
std::unique_ptr<wpi::DenseMap<int, std::weak_ptr<PneumaticHub::DataStore>>[]>
wpi::util::mutex PneumaticHub::m_handleLock;
std::unique_ptr<wpi::util::DenseMap<int, std::weak_ptr<PneumaticHub::DataStore>>[]>
PneumaticHub::m_handleMaps = nullptr;
// Always called under lock, so we can avoid the double lock from the magic
@@ -52,7 +52,7 @@ std::weak_ptr<PneumaticHub::DataStore>& PneumaticHub::GetDataStore(int busId,
"Bus {} out of range. Must be [0-{}).", busId, numBuses);
if (!m_handleMaps) {
m_handleMaps = std::make_unique<
wpi::DenseMap<int, std::weak_ptr<PneumaticHub::DataStore>>[]>(numBuses);
wpi::util::DenseMap<int, std::weak_ptr<PneumaticHub::DataStore>>[]>(numBuses);
}
return m_handleMaps[busId][module];
}
@@ -66,7 +66,7 @@ class PneumaticHub::DataStore {
FRC_CheckErrorStatus(status, "Module {}", module);
m_moduleObject = PneumaticHub{busId, handle, module};
m_moduleObject.m_dataStore =
std::shared_ptr<DataStore>{this, wpi::NullDeleter<DataStore>()};
std::shared_ptr<DataStore>{this, wpi::util::NullDeleter<DataStore>()};
auto version = m_moduleObject.GetVersion();
@@ -89,16 +89,16 @@ class PneumaticHub::DataStore {
friend class PneumaticHub;
uint32_t m_reservedMask{0};
bool m_compressorReserved{false};
wpi::mutex m_reservedLock;
wpi::util::mutex m_reservedLock;
PneumaticHub m_moduleObject{0, HAL_kInvalidHandle, 0};
std::array<units::millisecond_t, 16> m_oneShotDurMs{0_ms};
std::array<wpi::units::millisecond_t, 16> m_oneShotDurMs{0_ms};
};
PneumaticHub::PneumaticHub(int busId)
: PneumaticHub{busId, SensorUtil::GetDefaultREVPHModule()} {}
PneumaticHub::PneumaticHub(int busId, int module) {
std::string stackTrace = wpi::GetStackTrace(1);
std::string stackTrace = wpi::util::GetStackTrace(1);
std::scoped_lock lock(m_handleLock);
auto& res = GetDataStore(busId, module);
m_dataStore = res.lock();
@@ -134,8 +134,8 @@ void PneumaticHub::EnableCompressorDigital() {
}
void PneumaticHub::EnableCompressorAnalog(
units::pounds_per_square_inch_t minPressure,
units::pounds_per_square_inch_t maxPressure) {
wpi::units::pounds_per_square_inch_t minPressure,
wpi::units::pounds_per_square_inch_t maxPressure) {
if (minPressure >= maxPressure) {
throw FRC_MakeError(err::InvalidParameter,
"maxPressure must be greater than minPressure");
@@ -154,8 +154,8 @@ void PneumaticHub::EnableCompressorAnalog(
// Send the voltage as it would be if the 5V rail was at exactly 5V.
// The firmware will compensate for the real 5V rail voltage, which
// can fluctuate somewhat over time.
units::volt_t minAnalogVoltage = PSIToVolts(minPressure, 5_V);
units::volt_t maxAnalogVoltage = PSIToVolts(maxPressure, 5_V);
wpi::units::volt_t minAnalogVoltage = PSIToVolts(minPressure, 5_V);
wpi::units::volt_t maxAnalogVoltage = PSIToVolts(maxPressure, 5_V);
int32_t status = 0;
HAL_SetREVPHClosedLoopControlAnalog(m_handle, minAnalogVoltage.value(),
@@ -164,8 +164,8 @@ void PneumaticHub::EnableCompressorAnalog(
}
void PneumaticHub::EnableCompressorHybrid(
units::pounds_per_square_inch_t minPressure,
units::pounds_per_square_inch_t maxPressure) {
wpi::units::pounds_per_square_inch_t minPressure,
wpi::units::pounds_per_square_inch_t maxPressure) {
if (minPressure >= maxPressure) {
throw FRC_MakeError(err::InvalidParameter,
"maxPressure must be greater than minPressure");
@@ -184,8 +184,8 @@ void PneumaticHub::EnableCompressorHybrid(
// Send the voltage as it would be if the 5V rail was at exactly 5V.
// The firmware will compensate for the real 5V rail voltage, which
// can fluctuate somewhat over time.
units::volt_t minAnalogVoltage = PSIToVolts(minPressure, 5_V);
units::volt_t maxAnalogVoltage = PSIToVolts(maxPressure, 5_V);
wpi::units::volt_t minAnalogVoltage = PSIToVolts(minPressure, 5_V);
wpi::units::volt_t maxAnalogVoltage = PSIToVolts(maxPressure, 5_V);
int32_t status = 0;
HAL_SetREVPHClosedLoopControlHybrid(m_handle, minAnalogVoltage.value(),
@@ -207,11 +207,11 @@ bool PneumaticHub::GetPressureSwitch() const {
return result;
}
units::ampere_t PneumaticHub::GetCompressorCurrent() const {
wpi::units::ampere_t PneumaticHub::GetCompressorCurrent() const {
int32_t status = 0;
auto result = HAL_GetREVPHCompressorCurrent(m_handle, &status);
FRC_ReportError(status, "Module {}", m_module);
return units::ampere_t{result};
return wpi::units::ampere_t{result};
}
void PneumaticHub::SetSolenoids(int mask, int values) {
@@ -245,7 +245,7 @@ void PneumaticHub::FireOneShot(int index) {
FRC_ReportError(status, "Module {}", m_module);
}
void PneumaticHub::SetOneShotDuration(int index, units::second_t duration) {
void PneumaticHub::SetOneShotDuration(int index, wpi::units::second_t duration) {
m_dataStore->m_oneShotDurMs[index] = duration;
}
@@ -370,48 +370,48 @@ void PneumaticHub::ClearStickyFaults() {
FRC_ReportError(status, "Module {}", m_module);
}
units::volt_t PneumaticHub::GetInputVoltage() const {
wpi::units::volt_t PneumaticHub::GetInputVoltage() const {
int32_t status = 0;
auto voltage = HAL_GetREVPHVoltage(m_handle, &status);
FRC_ReportError(status, "Module {}", m_module);
return units::volt_t{voltage};
return wpi::units::volt_t{voltage};
}
units::volt_t PneumaticHub::Get5VRegulatedVoltage() const {
wpi::units::volt_t PneumaticHub::Get5VRegulatedVoltage() const {
int32_t status = 0;
auto voltage = HAL_GetREVPH5VVoltage(m_handle, &status);
FRC_ReportError(status, "Module {}", m_module);
return units::volt_t{voltage};
return wpi::units::volt_t{voltage};
}
units::ampere_t PneumaticHub::GetSolenoidsTotalCurrent() const {
wpi::units::ampere_t PneumaticHub::GetSolenoidsTotalCurrent() const {
int32_t status = 0;
auto current = HAL_GetREVPHSolenoidCurrent(m_handle, &status);
FRC_ReportError(status, "Module {}", m_module);
return units::ampere_t{current};
return wpi::units::ampere_t{current};
}
units::volt_t PneumaticHub::GetSolenoidsVoltage() const {
wpi::units::volt_t PneumaticHub::GetSolenoidsVoltage() const {
int32_t status = 0;
auto voltage = HAL_GetREVPHSolenoidVoltage(m_handle, &status);
FRC_ReportError(status, "Module {}", m_module);
return units::volt_t{voltage};
return wpi::units::volt_t{voltage};
}
units::volt_t PneumaticHub::GetAnalogVoltage(int channel) const {
wpi::units::volt_t PneumaticHub::GetAnalogVoltage(int channel) const {
int32_t status = 0;
auto voltage = HAL_GetREVPHAnalogVoltage(m_handle, channel, &status);
FRC_ReportError(status, "Module {}", m_module);
return units::volt_t{voltage};
return wpi::units::volt_t{voltage};
}
units::pounds_per_square_inch_t PneumaticHub::GetPressure(int channel) const {
wpi::units::pounds_per_square_inch_t PneumaticHub::GetPressure(int channel) const {
int32_t status = 0;
auto sensorVoltage = HAL_GetREVPHAnalogVoltage(m_handle, channel, &status);
FRC_ReportError(status, "Module {}", m_module);
auto supplyVoltage = HAL_GetREVPH5VVoltage(m_handle, &status);
FRC_ReportError(status, "Module {}", m_module);
return VoltsToPSI(units::volt_t{sensorVoltage}, units::volt_t{supplyVoltage});
return VoltsToPSI(wpi::units::volt_t{sensorVoltage}, wpi::units::volt_t{supplyVoltage});
}
Solenoid PneumaticHub::MakeSolenoid(int channel) {
@@ -434,7 +434,7 @@ void PneumaticHub::ReportUsage(std::string_view device, std::string_view data) {
std::shared_ptr<PneumaticsBase> PneumaticHub::GetForModule(int busId,
int module) {
std::string stackTrace = wpi::GetStackTrace(1);
std::string stackTrace = wpi::util::GetStackTrace(1);
std::scoped_lock lock(m_handleLock);
auto& res = GetDataStore(busId, module);
std::shared_ptr<DataStore> dataStore = res.lock();

View File

@@ -12,7 +12,7 @@
#include "wpi/system/Errors.hpp"
#include "wpi/util/SensorUtil.hpp"
using namespace frc;
using namespace wpi;
static_assert(
static_cast<int>(CompressorConfigType::Disabled) ==

View File

@@ -20,11 +20,11 @@
#include "wpi/util/SensorUtil.hpp"
#include "wpi/util/StackTrace.hpp"
using namespace frc;
using namespace wpi;
wpi::mutex PneumaticsControlModule::m_handleLock;
wpi::util::mutex PneumaticsControlModule::m_handleLock;
std::unique_ptr<
wpi::DenseMap<int, std::weak_ptr<PneumaticsControlModule::DataStore>>[]>
wpi::util::DenseMap<int, std::weak_ptr<PneumaticsControlModule::DataStore>>[]>
PneumaticsControlModule::m_handleMaps = nullptr;
// Always called under lock, so we can avoid the double lock from the magic
@@ -35,7 +35,7 @@ PneumaticsControlModule::GetDataStore(int busId, int module) {
FRC_AssertMessage(busId >= 0 && busId < numBuses,
"Bus {} out of range. Must be [0-{}).", busId, numBuses);
if (!m_handleMaps) {
m_handleMaps = std::make_unique<wpi::DenseMap<
m_handleMaps = std::make_unique<wpi::util::DenseMap<
int, std::weak_ptr<PneumaticsControlModule::DataStore>>[]>(numBuses);
}
@@ -51,7 +51,7 @@ class PneumaticsControlModule::DataStore {
FRC_CheckErrorStatus(status, "Module {}", module);
m_moduleObject = PneumaticsControlModule{busId, handle, module};
m_moduleObject.m_dataStore =
std::shared_ptr<DataStore>{this, wpi::NullDeleter<DataStore>()};
std::shared_ptr<DataStore>{this, wpi::util::NullDeleter<DataStore>()};
}
~DataStore() noexcept { HAL_FreeCTREPCM(m_moduleObject.m_handle); }
@@ -63,7 +63,7 @@ class PneumaticsControlModule::DataStore {
friend class PneumaticsControlModule;
uint32_t m_reservedMask{0};
bool m_compressorReserved{false};
wpi::mutex m_reservedLock;
wpi::util::mutex m_reservedLock;
PneumaticsControlModule m_moduleObject{0, HAL_kInvalidHandle, 0};
};
@@ -71,7 +71,7 @@ PneumaticsControlModule::PneumaticsControlModule(int busId)
: PneumaticsControlModule{busId, SensorUtil::GetDefaultCTREPCMModule()} {}
PneumaticsControlModule::PneumaticsControlModule(int busId, int module) {
std::string stackTrace = wpi::GetStackTrace(1);
std::string stackTrace = wpi::util::GetStackTrace(1);
std::scoped_lock lock(m_handleLock);
auto& res = GetDataStore(busId, module);
m_dataStore = res.lock();
@@ -109,16 +109,16 @@ void PneumaticsControlModule::EnableCompressorDigital() {
}
void PneumaticsControlModule::EnableCompressorAnalog(
units::pounds_per_square_inch_t minPressure,
units::pounds_per_square_inch_t maxPressure) {
wpi::units::pounds_per_square_inch_t minPressure,
wpi::units::pounds_per_square_inch_t maxPressure) {
int32_t status = 0;
HAL_SetCTREPCMClosedLoopControl(m_handle, true, &status);
FRC_ReportError(status, "Module {}", m_module);
}
void PneumaticsControlModule::EnableCompressorHybrid(
units::pounds_per_square_inch_t minPressure,
units::pounds_per_square_inch_t maxPressure) {
wpi::units::pounds_per_square_inch_t minPressure,
wpi::units::pounds_per_square_inch_t maxPressure) {
int32_t status = 0;
HAL_SetCTREPCMClosedLoopControl(m_handle, true, &status);
FRC_ReportError(status, "Module {}", m_module);
@@ -139,11 +139,11 @@ bool PneumaticsControlModule::GetPressureSwitch() const {
return result;
}
units::ampere_t PneumaticsControlModule::GetCompressorCurrent() const {
wpi::units::ampere_t PneumaticsControlModule::GetCompressorCurrent() const {
int32_t status = 0;
auto result = HAL_GetCTREPCMCompressorCurrent(m_handle, &status);
FRC_ReportError(status, "Module {}", m_module);
return units::ampere_t{result};
return wpi::units::ampere_t{result};
}
bool PneumaticsControlModule::GetCompressorCurrentTooHighFault() const {
@@ -235,9 +235,9 @@ void PneumaticsControlModule::FireOneShot(int index) {
}
void PneumaticsControlModule::SetOneShotDuration(int index,
units::second_t duration) {
wpi::units::second_t duration) {
int32_t status = 0;
units::millisecond_t millis = duration;
wpi::units::millisecond_t millis = duration;
HAL_SetCTREPCMOneShotDuration(m_handle, index, millis.to<int32_t>(), &status);
FRC_ReportError(status, "Module {}", m_module);
}
@@ -275,11 +275,11 @@ void PneumaticsControlModule::UnreserveCompressor() {
m_dataStore->m_compressorReserved = false;
}
units::volt_t PneumaticsControlModule::GetAnalogVoltage(int channel) const {
wpi::units::volt_t PneumaticsControlModule::GetAnalogVoltage(int channel) const {
return 0_V;
}
units::pounds_per_square_inch_t PneumaticsControlModule::GetPressure(
wpi::units::pounds_per_square_inch_t PneumaticsControlModule::GetPressure(
int channel) const {
return 0_psi;
}
@@ -305,7 +305,7 @@ void PneumaticsControlModule::ReportUsage(std::string_view device,
std::shared_ptr<PneumaticsBase> PneumaticsControlModule::GetForModule(
int busId, int module) {
std::string stackTrace = wpi::GetStackTrace(1);
std::string stackTrace = wpi::util::GetStackTrace(1);
std::scoped_lock lock(m_handleLock);
auto& res = GetDataStore(busId, module);
std::shared_ptr<DataStore> dataStore = res.lock();

View File

@@ -12,7 +12,7 @@
#include "wpi/util/sendable/SendableBuilder.hpp"
#include "wpi/util/sendable/SendableRegistry.hpp"
using namespace frc;
using namespace wpi;
Solenoid::Solenoid(int busId, int module, PneumaticsModuleType moduleType,
int channel)
@@ -28,7 +28,7 @@ Solenoid::Solenoid(int busId, int module, PneumaticsModuleType moduleType,
}
m_module->ReportUsage(fmt::format("Solenoid[{}]", m_channel), "Solenoid");
wpi::SendableRegistry::Add(this, "Solenoid", m_module->GetModuleNumber(),
wpi::util::SendableRegistry::Add(this, "Solenoid", m_module->GetModuleNumber(),
m_channel);
}
@@ -64,7 +64,7 @@ bool Solenoid::IsDisabled() const {
return (m_module->GetSolenoidDisabledList() & m_mask) != 0;
}
void Solenoid::SetPulseDuration(units::second_t duration) {
void Solenoid::SetPulseDuration(wpi::units::second_t duration) {
m_module->SetOneShotDuration(m_channel, duration);
}
@@ -72,7 +72,7 @@ void Solenoid::StartPulse() {
m_module->FireOneShot(m_channel);
}
void Solenoid::InitSendable(wpi::SendableBuilder& builder) {
void Solenoid::InitSendable(wpi::util::SendableBuilder& builder) {
builder.SetSmartDashboardType("Solenoid");
builder.SetActuator(true);
builder.AddBooleanProperty(