Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 2 | /* Copyright (c) FIRST 2008-2016. All Rights Reserved. */ |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ |
| 5 | /* the project. */ |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 6 | /*----------------------------------------------------------------------------*/ |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 7 | |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 8 | #pragma once |
| 9 | |
| 10 | #include "simulation/SimContinuousOutput.h" |
| 11 | #include "LiveWindow/LiveWindowSendable.h" |
| 12 | #include "tables/ITableListener.h" |
| 13 | |
| 14 | #include <memory> |
| 15 | |
| 16 | /** |
| 17 | * DoubleSolenoid class for running 2 channels of high voltage Digital Output |
| 18 | * (PCM). |
| 19 | * |
| 20 | * The DoubleSolenoid class is typically used for pneumatics solenoids that |
| 21 | * have two positions controlled by two separate channels. |
| 22 | */ |
| 23 | class DoubleSolenoid : public LiveWindowSendable, public ITableListener |
| 24 | { |
| 25 | public: |
| 26 | enum Value |
| 27 | { |
| 28 | kOff, |
| 29 | kForward, |
| 30 | kReverse |
| 31 | }; |
| 32 | |
| 33 | explicit DoubleSolenoid(uint32_t forwardChannel, uint32_t reverseChannel); |
| 34 | DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel, uint32_t reverseChannel); |
| 35 | virtual ~DoubleSolenoid(); |
| 36 | virtual void Set(Value value); |
| 37 | virtual Value Get() const; |
| 38 | |
| 39 | void ValueChanged(ITable* source, llvm::StringRef key, |
| 40 | std::shared_ptr<nt::Value> value, bool isNew) override; |
| 41 | void UpdateTable() override; |
| 42 | void StartLiveWindowMode() override; |
| 43 | void StopLiveWindowMode() override; |
| 44 | std::string GetSmartDashboardType() const override; |
| 45 | void InitTable(std::shared_ptr<ITable> subTable) override; |
| 46 | std::shared_ptr<ITable> GetTable() const override; |
| 47 | |
| 48 | private: |
| 49 | SimContinuousOutput* m_impl; |
| 50 | Value m_value; |
| 51 | bool m_reversed; |
| 52 | |
| 53 | std::shared_ptr<ITable> m_table; |
| 54 | }; |