WPILibC++  unspecified
Compressor.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2014-2017 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 <memory>
11 #include <string>
12 
13 #include <HAL/Types.h>
14 
15 #include "LiveWindow/LiveWindowSendable.h"
16 #include "SensorBase.h"
17 #include "networktables/NetworkTableEntry.h"
18 
19 namespace frc {
20 
34 class Compressor : public SensorBase, public LiveWindowSendable {
35  public:
36  // Default PCM ID is 0
37  explicit Compressor(int pcmID = GetDefaultSolenoidModule());
38  virtual ~Compressor();
39 
40  void Start();
41  void Stop();
42  bool Enabled() const;
43 
44  bool GetPressureSwitchValue() const;
45 
46  double GetCompressorCurrent() const;
47 
48  void SetClosedLoopControl(bool on);
49  bool GetClosedLoopControl() const;
50 
54  bool GetCompressorShortedFault() const;
56  bool GetCompressorNotConnectedFault() const;
58 
59  void UpdateTable() override;
60  void StartLiveWindowMode() override;
61  void StopLiveWindowMode() override;
62  std::string GetSmartDashboardType() const override;
63  void InitTable(std::shared_ptr<nt::NetworkTable> subTable) override;
64 
65  protected:
66  HAL_CompressorHandle m_compressorHandle;
67 
68  private:
69  void SetCompressor(bool on);
70  int m_module;
71 
72  nt::NetworkTableEntry m_enabledEntry;
73  nt::NetworkTableEntry m_pressureSwitchEntry;
74  NT_EntryListener m_enabledListener = 0;
75 };
76 
77 } // namespace frc
bool GetCompressorNotConnectedStickyFault() const
Query if the compressor output does not appear to be wired (sticky).
Definition: Compressor.cpp:256
Definition: Timer.cpp:18
bool GetCompressorCurrentTooHighStickyFault() const
Query if the compressor output has been disabled due to high current draw (sticky).
Definition: Compressor.cpp:188
void SetClosedLoopControl(bool on)
Enables or disables automatically turning the compressor on when the pressure is low.
Definition: Compressor.cpp:126
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:17
void StopLiveWindowMode() override
Stop having this sendable object automatically respond to value changes.
Definition: Compressor.cpp:331
bool GetClosedLoopControl() const
Returns true if the compressor will automatically turn on when the pressure is low.
Definition: Compressor.cpp:144
Base class for all sensors.
Definition: SensorBase.h:20
bool GetPressureSwitchValue() const
Check if the pressure switch is triggered.
Definition: Compressor.cpp:86
double GetCompressorCurrent() const
Query how much current the compressor is drawing.
Definition: Compressor.cpp:105
Class for operating a compressor connected to a PCM (Pneumatic Control Module).
Definition: Compressor.h:34
bool GetCompressorCurrentTooHighFault() const
Query if the compressor output has been disabled due to high current draw.
Definition: Compressor.cpp:164
Compressor(int pcmID=GetDefaultSolenoidModule())
Constructor.
Definition: Compressor.cpp:24
bool Enabled() const
Check if compressor output is active.
Definition: Compressor.cpp:67
bool GetCompressorShortedFault() const
Query if the compressor output has been disabled due to a short circuit.
Definition: Compressor.cpp:233
virtual ~Compressor()
Destructor.
Definition: Compressor.cpp:40
bool GetCompressorShortedStickyFault() const
Query if the compressor output has been disabled due to a short circuit (sticky). ...
Definition: Compressor.cpp:213
bool GetCompressorNotConnectedFault() const
Query if the compressor output does not appear to be wired.
Definition: Compressor.cpp:276
void StartLiveWindowMode() override
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: Compressor.cpp:317
void InitTable(std::shared_ptr< nt::NetworkTable > subTable) override
Initializes a table for this sendable object.
Definition: Compressor.cpp:340
void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: Compressor.cpp:311
NetworkTables Entry.
Definition: NetworkTableEntry.h:30
std::string GetSmartDashboardType() const override
Definition: Compressor.cpp:338
void Start()
Starts closed-loop control.
Definition: Compressor.cpp:48
void ClearAllPCMStickyFaults()
Clear ALL sticky faults inside PCM that Compressor is wired to.
Definition: Compressor.cpp:300
void Stop()
Stops closed-loop control.
Definition: Compressor.cpp:57