mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
In C++, it's not legal to call a virtual function from within a constructor, so the user override was never called (the base function is always called). See https://isocpp.org/wiki/faq/strange-inheritance#calling-virtuals-from-ctors While this is technically allowed in Java, also change Java for consistency.
41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
/*----------------------------------------------------------------------------*/
|
|
/* Copyright (c) 2008-2017 FIRST. All Rights Reserved. */
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
/* the project. */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
#include "IterativeRobot.h"
|
|
|
|
#include <HAL/HAL.h>
|
|
|
|
#include "DriverStation.h"
|
|
|
|
using namespace frc;
|
|
|
|
IterativeRobot::IterativeRobot() {
|
|
HAL_Report(HALUsageReporting::kResourceType_Framework,
|
|
HALUsageReporting::kFramework_Iterative);
|
|
}
|
|
|
|
/**
|
|
* Provide an alternate "main loop" via StartCompetition().
|
|
*
|
|
* This specific StartCompetition() implements "main loop" behaviour synced with
|
|
* the DS packets.
|
|
*/
|
|
void IterativeRobot::StartCompetition() {
|
|
RobotInit();
|
|
|
|
// Tell the DS that the robot is ready to be enabled
|
|
HAL_ObserveUserProgramStarting();
|
|
|
|
// Loop forever, calling the appropriate mode-dependent function
|
|
while (true) {
|
|
// wait for driver station data so the loop doesn't hog the CPU
|
|
DriverStation::GetInstance().WaitForData();
|
|
|
|
LoopFunc();
|
|
}
|
|
}
|