Files
LL-28/SLC1-N/LeakCompensate.cs
moxiliang 7065cad6d7 251024
2025-10-24 14:08:41 +08:00

162 lines
6.9 KiB
C#

using System;
using System.Linq;
using System.Windows.Forms;
namespace SLC1_N
{
public partial class LeakCompensate : Form
{
public LeakCompensate()
{
InitializeComponent();
}
private void LeakCompensate_Load(object sender, EventArgs e)
{
//string dialog = Form1.f1.machine;
//ConfigINI config = new ConfigINI("Model", dialog);
//CH1LeakCompe.Text = config.IniReadValue("Compensate", "CH1LeakCompe");
//CH2LeakCompe.Text = config.IniReadValue("Compensate", "CH2LeakCompe");
//CH1PreCompensation.Text = config.IniReadValue("Compensate", "CH1PreCompensation");
//CH2PreCompensation.Text = config.IniReadValue("Compensate", "CH2PreCompensation");
//string chkcompe = config.IniReadValue("Compensate", "CHKLeakCompe");
//if (String.IsNullOrEmpty(chkcompe))
//{
// CHKCompe.Checked = false;
//}
//else
//{
// CHKCompe.Checked = Convert.ToBoolean(chkcompe);
//}
}
private void Save_Click(object sender, EventArgs e)
{
if (CH1LeakCompe.Text.Length > 0)
{
//Form1.f1.CH1IsRun.Stop();
byte[] leak_comp = BitConverter.GetBytes(Convert.ToSingle(CH1LeakCompe.Text));
string str_leakcomp = BitConverter.ToString(leak_comp.Reverse().ToArray()).Replace("-", "");
string ch1hex_leakcomp = str_leakcomp.Substring(4, 4) + str_leakcomp.Substring(0, 4);
//SendText.Text = "";
//SendText.Text += hex_presscomp;
//switch (MachineNum.SelectedIndex)
//{
// case 0:
string ch1sendstr = "01 10 04 3E 00 02 04" + ch1hex_leakcomp;
//Form1.f1.left_ch1tcp.ClientSendMsgAsync(ch1sendstr);
//Form1.f1.ch1client.btnSendData(ch1sendstr);
//Form1.f1.ch1stage = 10;
//Form1.f1.CH1IsRun.Interval = 1000;
//Form1.f1.CH1IsRun.Start();
//Form1.f1.ch1stage = 1;
//Form1.f1.ch1readpara = true;
}
if (CH2LeakCompe.Text.Length > 0)
{
//Form1.f1.CH2IsRun.Stop();
// break;
//case 1:
byte[] leak_comp2 = BitConverter.GetBytes(Convert.ToSingle(CH2LeakCompe.Text));
string str_leakcomp2 = BitConverter.ToString(leak_comp2.Reverse().ToArray()).Replace("-", "");
string ch2hex_leakcomp = str_leakcomp2.Substring(4, 4) + str_leakcomp2.Substring(0, 4);
string ch2sendstr = "02 10 04 3E 00 02 04" + ch2hex_leakcomp;
//Form1.f1.left_ch2tcp.ClientSendMsgAsync(ch2sendstr);
//Form1.f1.ch2client.btnSendData(ch2sendstr);
//Form1.f1.ch2stage = 10;
//Form1.f1.CH2IsRun.Interval = 1000;
//Form1.f1.CH2IsRun.Start();
//Form1.f1.ch2stage = 1;
//Form1.f1.ch2readpara = true;
}
SetLeakCompen();
}
/// <summary>
/// 写入泄漏补偿
/// </summary>
/// <param name="CH"></param>
private void SetLeakCompen()
{
//if (String.IsNullOrEmpty(CH1LeakCompe.Text))
//{
// Form1.f1.CH1LeakCompe = 0;
//}
//else
//{
// Form1.f1.CH1LeakCompe = Convert.ToDouble(CH1LeakCompe.Text);
//}
//if (String.IsNullOrEmpty(CH2LeakCompe.Text))
//{
// Form1.f1.CH2LeakCompe = 0;
//}
//else
//{
// Form1.f1.CH2LeakCompe = Convert.ToDouble(CH2LeakCompe.Text);
//}
//Form1.f1.CHKLeakCompe = CHKCompe.Checked;
//string dialog = Form1.f1.machine;
//ConfigINI mesconfig = new ConfigINI("Model", dialog);
//mesconfig.IniWriteValue("Compensate", "CH1LeakCompe", CH1LeakCompe.Text);
////mesconfig.IniWriteValue("Compensate", "CHKLeakCompe", CHKCompe.Checked.ToString());
//mesconfig.IniWriteValue("Compensate", "CH2LeakCompe", CH2LeakCompe.Text);
}
private void Compensation_Click(object sender, EventArgs e)
{
if (CH1PreCompensation.Text.Length > 0)
{
//Form1.f1.CH1IsRun.Stop();
byte[] press_comp = BitConverter.GetBytes(Convert.ToSingle(CH1PreCompensation.Text));
string str_presscomp = BitConverter.ToString(press_comp.Reverse().ToArray()).Replace("-", "");
string ch1hex_presscomp = str_presscomp.Substring(4, 4) + str_presscomp.Substring(0, 4);
//SendText.Text = "";
//SendText.Text += hex_presscomp;
//switch (MachineNum.SelectedIndex)
//{
// case 0:
string ch1sendstr = "01 10 04 05 00 02 04" + ch1hex_presscomp;
//Form1.f1.left_ch1tcp.ClientSendMsgAsync(ch1sendstr);
//Form1.f1.ch1client.btnSendData(ch1sendstr);
//Form1.f1.ch1stage = 10;
//Form1.f1.CH1IsRun.Interval = 1000;
//Form1.f1.CH1IsRun.Start();
//Form1.f1.ch1stage = 1;
//Form1.f1.ch1readpara = true;
}
if (CH2PreCompensation.Text.Length > 0)
{
//Form1.f1.CH2IsRun.Stop();
// break;
//case 1:
byte[] press_comp2 = BitConverter.GetBytes(Convert.ToSingle(CH2PreCompensation.Text));
string str_presscomp2 = BitConverter.ToString(press_comp2.Reverse().ToArray()).Replace("-", "");
string ch2hex_presscomp = str_presscomp2.Substring(4, 4) + str_presscomp2.Substring(0, 4);
string ch2sendstr = "02 10 04 05 00 02 04" + ch2hex_presscomp;
//Form1.f1.left_ch2tcp.ClientSendMsgAsync(ch2sendstr);
//Form1.f1.ch2client.btnSendData(ch2sendstr);
//Form1.f1.ch2stage = 10;
//Form1.f1.CH2IsRun.Interval = 1000;
//Form1.f1.CH2IsRun.Start();
//Form1.f1.ch2stage = 1;
//Form1.f1.ch2readpara = true;
}
SetPressCompen();
// break;
//}
}
/// <summary>
/// 写入压力补偿
/// </summary>
/// <param name="CH"></param>
private void SetPressCompen()
{
//string dialog = Form1.f1.machine;
//ConfigINI mesconfig = new ConfigINI("Model", dialog);
//mesconfig.IniWriteValue("Compensate", "CH1presscompensation", CH1PreCompensation.Text);
//mesconfig.IniWriteValue("Compensate", "CH2presscompensation", CH2PreCompensation.Text);
}
}
}