Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame^] | 1 | /*----------------------------------------------------------------------------*/ |
| 2 | /* Copyright (c) FIRST 2008. 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 | #pragma once |
| 7 | |
| 8 | #include "simulation/SimDigitalInput.h" |
| 9 | #include "LiveWindow/LiveWindowSendable.h" |
| 10 | |
| 11 | #include <memory> |
| 12 | |
| 13 | /** |
| 14 | * Class to read a digital input. |
| 15 | * This class will read digital inputs and return the current value on the channel. Other devices |
| 16 | * such as encoders, gear tooth sensors, etc. that are implemented elsewhere will automatically |
| 17 | * allocate digital inputs and outputs as required. This class is only for devices like switches |
| 18 | * etc. that aren't implemented anywhere else. |
| 19 | */ |
| 20 | class DigitalInput : public LiveWindowSendable { |
| 21 | public: |
| 22 | explicit DigitalInput(uint32_t channel); |
| 23 | virtual ~DigitalInput() = default; |
| 24 | uint32_t Get() const; |
| 25 | uint32_t GetChannel() const; |
| 26 | |
| 27 | void UpdateTable() override; |
| 28 | void StartLiveWindowMode() override; |
| 29 | void StopLiveWindowMode() override; |
| 30 | std::string GetSmartDashboardType() const override; |
| 31 | void InitTable(std::shared_ptr<ITable> subTable) override; |
| 32 | std::shared_ptr<ITable> GetTable() const override; |
| 33 | |
| 34 | private: |
| 35 | uint32_t m_channel; |
| 36 | bool m_lastValue; |
| 37 | SimDigitalInput *m_impl; |
| 38 | |
| 39 | std::shared_ptr<ITable> m_table; |
| 40 | }; |