# Conflicts:
#	C-Windows-1/bin/Debug/LL28-Control.exe
#	C-Windows-1/obj/Debug/LL28-Control.exe
This commit is contained in:
RD001
2024-08-16 17:52:03 +08:00
4 changed files with 136 additions and 65 deletions

View File

@@ -115,6 +115,9 @@
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.button2 = new System.Windows.Forms.Button();
this.zhanhao = new System.Windows.Forms.TextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.labelyinjian = new System.Windows.Forms.Label();
this.labelruanjian = new System.Windows.Forms.Label();
this.myGroupBox4 = new C_Windows_1.MyGroupBox(this.components);
this.PUnit = new System.Windows.Forms.ComboBox();
this.label47 = new System.Windows.Forms.Label();
@@ -185,6 +188,7 @@
((System.ComponentModel.ISupportInitialize)(this.DataGridView1)).BeginInit();
this.menuStrip1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.myGroupBox4.SuspendLayout();
this.myGroupBox3.SuspendLayout();
this.myGroupBox1.SuspendLayout();
@@ -566,7 +570,7 @@
this.ToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1034, 25);
this.menuStrip1.Size = new System.Drawing.Size(1045, 25);
this.menuStrip1.TabIndex = 126;
this.menuStrip1.Text = "menuStrip1";
//
@@ -753,7 +757,7 @@
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(889, 83);
this.checkBox1.Location = new System.Drawing.Point(900, 83);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(96, 16);
this.checkBox1.TabIndex = 141;
@@ -764,7 +768,7 @@
// codecheck
//
this.codecheck.Enabled = false;
this.codecheck.Location = new System.Drawing.Point(885, 56);
this.codecheck.Location = new System.Drawing.Point(896, 56);
this.codecheck.Name = "codecheck";
this.codecheck.ReadOnly = true;
this.codecheck.Size = new System.Drawing.Size(100, 21);
@@ -775,7 +779,7 @@
//
this.label9.AutoSize = true;
this.label9.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label9.Location = new System.Drawing.Point(892, 29);
this.label9.Location = new System.Drawing.Point(903, 29);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(87, 16);
this.label9.TabIndex = 143;
@@ -801,12 +805,13 @@
this.groupBox1.Controls.Add(this.label34);
this.groupBox1.Controls.Add(this.Sunzong);
this.groupBox1.Controls.Add(this.label28);
this.groupBox1.Location = new System.Drawing.Point(822, 127);
this.groupBox1.Location = new System.Drawing.Point(1140, 127);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(200, 161);
this.groupBox1.TabIndex = 145;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "产测计数";
this.groupBox1.Visible = false;
//
// button1
//
@@ -893,6 +898,37 @@
this.zhanhao.Size = new System.Drawing.Size(113, 21);
this.zhanhao.TabIndex = 148;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.labelyinjian);
this.groupBox2.Controls.Add(this.labelruanjian);
this.groupBox2.Location = new System.Drawing.Point(816, 108);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(174, 184);
this.groupBox2.TabIndex = 149;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "设备信息";
//
// labelyinjian
//
this.labelyinjian.AutoSize = true;
this.labelyinjian.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelyinjian.Location = new System.Drawing.Point(6, 140);
this.labelyinjian.Name = "labelyinjian";
this.labelyinjian.Size = new System.Drawing.Size(95, 16);
this.labelyinjian.TabIndex = 24;
this.labelyinjian.Text = "硬件版本号:";
//
// labelruanjian
//
this.labelruanjian.AutoSize = true;
this.labelruanjian.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelruanjian.Location = new System.Drawing.Point(6, 71);
this.labelruanjian.Name = "labelruanjian";
this.labelruanjian.Size = new System.Drawing.Size(95, 16);
this.labelruanjian.TabIndex = 23;
this.labelruanjian.Text = "软件版本号:";
//
// myGroupBox4
//
this.myGroupBox4.Controls.Add(this.PUnit);
@@ -1551,7 +1587,8 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1034, 617);
this.ClientSize = new System.Drawing.Size(1045, 617);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.zhanhao);
this.Controls.Add(this.button2);
this.Controls.Add(this.progressBar1);
@@ -1600,7 +1637,7 @@
this.Controls.Add(this.ReceiveText);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Form1";
this.Text = "LL-Control";
this.Text = "20240816";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.DataGridView1)).EndInit();
@@ -1608,6 +1645,8 @@
this.menuStrip1.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.myGroupBox4.ResumeLayout(false);
this.myGroupBox4.PerformLayout();
this.myGroupBox3.ResumeLayout(false);
@@ -1772,5 +1811,8 @@
public System.Windows.Forms.Button BtnBreak;
public System.Windows.Forms.ComboBox UDPResults;
public System.Windows.Forms.Button TCPconnect;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label labelyinjian;
private System.Windows.Forms.Label labelruanjian;
}
}

View File

@@ -57,7 +57,7 @@ namespace C_Windows_1
private UdpClient udpClient;
private const int Port = 9999; // 监听端口号
private const int ReceiveTimeout = 5000; // 超时时间(毫秒)
private const int ReceiveTimeout = 3000; // 超时时间(毫秒)
private bool isListening = false; // 监听标志位,控制是否继续监听
private Timer timeoutTimer; // 定时器用于控制超时
@@ -301,7 +301,7 @@ namespace C_Windows_1
int i = 0;
int progressvalue = 0;
public void ModbusRtuint(ModbusRtu X, byte station, string COM, int Bund, int numberbit, StopBits stopbit, Parity parity)
{
@@ -399,16 +399,16 @@ namespace C_Windows_1
case (int)yiqi.test://读取检测数据以及判断仪器是否结束
//operateResult21=Modbusread(170, 23, ReadData);
Booltomath(2, ReadData);
progressBar2.Value = i;
i++;
progressBar2.Value = progressvalue;
progressvalue += 2;
Modbusread(1013, 16, ReadData);//各项参数
Modbusread(1034, 26, ReadData);
//Modbusread(25, 24, ReadData);
//test(ReadData);
//int ba = progressBar2.Value + 2;
//if (ba >= progressBar2.Maximum)
// ba = progressBar2.Maximum;
//progressBar2.Value = ba;
if (progressvalue >= progressBar2.Maximum)
progressvalue = progressBar2.Maximum;
progressBar2.Value = progressvalue;
//if (!(grovalue > 99.8))
//{
@@ -467,13 +467,14 @@ namespace C_Windows_1
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);
//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;
@@ -1011,15 +1012,15 @@ namespace C_Windows_1
if (ReadData[1041] == 2)
{
ChanSum++;
//ChanSum++;
Tlight.Text = "NG";
Tlight.ForeColor = Color.Red;
}
if (ReadData[1041] == 1)
{
ChanPass++;
ChanSum++;
//ChanPass++;
//ChanSum++;
Tlight.Text = "OK";
Tlight.ForeColor = Color.Green;
}
@@ -1141,29 +1142,29 @@ namespace C_Windows_1
workstation = (int)yiqi.standby;
while (true)
{
//Thread.Sleep(500);
//if (connectflag==1)
//{
Thread.Sleep(500);
if (connectflag == 1)
{
// connect = modbusClient.Read("1006", 1);//判断连接是否正常
// if (connect.IsSuccess)
// {
// TCPconnect.Enabled = false;
// PortNum.Text = modbusClient.IpAddress;
// label6.Text = modbusClient.Port.ToString();
// label6.ForeColor = Color.Green;
// //Code.Focus();
// }
// else
// {
// connectflag = 0;
// TCPconnect.Enabled = true;
// PortNum.Text = "";
// label6.Text = "未连接";
// label6.ForeColor = Color.Red;
// }
// machine2();//仪器读取线程
// MachineDisplay();//仪器显示线程
connect = modbusClient.Read("1006", 1);//判断连接是否正常
if (connect.IsSuccess)
{
TCPconnect.Enabled = false;
PortNum.Text = modbusClient.IpAddress;
label6.Text = modbusClient.Port.ToString();
label6.ForeColor = Color.Green;
//Code.Focus();
}
else
{
connectflag = 0;
TCPconnect.Enabled = true;
PortNum.Text = "";
label6.Text = "未连接";
label6.ForeColor = Color.Red;
}
machine2();//仪器读取线程
MachineDisplay();//仪器显示线程
// //if (MachineStatus.Text == "待机中" && connect.IsSuccess)
// //{
@@ -1172,7 +1173,7 @@ namespace C_Windows_1
// // MachineStatus.Text = "";
// //}
//}
}
@@ -1184,14 +1185,30 @@ namespace C_Windows_1
}
public string GetLocalIPAddress()
{
string localIP = "";
foreach (var addr in Dns.GetHostAddresses(Dns.GetHostName()))
{
if (addr.AddressFamily == AddressFamily.InterNetwork) // 选择 IPv4 地址
{
localIP = addr.ToString();
break;
}
}
return localIP;
}
//点击“连接串口”按钮,连接串口
private void BtnCon1_Click(object sender, EventArgs e)
{
UDPResults.Items.Clear();
byte[] data = Encoding.ASCII.GetBytes("hello,udp server");
System.Net.IPAddress ip;
ip = System.Net.IPAddress.Parse("192.168.1.255");
// 广播到 192.168.1.255
string localip=GetLocalIPAddress();
localip = localip.Substring(0, 10) + "255";
ip = System.Net.IPAddress.Parse(localip);
// 获本机IP频段广播到 .255
IPEndPoint endPoint = new IPEndPoint(ip, Port);
try
@@ -3115,6 +3132,9 @@ namespace C_Windows_1
label6.ForeColor = Color.Green;
station2 = Convert.ToUInt16(stationIP);
station = station2.ToString("X2");
Modbusread(360, 4, ReadData);
labelruanjian.Text = "软件版本号:" + ReadData[360].ToString("X4") + ReadData[361].ToString("X4");
labelyinjian.Text = "硬件版本号:" + ReadData[362].ToString("X4") + ReadData[363].ToString("X4");
}

View File

@@ -123,11 +123,20 @@ namespace C_Windows_1
short g = Convert.ToInt16(Convert.ToDouble(DelayTime2.Text) * 10);//延时2
Form1.f1.modbusClient.Write("1012", g);
short h = Convert.ToInt16(Convert.ToDouble(BLeakTPre.Text));//平衡压差上限
Form1.f1.modbusClient.Write("1017", h);
short i = Convert.ToInt16(Convert.ToDouble(BLeakLPre.Text));//平衡压差下限
Form1.f1.modbusClient.Write("1019", i);
List<byte> bigleakmax = new List<byte>();//压差上限
bigleakmax.AddRange(XdrFloat(Convert.ToSingle(BLeakTPre.Text)));
byte[] bigleakda = bigleakmax.ToArray();
Form1.f1.modbusClient.Write("1017", bigleakda);
List<byte> bigleakmin = new List<byte>();//压差下限
bigleakmin.AddRange(XdrFloat(Convert.ToSingle(BLeakLPre.Text)));
byte[] bigleakxiao = bigleakmin.ToArray();
Form1.f1.modbusClient.Write("1019", bigleakxiao);
//BLeakLPre
List<byte> parmEvolume = new List<byte>();//等效容积
parmEvolume.AddRange(XdrFloat(Convert.ToSingle(Evolume.Text)));
byte[] pEvolume = parmEvolume.ToArray();

View File

@@ -1,3 +1,3 @@
[Config]
Passzong=2810
Sunzong=3039
Passzong=2812
Sunzong=3041