Now you can download a copy of these docs so you can use them offline! Download now
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 
bool IsOperatorControl()
Definition: RobotBase.cpp:115
bool IsAutonomous()
Definition: RobotBase.cpp:106
bool IsEnabled()
Definition: RobotBase.cpp:88
bool IsTest()
Definition: RobotBase.cpp:124
Watchdog & GetWatchdog()
Definition: RobotBase.cpp:79
static void robotTask(FUNCPTR factory, Task *task)
Definition: RobotBase.cpp:141
bool IsDisabled()
Definition: RobotBase.cpp:97
Definition: Task.h:17
static void startRobotTask(FUNCPTR factory)
Definition: RobotBase.cpp:164
bool IsSystemActive()
Definition: RobotBase.cpp:69
virtual ~RobotBase()
Definition: RobotBase.cpp:56
bool IsNewDataAvailable()
Definition: RobotBase.cpp:133

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