在治具的左上角增加和治具通信的实时状态,当通信停止时显示红色

master
lhiven 1 year ago
parent 2cf6d2fd3e
commit 081afbecf0

@ -0,0 +1,264 @@
namespace Rs.MotionPlat
{
partial class CommunicationFrm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

@ -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) )
{
}
}
}
}

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="timer2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>107, 17</value>
</metadata>
<metadata name="timer3.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>197, 17</value>
</metadata>
<metadata name="timer4.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>287, 17</value>
</metadata>
<metadata name="timer5.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>377, 17</value>
</metadata>
<metadata name="timer6.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>467, 17</value>
</metadata>
</root>

@ -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;
}
}

@ -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();

@ -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<string> logs = new ConcurrentQueue<string>();
@ -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);
// }
// }
// });
//}
/// <summary>
/// 检测是否需要打印日志
/// </summary>
/// <returns></returns>
private bool CheckPrintLog()
{
return true;
switch (Index)
{
case 1:

File diff suppressed because it is too large Load Diff

@ -150,6 +150,12 @@
<Compile Include="Commom\ParameterInitAttribute.cs" />
<Compile Include="Commom\TrayRunPointManager.cs" />
<Compile Include="Commom\UpCameraHelper.cs" />
<Compile Include="CommunicationFrm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="CommunicationFrm.Designer.cs">
<DependentUpon>CommunicationFrm.cs</DependentUpon>
</Compile>
<Compile Include="Data\DataRecords.cs">
<SubType>Form</SubType>
</Compile>
@ -486,6 +492,9 @@
<EmbeddedResource Include="CalibrationForm.resx">
<DependentUpon>CalibrationForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="CommunicationFrm.resx">
<DependentUpon>CommunicationFrm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ConfigForm.resx">
<DependentUpon>ConfigForm.cs</DependentUpon>
</EmbeddedResource>

@ -1770,6 +1770,9 @@
<data name="cboxPrintTC6Communicate.Text" xml:space="preserve">
<value>TC6通信日志</value>
</data>
<data name="cboxPrintTC6Communicate.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;cboxPrintTC6Communicate.Name" xml:space="preserve">
<value>cboxPrintTC6Communicate</value>
</data>
@ -1800,6 +1803,9 @@
<data name="cboxPrintTC3Communicate.Text" xml:space="preserve">
<value>TC3通信日志</value>
</data>
<data name="cboxPrintTC3Communicate.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;cboxPrintTC3Communicate.Name" xml:space="preserve">
<value>cboxPrintTC3Communicate</value>
</data>
@ -1830,6 +1836,9 @@
<data name="cboxPrintTC5Communicate.Text" xml:space="preserve">
<value>TC5通信日志</value>
</data>
<data name="cboxPrintTC5Communicate.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;cboxPrintTC5Communicate.Name" xml:space="preserve">
<value>cboxPrintTC5Communicate</value>
</data>
@ -1860,6 +1869,9 @@
<data name="cboxPrintTC2Communicate.Text" xml:space="preserve">
<value>TC2通信日志</value>
</data>
<data name="cboxPrintTC2Communicate.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;cboxPrintTC2Communicate.Name" xml:space="preserve">
<value>cboxPrintTC2Communicate</value>
</data>
@ -1890,6 +1902,9 @@
<data name="cboxPrintTC4Communicate.Text" xml:space="preserve">
<value>TC4通信日志</value>
</data>
<data name="cboxPrintTC4Communicate.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;cboxPrintTC4Communicate.Name" xml:space="preserve">
<value>cboxPrintTC4Communicate</value>
</data>
@ -1920,6 +1935,9 @@
<data name="cboxPrintTC1Communicate.Text" xml:space="preserve">
<value>TC1通信日志</value>
</data>
<data name="cboxPrintTC1Communicate.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;cboxPrintTC1Communicate.Name" xml:space="preserve">
<value>cboxPrintTC1Communicate</value>
</data>
@ -2668,6 +2686,6 @@
<value>CommonConfig</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>Rs.MotionPlat.BaseForm, Rs.MotionPlat, Version=1.20.24.8, Culture=neutral, PublicKeyToken=null</value>
<value>Rs.MotionPlat.BaseForm, Rs.MotionPlat, Version=1.20.24.9, Culture=neutral, PublicKeyToken=null</value>
</data>
</root>
Loading…
Cancel
Save