コード例 #1
0
ファイル: DriveRoute.cs プロジェクト: benj1291/CSA_Robot
        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);
        }
コード例 #2
0
ファイル: DriveCommand.cs プロジェクト: benj1291/CSA_Robot
        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);
        }