WPILibC++  2018.4.1-20180729123227-1139-ga11fcb6
 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 
48  void Start();
49 
54  void Stop();
55 
61  bool Enabled() const;
62 
68  bool GetPressureSwitchValue() const;
69 
75  double GetCompressorCurrent() const;
76 
84  void SetClosedLoopControl(bool on);
85 
93  bool GetClosedLoopControl() const;
94 
102 
114 
125  bool GetCompressorShortedStickyFault() const;
126 
133  bool GetCompressorShortedFault() const;
134 
145 
152  bool GetCompressorNotConnectedFault() const;
153 
165 
166  void InitSendable(SendableBuilder& builder) override;
167 
168  protected:
169  HAL_CompressorHandle m_compressorHandle;
170 
171  private:
172  void SetCompressor(bool on);
173  int m_module;
174 };
175 
176 } // 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.
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.