创建得辉达定制分支
This commit is contained in:
@@ -4,6 +4,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace C_Windows_1
|
||||
@@ -85,110 +86,101 @@ namespace C_Windows_1
|
||||
|
||||
|
||||
|
||||
public OperateResult operateResult;
|
||||
|
||||
|
||||
private void BtnUpload_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (FullTime.Text == "" || TestTime1.Text == "" || ExhaustTime.Text == "" || DelayTime1.Text == "" || DelayTime2.Text == "" || BLeakLPre.Text == "" || BLeakTPre.Text == "" || LUnit.Text == "" || PUnit.Text == "")
|
||||
int p = Convert.ToInt32(ParaNum.Text);
|
||||
SetParameters(p);
|
||||
if (FullTime.Text == "" || BBalanTime.Text == "" || SBalanTime.Text == "" || TestTime1.Text == "" || ExhaustTime.Text == "" || BypassTime.Text == "" || DelayTime1.Text == "" || DelayTime2.Text == "" || BLeakLPre.Text == "" || BLeakTPre.Text == "" || LUnit.Text == "" || PUnit.Text == "")
|
||||
{
|
||||
MessageBox.Show("输入参数格式不对");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FullTime.Text == "" || TestTime1.Text == "" || ExhaustTime.Text == "" || DelayTime1.Text == "" || DelayTime2.Text == "" || BLeakLPre.Text == "" || BLeakTPre.Text == "" || LUnit.Text == "" || PUnit.Text == "")
|
||||
if (FullTime.Text == "" || BBalanTime.Text == "" || SBalanTime.Text == "" || TestTime1.Text == "" || ExhaustTime.Text == "" || BypassTime.Text == "" || DelayTime1.Text == "" || DelayTime2.Text == "" || BLeakLPre.Text == "" || BLeakTPre.Text == "" || LUnit.Text == "" || PUnit.Text == "")
|
||||
{
|
||||
MessageBox.Show("输入参数格式不对");
|
||||
}
|
||||
else
|
||||
{
|
||||
BtnUpload.Text = "正在上传";
|
||||
//BtnUpload.Enabled = false;
|
||||
BtnUpload.ForeColor = Color.Red;
|
||||
short a = Convert.ToInt16(Convert.ToDouble(FullTime.Text) * 10);//充气时间
|
||||
Form1.f1.modbusClient.Write("1006", a);
|
||||
Form1.f1.CH1.Write("25", a);
|
||||
//平衡时间不能写入,为大漏平衡时间和微漏平衡时间的和
|
||||
//short b = Convert.ToInt16(Convert.ToDouble(BBalanTime.Text) * 10);//平衡时间
|
||||
short b = Convert.ToInt16(Convert.ToDouble(BalanTime.Text) * 10);
|
||||
Form1.f1.modbusClient.Write("1007", b);
|
||||
Form1.f1.CH1.Write("34", b);
|
||||
short c = Convert.ToInt16(Convert.ToDouble(TestTime1.Text) * 10);//检测时间1
|
||||
Form1.f1.modbusClient.Write("1008", c);
|
||||
Form1.f1.CH1.Write("27", c);
|
||||
short d = Convert.ToInt16(Convert.ToDouble(ExhaustTime.Text) * 10);//排气时间
|
||||
Form1.f1.modbusClient.Write("1009", d);
|
||||
Form1.f1.CH1.Write("28", d);
|
||||
|
||||
|
||||
short j = Convert.ToInt16(Convert.ToDouble(BypassTime.Text) * 10);//旁路时间
|
||||
Form1.f1.CH1.Write("29", j);
|
||||
short f = Convert.ToInt16(Convert.ToDouble(DelayTime1.Text) * 10);//延时1
|
||||
Form1.f1.modbusClient.Write("1011", f);
|
||||
Form1.f1.CH1.Write("30", f);
|
||||
short g = Convert.ToInt16(Convert.ToDouble(DelayTime2.Text) * 10);//延时2
|
||||
Form1.f1.modbusClient.Write("1012", g);
|
||||
|
||||
|
||||
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);
|
||||
Form1.f1.CH1.Write("31", g);
|
||||
|
||||
short h = Convert.ToInt16(Convert.ToDouble(BLeakTPre.Text));//大漏压差上限
|
||||
Form1.f1.CH1.Write("36", h);
|
||||
short i = Convert.ToInt16(Convert.ToDouble(BLeakLPre.Text));//大漏压差下限
|
||||
Form1.f1.CH1.Write("37", i);
|
||||
//BLeakLPre
|
||||
|
||||
|
||||
List<byte> parmEvolume = new List<byte>();//等效容积
|
||||
parmEvolume.AddRange(XdrFloat(Convert.ToSingle(Evolume.Text)));
|
||||
byte[] pEvolume = parmEvolume.ToArray();
|
||||
Form1.f1.modbusClient.Write("1025", pEvolume);
|
||||
Form1.f1.CH1.Write("42", pEvolume);
|
||||
|
||||
|
||||
List<byte> parmFPtoplimit = new List<byte>();//充气压力上限
|
||||
parmFPtoplimit.AddRange(XdrFloat(Convert.ToSingle(FPtoplimit.Text)));
|
||||
byte[] toplimit = parmFPtoplimit.ToArray();
|
||||
Form1.f1.modbusClient.Write("1013", toplimit);
|
||||
Form1.f1.CH1.Write("32", toplimit);
|
||||
|
||||
List<byte> parmFPlowlimit = new List<byte>();//充气压力下限
|
||||
parmFPlowlimit.AddRange(XdrFloat(Convert.ToSingle(FPlowlimit.Text)));
|
||||
byte[] lowlimit = parmFPlowlimit.ToArray();
|
||||
Form1.f1.modbusClient.Write("1015", lowlimit);
|
||||
Form1.f1.CH1.Write("46", lowlimit);
|
||||
|
||||
//short BBaTime = Convert.ToInt16(Convert.ToDouble(BBalanTime.Text) * 10);//大漏平衡时间
|
||||
//Form1.f1.modbusClient.Write("34", BBaTime);
|
||||
//Form1.f1.CH1.Write("34", BBaTime);
|
||||
|
||||
//short SBaTime = Convert.ToInt16(Convert.ToDouble(SBalanTime.Text) * 10);//微漏平衡时间
|
||||
//Form1.f1.modbusClient.Write("35", SBaTime);
|
||||
//Form1.f1.CH1.Write("35", SBaTime);
|
||||
|
||||
List<byte> parmLeaktoplimit = new List<byte>();//泄露量上限
|
||||
parmLeaktoplimit.AddRange(XdrFloat(Convert.ToSingle(Leaktoplimit.Text)));
|
||||
byte[] Leaktop = parmLeaktoplimit.ToArray();
|
||||
Form1.f1.modbusClient.Write("1021", Leaktop);
|
||||
Form1.f1.CH1.Write("38", Leaktop);
|
||||
|
||||
List<byte> parmLeaklowlimit = new List<byte>();//泄露量下限
|
||||
parmLeaklowlimit.AddRange(XdrFloat(Convert.ToSingle(Leaklowlimit.Text)));
|
||||
byte[] Leaklow = parmLeaklowlimit.ToArray();
|
||||
Form1.f1.modbusClient.Write("1023", Leaklow);
|
||||
Form1.f1.CH1.Write("44", Leaklow);
|
||||
|
||||
//单位
|
||||
ushort punit1 = Convert.ToUInt16(PUnit.SelectedIndex);
|
||||
ushort lunit1 = Convert.ToUInt16(LUnit.SelectedIndex);
|
||||
Form1.f1.modbusClient.Write("1027", punit1);
|
||||
operateResult= Form1.f1.modbusClient.Write("1028", lunit1);
|
||||
Form1.f1.CH1.Write("41", punit1);
|
||||
Form1.f1.CH1.Write("40", lunit1);
|
||||
|
||||
|
||||
if (operateResult.IsSuccess)
|
||||
{
|
||||
MessageBox.Show("上传参数成功");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("上传参数失败,请检查连接状态后重新上传");
|
||||
|
||||
}
|
||||
Form1.f1.CH1.WriteCoil("36", true);
|
||||
Thread.Sleep(500);
|
||||
Form1.f1.CH1.WriteCoil("38", true);
|
||||
Thread.Sleep(500);
|
||||
Form1.f1.CH1.WriteCoil("36", false);
|
||||
Thread.Sleep(500);
|
||||
Form1.f1.CH1.WriteCoil("38", false);
|
||||
Thread.Sleep(500);
|
||||
//Delay(1);
|
||||
MessageBox.Show("上传参数成功");
|
||||
BtnUpload.Text = "上传参数";
|
||||
BtnUpload.ForeColor = Color.Black;
|
||||
BtnUpload.Enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,14 +279,7 @@ namespace C_Windows_1
|
||||
try
|
||||
{
|
||||
Parameters();
|
||||
if (Form1.f1.modbusClient.Read("1006", (ushort)1).IsSuccess)
|
||||
{
|
||||
MessageBox.Show("参数读取成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("参数读取失败");
|
||||
}
|
||||
MessageBox.Show("参数读取成功");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -307,7 +292,7 @@ namespace C_Windows_1
|
||||
try
|
||||
{
|
||||
OperateResult<bool> reslutget;
|
||||
reslutget = Form1.f1.modbusClient.ReadBool(Convert.ToString(sta));
|
||||
reslutget = Form1.f1.CH1.ReadBool(Convert.ToString(sta));
|
||||
if (reslutget.IsSuccess == true)
|
||||
{
|
||||
if (reslutget.Content == true)
|
||||
@@ -343,43 +328,47 @@ namespace C_Windows_1
|
||||
|
||||
public void Parameters()
|
||||
{
|
||||
Form1.f1.Modbusread(1006, 7, Form1.ReadData);
|
||||
Form1.f1.Modbusread(1013, 16, Form1.ReadData);
|
||||
|
||||
FullTime.Text = ((Form1.ReadData[1006] / 10).ToString());
|
||||
BalanTime.Text = ((Form1.ReadData[1007] / 10).ToString());
|
||||
TestTime1.Text = (Form1.ReadData[1008] / 10).ToString();
|
||||
//TestTime2.Text = ((Form1.ReadData[48] / 10).ToString());
|
||||
ExhaustTime.Text = (Form1.ReadData[1009] / 10).ToString();
|
||||
//BypassTime.Text = (Form1.ReadData[29] / 10).ToString();
|
||||
DelayTime1.Text = (Form1.ReadData[1011] / 10).ToString();
|
||||
DelayTime2.Text = ((Form1.ReadData[1012] / 10).ToString());
|
||||
Evolume.Text = Form1.TwoUInt16ToFloat(Form1.ReadData[1026], Form1.ReadData[1025]).ToString();
|
||||
Form1.f1.Modbusread(25, 24, Form1.ReadData);
|
||||
Form1.f1.Modbusread(604, 2, Form1.ReadData);
|
||||
Booltomath(604, Form1.ReadData);
|
||||
Booltomath(605, Form1.ReadData);
|
||||
FullTime.Text = ((Form1.ReadData[25] / 10).ToString());
|
||||
BalanTime.Text = ((Form1.ReadData[34] / 10).ToString());
|
||||
TestTime1.Text = (Form1.ReadData[27] / 10).ToString();
|
||||
TestTime2.Text = ((Form1.ReadData[48] / 10).ToString());
|
||||
ExhaustTime.Text = (Form1.ReadData[28] / 10).ToString();
|
||||
BypassTime.Text = (Form1.ReadData[29] / 10).ToString();
|
||||
DelayTime1.Text = (Form1.ReadData[30] / 10).ToString();
|
||||
DelayTime2.Text = ((Form1.ReadData[31] / 10).ToString());
|
||||
Evolume.Text = Form1.TwoUInt16ToFloat(Form1.ReadData[43], Form1.ReadData[42]).ToString();
|
||||
//参数名称
|
||||
//ParaName.Text =
|
||||
FPtoplimit.Text = Form1.TwoUInt16ToFloat(Form1.ReadData[1014], Form1.ReadData[1013]).ToString();
|
||||
FPlowlimit.Text = Form1.TwoUInt16ToFloat(Form1.ReadData[1016], Form1.ReadData[1015]).ToString();
|
||||
//BBalanTime.Text = ((Form1.ReadData[34] / 10).ToString());
|
||||
//SBalanTime.Text = ((Form1.ReadData[35] / 10).ToString());
|
||||
BLeakTPre.Text = Form1.TwoUInt16ToFloat(Form1.ReadData[1018], Form1.ReadData[1017]).ToString();
|
||||
BLeakLPre.Text = Form1.TwoUInt16ToFloat(Form1.ReadData[1020], Form1.ReadData[1019]).ToString();
|
||||
Leaktoplimit.Text = Form1.TwoUInt16ToFloat(Form1.ReadData[1022], Form1.ReadData[1021]).ToString();
|
||||
Leaklowlimit.Text = Form1.TwoUInt16ToFloat(Form1.ReadData[1024], Form1.ReadData[1023]).ToString();
|
||||
PUnit.SelectedIndex = Form1.ReadData[1027];
|
||||
LUnit.SelectedIndex = Form1.ReadData[1028];
|
||||
label24.Text = PUnit.Text;
|
||||
label25.Text = PUnit.Text;
|
||||
label28.Text = LUnit.Text;
|
||||
label29.Text = LUnit.Text;
|
||||
|
||||
|
||||
FPtoplimit.Text = Form1.TwoUInt16ToFloat(Form1.ReadData[33], Form1.ReadData[32]).ToString();
|
||||
FPlowlimit.Text = Form1.TwoUInt16ToFloat(Form1.ReadData[47], Form1.ReadData[46]).ToString();
|
||||
BBalanTime.Text = ((Form1.ReadData[34] / 10).ToString());
|
||||
SBalanTime.Text = ((Form1.ReadData[35] / 10).ToString());
|
||||
BLeakTPre.Text = ((Form1.ReadData[36]).ToString());
|
||||
BLeakLPre.Text = ((Digitalconversion(Form1.ReadData[37])).ToString());
|
||||
Leaktoplimit.Text = Form1.TwoUInt16ToFloat(Form1.ReadData[39], Form1.ReadData[38]).ToString();
|
||||
Leaklowlimit.Text = Form1.TwoUInt16ToFloat(Form1.ReadData[45], Form1.ReadData[44]).ToString();
|
||||
PUnit.SelectedIndex = Form1.ReadData[41];
|
||||
LUnit.SelectedIndex = Form1.ReadData[40];
|
||||
label24.Text=label25.Text=PUnit.Text;
|
||||
label28.Text=label29.Text=LUnit.Text;
|
||||
if (Form1.ReadData[604] == 1)
|
||||
{
|
||||
Test_Type.SelectedIndex = 0;
|
||||
}
|
||||
if (Form1.ReadData[605] == 1)
|
||||
{
|
||||
Test_Type.SelectedIndex = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void BtnKeep_Click(object sender, EventArgs e)
|
||||
{
|
||||
int i = Convert.ToInt32(ParaNum.Text);
|
||||
SetParameters(i);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -791,10 +780,10 @@ namespace C_Windows_1
|
||||
{
|
||||
if (Test_Type.SelectedIndex == 0)
|
||||
{
|
||||
operateResult1 = Form1.f1.CH1.Write("605", false);
|
||||
operateResult1 = Form1.f1.CH1.WriteCoil("605", false);
|
||||
if (operateResult1.IsSuccess)
|
||||
{
|
||||
Form1.f1.CH1.Write("604", true);
|
||||
Form1.f1.CH1.WriteCoil("604", true);
|
||||
}
|
||||
|
||||
//SendText.Text = Form1.f1.Station.Text + " 05 02 5D 00 00 ";//关闭负压
|
||||
@@ -805,18 +794,18 @@ namespace C_Windows_1
|
||||
}
|
||||
if (Test_Type.SelectedIndex == 1)
|
||||
{
|
||||
operateResult2 = Form1.f1.CH1.Write("604", false);
|
||||
operateResult2 = Form1.f1.CH1.WriteCoil("604", false);
|
||||
if (operateResult2.IsSuccess)
|
||||
{
|
||||
Form1.f1.CH1.Write("605", true);
|
||||
Form1.f1.CH1.WriteCoil("605", true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
operateResult3 = Form1.f1.CH1.Write("605", false);
|
||||
operateResult3 = Form1.f1.CH1.WriteCoil("605", false);
|
||||
if (operateResult3.IsSuccess)
|
||||
{
|
||||
Form1.f1.CH1.Write("604", true);
|
||||
Form1.f1.CH1.WriteCoil("604", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -825,10 +814,10 @@ namespace C_Windows_1
|
||||
Form1.f1.CH1.Open();
|
||||
if (Test_Type.SelectedIndex == 0)
|
||||
{
|
||||
operateResult4 = Form1.f1.CH1.Write("605", false);
|
||||
operateResult4 = Form1.f1.CH1.WriteCoil("605", false);
|
||||
if (operateResult4.IsSuccess)
|
||||
{
|
||||
Form1.f1.CH1.Write("604", true);
|
||||
Form1.f1.CH1.WriteCoil("604", true);
|
||||
}
|
||||
|
||||
//SendText.Text = Form1.f1.Station.Text + " 05 02 5D 00 00 ";//关闭负压
|
||||
@@ -839,10 +828,10 @@ namespace C_Windows_1
|
||||
}
|
||||
if (Test_Type.SelectedIndex == 1)
|
||||
{
|
||||
operateResult24 = Form1.f1.CH1.Write("604", false);
|
||||
operateResult24 = Form1.f1.CH1.WriteCoil("604", false);
|
||||
if (operateResult24.IsSuccess)
|
||||
{
|
||||
Form1.f1.CH1.Write("605", true);
|
||||
Form1.f1.CH1.WriteCoil("605", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user