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
@@ -17,7 +17,7 @@
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
#include "wpi/util/sendable/SendableRegistry.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
AnalogInput::AnalogInput(int channel) {
|
||||
if (!SensorUtil::CheckAnalogInputChannel(channel)) {
|
||||
@@ -26,13 +26,13 @@ AnalogInput::AnalogInput(int channel) {
|
||||
|
||||
m_channel = channel;
|
||||
int32_t status = 0;
|
||||
std::string stackTrace = wpi::GetStackTrace(1);
|
||||
std::string stackTrace = wpi::util::GetStackTrace(1);
|
||||
m_port = HAL_InitializeAnalogInputPort(channel, stackTrace.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", channel);
|
||||
|
||||
HAL_ReportUsage("IO", channel, "AnalogInput");
|
||||
|
||||
wpi::SendableRegistry::Add(this, "AnalogInput", channel);
|
||||
wpi::util::SendableRegistry::Add(this, "AnalogInput", channel);
|
||||
}
|
||||
|
||||
int AnalogInput::GetValue() const {
|
||||
@@ -124,7 +124,7 @@ void AnalogInput::SetSimDevice(HAL_SimDeviceHandle device) {
|
||||
HAL_SetAnalogInputSimDevice(m_port, device);
|
||||
}
|
||||
|
||||
void AnalogInput::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void AnalogInput::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Analog Input");
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=, this] { return GetAverageVoltage(); }, nullptr);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
#include "wpi/util/sendable/SendableRegistry.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
DigitalInput::DigitalInput(int channel) {
|
||||
if (!SensorUtil::CheckDigitalChannel(channel)) {
|
||||
@@ -25,12 +25,12 @@ DigitalInput::DigitalInput(int channel) {
|
||||
m_channel = channel;
|
||||
|
||||
int32_t status = 0;
|
||||
std::string stackTrace = wpi::GetStackTrace(1);
|
||||
std::string stackTrace = wpi::util::GetStackTrace(1);
|
||||
m_handle = HAL_InitializeDIOPort(channel, true, stackTrace.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", channel);
|
||||
|
||||
HAL_ReportUsage("IO", channel, "DigitalInput");
|
||||
wpi::SendableRegistry::Add(this, "DigitalInput", channel);
|
||||
wpi::util::SendableRegistry::Add(this, "DigitalInput", channel);
|
||||
}
|
||||
|
||||
bool DigitalInput::Get() const {
|
||||
@@ -48,7 +48,7 @@ int DigitalInput::GetChannel() const {
|
||||
return m_channel;
|
||||
}
|
||||
|
||||
void DigitalInput::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void DigitalInput::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Digital Input");
|
||||
builder.AddBooleanProperty("Value", [=, this] { return Get(); }, nullptr);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
#include "wpi/util/sendable/SendableRegistry.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
DigitalOutput::DigitalOutput(int channel) {
|
||||
m_pwmGenerator = HAL_kInvalidHandle;
|
||||
@@ -26,12 +26,12 @@ DigitalOutput::DigitalOutput(int channel) {
|
||||
m_channel = channel;
|
||||
|
||||
int32_t status = 0;
|
||||
std::string stackTrace = wpi::GetStackTrace(1);
|
||||
std::string stackTrace = wpi::util::GetStackTrace(1);
|
||||
m_handle = HAL_InitializeDIOPort(channel, false, stackTrace.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", channel);
|
||||
|
||||
HAL_ReportUsage("IO", channel, "DigitalOutput");
|
||||
wpi::SendableRegistry::Add(this, "DigitalOutput", channel);
|
||||
wpi::util::SendableRegistry::Add(this, "DigitalOutput", channel);
|
||||
}
|
||||
|
||||
DigitalOutput::~DigitalOutput() {
|
||||
@@ -62,7 +62,7 @@ int DigitalOutput::GetChannel() const {
|
||||
return m_channel;
|
||||
}
|
||||
|
||||
void DigitalOutput::Pulse(units::second_t pulseLength) {
|
||||
void DigitalOutput::Pulse(wpi::units::second_t pulseLength) {
|
||||
int32_t status = 0;
|
||||
HAL_Pulse(m_handle, pulseLength.value(), &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
@@ -142,7 +142,7 @@ void DigitalOutput::SetSimDevice(HAL_SimDeviceHandle device) {
|
||||
HAL_SetDIOSimDevice(m_handle, device);
|
||||
}
|
||||
|
||||
void DigitalOutput::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void DigitalOutput::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("Digital Output");
|
||||
builder.AddBooleanProperty(
|
||||
"Value", [=, this] { return Get(); },
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
#include "wpi/util/sendable/SendableRegistry.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
PWM::PWM(int channel, bool registerSendable) {
|
||||
if (!SensorUtil::CheckPWMChannel(channel)) {
|
||||
throw FRC_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
}
|
||||
|
||||
auto stack = wpi::GetStackTrace(1);
|
||||
auto stack = wpi::util::GetStackTrace(1);
|
||||
int32_t status = 0;
|
||||
m_handle = HAL_InitializePWMPort(channel, stack.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", channel);
|
||||
@@ -34,7 +34,7 @@ PWM::PWM(int channel, bool registerSendable) {
|
||||
|
||||
HAL_ReportUsage("IO", channel, "PWM");
|
||||
if (registerSendable) {
|
||||
wpi::SendableRegistry::Add(this, "PWM", channel);
|
||||
wpi::util::SendableRegistry::Add(this, "PWM", channel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,18 +44,18 @@ PWM::~PWM() {
|
||||
}
|
||||
}
|
||||
|
||||
void PWM::SetPulseTime(units::microsecond_t time) {
|
||||
void PWM::SetPulseTime(wpi::units::microsecond_t time) {
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMPulseTimeMicroseconds(m_handle, time.value(), &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
}
|
||||
|
||||
units::microsecond_t PWM::GetPulseTime() const {
|
||||
wpi::units::microsecond_t PWM::GetPulseTime() const {
|
||||
int32_t status = 0;
|
||||
double value = HAL_GetPWMPulseTimeMicroseconds(m_handle, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
|
||||
return units::microsecond_t{value};
|
||||
return wpi::units::microsecond_t{value};
|
||||
}
|
||||
|
||||
void PWM::SetDisabled() {
|
||||
@@ -96,10 +96,10 @@ void PWM::SetSimDevice(HAL_SimDeviceHandle device) {
|
||||
HAL_SetPWMSimDevice(m_handle, device);
|
||||
}
|
||||
|
||||
void PWM::InitSendable(wpi::SendableBuilder& builder) {
|
||||
void PWM::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("PWM");
|
||||
builder.SetActuator(true);
|
||||
builder.AddDoubleProperty(
|
||||
"Value", [=, this] { return GetPulseTime().value(); },
|
||||
[=, this](double value) { SetPulseTime(units::millisecond_t{value}); });
|
||||
[=, this](double value) { SetPulseTime(wpi::units::millisecond_t{value}); });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user