Improve selector homing behavior in unit tests
Waiting for the selector to return to the parked position after homing is not enforced by the firmware and should therefore not be enforced by the unit tests. There are some few exceptions to this, and for those situations I added a parameter to SimulateSelectorHoming() called waitForParkedPosition to explicitly wait for the selector to return to the parked position if set to true. This is very useful when setting up test cases in general and also allows us to control the behavior in each test.pull/282/head
parent
372045c38c
commit
eb52475819
|
|
@ -82,7 +82,10 @@ bool SelectorFailedRetry() {
|
|||
|
||||
SimulateSelectorHoming(h);
|
||||
|
||||
REQUIRE(WhileTopState(h, ProgressCode::Homing, 5000));
|
||||
REQUIRE(ms::selector.HomingValid());
|
||||
|
||||
// Wait for the selector to return to the parked position
|
||||
REQUIRE(WhileTopState(h, ProgressCode::Homing, selectorMoveMaxSteps));
|
||||
|
||||
REQUIRE(VerifyState(h, mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), 0, false, false, ml::off, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
REQUIRE(mi::idler.HomingValid());
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ void SimulateIdlerAndSelectorHoming(logic::CommandBase &cb) {
|
|||
#else
|
||||
// sadly, it looks like we need to separate homing of idler and selector due to electrical reasons
|
||||
SimulateIdlerHoming(cb);
|
||||
SimulateSelectorHoming(cb);
|
||||
SimulateSelectorHoming(cb, true);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ void SimulateIdlerHoming(logic::CommandBase &cb) {
|
|||
}
|
||||
}
|
||||
|
||||
void SimulateSelectorHoming(logic::CommandBase &cb) {
|
||||
void SimulateSelectorHoming(logic::CommandBase &cb, bool waitForParkedPosition) {
|
||||
// do 5 steps until we trigger the simulated StallGuard
|
||||
for (uint8_t i = 0; i < 5; ++i) {
|
||||
main_loop();
|
||||
|
|
@ -117,11 +117,22 @@ void SimulateSelectorHoming(logic::CommandBase &cb) {
|
|||
}
|
||||
}
|
||||
|
||||
// Wait for the HomingValid flag to be set
|
||||
while (!ms::selector.HomingValid()) {
|
||||
main_loop();
|
||||
cb.Step();
|
||||
}
|
||||
|
||||
// Normally the firmware does not wait for the state to turn ready. But it can
|
||||
// be useful to setup test cases. After the selector homing is valid, it will
|
||||
// go to it's last planned position.
|
||||
if (waitForParkedPosition) {
|
||||
// now the Selector shall perform a move into their parking positions
|
||||
while (ms::selector.State() != mm::MovableBase::Ready) {
|
||||
main_loop();
|
||||
cb.Step();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SimulateFailedHomeSelectorPostfix(logic::CommandBase &cb) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class CommandBase;
|
|||
}
|
||||
|
||||
void SimulateIdlerHoming(logic::CommandBase &cb);
|
||||
void SimulateSelectorHoming(logic::CommandBase &cb);
|
||||
void SimulateSelectorHoming(logic::CommandBase &cb, bool waitForParkedPosition = false);
|
||||
void SimulateIdlerAndSelectorHoming(logic::CommandBase &cb);
|
||||
bool SimulateFailedHomeFirstTime(logic::CommandBase &cb);
|
||||
bool SimulateFailedHomeSelectorRepeated(logic::CommandBase &cb);
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ void HomeIdlerAndSelector() {
|
|||
ms::selector.InvalidateHoming();
|
||||
logic::NoCommand nc; // just a dummy instance which has an empty Step()
|
||||
SimulateIdlerHoming(nc);
|
||||
SimulateSelectorHoming(nc);
|
||||
SimulateSelectorHoming(nc, true);
|
||||
}
|
||||
|
||||
bool EnsureActiveSlotIndex(uint8_t slot, mg::FilamentLoadState loadState) {
|
||||
|
|
|
|||
|
|
@ -513,7 +513,11 @@ void ToolChangeFSENSOR_TOO_EARLY(logic::ToolChange &tc, uint8_t slot) {
|
|||
200'000UL));
|
||||
|
||||
// still unloading, but Selector can start homing
|
||||
SimulateSelectorHoming(tc);
|
||||
|
||||
// Set waitForParkedPosition to true, since the unload filament statemachine
|
||||
// explicitly waits for (ms::selector.State() == ms::Selector::Ready)
|
||||
SimulateSelectorHoming(tc, true);
|
||||
|
||||
// wait for finishing of UnloadingFilament
|
||||
WhileTopState(tc, ProgressCode::UnloadingFilament, 5000);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue