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"
|
|
|
|
|
#include "wpi/hardware/pneumatic/PneumaticHub.hpp"
|
|
|
|
|
#include "wpi/hardware/pneumatic/PneumaticsControlModule.hpp"
|
2025-11-07 19:57:55 -05:00
|
|
|
#include "wpi/system/Errors.hpp"
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/util/SensorUtil.hpp"
|
2021-09-16 18:50:27 -07:00
|
|
|
|
2025-11-07 20:00:05 -05:00
|
|
|
using namespace wpi;
|
2021-09-16 18:50:27 -07:00
|
|
|
|
2021-11-23 20:32:02 -08:00
|
|
|
static_assert(
|
2026-03-14 12:11:25 -07:00
|
|
|
static_cast<int>(CompressorConfigType::DISABLED) ==
|
|
|
|
|
HAL_REVPHCompressorConfigType::HAL_REVPH_COMPRESSOR_CONFIG_DISABLED);
|
2021-11-23 20:32:02 -08:00
|
|
|
static_assert(
|
2026-03-14 12:11:25 -07:00
|
|
|
static_cast<int>(CompressorConfigType::DIGITAL) ==
|
|
|
|
|
HAL_REVPHCompressorConfigType::HAL_REVPH_COMPRESSOR_CONFIG_DIGITAL);
|
2021-11-23 20:32:02 -08:00
|
|
|
static_assert(
|
2026-03-14 12:11:25 -07:00
|
|
|
static_cast<int>(CompressorConfigType::ANALOG) ==
|
|
|
|
|
HAL_REVPHCompressorConfigType::HAL_REVPH_COMPRESSOR_CONFIG_ANALOG);
|
2021-11-23 20:32:02 -08:00
|
|
|
static_assert(
|
2026-03-14 12:11:25 -07:00
|
|
|
static_cast<int>(CompressorConfigType::HYBRID) ==
|
|
|
|
|
HAL_REVPHCompressorConfigType::HAL_REVPH_COMPRESSOR_CONFIG_HYBRID);
|
2021-11-23 20:32:02 -08:00
|
|
|
|
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
|
|
|
}
|
2025-11-07 20:00:43 -05:00
|
|
|
throw WPILIB_MakeError(err::InvalidParameter, "{}",
|
2025-11-07 20:01:58 -05:00
|
|
|
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
|
|
|
}
|
2025-11-07 20:00:43 -05:00
|
|
|
throw WPILIB_MakeError(err::InvalidParameter, "{}",
|
2025-11-07 20:01:58 -05:00
|
|
|
static_cast<int>(moduleType));
|
2021-09-16 18:50:27 -07:00
|
|
|
}
|