WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
Compressor.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2014-2016. 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 #ifndef Compressor_H_
9 #define Compressor_H_
10 
11 #include "HAL/HAL.hpp"
12 #include "SensorBase.h"
13 #include "tables/ITableListener.h"
14 #include "LiveWindow/LiveWindowSendable.h"
15 
16 #include <memory>
17 
21 class Compressor : public SensorBase,
22  public LiveWindowSendable,
23  public ITableListener {
24  public:
25  // Default PCM ID is 0
26  explicit Compressor(uint8_t pcmID = GetDefaultSolenoidModule());
27  virtual ~Compressor() = default;
28 
29  void Start();
30  void Stop();
31  bool Enabled() const;
32 
33  bool GetPressureSwitchValue() const;
34 
35  float GetCompressorCurrent() const;
36 
37  void SetClosedLoopControl(bool on);
38  bool GetClosedLoopControl() const;
39 
43  bool GetCompressorShortedFault() const;
45  bool GetCompressorNotConnectedFault() const;
47 
48  void UpdateTable() override;
49  void StartLiveWindowMode() override;
50  void StopLiveWindowMode() override;
51  std::string GetSmartDashboardType() const override;
52  void InitTable(std::shared_ptr<ITable> subTable) override;
53  std::shared_ptr<ITable> GetTable() const override;
54  void ValueChanged(ITable* source, llvm::StringRef key,
55  std::shared_ptr<nt::Value> value, bool isNew) override;
56 
57  protected:
58  void *m_pcm_pointer;
59 
60  private:
61  void SetCompressor(bool on);
62 
63  std::shared_ptr<ITable> m_table;
64 };
65 
66 #endif /* Compressor_H_ */
Compressor(uint8_t pcmID=GetDefaultSolenoidModule())
Constructor.
Definition: Compressor.cpp:13
void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: Compressor.cpp:250
A table whose values can be read and written to.
Definition: ITable.h:43
std::string GetSmartDashboardType() const override
Definition: Compressor.cpp:261
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:18
bool GetCompressorShortedStickyFault() const
Query if the compressor output has been disabled due to a short circuit (sticky). ...
Definition: Compressor.cpp:161
std::shared_ptr< ITable > GetTable() const override
Definition: Compressor.cpp:268
bool GetCompressorShortedFault() const
Query if the compressor output has been disabled due to a short circuit.
Definition: Compressor.cpp:178
bool GetPressureSwitchValue() const
Check if the pressure switch is triggered.
Definition: Compressor.cpp:51
bool GetClosedLoopControl() const
Returns true if the compressor will automatically turn on when the pressure is low.
Definition: Compressor.cpp:103
void ValueChanged(ITable *source, llvm::StringRef key, std::shared_ptr< nt::Value > value, bool isNew) override
Called when a key-value pair is changed in a ITable.
Definition: Compressor.cpp:270
void StartLiveWindowMode() override
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: Compressor.cpp:257
Base class for all sensors.
Definition: SensorBase.h:20
PCM compressor.
Definition: Compressor.h:21
bool GetCompressorNotConnectedStickyFault() const
Query if the compressor output does not appear to be wired (sticky).
Definition: Compressor.cpp:198
bool GetCompressorCurrentTooHighStickyFault() const
Query if the compressor output has been disabled due to high current draw (sticky).
Definition: Compressor.cpp:141
void Stop()
Stops closed-loop control.
Definition: Compressor.cpp:28
void SetClosedLoopControl(bool on)
Enables or disables automatically turning the compressor on when the pressure is low.
Definition: Compressor.cpp:87
bool GetCompressorNotConnectedFault() const
Query if the compressor output does not appear to be wired.
Definition: Compressor.cpp:216
A listener that listens to changes in values in a ITable.
Definition: ITableListener.h:18
float GetCompressorCurrent() const
Query how much current the compressor is drawing.
Definition: Compressor.cpp:68
bool Enabled() const
Check if compressor output is active.
Definition: Compressor.cpp:34
void InitTable(std::shared_ptr< ITable > subTable) override
Initializes a table for this sendable object.
Definition: Compressor.cpp:263
void StopLiveWindowMode() override
Stop having this sendable object automatically respond to value changes.
Definition: Compressor.cpp:259
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:39
void Start()
Starts closed-loop control.
Definition: Compressor.cpp:22
bool GetCompressorCurrentTooHighFault() const
Query if the compressor output has been disabled due to high current draw.
Definition: Compressor.cpp:121
void ClearAllPCMStickyFaults()
Clear ALL sticky faults inside PCM that Compressor is wired to.
Definition: Compressor.cpp:241