WPILib  2014.0
WPIRoboticsLibraryforFRC
 All Classes Functions Variables Pages
AnalogChannel.h
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 
7 #ifndef ANALOG_CHANNEL_H_
8 #define ANALOG_CHANNEL_H_
9 
10 #include "ChipObject.h"
11 #include "SensorBase.h"
12 #include "PIDSource.h"
13 #include "LiveWindow/LiveWindowSendable.h"
14 
15 class AnalogModule;
16 
29 class AnalogChannel : public SensorBase, public PIDSource, public LiveWindowSendable
30 {
31 public:
32  static const uint8_t kAccumulatorModuleNumber = 1;
33  static const uint32_t kAccumulatorNumChannels = 2;
34  static const uint32_t kAccumulatorChannels[kAccumulatorNumChannels];
35 
36  AnalogChannel(uint8_t moduleNumber, uint32_t channel);
37  explicit AnalogChannel(uint32_t channel);
38  virtual ~AnalogChannel();
39 
41 
42  int16_t GetValue();
43  int32_t GetAverageValue();
44 
45  float GetVoltage();
46  float GetAverageVoltage();
47 
48  uint8_t GetModuleNumber();
49  uint32_t GetChannel();
50 
51  void SetAverageBits(uint32_t bits);
52  uint32_t GetAverageBits();
53  void SetOversampleBits(uint32_t bits);
54  uint32_t GetOversampleBits();
55 
56  uint32_t GetLSBWeight();
57  int32_t GetOffset();
58 
59  bool IsAccumulatorChannel();
60  void InitAccumulator();
61  void SetAccumulatorInitialValue(INT64 value);
62  void ResetAccumulator();
63  void SetAccumulatorCenter(int32_t center);
64  void SetAccumulatorDeadband(int32_t deadband);
65  INT64 GetAccumulatorValue();
66  uint32_t GetAccumulatorCount();
67  void GetAccumulatorOutput(INT64 *value, uint32_t *count);
68  void SetVoltageForPID(bool shouldUseVoltageForPID);
69 
70  double PIDGet();
71 
72  void UpdateTable();
73  void StartLiveWindowMode();
74  void StopLiveWindowMode();
75  std::string GetSmartDashboardType();
76  void InitTable(ITable *subTable);
77  ITable * GetTable();
78 
79 private:
80  void InitChannel(uint8_t moduleNumber, uint32_t channel);
81  uint32_t m_channel;
82  AnalogModule *m_module;
83  tAccumulator *m_accumulator;
84  INT64 m_accumulatorOffset;
85  bool m_shouldUseVoltageForPID;
86 
87  ITable *m_table;
88 };
89 
90 #endif
Definition: AnalogModule.h:20
int32_t GetOffset()
Definition: AnalogChannel.cpp:179
void SetAccumulatorDeadband(int32_t deadband)
Definition: AnalogChannel.cpp:341
uint32_t GetLSBWeight()
Definition: AnalogChannel.cpp:164
uint32_t GetChannel()
Definition: AnalogChannel.cpp:189
AnalogChannel(uint8_t moduleNumber, uint32_t channel)
Definition: AnalogChannel.cpp:71
void SetAverageBits(uint32_t bits)
Definition: AnalogChannel.cpp:213
void InitAccumulator()
Definition: AnalogChannel.cpp:278
Definition: SensorBase.h:20
uint8_t GetModuleNumber()
Definition: AnalogChannel.cpp:199
void SetAccumulatorCenter(int32_t center)
Definition: AnalogChannel.cpp:325
void SetOversampleBits(uint32_t bits)
Definition: AnalogChannel.cpp:240
int32_t GetAverageValue()
Definition: AnalogChannel.cpp:125
void ResetAccumulator()
Definition: AnalogChannel.cpp:302
AnalogModule * GetModule()
Definition: AnalogChannel.cpp:98
Definition: PIDSource.h:15
void SetAccumulatorInitialValue(INT64 value)
Definition: AnalogChannel.cpp:293
bool IsAccumulatorChannel()
Definition: AnalogChannel.cpp:264
uint32_t GetAccumulatorCount()
Definition: AnalogChannel.cpp:383
float GetVoltage()
Definition: AnalogChannel.cpp:136
uint32_t GetAverageBits()
Definition: AnalogChannel.cpp:226
void GetAccumulatorOutput(INT64 *value, uint32_t *count)
Definition: AnalogChannel.cpp:407
uint32_t GetOversampleBits()
Definition: AnalogChannel.cpp:253
void SetVoltageForPID(bool shouldUseVoltageForPID)
Definition: AnalogChannel.cpp:436
double PIDGet()
Definition: AnalogChannel.cpp:445
INT64 GetAccumulatorValue()
Definition: AnalogChannel.cpp:362
int16_t GetValue()
Definition: AnalogChannel.cpp:110
Definition: AnalogChannel.h:29
float GetAverageVoltage()
Definition: AnalogChannel.cpp:149
virtual ~AnalogChannel()
Definition: AnalogChannel.cpp:89