private List <DriveCommand> encodeDriveCommand() { var listDriveCommand = new List <DriveCommand>(); using (var streamReader = new StreamReader(this.PathDriveRouteFile)) { while (!streamReader.EndOfStream) { var line = streamReader.ReadLine(); listDriveCommand.Add(DriveCommand.CreateDriveCommand(line, this.Robot, this.DriveLog, this.Acceleration, this.Speed)); } } return(listDriveCommand); }
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); }