版本升级至1.0.0.2,增加流量版本日志记录字段平衡流量(大漏泄漏量),测试流量(泄漏量)
This commit is contained in:
@@ -24,6 +24,8 @@ using Timer = System.Windows.Forms.Timer;
|
||||
using System.Net;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
using Org.BouncyCastle.Utilities.Net;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.NetworkInformation;
|
||||
|
||||
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[] strListLeakUnit = { "Pa", "KPa", "mbar", "atm", "sccm", "ccm3/s", "Pa/s" };
|
||||
string[] strListStatus = { "待机中", "准备", "充气", "平衡", "检测", "排气"};
|
||||
public Form1()
|
||||
{
|
||||
f1 = this;
|
||||
@@ -335,37 +338,18 @@ namespace C_Windows_1
|
||||
switch (workstation)
|
||||
{
|
||||
case (int)yiqi.start:
|
||||
|
||||
operateResult22 = modbusClient.Write("0", true);
|
||||
//MachineStatus.Text = "开始测试";
|
||||
//Console.WriteLine("当前是启动状态");
|
||||
//if (operateResult22.IsSuccess)
|
||||
//{
|
||||
// operateResult22 = CH1.Write("85", false);
|
||||
workstation = (int)yiqi.prepare;
|
||||
//}
|
||||
break;
|
||||
//return workstation;
|
||||
|
||||
|
||||
|
||||
case (int)yiqi.rst:
|
||||
//byte[] data2 = new byte[] { 0xff, 0x00 };
|
||||
operateResult21 = modbusClient.Write("1", true);
|
||||
//Console.WriteLine("当前是复位状态");
|
||||
////点击复位进度条置为0
|
||||
progressBar2.Value = 0;
|
||||
//MachineStatus.Text = "复位";
|
||||
//LeakPressure.Text = "";
|
||||
//Leak.Text = "";
|
||||
//label2.Text = "";
|
||||
//Tlight.Text = "";
|
||||
if (operateResult21.IsSuccess)
|
||||
{
|
||||
workstation = (int)yiqi.standby;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -375,24 +359,17 @@ namespace C_Windows_1
|
||||
Tlight.Text = "";
|
||||
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.Maximum = aaa;
|
||||
Booltomath(2, ReadData);
|
||||
|
||||
if(ReadData[2]!=0)
|
||||
{
|
||||
workstation = (int)yiqi.test;
|
||||
}
|
||||
else
|
||||
{
|
||||
workstation = (int)yiqi.standby;
|
||||
}
|
||||
|
||||
|
||||
if(ReadData[2]!=0)
|
||||
{
|
||||
workstation = (int)yiqi.test;
|
||||
}
|
||||
else
|
||||
{
|
||||
workstation = (int)yiqi.standby;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -406,29 +383,14 @@ namespace C_Windows_1
|
||||
progressvalue += 2;
|
||||
Modbusread(1013, 16, ReadData);//各项参数
|
||||
Modbusread(1034, 26, ReadData);
|
||||
//Modbusread(25, 24, ReadData);
|
||||
//test(ReadData);
|
||||
//int ba = progressBar2.Value + 2;
|
||||
if (progressvalue >= progressBar2.Maximum)
|
||||
progressvalue = progressBar2.Maximum;
|
||||
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且有结果时
|
||||
{
|
||||
workstation = (int)yiqi.finish;
|
||||
//return workstation;
|
||||
}
|
||||
if (ReadData[2] == 0)
|
||||
{
|
||||
@@ -444,11 +406,7 @@ namespace C_Windows_1
|
||||
workstation = (int)yiqi.standby;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case (int)yiqi.standby://读取仪器是否启动
|
||||
Booltomath(2, ReadData);
|
||||
Modbusread(1041, 1, ReadData);
|
||||
@@ -457,9 +415,6 @@ namespace C_Windows_1
|
||||
{
|
||||
workstation = (int)yiqi.prepare;
|
||||
}
|
||||
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -467,31 +422,17 @@ namespace C_Windows_1
|
||||
case (int)yiqi.finish:
|
||||
Modbusread(1034, 26, ReadData);
|
||||
progressBar2.Value = progressBar2.Maximum;
|
||||
//timerbar.Stop();
|
||||
DataGridView1.Invoke(new System.Action(Display));
|
||||
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();
|
||||
progressvalue = 0;
|
||||
workstation = (int)yiqi.standby;
|
||||
|
||||
|
||||
// return workstation;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
//return 0;break;
|
||||
|
||||
|
||||
}
|
||||
//}
|
||||
// )));
|
||||
}
|
||||
|
||||
|
||||
@@ -500,9 +441,6 @@ namespace C_Windows_1
|
||||
switch (workstation)
|
||||
{
|
||||
case (int)yiqi.start:
|
||||
|
||||
//MachineStatus.Text = "开始测试";
|
||||
|
||||
break;
|
||||
case (int)yiqi.rst:
|
||||
MachineStatus.Text = "复位";
|
||||
@@ -526,7 +464,7 @@ namespace C_Windows_1
|
||||
break;
|
||||
|
||||
case (int)yiqi.test:
|
||||
MachineStatus.Text = "测试中";
|
||||
MachineStatus.Text = strListStatus[ReadData[1034]];
|
||||
PressureUnit.Text = strPressureUnit[ReadData[1027]];
|
||||
LeakUnit.Text = strListLeakUnit[ReadData[1028]];
|
||||
if (ReadData[1041] == 2)
|
||||
@@ -671,6 +609,26 @@ namespace C_Windows_1
|
||||
{
|
||||
label41.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(() =>
|
||||
@@ -702,22 +660,9 @@ namespace C_Windows_1
|
||||
machine2();//仪器读取线程
|
||||
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;
|
||||
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)
|
||||
{
|
||||
UDPResults.Items.Clear();
|
||||
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
|
||||
{
|
||||
if (!isListening) return;
|
||||
|
||||
IPEndPoint remoteEndPoint = new IPEndPoint(ip, Port);
|
||||
byte[] receivedData = udpClient.EndReceive(ar, ref remoteEndPoint);
|
||||
string receivedMessage = Encoding.ASCII.GetString(receivedData);
|
||||
|
||||
// 更新 UI 线程中的 ComboBox
|
||||
Invoke(new Action(() =>
|
||||
UDPRecvData = "";
|
||||
// 获取所有可用网卡IP
|
||||
List<System.Net.IPAddress> localIPs = GetActiveNICsIP();
|
||||
if (localIPs.Count == 0)
|
||||
{
|
||||
UDPResults.Items.Add(receivedMessage); // 将接收到的消息添加到 ComboBox
|
||||
UDPResults.SelectedIndex = UDPResults.Items.Count - 1;
|
||||
}));
|
||||
Console.WriteLine("No active network interfaces found");
|
||||
}
|
||||
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)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
Console.WriteLine("UDP广播:" + ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//关闭串口
|
||||
private void BtnBreak_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -1161,7 +1113,39 @@ namespace C_Windows_1
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1253,7 +1237,14 @@ namespace C_Windows_1
|
||||
if (File.Exists(fileName) == false)
|
||||
{
|
||||
StreamWriter fileWriter1 = new StreamWriter(fileName, true, Encoding.UTF8);
|
||||
fileWriter1.Write("时间,条形码,充气时间,平衡时间,检测时间,排气时间,充气压力上限,充气压力下限,大漏压差上限,大漏压差下限,泄漏量上限,泄漏量下限,测试结果,测试压力,压力单位,泄漏量,泄漏量单位" + "\r\n");
|
||||
if (liuliangVersion == 1)
|
||||
{
|
||||
fileWriter1.Write("时间,条形码,充气时间,平衡时间,检测时间,排气时间,充气压力上限,充气压力下限,大漏压差上限,大漏压差下限,泄漏量上限,泄漏量下限,测试结果,测试压力,压力单位,测试流量,平衡流量,泄漏量单位" + "\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
fileWriter1.Write("时间,条形码,充气时间,平衡时间,检测时间,排气时间,充气压力上限,充气压力下限,大漏压差上限,大漏压差下限,泄漏量上限,泄漏量下限,测试结果,测试压力,压力单位,泄漏量,泄漏量单位" + "\r\n");
|
||||
}
|
||||
fileWriter1.Flush();
|
||||
fileWriter1.Close();
|
||||
}
|
||||
@@ -1262,21 +1253,25 @@ namespace C_Windows_1
|
||||
string nowdate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
|
||||
fileWriter.Write(nowdate + "," + Code.Text + ",");
|
||||
fileWriter.Write(FullTime.Text + "s" + ",");
|
||||
fileWriter.Write(BalanTime.Text + "s" + ",");
|
||||
fileWriter.Write(TestTime1.Text + "s" + ",");
|
||||
fileWriter.Write(ExhaustTime.Text + "s" + ",");
|
||||
fileWriter.Write(FPtoplimit.Text + PUnit.Text + ",");
|
||||
fileWriter.Write(FPlowlimit.Text + PUnit.Text + ",");
|
||||
fileWriter.Write(BLeakTPre.Text + PUnit.Text + ",");
|
||||
fileWriter.Write(BLeakLPre.Text + PUnit.Text + ",");
|
||||
fileWriter.Write(Leaktoplimit.Text + LUnit.Text + ",");
|
||||
fileWriter.Write(Leaklowlimit.Text + LUnit.Text + ",");
|
||||
fileWriter.Write(ReadData[1006] / 10.0 + "s" + ",");
|
||||
fileWriter.Write(ReadData[1007] / 10.0 + "s" + ",");
|
||||
fileWriter.Write(ReadData[1008] / 10.0 + "s" + ",");
|
||||
fileWriter.Write(ReadData[1009] / 10.0 + "s" + ",");
|
||||
fileWriter.Write(TwoUInt16ToFloat(ReadData[1014], ReadData[1013]).ToString() + PUnit.Text + ",");
|
||||
fileWriter.Write(TwoUInt16ToFloat(ReadData[1016], ReadData[1015]).ToString() + PUnit.Text + ",");
|
||||
fileWriter.Write(TwoUInt16ToFloat(ReadData[1018], ReadData[1017]).ToString() + PUnit.Text + ",");
|
||||
fileWriter.Write(TwoUInt16ToFloat(ReadData[1020], ReadData[1019]).ToString() + PUnit.Text + ",");
|
||||
fileWriter.Write(TwoUInt16ToFloat(ReadData[1022], ReadData[1021]).ToString() + LUnit.Text + ",");
|
||||
fileWriter.Write(TwoUInt16ToFloat(ReadData[1024], ReadData[1023]).ToString() + LUnit.Text + ",");
|
||||
fileWriter.Write(Tlight.Text + ",");
|
||||
fileWriter.Write(DLeakPressure + ",");
|
||||
fileWriter.Write(PUnit.Text + ",");
|
||||
fileWriter.Write(DLeak + ",");
|
||||
fileWriter.Write(LUnit.Text + "\n");
|
||||
fileWriter.Write(PressureUnit.Text + ",");
|
||||
if (liuliangVersion == 1)
|
||||
{
|
||||
fileWriter.Write(TwoUInt16ToFloat(ReadData[1036], ReadData[1035]).ToString() + ",");
|
||||
}
|
||||
fileWriter.Write(TwoUInt16ToFloat(ReadData[1039], ReadData[1038]).ToString() + ",");
|
||||
fileWriter.Write(LeakUnit.Text + "\n");
|
||||
|
||||
fileWriter.Flush();
|
||||
fileWriter.Close();
|
||||
@@ -1324,18 +1319,18 @@ namespace C_Windows_1
|
||||
{
|
||||
AddExcel();
|
||||
}
|
||||
//if (ChkTXT.Checked)
|
||||
//{
|
||||
// AddTXT();
|
||||
//}
|
||||
if (ChkTXT.Checked)
|
||||
{
|
||||
AddTXT();
|
||||
}
|
||||
if (ChkSql.Checked)
|
||||
{
|
||||
AddDatebase();
|
||||
}
|
||||
//if (ChkCSV.Checked)
|
||||
//{
|
||||
// AddCSV();
|
||||
//}
|
||||
if (ChkCSV.Checked)
|
||||
{
|
||||
AddCSV();
|
||||
}
|
||||
if (ChkMES.Checked && Code.TextLength > 0)
|
||||
{
|
||||
ADDMES();
|
||||
@@ -1345,11 +1340,26 @@ namespace C_Windows_1
|
||||
//在界面显示数据
|
||||
private void Display()
|
||||
{
|
||||
DataGridView1.Rows.Add(
|
||||
if (liuliangVersion == 1) //流量版本
|
||||
{
|
||||
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);
|
||||
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[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)
|
||||
@@ -1898,8 +1908,7 @@ namespace C_Windows_1
|
||||
string ipAddress;
|
||||
|
||||
private void TCPconnect_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
//根据:符号分割站号和IP
|
||||
string[] parts = UDPResults.Text.Split(':');
|
||||
@@ -1915,8 +1924,7 @@ namespace C_Windows_1
|
||||
|
||||
|
||||
modbusClient = new ModbusRtuOverTcp(ipAddress, 9999, Convert.ToByte(stationIP));
|
||||
//modbusClient.ConnectTimeOut = 1000;
|
||||
//modbusClient.ReceiveTimeOut = 1000;
|
||||
Thread.Sleep(100);
|
||||
if (modbusClient.ConnectServer().IsSuccess)
|
||||
{
|
||||
connectflag = 1;
|
||||
|
||||
Reference in New Issue
Block a user