[wpilib] Add method to enable/disable LiveWindow in test mode (#4678)

This commit is contained in:
Starlight220
2022-12-01 23:28:06 +02:00
committed by GitHub
parent eae68fc165
commit 1f1461e254
5 changed files with 146 additions and 12 deletions

View File

@@ -94,6 +94,18 @@ void IterativeRobotBase::SetNetworkTablesFlushEnabled(bool enabled) {
m_ntFlushEnabled = enabled;
}
void IterativeRobotBase::EnableLiveWindowInTest(bool testLW) {
if (IsTest()) {
throw FRC_MakeError(err::IncompatibleMode,
"Can't configure test mode while in test mode!");
}
m_lwEnabledInTest = testLW;
}
bool IterativeRobotBase::IsLiveWindowEnabledInTest() {
return m_lwEnabledInTest;
}
units::second_t IterativeRobotBase::GetPeriod() const {
return m_period;
}
@@ -125,8 +137,10 @@ void IterativeRobotBase::LoopFunc() {
} else if (m_lastMode == Mode::kTeleop) {
TeleopExit();
} else if (m_lastMode == Mode::kTest) {
LiveWindow::SetEnabled(false);
Shuffleboard::DisableActuatorWidgets();
if (m_lwEnabledInTest) {
LiveWindow::SetEnabled(false);
Shuffleboard::DisableActuatorWidgets();
}
TestExit();
}
@@ -141,8 +155,10 @@ void IterativeRobotBase::LoopFunc() {
TeleopInit();
m_watchdog.AddEpoch("TeleopInit()");
} else if (mode == Mode::kTest) {
LiveWindow::SetEnabled(true);
Shuffleboard::EnableActuatorWidgets();
if (m_lwEnabledInTest) {
LiveWindow::SetEnabled(true);
Shuffleboard::EnableActuatorWidgets();
}
TestInit();
m_watchdog.AddEpoch("TestInit()");
}