WPILib 2012
WPILibRoboticsLibraryforFRC
IterativeRobot.h
00001 /*----------------------------------------------------------------------------*/
00002 /* Copyright (c) FIRST 2008. All Rights Reserved.                                                         */
00003 /* Open Source Software - may be modified and shared by FRC teams. The code   */
00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib.  */
00005 /*----------------------------------------------------------------------------*/
00006 
00007 #ifndef ROBOT_ITERATIVE_H_
00008 #define ROBOT_ITERATIVE_H_
00009 
00010 #include "Timer.h"
00011 #include "RobotBase.h"
00012 
00046 class IterativeRobot : public RobotBase {
00047 public:
00048         /*
00049          * The default period for the periodic function calls (seconds)
00050          * Setting the period to 0.0 will cause the periodic functions to follow
00051          * the Driver Station packet rate of about 50Hz.
00052          */
00053         static const double kDefaultPeriod = 0.0;
00054 
00055         virtual void StartCompetition();
00056 
00057         virtual void RobotInit();
00058         virtual void DisabledInit();
00059         virtual void AutonomousInit();
00060         virtual void TeleopInit();
00061 
00062         virtual void DisabledPeriodic();
00063         virtual void AutonomousPeriodic();
00064         virtual void TeleopPeriodic();
00065 
00066         virtual void DisabledContinuous();
00067         virtual void AutonomousContinuous();
00068         virtual void TeleopContinuous();
00069 
00070         void SetPeriod(double period);
00071         double GetPeriod();
00072         double GetLoopsPerSec();
00073 
00074 protected:
00075         virtual ~IterativeRobot();
00076         IterativeRobot();
00077 
00078 private:
00079         bool NextPeriodReady();
00080 
00081         bool m_disabledInitialized;
00082         bool m_autonomousInitialized;
00083         bool m_teleopInitialized;
00084         double m_period;
00085         Timer m_mainLoopTimer;
00086 };
00087 
00088 #endif
00089 
 All Classes Functions Variables