WPILibC++  2019.1.1-beta-4-28-g80f87ff
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Compressor.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2014-2018 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/SendableBase.h"
15 
16 namespace frc {
17 
33 class Compressor : public ErrorBase, public SendableBase {
34  public:
40  explicit Compressor(int pcmID = SensorUtil::GetDefaultSolenoidModule());
41 
42  ~Compressor() override = default;
43 
44  Compressor(Compressor&&) = default;
45  Compressor& operator=(Compressor&&) = default;
46 
51  void Start();
52 
57  void Stop();
58 
64  bool Enabled() const;
65 
71  bool GetPressureSwitchValue() const;
72 
78  double GetCompressorCurrent() const;
79 
87  void SetClosedLoopControl(bool on);
88 
96  bool GetClosedLoopControl() const;
97 
105 
117 
128  bool GetCompressorShortedStickyFault() const;
129 
136  bool GetCompressorShortedFault() const;
137 
148 
155  bool GetCompressorNotConnectedFault() const;
156 
168 
169  void InitSendable(SendableBuilder& builder) override;
170 
171  protected:
172  HAL_CompressorHandle m_compressorHandle = HAL_kInvalidHandle;
173 
174  private:
175  void SetCompressor(bool on);
176  int m_module;
177 };
178 
179 } // namespace frc
void ClearAllPCMStickyFaults()
Clear ALL sticky faults inside PCM that Compressor is wired to.
double GetCompressorCurrent() const
Query how much current the compressor is drawing.
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
bool GetPressureSwitchValue() const
Check if the pressure switch is triggered.
static int GetDefaultSolenoidModule()
Get the number of the default solenoid module.
bool Enabled() const
Check if compressor output is active.
bool GetCompressorShortedStickyFault() const
Query if the compressor output has been disabled due to a short circuit (sticky). ...
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
Class for operating a compressor connected to a PCM (Pneumatic Control Module).
Definition: Compressor.h:33
void Stop()
Stops closed-loop control.
bool GetCompressorCurrentTooHighFault() const
Query if the compressor output has been disabled due to high current draw.
bool GetCompressorCurrentTooHighStickyFault() const
Query if the compressor output has been disabled due to high current draw (sticky).
bool GetCompressorNotConnectedFault() const
Query if the compressor output does not appear to be wired.
bool GetCompressorShortedFault() const
Query if the compressor output has been disabled due to a short circuit.
Base class for most objects.
Definition: ErrorBase.h:74
Compressor(int pcmID=SensorUtil::GetDefaultSolenoidModule())
Constructor.
Definition: SendableBase.h:19
Definition: SendableBuilder.h:23
bool GetCompressorNotConnectedStickyFault() const
Query if the compressor output does not appear to be wired (sticky).
void Start()
Starts closed-loop control.
void SetClosedLoopControl(bool on)
Enables or disables automatically turning the compressor on when the pressure is low.
bool GetClosedLoopControl() const
Returns true if the compressor will automatically turn on when the pressure is low.