Beispiel #1
0
        /// <summary>
        /// Ejecuta un comando del robot.
        /// </summary>
        /// <param name="commandChart">Un chartElement que contiene la instruccion a ejecutar.</param>
        public void ExecuteCommand(CommandChartElement commandChart)
        {
            switch (commandChart.CommandName.ToLower())
            {
            case "moveforward":
                Robot.Motor.MoveForward();
                break;

            case "movebackward":
                Robot.Motor.MoveBackward();
                break;

            case "turnleft":
                Robot.Motor.TurnLeft();
                break;

            case "turnright":
                Robot.Motor.TurnRight();
                break;

            case "loaditem":
                Robot.Motor.LoadItem();
                break;

            case "unloaditem":
                Robot.Motor.UnloadItem();
                break;

            default:
                throw new InvalidOperationException(string.Format("Invalid Command: {0}", commandChart.CommandName));
            }
            Robot.OnMove();
            Thread.Sleep(wait);
        }