[wpilib] Compressor: Add more Sendable data (#6687)

This commit is contained in:
Wispy
2024-06-03 09:47:17 -05:00
committed by GitHub
parent bdc42532ed
commit 5f8c842223
3 changed files with 22 additions and 1 deletions

View File

@@ -4,6 +4,8 @@
#include "frc/Compressor.h"
#include <frc/PneumaticHub.h>
#include <hal/FRCUsageReporting.h>
#include <hal/Ports.h>
#include <wpi/sendable/SendableBuilder.h>
@@ -14,7 +16,8 @@
using namespace frc;
Compressor::Compressor(int module, PneumaticsModuleType moduleType)
: m_module{PneumaticsBase::GetForType(module, moduleType)} {
: m_module{PneumaticsBase::GetForType(module, moduleType)},
m_moduleType{moduleType} {
if (!m_module->ReserveCompressor()) {
throw FRC_MakeError(err::ResourceAlreadyAllocated, "{}", module);
}
@@ -82,4 +85,14 @@ void Compressor::InitSendable(wpi::SendableBuilder& builder) {
"Enabled", [this] { return IsEnabled(); }, nullptr);
builder.AddBooleanProperty(
"Pressure switch", [this] { return GetPressureSwitchValue(); }, nullptr);
builder.AddDoubleProperty(
"Current (A)", [this] { return GetCurrent().value(); }, nullptr);
// These are not supported by the CTRE PCM
if (m_moduleType == PneumaticsModuleType::REVPH) {
builder.AddDoubleProperty(
"Analog Voltage", [this] { return GetAnalogVoltage().value(); },
nullptr);
builder.AddDoubleProperty(
"Pressure (PSI)", [this] { return GetPressure().value(); }, nullptr);
}
}