Ejemplo n.º 1
0
        // (TL, TL, A)
        public bool execStrategy(OpMap m, IMotionControl mc)
        {
            try
            {
                m.turnLeft();
                mc.turnLeft();

                m.turnLeft();
                mc.turnLeft();

                m.advance();
                mc.advance();
            }
            catch (CannotComplyException)
            {
                return(false);
            }
            catch (NotEnoughBatteryException)
            {
                return(false);
            }
            catch (OutOfBatteryException)
            {
                return(false);
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
        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;
                }
            }
        }
Ejemplo n.º 3
0
 public void advance_batteryDecrease2_return3()
 {
     proc.advance();
     Assert.AreEqual(3, proc.Battery);
 }