TimedRobot.cpp: Fix deprecation warning (#1846)

For both TimedRobot and IterativeRobotBase, use delegating constructors
to reduce code duplication.
This commit is contained in:
Peter Johnson
2019-08-24 21:13:29 -07:00
committed by GitHub
parent b2861f8948
commit 4cd8a56672
2 changed files with 2 additions and 10 deletions

View File

@@ -24,8 +24,7 @@
using namespace frc;
IterativeRobotBase::IterativeRobotBase(double period)
: m_period(period),
m_watchdog(period, [this] { PrintLoopOverrunMessage(); }) {}
: IterativeRobotBase(units::second_t(period)) {}
IterativeRobotBase::IterativeRobotBase(units::second_t period)
: m_period(period.to<double>()),

View File

@@ -47,14 +47,7 @@ units::second_t TimedRobot::GetPeriod() const {
return units::second_t(m_period);
}
TimedRobot::TimedRobot(double period) : IterativeRobotBase(period) {
int32_t status = 0;
m_notifier = HAL_InitializeNotifier(&status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
HAL_Report(HALUsageReporting::kResourceType_Framework,
HALUsageReporting::kFramework_Timed);
}
TimedRobot::TimedRobot(double period) : TimedRobot(units::second_t(period)) {}
TimedRobot::TimedRobot(units::second_t period) : IterativeRobotBase(period) {
int32_t status = 0;