From 081afbecf0121dd930ac89377cb1c0eaadaf3471 Mon Sep 17 00:00:00 2001 From: lhiven Date: Tue, 20 Aug 2024 17:04:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E6=B2=BB=E5=85=B7=E7=9A=84=E5=B7=A6?= =?UTF-8?q?=E4=B8=8A=E8=A7=92=E5=A2=9E=E5=8A=A0=E5=92=8C=E6=B2=BB=E5=85=B7?= =?UTF-8?q?=E9=80=9A=E4=BF=A1=E7=9A=84=E5=AE=9E=E6=97=B6=E7=8A=B6=E6=80=81?= =?UTF-8?q?=EF=BC=8C=E5=BD=93=E9=80=9A=E4=BF=A1=E5=81=9C=E6=AD=A2=E6=97=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=BA=A2=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rs.DeweyTester/CommunicationFrm.Designer.cs | 264 +++++ Rs.DeweyTester/CommunicationFrm.cs | 30 + Rs.DeweyTester/CommunicationFrm.resx | 138 +++ Rs.DeweyTester/Controls/UFixture.Designer.cs | 15 +- Rs.DeweyTester/Controls/UFixture.cs | 29 +- Rs.DeweyTester/Entitys/TestFixtureManager.cs | 95 +- Rs.DeweyTester/Home.resx | 1051 ++++++------------ Rs.DeweyTester/Rs.DeweyTester.csproj | 9 + Rs.DeweyTester/SysConfig/CommonConfig.resx | 20 +- 9 files changed, 920 insertions(+), 731 deletions(-) create mode 100644 Rs.DeweyTester/CommunicationFrm.Designer.cs create mode 100644 Rs.DeweyTester/CommunicationFrm.cs create mode 100644 Rs.DeweyTester/CommunicationFrm.resx diff --git a/Rs.DeweyTester/CommunicationFrm.Designer.cs b/Rs.DeweyTester/CommunicationFrm.Designer.cs new file mode 100644 index 0000000..f3a2b2b --- /dev/null +++ b/Rs.DeweyTester/CommunicationFrm.Designer.cs @@ -0,0 +1,264 @@ +namespace Rs.MotionPlat +{ + partial class CommunicationFrm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.groupBox5 = new System.Windows.Forms.GroupBox(); + this.groupBox6 = new System.Windows.Forms.GroupBox(); + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.richTextBox2 = new System.Windows.Forms.RichTextBox(); + this.richTextBox3 = new System.Windows.Forms.RichTextBox(); + this.richTextBox4 = new System.Windows.Forms.RichTextBox(); + this.richTextBox5 = new System.Windows.Forms.RichTextBox(); + this.richTextBox6 = new System.Windows.Forms.RichTextBox(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.timer2 = new System.Windows.Forms.Timer(this.components); + this.timer3 = new System.Windows.Forms.Timer(this.components); + this.timer4 = new System.Windows.Forms.Timer(this.components); + this.timer5 = new System.Windows.Forms.Timer(this.components); + this.timer6 = new System.Windows.Forms.Timer(this.components); + this.tableLayoutPanel1.SuspendLayout(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.groupBox4.SuspendLayout(); + this.groupBox5.SuspendLayout(); + this.groupBox6.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 3; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334F)); + this.tableLayoutPanel1.Controls.Add(this.groupBox1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.groupBox2, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.groupBox3, 2, 0); + this.tableLayoutPanel1.Controls.Add(this.groupBox4, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.groupBox5, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.groupBox6, 2, 1); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 2; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1467, 851); + this.tableLayoutPanel1.TabIndex = 0; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.richTextBox1); + this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox1.ForeColor = System.Drawing.Color.White; + this.groupBox1.Location = new System.Drawing.Point(3, 3); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(483, 419); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "TC1"; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.richTextBox2); + this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox2.ForeColor = System.Drawing.Color.White; + this.groupBox2.Location = new System.Drawing.Point(492, 3); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(483, 419); + this.groupBox2.TabIndex = 0; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "TC2"; + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.richTextBox3); + this.groupBox3.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox3.ForeColor = System.Drawing.Color.White; + this.groupBox3.Location = new System.Drawing.Point(981, 3); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(483, 419); + this.groupBox3.TabIndex = 0; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "TC3"; + // + // groupBox4 + // + this.groupBox4.Controls.Add(this.richTextBox4); + this.groupBox4.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox4.ForeColor = System.Drawing.Color.White; + this.groupBox4.Location = new System.Drawing.Point(3, 428); + this.groupBox4.Name = "groupBox4"; + this.groupBox4.Size = new System.Drawing.Size(483, 420); + this.groupBox4.TabIndex = 0; + this.groupBox4.TabStop = false; + this.groupBox4.Text = "TC4"; + // + // groupBox5 + // + this.groupBox5.Controls.Add(this.richTextBox5); + this.groupBox5.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox5.ForeColor = System.Drawing.Color.White; + this.groupBox5.Location = new System.Drawing.Point(492, 428); + this.groupBox5.Name = "groupBox5"; + this.groupBox5.Size = new System.Drawing.Size(483, 420); + this.groupBox5.TabIndex = 0; + this.groupBox5.TabStop = false; + this.groupBox5.Text = "TC5"; + // + // groupBox6 + // + this.groupBox6.Controls.Add(this.richTextBox6); + this.groupBox6.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox6.ForeColor = System.Drawing.Color.White; + this.groupBox6.Location = new System.Drawing.Point(981, 428); + this.groupBox6.Name = "groupBox6"; + this.groupBox6.Size = new System.Drawing.Size(483, 420); + this.groupBox6.TabIndex = 0; + this.groupBox6.TabStop = false; + this.groupBox6.Text = "TC6"; + // + // richTextBox1 + // + this.richTextBox1.BackColor = System.Drawing.Color.Black; + this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.richTextBox1.ForeColor = System.Drawing.Color.Lime; + this.richTextBox1.Location = new System.Drawing.Point(3, 17); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.Size = new System.Drawing.Size(477, 399); + this.richTextBox1.TabIndex = 0; + this.richTextBox1.Text = ""; + // + // richTextBox2 + // + this.richTextBox2.BackColor = System.Drawing.Color.Black; + this.richTextBox2.Dock = System.Windows.Forms.DockStyle.Fill; + this.richTextBox2.ForeColor = System.Drawing.Color.Lime; + this.richTextBox2.Location = new System.Drawing.Point(3, 17); + this.richTextBox2.Name = "richTextBox2"; + this.richTextBox2.Size = new System.Drawing.Size(477, 399); + this.richTextBox2.TabIndex = 0; + this.richTextBox2.Text = ""; + // + // richTextBox3 + // + this.richTextBox3.BackColor = System.Drawing.Color.Black; + this.richTextBox3.Dock = System.Windows.Forms.DockStyle.Fill; + this.richTextBox3.ForeColor = System.Drawing.Color.Lime; + this.richTextBox3.Location = new System.Drawing.Point(3, 17); + this.richTextBox3.Name = "richTextBox3"; + this.richTextBox3.Size = new System.Drawing.Size(477, 399); + this.richTextBox3.TabIndex = 0; + this.richTextBox3.Text = ""; + // + // richTextBox4 + // + this.richTextBox4.BackColor = System.Drawing.Color.Black; + this.richTextBox4.Dock = System.Windows.Forms.DockStyle.Fill; + this.richTextBox4.ForeColor = System.Drawing.Color.Lime; + this.richTextBox4.Location = new System.Drawing.Point(3, 17); + this.richTextBox4.Name = "richTextBox4"; + this.richTextBox4.Size = new System.Drawing.Size(477, 400); + this.richTextBox4.TabIndex = 0; + this.richTextBox4.Text = ""; + // + // richTextBox5 + // + this.richTextBox5.BackColor = System.Drawing.Color.Black; + this.richTextBox5.Dock = System.Windows.Forms.DockStyle.Fill; + this.richTextBox5.ForeColor = System.Drawing.Color.Lime; + this.richTextBox5.Location = new System.Drawing.Point(3, 17); + this.richTextBox5.Name = "richTextBox5"; + this.richTextBox5.Size = new System.Drawing.Size(477, 400); + this.richTextBox5.TabIndex = 0; + this.richTextBox5.Text = ""; + // + // richTextBox6 + // + this.richTextBox6.BackColor = System.Drawing.Color.Black; + this.richTextBox6.Dock = System.Windows.Forms.DockStyle.Fill; + this.richTextBox6.ForeColor = System.Drawing.Color.Lime; + this.richTextBox6.Location = new System.Drawing.Point(3, 17); + this.richTextBox6.Name = "richTextBox6"; + this.richTextBox6.Size = new System.Drawing.Size(477, 400); + this.richTextBox6.TabIndex = 0; + this.richTextBox6.Text = ""; + // + // timer1 + // + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // CommunicationFrm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1467, 851); + this.Controls.Add(this.tableLayoutPanel1); + this.Name = "CommunicationFrm"; + this.Text = "CommunicationFrm"; + this.tableLayoutPanel1.ResumeLayout(false); + this.groupBox1.ResumeLayout(false); + this.groupBox2.ResumeLayout(false); + this.groupBox3.ResumeLayout(false); + this.groupBox4.ResumeLayout(false); + this.groupBox5.ResumeLayout(false); + this.groupBox6.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.GroupBox groupBox4; + private System.Windows.Forms.GroupBox groupBox5; + private System.Windows.Forms.GroupBox groupBox6; + private System.Windows.Forms.RichTextBox richTextBox1; + private System.Windows.Forms.RichTextBox richTextBox2; + private System.Windows.Forms.RichTextBox richTextBox3; + private System.Windows.Forms.RichTextBox richTextBox4; + private System.Windows.Forms.RichTextBox richTextBox5; + private System.Windows.Forms.RichTextBox richTextBox6; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.Timer timer2; + private System.Windows.Forms.Timer timer3; + private System.Windows.Forms.Timer timer4; + private System.Windows.Forms.Timer timer5; + private System.Windows.Forms.Timer timer6; + } +} \ No newline at end of file diff --git a/Rs.DeweyTester/CommunicationFrm.cs b/Rs.DeweyTester/CommunicationFrm.cs new file mode 100644 index 0000000..1c52c6e --- /dev/null +++ b/Rs.DeweyTester/CommunicationFrm.cs @@ -0,0 +1,30 @@ +using Rs.MotionPlat.Entitys; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Rs.MotionPlat +{ + public partial class CommunicationFrm :BaseForm + { + public CommunicationFrm() + { + InitializeComponent(); + } + + private void timer1_Tick(object sender, EventArgs e) + { + string log = TestFixtureManager.Instance.GetTestFixture(1).GetLog(); + if(!string.IsNullOrEmpty(log) ) + { + + } + } + } +} diff --git a/Rs.DeweyTester/CommunicationFrm.resx b/Rs.DeweyTester/CommunicationFrm.resx new file mode 100644 index 0000000..a3789af --- /dev/null +++ b/Rs.DeweyTester/CommunicationFrm.resx @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 107, 17 + + + 197, 17 + + + 287, 17 + + + 377, 17 + + + 467, 17 + + \ No newline at end of file diff --git a/Rs.DeweyTester/Controls/UFixture.Designer.cs b/Rs.DeweyTester/Controls/UFixture.Designer.cs index 0ebada4..518ec92 100644 --- a/Rs.DeweyTester/Controls/UFixture.Designer.cs +++ b/Rs.DeweyTester/Controls/UFixture.Designer.cs @@ -53,6 +53,7 @@ this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.lblIndex = new System.Windows.Forms.Label(); this.btnReset = new System.Windows.Forms.Button(); + this.label5 = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel2.SuspendLayout(); @@ -62,6 +63,7 @@ // this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0))))); this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel1.Controls.Add(this.label5); this.panel1.Controls.Add(this.lblFixtureName); this.panel1.Dock = System.Windows.Forms.DockStyle.Top; this.panel1.Location = new System.Drawing.Point(0, 0); @@ -78,7 +80,7 @@ this.lblFixtureName.Location = new System.Drawing.Point(0, 0); this.lblFixtureName.Name = "lblFixtureName"; this.lblFixtureName.Size = new System.Drawing.Size(302, 34); - this.lblFixtureName.TabIndex = 1; + this.lblFixtureName.TabIndex = 3; this.lblFixtureName.Text = "title"; this.lblFixtureName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // @@ -358,6 +360,14 @@ this.btnReset.UseVisualStyleBackColor = false; this.btnReset.Click += new System.EventHandler(this.btnReset_Click); // + // label5 + // + this.label5.BackColor = System.Drawing.Color.Red; + this.label5.Location = new System.Drawing.Point(0, 0); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(5, 5); + this.label5.TabIndex = 4; + // // UFixture // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -381,7 +391,6 @@ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label lblFixtureName; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label7; @@ -402,5 +411,7 @@ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; private System.Windows.Forms.Label lblIndex; private System.Windows.Forms.Button btnReset; + private System.Windows.Forms.Label lblFixtureName; + private System.Windows.Forms.Label label5; } } diff --git a/Rs.DeweyTester/Controls/UFixture.cs b/Rs.DeweyTester/Controls/UFixture.cs index c9ee647..992f69a 100644 --- a/Rs.DeweyTester/Controls/UFixture.cs +++ b/Rs.DeweyTester/Controls/UFixture.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -31,9 +32,35 @@ namespace Rs.MotionPlat } } - + int errNum = 0; public void RefreshStatus(TestFixture tf) { + string msg = tf.GetLog(); + if(string.IsNullOrEmpty(msg)) + { + errNum++; + if(errNum>=10) + { + if (label5.BackColor != Color.Red) + label5.BackColor = Color.Red; + } + } + else + { + //打印日志 + string logDir = $"d:\\log\\Communition\\{DateTime.Now.ToString("yyyyMMdd")}"; + if (!Directory.Exists(logDir)) + { + Directory.CreateDirectory(logDir); + } + string logFileName = $"{logDir}\\{tf.Index}.txt"; + File.WriteAllText(logFileName, $"{msg}\r\n"); + if (label5.BackColor!=Color.Lime) + { + label5.BackColor = Color.Lime; + } + errNum = 0; + } if (lblStatus.Text != tf.Status.ToString()) { lblStatus.Text = tf.Status.ToString(); diff --git a/Rs.DeweyTester/Entitys/TestFixtureManager.cs b/Rs.DeweyTester/Entitys/TestFixtureManager.cs index 538ac0c..38c385e 100644 --- a/Rs.DeweyTester/Entitys/TestFixtureManager.cs +++ b/Rs.DeweyTester/Entitys/TestFixtureManager.cs @@ -1,5 +1,7 @@ -using NPOI.SS.Format; +using log4net.Util; +using NPOI.SS.Format; using NPOI.SS.Formula.Functions; +using NPOI.SS.Formula.PTG; using Rs.Framework; using Rs.MotionPlat.Commom; using Rs.MotionPlat.Flow; @@ -65,7 +67,7 @@ namespace Rs.MotionPlat.Entitys bool exit = false; public TestFixture() { - PrintCommunitionLog(); + //PrintCommunitionLog(); QueryStatus(); StartRecive(); } @@ -372,7 +374,8 @@ namespace Rs.MotionPlat.Entitys //dataEvent.Reset(); if (CheckPrintLog()) { - logs.Enqueue($"<<< TC{Index} status$"); + AddLog($"<<< TC{Index} status$"); + //logs.Enqueue($"<<< TC{Index} status$"); //lock(this) //{ // File.AppendAllText($"d:\\1\\{Index}.txt", $"<<< 治具{Index} status$\r\n"); @@ -403,7 +406,7 @@ namespace Rs.MotionPlat.Entitys Send($"Reset$"); if (CheckPrintLog()) { - logs.Enqueue($"<<< TC{Index} Reset$"); + AddLog($"<<< TC{Index} Reset$"); } } @@ -426,7 +429,7 @@ namespace Rs.MotionPlat.Entitys Send($"Pause#1$"); if (CheckPrintLog()) { - logs.Enqueue($"<<< TC{Index} Pause#1$"); + AddLog($"<<< TC{Index} Pause#1$"); } } @@ -468,7 +471,7 @@ namespace Rs.MotionPlat.Entitys Send(msg); if(CheckPrintLog()) { - logs.Enqueue($"<<< TC{Index} {msg}"); + AddLog($"<<< TC{Index} {msg}"); } } private ConcurrentQueue logs = new ConcurrentQueue(); @@ -528,7 +531,7 @@ namespace Rs.MotionPlat.Entitys string content = Encoding.ASCII.GetString(data.ToArray()); if (CheckPrintLog()) { - logs.Enqueue($">>> TC{Index},{content}"); + AddLog($">>> TC{Index},{content}"); } string[] items = content.Split('#'); string command = items[0]; @@ -548,7 +551,7 @@ namespace Rs.MotionPlat.Entitys // File.AppendAllText($"d:\\1\\{Index}.txt", $"<<< 治具{Index} ErrorCode$\r\n"); //} - logs.Enqueue($"<<< TC{Index} ErrorCode$"); + AddLog($"<<< TC{Index} ErrorCode$"); } break; case "1": @@ -563,7 +566,7 @@ namespace Rs.MotionPlat.Entitys //{ // File.AppendAllText($"d:\\1\\{Index}.txt", $"<<< 治具{Index} Result$\r\n"); //} - logs.Enqueue($"<<< TC{Index} Result$"); + AddLog($"<<< TC{Index} Result$"); } } else @@ -715,42 +718,70 @@ namespace Rs.MotionPlat.Entitys public void AddLog(string log) { - logs.Enqueue(log); - } - private void PrintCommunitionLog() - { - Task.Run(() => { + if(logs.Count>500) + { + int i = 0; while (true) { - if(logs.Count > 0) - { - bool ret = logs.TryDequeue(out string log); - if (ret) - { - //打印日志 - string logDir = $"d:\\Communition\\{DateTime.Now.ToString("yyyyMMdd")}"; - if(!Directory.Exists(logDir)) - { - Directory.CreateDirectory(logDir); - } - string logFileName = $"{logDir}\\{Index}.txt"; - File.AppendAllText(logFileName, $"{DateTime.Now.ToString("HH:mm:ss fff")} {log}\r\n"); - } - } - else + i++; + logs.TryDequeue(out string msg); + if(i>=500) { - Thread.Sleep(100); + break; } } - }); + } + logs.Enqueue(log); } + public string GetLog() + { + StringBuilder msg = new StringBuilder(); + while (logs.Count > 0) + { + bool b = logs.TryDequeue(out string content); + if(b) + { + msg.Append($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} {content}\r\n"); + } + } + return msg.ToString(); + } + //private void PrintCommunitionLog() + //{ + // Task.Run(() => { + // while (true) + // { + // if(logs.Count > 0) + // { + // bool ret = logs.TryDequeue(out string log); + // if (ret) + // { + // //打印日志 + // string logDir = $"d:\\Communition\\{DateTime.Now.ToString("yyyyMMdd")}"; + // if(!Directory.Exists(logDir)) + // { + // Directory.CreateDirectory(logDir); + // } + // string logFileName = $"{logDir}\\{Index}.txt"; + // File.AppendAllText(logFileName, $"{DateTime.Now.ToString("HH:mm:ss fff")} {log}\r\n"); + // } + // } + // else + // { + // Thread.Sleep(100); + // } + // } + // }); + //} + /// /// 检测是否需要打印日志 /// /// private bool CheckPrintLog() { + return true; switch (Index) { case 1: diff --git a/Rs.DeweyTester/Home.resx b/Rs.DeweyTester/Home.resx index 06761e5..71bf932 100644 --- a/Rs.DeweyTester/Home.resx +++ b/Rs.DeweyTester/Home.resx @@ -126,7 +126,7 @@ 0, 93 - 970, 424 + 1806, 650 @@ -160,13 +160,13 @@ NoControl - 222, 0 + 414, 0 0, 0, 0, 0 - 111, 53 + 207, 53 1 @@ -183,6 +183,30 @@ 0 + + Fill + + + Flat + + + SimSun-ExtB, 14pt + + + 0, 0 + + + 0, 0, 0, 0 + + + 0, 0, 30, 0 + + + 207, 53 + + + 2 + btnMain @@ -205,7 +229,7 @@ 0, 0, 0, 0 - 111, 53 + 207, 53 0 @@ -222,6 +246,27 @@ 1 + + Fill + + + Flat + + + SimSun-ExtB, 14pt + + + 0, 0 + + + 0, 0, 0, 0 + + + 207, 53 + + + 0 + btnRecipe @@ -238,13 +283,13 @@ Fill - 111, 0 + 207, 0 0, 0, 0, 0 - 111, 53 + 207, 53 1 @@ -261,6 +306,27 @@ 2 + + Fill + + + Flat + + + SimSun-ExtB, 14pt + + + 0, 0 + + + 0, 0, 0, 0 + + + 207, 53 + + + 1 + btnSystem @@ -277,13 +343,13 @@ Fill - 333, 0 + 621, 0 0, 0, 0, 0 - 111, 53 + 207, 53 2 @@ -300,6 +366,27 @@ 3 + + Fill + + + Flat + + + SimSun-ExtB, 14pt + + + 0, 0 + + + 0, 0, 0, 0 + + + 207, 53 + + + 6 + btnAbout @@ -316,13 +403,13 @@ Fill - 444, 0 + 828, 0 0, 0, 0, 0 - 111, 53 + 207, 53 3 @@ -339,6 +426,27 @@ 4 + + Fill + + + Flat + + + SimSun-ExtB, 14pt + + + 0, 0 + + + 0, 0, 0, 0 + + + 207, 53 + + + 3 + btnData @@ -355,13 +463,13 @@ Fill - 555, 0 + 1035, 0 0, 0, 0, 0 - 111, 53 + 207, 53 4 @@ -378,6 +486,30 @@ 5 + + Fill + + + Flat + + + SimSun-ExtB, 14pt + + + NoControl + + + 0, 0 + + + 0, 0, 0, 0 + + + 207, 53 + + + 4 + btnLanguage @@ -394,13 +526,13 @@ Fill - 666, 0 + 1242, 0 0, 0, 0, 0 - 111, 53 + 207, 53 5 @@ -417,6 +549,27 @@ 6 + + Fill + + + Flat + + + SimSun-ExtB, 14pt + + + 0, 0 + + + 0, 0, 0, 0 + + + 207, 53 + + + 7 + btnPermission @@ -433,13 +586,13 @@ Fill - 777, 0 + 1449, 0 0, 0, 0, 0 - 111, 53 + 207, 53 6 @@ -456,6 +609,27 @@ 7 + + Fill + + + Flat + + + SimSun-ExtB, 14pt + + + 0, 0 + + + 0, 0, 0, 0 + + + 150, 53 + + + 5 + btnQuit @@ -472,13 +646,13 @@ Fill - 888, 0 + 1656, 0 0, 0, 0, 0 - 82, 53 + 150, 53 7 @@ -508,7 +682,7 @@ 1 - 970, 53 + 1806, 53 6 @@ -528,477 +702,81 @@ <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="btnRunData" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="panel8" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="panel9" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="panel10" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="panel11" Row="0" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="panel12" Row="0" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="panel13" Row="0" RowSpan="1" Column="6" ColumnSpan="1" /><Control Name="panel14" Row="0" RowSpan="1" Column="7" ColumnSpan="1" /><Control Name="panel15" Row="0" RowSpan="1" Column="8" ColumnSpan="1" /></Controls><Columns Styles="Percent,11.5,Percent,11.5,Percent,11.5,Percent,11.5,Percent,11.5,Percent,11.5,Percent,11.5,Percent,11.5,Percent,8" /><Rows Styles="Percent,100" /></TableLayoutSettings> - + Fill - - Flat - - - SimSun-ExtB, 14pt - - + 0, 0 - - 0, 0, 0, 0 + + 184, 33 - - 0, 0, 30, 0 + + 3 - - 111, 53 + + Monitor: - - 2 + + MiddleLeft - - btnMain + + lblMonitorFlow - - Rs.Controls.ButtonEx, Rs.Controls, Version=2.20.24.4, Culture=neutral, PublicKeyToken=null + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - panel8 + + panel16 - + 0 - - Fill - - - Flat - - - SimSun-ExtB, 14pt - - - 0, 0 + + Left - - 0, 0, 0, 0 + + 1228, 0 - - 111, 53 + + 184, 33 - - 0 + + 8 - - btnRecipe + + panel16 - - Rs.Controls.ButtonEx, Rs.Controls, Version=2.20.24.4, Culture=neutral, PublicKeyToken=null + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - panel9 + + panel1 - + 0 - + Fill - - Flat - - - SimSun-ExtB, 14pt + + NoControl - + 0, 0 - - 0, 0, 0, 0 - - - 111, 53 - - - 1 - - - btnSystem - - - Rs.Controls.ButtonEx, Rs.Controls, Version=2.20.24.4, Culture=neutral, PublicKeyToken=null - - - panel10 - - - 0 - - - Fill - - - Flat - - - SimSun-ExtB, 14pt - - - 0, 0 - - - 0, 0, 0, 0 - - - 111, 53 - - - 6 - - - btnAbout - - - Rs.Controls.ButtonEx, Rs.Controls, Version=2.20.24.4, Culture=neutral, PublicKeyToken=null - - - panel11 - - - 0 - - - Fill - - - Flat - - - SimSun-ExtB, 14pt - - - 0, 0 - - - 0, 0, 0, 0 - - - 111, 53 - - - 3 - - - btnData - - - Rs.Controls.ButtonEx, Rs.Controls, Version=2.20.24.4, Culture=neutral, PublicKeyToken=null - - - panel12 - - - 0 - - - Fill - - - Flat - - - SimSun-ExtB, 14pt - - - NoControl - - - 0, 0 - - - 0, 0, 0, 0 - - - 111, 53 - - - 4 - - - btnLanguage - - - Rs.Controls.ButtonEx, Rs.Controls, Version=2.20.24.4, Culture=neutral, PublicKeyToken=null - - - panel13 - - - 0 - - - Fill - - - Flat - - - SimSun-ExtB, 14pt - - - 0, 0 - - - 0, 0, 0, 0 - - - 111, 53 - - - 7 - - - btnPermission - - - Rs.Controls.ButtonEx, Rs.Controls, Version=2.20.24.4, Culture=neutral, PublicKeyToken=null - - - panel14 - - - 0 - - - Fill - - - Flat - - - SimSun-ExtB, 14pt - - - 0, 0 - - - 0, 0, 0, 0 - - - 82, 53 - - - 5 - - - btnQuit - - - Rs.Controls.ButtonEx, Rs.Controls, Version=2.20.24.4, Culture=neutral, PublicKeyToken=null - - - panel15 - - - 0 - - - panel16 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel1 - - - 0 - - - panel7 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel1 - - - 1 - - - panel6 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel1 - - - 2 - - - panel5 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel1 - - - 3 - - - panel4 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel1 - - - 4 - - - panel3 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel1 - - - 5 - - - panelEx2 - - - Rs.Controls.PanelEx, Rs.Controls, Version=2.20.24.4, Culture=neutral, PublicKeyToken=null - - - panel1 - - - 6 - - - tableLayoutPanel3 - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel1 - - - 7 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lblMachineState" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="Percent,30,Percent,70" /><Rows Styles="Percent,100" /></TableLayoutSettings> - - - panelEx1 - - - Rs.Controls.PanelEx, Rs.Controls, Version=2.20.24.4, Culture=neutral, PublicKeyToken=null - - - panel1 - - - 8 - - - Bottom - - - 0, 517 - - - 970, 33 - - - 7 - - - panel1 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 2 - - - lblMonitorFlow - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel16 - - - 0 - - - Left - - - 1228, 0 - - - 184, 33 - - - 8 - - - panel16 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel1 - - - 0 - - - Fill - - - 0, 0 - - + 184, 33 - - 3 + + 5 - - Monitor: + + 治具下料: - + MiddleLeft - - lblMonitorFlow - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel16 - - - 0 - lblFixtureTakeFlow @@ -1035,39 +813,27 @@ 1 - + Fill - + NoControl - + 0, 0 - - 184, 33 + + 237, 33 - - 5 + + 4 - - 治具下料: + + 治具上料: - + MiddleLeft - - lblFixtureTakeFlow - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel7 - - - 0 - lblFixturePlaceFlow @@ -1104,39 +870,21 @@ 2 - + Fill - - NoControl - - + 0, 0 - - 237, 33 - - - 4 - - - 治具上料: - - - MiddleLeft - - - lblFixturePlaceFlow - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel6 + + 126, 33 - + 0 + + MiddleCenter + lblMemory @@ -1153,7 +901,7 @@ Right - 607, 0 + 1443, 0 126, 33 @@ -1173,32 +921,26 @@ 3 - + Fill - - 0, 0 - - - 126, 33 - - - 0 - - - MiddleCenter + + NoControl - - lblMemory + + 0, 0 - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 213, 33 - - panel5 + + 5 - - 0 + + 料仓下料: + + + MiddleLeft lblStockPlaceFlow @@ -1236,39 +978,24 @@ 4 - + Fill - - NoControl - - + 0, 0 - - 213, 33 + + 215, 33 - - 5 + + 3 - - 料仓下料: + + 料仓上料: - + MiddleLeft - - lblStockPlaceFlow - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel4 - - - 0 - lblStockLoadProductFlow @@ -1305,36 +1032,24 @@ 5 - + Fill - + 0, 0 - - 215, 33 + + 213, 33 - + 3 - - 料仓上料: + + 主流程: - + MiddleLeft - - lblStockLoadProductFlow - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel3 - - - 0 - lblDischargeFlow @@ -1371,38 +1086,26 @@ 6 - - Fill - - - 0, 0 - - - 213, 33 - - - 3 - - - 主流程: - - - MiddleLeft + + 2 - - lblDischargeFlow + + Fill - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 3, 0 - - panelEx2 + + 43, 33 - + 0 - - 2 + + State: + + + MiddleCenter label1 @@ -1416,6 +1119,24 @@ 0 + + Fill + + + 52, 0 + + + 111, 33 + + + 1 + + + Noinit + + + MiddleLeft + lblMachineState @@ -1458,65 +1179,44 @@ <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="label1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="lblMachineState" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="Percent,30,Percent,70" /><Rows Styles="Percent,100" /></TableLayoutSettings> - + Fill - - 3, 0 + + 0, 0 - - 43, 33 + + 168, 33 - + 0 - - State: - - + MiddleCenter - - label1 + + lblVersion - + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - tableLayoutPanel3 + + panel2 - + 0 - - Fill - - - 52, 0 - - - 111, 33 - - - 1 - - - Noinit - - - MiddleLeft - - - lblMachineState + + Right - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 69, 0 - - tableLayoutPanel3 + + 168, 33 - - 1 + + 0 panel2 @@ -1534,7 +1234,7 @@ Right - 733, 0 + 1569, 0 237, 33 @@ -1554,68 +1254,29 @@ 8 - - lblVersion - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel2 - - - 0 - - - Right + + Bottom - - 69, 0 + + 0, 743 - - 168, 33 + + 1806, 33 - - 0 + + 7 - - panel2 + + panel1 - + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - panelEx1 - - - 0 - - - Fill - - - 0, 0 - - - 168, 33 - - - 0 - - - MiddleCenter - - - lblVersion - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel2 + + $this - - 0 + + 2 17, 17 @@ -1633,7 +1294,7 @@ 6, 12 - 970, 550 + 1806, 776 6, 6, 6, 6 @@ -1666,6 +1327,6 @@ Home - Rs.MotionPlat.BaseFormHeader, Rs.MotionPlat, Version=1.20.24.8, Culture=neutral, PublicKeyToken=null + Rs.MotionPlat.BaseFormHeader, Rs.MotionPlat, Version=1.20.24.9, Culture=neutral, PublicKeyToken=null \ No newline at end of file diff --git a/Rs.DeweyTester/Rs.DeweyTester.csproj b/Rs.DeweyTester/Rs.DeweyTester.csproj index 050baf5..7310f24 100644 --- a/Rs.DeweyTester/Rs.DeweyTester.csproj +++ b/Rs.DeweyTester/Rs.DeweyTester.csproj @@ -150,6 +150,12 @@ + + Form + + + CommunicationFrm.cs + Form @@ -486,6 +492,9 @@ CalibrationForm.cs + + CommunicationFrm.cs + ConfigForm.cs diff --git a/Rs.DeweyTester/SysConfig/CommonConfig.resx b/Rs.DeweyTester/SysConfig/CommonConfig.resx index 6e9db21..83c8feb 100644 --- a/Rs.DeweyTester/SysConfig/CommonConfig.resx +++ b/Rs.DeweyTester/SysConfig/CommonConfig.resx @@ -1770,6 +1770,9 @@ TC6通信日志 + + False + cboxPrintTC6Communicate @@ -1800,6 +1803,9 @@ TC3通信日志 + + False + cboxPrintTC3Communicate @@ -1830,6 +1836,9 @@ TC5通信日志 + + False + cboxPrintTC5Communicate @@ -1860,6 +1869,9 @@ TC2通信日志 + + False + cboxPrintTC2Communicate @@ -1890,6 +1902,9 @@ TC4通信日志 + + False + cboxPrintTC4Communicate @@ -1920,6 +1935,9 @@ TC1通信日志 + + False + cboxPrintTC1Communicate @@ -2668,6 +2686,6 @@ CommonConfig - Rs.MotionPlat.BaseForm, Rs.MotionPlat, Version=1.20.24.8, Culture=neutral, PublicKeyToken=null + Rs.MotionPlat.BaseForm, Rs.MotionPlat, Version=1.20.24.9, Culture=neutral, PublicKeyToken=null \ No newline at end of file