private void Run(List <DriveCommand> driveCommands) { if (Robot.Drive != null) { Robot.Drive.Position = new PositionInfo(0, 0, 0); } DriveLog.RepressLog(); DriveLog.CreateLog(); DriveLog.AddLogEntry(DateTime.Now.ToString("dd/MM/yyyy-hh:mm:ss.fff") + ";" + Robot.Drive.DriveInfo.Position.X.ToString() + ";" + Robot.Drive.DriveInfo.Position.Y.ToString()); foreach (DriveCommand dc in driveCommands) { Console.WriteLine("Befehl: " + dc.ToString()); dc.Run(); } DriveLog.CloseLog(); this.onRobotDone(new EventArgs()); }
public static DriveCommand CreateDriveCommand(string commandCSV, Robot robot, DriveLog driveLog, float accleration, float speed) { var driveCommand = new DriveCommand(); driveCommand.Robot = robot; driveCommand.DriveLog = driveLog; driveCommand.Acceleration = accleration; driveCommand.Speed = speed; var values = commandCSV.Split(';'); var commandName = values[0]; switch (commandName) { case "TrackLine": driveCommand.DriveCommandTyp = DriveCommandTyp.TrackLine; driveCommand.ValueL = float.Parse(values[1]); break; case "TrackTurnLeft": driveCommand.DriveCommandTyp = DriveCommandTyp.TrackTurnLeft; driveCommand.ValueA = Convert.ToInt32(values[1]); break; case "TrackTurnRight": driveCommand.DriveCommandTyp = DriveCommandTyp.TrackTurnRight; driveCommand.ValueA = Convert.ToInt32(values[1]) * -1; break; case "TrackArcLeft": driveCommand.DriveCommandTyp = DriveCommandTyp.TrackArcLeft; driveCommand.ValueA = Convert.ToInt32(values[2]); driveCommand.ValueL = float.Parse(values[1]); break; case "TrackArcRight": driveCommand.DriveCommandTyp = DriveCommandTyp.TrackArcRight; driveCommand.ValueA = Convert.ToInt32(values[2]); driveCommand.ValueL = float.Parse(values[1]); break; } return(driveCommand); }