diff --git a/EcomAnalysis/Form1.Designer.cs b/EcomAnalysis/Form1.Designer.cs index 418fd4c..d9eea56 100644 --- a/EcomAnalysis/Form1.Designer.cs +++ b/EcomAnalysis/Form1.Designer.cs @@ -25,7 +25,7 @@ /// private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); - this.textBox1 = new System.Windows.Forms.TextBox(); + this.TxtLogFilename = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.TxtFB1 = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); @@ -41,6 +41,15 @@ this.label8 = new System.Windows.Forms.Label(); this.TxtDateTime = new System.Windows.Forms.TextBox(); this.label9 = new System.Windows.Forms.Label(); + this.listView1 = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.label10 = new System.Windows.Forms.Label(); + this.TxtSubject = new System.Windows.Forms.TextBox(); + this.label11 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label1 @@ -52,21 +61,21 @@ this.label1.TabIndex = 0; this.label1.Text = "Log File"; // - // textBox1 + // TxtLogFilename // - this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.TxtLogFilename.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.textBox1.Location = new System.Drawing.Point(64, 6); - this.textBox1.Name = "textBox1"; - this.textBox1.ReadOnly = true; - this.textBox1.Size = new System.Drawing.Size(380, 19); - this.textBox1.TabIndex = 1; + this.TxtLogFilename.Location = new System.Drawing.Point(64, 6); + this.TxtLogFilename.Name = "TxtLogFilename"; + this.TxtLogFilename.ReadOnly = true; + this.TxtLogFilename.Size = new System.Drawing.Size(576, 19); + this.TxtLogFilename.TabIndex = 1; // // label2 // this.label2.AutoSize = true; this.label2.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.label2.Location = new System.Drawing.Point(57, 149); + this.label2.Location = new System.Drawing.Point(119, 145); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(41, 24); this.label2.TabIndex = 2; @@ -77,7 +86,7 @@ this.TxtFB1.BackColor = System.Drawing.SystemColors.Info; this.TxtFB1.BorderStyle = System.Windows.Forms.BorderStyle.None; this.TxtFB1.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.TxtFB1.Location = new System.Drawing.Point(193, 146); + this.TxtFB1.Location = new System.Drawing.Point(255, 142); this.TxtFB1.Name = "TxtFB1"; this.TxtFB1.ReadOnly = true; this.TxtFB1.Size = new System.Drawing.Size(199, 24); @@ -88,7 +97,7 @@ // this.label3.AutoSize = true; this.label3.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.label3.Location = new System.Drawing.Point(57, 190); + this.label3.Location = new System.Drawing.Point(119, 175); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(62, 24); this.label3.TabIndex = 4; @@ -98,7 +107,7 @@ // this.label4.AutoSize = true; this.label4.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.label4.Location = new System.Drawing.Point(57, 231); + this.label4.Location = new System.Drawing.Point(119, 205); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(54, 24); this.label4.TabIndex = 5; @@ -108,7 +117,7 @@ // this.label5.AutoSize = true; this.label5.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.label5.Location = new System.Drawing.Point(57, 272); + this.label5.Location = new System.Drawing.Point(119, 235); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(65, 24); this.label5.TabIndex = 6; @@ -118,7 +127,7 @@ // this.label6.AutoSize = true; this.label6.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.label6.Location = new System.Drawing.Point(57, 313); + this.label6.Location = new System.Drawing.Point(119, 265); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(101, 24); this.label6.TabIndex = 7; @@ -129,7 +138,7 @@ this.TxtFB2.BackColor = System.Drawing.SystemColors.Info; this.TxtFB2.BorderStyle = System.Windows.Forms.BorderStyle.None; this.TxtFB2.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.TxtFB2.Location = new System.Drawing.Point(193, 187); + this.TxtFB2.Location = new System.Drawing.Point(255, 172); this.TxtFB2.Name = "TxtFB2"; this.TxtFB2.ReadOnly = true; this.TxtFB2.Size = new System.Drawing.Size(199, 24); @@ -141,7 +150,7 @@ this.TxtFB3.BackColor = System.Drawing.SystemColors.Info; this.TxtFB3.BorderStyle = System.Windows.Forms.BorderStyle.None; this.TxtFB3.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.TxtFB3.Location = new System.Drawing.Point(193, 228); + this.TxtFB3.Location = new System.Drawing.Point(255, 202); this.TxtFB3.Name = "TxtFB3"; this.TxtFB3.ReadOnly = true; this.TxtFB3.Size = new System.Drawing.Size(199, 24); @@ -153,7 +162,7 @@ this.TxtFB4.BackColor = System.Drawing.SystemColors.Info; this.TxtFB4.BorderStyle = System.Windows.Forms.BorderStyle.None; this.TxtFB4.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.TxtFB4.Location = new System.Drawing.Point(193, 269); + this.TxtFB4.Location = new System.Drawing.Point(255, 232); this.TxtFB4.Name = "TxtFB4"; this.TxtFB4.ReadOnly = true; this.TxtFB4.Size = new System.Drawing.Size(199, 24); @@ -165,7 +174,7 @@ this.TxtFB5.BackColor = System.Drawing.SystemColors.Info; this.TxtFB5.BorderStyle = System.Windows.Forms.BorderStyle.None; this.TxtFB5.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.TxtFB5.Location = new System.Drawing.Point(193, 310); + this.TxtFB5.Location = new System.Drawing.Point(255, 262); this.TxtFB5.Name = "TxtFB5"; this.TxtFB5.ReadOnly = true; this.TxtFB5.Size = new System.Drawing.Size(199, 24); @@ -176,7 +185,7 @@ // this.label7.AutoSize = true; this.label7.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.label7.Location = new System.Drawing.Point(57, 368); + this.label7.Location = new System.Drawing.Point(119, 304); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(58, 24); this.label7.TabIndex = 12; @@ -187,7 +196,7 @@ this.TxtFBTotal.BackColor = System.Drawing.SystemColors.Info; this.TxtFBTotal.BorderStyle = System.Windows.Forms.BorderStyle.None; this.TxtFBTotal.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.TxtFBTotal.Location = new System.Drawing.Point(193, 365); + this.TxtFBTotal.Location = new System.Drawing.Point(255, 301); this.TxtFBTotal.Name = "TxtFBTotal"; this.TxtFBTotal.ReadOnly = true; this.TxtFBTotal.Size = new System.Drawing.Size(199, 24); @@ -198,7 +207,7 @@ // this.label8.AutoSize = true; this.label8.Font = new System.Drawing.Font("MS UI Gothic", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.label8.Location = new System.Drawing.Point(22, 101); + this.label8.Location = new System.Drawing.Point(273, 40); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(94, 21); this.label8.TabIndex = 14; @@ -209,10 +218,10 @@ this.TxtDateTime.BackColor = System.Drawing.SystemColors.Control; this.TxtDateTime.BorderStyle = System.Windows.Forms.BorderStyle.None; this.TxtDateTime.Font = new System.Drawing.Font("MS UI Gothic", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.TxtDateTime.Location = new System.Drawing.Point(137, 101); + this.TxtDateTime.Location = new System.Drawing.Point(373, 40); this.TxtDateTime.Name = "TxtDateTime"; this.TxtDateTime.ReadOnly = true; - this.TxtDateTime.Size = new System.Drawing.Size(288, 21); + this.TxtDateTime.Size = new System.Drawing.Size(255, 21); this.TxtDateTime.TabIndex = 15; this.TxtDateTime.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // @@ -220,17 +229,102 @@ // this.label9.AutoSize = true; this.label9.Font = new System.Drawing.Font("MS UI Gothic", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.label9.Location = new System.Drawing.Point(100, 39); + this.label9.Location = new System.Drawing.Point(12, 40); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(251, 37); this.label9.TabIndex = 16; this.label9.Text = "Ecom実施結果"; // + // listView1 + // + this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2, + this.columnHeader3, + this.columnHeader4, + this.columnHeader5}); + this.listView1.Font = new System.Drawing.Font("MS UI Gothic", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.listView1.FullRowSelect = true; + this.listView1.GridLines = true; + this.listView1.HideSelection = false; + this.listView1.Location = new System.Drawing.Point(24, 386); + this.listView1.Name = "listView1"; + this.listView1.Size = new System.Drawing.Size(604, 199); + this.listView1.TabIndex = 17; + this.listView1.UseCompatibleStateImageBehavior = false; + this.listView1.View = System.Windows.Forms.View.Details; + // + // columnHeader1 + // + this.columnHeader1.Text = "シーン"; + // + // columnHeader2 + // + this.columnHeader2.Text = "FB回数"; + this.columnHeader2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.columnHeader2.Width = 100; + // + // columnHeader3 + // + this.columnHeader3.Text = "EC時間"; + this.columnHeader3.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.columnHeader3.Width = 120; + // + // columnHeader4 + // + this.columnHeader4.Text = "潜時"; + this.columnHeader4.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.columnHeader4.Width = 120; + // + // columnHeader5 + // + this.columnHeader5.Text = "心拍数"; + this.columnHeader5.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.columnHeader5.Width = 120; + // + // label10 + // + this.label10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label10.AutoSize = true; + this.label10.Font = new System.Drawing.Font("MS UI Gothic", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.label10.Location = new System.Drawing.Point(19, 356); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(157, 27); + this.label10.TabIndex = 18; + this.label10.Text = "シーン別解析"; + // + // TxtSubject + // + this.TxtSubject.BackColor = System.Drawing.SystemColors.Control; + this.TxtSubject.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.TxtSubject.Font = new System.Drawing.Font("MS UI Gothic", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.TxtSubject.Location = new System.Drawing.Point(373, 77); + this.TxtSubject.Name = "TxtSubject"; + this.TxtSubject.ReadOnly = true; + this.TxtSubject.Size = new System.Drawing.Size(255, 27); + this.TxtSubject.TabIndex = 20; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Font = new System.Drawing.Font("MS UI Gothic", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.label11.Location = new System.Drawing.Point(273, 77); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(93, 27); + this.label11.TabIndex = 19; + this.label11.Text = "被験者"; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(456, 415); + this.ClientSize = new System.Drawing.Size(652, 597); + this.Controls.Add(this.TxtSubject); + this.Controls.Add(this.label11); + this.Controls.Add(this.label10); + this.Controls.Add(this.listView1); this.Controls.Add(this.label9); this.Controls.Add(this.TxtDateTime); this.Controls.Add(this.label8); @@ -246,7 +340,7 @@ this.Controls.Add(this.label3); this.Controls.Add(this.TxtFB1); this.Controls.Add(this.label2); - this.Controls.Add(this.textBox1); + this.Controls.Add(this.TxtLogFilename); this.Controls.Add(this.label1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; this.Name = "Form1"; @@ -260,7 +354,7 @@ #endregion private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TextBox TxtLogFilename; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox TxtFB1; private System.Windows.Forms.Label label3; @@ -276,6 +370,15 @@ private System.Windows.Forms.Label label8; private System.Windows.Forms.TextBox TxtDateTime; private System.Windows.Forms.Label label9; + private System.Windows.Forms.ListView listView1; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.ColumnHeader columnHeader3; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.TextBox TxtSubject; + private System.Windows.Forms.Label label11; } } diff --git a/EcomAnalysis/Form1.cs b/EcomAnalysis/Form1.cs index 5c456a7..246592f 100644 --- a/EcomAnalysis/Form1.cs +++ b/EcomAnalysis/Form1.cs @@ -18,6 +18,10 @@ private Dictionary _SceneNoAssign = new Dictionary(); private List _Data = new List(); + /// + /// コンストラクタ + /// 基本データ設定 + /// public Form1() { InitializeComponent(); for (int scene = 1, stim = 5; scene <= 10; scene++, stim += 2) { @@ -34,8 +38,13 @@ } } + /// + /// フォームロード時 + /// + /// + /// private void Form1_Load(object sender, EventArgs e) { - textBox1.Text = "not opened"; + TxtLogFilename.Text = "not opened"; var args = Environment.GetCommandLineArgs(); if (args.Length > 1) { ReadCSV(args[1]); @@ -43,27 +52,64 @@ } } + /// + /// 解析 + /// private void Analyze() { + // FB回数 var fbCounts = new int[5]; var fbPts = new int[5]; for (int i=0; i s.Feedback == i + 1).Count(); fbPts[i] = fbCounts[i] * (i + 1); } - TxtFB1.Text = fbCounts[0].ToString("0回") + - fbPts[0].ToString(" 0ポイント"); - TxtFB2.Text = fbCounts[1].ToString("0回") + - fbPts[1].ToString(" 0ポイント"); - TxtFB3.Text = fbCounts[2].ToString("0回") + - fbPts[2].ToString(" 0ポイント"); - TxtFB4.Text = fbCounts[3].ToString("0回") + - fbPts[3].ToString(" 0ポイント"); - TxtFB5.Text = fbCounts[4].ToString("0回") + - fbPts[4].ToString(" 0ポイント"); - TxtFBTotal.Text = fbCounts.Sum().ToString("0回") + - fbPts.Sum().ToString(" 0ポイント"); + + // シーン別解析 + if (_Data.Where(s => s.SceneNo > 0).Count() > 0) { + var sceneBegin = _Data.Where(s => s.SceneNo > 0).Min(s => s.SceneNo); + var sceneEnd = _Data.Where(s => s.SceneNo > 0).Max(s => s.SceneNo); + + var allData = new List(); + for (int sc = sceneBegin; sc <= sceneEnd; sc++) { + var scDat = new SceneData(); + scDat.SceneNo = sc; + var dat = _Data.Where(s => s.SceneNo == sc); + scDat.FBCount = dat.Count(c => c.Feedback > 0); + scDat.ECTime = dat.Count(c => c.Feedback == 5) * 15.0 + + dat.OrderBy(s => s.SceneTime).Select(s=>s.ContactTime).Last(); + scDat.Latency = dat.Where(c => c.Feedback > 0).Count()==0 ? 0 : + dat.Where(c => c.Feedback > 0).Select(s => s.SceneTime).First(); + scDat.MeanRR = 60000.0 / dat.Select(s => s.RR).Average(); + + var items = new string[] { + $"{scDat.SceneNo}", $"{scDat.FBCount} 回", + $"{scDat.ECTime:0.00} ms", $"{scDat.Latency:0.00} ms", + $"{scDat.MeanRR:0.00} bpm" }; + listView1.Items.Add(new ListViewItem(items)); + allData.Add(scDat); + } + + listView1.Items.Add(new ListViewItem(new string[] { + "平均", + $"{allData.Select(s=>s.FBCount).Average():0.00} 回", + $"{allData.Select(s=>s.ECTime).Average():0.00} ms", + $"{allData.Select(s=>s.Latency).Average():0.00} ms", + $"{allData.Select(s=>s.MeanRR).Average():0.00} bpm" })); + } + + // 表示 + TxtFB1.Text = $"{fbCounts[0],2}回 {fbPts[0],4}ポイント"; + TxtFB2.Text = $"{fbCounts[1],2}回 {fbPts[1],4}ポイント"; + TxtFB3.Text = $"{fbCounts[2],2}回 {fbPts[2],4}ポイント"; + TxtFB4.Text = $"{fbCounts[3],2}回 {fbPts[3],4}ポイント"; + TxtFB5.Text = $"{fbCounts[4],2}回 {fbPts[4],4}ポイント"; + TxtFBTotal.Text = $"{fbCounts.Sum(),2}回 {fbPts.Sum(),4}ポイント"; } + /// + /// CSVファイルの読み込み + /// + /// private void ReadCSV(string csvfile) { char[] sep = { ',' }; @@ -75,6 +121,7 @@ using (var sr = new StreamReader(csvfile, Encoding.GetEncoding("shift_jis"))) { + // ヘッダー検証 var readHeader = sr.ReadLine().Split(sep); var headerCol = new Dictionary(); foreach (var hi in _HeaderItems) { @@ -86,6 +133,7 @@ return; } + // 読み込み _Data.Clear(); var sceneNoExist = headerCol["sceneNo"] >= 0; while (sr.Peek() > -1) { @@ -101,12 +149,16 @@ _Data.Add(ld); } //Debug.WriteLine(_Data.Count); - textBox1.Text = csvfile; + + // 表示 + 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('_'); + TxtSubject.Text = $"{strs[2]} Visit {strs[3]}"; } } } diff --git a/EcomAnalysis/LogData.cs b/EcomAnalysis/LogData.cs index 0b6d104..7a8d0f4 100644 --- a/EcomAnalysis/LogData.cs +++ b/EcomAnalysis/LogData.cs @@ -27,4 +27,12 @@ //public float PupilL; // 瞳孔径 //public float PupilR; // 瞳孔径 } + + class SceneData { + public int SceneNo; + public int FBCount; + public double ECTime; + public double Latency; + public double MeanRR; + } }