Now you can download a copy of these docs so you can use them offline! Download now
DriverStation.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 __DRIVER_STATION_H__
8 #define __DRIVER_STATION_H__
9 
10 #include "Dashboard.h"
11 #include "DriverStationEnhancedIO.h"
12 #include "SensorBase.h"
13 #include "Task.h"
14 
15 struct FRCCommonControlData;
16 class AnalogChannel;
17 
21 class DriverStation : public SensorBase
22 {
23 public:
24  enum Alliance {kRed, kBlue, kInvalid};
25 
26  virtual ~DriverStation();
27  static DriverStation *GetInstance();
28 
29  static const uint32_t kBatteryModuleNumber = 1;
30  static const uint32_t kBatteryChannel = 8;
31  static const uint32_t kJoystickPorts = 4;
32  static const uint32_t kJoystickAxes = 6;
33 
34  float GetStickAxis(uint32_t stick, uint32_t axis);
35  short GetStickButtons(uint32_t stick);
36 
37  float GetAnalogIn(uint32_t channel);
38  bool GetDigitalIn(uint32_t channel);
39  void SetDigitalOut(uint32_t channel, bool value);
40  bool GetDigitalOut(uint32_t channel);
41 
42  bool IsEnabled();
43  bool IsDisabled();
44  bool IsAutonomous();
45  bool IsOperatorControl();
46  bool IsTest();
47  bool IsNewControlData();
48  bool IsFMSAttached();
49 
50  uint32_t GetPacketNumber();
51  Alliance GetAlliance();
52  uint32_t GetLocation();
53  void WaitForData();
54  double GetMatchTime();
55  float GetBatteryVoltage();
56  uint16_t GetTeamNumber();
57 
58  // Get the default dashboard packers. These instances stay around even after
59  // a call to SetHigh|LowPriorityDashboardPackerToUse() changes which packer
60  // is in use. You can restore the default high priority packer by calling
61  // SetHighPriorityDashboardPackerToUse(&GetHighPriorityDashboardPacker()).
62  Dashboard& GetHighPriorityDashboardPacker() { return m_dashboardHigh; }
63  Dashboard& GetLowPriorityDashboardPacker() { return m_dashboardLow; }
64 
65  // Get/set the dashboard packers to use. This can sideline or restore the
66  // default packers. Initializing SmartDashboard changes the high priority
67  // packer in use so beware that the default packer will then be idle. These
68  // methods support any kind of DashboardBase, e.g. a Dashboard or a
69  // SmartDashboard.
70  DashboardBase* GetHighPriorityDashboardPackerInUse() { return m_dashboardInUseHigh; }
71  DashboardBase* GetLowPriorityDashboardPackerInUse() { return m_dashboardInUseLow; }
72  void SetHighPriorityDashboardPackerToUse(DashboardBase* db) { m_dashboardInUseHigh = db; }
73  void SetLowPriorityDashboardPackerToUse(DashboardBase* db) { m_dashboardInUseLow = db; }
74 
75  DriverStationEnhancedIO& GetEnhancedIO() { return m_enhancedIO; }
76 
77  void IncrementUpdateNumber() { m_updateNumber++; }
78  SEM_ID GetUserStatusDataSem() { return m_statusDataSemaphore; }
79 
83  void InDisabled(bool entering) {m_userInDisabled=entering;}
87  void InAutonomous(bool entering) {m_userInAutonomous=entering;}
91  void InOperatorControl(bool entering) {m_userInTeleop=entering;}
95  void InTest(bool entering) {m_userInTest=entering;}
96 
97 protected:
98  DriverStation();
99 
100  void GetData();
101  void SetData();
102 
103 private:
104  static void InitTask(DriverStation *ds);
105  static DriverStation *m_instance;
106  static uint8_t m_updateNumber;
108  static constexpr float kUpdatePeriod = 0.02;
109 
110  void Run();
111 
112  struct FRCCommonControlData *m_controlData;
113  uint8_t m_digitalOut;
114  AnalogChannel *m_batteryChannel;
115  SEM_ID m_statusDataSemaphore;
116  Task m_task;
117  Dashboard m_dashboardHigh; // the default dashboard packers
118  Dashboard m_dashboardLow;
119  DashboardBase* m_dashboardInUseHigh; // the current dashboard packers in use
120  DashboardBase* m_dashboardInUseLow;
121  SEM_ID m_newControlData;
122  SEM_ID m_packetDataAvailableSem;
123  DriverStationEnhancedIO m_enhancedIO;
124  SEM_ID m_waitForDataSem;
125  double m_approxMatchTimeOffset;
126  bool m_userInDisabled;
127  bool m_userInAutonomous;
128  bool m_userInTeleop;
129  bool m_userInTest;
130 };
131 
132 #endif
133 
bool IsNewControlData()
float GetAnalogIn(uint32_t channel)
bool GetDigitalIn(uint32_t channel)
uint32_t GetPacketNumber()
Alliance GetAlliance()
uint16_t GetTeamNumber()
void InOperatorControl(bool entering)
Definition: DriverStation.h:91
bool GetDigitalOut(uint32_t channel)
void SetDigitalOut(uint32_t channel, bool value)
static DriverStation * GetInstance()
void InDisabled(bool entering)
Definition: DriverStation.h:83
Definition: Task.h:17
double GetMatchTime()
void InTest(bool entering)
Definition: DriverStation.h:95
uint32_t GetLocation()
short GetStickButtons(uint32_t stick)
float GetBatteryVoltage()
void InAutonomous(bool entering)
Definition: DriverStation.h:87
float GetStickAxis(uint32_t stick, uint32_t axis)

Generated on Sat Apr 26 2014 12:26:45 for WPILibC++ by doxygen 1.8.6