Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame^] | 1 | /*----------------------------------------------------------------------------*/ |
| 2 | /* Copyright (c) FIRST 2008. All Rights Reserved. |
| 3 | */ |
| 4 | /* Open Source Software - may be modified and shared by FRC teams. The code */ |
| 5 | /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ |
| 6 | /*----------------------------------------------------------------------------*/ |
| 7 | #pragma once |
| 8 | |
| 9 | #include "DigitalSource.h" |
| 10 | #include "LiveWindow/LiveWindowSendable.h" |
| 11 | |
| 12 | #include <memory> |
| 13 | #include <cstdint> |
| 14 | |
| 15 | class DigitalGlitchFilter; |
| 16 | |
| 17 | /** |
| 18 | * Class to read a digital input. |
| 19 | * This class will read digital inputs and return the current value on the |
| 20 | * channel. Other devices |
| 21 | * such as encoders, gear tooth sensors, etc. that are implemented elsewhere |
| 22 | * will automatically |
| 23 | * allocate digital inputs and outputs as required. This class is only for |
| 24 | * devices like switches |
| 25 | * etc. that aren't implemented anywhere else. |
| 26 | */ |
| 27 | class DigitalInput : public DigitalSource, public LiveWindowSendable { |
| 28 | public: |
| 29 | explicit DigitalInput(uint32_t channel); |
| 30 | virtual ~DigitalInput(); |
| 31 | bool Get() const; |
| 32 | uint32_t GetChannel() const; |
| 33 | |
| 34 | // Digital Source Interface |
| 35 | virtual uint32_t GetChannelForRouting() const; |
| 36 | virtual uint32_t GetModuleForRouting() const; |
| 37 | virtual bool GetAnalogTriggerForRouting() const; |
| 38 | |
| 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 | uint32_t m_channel; |
| 48 | |
| 49 | std::shared_ptr<ITable> m_table; |
| 50 | friend class DigitalGlitchFilter; |
| 51 | }; |