版本升级至1.0.0.2,增加流量版本日志记录字段平衡流量(大漏泄漏量),测试流量(泄漏量)

This commit is contained in:
jfp
2025-09-30 11:49:56 +08:00
parent 9b861a13eb
commit 1ec079a04f
6 changed files with 238 additions and 230 deletions

View File

@@ -397,7 +397,7 @@
// //
this.MachineStatus.AutoSize = true; this.MachineStatus.AutoSize = true;
this.MachineStatus.Font = new System.Drawing.Font("宋体", 40F); this.MachineStatus.Font = new System.Drawing.Font("宋体", 40F);
this.MachineStatus.Location = new System.Drawing.Point(591, 104); this.MachineStatus.Location = new System.Drawing.Point(626, 104);
this.MachineStatus.Name = "MachineStatus"; this.MachineStatus.Name = "MachineStatus";
this.MachineStatus.Size = new System.Drawing.Size(185, 54); this.MachineStatus.Size = new System.Drawing.Size(185, 54);
this.MachineStatus.TabIndex = 47; this.MachineStatus.TabIndex = 47;
@@ -407,7 +407,7 @@
// //
this.Tlight.AutoSize = true; this.Tlight.AutoSize = true;
this.Tlight.Font = new System.Drawing.Font("宋体", 80F); this.Tlight.Font = new System.Drawing.Font("宋体", 80F);
this.Tlight.Location = new System.Drawing.Point(429, 108); this.Tlight.Location = new System.Drawing.Point(464, 108);
this.Tlight.Name = "Tlight"; this.Tlight.Name = "Tlight";
this.Tlight.Size = new System.Drawing.Size(153, 107); this.Tlight.Size = new System.Drawing.Size(153, 107);
this.Tlight.TabIndex = 42; this.Tlight.TabIndex = 42;
@@ -427,7 +427,7 @@
// //
this.label33.AutoSize = true; this.label33.AutoSize = true;
this.label33.Font = new System.Drawing.Font("宋体", 18F); this.label33.Font = new System.Drawing.Font("宋体", 18F);
this.label33.Location = new System.Drawing.Point(416, 72); this.label33.Location = new System.Drawing.Point(451, 72);
this.label33.Name = "label33"; this.label33.Name = "label33";
this.label33.Size = new System.Drawing.Size(130, 24); this.label33.Size = new System.Drawing.Size(130, 24);
this.label33.TabIndex = 85; this.label33.TabIndex = 85;
@@ -458,7 +458,7 @@
// //
this.label32.AutoSize = true; this.label32.AutoSize = true;
this.label32.Font = new System.Drawing.Font("宋体", 18F); this.label32.Font = new System.Drawing.Font("宋体", 18F);
this.label32.Location = new System.Drawing.Point(596, 72); this.label32.Location = new System.Drawing.Point(631, 72);
this.label32.Name = "label32"; this.label32.Name = "label32";
this.label32.Size = new System.Drawing.Size(130, 24); this.label32.Size = new System.Drawing.Size(130, 24);
this.label32.TabIndex = 84; this.label32.TabIndex = 84;
@@ -698,7 +698,7 @@
// //
this.MESStatus.AutoSize = true; this.MESStatus.AutoSize = true;
this.MESStatus.Font = new System.Drawing.Font("宋体", 40F); this.MESStatus.Font = new System.Drawing.Font("宋体", 40F);
this.MESStatus.Location = new System.Drawing.Point(596, 212); this.MESStatus.Location = new System.Drawing.Point(631, 212);
this.MESStatus.Name = "MESStatus"; this.MESStatus.Name = "MESStatus";
this.MESStatus.Size = new System.Drawing.Size(131, 54); this.MESStatus.Size = new System.Drawing.Size(131, 54);
this.MESStatus.TabIndex = 135; this.MESStatus.TabIndex = 135;
@@ -708,7 +708,7 @@
// //
this.label7.AutoSize = true; this.label7.AutoSize = true;
this.label7.Font = new System.Drawing.Font("宋体", 18F); this.label7.Font = new System.Drawing.Font("宋体", 18F);
this.label7.Location = new System.Drawing.Point(596, 182); this.label7.Location = new System.Drawing.Point(631, 182);
this.label7.Name = "label7"; this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(118, 24); this.label7.Size = new System.Drawing.Size(118, 24);
this.label7.TabIndex = 136; this.label7.TabIndex = 136;
@@ -717,20 +717,20 @@
// LeakPressure // LeakPressure
// //
this.LeakPressure.AutoSize = true; this.LeakPressure.AutoSize = true;
this.LeakPressure.Font = new System.Drawing.Font("宋体", 36F); this.LeakPressure.Font = new System.Drawing.Font("宋体", 34F);
this.LeakPressure.Location = new System.Drawing.Point(191, 100); this.LeakPressure.Location = new System.Drawing.Point(191, 100);
this.LeakPressure.Name = "LeakPressure"; this.LeakPressure.Name = "LeakPressure";
this.LeakPressure.Size = new System.Drawing.Size(212, 48); this.LeakPressure.Size = new System.Drawing.Size(204, 46);
this.LeakPressure.TabIndex = 137; this.LeakPressure.TabIndex = 137;
this.LeakPressure.Text = "11111111"; this.LeakPressure.Text = "11111111";
// //
// Leak // Leak
// //
this.Leak.AutoSize = true; this.Leak.AutoSize = true;
this.Leak.Font = new System.Drawing.Font("宋体", 36F); this.Leak.Font = new System.Drawing.Font("宋体", 34F);
this.Leak.Location = new System.Drawing.Point(191, 259); this.Leak.Location = new System.Drawing.Point(191, 259);
this.Leak.Name = "Leak"; this.Leak.Name = "Leak";
this.Leak.Size = new System.Drawing.Size(212, 48); this.Leak.Size = new System.Drawing.Size(204, 46);
this.Leak.TabIndex = 138; this.Leak.TabIndex = 138;
this.Leak.Text = "11111111"; this.Leak.Text = "11111111";
// //
@@ -1577,10 +1577,10 @@
// bigLeak // bigLeak
// //
this.bigLeak.AutoSize = true; this.bigLeak.AutoSize = true;
this.bigLeak.Font = new System.Drawing.Font("宋体", 36F); this.bigLeak.Font = new System.Drawing.Font("宋体", 34F);
this.bigLeak.Location = new System.Drawing.Point(192, 180); this.bigLeak.Location = new System.Drawing.Point(192, 180);
this.bigLeak.Name = "bigLeak"; this.bigLeak.Name = "bigLeak";
this.bigLeak.Size = new System.Drawing.Size(212, 48); this.bigLeak.Size = new System.Drawing.Size(204, 46);
this.bigLeak.TabIndex = 152; this.bigLeak.TabIndex = 152;
this.bigLeak.Text = "11111111"; this.bigLeak.Text = "11111111";
// //
@@ -1648,7 +1648,7 @@
this.Controls.Add(this.ReceiveText); this.Controls.Add(this.ReceiveText);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Form1"; this.Name = "Form1";
this.Text = "LL-28_20250923"; this.Text = "LL-28_20250930";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load); this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.DataGridView1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.DataGridView1)).EndInit();

View File

@@ -24,6 +24,8 @@ using Timer = System.Windows.Forms.Timer;
using System.Net; using System.Net;
using static System.Windows.Forms.VisualStyles.VisualStyleElement; using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using Org.BouncyCastle.Utilities.Net; using Org.BouncyCastle.Utilities.Net;
using System.Collections.Generic;
using System.Net.NetworkInformation;
namespace C_Windows_1 namespace C_Windows_1
{ {
@@ -66,6 +68,7 @@ namespace C_Windows_1
string[] strPressureUnit = { "Pa", "KPa", "MPa", "bar","Psi", "kg/cm^2", "atm", "mmHg" }; string[] strPressureUnit = { "Pa", "KPa", "MPa", "bar","Psi", "kg/cm^2", "atm", "mmHg" };
string[] strListLeakUnit = { "Pa", "KPa", "mbar", "atm", "sccm", "ccm3/s", "Pa/s" }; string[] strListLeakUnit = { "Pa", "KPa", "mbar", "atm", "sccm", "ccm3/s", "Pa/s" };
string[] strListStatus = { "待机中", "准备", "充气", "平衡", "检测", "排气"};
public Form1() public Form1()
{ {
f1 = this; f1 = this;
@@ -335,37 +338,18 @@ namespace C_Windows_1
switch (workstation) switch (workstation)
{ {
case (int)yiqi.start: case (int)yiqi.start:
operateResult22 = modbusClient.Write("0", true); operateResult22 = modbusClient.Write("0", true);
//MachineStatus.Text = "开始测试";
//Console.WriteLine("当前是启动状态");
//if (operateResult22.IsSuccess)
//{
// operateResult22 = CH1.Write("85", false);
workstation = (int)yiqi.prepare; workstation = (int)yiqi.prepare;
//}
break; break;
//return workstation;
case (int)yiqi.rst: case (int)yiqi.rst:
//byte[] data2 = new byte[] { 0xff, 0x00 };
operateResult21 = modbusClient.Write("1", true); operateResult21 = modbusClient.Write("1", true);
//Console.WriteLine("当前是复位状态");
////点击复位进度条置为0
progressBar2.Value = 0; progressBar2.Value = 0;
//MachineStatus.Text = "复位";
//LeakPressure.Text = "";
//Leak.Text = "";
//label2.Text = "";
//Tlight.Text = "";
if (operateResult21.IsSuccess) if (operateResult21.IsSuccess)
{ {
workstation = (int)yiqi.standby; workstation = (int)yiqi.standby;
} }
break; break;
@@ -375,12 +359,7 @@ namespace C_Windows_1
Tlight.Text = ""; Tlight.Text = "";
if (operateResult21.IsSuccess == true) if (operateResult21.IsSuccess == true)
{ {
int aaa;
// grovalue = 100 / ((ReadData[1006] / 10) + (ReadData[1007] / 10) + (ReadData[1008] / 10) + (ReadData[1009] / 10)) ;
//grovalueone = (float)(grovalue * 0.0003);
//aaa = ReadData[1006] + ReadData[1007] + ReadData[1008] + ReadData[1009];
progressBar2.Value = 0; progressBar2.Value = 0;
//progressBar2.Maximum = aaa;
Booltomath(2, ReadData); Booltomath(2, ReadData);
if(ReadData[2]!=0) if(ReadData[2]!=0)
@@ -391,8 +370,6 @@ namespace C_Windows_1
{ {
workstation = (int)yiqi.standby; workstation = (int)yiqi.standby;
} }
} }
break; break;
@@ -406,29 +383,14 @@ namespace C_Windows_1
progressvalue += 2; progressvalue += 2;
Modbusread(1013, 16, ReadData);//各项参数 Modbusread(1013, 16, ReadData);//各项参数
Modbusread(1034, 26, ReadData); Modbusread(1034, 26, ReadData);
//Modbusread(25, 24, ReadData);
//test(ReadData);
//int ba = progressBar2.Value + 2;
if (progressvalue >= progressBar2.Maximum) if (progressvalue >= progressBar2.Maximum)
progressvalue = progressBar2.Maximum; progressvalue = progressBar2.Maximum;
progressBar2.Value = progressvalue; progressBar2.Value = progressvalue;
//if (!(grovalue > 99.8))
//{
// grovalue += grovalueone;
// progressBar2.Value = (int)grovalue;
//}
//else
//{
// progressBar2.Maximum = (int)grovalue;
//}
if (ReadData[2] == 0 && (ReadData[1041] == 1 || ReadData[1041] == 2))//当仪器状态位不为0且有结果时 if (ReadData[2] == 0 && (ReadData[1041] == 1 || ReadData[1041] == 2))//当仪器状态位不为0且有结果时
{ {
workstation = (int)yiqi.finish; workstation = (int)yiqi.finish;
//return workstation;
} }
if (ReadData[2] == 0) if (ReadData[2] == 0)
{ {
@@ -444,11 +406,7 @@ namespace C_Windows_1
workstation = (int)yiqi.standby; workstation = (int)yiqi.standby;
} }
} }
break; break;
case (int)yiqi.standby://读取仪器是否启动 case (int)yiqi.standby://读取仪器是否启动
Booltomath(2, ReadData); Booltomath(2, ReadData);
Modbusread(1041, 1, ReadData); Modbusread(1041, 1, ReadData);
@@ -457,9 +415,6 @@ namespace C_Windows_1
{ {
workstation = (int)yiqi.prepare; workstation = (int)yiqi.prepare;
} }
break; break;
@@ -467,31 +422,17 @@ namespace C_Windows_1
case (int)yiqi.finish: case (int)yiqi.finish:
Modbusread(1034, 26, ReadData); Modbusread(1034, 26, ReadData);
progressBar2.Value = progressBar2.Maximum; progressBar2.Value = progressBar2.Maximum;
//timerbar.Stop();
DataGridView1.Invoke(new System.Action(Display)); DataGridView1.Invoke(new System.Action(Display));
CreateFile(); CreateFile();
//Passzong.Text = ChanPass.ToString();
//Sunzong.Text = ChanSum.ToString();
//string path = System.Environment.CurrentDirectory + "\\Config\\Config.ini";
//ConfigINI config = new ConfigINI(path);
//config.IniWriteValue("Config", "Passzong", Passzong.Text);
//config.IniWriteValue("Config", "Sunzong", Sunzong.Text);
Code.Clear(); Code.Clear();
progressvalue = 0; progressvalue = 0;
workstation = (int)yiqi.standby; workstation = (int)yiqi.standby;
// return workstation;
break; break;
default: default:
break; break;
//return 0;break;
} }
//}
// )));
} }
@@ -500,9 +441,6 @@ namespace C_Windows_1
switch (workstation) switch (workstation)
{ {
case (int)yiqi.start: case (int)yiqi.start:
//MachineStatus.Text = "开始测试";
break; break;
case (int)yiqi.rst: case (int)yiqi.rst:
MachineStatus.Text = "复位"; MachineStatus.Text = "复位";
@@ -526,7 +464,7 @@ namespace C_Windows_1
break; break;
case (int)yiqi.test: case (int)yiqi.test:
MachineStatus.Text = "测试中"; MachineStatus.Text = strListStatus[ReadData[1034]];
PressureUnit.Text = strPressureUnit[ReadData[1027]]; PressureUnit.Text = strPressureUnit[ReadData[1027]];
LeakUnit.Text = strListLeakUnit[ReadData[1028]]; LeakUnit.Text = strListLeakUnit[ReadData[1028]];
if (ReadData[1041] == 2) if (ReadData[1041] == 2)
@@ -671,6 +609,26 @@ namespace C_Windows_1
{ {
label41.Text = "平衡流量:"; label41.Text = "平衡流量:";
label31.Text = "测试流量:"; label31.Text = "测试流量:";
DataGridView1.Columns.Clear();
DataGridView1.Columns.Add("Column1", "时间");
DataGridView1.Columns.Add("Column2", "条形码");
DataGridView1.Columns.Add("Column3", "充气时间");
DataGridView1.Columns.Add("Column4", "平衡时间");
DataGridView1.Columns.Add("Column5", "检测时间");
DataGridView1.Columns.Add("Column6", "排气时间");
DataGridView1.Columns.Add("Column7", "充气压力上限");
DataGridView1.Columns.Add("Column8", "充气压力下限");
DataGridView1.Columns.Add("Column9", "平衡压差上限");
DataGridView1.Columns.Add("Column10", "平衡压差下限");
DataGridView1.Columns.Add("Column11", "泄漏量上限");
DataGridView1.Columns.Add("Column12", "泄漏量下限");
DataGridView1.Columns.Add("Column13", "测试结果");
DataGridView1.Columns.Add("Column14", "测试压力");
DataGridView1.Columns.Add("Column15", "压力单位");
DataGridView1.Columns.Add("Column16", "平衡流量");
DataGridView1.Columns.Add("Column17", "测试流量");
DataGridView1.Columns.Add("Column18", "泄漏量单位");
} }
Task.Run(() => Task.Run(() =>
@@ -702,22 +660,9 @@ namespace C_Windows_1
machine2();//仪器读取线程 machine2();//仪器读取线程
MachineDisplay();//仪器显示线程 MachineDisplay();//仪器显示线程
// //if (MachineStatus.Text == "待机中" && connect.IsSuccess)
// //{
// // Thread.Sleep(3000);
// // workstation = (int)yiqi.start;
// // MachineStatus.Text = "";
// //}
} }
} }
});
}
);
} }
@@ -739,106 +684,113 @@ namespace C_Windows_1
Thread UDPlisten; Thread UDPlisten;
string UDPRecvData; string UDPRecvData;
//点击“连接串口”按钮,连接串口 //点击“连接串口”按钮,连接串口
private static int BROADCAST_PORT = 9999;
static List<System.Net.IPAddress> GetActiveNICsIP()
{
List<System.Net.IPAddress> ips = new List<System.Net.IPAddress>();
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
{
if (nic.OperationalStatus == OperationalStatus.Up &&
!nic.Description.Contains("Loopback"))
{
foreach (UnicastIPAddressInformation ip in nic.GetIPProperties().UnicastAddresses)
{
if (ip.Address.AddressFamily == AddressFamily.InterNetwork)
{
ips.Add(ip.Address);
}
}
}
}
return ips;
}
// 为每个网卡创建独立接收线程
// private static List<Thread> receiveThreads = new List<Thread>();
private void SendBroadcast(System.Net.IPAddress localIP, byte[] data)
{
using (Socket sender = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp))
{
//发送数据
try
{
sender.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.Broadcast, 1);
sender.Bind(new IPEndPoint(localIP, 0));
IPEndPoint broadcastEP = new IPEndPoint(System.Net.IPAddress.Broadcast, BROADCAST_PORT);
sender.SendTo(data, broadcastEP);
Console.WriteLine($"已通过 {localIP} 发送广播");
//FormMain.form.wa.InsertWarningData(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "-", "发送广播");
}
catch (Exception ex)
{
Console.WriteLine($"{localIP} 发送失败: {ex.Message}");
}
//接受数据
byte[] buffer = new byte[1024];
sender.ReceiveTimeout = 2000;
while (true)
{
try
{
EndPoint remoteEP = new IPEndPoint(System.Net.IPAddress.Any, 0);
int bytesRead = sender.ReceiveFrom(buffer, ref remoteEP);
string message = System.Text.Encoding.UTF8.GetString(buffer, 0, bytesRead);
Console.WriteLine($"[{localIP}] 接收到来自 {remoteEP}: {message}");
Invoke(new Action(() =>
{
UDPResults.Items.Add(message); // 将接收到的消息添加到 ComboBox
UDPResults.SelectedIndex = UDPResults.Items.Count - 1;
}));
}
catch (SocketException)
{
break;/* 超时处理 */
}
catch (Exception ex)
{
Console.WriteLine($"[{localIP}] 接收错误: {ex.Message}");
}
}
}
}
private void BtnCon1_Click(object sender, EventArgs e) private void BtnCon1_Click(object sender, EventArgs e)
{ {
UDPResults.Items.Clear(); UDPResults.Items.Clear();
byte[] data = Encoding.ASCII.GetBytes("hello,udp server"); byte[] data = Encoding.ASCII.GetBytes("hello,udp server");
string localip=GetLocalIPAddress();
// 查找第三个 '.' 符号的位置
int firstDot = localip.IndexOf('.');
int secondDot = localip.IndexOf('.', firstDot + 1);
int thirdDot = localip.IndexOf('.', secondDot + 1);
// 截取到第三个 '.' 符号
localip = thirdDot != -1
? localip.Substring(0, thirdDot + 1)
: localip;
localip = localip/*.Substring(0, 10)*/ + "255";
//Code.Text = localip;
ip = System.Net.IPAddress.Parse(localip);
// 获本机IP频段广播到 .255
IPEndPoint endPoint = new IPEndPoint(ip, Port);
//try
//{
// // 发送广播
// udpClient.Send(data, data.Length, endPoint);
// isListening = true;
// // 开始监听返回消息
// udpClient.BeginReceive(ReceiveCallback, null);
// timeoutTimer.Start();
//}
//catch (Exception ex)
//{
// MessageBox.Show(ex.Message);
//}
sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
sock.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.Broadcast, 1);
UDPOverTime.Interval = 3000;
UDPOverTime.Start();
isListening = true;
UDPlisten = new Thread(UDP_Listening);
UDPlisten.Start();
sock.SendTo(data, endPoint);
//UDPRead.Interval = 3000;
//UDPRead.Start();
}
private void UDP_Listening()
{
while (isListening)
{
Invoke(new System.Action(() =>
{
UDPOverTime.Stop();
}
));
byte[] data = new byte[1024];
int recv = sock.Receive(data);
string RecvData = Encoding.ASCII.GetString(data, 0, recv);
Invoke(new Action(() =>
{
UDPResults.Items.Add(RecvData); // 将接收到的消息添加到 ComboBox
UDPResults.SelectedIndex = UDPResults.Items.Count - 1;
}));
//UDPRecvData += RecvData;
//UDPRecvData += "\n";
}
}
private void ReceiveCallback(IAsyncResult ar)
{
try try
{ {
if (!isListening) return; UDPRecvData = "";
// 获取所有可用网卡IP
IPEndPoint remoteEndPoint = new IPEndPoint(ip, Port); List<System.Net.IPAddress> localIPs = GetActiveNICsIP();
byte[] receivedData = udpClient.EndReceive(ar, ref remoteEndPoint); if (localIPs.Count == 0)
string receivedMessage = Encoding.ASCII.GetString(receivedData);
// 更新 UI 线程中的 ComboBox
Invoke(new Action(() =>
{ {
UDPResults.Items.Add(receivedMessage); // 将接收到的消息添加到 ComboBox Console.WriteLine("No active network interfaces found");
UDPResults.SelectedIndex = UDPResults.Items.Count - 1; }
})); data = Encoding.ASCII.GetBytes("hello,udp server");
// 继续接收下一个数据包 // 发送广播
if (isListening) foreach (System.Net.IPAddress localIP in localIPs)
{ {
udpClient.BeginReceive(ReceiveCallback, null); Thread t = new Thread(() => SendBroadcast(localIP, data));
t.IsBackground = true;
t.Start();
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message); Console.WriteLine("UDP广播:" + ex.Message);
} }
} }
//关闭串口 //关闭串口
private void BtnBreak_Click(object sender, EventArgs e) private void BtnBreak_Click(object sender, EventArgs e)
{ {
@@ -1161,7 +1113,39 @@ namespace C_Windows_1
{ {
fileName = path.Text + "\\" + file + ".txt"; fileName = path.Text + "\\" + file + ".txt";
} }
string str1 = "时间 " + DateTime.Now + " 条形码 " + Code.Text + " 充气时间 " + FullTime.Text + "s" + " 平衡时间 " + BalanTime.Text + "s" + " 检测时间 " + TestTime1.Text + "s" + " 排气时间 " + ExhaustTime.Text + "s" + " 充气压力上限 " + FPtoplimit.Text + PressureUnit.Text + " 充气压力下限 " + FPlowlimit.Text + PressureUnit.Text + " 大漏压差上限 " + BLeakTPre.Text + LeakUnit.Text + " 大漏压差下限 " + BLeakLPre.Text + LeakUnit.Text + " 泄漏量上限 " + Leaktoplimit.Text + LeakUnit.Text + " 泄漏量下限 " + Leaklowlimit.Text + LeakUnit.Text + " 测试结果 " + Tlight.Text + " 测试压力 " + DLeakPressure + " 压力单位 " + PressureUnit.Text + " 泄漏量 " + DLeak + " 泄漏量单位 " + LeakUnit.Text + " \n"; string str1 = "";
if (liuliangVersion == 1)
{
str1 = "时间 " + DateTime.Now + " 条形码 " + Code.Text + " 充气时间 " + ReadData[1006] / 10.0 + "s"
+ " 平衡时间 " + ReadData[1007] / 10.0 + "s" + " 检测时间 " + ReadData[1008] / 10.0 + "s"
+ " 排气时间 " + ReadData[1009] / 10.0 + "s" + " 充气压力上限 "
+ TwoUInt16ToFloat(ReadData[1014], ReadData[1013]).ToString()
+ PressureUnit.Text + " 充气压力下限 " + TwoUInt16ToFloat(ReadData[1016], ReadData[1015]).ToString() + PressureUnit.Text
+ " 大漏压差上限 " + TwoUInt16ToFloat(ReadData[1018], ReadData[1017]).ToString() + LeakUnit.Text
+ " 大漏压差下限 " + TwoUInt16ToFloat(ReadData[1020], ReadData[1019]).ToString() + LeakUnit.Text
+ " 泄漏量上限 " + TwoUInt16ToFloat(ReadData[1022], ReadData[1021]).ToString() + LeakUnit.Text
+ " 泄漏量下限 " + TwoUInt16ToFloat(ReadData[1024], ReadData[1023]).ToString() + LeakUnit.Text
+ " 测试结果 " + Tlight.Text + " 测试压力 " + DLeakPressure
+ " 压力单位 " + PressureUnit.Text + "平衡流量" + TwoUInt16ToFloat(ReadData[1036], ReadData[1035]).ToString()
+ " 测试流量 " + TwoUInt16ToFloat(ReadData[1039], ReadData[1038]).ToString()
+ " 泄漏量单位 " + LeakUnit.Text + " \n";
}
else
{
str1 = "时间 " + DateTime.Now + " 条形码 " + Code.Text + " 充气时间 " + ReadData[1006] / 10.0 + "s"
+ " 平衡时间 " + ReadData[1007] / 10.0 + "s" + " 检测时间 " + ReadData[1008] / 10.0 + "s"
+ " 排气时间 " + ReadData[1009] / 10.0 + "s" + " 充气压力上限 "
+ TwoUInt16ToFloat(ReadData[1014], ReadData[1013]).ToString()
+ PressureUnit.Text + " 充气压力下限 " + TwoUInt16ToFloat(ReadData[1016], ReadData[1015]).ToString() + PressureUnit.Text
+ " 大漏压差上限 " + TwoUInt16ToFloat(ReadData[1018], ReadData[1017]).ToString() + LeakUnit.Text
+ " 大漏压差下限 " + TwoUInt16ToFloat(ReadData[1020], ReadData[1019]).ToString() + LeakUnit.Text
+ " 泄漏量上限 " + TwoUInt16ToFloat(ReadData[1022], ReadData[1021]).ToString() + LeakUnit.Text
+ " 泄漏量下限 " + TwoUInt16ToFloat(ReadData[1024], ReadData[1023]).ToString() + LeakUnit.Text
+ " 测试结果 " + Tlight.Text + " 测试压力 " + DLeakPressure
+ " 压力单位 " + PressureUnit.Text
+ " 泄漏量 " + TwoUInt16ToFloat(ReadData[1039], ReadData[1038]).ToString()
+ " 泄漏量单位 " + LeakUnit.Text + " \n";
}
System.IO.File.AppendAllText(fileName, str1); System.IO.File.AppendAllText(fileName, str1);
} }
@@ -1253,7 +1237,14 @@ namespace C_Windows_1
if (File.Exists(fileName) == false) if (File.Exists(fileName) == false)
{ {
StreamWriter fileWriter1 = new StreamWriter(fileName, true, Encoding.UTF8); StreamWriter fileWriter1 = new StreamWriter(fileName, true, Encoding.UTF8);
if (liuliangVersion == 1)
{
fileWriter1.Write("时间,条形码,充气时间,平衡时间,检测时间,排气时间,充气压力上限,充气压力下限,大漏压差上限,大漏压差下限,泄漏量上限,泄漏量下限,测试结果,测试压力,压力单位,测试流量,平衡流量,泄漏量单位" + "\r\n");
}
else
{
fileWriter1.Write("时间,条形码,充气时间,平衡时间,检测时间,排气时间,充气压力上限,充气压力下限,大漏压差上限,大漏压差下限,泄漏量上限,泄漏量下限,测试结果,测试压力,压力单位,泄漏量,泄漏量单位" + "\r\n"); fileWriter1.Write("时间,条形码,充气时间,平衡时间,检测时间,排气时间,充气压力上限,充气压力下限,大漏压差上限,大漏压差下限,泄漏量上限,泄漏量下限,测试结果,测试压力,压力单位,泄漏量,泄漏量单位" + "\r\n");
}
fileWriter1.Flush(); fileWriter1.Flush();
fileWriter1.Close(); fileWriter1.Close();
} }
@@ -1262,21 +1253,25 @@ namespace C_Windows_1
string nowdate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); string nowdate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
fileWriter.Write(nowdate + "," + Code.Text + ","); fileWriter.Write(nowdate + "," + Code.Text + ",");
fileWriter.Write(FullTime.Text + "s" + ","); fileWriter.Write(ReadData[1006] / 10.0 + "s" + ",");
fileWriter.Write(BalanTime.Text + "s" + ","); fileWriter.Write(ReadData[1007] / 10.0 + "s" + ",");
fileWriter.Write(TestTime1.Text + "s" + ","); fileWriter.Write(ReadData[1008] / 10.0 + "s" + ",");
fileWriter.Write(ExhaustTime.Text + "s" + ","); fileWriter.Write(ReadData[1009] / 10.0 + "s" + ",");
fileWriter.Write(FPtoplimit.Text + PUnit.Text + ","); fileWriter.Write(TwoUInt16ToFloat(ReadData[1014], ReadData[1013]).ToString() + PUnit.Text + ",");
fileWriter.Write(FPlowlimit.Text + PUnit.Text + ","); fileWriter.Write(TwoUInt16ToFloat(ReadData[1016], ReadData[1015]).ToString() + PUnit.Text + ",");
fileWriter.Write(BLeakTPre.Text + PUnit.Text + ","); fileWriter.Write(TwoUInt16ToFloat(ReadData[1018], ReadData[1017]).ToString() + PUnit.Text + ",");
fileWriter.Write(BLeakLPre.Text + PUnit.Text + ","); fileWriter.Write(TwoUInt16ToFloat(ReadData[1020], ReadData[1019]).ToString() + PUnit.Text + ",");
fileWriter.Write(Leaktoplimit.Text + LUnit.Text + ","); fileWriter.Write(TwoUInt16ToFloat(ReadData[1022], ReadData[1021]).ToString() + LUnit.Text + ",");
fileWriter.Write(Leaklowlimit.Text + LUnit.Text + ","); fileWriter.Write(TwoUInt16ToFloat(ReadData[1024], ReadData[1023]).ToString() + LUnit.Text + ",");
fileWriter.Write(Tlight.Text + ","); fileWriter.Write(Tlight.Text + ",");
fileWriter.Write(DLeakPressure + ","); fileWriter.Write(DLeakPressure + ",");
fileWriter.Write(PUnit.Text + ","); fileWriter.Write(PressureUnit.Text + ",");
fileWriter.Write(DLeak + ","); if (liuliangVersion == 1)
fileWriter.Write(LUnit.Text + "\n"); {
fileWriter.Write(TwoUInt16ToFloat(ReadData[1036], ReadData[1035]).ToString() + ",");
}
fileWriter.Write(TwoUInt16ToFloat(ReadData[1039], ReadData[1038]).ToString() + ",");
fileWriter.Write(LeakUnit.Text + "\n");
fileWriter.Flush(); fileWriter.Flush();
fileWriter.Close(); fileWriter.Close();
@@ -1324,18 +1319,18 @@ namespace C_Windows_1
{ {
AddExcel(); AddExcel();
} }
//if (ChkTXT.Checked) if (ChkTXT.Checked)
//{ {
// AddTXT(); AddTXT();
//} }
if (ChkSql.Checked) if (ChkSql.Checked)
{ {
AddDatebase(); AddDatebase();
} }
//if (ChkCSV.Checked) if (ChkCSV.Checked)
//{ {
// AddCSV(); AddCSV();
//} }
if (ChkMES.Checked && Code.TextLength > 0) if (ChkMES.Checked && Code.TextLength > 0)
{ {
ADDMES(); ADDMES();
@@ -1344,12 +1339,27 @@ namespace C_Windows_1
//在界面显示数据 //在界面显示数据
private void Display() private void Display()
{
if (liuliangVersion == 1) //流量版本
{ {
DataGridView1.Rows.Add( DataGridView1.Rows.Add(
DateTime.Now.ToString(), Code.Text, ReadData[1006] / 10.0 + "s", ReadData[1007] / 10.0 + "s", ReadData[1008] / 10.0 + "s", ReadData[1009] / 10.0 + "s", DateTime.Now.ToString(), Code.Text, ReadData[1006] / 10.0 + "s", ReadData[1007] / 10.0 + "s", ReadData[1008] / 10.0 + "s", ReadData[1009] / 10.0 + "s",
TwoUInt16ToFloat(ReadData[1014], ReadData[1013]).ToString(), TwoUInt16ToFloat(ReadData[1016], ReadData[1015]).ToString(), TwoUInt16ToFloat(ReadData[1014], ReadData[1013]).ToString(), TwoUInt16ToFloat(ReadData[1016], ReadData[1015]).ToString(),
TwoUInt16ToFloat(ReadData[1018], ReadData[1017]).ToString(), TwoUInt16ToFloat(ReadData[1020], ReadData[1019]).ToString(), TwoUInt16ToFloat(ReadData[1022], ReadData[1021]).ToString(), TwoUInt16ToFloat(ReadData[1024], ReadData[1023]).ToString(), Tlight.Text, TwoUInt16ToFloat(ReadData[1018], ReadData[1017]).ToString(), TwoUInt16ToFloat(ReadData[1020], ReadData[1019]).ToString(),
TwoUInt16ToFloat(ReadData[1049], ReadData[1048]).ToString(), PressureUnit.Text, TwoUInt16ToFloat(ReadData[1039], ReadData[1038]).ToString(), LeakUnit.Text); TwoUInt16ToFloat(ReadData[1022], ReadData[1021]).ToString(), TwoUInt16ToFloat(ReadData[1024], ReadData[1023]).ToString(),
Tlight.Text, TwoUInt16ToFloat(ReadData[1049], ReadData[1048]).ToString(), PressureUnit.Text, TwoUInt16ToFloat(ReadData[1036], ReadData[1035]).ToString(),
TwoUInt16ToFloat(ReadData[1039], ReadData[1038]).ToString(), LeakUnit.Text);
}
else
{
DataGridView1.Rows.Add(
DateTime.Now.ToString(), Code.Text, ReadData[1006] / 10.0 + "s", ReadData[1007] / 10.0 + "s", ReadData[1008] / 10.0 + "s", ReadData[1009] / 10.0 + "s",
TwoUInt16ToFloat(ReadData[1014], ReadData[1013]).ToString(), TwoUInt16ToFloat(ReadData[1016], ReadData[1015]).ToString(),
TwoUInt16ToFloat(ReadData[1018], ReadData[1017]).ToString(), TwoUInt16ToFloat(ReadData[1020], ReadData[1019]).ToString(),
TwoUInt16ToFloat(ReadData[1022], ReadData[1021]).ToString(), TwoUInt16ToFloat(ReadData[1024], ReadData[1023]).ToString(),
Tlight.Text,TwoUInt16ToFloat(ReadData[1049], ReadData[1048]).ToString(), PressureUnit.Text,
TwoUInt16ToFloat(ReadData[1039], ReadData[1038]).ToString(), LeakUnit.Text);
}
} }
//条形码 //条形码
private void Code_TextChanged(object sender, EventArgs e) private void Code_TextChanged(object sender, EventArgs e)
@@ -1900,7 +1910,6 @@ namespace C_Windows_1
private void TCPconnect_Click(object sender, EventArgs e) private void TCPconnect_Click(object sender, EventArgs e)
{ {
//根据:符号分割站号和IP //根据:符号分割站号和IP
string[] parts = UDPResults.Text.Split(':'); string[] parts = UDPResults.Text.Split(':');
@@ -1915,8 +1924,7 @@ namespace C_Windows_1
modbusClient = new ModbusRtuOverTcp(ipAddress, 9999, Convert.ToByte(stationIP)); modbusClient = new ModbusRtuOverTcp(ipAddress, 9999, Convert.ToByte(stationIP));
//modbusClient.ConnectTimeOut = 1000; Thread.Sleep(100);
//modbusClient.ReceiveTimeOut = 1000;
if (modbusClient.ConnectServer().IsSuccess) if (modbusClient.ConnectServer().IsSuccess)
{ {
connectflag = 1; connectflag = 1;

View File

@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示: //通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.1")] [assembly: AssemblyVersion("1.0.0.2")]
[assembly: AssemblyFileVersion("1.0.0.1")] [assembly: AssemblyFileVersion("1.0.0.2")]

View File

@@ -61,7 +61,7 @@
this.ChkMES.Location = new System.Drawing.Point(309, 146); this.ChkMES.Location = new System.Drawing.Point(309, 146);
this.ChkMES.Margin = new System.Windows.Forms.Padding(5); this.ChkMES.Margin = new System.Windows.Forms.Padding(5);
this.ChkMES.Name = "ChkMES"; this.ChkMES.Name = "ChkMES";
this.ChkMES.Size = new System.Drawing.Size(98, 20); this.ChkMES.Size = new System.Drawing.Size(99, 20);
this.ChkMES.TabIndex = 106; this.ChkMES.TabIndex = 106;
this.ChkMES.Text = "导出到Mes"; this.ChkMES.Text = "导出到Mes";
this.ChkMES.UseVisualStyleBackColor = true; this.ChkMES.UseVisualStyleBackColor = true;
@@ -84,7 +84,7 @@
this.label35.Location = new System.Drawing.Point(15, 14); this.label35.Location = new System.Drawing.Point(15, 14);
this.label35.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0); this.label35.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.label35.Name = "label35"; this.label35.Name = "label35";
this.label35.Size = new System.Drawing.Size(39, 16); this.label35.Size = new System.Drawing.Size(40, 16);
this.label35.TabIndex = 105; this.label35.TabIndex = 105;
this.label35.Text = "路径"; this.label35.Text = "路径";
// //
@@ -92,10 +92,10 @@
// //
this.ChkExcel.AutoSize = true; this.ChkExcel.AutoSize = true;
this.ChkExcel.Font = new System.Drawing.Font("宋体", 12F); this.ChkExcel.Font = new System.Drawing.Font("宋体", 12F);
this.ChkExcel.Location = new System.Drawing.Point(156, 146); this.ChkExcel.Location = new System.Drawing.Point(156, 224);
this.ChkExcel.Margin = new System.Windows.Forms.Padding(5); this.ChkExcel.Margin = new System.Windows.Forms.Padding(5);
this.ChkExcel.Name = "ChkExcel"; this.ChkExcel.Name = "ChkExcel";
this.ChkExcel.Size = new System.Drawing.Size(114, 20); this.ChkExcel.Size = new System.Drawing.Size(115, 20);
this.ChkExcel.TabIndex = 102; this.ChkExcel.TabIndex = 102;
this.ChkExcel.Text = "导出到Excel"; this.ChkExcel.Text = "导出到Excel";
this.ChkExcel.UseVisualStyleBackColor = true; this.ChkExcel.UseVisualStyleBackColor = true;
@@ -104,14 +104,13 @@
// //
this.ChkTXT.AutoSize = true; this.ChkTXT.AutoSize = true;
this.ChkTXT.Font = new System.Drawing.Font("宋体", 12F); this.ChkTXT.Font = new System.Drawing.Font("宋体", 12F);
this.ChkTXT.Location = new System.Drawing.Point(14, 176); this.ChkTXT.Location = new System.Drawing.Point(154, 146);
this.ChkTXT.Margin = new System.Windows.Forms.Padding(5); this.ChkTXT.Margin = new System.Windows.Forms.Padding(5);
this.ChkTXT.Name = "ChkTXT"; this.ChkTXT.Name = "ChkTXT";
this.ChkTXT.Size = new System.Drawing.Size(98, 20); this.ChkTXT.Size = new System.Drawing.Size(99, 20);
this.ChkTXT.TabIndex = 103; this.ChkTXT.TabIndex = 103;
this.ChkTXT.Text = "导出到TXT"; this.ChkTXT.Text = "导出到TXT";
this.ChkTXT.UseVisualStyleBackColor = true; this.ChkTXT.UseVisualStyleBackColor = true;
this.ChkTXT.Visible = false;
// //
// path // path
// //
@@ -125,23 +124,25 @@
// //
this.ChkSql.AutoSize = true; this.ChkSql.AutoSize = true;
this.ChkSql.Font = new System.Drawing.Font("宋体", 12F); this.ChkSql.Font = new System.Drawing.Font("宋体", 12F);
this.ChkSql.Location = new System.Drawing.Point(156, 185); this.ChkSql.Location = new System.Drawing.Point(156, 264);
this.ChkSql.Margin = new System.Windows.Forms.Padding(5); this.ChkSql.Margin = new System.Windows.Forms.Padding(5);
this.ChkSql.Name = "ChkSql"; this.ChkSql.Name = "ChkSql";
this.ChkSql.Size = new System.Drawing.Size(146, 20); this.ChkSql.Size = new System.Drawing.Size(147, 20);
this.ChkSql.TabIndex = 104; this.ChkSql.TabIndex = 104;
this.ChkSql.Text = "导出到SqlServer"; this.ChkSql.Text = "导出到SqlServer";
this.ChkSql.UseVisualStyleBackColor = true; this.ChkSql.UseVisualStyleBackColor = true;
this.ChkSql.Visible = false;
// //
// BtnConSql // BtnConSql
// //
this.BtnConSql.Location = new System.Drawing.Point(135, 215); this.BtnConSql.Location = new System.Drawing.Point(135, 357);
this.BtnConSql.Margin = new System.Windows.Forms.Padding(5); this.BtnConSql.Margin = new System.Windows.Forms.Padding(5);
this.BtnConSql.Name = "BtnConSql"; this.BtnConSql.Name = "BtnConSql";
this.BtnConSql.Size = new System.Drawing.Size(151, 53); this.BtnConSql.Size = new System.Drawing.Size(151, 53);
this.BtnConSql.TabIndex = 101; this.BtnConSql.TabIndex = 101;
this.BtnConSql.Text = "Sql设置"; this.BtnConSql.Text = "Sql设置";
this.BtnConSql.UseVisualStyleBackColor = true; this.BtnConSql.UseVisualStyleBackColor = true;
this.BtnConSql.Visible = false;
this.BtnConSql.Click += new System.EventHandler(this.BtnConSql_Click); this.BtnConSql.Click += new System.EventHandler(this.BtnConSql_Click);
// //
// BtnConMES // BtnConMES
@@ -164,13 +165,12 @@
// //
this.ChkCSV.AutoSize = true; this.ChkCSV.AutoSize = true;
this.ChkCSV.Font = new System.Drawing.Font("宋体", 11F); this.ChkCSV.Font = new System.Drawing.Font("宋体", 11F);
this.ChkCSV.Location = new System.Drawing.Point(12, 204); this.ChkCSV.Location = new System.Drawing.Point(154, 188);
this.ChkCSV.Name = "ChkCSV"; this.ChkCSV.Name = "ChkCSV";
this.ChkCSV.Size = new System.Drawing.Size(95, 19); this.ChkCSV.Size = new System.Drawing.Size(95, 19);
this.ChkCSV.TabIndex = 109; this.ChkCSV.TabIndex = 109;
this.ChkCSV.Text = "导出到csv"; this.ChkCSV.Text = "导出到csv";
this.ChkCSV.UseVisualStyleBackColor = true; this.ChkCSV.UseVisualStyleBackColor = true;
this.ChkCSV.Visible = false;
// //
// Save // Save
// //