/** * コンストラクタ */ public NxtTrackLog(string path) { //X,Y,Angle以外も含む全CSVログ List <int[]> log; //CSVファイルを読み込む FileStream inFile = new FileStream(path, FileMode.Open); StreamReader reader = new StreamReader(inFile, Encoding.GetEncoding(LOG_CODEPAGE_ID)); //例外発生時はcatchせずそのまま呼び出し元に送信する try { //読み込んでint[]のListにする log = ReadLog(reader); } finally { reader.Close(); } //X,Y,Angleのカラムインデックスを取得 ColumnAssigner assigner = new ColumnAssigner(splitedHeader); int xCol = 0; int yCol = 0; int angleCol = 0; try { if (assigner.ShowDialog() != DialogResult.OK) { throw new UserCanceledException("ユーザーにより値の割り当てがキャンセルされました。"); } ; xCol = assigner.xColumnIndex; yCol = assigner.yColumnIndex; angleCol = assigner.angleColumnIndex; } finally { assigner.Dispose(); } //Time,X,Y,Angleのみを抽出する //Timeは無条件に先頭の要素 robotLog = new List <XYAngle>(); foreach (int[] record in log) { robotLog.Add(new XYAngle( record[0], record[xCol], record[yCol], record[angleCol])); } //時刻順にソート SortLog(log); }
/** * コンストラクタ */ public NxtTrackLog(string path) { //X,Y,Angle以外も含む全CSVログ List<int[]> log; //CSVファイルを読み込む FileStream inFile = new FileStream(path, FileMode.Open); StreamReader reader = new StreamReader(inFile,Encoding.GetEncoding(LOG_CODEPAGE_ID)); //例外発生時はcatchせずそのまま呼び出し元に送信する try { //読み込んでint[]のListにする log = ReadLog(reader); } finally { reader.Close(); } //X,Y,Angleのカラムインデックスを取得 ColumnAssigner assigner = new ColumnAssigner(splitedHeader); int xCol = 0; int yCol = 0; int angleCol = 0; try { if (assigner.ShowDialog() != DialogResult.OK) { throw new UserCanceledException("ユーザーにより値の割り当てがキャンセルされました。"); }; xCol = assigner.xColumnIndex; yCol = assigner.yColumnIndex; angleCol = assigner.angleColumnIndex; } finally { assigner.Dispose(); } //Time,X,Y,Angleのみを抽出する //Timeは無条件に先頭の要素 robotLog = new List<XYAngle>(); foreach(int[] record in log){ robotLog.Add(new XYAngle( record[0], record[xCol], record[yCol], record[angleCol])); } //時刻順にソート SortLog(log); }