Brian Silverman | f7f267a | 2017-02-04 16:16:08 -0800 | [diff] [blame^] | 1 | /*----------------------------------------------------------------------------*/ |
| 2 | /* Copyright (c) FIRST 2008-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 "SolenoidBase.h" |
| 16 | #include "tables/ITableListener.h" |
| 17 | |
| 18 | namespace frc { |
| 19 | |
| 20 | /** |
| 21 | * Solenoid class for running high voltage Digital Output (PCM). |
| 22 | * |
| 23 | * The Solenoid class is typically used for pneumatics solenoids, but could be |
| 24 | * used for any device within the current spec of the PCM. |
| 25 | */ |
| 26 | class Solenoid : public SolenoidBase, |
| 27 | public LiveWindowSendable, |
| 28 | public ITableListener { |
| 29 | public: |
| 30 | explicit Solenoid(int channel); |
| 31 | Solenoid(int moduleNumber, int channel); |
| 32 | virtual ~Solenoid(); |
| 33 | virtual void Set(bool on); |
| 34 | virtual bool Get() const; |
| 35 | bool IsBlackListed() const; |
| 36 | |
| 37 | void ValueChanged(ITable* source, llvm::StringRef key, |
| 38 | std::shared_ptr<nt::Value> value, bool isNew); |
| 39 | void UpdateTable(); |
| 40 | void StartLiveWindowMode(); |
| 41 | void StopLiveWindowMode(); |
| 42 | std::string GetSmartDashboardType() const; |
| 43 | void InitTable(std::shared_ptr<ITable> subTable); |
| 44 | std::shared_ptr<ITable> GetTable() const; |
| 45 | |
| 46 | private: |
| 47 | HAL_SolenoidHandle m_solenoidHandle = HAL_kInvalidHandle; |
| 48 | int m_channel; ///< The channel on the module to control. |
| 49 | std::shared_ptr<ITable> m_table; |
| 50 | }; |
| 51 | |
| 52 | } // namespace frc |