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 "SensorBase.h"
14 #include "SmartDashboard/SendableBase.h"
15 
16 namespace frc {
17 
33 class Compressor : public ErrorBase, public SendableBase {
34  public:
35  // Default PCM ID is 0
36  explicit Compressor(int pcmID = SensorBase::GetDefaultSolenoidModule());
37  ~Compressor() override = default;
38 
39  void Start();
40  void Stop();
41  bool Enabled() const;
42 
43  bool GetPressureSwitchValue() const;
44 
45  double GetCompressorCurrent() const;
46 
47  void SetClosedLoopControl(bool on);
48  bool GetClosedLoopControl() const;
49 
53  bool GetCompressorShortedFault() const;
55  bool GetCompressorNotConnectedFault() const;
57 
58  void InitSendable(SendableBuilder& builder) override;
59 
60  protected:
61  HAL_CompressorHandle m_compressorHandle;
62 
63  private:
64  void SetCompressor(bool on);
65  int m_module;
66 };
67 
68 } // namespace frc
bool GetCompressorNotConnectedStickyFault() const
Query if the compressor output does not appear to be wired (sticky).
Definition: Compressor.cpp:251
Definition: RobotController.cpp:14
bool GetCompressorCurrentTooHighStickyFault() const
Query if the compressor output has been disabled due to high current draw (sticky).
Definition: Compressor.cpp:183
void SetClosedLoopControl(bool on)
Enables or disables automatically turning the compressor on when the pressure is low.
Definition: Compressor.cpp:121
bool GetClosedLoopControl() const
Returns true if the compressor will automatically turn on when the pressure is low.
Definition: Compressor.cpp:139
bool GetPressureSwitchValue() const
Check if the pressure switch is triggered.
Definition: Compressor.cpp:81
double GetCompressorCurrent() const
Query how much current the compressor is drawing.
Definition: Compressor.cpp:100
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:159
bool Enabled() const
Check if compressor output is active.
Definition: Compressor.cpp:62
bool GetCompressorShortedFault() const
Query if the compressor output has been disabled due to a short circuit.
Definition: Compressor.cpp:228
bool GetCompressorShortedStickyFault() const
Query if the compressor output has been disabled due to a short circuit (sticky). ...
Definition: Compressor.cpp:208
bool GetCompressorNotConnectedFault() const
Query if the compressor output does not appear to be wired.
Definition: Compressor.cpp:271
Compressor(int pcmID=SensorBase::GetDefaultSolenoidModule())
Constructor.
Definition: Compressor.cpp:25
Base class for most objects.
Definition: ErrorBase.h:74
Definition: SendableBase.h:19
Definition: SendableBuilder.h:23
void Start()
Starts closed-loop control.
Definition: Compressor.cpp:43
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
Definition: Compressor.cpp:306
void ClearAllPCMStickyFaults()
Clear ALL sticky faults inside PCM that Compressor is wired to.
Definition: Compressor.cpp:295
void Stop()
Stops closed-loop control.
Definition: Compressor.cpp:52