25111302 差压28出货版本

This commit is contained in:
moxiliang
2025-11-14 09:32:59 +08:00
parent 6df003f5f8
commit 589dcaa568
88 changed files with 5372 additions and 14986 deletions

View File

@@ -1,7 +1,9 @@
using EasyModbus;
using Sunny.UI;
using System;
using System.Drawing;
using System.Linq;
using System.Web.Services.Description;
using System.Windows.Forms;
namespace SLC1_N
@@ -25,13 +27,11 @@ namespace SLC1_N
// 读取一次本地参数
cb_MachineNum.SelectedIndex = 0;
cb_ParaNum.SelectedIndex = 0;
ReadParametersJson("1","1");
if (Form1.f1.User == "操作员")
{
chk_ChkBee.Enabled = false;
chk_CH1CHKVacuum.Enabled = false; // 真空复选框
chk_CH2CHKVacuum.Enabled = false;
bt_BtnKeep.Enabled = false;
tb_FullTime.Enabled = false;
@@ -85,15 +85,42 @@ namespace SLC1_N
// Json记录读取
var config = new JsonConfig("config.json");
// 条码长度
tb_code1len.Text = config.GetValue<string>("CodeLength1", "9");
tb_code2len.Text = config.GetValue<string>("CodeLength2", "9");
tb_code3len.Text = config.GetValue<string>("CodeLength3", "9");
tb_code4len.Text = config.GetValue<string>("CodeLength4", "9");
chk_ch1saoma.Checked = config.GetValue<bool>("chk_ch1saoma", true);
chk_ch2saoma.Checked = config.GetValue<bool>("chk_ch2saoma", true);
chk_ch3saoma.Checked = config.GetValue<bool>("chk_ch3saoma", true);
chk_ch4saoma.Checked = config.GetValue<bool>("chk_ch4saoma", true);
// 是否扫码
if (Form1.f1.HCPLC_client?.Connected == true)
{
chk_ch1saoma.Checked = Form1.f1.coilSaoma[0];
chk_ch2saoma.Checked = Form1.f1.coilSaoma[1];
chk_ch3saoma.Checked = Form1.f1.coilSaoma[2];
chk_ch4saoma.Checked = Form1.f1.coilSaoma[3];
}
else
{
lb_PLCsaomamsg.Text = "PLC未连接";
lb_PLCsaomamsg.ForeColor = Color.Red;
}
//chk_ch1saoma.Checked = config.GetValue<bool>("chk_ch1saoma", true);
//chk_ch2saoma.Checked = config.GetValue<bool>("chk_ch2saoma", true);
//chk_ch3saoma.Checked = config.GetValue<bool>("chk_ch3saoma", true);
//chk_ch4saoma.Checked = config.GetValue<bool>("chk_ch4saoma", true);
// 正负压
rbt_PpressureMode.Checked = config.GetValue<bool>("rbt_PpressureMode", true);
rbt_NpressureMode.Checked = config.GetValue<bool>("rbt_NpressureMode", true);
string PorN = "P";
if (rbt_PpressureMode.Checked)
PorN = "P";
else if (rbt_NpressureMode.Checked)
PorN = "N";
ReadParametersJson("1", "1", PorN);
// 连续测试/次数
chk_ContinueTest.Checked = config.GetValue<bool>("chk_ContinueTest", true);
@@ -155,15 +182,19 @@ namespace SLC1_N
{
case 0:
Form1.f1.LL28CH1client.writeRegisters(1006, values); // 通道1 从1006 开始写入
Signal_PLC_WriteCoil?.Invoke(1008, rbt_NpressureMode.Checked);
break;
case 1:
Form1.f1.LL28CH2client.writeRegisters(1006, values); // 通道2 从1006 开始写入
Signal_PLC_WriteCoil?.Invoke(1009, rbt_NpressureMode.Checked);
break;
case 2:
Form1.f1.LL28CH3client.writeRegisters(1006, values); // 通道3 从1006 开始写入
Signal_PLC_WriteCoil?.Invoke(1010, rbt_NpressureMode.Checked);
break;
case 3:
Form1.f1.LL28CH4client.writeRegisters(1006, values); // 通道4 从1006 开始写入
Signal_PLC_WriteCoil?.Invoke(1011, rbt_NpressureMode.Checked);
break;
}
}
@@ -303,37 +334,77 @@ namespace SLC1_N
// 保存参数 按钮
private void BtnKeep_Click(object sender, EventArgs e)
{
SetParametersJson(cb_MachineNum.Text, cb_ParaNum.Text); // 通道-编号
string PorN = "P";
if(rbt_PpressureMode.Checked)
PorN = "P";
else if (rbt_NpressureMode.Checked)
PorN = "N";
SetParametersJson(Convert.ToInt32(cb_MachineNum.Text), cb_ParaNum.Text, PorN); // 通道-编号
}
// 写入参数 通道-编号
private void SetParametersJson(string CH, string i)
private void SetParametersJson(int CH, string i, string PorN)
{
// 保存到本地文件
var config = new JsonConfig("config.json");
config.SetValue($"{CH}" + "params_number" + i, cb_ParaNum.Text);
config.SetValue($"{CH}" + "paraname" + i, tb_ParaName.Text);
config.SetValue($"{CH}" + PorN + "params_number" + i, cb_ParaNum.Text);
config.SetValue($"{CH}" + PorN + "paraname" + i, tb_ParaName.Text);
config.SetValue($"{CH}" + "fulltime" + i, tb_FullTime.Text);
config.SetValue($"{CH}" + "balantime" + i, tb_BalanTime.Text);
config.SetValue($"{CH}" + "testtime1" + i, tb_TestTime1.Text);
config.SetValue($"{CH}" + "exhausttime" + i, tb_ExhaustTime.Text);
config.SetValue($"{CH}" + PorN + "fulltime" + i, tb_FullTime.Text);
config.SetValue($"{CH}" + PorN + "balantime" + i, tb_BalanTime.Text);
config.SetValue($"{CH}" + PorN + "testtime1" + i, tb_TestTime1.Text);
config.SetValue($"{CH}" + PorN + "exhausttime" + i, tb_ExhaustTime.Text);
config.SetValue($"{CH}" + "delaytime1" + i, tb_DelayTime1.Text);
config.SetValue($"{CH}" + "delaytime2" + i, tb_DelayTime2.Text);
config.SetValue($"{CH}" + "relievedelay" + i, tb_RelieveDelay.Text);
config.SetValue($"{CH}" + "evolume" + i, tb_Evolume.Text);
config.SetValue($"{CH}" + PorN + "delaytime1" + i, tb_DelayTime1.Text);
config.SetValue($"{CH}" + PorN + "delaytime2" + i, tb_DelayTime2.Text);
config.SetValue($"{CH}" + PorN + "relievedelay" + i, tb_RelieveDelay.Text);
config.SetValue($"{CH}" + PorN + "evolume" + i, tb_Evolume.Text);
config.SetValue($"{CH}" + "fptoplimit" + i, tb_FPtoplimit.Text);
config.SetValue($"{CH}" + "fplowlimit" + i, tb_FPlowlimit.Text);
config.SetValue($"{CH}" + "balanpremax" + i, tb_BalanPreMax.Text);
config.SetValue($"{CH}" + "balanpremin" + i, tb_BalanPreMin.Text);
config.SetValue($"{CH}" + PorN + "fptoplimit" + i, tb_FPtoplimit.Text);
config.SetValue($"{CH}" + PorN + "fplowlimit" + i, tb_FPlowlimit.Text);
config.SetValue($"{CH}" + PorN + "balanpremax" + i, tb_BalanPreMax.Text);
config.SetValue($"{CH}" + PorN + "balanpremin" + i, tb_BalanPreMin.Text);
config.SetValue($"{CH}" + "leaktoplimit" + i, tb_Leaktoplimit.Text);
config.SetValue($"{CH}" + "leaklowlimit" + i, tb_Leaklowlimit.Text);
config.SetValue($"{CH}" + "punit" + i, cb_PUnit.SelectedIndex);
config.SetValue($"{CH}" + "lunit" + i, cb_LUnit.SelectedIndex);
config.SetValue($"{CH}" + PorN + "leaktoplimit" + i, tb_Leaktoplimit.Text);
config.SetValue($"{CH}" + PorN + "leaklowlimit" + i, tb_Leaklowlimit.Text);
config.SetValue($"{CH}" + PorN + "punit" + i, cb_PUnit.SelectedIndex);
config.SetValue($"{CH}" + PorN + "lunit" + i, cb_LUnit.SelectedIndex);
config.SetValue($"{CH}" + "bee" + i, chk_ChkBee.Checked);
config.SetValue($"{CH}" + PorN + "bee" + i, chk_ChkBee.Checked);
// 保存开口、容积
if(rbt_OpeningMode.Checked)
{
config.SetValue($"{CH}" + PorN + "opmode" + i, false);
}
else if (rbt_VolumeMode.Checked)
{
config.SetValue($"{CH}" + PorN + "opmode" + i, true);
}
// 保存到主界面变量
Form1.f1.GetYiqiParam(CH, PorN).fulltime = Convert.ToInt32(tb_FullTime.Text);
Form1.f1.GetYiqiParam(CH, PorN).balantime = Convert.ToInt32(tb_BalanTime.Text);
Form1.f1.GetYiqiParam(CH, PorN).testtime1 = Convert.ToInt32(tb_TestTime1.Text);
Form1.f1.GetYiqiParam(CH, PorN).exhausttime = Convert.ToInt32(tb_ExhaustTime.Text);
Form1.f1.GetYiqiParam(CH, PorN).delaytime1 = Convert.ToInt32(tb_DelayTime1.Text);
Form1.f1.GetYiqiParam(CH, PorN).delaytime2 = Convert.ToInt32(tb_DelayTime2.Text);
Form1.f1.GetYiqiParam(CH, PorN).relievedelay = Convert.ToInt32(tb_RelieveDelay.Text);
Form1.f1.GetYiqiParam(CH, PorN).evolume = Convert.ToInt32(tb_Evolume.Text);
Form1.f1.GetYiqiParam(CH, PorN).fptoplimit = Convert.ToInt32(tb_FPtoplimit.Text);
Form1.f1.GetYiqiParam(CH, PorN).fplowlimit = Convert.ToInt32(tb_FPlowlimit.Text);
Form1.f1.GetYiqiParam(CH, PorN).balanpremax = Convert.ToInt32(tb_BalanPreMax.Text);
Form1.f1.GetYiqiParam(CH, PorN).balanpremin = Convert.ToInt32(tb_BalanPreMin.Text);
Form1.f1.GetYiqiParam(CH, PorN).leaktoplimit = Convert.ToInt32(tb_Leaktoplimit.Text);
Form1.f1.GetYiqiParam(CH, PorN).leaklowlimit = Convert.ToInt32(tb_Leaklowlimit.Text);
Form1.f1.GetYiqiParam(CH, PorN).punit = cb_PUnit.SelectedIndex;
Form1.f1.GetYiqiParam(CH, PorN).lunit = cb_LUnit.SelectedIndex;
Form1.f1.GetYiqiParam(CH, PorN).opmode = rbt_VolumeMode.Checked;
//mesconfig.IniWriteValue("Parameters", CH + "unit", CHKUnit.Checked.ToString());
//mesconfig.IniWriteValue("Parameters", CH + "presscompensation", PressCompensation.Text);
@@ -341,33 +412,44 @@ namespace SLC1_N
}
// 读取本地参数记录
private void ReadParametersJson(string CH, string i)
private void ReadParametersJson(string CH, string i, string PorN)
{
var config = new JsonConfig("config.json");
//ParaNum.Text = config.GetValue<string>($"{CH}" + "params_number" + i, "");
tb_ParaName.Text = config.GetValue<string>($"{CH}" + "paraname" + i, "0");
tb_ParaName.Text = config.GetValue<string>($"{CH}" + PorN + "paraname" + i, "0");
tb_FullTime.Text = config.GetValue<string>($"{CH}" + "fulltime" + i, "0");
tb_BalanTime.Text = config.GetValue<string>($"{CH}" + "balantime" + i, "0");
tb_TestTime1.Text = config.GetValue<string>($"{CH}" + "testtime1" + i, "0");
tb_ExhaustTime.Text = config.GetValue<string>($"{CH}" + "exhausttime" + i, "0");
tb_FullTime.Text = config.GetValue<string>($"{CH}" + PorN + "fulltime" + i, "0");
tb_BalanTime.Text = config.GetValue<string>($"{CH}" + PorN + "balantime" + i, "0");
tb_TestTime1.Text = config.GetValue<string>($"{CH}" + PorN + "testtime1" + i, "0");
tb_ExhaustTime.Text = config.GetValue<string>($"{CH}" + PorN + "exhausttime" + i, "0");
tb_DelayTime1.Text = config.GetValue<string>($"{CH}" + "delaytime1" + i, "0");
tb_DelayTime2.Text = config.GetValue<string>($"{CH}" + "delaytime2" + i, "0");
tb_RelieveDelay.Text = config.GetValue<string>($"{CH}" + "relievedelay" + i, "0");
tb_Evolume.Text = config.GetValue<string>($"{CH}" + "evolume" + i, "0");
tb_DelayTime1.Text = config.GetValue<string>($"{CH}" + PorN + "delaytime1" + i, "0");
tb_DelayTime2.Text = config.GetValue<string>($"{CH}" + PorN + "delaytime2" + i, "0");
tb_RelieveDelay.Text = config.GetValue<string>($"{CH}" + PorN + "relievedelay" + i, "0");
tb_Evolume.Text = config.GetValue<string>($"{CH}" + PorN + "evolume" + i, "0");
tb_FPtoplimit.Text = config.GetValue<string>($"{CH}" + "fptoplimit" + i, "0");
tb_FPlowlimit.Text = config.GetValue<string>($"{CH}" + "fplowlimit" + i, "0");
tb_BalanPreMax.Text = config.GetValue<string>($"{CH}" + "balanpremax" + i, "0");
tb_BalanPreMin.Text = config.GetValue<string>($"{CH}" + "balanpremin" + i, "0");
tb_FPtoplimit.Text = config.GetValue<string>($"{CH}" + PorN + "fptoplimit" + i, "0");
tb_FPlowlimit.Text = config.GetValue<string>($"{CH}" + PorN + "fplowlimit" + i, "0");
tb_BalanPreMax.Text = config.GetValue<string>($"{CH}" + PorN + "balanpremax" + i, "0");
tb_BalanPreMin.Text = config.GetValue<string>($"{CH}" + PorN + "balanpremin" + i, "0");
tb_Leaktoplimit.Text = config.GetValue<string>($"{CH}" + "leaktoplimit" + i, "0");
tb_Leaklowlimit.Text = config.GetValue<string>($"{CH}" + "leaklowlimit" + i, "0");
cb_PUnit.SelectedIndex = config.GetValue<int>($"{CH}" + "punit" + i, 1);
cb_LUnit.SelectedIndex = config.GetValue<int>($"{CH}" + "lunit" + i, 1);
tb_Leaktoplimit.Text = config.GetValue<string>($"{CH}" + PorN + "leaktoplimit" + i, "0");
tb_Leaklowlimit.Text = config.GetValue<string>($"{CH}" + PorN + "leaklowlimit" + i, "0");
cb_PUnit.SelectedIndex = config.GetValue<int>($"{CH}" + PorN + "punit" + i, 1);
cb_LUnit.SelectedIndex = config.GetValue<int>($"{CH}" + PorN + "lunit" + i, 1);
chk_ChkBee.Checked = config.GetValue<bool>($"{CH}" + "bee" + i, false);
chk_ChkBee.Checked = config.GetValue<bool>($"{CH}" + PorN + "bee" + i, false);
// 容积/开口
bool kk = config.GetValue<bool>($"{CH}" + PorN + "opmode" + i, false);
if (kk == false)
{
rbt_OpeningMode.Checked = true;
}
else if (kk == true)
{
rbt_VolumeMode.Checked = true;
}
}
private void MachineNum_KeyPress(object sender, KeyPressEventArgs e)
@@ -378,63 +460,25 @@ namespace SLC1_N
// 通道下拉框变化
private void MachineNum_SelectedIndexChanged(object sender, EventArgs e)
{
ReadParametersJson(cb_MachineNum.Text, cb_ParaNum.Text);
string PorN = "P";
if (rbt_PpressureMode.Checked)
PorN = "P";
else if (rbt_NpressureMode.Checked)
PorN = "N";
ReadParametersJson(cb_MachineNum.Text, cb_ParaNum.Text, PorN);
}
// 编号下拉框变化
private void ParaNum_SelectedIndexChanged(object sender, EventArgs e)
{
ReadParametersJson(cb_MachineNum.Text, cb_ParaNum.Text);
}
string PorN = "P";
if (rbt_PpressureMode.Checked)
PorN = "P";
else if (rbt_NpressureMode.Checked)
PorN = "N";
// 真空复选框
private void CH1CHKVacuum_Click(object sender, EventArgs e)
{
//if (Form1.f1.plc.PLCIsRun)
//{
// Form1.f1.PLCSignal.Stop();
// if (chk_CH1CHKVacuum.Checked)
// {
// //Form1.f1.plc.CH1VacuumTrue();
// }
// else
// {
// //Form1.f1.plc.CH1VacuumFalse();
// }
// Form1.f1.PLCSignal.Interval = 1000;
// Form1.f1.PLCSignal.Start();
//}
//else
//{
// bool check = (!chk_CH1CHKVacuum.Checked);
// chk_CH1CHKVacuum.Checked = check;
// MessageBox.Show("PLC未通讯");
//}
}
// 真空复选框
private void CH2CHKVacuum_Click(object sender, EventArgs e)
{
//if (Form1.f1.plc.PLCIsRun)
//{
// Form1.f1.PLCSignal.Stop();
// if (chk_CH2CHKVacuum.Checked)
// {
// //Form1.f1.plc.CH2VacuumTrue();
// }
// else
// {
// //Form1.f1.plc.CH2VacuumFalse();
// }
// Form1.f1.PLCSignal.Interval = 1000;
// Form1.f1.PLCSignal.Start();
//}
//else
//{
// bool check = (!chk_CH2CHKVacuum.Checked);
// chk_CH2CHKVacuum.Checked = check;
// MessageBox.Show("PLC未通讯");
//}
ReadParametersJson(cb_MachineNum.Text, cb_ParaNum.Text, PorN);
}
// 不知道干嘛的,隐藏在下面
@@ -491,34 +535,16 @@ namespace SLC1_N
//MessageBox.Show("设置成功");
}
// 正压模式
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
// Form1.f1.plc.w正压模式();
}
}
// 负压模式
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
if (radioButton2.Checked)
{
// Form1.f1.plc.w负压模式();
}
}
// 通道1扫码
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (chk_ch1saoma.Checked)
{
Signal_PLC_WriteCoil?.Invoke(600, true);
Signal_PLC_WriteCoil?.Invoke(1012, true);
}
else
{
Signal_PLC_WriteCoil?.Invoke(600, false);
Signal_PLC_WriteCoil?.Invoke(1012, false);
}
var config = new JsonConfig("config.json");
config.SetValue("chk_ch1saoma", chk_ch1saoma.Checked);
@@ -529,11 +555,11 @@ namespace SLC1_N
{
if (chk_ch2saoma.Checked)
{
Signal_PLC_WriteCoil?.Invoke(601, true);
Signal_PLC_WriteCoil?.Invoke(1013, true);
}
else
{
Signal_PLC_WriteCoil?.Invoke(601, false);
Signal_PLC_WriteCoil?.Invoke(1013, false);
}
var config = new JsonConfig("config.json");
config.SetValue("chk_ch2saoma", chk_ch2saoma.Checked);
@@ -544,11 +570,11 @@ namespace SLC1_N
{
if (chk_ch3saoma.Checked)
{
Signal_PLC_WriteCoil?.Invoke(602, true);
Signal_PLC_WriteCoil?.Invoke(1014, true);
}
else
{
Signal_PLC_WriteCoil?.Invoke(602, false);
Signal_PLC_WriteCoil?.Invoke(1014, false);
}
var config = new JsonConfig("config.json");
config.SetValue("chk_ch3saoma", chk_ch3saoma.Checked);
@@ -559,11 +585,11 @@ namespace SLC1_N
{
if (chk_ch4saoma.Checked)
{
Signal_PLC_WriteCoil?.Invoke(603, true);
Signal_PLC_WriteCoil?.Invoke(1015, true);
}
else
{
Signal_PLC_WriteCoil?.Invoke(603, false);
Signal_PLC_WriteCoil?.Invoke(1015, false);
}
var config = new JsonConfig("config.json");
config.SetValue("chk_ch4saoma", chk_ch4saoma.Checked);
@@ -601,6 +627,68 @@ namespace SLC1_N
}
}
//// 容积模式/开口模式
//private void rbt_VolumeModeOrOpeningMode_Click(object sender, EventArgs e)
//{
// if(rbt_VolumeMode.Checked)
// {
// Signal_PLC_WriteCoil?.Invoke(1000, true);
// Signal_PLC_WriteCoil?.Invoke(1001, true);
// Signal_PLC_WriteCoil?.Invoke(1002, true);
// Signal_PLC_WriteCoil?.Invoke(1003, true);
// }
// else if(rbt_OpeningMode.Checked)
// {
// Signal_PLC_WriteCoil?.Invoke(1000, false);
// Signal_PLC_WriteCoil?.Invoke(1001, false);
// Signal_PLC_WriteCoil?.Invoke(1002, false);
// Signal_PLC_WriteCoil?.Invoke(1003, false);
// }
// var config = new JsonConfig("config.json");
// config.SetValue("rbt_VolumeMode", rbt_VolumeMode.Checked);
// config.SetValue("rbt_OpeningMode", rbt_OpeningMode.Checked);
//}
// 正负压
private void rbt_PpressureModeOr_NpressureMode_Click(object sender, EventArgs e)
{
if (rbt_PpressureMode.Checked)
{
string PorN = "P";
if (rbt_PpressureMode.Checked)
PorN = "P";
else if (rbt_NpressureMode.Checked)
PorN = "N";
ReadParametersJson(cb_MachineNum.Text, cb_ParaNum.Text, PorN);
//Signal_PLC_WriteCoil?.Invoke(1008, false);
//Signal_PLC_WriteCoil?.Invoke(1009, false);
//Signal_PLC_WriteCoil?.Invoke(1010, false);
//Signal_PLC_WriteCoil?.Invoke(1011, false);
}
else if (rbt_NpressureMode.Checked)
{
string PorN = "P";
if (rbt_PpressureMode.Checked)
PorN = "P";
else if (rbt_NpressureMode.Checked)
PorN = "N";
ReadParametersJson(cb_MachineNum.Text, cb_ParaNum.Text, PorN);
//Signal_PLC_WriteCoil?.Invoke(1008, true);
//Signal_PLC_WriteCoil?.Invoke(1009, true);
//Signal_PLC_WriteCoil?.Invoke(1010, true);
//Signal_PLC_WriteCoil?.Invoke(1011, true);
}
var config = new JsonConfig("config.json");
config.SetValue("rbt_PpressureMode", rbt_PpressureMode.Checked);
config.SetValue("rbt_NpressureMode", rbt_NpressureMode.Checked);
}
// 是否连续测试
private void chk_ContinueTest_CheckedChanged(object sender, EventArgs e)
{
@@ -615,7 +703,7 @@ namespace SLC1_N
// 连续次数
private void tb_ContinueTestCount_TextChanged(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(tb_ContinueTestCount.Text))
if(string.IsNullOrEmpty(tb_ContinueTestCount.Text))
return;
Form1.f1.m_ContinueTestCount = Convert.ToInt32(tb_ContinueTestCount.Text);
@@ -623,5 +711,6 @@ namespace SLC1_N
var config = new JsonConfig("config.json");
config.SetValue("tb_ContinueTestCount", Convert.ToInt32(tb_ContinueTestCount.Text));
}
}
}