blob: 0d56ef72136b244779d0bbd81d94f60832e6cef1 [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
Brian Silverman1a675112016-02-20 20:42:49 -05002/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */
Brian Silverman26e4e522015-12-17 01:56:40 -05003/* Open Source Software - may be modified and shared by FRC teams. The code */
Brian Silverman1a675112016-02-20 20:42:49 -05004/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
Brian Silverman26e4e522015-12-17 01:56:40 -05006/*----------------------------------------------------------------------------*/
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
18/**
19 * PCM compressor
20 */
21class 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
40 bool GetCompressorCurrentTooHighFault() const;
41 bool GetCompressorCurrentTooHighStickyFault() const;
42 bool GetCompressorShortedStickyFault() const;
43 bool GetCompressorShortedFault() const;
44 bool GetCompressorNotConnectedStickyFault() const;
45 bool GetCompressorNotConnectedFault() const;
46 void ClearAllPCMStickyFaults();
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_ */