WPILibC++  2018.4.1-20180927001728-1207-gd5d744a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
TimedRobot.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2017-2018 FIRST. 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 the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <hal/Notifier.h>
11 
12 #include "frc/ErrorBase.h"
13 #include "frc/IterativeRobotBase.h"
14 
15 namespace frc {
16 
26 class TimedRobot : public IterativeRobotBase, public ErrorBase {
27  public:
28  static constexpr double kDefaultPeriod = 0.02;
29 
33  void StartCompetition() override;
34 
38  double GetPeriod() const;
39 
45  explicit TimedRobot(double period = kDefaultPeriod);
46 
47  ~TimedRobot() override;
48 
49  TimedRobot(TimedRobot&& rhs);
50  TimedRobot& operator=(TimedRobot&& rhs);
51 
52  private:
53  HAL_NotifierHandle m_notifier{0};
54 
55  // The absolute expiration time
56  double m_expirationTime = 0;
57 
61  void UpdateAlarm();
62 };
63 
64 } // namespace frc
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
void StartCompetition() override
Provide an alternate "main loop" via StartCompetition().
TimedRobot(double period=kDefaultPeriod)
Constructor for TimedRobot.
Base class for most objects.
Definition: ErrorBase.h:74
TimedRobot implements the IterativeRobotBase robot program framework.
Definition: TimedRobot.h:26
double GetPeriod() const
Get the time period between calls to Periodic() functions.
IterativeRobotBase implements a specific type of robot program framework, extending the RobotBase cla...
Definition: IterativeRobotBase.h:44