Files
allwpilib/wpilibc/src/main/native/cpp/PneumaticsBase.cpp
Tyler Veness b3707cca0b [wpiutil] Upgrade to fmt 8.1.1 (#3879)
The changes to PneumaticsBase.cpp were to fix errors like the following
from enum classes not being formattable:
```
allwpilib/wpilibc/src/main/native/cpp/PneumaticsBase.cpp:36:9:   required from here
allwpilib/wpiutil/src/main/native/fmtlib/include/fmt/core.h:2672:12: error: use of deleted function ‘fmt::v8::detail::fallback_formatter<T, Char, Enable>::fallback_formatter() [with T = frc::PneumaticsModuleType; Char = char; Enable = void]’
 2672 |   auto f = conditional_t<has_formatter<mapped_type, context>::value,
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2673 |                          formatter<mapped_type, char_type>,
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2674 |                          fallback_formatter<T, char_type>>();
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
2022-01-08 11:10:42 -08:00

49 lines
1.8 KiB
C++

// 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"
#include <hal/REVPH.h>
#include "frc/Errors.h"
#include "frc/PneumaticHub.h"
#include "frc/PneumaticsControlModule.h"
#include "frc/SensorUtil.h"
using namespace frc;
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);
std::shared_ptr<PneumaticsBase> PneumaticsBase::GetForType(
int module, PneumaticsModuleType moduleType) {
if (moduleType == PneumaticsModuleType::CTREPCM) {
return PneumaticsControlModule::GetForModule(module);
} else if (moduleType == PneumaticsModuleType::REVPH) {
return PneumaticHub::GetForModule(module);
}
throw FRC_MakeError(err::InvalidParameter, "{}",
static_cast<int>(moduleType));
}
int PneumaticsBase::GetDefaultForType(PneumaticsModuleType moduleType) {
if (moduleType == PneumaticsModuleType::CTREPCM) {
return SensorUtil::GetDefaultCTREPCMModule();
} else if (moduleType == PneumaticsModuleType::REVPH) {
return SensorUtil::GetDefaultREVPHModule();
}
throw FRC_MakeError(err::InvalidParameter, "{}",
static_cast<int>(moduleType));
}