2021-06-05 22:36:39 -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.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2021-09-16 18:50:27 -07:00
|
|
|
#include <memory>
|
|
|
|
|
|
2021-06-05 22:36:39 -07:00
|
|
|
#include <hal/Types.h>
|
2021-09-16 18:50:27 -07:00
|
|
|
#include <wpi/DenseMap.h>
|
2021-07-09 15:11:12 -07:00
|
|
|
#include <wpi/mutex.h>
|
2021-06-05 22:36:39 -07:00
|
|
|
|
|
|
|
|
#include "PneumaticsBase.h"
|
|
|
|
|
|
|
|
|
|
namespace frc {
|
2021-09-16 18:50:27 -07:00
|
|
|
class PneumaticsControlModule : public PneumaticsBase {
|
2021-06-05 22:36:39 -07:00
|
|
|
public:
|
|
|
|
|
PneumaticsControlModule();
|
|
|
|
|
explicit PneumaticsControlModule(int module);
|
|
|
|
|
|
2021-09-16 18:50:27 -07:00
|
|
|
~PneumaticsControlModule() override = default;
|
2021-06-05 22:36:39 -07:00
|
|
|
|
2021-09-16 18:50:27 -07:00
|
|
|
bool GetCompressor() const override;
|
2021-06-05 22:36:39 -07:00
|
|
|
|
2021-09-16 18:50:27 -07:00
|
|
|
void SetClosedLoopControl(bool enabled) override;
|
2021-06-05 22:36:39 -07:00
|
|
|
|
2021-09-16 18:50:27 -07:00
|
|
|
bool GetClosedLoopControl() const override;
|
2021-06-05 22:36:39 -07:00
|
|
|
|
2021-09-16 18:50:27 -07:00
|
|
|
bool GetPressureSwitch() const override;
|
2021-06-05 22:36:39 -07:00
|
|
|
|
2021-09-16 18:50:27 -07:00
|
|
|
double GetCompressorCurrent() const override;
|
2021-06-05 22:36:39 -07:00
|
|
|
|
2021-09-16 18:50:27 -07:00
|
|
|
bool GetCompressorCurrentTooHighFault() const;
|
|
|
|
|
bool GetCompressorCurrentTooHighStickyFault() const;
|
|
|
|
|
bool GetCompressorShortedFault() const;
|
|
|
|
|
bool GetCompressorShortedStickyFault() const;
|
|
|
|
|
bool GetCompressorNotConnectedFault() const;
|
|
|
|
|
bool GetCompressorNotConnectedStickyFault() const;
|
2021-06-05 22:36:39 -07:00
|
|
|
|
2021-09-16 18:50:27 -07:00
|
|
|
bool GetSolenoidVoltageFault() const;
|
|
|
|
|
bool GetSolenoidVoltageStickyFault() const;
|
2021-06-05 22:36:39 -07:00
|
|
|
|
|
|
|
|
void ClearAllStickyFaults();
|
|
|
|
|
|
|
|
|
|
void SetSolenoids(int mask, int values) override;
|
|
|
|
|
|
|
|
|
|
int GetSolenoids() const override;
|
|
|
|
|
|
|
|
|
|
int GetModuleNumber() const override;
|
|
|
|
|
|
|
|
|
|
int GetSolenoidDisabledList() const override;
|
|
|
|
|
|
|
|
|
|
void FireOneShot(int index) override;
|
|
|
|
|
|
|
|
|
|
void SetOneShotDuration(int index, units::second_t duration) override;
|
|
|
|
|
|
|
|
|
|
bool CheckSolenoidChannel(int channel) const override;
|
|
|
|
|
|
2021-07-09 15:11:12 -07:00
|
|
|
int CheckAndReserveSolenoids(int mask) override;
|
|
|
|
|
|
|
|
|
|
void UnreserveSolenoids(int mask) override;
|
|
|
|
|
|
2021-09-16 18:50:27 -07:00
|
|
|
bool ReserveCompressor() override;
|
|
|
|
|
|
|
|
|
|
void UnreserveCompressor() override;
|
|
|
|
|
|
|
|
|
|
Solenoid MakeSolenoid(int channel) override;
|
|
|
|
|
DoubleSolenoid MakeDoubleSolenoid(int forwardChannel,
|
|
|
|
|
int reverseChannel) override;
|
|
|
|
|
Compressor MakeCompressor() override;
|
2021-07-09 15:11:12 -07:00
|
|
|
|
2021-06-05 22:36:39 -07:00
|
|
|
private:
|
2021-09-16 18:50:27 -07:00
|
|
|
class DataStore;
|
|
|
|
|
friend class DataStore;
|
|
|
|
|
friend class PneumaticsBase;
|
|
|
|
|
PneumaticsControlModule(HAL_CTREPCMHandle handle, int module);
|
|
|
|
|
|
|
|
|
|
static std::shared_ptr<PneumaticsBase> GetForModule(int module);
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<DataStore> m_dataStore;
|
|
|
|
|
HAL_CTREPCMHandle m_handle;
|
2021-06-05 22:36:39 -07:00
|
|
|
int m_module;
|
2021-09-16 18:50:27 -07:00
|
|
|
|
|
|
|
|
static wpi::mutex m_handleLock;
|
|
|
|
|
static std::unique_ptr<wpi::DenseMap<int, std::weak_ptr<DataStore>>>
|
|
|
|
|
m_handleMap;
|
|
|
|
|
static std::weak_ptr<DataStore>& GetDataStore(int module);
|
2021-06-05 22:36:39 -07:00
|
|
|
};
|
|
|
|
|
} // namespace frc
|