/// <summary>
        /// Devuelve un nuevo CommandChartElement.
        /// </summary>
        /// <param name="index">Define que instruccion crear de la lista de instrucciones posibles.</param>
        /// <returns>El nuevo CommandChartElement.</returns>
        public override ChartElement Build(int index)
        {
            CommandChartElement element = new CommandChartElement();

             element.PinSize = new Size(5, 5);
             element.BackColor = Color.Gray;
             element.Display = new Rectangle(Center.X - 50, Center.Y - 10, 100, 20);
             element.ShowInputPins = false;
             element.ShowOutputPins = false;
             element.CommandName = ValuesList[index];

             return element;
        }
Esempio n. 2
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);
 }