blob: 7bb7e8dca85e91b16fd2ef71e057becc2616d212 [file] [log] [blame]
Brian Silvermanf7f267a2017-02-04 16:16:08 -08001/*----------------------------------------------------------------------------*/
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/*----------------------------------------------------------------------------*/
7
8#pragma once
9
10#include <memory>
11#include <string>
12
13#include "HAL/Types.h"
14#include "LiveWindow/LiveWindowSendable.h"
15#include "SensorBase.h"
16#include "tables/ITableListener.h"
17
18namespace frc {
19
20/**
21 * PCM compressor
22 */
23class 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;
30
31 void Start();
32 void Stop();
33 bool Enabled() const;
34
35 bool GetPressureSwitchValue() const;
36
37 double GetCompressorCurrent() const;
38
39 void SetClosedLoopControl(bool on);
40 bool GetClosedLoopControl() const;
41
42 bool GetCompressorCurrentTooHighFault() const;
43 bool GetCompressorCurrentTooHighStickyFault() const;
44 bool GetCompressorShortedStickyFault() const;
45 bool GetCompressorShortedFault() const;
46 bool GetCompressorNotConnectedStickyFault() const;
47 bool GetCompressorNotConnectedFault() const;
48 void ClearAllPCMStickyFaults();
49
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;
58
59 protected:
60 HAL_CompressorHandle m_compressorHandle;
61
62 private:
63 void SetCompressor(bool on);
64 int m_module;
65
66 std::shared_ptr<ITable> m_table;
67};
68
69} // namespace frc