mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
SCRIPT: FRC_ replacements
This commit is contained in:
committed by
Peter Johnson
parent
824f36f63a
commit
928ff20695
@@ -20,7 +20,7 @@ AnalogAccelerometer::AnalogAccelerometer(int channel)
|
||||
AnalogAccelerometer::AnalogAccelerometer(AnalogInput* channel)
|
||||
: m_analogInput(channel, wpi::util::NullDeleter<AnalogInput>()) {
|
||||
if (!channel) {
|
||||
throw FRC_MakeError(err::NullParameter, "channel");
|
||||
throw WPILIB_MakeError(err::NullParameter, "channel");
|
||||
}
|
||||
InitAccelerometer();
|
||||
}
|
||||
@@ -28,7 +28,7 @@ AnalogAccelerometer::AnalogAccelerometer(AnalogInput* channel)
|
||||
AnalogAccelerometer::AnalogAccelerometer(std::shared_ptr<AnalogInput> channel)
|
||||
: m_analogInput(channel) {
|
||||
if (!channel) {
|
||||
throw FRC_MakeError(err::NullParameter, "channel");
|
||||
throw WPILIB_MakeError(err::NullParameter, "channel");
|
||||
}
|
||||
InitAccelerometer();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ CAN::CAN(int busId, int deviceId, int deviceManufacturer, int deviceType) {
|
||||
m_handle = HAL_InitializeCAN(
|
||||
busId, static_cast<HAL_CANManufacturer>(deviceManufacturer), deviceId,
|
||||
static_cast<HAL_CANDeviceType>(deviceType), &status);
|
||||
FRC_CheckErrorStatus(status, "device id {} mfg {} type {}", deviceId,
|
||||
WPILIB_CheckErrorStatus(status, "device id {} mfg {} type {}", deviceId,
|
||||
deviceManufacturer, deviceType);
|
||||
|
||||
HAL_ReportUsage(
|
||||
@@ -33,20 +33,20 @@ CAN::CAN(int busId, int deviceId, int deviceManufacturer, int deviceType) {
|
||||
void CAN::WritePacket(int apiId, const HAL_CANMessage& message) {
|
||||
int32_t status = 0;
|
||||
HAL_WriteCANPacket(m_handle, apiId, &message, &status);
|
||||
FRC_CheckErrorStatus(status, "WritePacket");
|
||||
WPILIB_CheckErrorStatus(status, "WritePacket");
|
||||
}
|
||||
|
||||
void CAN::WritePacketRepeating(int apiId, const HAL_CANMessage& message,
|
||||
int repeatMs) {
|
||||
int32_t status = 0;
|
||||
HAL_WriteCANPacketRepeating(m_handle, apiId, &message, repeatMs, &status);
|
||||
FRC_CheckErrorStatus(status, "WritePacketRepeating");
|
||||
WPILIB_CheckErrorStatus(status, "WritePacketRepeating");
|
||||
}
|
||||
|
||||
void CAN::WriteRTRFrame(int apiId, const HAL_CANMessage& message) {
|
||||
int32_t status = 0;
|
||||
HAL_WriteCANRTRFrame(m_handle, apiId, &message, &status);
|
||||
FRC_CheckErrorStatus(status, "WriteRTRFrame");
|
||||
WPILIB_CheckErrorStatus(status, "WriteRTRFrame");
|
||||
}
|
||||
|
||||
int CAN::WritePacketNoError(int apiId, const HAL_CANMessage& message) {
|
||||
@@ -71,7 +71,7 @@ int CAN::WriteRTRFrameNoError(int apiId, const HAL_CANMessage& message) {
|
||||
void CAN::StopPacketRepeating(int apiId) {
|
||||
int32_t status = 0;
|
||||
HAL_StopCANPacketRepeating(m_handle, apiId, &status);
|
||||
FRC_CheckErrorStatus(status, "StopPacketRepeating");
|
||||
WPILIB_CheckErrorStatus(status, "StopPacketRepeating");
|
||||
}
|
||||
|
||||
bool CAN::ReadPacketNew(int apiId, HAL_CANReceiveMessage* data) {
|
||||
@@ -81,7 +81,7 @@ bool CAN::ReadPacketNew(int apiId, HAL_CANReceiveMessage* data) {
|
||||
return false;
|
||||
}
|
||||
if (status != 0) {
|
||||
FRC_CheckErrorStatus(status, "ReadPacketNew");
|
||||
WPILIB_CheckErrorStatus(status, "ReadPacketNew");
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -95,7 +95,7 @@ bool CAN::ReadPacketLatest(int apiId, HAL_CANReceiveMessage* data) {
|
||||
return false;
|
||||
}
|
||||
if (status != 0) {
|
||||
FRC_CheckErrorStatus(status, "ReadPacketLatest");
|
||||
WPILIB_CheckErrorStatus(status, "ReadPacketLatest");
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -111,7 +111,7 @@ bool CAN::ReadPacketTimeout(int apiId, int timeoutMs,
|
||||
return false;
|
||||
}
|
||||
if (status != 0) {
|
||||
FRC_CheckErrorStatus(status, "ReadPacketTimeout");
|
||||
WPILIB_CheckErrorStatus(status, "ReadPacketTimeout");
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
|
||||
@@ -17,7 +17,7 @@ I2C::I2C(Port port, int deviceAddress)
|
||||
int32_t status = 0;
|
||||
|
||||
HAL_InitializeI2C(m_port, &status);
|
||||
FRC_CheckErrorStatus(status, "Port {}", static_cast<int>(port));
|
||||
WPILIB_CheckErrorStatus(status, "Port {}", static_cast<int>(port));
|
||||
|
||||
HAL_ReportUsage(
|
||||
fmt::format("I2C[{}][{}]", static_cast<int>(port), deviceAddress), "");
|
||||
@@ -60,10 +60,10 @@ bool I2C::WriteBulk(uint8_t* data, int count) {
|
||||
|
||||
bool I2C::Read(int registerAddress, int count, uint8_t* buffer) {
|
||||
if (count < 1) {
|
||||
throw FRC_MakeError(err::ParameterOutOfRange, "count {}", count);
|
||||
throw WPILIB_MakeError(err::ParameterOutOfRange, "count {}", count);
|
||||
}
|
||||
if (!buffer) {
|
||||
throw FRC_MakeError(err::NullParameter, "buffer");
|
||||
throw WPILIB_MakeError(err::NullParameter, "buffer");
|
||||
}
|
||||
uint8_t regAddr = registerAddress;
|
||||
return Transaction(®Addr, sizeof(regAddr), buffer, count);
|
||||
@@ -71,10 +71,10 @@ bool I2C::Read(int registerAddress, int count, uint8_t* buffer) {
|
||||
|
||||
bool I2C::ReadOnly(int count, uint8_t* buffer) {
|
||||
if (count < 1) {
|
||||
throw FRC_MakeError(err::ParameterOutOfRange, "count {}", count);
|
||||
throw WPILIB_MakeError(err::ParameterOutOfRange, "count {}", count);
|
||||
}
|
||||
if (!buffer) {
|
||||
throw FRC_MakeError(err::NullParameter, "buffer");
|
||||
throw WPILIB_MakeError(err::NullParameter, "buffer");
|
||||
}
|
||||
return HAL_ReadI2C(m_port, m_deviceAddress, buffer, count) < 0;
|
||||
}
|
||||
|
||||
@@ -19,15 +19,15 @@ SerialPort::SerialPort(int baudRate, Port port, int dataBits,
|
||||
|
||||
m_portHandle =
|
||||
HAL_InitializeSerialPort(static_cast<HAL_SerialPort>(port), &status);
|
||||
FRC_CheckErrorStatus(status, "Port {}", static_cast<int>(port));
|
||||
WPILIB_CheckErrorStatus(status, "Port {}", static_cast<int>(port));
|
||||
HAL_SetSerialBaudRate(m_portHandle, baudRate, &status);
|
||||
FRC_CheckErrorStatus(status, "SetSerialBaudRate {}", baudRate);
|
||||
WPILIB_CheckErrorStatus(status, "SetSerialBaudRate {}", baudRate);
|
||||
HAL_SetSerialDataBits(m_portHandle, dataBits, &status);
|
||||
FRC_CheckErrorStatus(status, "SetSerialDataBits {}", dataBits);
|
||||
WPILIB_CheckErrorStatus(status, "SetSerialDataBits {}", dataBits);
|
||||
HAL_SetSerialParity(m_portHandle, parity, &status);
|
||||
FRC_CheckErrorStatus(status, "SetSerialParity {}", static_cast<int>(parity));
|
||||
WPILIB_CheckErrorStatus(status, "SetSerialParity {}", static_cast<int>(parity));
|
||||
HAL_SetSerialStopBits(m_portHandle, stopBits, &status);
|
||||
FRC_CheckErrorStatus(status, "SetSerialStopBits {}",
|
||||
WPILIB_CheckErrorStatus(status, "SetSerialStopBits {}",
|
||||
static_cast<int>(stopBits));
|
||||
|
||||
// Set the default timeout to 5 seconds.
|
||||
@@ -49,15 +49,15 @@ SerialPort::SerialPort(int baudRate, std::string_view portName, Port port,
|
||||
m_portHandle =
|
||||
HAL_InitializeSerialPortDirect(static_cast<HAL_SerialPort>(port),
|
||||
std::string(portName).c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Port {}", static_cast<int>(port));
|
||||
WPILIB_CheckErrorStatus(status, "Port {}", static_cast<int>(port));
|
||||
HAL_SetSerialBaudRate(m_portHandle, baudRate, &status);
|
||||
FRC_CheckErrorStatus(status, "SetSerialBaudRate {}", baudRate);
|
||||
WPILIB_CheckErrorStatus(status, "SetSerialBaudRate {}", baudRate);
|
||||
HAL_SetSerialDataBits(m_portHandle, dataBits, &status);
|
||||
FRC_CheckErrorStatus(status, "SetSerialDataBits {}", dataBits);
|
||||
WPILIB_CheckErrorStatus(status, "SetSerialDataBits {}", dataBits);
|
||||
HAL_SetSerialParity(m_portHandle, parity, &status);
|
||||
FRC_CheckErrorStatus(status, "SetSerialParity {}", static_cast<int>(parity));
|
||||
WPILIB_CheckErrorStatus(status, "SetSerialParity {}", static_cast<int>(parity));
|
||||
HAL_SetSerialStopBits(m_portHandle, stopBits, &status);
|
||||
FRC_CheckErrorStatus(status, "SetSerialStopBits {}",
|
||||
WPILIB_CheckErrorStatus(status, "SetSerialStopBits {}",
|
||||
static_cast<int>(stopBits));
|
||||
|
||||
// Set the default timeout to 5 seconds.
|
||||
@@ -74,33 +74,33 @@ SerialPort::SerialPort(int baudRate, std::string_view portName, Port port,
|
||||
void SerialPort::SetFlowControl(SerialPort::FlowControl flowControl) {
|
||||
int32_t status = 0;
|
||||
HAL_SetSerialFlowControl(m_portHandle, flowControl, &status);
|
||||
FRC_CheckErrorStatus(status, "SetFlowControl {}",
|
||||
WPILIB_CheckErrorStatus(status, "SetFlowControl {}",
|
||||
static_cast<int>(flowControl));
|
||||
}
|
||||
|
||||
void SerialPort::EnableTermination(char terminator) {
|
||||
int32_t status = 0;
|
||||
HAL_EnableSerialTermination(m_portHandle, terminator, &status);
|
||||
FRC_CheckErrorStatus(status, "EnableTermination {}", terminator);
|
||||
WPILIB_CheckErrorStatus(status, "EnableTermination {}", terminator);
|
||||
}
|
||||
|
||||
void SerialPort::DisableTermination() {
|
||||
int32_t status = 0;
|
||||
HAL_DisableSerialTermination(m_portHandle, &status);
|
||||
FRC_CheckErrorStatus(status, "DisableTermination");
|
||||
WPILIB_CheckErrorStatus(status, "DisableTermination");
|
||||
}
|
||||
|
||||
int SerialPort::GetBytesReceived() {
|
||||
int32_t status = 0;
|
||||
int retVal = HAL_GetSerialBytesReceived(m_portHandle, &status);
|
||||
FRC_CheckErrorStatus(status, "GetBytesReceived");
|
||||
WPILIB_CheckErrorStatus(status, "GetBytesReceived");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
int SerialPort::Read(char* buffer, int count) {
|
||||
int32_t status = 0;
|
||||
int retVal = HAL_ReadSerial(m_portHandle, buffer, count, &status);
|
||||
FRC_CheckErrorStatus(status, "Read");
|
||||
WPILIB_CheckErrorStatus(status, "Read");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -112,42 +112,42 @@ int SerialPort::Write(std::string_view buffer) {
|
||||
int32_t status = 0;
|
||||
int retVal =
|
||||
HAL_WriteSerial(m_portHandle, buffer.data(), buffer.size(), &status);
|
||||
FRC_CheckErrorStatus(status, "Write");
|
||||
WPILIB_CheckErrorStatus(status, "Write");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void SerialPort::SetTimeout(wpi::units::second_t timeout) {
|
||||
int32_t status = 0;
|
||||
HAL_SetSerialTimeout(m_portHandle, timeout.value(), &status);
|
||||
FRC_CheckErrorStatus(status, "SetTimeout");
|
||||
WPILIB_CheckErrorStatus(status, "SetTimeout");
|
||||
}
|
||||
|
||||
void SerialPort::SetReadBufferSize(int size) {
|
||||
int32_t status = 0;
|
||||
HAL_SetSerialReadBufferSize(m_portHandle, size, &status);
|
||||
FRC_CheckErrorStatus(status, "SetReadBufferSize {}", size);
|
||||
WPILIB_CheckErrorStatus(status, "SetReadBufferSize {}", size);
|
||||
}
|
||||
|
||||
void SerialPort::SetWriteBufferSize(int size) {
|
||||
int32_t status = 0;
|
||||
HAL_SetSerialWriteBufferSize(m_portHandle, size, &status);
|
||||
FRC_CheckErrorStatus(status, "SetWriteBufferSize {}", size);
|
||||
WPILIB_CheckErrorStatus(status, "SetWriteBufferSize {}", size);
|
||||
}
|
||||
|
||||
void SerialPort::SetWriteBufferMode(SerialPort::WriteBufferMode mode) {
|
||||
int32_t status = 0;
|
||||
HAL_SetSerialWriteMode(m_portHandle, mode, &status);
|
||||
FRC_CheckErrorStatus(status, "SetWriteBufferMode {}", static_cast<int>(mode));
|
||||
WPILIB_CheckErrorStatus(status, "SetWriteBufferMode {}", static_cast<int>(mode));
|
||||
}
|
||||
|
||||
void SerialPort::Flush() {
|
||||
int32_t status = 0;
|
||||
HAL_FlushSerial(m_portHandle, &status);
|
||||
FRC_CheckErrorStatus(status, "Flush");
|
||||
WPILIB_CheckErrorStatus(status, "Flush");
|
||||
}
|
||||
|
||||
void SerialPort::Reset() {
|
||||
int32_t status = 0;
|
||||
HAL_ClearSerial(m_portHandle, &status);
|
||||
FRC_CheckErrorStatus(status, "Reset");
|
||||
WPILIB_CheckErrorStatus(status, "Reset");
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ using namespace wpi;
|
||||
|
||||
AnalogInput::AnalogInput(int channel) {
|
||||
if (!SensorUtil::CheckAnalogInputChannel(channel)) {
|
||||
throw FRC_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
}
|
||||
|
||||
m_channel = channel;
|
||||
int32_t status = 0;
|
||||
std::string stackTrace = wpi::util::GetStackTrace(1);
|
||||
m_port = HAL_InitializeAnalogInputPort(channel, stackTrace.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", channel);
|
||||
|
||||
HAL_ReportUsage("IO", channel, "AnalogInput");
|
||||
|
||||
@@ -38,28 +38,28 @@ AnalogInput::AnalogInput(int channel) {
|
||||
int AnalogInput::GetValue() const {
|
||||
int32_t status = 0;
|
||||
int value = HAL_GetAnalogValue(m_port, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
return value;
|
||||
}
|
||||
|
||||
int AnalogInput::GetAverageValue() const {
|
||||
int32_t status = 0;
|
||||
int value = HAL_GetAnalogAverageValue(m_port, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
return value;
|
||||
}
|
||||
|
||||
double AnalogInput::GetVoltage() const {
|
||||
int32_t status = 0;
|
||||
double voltage = HAL_GetAnalogVoltage(m_port, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
return voltage;
|
||||
}
|
||||
|
||||
double AnalogInput::GetAverageVoltage() const {
|
||||
int32_t status = 0;
|
||||
double voltage = HAL_GetAnalogAverageVoltage(m_port, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
return voltage;
|
||||
}
|
||||
|
||||
@@ -70,53 +70,53 @@ int AnalogInput::GetChannel() const {
|
||||
void AnalogInput::SetAverageBits(int bits) {
|
||||
int32_t status = 0;
|
||||
HAL_SetAnalogAverageBits(m_port, bits, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
}
|
||||
|
||||
int AnalogInput::GetAverageBits() const {
|
||||
int32_t status = 0;
|
||||
int averageBits = HAL_GetAnalogAverageBits(m_port, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
return averageBits;
|
||||
}
|
||||
|
||||
void AnalogInput::SetOversampleBits(int bits) {
|
||||
int32_t status = 0;
|
||||
HAL_SetAnalogOversampleBits(m_port, bits, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
}
|
||||
|
||||
int AnalogInput::GetOversampleBits() const {
|
||||
int32_t status = 0;
|
||||
int oversampleBits = HAL_GetAnalogOversampleBits(m_port, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
return oversampleBits;
|
||||
}
|
||||
|
||||
int AnalogInput::GetLSBWeight() const {
|
||||
int32_t status = 0;
|
||||
int lsbWeight = HAL_GetAnalogLSBWeight(m_port, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
return lsbWeight;
|
||||
}
|
||||
|
||||
int AnalogInput::GetOffset() const {
|
||||
int32_t status = 0;
|
||||
int offset = HAL_GetAnalogOffset(m_port, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
return offset;
|
||||
}
|
||||
|
||||
void AnalogInput::SetSampleRate(double samplesPerSecond) {
|
||||
int32_t status = 0;
|
||||
HAL_SetAnalogSampleRate(samplesPerSecond, &status);
|
||||
FRC_CheckErrorStatus(status, "SetSampleRate");
|
||||
WPILIB_CheckErrorStatus(status, "SetSampleRate");
|
||||
}
|
||||
|
||||
double AnalogInput::GetSampleRate() {
|
||||
int32_t status = 0;
|
||||
double sampleRate = HAL_GetAnalogSampleRate(&status);
|
||||
FRC_CheckErrorStatus(status, "GetSampleRate");
|
||||
WPILIB_CheckErrorStatus(status, "GetSampleRate");
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@ using namespace wpi;
|
||||
|
||||
DigitalInput::DigitalInput(int channel) {
|
||||
if (!SensorUtil::CheckDigitalChannel(channel)) {
|
||||
throw FRC_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
}
|
||||
m_channel = channel;
|
||||
|
||||
int32_t status = 0;
|
||||
std::string stackTrace = wpi::util::GetStackTrace(1);
|
||||
m_handle = HAL_InitializeDIOPort(channel, true, stackTrace.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", channel);
|
||||
|
||||
HAL_ReportUsage("IO", channel, "DigitalInput");
|
||||
wpi::util::SendableRegistry::Add(this, "DigitalInput", channel);
|
||||
@@ -36,7 +36,7 @@ DigitalInput::DigitalInput(int channel) {
|
||||
bool DigitalInput::Get() const {
|
||||
int32_t status = 0;
|
||||
bool value = HAL_GetDIO(m_handle, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,14 +21,14 @@ using namespace wpi;
|
||||
DigitalOutput::DigitalOutput(int channel) {
|
||||
m_pwmGenerator = HAL_kInvalidHandle;
|
||||
if (!SensorUtil::CheckDigitalChannel(channel)) {
|
||||
throw FRC_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
}
|
||||
m_channel = channel;
|
||||
|
||||
int32_t status = 0;
|
||||
std::string stackTrace = wpi::util::GetStackTrace(1);
|
||||
m_handle = HAL_InitializeDIOPort(channel, false, stackTrace.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", channel);
|
||||
|
||||
HAL_ReportUsage("IO", channel, "DigitalOutput");
|
||||
wpi::util::SendableRegistry::Add(this, "DigitalOutput", channel);
|
||||
@@ -48,13 +48,13 @@ DigitalOutput::~DigitalOutput() {
|
||||
void DigitalOutput::Set(bool value) {
|
||||
int32_t status = 0;
|
||||
HAL_SetDIO(m_handle, value, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
}
|
||||
|
||||
bool DigitalOutput::Get() const {
|
||||
int32_t status = 0;
|
||||
bool val = HAL_GetDIO(m_handle, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
return val;
|
||||
}
|
||||
|
||||
@@ -65,20 +65,20 @@ int DigitalOutput::GetChannel() const {
|
||||
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);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
}
|
||||
|
||||
bool DigitalOutput::IsPulsing() const {
|
||||
int32_t status = 0;
|
||||
bool value = HAL_IsPulsing(m_handle, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
return value;
|
||||
}
|
||||
|
||||
void DigitalOutput::SetPWMRate(double rate) {
|
||||
int32_t status = 0;
|
||||
HAL_SetDigitalPWMRate(rate, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
}
|
||||
|
||||
void DigitalOutput::EnablePPS(double dutyCycle) {
|
||||
@@ -89,13 +89,13 @@ void DigitalOutput::EnablePPS(double dutyCycle) {
|
||||
int32_t status = 0;
|
||||
|
||||
m_pwmGenerator = HAL_AllocateDigitalPWM(&status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
|
||||
HAL_SetDigitalPWMPPS(m_pwmGenerator, dutyCycle, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
|
||||
HAL_SetDigitalPWMOutputChannel(m_pwmGenerator, m_channel, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
}
|
||||
|
||||
void DigitalOutput::EnablePWM(double initialDutyCycle) {
|
||||
@@ -106,13 +106,13 @@ void DigitalOutput::EnablePWM(double initialDutyCycle) {
|
||||
int32_t status = 0;
|
||||
|
||||
m_pwmGenerator = HAL_AllocateDigitalPWM(&status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
|
||||
HAL_SetDigitalPWMDutyCycle(m_pwmGenerator, initialDutyCycle, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
|
||||
HAL_SetDigitalPWMOutputChannel(m_pwmGenerator, m_channel, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
}
|
||||
|
||||
void DigitalOutput::DisablePWM() {
|
||||
@@ -125,7 +125,7 @@ void DigitalOutput::DisablePWM() {
|
||||
// Disable the output by routing to a dead bit.
|
||||
HAL_SetDigitalPWMOutputChannel(m_pwmGenerator,
|
||||
SensorUtil::GetNumDigitalChannels(), &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
|
||||
HAL_FreeDigitalPWM(m_pwmGenerator);
|
||||
|
||||
@@ -135,7 +135,7 @@ void DigitalOutput::DisablePWM() {
|
||||
void DigitalOutput::UpdateDutyCycle(double dutyCycle) {
|
||||
int32_t status = 0;
|
||||
HAL_SetDigitalPWMDutyCycle(m_pwmGenerator, dutyCycle, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
}
|
||||
|
||||
void DigitalOutput::SetSimDevice(HAL_SimDeviceHandle device) {
|
||||
|
||||
@@ -20,13 +20,13 @@ using namespace wpi;
|
||||
|
||||
PWM::PWM(int channel, bool registerSendable) {
|
||||
if (!SensorUtil::CheckPWMChannel(channel)) {
|
||||
throw FRC_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
}
|
||||
|
||||
auto stack = wpi::util::GetStackTrace(1);
|
||||
int32_t status = 0;
|
||||
m_handle = HAL_InitializePWMPort(channel, stack.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", channel);
|
||||
|
||||
m_channel = channel;
|
||||
|
||||
@@ -47,13 +47,13 @@ PWM::~PWM() {
|
||||
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);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
}
|
||||
|
||||
wpi::units::microsecond_t PWM::GetPulseTime() const {
|
||||
int32_t status = 0;
|
||||
double value = HAL_GetPWMPulseTimeMicroseconds(m_handle, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
|
||||
return wpi::units::microsecond_t{value};
|
||||
}
|
||||
@@ -61,7 +61,7 @@ wpi::units::microsecond_t PWM::GetPulseTime() const {
|
||||
void PWM::SetDisabled() {
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMPulseTimeMicroseconds(m_handle, 0, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
}
|
||||
|
||||
void PWM::SetOutputPeriod(OutputPeriod mult) {
|
||||
@@ -81,11 +81,11 @@ void PWM::SetOutputPeriod(OutputPeriod mult) {
|
||||
&status); // Don't squelch any outputs
|
||||
break;
|
||||
default:
|
||||
throw FRC_MakeError(err::InvalidParameter, "OutputPeriod value {}",
|
||||
throw WPILIB_MakeError(err::InvalidParameter, "OutputPeriod value {}",
|
||||
static_cast<int>(mult));
|
||||
}
|
||||
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", m_channel);
|
||||
}
|
||||
|
||||
int PWM::GetChannel() const {
|
||||
|
||||
@@ -53,7 +53,7 @@ wpi::math::Quaternion OnboardIMU::GetQuaternion() {
|
||||
HAL_Quaternion val;
|
||||
int32_t status = 0;
|
||||
HAL_GetIMUQuaternion(&val, &status);
|
||||
FRC_CheckErrorStatus(status, "Onboard IMU");
|
||||
WPILIB_CheckErrorStatus(status, "Onboard IMU");
|
||||
return wpi::math::Quaternion{val.w, val.x, val.y, val.z};
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ wpi::units::radian_t OnboardIMU::GetAngleX() {
|
||||
HAL_GetIMUEulerAnglesPortrait(&val, &status);
|
||||
break;
|
||||
}
|
||||
FRC_CheckErrorStatus(status, "Onboard IMU");
|
||||
WPILIB_CheckErrorStatus(status, "Onboard IMU");
|
||||
return wpi::units::radian_t{val.x};
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ wpi::units::radian_t OnboardIMU::GetAngleY() {
|
||||
HAL_GetIMUEulerAnglesPortrait(&val, &status);
|
||||
break;
|
||||
}
|
||||
FRC_CheckErrorStatus(status, "Onboard IMU");
|
||||
WPILIB_CheckErrorStatus(status, "Onboard IMU");
|
||||
return wpi::units::radian_t{val.y};
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ wpi::units::radian_t OnboardIMU::GetAngleZ() {
|
||||
HAL_GetIMUEulerAnglesPortrait(&val, &status);
|
||||
break;
|
||||
}
|
||||
FRC_CheckErrorStatus(status, "Onboard IMU");
|
||||
WPILIB_CheckErrorStatus(status, "Onboard IMU");
|
||||
return wpi::units::radian_t{val.z};
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ wpi::units::radians_per_second_t OnboardIMU::GetGyroRateX() {
|
||||
HAL_GyroRate3d val;
|
||||
int32_t status = 0;
|
||||
HAL_GetIMUGyroRates(&val, &status);
|
||||
FRC_CheckErrorStatus(status, "Onboard IMU");
|
||||
WPILIB_CheckErrorStatus(status, "Onboard IMU");
|
||||
return wpi::units::radians_per_second_t{val.x};
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ wpi::units::radians_per_second_t OnboardIMU::GetGyroRateY() {
|
||||
HAL_GyroRate3d val;
|
||||
int32_t status = 0;
|
||||
HAL_GetIMUGyroRates(&val, &status);
|
||||
FRC_CheckErrorStatus(status, "Onboard IMU");
|
||||
WPILIB_CheckErrorStatus(status, "Onboard IMU");
|
||||
return wpi::units::radians_per_second_t{val.y};
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ wpi::units::radians_per_second_t OnboardIMU::GetGyroRateZ() {
|
||||
HAL_GyroRate3d val;
|
||||
int32_t status = 0;
|
||||
HAL_GetIMUGyroRates(&val, &status);
|
||||
FRC_CheckErrorStatus(status, "Onboard IMU");
|
||||
WPILIB_CheckErrorStatus(status, "Onboard IMU");
|
||||
return wpi::units::radians_per_second_t{val.z};
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ wpi::units::meters_per_second_squared_t OnboardIMU::GetAccelX() {
|
||||
HAL_Acceleration3d val;
|
||||
int32_t status = 0;
|
||||
HAL_GetIMUAcceleration(&val, &status);
|
||||
FRC_CheckErrorStatus(status, "Onboard IMU");
|
||||
WPILIB_CheckErrorStatus(status, "Onboard IMU");
|
||||
return wpi::units::meters_per_second_squared_t{val.x};
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ wpi::units::meters_per_second_squared_t OnboardIMU::GetAccelY() {
|
||||
HAL_Acceleration3d val;
|
||||
int32_t status = 0;
|
||||
HAL_GetIMUAcceleration(&val, &status);
|
||||
FRC_CheckErrorStatus(status, "Onboard IMU");
|
||||
WPILIB_CheckErrorStatus(status, "Onboard IMU");
|
||||
return wpi::units::meters_per_second_squared_t{val.x};
|
||||
}
|
||||
|
||||
@@ -155,6 +155,6 @@ wpi::units::meters_per_second_squared_t OnboardIMU::GetAccelZ() {
|
||||
HAL_Acceleration3d val;
|
||||
int32_t status = 0;
|
||||
HAL_GetIMUAcceleration(&val, &status);
|
||||
FRC_CheckErrorStatus(status, "Onboard IMU");
|
||||
WPILIB_CheckErrorStatus(status, "Onboard IMU");
|
||||
return wpi::units::meters_per_second_squared_t{val.x};
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@ using namespace wpi;
|
||||
|
||||
AddressableLED::AddressableLED(int channel) : m_channel{channel} {
|
||||
if (!SensorUtil::CheckDigitalChannel(channel)) {
|
||||
throw FRC_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
}
|
||||
|
||||
int32_t status = 0;
|
||||
auto stack = wpi::util::GetStackTrace(1);
|
||||
m_handle = HAL_InitializeAddressableLED(channel, stack.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", channel);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", channel);
|
||||
|
||||
HAL_ReportUsage("IO", channel, "AddressableLED");
|
||||
}
|
||||
@@ -38,14 +38,14 @@ void AddressableLED::SetStart(int start) {
|
||||
m_start = start;
|
||||
int32_t status = 0;
|
||||
HAL_SetAddressableLEDStart(m_handle, start, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {} start {}", m_channel, start);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {} start {}", m_channel, start);
|
||||
}
|
||||
|
||||
void AddressableLED::SetLength(int length) {
|
||||
m_length = length;
|
||||
int32_t status = 0;
|
||||
HAL_SetAddressableLEDLength(m_handle, length, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {} length {}", m_channel, length);
|
||||
WPILIB_CheckErrorStatus(status, "Channel {} length {}", m_channel, length);
|
||||
}
|
||||
|
||||
static_assert(sizeof(AddressableLED::LEDData) == sizeof(HAL_AddressableLEDData),
|
||||
@@ -57,7 +57,7 @@ void AddressableLED::SetData(std::span<const LEDData> ledData) {
|
||||
m_start, std::min(static_cast<size_t>(m_length), ledData.size()),
|
||||
static_cast<HAL_AddressableLEDColorOrder>(m_colorOrder), ledData.data(),
|
||||
&status);
|
||||
FRC_CheckErrorStatus(status, "Port {}", m_channel);
|
||||
WPILIB_CheckErrorStatus(status, "Port {}", m_channel);
|
||||
}
|
||||
|
||||
void AddressableLED::SetData(std::initializer_list<LEDData> ledData) {
|
||||
@@ -71,7 +71,7 @@ void AddressableLED::SetGlobalData(int start, ColorOrder colorOrder,
|
||||
start, ledData.size(),
|
||||
static_cast<HAL_AddressableLEDColorOrder>(colorOrder), ledData.data(),
|
||||
&status);
|
||||
FRC_CheckErrorStatus(status, "");
|
||||
WPILIB_CheckErrorStatus(status, "");
|
||||
}
|
||||
|
||||
void AddressableLED::LEDData::SetHSV(int h, int s, int v) {
|
||||
|
||||
@@ -158,7 +158,7 @@ void MotorSafety::Check() {
|
||||
}
|
||||
|
||||
if (stopTime < Timer::GetFPGATimestamp()) {
|
||||
FRC_ReportError(err::Timeout,
|
||||
WPILIB_ReportError(err::Timeout,
|
||||
"{}... Output not updated often enough. See "
|
||||
"https://docs.wpilib.org/motorsafety for more information.",
|
||||
GetDescription());
|
||||
@@ -168,7 +168,7 @@ void MotorSafety::Check() {
|
||||
} catch (wpi::RuntimeError& e) {
|
||||
e.Report();
|
||||
} catch (std::exception& e) {
|
||||
FRC_ReportError(err::Error, "{} StopMotor threw unexpected exception: {}",
|
||||
WPILIB_ReportError(err::Error, "{} StopMotor threw unexpected exception: {}",
|
||||
GetDescription(), e.what());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ Compressor::Compressor(int busId, int module, PneumaticsModuleType moduleType)
|
||||
: m_module{PneumaticsBase::GetForType(busId, module, moduleType)},
|
||||
m_moduleType{moduleType} {
|
||||
if (!m_module->ReserveCompressor()) {
|
||||
throw FRC_MakeError(err::ResourceAlreadyAllocated, "{}", module);
|
||||
throw WPILIB_MakeError(err::ResourceAlreadyAllocated, "{}", module);
|
||||
}
|
||||
|
||||
m_module->EnableCompressorDigital();
|
||||
|
||||
@@ -22,11 +22,11 @@ DoubleSolenoid::DoubleSolenoid(int busId, int module,
|
||||
m_forwardChannel{forwardChannel},
|
||||
m_reverseChannel{reverseChannel} {
|
||||
if (!m_module->CheckSolenoidChannel(m_forwardChannel)) {
|
||||
throw FRC_MakeError(err::ChannelIndexOutOfRange, "Channel {}",
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}",
|
||||
m_forwardChannel);
|
||||
}
|
||||
if (!m_module->CheckSolenoidChannel(m_reverseChannel)) {
|
||||
throw FRC_MakeError(err::ChannelIndexOutOfRange, "Channel {}",
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}",
|
||||
m_reverseChannel);
|
||||
}
|
||||
|
||||
@@ -37,13 +37,13 @@ DoubleSolenoid::DoubleSolenoid(int busId, int module,
|
||||
int allocMask = m_module->CheckAndReserveSolenoids(m_mask);
|
||||
if (allocMask != 0) {
|
||||
if (allocMask == m_mask) {
|
||||
throw FRC_MakeError(err::ResourceAlreadyAllocated, "Channels {} and {}",
|
||||
throw WPILIB_MakeError(err::ResourceAlreadyAllocated, "Channels {} and {}",
|
||||
m_forwardChannel, m_reverseChannel);
|
||||
} else if (allocMask == m_forwardMask) {
|
||||
throw FRC_MakeError(err::ResourceAlreadyAllocated, "Channel {}",
|
||||
throw WPILIB_MakeError(err::ResourceAlreadyAllocated, "Channel {}",
|
||||
m_forwardChannel);
|
||||
} else {
|
||||
throw FRC_MakeError(err::ResourceAlreadyAllocated, "Channel {}",
|
||||
throw WPILIB_MakeError(err::ResourceAlreadyAllocated, "Channel {}",
|
||||
m_reverseChannel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ std::unique_ptr<wpi::util::DenseMap<int, std::weak_ptr<PneumaticHub::DataStore>>
|
||||
std::weak_ptr<PneumaticHub::DataStore>& PneumaticHub::GetDataStore(int busId,
|
||||
int module) {
|
||||
int32_t numBuses = HAL_GetNumCanBuses();
|
||||
FRC_AssertMessage(busId >= 0 && busId < numBuses,
|
||||
WPILIB_AssertMessage(busId >= 0 && busId < numBuses,
|
||||
"Bus {} out of range. Must be [0-{}).", busId, numBuses);
|
||||
if (!m_handleMaps) {
|
||||
m_handleMaps = std::make_unique<
|
||||
@@ -63,7 +63,7 @@ class PneumaticHub::DataStore {
|
||||
int32_t status = 0;
|
||||
HAL_REVPHHandle handle =
|
||||
HAL_InitializeREVPH(busId, module, stackTrace, &status);
|
||||
FRC_CheckErrorStatus(status, "Module {}", module);
|
||||
WPILIB_CheckErrorStatus(status, "Module {}", module);
|
||||
m_moduleObject = PneumaticHub{busId, handle, module};
|
||||
m_moduleObject.m_dataStore =
|
||||
std::shared_ptr<DataStore>{this, wpi::util::NullDeleter<DataStore>()};
|
||||
@@ -72,7 +72,7 @@ class PneumaticHub::DataStore {
|
||||
|
||||
// Check PH firmware version
|
||||
if (version.FirmwareMajor > 0 && version.FirmwareMajor < 22) {
|
||||
throw FRC_MakeError(
|
||||
throw WPILIB_MakeError(
|
||||
err::AssertionFailure,
|
||||
"The Pneumatic Hub has firmware version {}.{}.{}, and must be "
|
||||
"updated to version 2022.0.0 or later using the REV Hardware Client",
|
||||
@@ -117,36 +117,36 @@ PneumaticHub::PneumaticHub(int /* busId */, HAL_REVPHHandle handle, int module)
|
||||
bool PneumaticHub::GetCompressor() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetREVPHCompressor(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return result;
|
||||
}
|
||||
|
||||
void PneumaticHub::DisableCompressor() {
|
||||
int32_t status = 0;
|
||||
HAL_SetREVPHClosedLoopControlDisabled(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
void PneumaticHub::EnableCompressorDigital() {
|
||||
int32_t status = 0;
|
||||
HAL_SetREVPHClosedLoopControlDigital(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
void PneumaticHub::EnableCompressorAnalog(
|
||||
wpi::units::pounds_per_square_inch_t minPressure,
|
||||
wpi::units::pounds_per_square_inch_t maxPressure) {
|
||||
if (minPressure >= maxPressure) {
|
||||
throw FRC_MakeError(err::InvalidParameter,
|
||||
throw WPILIB_MakeError(err::InvalidParameter,
|
||||
"maxPressure must be greater than minPressure");
|
||||
}
|
||||
if (minPressure < 0_psi || minPressure > 120_psi) {
|
||||
throw FRC_MakeError(err::ParameterOutOfRange,
|
||||
throw WPILIB_MakeError(err::ParameterOutOfRange,
|
||||
"minPressure must be between 0 and 120 PSI, got {}",
|
||||
minPressure);
|
||||
}
|
||||
if (maxPressure < 0_psi || maxPressure > 120_psi) {
|
||||
throw FRC_MakeError(err::ParameterOutOfRange,
|
||||
throw WPILIB_MakeError(err::ParameterOutOfRange,
|
||||
"maxPressure must be between 0 and 120 PSI, got {}",
|
||||
maxPressure);
|
||||
}
|
||||
@@ -160,23 +160,23 @@ void PneumaticHub::EnableCompressorAnalog(
|
||||
int32_t status = 0;
|
||||
HAL_SetREVPHClosedLoopControlAnalog(m_handle, minAnalogVoltage.value(),
|
||||
maxAnalogVoltage.value(), &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
void PneumaticHub::EnableCompressorHybrid(
|
||||
wpi::units::pounds_per_square_inch_t minPressure,
|
||||
wpi::units::pounds_per_square_inch_t maxPressure) {
|
||||
if (minPressure >= maxPressure) {
|
||||
throw FRC_MakeError(err::InvalidParameter,
|
||||
throw WPILIB_MakeError(err::InvalidParameter,
|
||||
"maxPressure must be greater than minPressure");
|
||||
}
|
||||
if (minPressure < 0_psi || minPressure > 120_psi) {
|
||||
throw FRC_MakeError(err::ParameterOutOfRange,
|
||||
throw WPILIB_MakeError(err::ParameterOutOfRange,
|
||||
"minPressure must be between 0 and 120 PSI, got {}",
|
||||
minPressure);
|
||||
}
|
||||
if (maxPressure < 0_psi || maxPressure > 120_psi) {
|
||||
throw FRC_MakeError(err::ParameterOutOfRange,
|
||||
throw WPILIB_MakeError(err::ParameterOutOfRange,
|
||||
"maxPressure must be between 0 and 120 PSI, got {}",
|
||||
maxPressure);
|
||||
}
|
||||
@@ -190,40 +190,40 @@ void PneumaticHub::EnableCompressorHybrid(
|
||||
int32_t status = 0;
|
||||
HAL_SetREVPHClosedLoopControlHybrid(m_handle, minAnalogVoltage.value(),
|
||||
maxAnalogVoltage.value(), &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
CompressorConfigType PneumaticHub::GetCompressorConfigType() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetREVPHCompressorConfig(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return static_cast<CompressorConfigType>(result);
|
||||
}
|
||||
|
||||
bool PneumaticHub::GetPressureSwitch() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetREVPHPressureSwitch(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return result;
|
||||
}
|
||||
|
||||
wpi::units::ampere_t PneumaticHub::GetCompressorCurrent() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetREVPHCompressorCurrent(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return wpi::units::ampere_t{result};
|
||||
}
|
||||
|
||||
void PneumaticHub::SetSolenoids(int mask, int values) {
|
||||
int32_t status = 0;
|
||||
HAL_SetREVPHSolenoids(m_handle, mask, values, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
int PneumaticHub::GetSolenoids() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetREVPHSolenoids(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ int PneumaticHub::GetModuleNumber() const {
|
||||
int PneumaticHub::GetSolenoidDisabledList() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetREVPHSolenoidDisabledList(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ void PneumaticHub::FireOneShot(int index) {
|
||||
int32_t status = 0;
|
||||
HAL_FireREVPHOneShot(m_handle, index,
|
||||
m_dataStore->m_oneShotDurMs[index].value(), &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
void PneumaticHub::SetOneShotDuration(int index, wpi::units::second_t duration) {
|
||||
@@ -287,7 +287,7 @@ PneumaticHub::Version PneumaticHub::GetVersion() const {
|
||||
HAL_REVPHVersion halVersions;
|
||||
std::memset(&halVersions, 0, sizeof(halVersions));
|
||||
HAL_GetREVPHVersion(m_handle, &halVersions, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
PneumaticHub::Version versions;
|
||||
static_assert(sizeof(halVersions) == sizeof(versions));
|
||||
static_assert(std::is_standard_layout_v<decltype(versions)>);
|
||||
@@ -301,7 +301,7 @@ PneumaticHub::Faults PneumaticHub::GetFaults() const {
|
||||
HAL_REVPHFaults halFaults;
|
||||
std::memset(&halFaults, 0, sizeof(halFaults));
|
||||
HAL_GetREVPHFaults(m_handle, &halFaults, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
PneumaticHub::Faults faults;
|
||||
static_assert(sizeof(halFaults) == sizeof(faults));
|
||||
static_assert(std::is_standard_layout_v<decltype(faults)>);
|
||||
@@ -315,7 +315,7 @@ PneumaticHub::StickyFaults PneumaticHub::GetStickyFaults() const {
|
||||
HAL_REVPHStickyFaults halStickyFaults;
|
||||
std::memset(&halStickyFaults, 0, sizeof(halStickyFaults));
|
||||
HAL_GetREVPHStickyFaults(m_handle, &halStickyFaults, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
PneumaticHub::StickyFaults stickyFaults;
|
||||
static_assert(sizeof(halStickyFaults) == sizeof(stickyFaults));
|
||||
static_assert(std::is_standard_layout_v<decltype(stickyFaults)>);
|
||||
@@ -359,7 +359,7 @@ bool PneumaticHub::Faults::GetChannelFault(int channel) const {
|
||||
case 15:
|
||||
return Channel15Fault != 0;
|
||||
default:
|
||||
throw FRC_MakeError(err::ChannelIndexOutOfRange,
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange,
|
||||
"Pneumatics fault channel out of bounds!");
|
||||
}
|
||||
}
|
||||
@@ -367,50 +367,50 @@ bool PneumaticHub::Faults::GetChannelFault(int channel) const {
|
||||
void PneumaticHub::ClearStickyFaults() {
|
||||
int32_t status = 0;
|
||||
HAL_ClearREVPHStickyFaults(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
wpi::units::volt_t PneumaticHub::GetInputVoltage() const {
|
||||
int32_t status = 0;
|
||||
auto voltage = HAL_GetREVPHVoltage(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return wpi::units::volt_t{voltage};
|
||||
}
|
||||
|
||||
wpi::units::volt_t PneumaticHub::Get5VRegulatedVoltage() const {
|
||||
int32_t status = 0;
|
||||
auto voltage = HAL_GetREVPH5VVoltage(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return wpi::units::volt_t{voltage};
|
||||
}
|
||||
|
||||
wpi::units::ampere_t PneumaticHub::GetSolenoidsTotalCurrent() const {
|
||||
int32_t status = 0;
|
||||
auto current = HAL_GetREVPHSolenoidCurrent(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return wpi::units::ampere_t{current};
|
||||
}
|
||||
|
||||
wpi::units::volt_t PneumaticHub::GetSolenoidsVoltage() const {
|
||||
int32_t status = 0;
|
||||
auto voltage = HAL_GetREVPHSolenoidVoltage(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return wpi::units::volt_t{voltage};
|
||||
}
|
||||
|
||||
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);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return wpi::units::volt_t{voltage};
|
||||
}
|
||||
|
||||
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);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
auto supplyVoltage = HAL_GetREVPH5VVoltage(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return VoltsToPSI(wpi::units::volt_t{sensorVoltage}, wpi::units::volt_t{supplyVoltage});
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ std::shared_ptr<PneumaticsBase> PneumaticsBase::GetForType(
|
||||
} else if (moduleType == PneumaticsModuleType::REVPH) {
|
||||
return PneumaticHub::GetForModule(busId, module);
|
||||
}
|
||||
throw FRC_MakeError(err::InvalidParameter, "{}",
|
||||
throw WPILIB_MakeError(err::InvalidParameter, "{}",
|
||||
static_cast<int>(moduleType));
|
||||
}
|
||||
|
||||
@@ -44,6 +44,6 @@ int PneumaticsBase::GetDefaultForType(PneumaticsModuleType moduleType) {
|
||||
} else if (moduleType == PneumaticsModuleType::REVPH) {
|
||||
return SensorUtil::GetDefaultREVPHModule();
|
||||
}
|
||||
throw FRC_MakeError(err::InvalidParameter, "{}",
|
||||
throw WPILIB_MakeError(err::InvalidParameter, "{}",
|
||||
static_cast<int>(moduleType));
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ std::unique_ptr<
|
||||
std::weak_ptr<PneumaticsControlModule::DataStore>&
|
||||
PneumaticsControlModule::GetDataStore(int busId, int module) {
|
||||
int32_t numBuses = HAL_GetNumCanBuses();
|
||||
FRC_AssertMessage(busId >= 0 && busId < numBuses,
|
||||
WPILIB_AssertMessage(busId >= 0 && busId < numBuses,
|
||||
"Bus {} out of range. Must be [0-{}).", busId, numBuses);
|
||||
if (!m_handleMaps) {
|
||||
m_handleMaps = std::make_unique<wpi::util::DenseMap<
|
||||
@@ -48,7 +48,7 @@ class PneumaticsControlModule::DataStore {
|
||||
int32_t status = 0;
|
||||
HAL_CTREPCMHandle handle =
|
||||
HAL_InitializeCTREPCM(busId, module, stackTrace, &status);
|
||||
FRC_CheckErrorStatus(status, "Module {}", module);
|
||||
WPILIB_CheckErrorStatus(status, "Module {}", module);
|
||||
m_moduleObject = PneumaticsControlModule{busId, handle, module};
|
||||
m_moduleObject.m_dataStore =
|
||||
std::shared_ptr<DataStore>{this, wpi::util::NullDeleter<DataStore>()};
|
||||
@@ -92,20 +92,20 @@ PneumaticsControlModule::PneumaticsControlModule(int /* busId */,
|
||||
bool PneumaticsControlModule::GetCompressor() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetCTREPCMCompressor(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return result;
|
||||
}
|
||||
|
||||
void PneumaticsControlModule::DisableCompressor() {
|
||||
int32_t status = 0;
|
||||
HAL_SetCTREPCMClosedLoopControl(m_handle, false, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
void PneumaticsControlModule::EnableCompressorDigital() {
|
||||
int32_t status = 0;
|
||||
HAL_SetCTREPCMClosedLoopControl(m_handle, true, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
void PneumaticsControlModule::EnableCompressorAnalog(
|
||||
@@ -113,7 +113,7 @@ void PneumaticsControlModule::EnableCompressorAnalog(
|
||||
wpi::units::pounds_per_square_inch_t maxPressure) {
|
||||
int32_t status = 0;
|
||||
HAL_SetCTREPCMClosedLoopControl(m_handle, true, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
void PneumaticsControlModule::EnableCompressorHybrid(
|
||||
@@ -121,13 +121,13 @@ void PneumaticsControlModule::EnableCompressorHybrid(
|
||||
wpi::units::pounds_per_square_inch_t maxPressure) {
|
||||
int32_t status = 0;
|
||||
HAL_SetCTREPCMClosedLoopControl(m_handle, true, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
CompressorConfigType PneumaticsControlModule::GetCompressorConfigType() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetCTREPCMClosedLoopControl(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return result ? CompressorConfigType::Digital
|
||||
: CompressorConfigType::Disabled;
|
||||
}
|
||||
@@ -135,85 +135,85 @@ CompressorConfigType PneumaticsControlModule::GetCompressorConfigType() const {
|
||||
bool PneumaticsControlModule::GetPressureSwitch() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetCTREPCMPressureSwitch(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return result;
|
||||
}
|
||||
|
||||
wpi::units::ampere_t PneumaticsControlModule::GetCompressorCurrent() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetCTREPCMCompressorCurrent(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return wpi::units::ampere_t{result};
|
||||
}
|
||||
|
||||
bool PneumaticsControlModule::GetCompressorCurrentTooHighFault() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetCTREPCMCompressorCurrentTooHighFault(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return result;
|
||||
}
|
||||
bool PneumaticsControlModule::GetCompressorCurrentTooHighStickyFault() const {
|
||||
int32_t status = 0;
|
||||
auto result =
|
||||
HAL_GetCTREPCMCompressorCurrentTooHighStickyFault(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return result;
|
||||
}
|
||||
bool PneumaticsControlModule::GetCompressorShortedFault() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetCTREPCMCompressorShortedFault(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return result;
|
||||
}
|
||||
bool PneumaticsControlModule::GetCompressorShortedStickyFault() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetCTREPCMCompressorShortedStickyFault(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return result;
|
||||
}
|
||||
bool PneumaticsControlModule::GetCompressorNotConnectedFault() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetCTREPCMCompressorNotConnectedFault(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return result;
|
||||
}
|
||||
bool PneumaticsControlModule::GetCompressorNotConnectedStickyFault() const {
|
||||
int32_t status = 0;
|
||||
auto result =
|
||||
HAL_GetCTREPCMCompressorNotConnectedStickyFault(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool PneumaticsControlModule::GetSolenoidVoltageFault() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetCTREPCMSolenoidVoltageFault(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return result;
|
||||
}
|
||||
bool PneumaticsControlModule::GetSolenoidVoltageStickyFault() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetCTREPCMSolenoidVoltageStickyFault(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return result;
|
||||
}
|
||||
|
||||
void PneumaticsControlModule::ClearAllStickyFaults() {
|
||||
int32_t status = 0;
|
||||
HAL_ClearAllCTREPCMStickyFaults(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
void PneumaticsControlModule::SetSolenoids(int mask, int values) {
|
||||
int32_t status = 0;
|
||||
HAL_SetCTREPCMSolenoids(m_handle, mask, values, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
int PneumaticsControlModule::GetSolenoids() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetCTREPCMSolenoids(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -224,14 +224,14 @@ int PneumaticsControlModule::GetModuleNumber() const {
|
||||
int PneumaticsControlModule::GetSolenoidDisabledList() const {
|
||||
int32_t status = 0;
|
||||
auto result = HAL_GetCTREPCMSolenoidDisabledList(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return result;
|
||||
}
|
||||
|
||||
void PneumaticsControlModule::FireOneShot(int index) {
|
||||
int32_t status = 0;
|
||||
HAL_FireCTREPCMOneShot(m_handle, index, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
void PneumaticsControlModule::SetOneShotDuration(int index,
|
||||
@@ -239,7 +239,7 @@ void PneumaticsControlModule::SetOneShotDuration(int index,
|
||||
int32_t status = 0;
|
||||
wpi::units::millisecond_t millis = duration;
|
||||
HAL_SetCTREPCMOneShotDuration(m_handle, index, millis.to<int32_t>(), &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
bool PneumaticsControlModule::CheckSolenoidChannel(int channel) const {
|
||||
|
||||
@@ -19,12 +19,12 @@ Solenoid::Solenoid(int busId, int module, PneumaticsModuleType moduleType,
|
||||
: m_module{PneumaticsBase::GetForType(busId, module, moduleType)},
|
||||
m_channel{channel} {
|
||||
if (!m_module->CheckSolenoidChannel(m_channel)) {
|
||||
throw FRC_MakeError(err::ChannelIndexOutOfRange, "Channel {}", m_channel);
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", m_channel);
|
||||
}
|
||||
m_mask = 1 << channel;
|
||||
|
||||
if (m_module->CheckAndReserveSolenoids(m_mask) != 0) {
|
||||
throw FRC_MakeError(err::ResourceAlreadyAllocated, "Channel {}", m_channel);
|
||||
throw WPILIB_MakeError(err::ResourceAlreadyAllocated, "Channel {}", m_channel);
|
||||
}
|
||||
|
||||
m_module->ReportUsage(fmt::format("Solenoid[{}]", m_channel), "Solenoid");
|
||||
|
||||
@@ -35,9 +35,9 @@ PowerDistribution::PowerDistribution(int busId) {
|
||||
busId, kDefaultModule,
|
||||
HAL_PowerDistributionType::HAL_PowerDistributionType_kAutomatic,
|
||||
stack.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Module {}", kDefaultModule);
|
||||
WPILIB_CheckErrorStatus(status, "Module {}", kDefaultModule);
|
||||
m_module = HAL_GetPowerDistributionModuleNumber(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
|
||||
if (HAL_GetPowerDistributionType(m_handle, &status) ==
|
||||
HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE) {
|
||||
@@ -56,9 +56,9 @@ PowerDistribution::PowerDistribution(int busId, int module,
|
||||
m_handle = HAL_InitializePowerDistribution(
|
||||
busId, module, static_cast<HAL_PowerDistributionType>(moduleType),
|
||||
stack.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Module {}", module);
|
||||
WPILIB_CheckErrorStatus(status, "Module {}", module);
|
||||
m_module = HAL_GetPowerDistributionModuleNumber(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", module);
|
||||
WPILIB_ReportError(status, "Module {}", module);
|
||||
|
||||
if (moduleType == ModuleType::kCTRE) {
|
||||
HAL_ReportUsage("PDP_CTRE", m_module, "");
|
||||
@@ -71,21 +71,21 @@ PowerDistribution::PowerDistribution(int busId, int module,
|
||||
int PowerDistribution::GetNumChannels() const {
|
||||
int32_t status = 0;
|
||||
int32_t size = HAL_GetPowerDistributionNumChannels(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return size;
|
||||
}
|
||||
|
||||
double PowerDistribution::GetVoltage() const {
|
||||
int32_t status = 0;
|
||||
double voltage = HAL_GetPowerDistributionVoltage(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return voltage;
|
||||
}
|
||||
|
||||
double PowerDistribution::GetTemperature() const {
|
||||
int32_t status = 0;
|
||||
double temperature = HAL_GetPowerDistributionTemperature(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return temperature;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ double PowerDistribution::GetCurrent(int channel) const {
|
||||
int32_t status = 0;
|
||||
double current =
|
||||
HAL_GetPowerDistributionChannelCurrent(m_handle, channel, &status);
|
||||
FRC_ReportError(status, "Module {} Channel {}", m_module, channel);
|
||||
WPILIB_ReportError(status, "Module {} Channel {}", m_module, channel);
|
||||
|
||||
return current;
|
||||
}
|
||||
@@ -105,41 +105,41 @@ std::vector<double> PowerDistribution::GetAllCurrents() const {
|
||||
|
||||
HAL_GetPowerDistributionAllChannelCurrents(m_handle, currents.data(), size,
|
||||
&status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return currents;
|
||||
}
|
||||
|
||||
double PowerDistribution::GetTotalCurrent() const {
|
||||
int32_t status = 0;
|
||||
double current = HAL_GetPowerDistributionTotalCurrent(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return current;
|
||||
}
|
||||
|
||||
double PowerDistribution::GetTotalPower() const {
|
||||
int32_t status = 0;
|
||||
double power = HAL_GetPowerDistributionTotalPower(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return power;
|
||||
}
|
||||
|
||||
double PowerDistribution::GetTotalEnergy() const {
|
||||
int32_t status = 0;
|
||||
double energy = HAL_GetPowerDistributionTotalEnergy(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return energy;
|
||||
}
|
||||
|
||||
void PowerDistribution::ResetTotalEnergy() {
|
||||
int32_t status = 0;
|
||||
HAL_ResetPowerDistributionTotalEnergy(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
void PowerDistribution::ClearStickyFaults() {
|
||||
int32_t status = 0;
|
||||
HAL_ClearPowerDistributionStickyFaults(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
int PowerDistribution::GetModule() const {
|
||||
@@ -149,21 +149,21 @@ int PowerDistribution::GetModule() const {
|
||||
PowerDistribution::ModuleType PowerDistribution::GetType() const {
|
||||
int32_t status = 0;
|
||||
auto type = HAL_GetPowerDistributionType(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return static_cast<ModuleType>(type);
|
||||
}
|
||||
|
||||
bool PowerDistribution::GetSwitchableChannel() const {
|
||||
int32_t status = 0;
|
||||
bool state = HAL_GetPowerDistributionSwitchableChannel(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
return state;
|
||||
}
|
||||
|
||||
void PowerDistribution::SetSwitchableChannel(bool enabled) {
|
||||
int32_t status = 0;
|
||||
HAL_SetPowerDistributionSwitchableChannel(m_handle, enabled, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
}
|
||||
|
||||
PowerDistribution::Version PowerDistribution::GetVersion() const {
|
||||
@@ -171,7 +171,7 @@ PowerDistribution::Version PowerDistribution::GetVersion() const {
|
||||
HAL_PowerDistributionVersion halVersion;
|
||||
std::memset(&halVersion, 0, sizeof(halVersion));
|
||||
HAL_GetPowerDistributionVersion(m_handle, &halVersion, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
PowerDistribution::Version version;
|
||||
static_assert(sizeof(halVersion) == sizeof(version));
|
||||
static_assert(std::is_standard_layout_v<decltype(version)>);
|
||||
@@ -185,7 +185,7 @@ PowerDistribution::Faults PowerDistribution::GetFaults() const {
|
||||
HAL_PowerDistributionFaults halFaults;
|
||||
std::memset(&halFaults, 0, sizeof(halFaults));
|
||||
HAL_GetPowerDistributionFaults(m_handle, &halFaults, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
PowerDistribution::Faults faults;
|
||||
static_assert(sizeof(halFaults) == sizeof(faults));
|
||||
static_assert(std::is_standard_layout_v<decltype(faults)>);
|
||||
@@ -245,7 +245,7 @@ bool PowerDistribution::Faults::GetBreakerFault(int channel) const {
|
||||
case 23:
|
||||
return Channel23BreakerFault != 0;
|
||||
default:
|
||||
throw FRC_MakeError(err::ChannelIndexOutOfRange,
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange,
|
||||
"Power distribution fault channel out of bounds!");
|
||||
}
|
||||
}
|
||||
@@ -301,7 +301,7 @@ bool PowerDistribution::StickyFaults::GetBreakerFault(int channel) const {
|
||||
case 23:
|
||||
return Channel23BreakerFault != 0;
|
||||
default:
|
||||
throw FRC_MakeError(err::ChannelIndexOutOfRange,
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange,
|
||||
"Power distribution fault channel out of bounds!");
|
||||
}
|
||||
}
|
||||
@@ -311,7 +311,7 @@ PowerDistribution::StickyFaults PowerDistribution::GetStickyFaults() const {
|
||||
HAL_PowerDistributionStickyFaults halStickyFaults;
|
||||
std::memset(&halStickyFaults, 0, sizeof(halStickyFaults));
|
||||
HAL_GetPowerDistributionStickyFaults(m_handle, &halStickyFaults, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
PowerDistribution::StickyFaults stickyFaults;
|
||||
static_assert(sizeof(halStickyFaults) == sizeof(stickyFaults));
|
||||
static_assert(std::is_standard_layout_v<decltype(stickyFaults)>);
|
||||
|
||||
@@ -20,7 +20,7 @@ using namespace wpi;
|
||||
|
||||
DutyCycle::DutyCycle(int channel) : m_channel{channel} {
|
||||
if (!SensorUtil::CheckDigitalChannel(channel)) {
|
||||
throw FRC_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "Channel {}", channel);
|
||||
}
|
||||
InitDutyCycle();
|
||||
}
|
||||
@@ -29,7 +29,7 @@ void DutyCycle::InitDutyCycle() {
|
||||
int32_t status = 0;
|
||||
std::string stackTrace = wpi::util::GetStackTrace(1);
|
||||
m_handle = HAL_InitializeDutyCycle(m_channel, stackTrace.c_str(), &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", GetSourceChannel());
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", GetSourceChannel());
|
||||
HAL_ReportUsage("IO", m_channel, "DutyCycle");
|
||||
wpi::util::SendableRegistry::Add(this, "Duty Cycle", m_channel);
|
||||
}
|
||||
@@ -37,21 +37,21 @@ void DutyCycle::InitDutyCycle() {
|
||||
wpi::units::hertz_t DutyCycle::GetFrequency() const {
|
||||
int32_t status = 0;
|
||||
auto retVal = HAL_GetDutyCycleFrequency(m_handle, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", GetSourceChannel());
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", GetSourceChannel());
|
||||
return wpi::units::hertz_t{retVal};
|
||||
}
|
||||
|
||||
double DutyCycle::GetOutput() const {
|
||||
int32_t status = 0;
|
||||
auto retVal = HAL_GetDutyCycleOutput(m_handle, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", GetSourceChannel());
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", GetSourceChannel());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
wpi::units::second_t DutyCycle::GetHighTime() const {
|
||||
int32_t status = 0;
|
||||
auto retVal = HAL_GetDutyCycleHighTime(m_handle, &status);
|
||||
FRC_CheckErrorStatus(status, "Channel {}", GetSourceChannel());
|
||||
WPILIB_CheckErrorStatus(status, "Channel {}", GetSourceChannel());
|
||||
return wpi::units::nanosecond_t{static_cast<double>(retVal)};
|
||||
}
|
||||
|
||||
|
||||
@@ -25,112 +25,112 @@ Encoder::Encoder(int aChannel, int bChannel, bool reverseDirection,
|
||||
int Encoder::Get() const {
|
||||
int32_t status = 0;
|
||||
int value = HAL_GetEncoder(m_encoder, &status);
|
||||
FRC_CheckErrorStatus(status, "Get");
|
||||
WPILIB_CheckErrorStatus(status, "Get");
|
||||
return value;
|
||||
}
|
||||
|
||||
void Encoder::Reset() {
|
||||
int32_t status = 0;
|
||||
HAL_ResetEncoder(m_encoder, &status);
|
||||
FRC_CheckErrorStatus(status, "Reset");
|
||||
WPILIB_CheckErrorStatus(status, "Reset");
|
||||
}
|
||||
|
||||
wpi::units::second_t Encoder::GetPeriod() const {
|
||||
int32_t status = 0;
|
||||
double value = HAL_GetEncoderPeriod(m_encoder, &status);
|
||||
FRC_CheckErrorStatus(status, "GetPeriod");
|
||||
WPILIB_CheckErrorStatus(status, "GetPeriod");
|
||||
return wpi::units::second_t{value};
|
||||
}
|
||||
|
||||
void Encoder::SetMaxPeriod(wpi::units::second_t maxPeriod) {
|
||||
int32_t status = 0;
|
||||
HAL_SetEncoderMaxPeriod(m_encoder, maxPeriod.value(), &status);
|
||||
FRC_CheckErrorStatus(status, "SetMaxPeriod");
|
||||
WPILIB_CheckErrorStatus(status, "SetMaxPeriod");
|
||||
}
|
||||
|
||||
bool Encoder::GetStopped() const {
|
||||
int32_t status = 0;
|
||||
bool value = HAL_GetEncoderStopped(m_encoder, &status);
|
||||
FRC_CheckErrorStatus(status, "GetStopped");
|
||||
WPILIB_CheckErrorStatus(status, "GetStopped");
|
||||
return value;
|
||||
}
|
||||
|
||||
bool Encoder::GetDirection() const {
|
||||
int32_t status = 0;
|
||||
bool value = HAL_GetEncoderDirection(m_encoder, &status);
|
||||
FRC_CheckErrorStatus(status, "GetDirection");
|
||||
WPILIB_CheckErrorStatus(status, "GetDirection");
|
||||
return value;
|
||||
}
|
||||
|
||||
int Encoder::GetRaw() const {
|
||||
int32_t status = 0;
|
||||
int value = HAL_GetEncoderRaw(m_encoder, &status);
|
||||
FRC_CheckErrorStatus(status, "GetRaw");
|
||||
WPILIB_CheckErrorStatus(status, "GetRaw");
|
||||
return value;
|
||||
}
|
||||
|
||||
int Encoder::GetEncodingScale() const {
|
||||
int32_t status = 0;
|
||||
int val = HAL_GetEncoderEncodingScale(m_encoder, &status);
|
||||
FRC_CheckErrorStatus(status, "GetEncodingScale");
|
||||
WPILIB_CheckErrorStatus(status, "GetEncodingScale");
|
||||
return val;
|
||||
}
|
||||
|
||||
double Encoder::GetDistance() const {
|
||||
int32_t status = 0;
|
||||
double value = HAL_GetEncoderDistance(m_encoder, &status);
|
||||
FRC_CheckErrorStatus(status, "GetDistance");
|
||||
WPILIB_CheckErrorStatus(status, "GetDistance");
|
||||
return value;
|
||||
}
|
||||
|
||||
double Encoder::GetRate() const {
|
||||
int32_t status = 0;
|
||||
double value = HAL_GetEncoderRate(m_encoder, &status);
|
||||
FRC_CheckErrorStatus(status, "GetRate");
|
||||
WPILIB_CheckErrorStatus(status, "GetRate");
|
||||
return value;
|
||||
}
|
||||
|
||||
void Encoder::SetMinRate(double minRate) {
|
||||
int32_t status = 0;
|
||||
HAL_SetEncoderMinRate(m_encoder, minRate, &status);
|
||||
FRC_CheckErrorStatus(status, "SetMinRate");
|
||||
WPILIB_CheckErrorStatus(status, "SetMinRate");
|
||||
}
|
||||
|
||||
void Encoder::SetDistancePerPulse(double distancePerPulse) {
|
||||
int32_t status = 0;
|
||||
HAL_SetEncoderDistancePerPulse(m_encoder, distancePerPulse, &status);
|
||||
FRC_CheckErrorStatus(status, "SetDistancePerPulse");
|
||||
WPILIB_CheckErrorStatus(status, "SetDistancePerPulse");
|
||||
}
|
||||
|
||||
double Encoder::GetDistancePerPulse() const {
|
||||
int32_t status = 0;
|
||||
double distancePerPulse = HAL_GetEncoderDistancePerPulse(m_encoder, &status);
|
||||
FRC_CheckErrorStatus(status, "GetDistancePerPulse");
|
||||
WPILIB_CheckErrorStatus(status, "GetDistancePerPulse");
|
||||
return distancePerPulse;
|
||||
}
|
||||
|
||||
void Encoder::SetReverseDirection(bool reverseDirection) {
|
||||
int32_t status = 0;
|
||||
HAL_SetEncoderReverseDirection(m_encoder, reverseDirection, &status);
|
||||
FRC_CheckErrorStatus(status, "SetReverseDirection");
|
||||
WPILIB_CheckErrorStatus(status, "SetReverseDirection");
|
||||
}
|
||||
|
||||
void Encoder::SetSamplesToAverage(int samplesToAverage) {
|
||||
if (samplesToAverage < 1 || samplesToAverage > 127) {
|
||||
throw FRC_MakeError(
|
||||
throw WPILIB_MakeError(
|
||||
err::ParameterOutOfRange,
|
||||
"Average counter values must be between 1 and 127, got {}",
|
||||
samplesToAverage);
|
||||
}
|
||||
int32_t status = 0;
|
||||
HAL_SetEncoderSamplesToAverage(m_encoder, samplesToAverage, &status);
|
||||
FRC_CheckErrorStatus(status, "SetSamplesToAverage");
|
||||
WPILIB_CheckErrorStatus(status, "SetSamplesToAverage");
|
||||
}
|
||||
|
||||
int Encoder::GetSamplesToAverage() const {
|
||||
int32_t status = 0;
|
||||
int result = HAL_GetEncoderSamplesToAverage(m_encoder, &status);
|
||||
FRC_CheckErrorStatus(status, "GetSamplesToAverage");
|
||||
WPILIB_CheckErrorStatus(status, "GetSamplesToAverage");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -141,14 +141,14 @@ void Encoder::SetSimDevice(HAL_SimDeviceHandle device) {
|
||||
int Encoder::GetFPGAIndex() const {
|
||||
int32_t status = 0;
|
||||
int val = HAL_GetEncoderFPGAIndex(m_encoder, &status);
|
||||
FRC_CheckErrorStatus(status, "GetFPGAIndex");
|
||||
WPILIB_CheckErrorStatus(status, "GetFPGAIndex");
|
||||
return val;
|
||||
}
|
||||
|
||||
void Encoder::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
int32_t status = 0;
|
||||
HAL_EncoderEncodingType type = HAL_GetEncoderEncodingType(m_encoder, &status);
|
||||
FRC_CheckErrorStatus(status, "GetEncodingType");
|
||||
WPILIB_CheckErrorStatus(status, "GetEncodingType");
|
||||
if (type == HAL_EncoderEncodingType::HAL_Encoder_k4X) {
|
||||
builder.SetSmartDashboardType("Quadrature Encoder");
|
||||
} else {
|
||||
@@ -169,7 +169,7 @@ void Encoder::InitEncoder(int aChannel, int bChannel, bool reverseDirection,
|
||||
m_encoder = HAL_InitializeEncoder(
|
||||
aChannel, bChannel, reverseDirection,
|
||||
static_cast<HAL_EncoderEncodingType>(encodingType), &status);
|
||||
FRC_CheckErrorStatus(status, "InitEncoder");
|
||||
WPILIB_CheckErrorStatus(status, "InitEncoder");
|
||||
|
||||
const char* type = "Encoder";
|
||||
switch (encodingType) {
|
||||
@@ -190,6 +190,6 @@ void Encoder::InitEncoder(int aChannel, int bChannel, bool reverseDirection,
|
||||
double Encoder::DecodingScaleFactor() const {
|
||||
int32_t status = 0;
|
||||
double val = HAL_GetEncoderDecodingScaleFactor(m_encoder, &status);
|
||||
FRC_CheckErrorStatus(status, "DecodingScaleFactor");
|
||||
WPILIB_CheckErrorStatus(status, "DecodingScaleFactor");
|
||||
return val;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user