WPILibC++  unspecified
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 "ErrorBase.h"
13 #include "SensorUtil.h"
14 #include "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
bool GetCompressorNotConnectedStickyFault() const
Query if the compressor output does not appear to be wired (sticky).
Definition: Compressor.cpp:168
Definition: Utility.cpp:119
bool GetCompressorCurrentTooHighStickyFault() const
Query if the compressor output has been disabled due to high current draw (sticky).
Definition: Compressor.cpp:125
void SetClosedLoopControl(bool on)
Enables or disables automatically turning the compressor on when the pressure is low.
Definition: Compressor.cpp:86
bool GetClosedLoopControl() const
Returns true if the compressor will automatically turn on when the pressure is low.
Definition: Compressor.cpp:97
bool GetPressureSwitchValue() const
Check if the pressure switch is triggered.
Definition: Compressor.cpp:58
double GetCompressorCurrent() const
Query how much current the compressor is drawing.
Definition: Compressor.cpp:72
Class for operating a compressor connected to a PCM (Pneumatic Control Module).
Definition: Compressor.h:33
bool GetCompressorCurrentTooHighFault() const
Query if the compressor output has been disabled due to high current draw.
Definition: Compressor.cpp:111
bool Enabled() const
Check if compressor output is active.
Definition: Compressor.cpp:44
bool GetCompressorShortedFault() const
Query if the compressor output has been disabled due to a short circuit.
Definition: Compressor.cpp:154
bool GetCompressorShortedStickyFault() const
Query if the compressor output has been disabled due to a short circuit (sticky). ...
Definition: Compressor.cpp:140
bool GetCompressorNotConnectedFault() const
Query if the compressor output does not appear to be wired.
Definition: Compressor.cpp:182
Base class for most objects.
Definition: ErrorBase.h:74
Compressor(int pcmID=SensorUtil::GetDefaultSolenoidModule())
Constructor.
Definition: Compressor.cpp:20
Definition: SendableBase.h:19
Definition: SendableBuilder.h:23
void Start()
Starts closed-loop control.
Definition: Compressor.cpp:34
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
Definition: Compressor.cpp:207
void ClearAllPCMStickyFaults()
Clear ALL sticky faults inside PCM that Compressor is wired to.
Definition: Compressor.cpp:196
void Stop()
Stops closed-loop control.
Definition: Compressor.cpp:39