WPILibC++  2020.3.2
Compressor.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <hal/Types.h>
11 
12 #include "frc/ErrorBase.h"
13 #include "frc/SensorUtil.h"
14 #include "frc/smartdashboard/Sendable.h"
15 #include "frc/smartdashboard/SendableHelper.h"
16 
17 namespace frc {
18 
19 class SendableBuilder;
20 
36 class Compressor : public ErrorBase,
37  public Sendable,
38  public SendableHelper<Compressor> {
39  public:
45  explicit Compressor(int pcmID = SensorUtil::GetDefaultSolenoidModule());
46 
47  ~Compressor() override = default;
48 
49  Compressor(Compressor&&) = default;
50  Compressor& operator=(Compressor&&) = default;
51 
56  void Start();
57 
62  void Stop();
63 
69  bool Enabled() const;
70 
76  bool GetPressureSwitchValue() const;
77 
83  double GetCompressorCurrent() const;
84 
92  void SetClosedLoopControl(bool on);
93 
101  bool GetClosedLoopControl() const;
102 
110 
122 
133  bool GetCompressorShortedStickyFault() const;
134 
141  bool GetCompressorShortedFault() const;
142 
153 
160  bool GetCompressorNotConnectedFault() const;
161 
173 
174  void InitSendable(SendableBuilder& builder) override;
175 
176  protected:
177  hal::Handle<HAL_CompressorHandle> m_compressorHandle;
178 
179  private:
180  void SetCompressor(bool on);
181  int m_module;
182 };
183 
184 } // namespace frc
frc::Compressor::Start
void Start()
Starts closed-loop control.
frc::Compressor::ClearAllPCMStickyFaults
void ClearAllPCMStickyFaults()
Clear ALL sticky faults inside PCM that Compressor is wired to.
frc::SensorUtil::GetDefaultSolenoidModule
static int GetDefaultSolenoidModule()
Get the number of the default solenoid module.
frc::Compressor::GetCompressorNotConnectedStickyFault
bool GetCompressorNotConnectedStickyFault() const
Query if the compressor output does not appear to be wired (sticky).
frc::Compressor::GetPressureSwitchValue
bool GetPressureSwitchValue() const
Check if the pressure switch is triggered.
frc::Compressor::GetCompressorCurrentTooHighStickyFault
bool GetCompressorCurrentTooHighStickyFault() const
Query if the compressor output has been disabled due to high current draw (sticky).
frc::Compressor::InitSendable
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
frc::Compressor::Stop
void Stop()
Stops closed-loop control.
frc::Compressor::GetCompressorShortedFault
bool GetCompressorShortedFault() const
Query if the compressor output has been disabled due to a short circuit.
frc::ErrorBase
Base class for most objects.
Definition: ErrorBase.h:104
frc::Compressor::GetCompressorCurrent
double GetCompressorCurrent() const
Query how much current the compressor is drawing.
frc::Compressor
Class for operating a compressor connected to a PCM (Pneumatic Control Module).
Definition: Compressor.h:36
frc::Compressor::GetCompressorNotConnectedFault
bool GetCompressorNotConnectedFault() const
Query if the compressor output does not appear to be wired.
frc::Compressor::GetCompressorShortedStickyFault
bool GetCompressorShortedStickyFault() const
Query if the compressor output has been disabled due to a short circuit (sticky).
frc::Sendable
Interface for Sendable objects.
Definition: Sendable.h:17
frc::Compressor::GetClosedLoopControl
bool GetClosedLoopControl() const
Returns true if the compressor will automatically turn on when the pressure is low.
frc::Compressor::Enabled
bool Enabled() const
Check if compressor output is active.
frc::Compressor::GetCompressorCurrentTooHighFault
bool GetCompressorCurrentTooHighFault() const
Query if the compressor output has been disabled due to high current draw.
frc
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
frc::Compressor::Compressor
Compressor(int pcmID=SensorUtil::GetDefaultSolenoidModule())
Constructor.
frc::Compressor::SetClosedLoopControl
void SetClosedLoopControl(bool on)
Enables or disables automatically turning the compressor on when the pressure is low.
frc::SendableHelper
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:28
frc::SendableBuilder
Definition: SendableBuilder.h:23