[wpilib] Make IterativeRobotBase::m_period private with getter

This commit is contained in:
Tyler Veness
2019-04-13 14:26:42 -07:00
committed by Peter Johnson
parent f00dfed7ac
commit 497b712f67
6 changed files with 16 additions and 18 deletions

View File

@@ -100,6 +100,10 @@ void IterativeRobotBase::SetNetworkTablesFlushEnabled(bool enabled) {
m_ntFlushEnabled = enabled;
}
units::second_t IterativeRobotBase::GetPeriod() const {
return m_period;
}
void IterativeRobotBase::LoopFunc() {
m_watchdog.Reset();

View File

@@ -69,10 +69,6 @@ void TimedRobot::EndCompetition() {
HAL_StopNotifier(m_notifier, &status);
}
units::second_t TimedRobot::GetPeriod() const {
return units::second_t(m_period);
}
TimedRobot::TimedRobot(double period) : TimedRobot(units::second_t(period)) {}
TimedRobot::TimedRobot(units::second_t period) : IterativeRobotBase(period) {

View File

@@ -160,6 +160,11 @@ class IterativeRobotBase : public RobotBase {
*/
void SetNetworkTablesFlushEnabled(bool enabled);
/**
* Gets time period between calls to Periodic() functions.
*/
units::second_t GetPeriod() const;
/**
* Constructor for IterativeRobotBase.
*
@@ -186,12 +191,11 @@ class IterativeRobotBase : public RobotBase {
void LoopFunc();
units::second_t m_period;
private:
enum class Mode { kNone, kDisabled, kAutonomous, kTeleop, kTest };
Mode m_lastMode = Mode::kNone;
units::second_t m_period;
Watchdog m_watchdog;
bool m_ntFlushEnabled = false;

View File

@@ -42,11 +42,6 @@ class TimedRobot : public IterativeRobotBase {
*/
void EndCompetition() override;
/**
* Get the time period between calls to Periodic() functions.
*/
units::second_t GetPeriod() const;
/**
* Constructor for TimedRobot.
*

View File

@@ -32,8 +32,6 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
* disabledPeriodic() - autonomousPeriodic() - teleopPeriodic() - testPeriodic()
*/
public abstract class IterativeRobotBase extends RobotBase {
protected double m_period;
private enum Mode {
kNone,
kDisabled,
@@ -43,6 +41,7 @@ public abstract class IterativeRobotBase extends RobotBase {
}
private Mode m_lastMode = Mode.kNone;
private final double m_period;
private final Watchdog m_watchdog;
private boolean m_ntFlushEnabled;
@@ -204,6 +203,11 @@ public abstract class IterativeRobotBase extends RobotBase {
m_ntFlushEnabled = enabled;
}
/** Gets time period between calls to Periodic() functions. */
public double getPeriod() {
return m_period;
}
@SuppressWarnings("PMD.CyclomaticComplexity")
protected void loopFunc() {
m_watchdog.reset();

View File

@@ -137,11 +137,6 @@ public class TimedRobot extends IterativeRobotBase {
NotifierJNI.stopNotifier(m_notifier);
}
/** Get time period between calls to Periodic() functions. */
public double getPeriod() {
return m_period;
}
/**
* Add a callback to run at a specific period.
*