WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2014-2017. 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 /*----------------------------------------------------------------------------*/
8 #pragma once
10 #include <memory>
11 #include <string>
13 #include "HAL/Types.h"
14 #include "LiveWindow/LiveWindowSendable.h"
15 #include "SensorBase.h"
16 #include "tables/ITableListener.h"
18 namespace frc {
23 class Compressor : public SensorBase,
24  public LiveWindowSendable,
25  public ITableListener {
26  public:
27  // Default PCM ID is 0
28  explicit Compressor(int pcmID = GetDefaultSolenoidModule());
29  virtual ~Compressor() = default;
31  void Start();
32  void Stop();
33  bool Enabled() const;
35  bool GetPressureSwitchValue() const;
37  double GetCompressorCurrent() const;
39  void SetClosedLoopControl(bool on);
40  bool GetClosedLoopControl() const;
45  bool GetCompressorShortedFault() const;
47  bool GetCompressorNotConnectedFault() const;
50  void UpdateTable() override;
51  void StartLiveWindowMode() override;
52  void StopLiveWindowMode() override;
53  std::string GetSmartDashboardType() const override;
54  void InitTable(std::shared_ptr<ITable> subTable) override;
55  std::shared_ptr<ITable> GetTable() const override;
56  void ValueChanged(ITable* source, llvm::StringRef key,
57  std::shared_ptr<nt::Value> value, bool isNew) override;
59  protected:
60  HAL_CompressorHandle m_compressorHandle;
62  private:
63  void SetCompressor(bool on);
64  int m_module;
66  std::shared_ptr<ITable> m_table;
67 };
69 } // namespace frc
bool GetCompressorNotConnectedStickyFault() const
Query if the compressor output does not appear to be wired (sticky).
Definition: Compressor.cpp:246
A table whose values can be read and written to.
Definition: ITable.h:22
bool GetCompressorCurrentTooHighStickyFault() const
Query if the compressor output has been disabled due to high current draw (sticky).
Definition: Compressor.cpp:178
void SetClosedLoopControl(bool on)
Enables or disables automatically turning the compressor on when the pressure is low.
Definition: Compressor.cpp:116
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:310
bool GetClosedLoopControl() const
Returns true if the compressor will automatically turn on when the pressure is low.
Definition: Compressor.cpp:134
Base class for all sensors.
Definition: SensorBase.h:22
bool GetPressureSwitchValue() const
Check if the pressure switch is triggered.
Definition: Compressor.cpp:76
double GetCompressorCurrent() const
Query how much current the compressor is drawing.
Definition: Compressor.cpp:95
void InitTable(std::shared_ptr< ITable > subTable) override
Initializes a table for this sendable object.
Definition: Compressor.cpp:314
PCM compressor.
Definition: Compressor.h:23
bool GetCompressorCurrentTooHighFault() const
Query if the compressor output has been disabled due to high current draw.
Definition: Compressor.cpp:154
Compressor(int pcmID=GetDefaultSolenoidModule())
Definition: Compressor.cpp:23
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:321
bool Enabled() const
Check if compressor output is active.
Definition: Compressor.cpp:57
bool GetCompressorShortedFault() const
Query if the compressor output has been disabled due to a short circuit.
Definition: Compressor.cpp:223
std::shared_ptr< ITable > GetTable() const override
Definition: Compressor.cpp:319
bool GetCompressorShortedStickyFault() const
Query if the compressor output has been disabled due to a short circuit (sticky). ...
Definition: Compressor.cpp:203
bool GetCompressorNotConnectedFault() const
Query if the compressor output does not appear to be wired.
Definition: Compressor.cpp:266
void StartLiveWindowMode() override
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: Compressor.cpp:308
A listener that listens to changes in values in a ITable.
Definition: ITableListener.h:18
void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: Compressor.cpp:301
std::string GetSmartDashboardType() const override
Definition: Compressor.cpp:312
void Start()
Starts closed-loop control.
Definition: Compressor.cpp:38
void ClearAllPCMStickyFaults()
Clear ALL sticky faults inside PCM that Compressor is wired to.
Definition: Compressor.cpp:290
void Stop()
Stops closed-loop control.
Definition: Compressor.cpp:47