blob: d5962c370d84c7042017188afa59e5a0cc7a7ac1 [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2014. 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 $(WIND_BASE)/WPILib. */
5/*----------------------------------------------------------------------------*/
6
7#ifndef Compressor_H_
8#define Compressor_H_
9
10#include "HAL/HAL.hpp"
11#include "SensorBase.h"
12#include "tables/ITableListener.h"
13#include "LiveWindow/LiveWindowSendable.h"
14
15#include <memory>
16
17/**
18 * PCM compressor
19 */
20class Compressor : public SensorBase,
21 public LiveWindowSendable,
22 public ITableListener {
23 public:
24 // Default PCM ID is 0
25 explicit Compressor(uint8_t pcmID = GetDefaultSolenoidModule());
26 virtual ~Compressor() = default;
27
28 void Start();
29 void Stop();
30 bool Enabled() const;
31
32 bool GetPressureSwitchValue() const;
33
34 float GetCompressorCurrent() const;
35
36 void SetClosedLoopControl(bool on);
37 bool GetClosedLoopControl() const;
38
39 bool GetCompressorCurrentTooHighFault() const;
40 bool GetCompressorCurrentTooHighStickyFault() const;
41 bool GetCompressorShortedStickyFault() const;
42 bool GetCompressorShortedFault() const;
43 bool GetCompressorNotConnectedStickyFault() const;
44 bool GetCompressorNotConnectedFault() const;
45 void ClearAllPCMStickyFaults();
46
47 void UpdateTable() override;
48 void StartLiveWindowMode() override;
49 void StopLiveWindowMode() override;
50 std::string GetSmartDashboardType() const override;
51 void InitTable(std::shared_ptr<ITable> subTable) override;
52 std::shared_ptr<ITable> GetTable() const override;
53 void ValueChanged(ITable* source, llvm::StringRef key,
54 std::shared_ptr<nt::Value> value, bool isNew) override;
55
56 protected:
57 void *m_pcm_pointer;
58
59 private:
60 void SetCompressor(bool on);
61
62 std::shared_ptr<ITable> m_table;
63};
64
65#endif /* Compressor_H_ */