2021-09-16 18:50:27 -07:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
|
|
|
|
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/hardware/pneumatic/PneumaticsBase.hpp"
|
2021-09-16 18:50:27 -07:00
|
|
|
|
2024-09-20 17:43:39 -07:00
|
|
|
#include <memory>
|
|
|
|
|
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/hal/REVPH.h"
|
2021-11-23 20:32:02 -08:00
|
|
|
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/system/Errors.hpp"
|
|
|
|
|
#include "wpi/hardware/pneumatic/PneumaticHub.hpp"
|
|
|
|
|
#include "wpi/hardware/pneumatic/PneumaticsControlModule.hpp"
|
|
|
|
|
#include "wpi/util/SensorUtil.hpp"
|
2021-09-16 18:50:27 -07:00
|
|
|
|
|
|
|
|
using namespace frc;
|
|
|
|
|
|
2021-11-23 20:32:02 -08:00
|
|
|
static_assert(
|
|
|
|
|
static_cast<int>(CompressorConfigType::Disabled) ==
|
|
|
|
|
HAL_REVPHCompressorConfigType::HAL_REVPHCompressorConfigType_kDisabled);
|
|
|
|
|
static_assert(
|
|
|
|
|
static_cast<int>(CompressorConfigType::Digital) ==
|
|
|
|
|
HAL_REVPHCompressorConfigType::HAL_REVPHCompressorConfigType_kDigital);
|
|
|
|
|
static_assert(
|
|
|
|
|
static_cast<int>(CompressorConfigType::Analog) ==
|
|
|
|
|
HAL_REVPHCompressorConfigType::HAL_REVPHCompressorConfigType_kAnalog);
|
|
|
|
|
static_assert(
|
|
|
|
|
static_cast<int>(CompressorConfigType::Hybrid) ==
|
|
|
|
|
HAL_REVPHCompressorConfigType::HAL_REVPHCompressorConfigType_kHybrid);
|
|
|
|
|
|
2021-09-16 18:50:27 -07:00
|
|
|
std::shared_ptr<PneumaticsBase> PneumaticsBase::GetForType(
|
2025-02-25 19:07:01 -08:00
|
|
|
int busId, int module, PneumaticsModuleType moduleType) {
|
2021-09-16 18:50:27 -07:00
|
|
|
if (moduleType == PneumaticsModuleType::CTREPCM) {
|
2025-02-25 19:07:01 -08:00
|
|
|
return PneumaticsControlModule::GetForModule(busId, module);
|
2021-10-10 20:04:50 -07:00
|
|
|
} else if (moduleType == PneumaticsModuleType::REVPH) {
|
2025-02-25 19:07:01 -08:00
|
|
|
return PneumaticHub::GetForModule(busId, module);
|
2021-09-16 18:50:27 -07:00
|
|
|
}
|
2022-01-08 11:10:42 -08:00
|
|
|
throw FRC_MakeError(err::InvalidParameter, "{}",
|
|
|
|
|
static_cast<int>(moduleType));
|
2021-09-16 18:50:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int PneumaticsBase::GetDefaultForType(PneumaticsModuleType moduleType) {
|
|
|
|
|
if (moduleType == PneumaticsModuleType::CTREPCM) {
|
|
|
|
|
return SensorUtil::GetDefaultCTREPCMModule();
|
2021-10-10 20:04:50 -07:00
|
|
|
} else if (moduleType == PneumaticsModuleType::REVPH) {
|
|
|
|
|
return SensorUtil::GetDefaultREVPHModule();
|
2021-09-16 18:50:27 -07:00
|
|
|
}
|
2022-01-08 11:10:42 -08:00
|
|
|
throw FRC_MakeError(err::InvalidParameter, "{}",
|
|
|
|
|
static_cast<int>(moduleType));
|
2021-09-16 18:50:27 -07:00
|
|
|
}
|