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.
|
|
|
|
|
|
|
|
|
|
#include "frc/PneumaticsBase.h"
|
|
|
|
|
|
2021-11-23 20:32:02 -08:00
|
|
|
#include <hal/REVPH.h>
|
|
|
|
|
|
2021-09-16 18:50:27 -07:00
|
|
|
#include "frc/Errors.h"
|
2021-10-29 00:00:31 -07:00
|
|
|
#include "frc/PneumaticHub.h"
|
2021-09-16 18:50:27 -07:00
|
|
|
#include "frc/PneumaticsControlModule.h"
|
|
|
|
|
#include "frc/SensorUtil.h"
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
|
|
int module, PneumaticsModuleType moduleType) {
|
|
|
|
|
if (moduleType == PneumaticsModuleType::CTREPCM) {
|
|
|
|
|
return PneumaticsControlModule::GetForModule(module);
|
2021-10-10 20:04:50 -07:00
|
|
|
} else if (moduleType == PneumaticsModuleType::REVPH) {
|
2021-10-29 00:00:31 -07:00
|
|
|
return PneumaticHub::GetForModule(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
|
|
|
}
|