WPILib  2014.0
WPIRoboticsLibraryforFRC
 All Classes Functions Variables Pages
RobotBase.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 ROBOT_H_
8 #define ROBOT_H_
9 
10 #include "Base.h"
11 #include "Task.h"
12 #include "Watchdog.h"
13 
14 class DriverStation;
15 
16 #define START_ROBOT_CLASS(_ClassName_) \
17  RobotBase *FRC_userClassFactory() \
18  { \
19  return new _ClassName_(); \
20  } \
21  extern "C" { \
22  int32_t FRC_UserProgram_StartupLibraryInit() \
23  { \
24  RobotBase::startRobotTask((FUNCPTR)FRC_userClassFactory); \
25  return 0; \
26  } \
27  }
28 
37 class RobotBase {
38  friend class RobotDeleter;
39 public:
40  static RobotBase &getInstance();
41  static void setInstance(RobotBase* robot);
42 
43  bool IsEnabled();
44  bool IsDisabled();
45  bool IsAutonomous();
46  bool IsOperatorControl();
47  bool IsTest();
48  bool IsSystemActive();
49  bool IsNewDataAvailable();
51  static void startRobotTask(FUNCPTR factory);
52  static void robotTask(FUNCPTR factory, Task *task);
53 
54 protected:
55  virtual ~RobotBase();
56  virtual void StartCompetition() = 0;
57  RobotBase();
58  static void WriteVersionString();
59 
60  Task *m_task;
61  Watchdog m_watchdog;
62  DriverStation *m_ds;
63 private:
64  static RobotBase *m_instance;
65  DISALLOW_COPY_AND_ASSIGN(RobotBase);
66 };
67 
68 #endif
69 
Watchdog & GetWatchdog()
Definition: RobotBase.cpp:79
bool IsEnabled()
Definition: RobotBase.cpp:88
bool IsNewDataAvailable()
Definition: RobotBase.cpp:133
Definition: RobotBase.h:37
RobotBase()
Definition: RobotBase.cpp:44
Definition: RobotBase.cpp:220
bool IsTest()
Definition: RobotBase.cpp:124
static void startRobotTask(FUNCPTR factory)
Definition: RobotBase.cpp:164
bool IsSystemActive()
Definition: RobotBase.cpp:69
Definition: Watchdog.h:25
virtual ~RobotBase()
Definition: RobotBase.cpp:56
static void robotTask(FUNCPTR factory, Task *task)
Definition: RobotBase.cpp:141
bool IsAutonomous()
Definition: RobotBase.cpp:106
bool IsDisabled()
Definition: RobotBase.cpp:97
bool IsOperatorControl()
Definition: RobotBase.cpp:115
Definition: Task.h:17
Definition: DriverStation.h:21