// (TL, B, TR, A) public bool execStrategy(OpMap m, IMotionControl mc) { try { m.turnLeft(); mc.turnLeft(); m.back(); mc.back(); m.turnRight(); mc.turnRight(); m.advance(); mc.advance(); } catch (CannotComplyException) { return(false); } catch (NotEnoughBatteryException) { return(false); } catch (OutOfBatteryException) { return(false); } catch (Exception) { return(false); } return(true); }
public void execProgram(Command[] cmds) { for (int i = 0; i < cmds.Length; i += 1) { try { switch (cmds[i]) { case Command.TL: map.turnLeft(); motCtrl.turnLeft(); break; case Command.TR: map.turnRight(); motCtrl.turnRight(); break; case Command.A: map.advance(); motCtrl.advance(); break; case Command.B: map.back(); motCtrl.back(); break; case Command.C: map.clean(); motCtrl.clean(); break; } } catch (CannotComplyException) { execBackoff(); if (error) { // All backoff strategies had failed. Execution finished return; } i -= 1; } catch (NotEnoughBatteryException) { return; } catch (OutOfBatteryException) { return; } catch (Exception) { error = true; } } }
public void back_batteryDecrease2_return2() { proc.back(); Assert.AreEqual(2, proc.Battery); }