mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpilib] Compressor: Add more Sendable data (#6687)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user