diff --git a/EcomAnalysis/EcomAnalysis.csproj b/EcomAnalysis/EcomAnalysis.csproj
index f9f40f1..8506baa 100644
--- a/EcomAnalysis/EcomAnalysis.csproj
+++ b/EcomAnalysis/EcomAnalysis.csproj
@@ -58,6 +58,7 @@
Form1.cs
+
diff --git a/EcomAnalysis/Form1.Designer.cs b/EcomAnalysis/Form1.Designer.cs
index 7c9cb0d..ea89c3f 100644
--- a/EcomAnalysis/Form1.Designer.cs
+++ b/EcomAnalysis/Form1.Designer.cs
@@ -66,6 +66,7 @@
this.label13 = new System.Windows.Forms.Label();
this.BtnOpenLog = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
+ this.BtnCompareLogs = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
@@ -467,12 +468,24 @@
this.openFileDialog1.Filter = "CSVファイル|*.csv";
this.openFileDialog1.Title = "Logファイルを開く";
//
+ // BtnCompareLogs
+ //
+ this.BtnCompareLogs.Font = new System.Drawing.Font("MS UI Gothic", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
+ this.BtnCompareLogs.Location = new System.Drawing.Point(259, 621);
+ this.BtnCompareLogs.Name = "BtnCompareLogs";
+ this.BtnCompareLogs.Size = new System.Drawing.Size(220, 38);
+ this.BtnCompareLogs.TabIndex = 27;
+ this.BtnCompareLogs.Text = "過去の実施結果と比較";
+ this.BtnCompareLogs.UseVisualStyleBackColor = true;
+ this.BtnCompareLogs.Click += new System.EventHandler(this.BtnCompareLogs_Click);
+ //
// Form1
//
this.AllowDrop = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(723, 671);
+ this.Controls.Add(this.BtnCompareLogs);
this.Controls.Add(this.BtnOpenLog);
this.Controls.Add(this.label13);
this.Controls.Add(this.listView2);
@@ -555,6 +568,7 @@
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Button BtnOpenLog;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
+ private System.Windows.Forms.Button BtnCompareLogs;
}
}
diff --git a/EcomAnalysis/Form1.cs b/EcomAnalysis/Form1.cs
index 5697aac..55edb7a 100644
--- a/EcomAnalysis/Form1.cs
+++ b/EcomAnalysis/Form1.cs
@@ -26,6 +26,7 @@
private SceneMean _ScMean = new SceneMean();
private double[] LF = new double[BLOCKS];
private double[] HF = new double[BLOCKS];
+ private LogFileInfo _LogFileInfo = new LogFileInfo();
///
/// コンストラクタ
@@ -53,13 +54,39 @@
///
///
private void Form1_Load(object sender, EventArgs e) {
- TxtLogFilename.Text = "not opened";
+ ClearData();
var args = Environment.GetCommandLineArgs();
- if (args.Length > 1) {
- ClearData();
- ReadCSV(args[1]);
- Analyze();
+ if (args.Length > 1) OpenLog(args[1]);
+ }
+
+ ///
+ /// ログファイルを開く
+ ///
+ ///
+ ///
+ private bool OpenLog(string filename) {
+ if (!_LogFileInfo.Set(filename)) {
+ MessageBox.Show("Logファイル名が正しくありません", "Error",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
}
+ if (!File.Exists(_LogFileInfo.Filepath)) {
+ MessageBox.Show("ファイルがありません", "Error",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return false;
+ }
+
+ ClearData();
+ ReadCSV();
+ Analyze();
+
+ // 表示
+ TxtLogFilename.Text = _LogFileInfo.Filepath;
+ TxtDateTime.Text = _LogFileInfo.ExecDate.ToString("yyyy年MM月dd日 HH時mm分");
+ TxtSubject.Text = _LogFileInfo.Subject;
+ TxtVisit.Text = _LogFileInfo.Visit.ToString();
+
+ return true;
}
///
@@ -70,11 +97,13 @@
_SceneTable.Clear();
listView1.Items.Clear();
+ listView2.Items.Clear();
foreach (var ctl in this.Controls) {
if (((Control)ctl).GetType().Equals(typeof(TextBox))){
((Control)ctl).Text = "";
}
}
+ TxtLogFilename.Text = "not opened";
}
///
@@ -308,20 +337,13 @@
///
/// CSVファイルの読み込み
///
- ///
- private void ReadCSV(string csvfile) {
+ private void ReadCSV() {
- char[] sep = { ',' };
- if (!File.Exists(csvfile)) {
- MessageBox.Show("ファイルがありません", "Error",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- using (var sr = new StreamReader(csvfile,
+ using (var sr = new StreamReader(_LogFileInfo.Filepath,
Encoding.GetEncoding("shift_jis"))) {
// ヘッダー検証
- var readHeader = sr.ReadLine().Split(sep);
+ var readHeader = sr.ReadLine().Split(',');
var headerCol = new Dictionary();
foreach (var hi in _HeaderItems) {
headerCol.Add(hi, readHeader.ToList().IndexOf(hi));
@@ -336,7 +358,7 @@
_Data.Clear();
var sceneNoExist = headerCol["sceneNo"] >= 0;
while (sr.Peek() > -1) {
- var line = sr.ReadLine().Split(sep);
+ var line = sr.ReadLine().Split(',');
var ld = new LogData();
ld.ElapTime = double.Parse(line[headerCol["time"]]);
ld.StimNo = int.Parse(line[headerCol["stimNo"]]);
@@ -355,18 +377,6 @@
}
//Debug.WriteLine(_Data.Count);
- // 表示
- TxtLogFilename.Text = csvfile;
- var filename = Path.GetFileNameWithoutExtension(csvfile);
- TxtDateTime.Text = string.Format("{0}年{1}月{2}日 {3}時{4}分",
- filename.Substring(0,4), filename.Substring(4, 2),
- filename.Substring(6, 2), filename.Substring(9, 2),
- filename.Substring(11, 2));
- var strs = filename.Split('_');
- var subj = new string[strs.Length - 3];
- Array.Copy(strs, 2, subj, 0, strs.Length - 3);
- TxtSubject.Text = $"{string.Join("_", subj)}";
- TxtVisit.Text = $"{strs[strs.Length - 1]}";
}
}
@@ -418,9 +428,7 @@
private void Form1_DragDrop(object sender, DragEventArgs e) {
var filename = (string[])e.Data.GetData(DataFormats.FileDrop, false);
if (Path.GetExtension(filename[0]) == ".csv") {
- ClearData();
- ReadCSV(filename[0]);
- Analyze();
+ OpenLog(filename[0]);
}
}
@@ -431,9 +439,16 @@
///
private void BtnOpenLog_Click(object sender, EventArgs e) {
if (openFileDialog1.ShowDialog() == DialogResult.Cancel) return;
- ClearData();
- ReadCSV(openFileDialog1.FileName);
- Analyze();
+ OpenLog(openFileDialog1.FileName);
+ }
+
+ ///
+ /// 過去の実施結果と比較ボタン
+ ///
+ ///
+ ///
+ private void BtnCompareLogs_Click(object sender, EventArgs e) {
+// var dir = Path.GetDirectoryName();
}
}
}
diff --git a/EcomAnalysis/LogFileInfo.cs b/EcomAnalysis/LogFileInfo.cs
new file mode 100644
index 0000000..43ef919
--- /dev/null
+++ b/EcomAnalysis/LogFileInfo.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.IO;
+using System.Globalization;
+
+namespace EcomAnalysis {
+
+ ///
+ /// ログファイル情報クラス
+ /// ファイル名から得られる情報の管理
+ ///
+ class LogFileInfo {
+ public string Filepath { get; private set; }
+ public string Filename { get; private set; }
+ public DateTime ExecDate { get; private set; }
+ public int Visit { get; private set; }
+ public string Subject { get; private set; }
+
+ public bool Set(string fn) {
+ Filepath = fn;
+ Filename = Path.GetFileNameWithoutExtension(fn);
+
+ var parseStr = "yyyyMMdd_HHmmss";
+ DateTime dt;
+ if (!DateTime.TryParseExact(Filename.Substring(0, parseStr.Length),
+ parseStr, CultureInfo.InvariantCulture, DateTimeStyles.None, out dt)) return false;
+ ExecDate = dt;
+
+ var strs = Filename.Split('_');
+ if (strs.Length < 4) return false;
+
+ var visitStr = strs[strs.Length - 1];
+ int v;
+ if (!int.TryParse(visitStr, out v)) return false;
+ Visit = v;
+
+ Subject = Filename.Substring(parseStr.Length + 1,
+ Filename.Length - parseStr.Length - visitStr.Length - 2);
+
+ return true;
+ }
+ }
+}