blob: 9f3f25ff5bac80c4eed5041656ac2c393abb78a3 [file] [log] [blame]
jerrymf1579332013-02-07 01:56:28 +00001/*----------------------------------------------------------------------------*/
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
7#ifndef DIGITAL_INPUT_H_
8#define DIGITAL_INPUT_H_
9
10class DigitalModule;
11
12#include "DigitalSource.h"
13#include "LiveWindow/LiveWindowSendable.h"
14
15/**
16 * Class to read a digital input.
17 * This class will read digital inputs and return the current value on the channel. Other devices
18 * such as encoders, gear tooth sensors, etc. that are implemented elsewhere will automatically
19 * allocate digital inputs and outputs as required. This class is only for devices like switches
20 * etc. that aren't implemented anywhere else.
21 */
22class DigitalInput : public DigitalSource, public LiveWindowSendable {
23public:
24 explicit DigitalInput(UINT32 channel);
25 DigitalInput(UINT8 moduleNumber, UINT32 channel);
26 virtual ~DigitalInput();
27 UINT32 Get();
28 UINT32 GetChannel();
29
30 // Digital Source Interface
31 virtual UINT32 GetChannelForRouting();
32 virtual UINT32 GetModuleForRouting();
33 virtual bool GetAnalogTriggerForRouting();
34
35 // Interruptable Interface
36 virtual void RequestInterrupts(tInterruptHandler handler, void *param=NULL); ///< Asynchronus handler version.
37 virtual void RequestInterrupts(); ///< Synchronus Wait version.
38 void SetUpSourceEdge(bool risingEdge, bool fallingEdge);
39
40 void UpdateTable();
41 void StartLiveWindowMode();
42 void StopLiveWindowMode();
43 std::string GetSmartDashboardType();
44 void InitTable(ITable *subTable);
45 ITable * GetTable();
46
47private:
48 void InitDigitalInput(UINT8 moduleNumber, UINT32 channel);
49 UINT32 m_channel;
50 DigitalModule *m_module;
51 bool m_lastValue;
52
53 ITable *m_table;
54};
55
56#endif
57