STC-单片机控制系统

时间:2023-03-08 16:30:20

电源测量命令

60V开 FD020600010101000000
60V关 FD020600020101000000
60V保开
60V保关

-8KV开
-8KV关 FD020928020102010000
-0-2000 FD0209180001020126dc
-2-4000 FD020910000102011b4f
-4-8000 FD020911000102011473

+8KV开 FD020918010001010000
+8KV关 FD020918020101010000
+0-2000 FD0209180001010114cd
+2-4000 FD020910000101013116
+4-8000 FD020911000101012fca

-16KV开 FD020B00010100020000
-16KV关 FD020B00020100020000
-0-8K
-8-130K
-1-160K

模拟设置
FD0103180001010100005C46AA //U14 - 聚焦电源一组 第一段
FD010310000101010000D586AA //U14 - 聚焦电源一组 第二段
FD010311000101010000C546AA //U14 - 聚焦电源一组 第三段

FD0103280001010100006C45AA //U13 - 聚焦电源二组 第一段
FD010320000101010000E585AA //U13 - 聚焦电源二组 第二段
FD010321000101010000F545AA //U13 - 聚焦电源二组 第三段

FD010418000101010000A01DAA //U14 - 预聚焦电源一组 第一段
FD0104100001010100006094AA //U14 - 预聚焦电源一组 第二段
FD01041100010101000084A0AA //U14 - 预聚焦电源一组 第三段

FD0104280001010100002DA3AA //U13 - 预聚焦电源二组 第一段
FD010420000101010000A463AA //U13 - 预聚焦电源二组 第二段
FD010421000101010000B4A3AA //U13 - 预聚焦电源二组 第三段

FD0104380001010100003C62AA //U13 - 预聚焦电源三组 第一段
FD010430000101010000B5A2AA //U13 - 预聚焦电源三组 第二段
FD010431000101010000A562AA //U13 - 预聚焦电源三组 第三段

数字量查询
FD010210000401010000D84AAA //U14 - 引出极 电压
FD010210000401020000284AAA //U14 - 引出极 电流

FD0103180004010100009046AA //U14 - 聚焦电源一组 电压
FD0103180004010200006046AA //U14 - 聚焦电源一组 电流
FD010328000401010000A045AA //U13 - 聚焦电源二组 电压
FD0103280004010200005045AA //U13 - 聚焦电源二组 电流

FD010418000401010000D1A0AA //U14 - 预聚焦电源一组 电压
FD01041800040102000021A0AA //U14 - 预聚焦电源一组 电流
FD010428000401010000E1A3AA //U13 - 预聚焦电源二组 电压
FD01042800040102000011A3AA //U13 - 预聚焦电源二组 电流
FD010438000401010000F062AA //U13 - 预聚焦电源三组 电压
FD0104380004010200000062AA //U13 - 预聚焦电源三组 电流

FD01051000040101000099ACAA //U14 - 脉冲输出电源 5KV 电压
FD01051000040102000069ACAA //U14 - 脉冲输出电源 5KV 电流

FD010610000401010000D9B9AA //U13- 60V整流电源 电压
FD01061000040102000029B9AA //U13 - 60V整流电源 电流

FD0108100004010100005835AA //U13 - 热丝电源 10V 电压
FD010810000401020000A835AA //U13 - 热丝电源 10V 电流

开关控制

FD010110010401010000998EAA //U13 - 抑制极+1KV电源开
FD01011002040102000069BDAA //U13 - 抑制极+1KV电源关
FD01011001040201000099CAAA //U13 - 抑制极-1KV电源开
FD01011002040202000069F9AA //U13 - 抑制极-1KV电源关

FD010210010401010000D99BAA //LPC - 引出极+5KV电源开
FD01021002040102000029A8AA //LPC - 引出极+5KV电源关

FD0103180104010100009197AA //U14 - 聚焦电源一组 开
FD01031802040102000061A4AA //U14 - 聚焦电源一组 关
FD010328010401010000A194AA //U13 - 聚焦电源二组 开
FD01032802040102000051A7AA //U13 - 聚焦电源二组 关

FD010418010401010000D071AA //U14 - 预聚焦电源一组 开
FD0104180204010200002042AA //U14 - 预聚焦电源一组 关
FD010428010401010000E072AA //U13 - 预聚焦电源二组 开
FD0104280204010200001041AA //U13 - 预聚焦电源二组 关
FD010438010401010000F1B3AA //U13 - 预聚焦电源三组 开
FD0104380204010200000180AA //U13 - 预聚焦电源三组 关

FD010510010401010000987DAA //U14 - 脉冲输出电源 5KV 开
FD010510020401020000684EAA //U14 - 脉冲输出电源 5KV 关

FD010610010401010000D868AA //U13- 60V整流电源 开 由控制箱控制
FD010610020401020000285BAA //U13 - 60V整流电源 关

FD01081001040101000059E4AA //U13 - 热丝电源 10V 开
FD010810020401020000A9D7AA //U13 - 热丝电源 10V 关

电流电压显示
FD010118000201010000999FAA //U14 - 抑制极+1KV电源电压显示
FD01011800020202000069DBAA //U13 - 抑制极-1KV电源电流显示
FD01011800020201000099DBAA //U13 - 抑制极-1KV电源过压显示

FD010218000201010000D98AAA //U14 - 引出极 +5KV电压
FD010218000201020000298AAA //U14 - 引出极 +5KV电流

FD0103180002010100001846AA //U14 - 聚焦电源一组 电压
FD010318000201020000E846AA //U14 - 聚焦电源一组 电流
FD0103280002010100002845AA //U13 - 聚焦电源二组 电压
FD010328000201020000D845AA //U13 - 聚焦电源二组 电流

FD01041800020101000059A0AA //U14 - 预聚焦电源一组 电压
FD010418000201020000A9A0AA //U14 - 预聚焦电源一组 电流
FD01042800020101000069A3AA //U13 - 预聚焦电源二组 电压
FD01042800020102000099A3AA //U13 - 预聚焦电源二组 电流
FD0104380002010100007862AA //U13 - 预聚焦电源三组 电压
FD0104380002010200008862AA //U13 - 预聚焦电源三组 电流

FD01051000020101000011ACAA //U14 - 脉冲输出电源 5KV 电压
FD010510000201020000E1ACAA //U14 - 脉冲输出电源 5KV 电流

FD01061000020101000051B9AA //U13- 60V整流电源 电压
FD010610000201020000A1B9AA //U13 - 60V整流电源 电流

FD010810000201010000D035AA //U13 - 热丝电源 10V 电压
FD0108100002010200002035AA //U13 - 热丝电源 10V 电流

使用到的串口调试工具

1.CRC_16校验程序(好!不分大小写)

2.STC_ISP_V480.exe

3.串口调试工具SSCOM32.exe

4.电源协议E.doc

5.技术文件67.doc

注意:此处技术文件为保密文件,此处就不提供出来了,还请谅解。

不闲扯,直接替源码,如下所示:

 using System;
using System.Drawing;
using System.IO.Ports;
using System.Threading;
using System.Windows.Forms; namespace CDCurrentControl.UI
{
public class BaseForm : Form
{
protected readonly string redPath = Application.StartupPath + @"\Images\红色.png";
protected readonly string greenPath = Application.StartupPath + @"\Images\绿色.png";
protected readonly string whitePath = Application.StartupPath + @"\Images\白色.png";
protected readonly SerialPort sp = new SerialPort(); #region 发送协议
/// <summary>
/// 发送协议
/// </summary>
/// <param name="str"></param>
public void SendAgreement(string str)
{
if (sp.IsOpen)
{
//TxtAllAgreement.Text += str;
Byte[] sendstrs = BLL.ZhuanHuan.GetByte(str);
sp.Write(sendstrs, , sendstrs.Length);
Thread.Sleep();
}
} #endregion /// <summary>
/// 清除所有文本框的值
/// </summary>
protected void ClearAllTextBox()
{
foreach (Control c in Controls)
{
if (c is TextBox)
{
c.Text = string.Empty;
}
}
} /// <summary>
/// 输入验证
/// </summary>
/// <param name="tb"></param>
/// <param name="min"></param>
/// <param name="max"></param>
/// <returns></returns>
public bool ValidateString(TextBox tb, double min, double max)
{
try
{
double zhi = Convert.ToDouble(tb.Text.Trim());
if (zhi < min || zhi > max)
{
MessageBox.Show("请输入" + min + "-" + max + "之间的电压");
return false;
}
return true;
}
catch
{
MessageBox.Show("请输入正确的数字");
return false;
}
} public void SetPicGreen(PictureBox image)
{
image.Image = Image.FromFile(greenPath);
} public void SetPicRed(PictureBox image)
{
image.Image = Image.FromFile(redPath);
} public void SetPicWhite(PictureBox image)
{
image.Image = Image.FromFile(whitePath);
} public void ClearText(TextBox t1, TextBox t2, TextBox t3, TextBox t4, TextBox t5)
{
while (true)
{
Thread.Sleep();
if (t1.Text == "" && t2.Text == "" && t3.Text == "" && t4.Text == "" && t5.Text == "")
{
break;
}
t1.Text = "";
t2.Text = "";
t3.Text = "";
t4.Text = "";
t5.Text = "";
} }
public void ClearText(TextBox t1, TextBox t2, TextBox t3, TextBox t4)
{ while (true)
{
Thread.Sleep();
if (t1.Text == "" && t2.Text == "" && t3.Text == "" && t4.Text == "")
{
break;
}
t1.Text = "";
t2.Text = "";
t3.Text = "";
t4.Text = "";
} }
}
}

BaseForm

 using System;
using System.Drawing;
using System.Windows.Forms; namespace CDCurrentControl.UI
{
public partial class frmMain : BaseForm
{
readonly RFD_Form rfd = new RFD_Form();
readonly CFS_Form cfs = new CFS_Form();
readonly CeS_Form csf = new CeS_Form();
readonly Point p = new Point();
int count = ;
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000;
return cp;
}
}
public frmMain()
{ p.X = ;
p.Y = ;
InitializeComponent(); }
/// <summary>
/// 热发电d
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void lblRFD_Click(object sender, EventArgs e)
{
cfs.Hide();
csf.Hide();
rfd.MdiParent = this;
rfd.Show();
rfd.Location = p; lblRFD.ImageIndex = ;
lblCFD.ImageIndex = ;
lblCS.ImageIndex = ;
}
/// <summary>
/// 场发射
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void lblCFD_Click(object sender, EventArgs e)
{
rfd.Hide();
csf.Hide();
cfs.MdiParent = this;
cfs.Show();
cfs.Location = p; lblRFD.ImageIndex = ;
lblCFD.ImageIndex = ;
lblCS.ImageIndex = ;
} /// <summary>
/// 测试
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void lblCS_Click(object sender, EventArgs e)
{
if (count == )
{
rfd.Hide();
cfs.Hide();
csf.MdiParent = this;
csf.Show();
csf.Location = p; lblRFD.ImageIndex = ;
lblCFD.ImageIndex = ;
lblCS.ImageIndex = ;
}
else
{
frmLogin fl = new frmLogin();
if (fl.ShowDialog() == DialogResult.OK)
{
TextBox tb = fl.Controls["txtName"] as TextBox;
if (tb.Text == "正确")
{
rfd.Hide();
cfs.Hide();
csf.MdiParent = this;
csf.Show();
csf.Location = p; count = ;
lblRFD.ImageIndex = ;
lblCFD.ImageIndex = ;
lblCS.ImageIndex = ;
}
else
{
lblCS_Click(sender, e); }
}
} } private void frmMain_Resize(object sender, EventArgs e)
{
int kuan = Width - ;
int gao = Height - panel1.Height - ; cfs.Width = kuan;
cfs.Height = gao;
rfd.Width = kuan;
rfd.Height = gao;
csf.Width = kuan;
csf.Height = gao;
} private void label1_Click(object sender, EventArgs e)
{
frmSJJY fs = new frmSJJY();
fs.Show();
} private void frmMain_Load(object sender, EventArgs e)
{
new BLL.SJJY().NewJiaZai();
}
}
}

frmMain

 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
using ZedGraph;
using System.Threading;
using CDCurrentControl.Model; namespace CDCurrentControl.UI {
public partial class RFD_Form : Form {
frmClose fc = new frmClose();
List<Thread> ltr = new List<Thread>();//线程
bool ZF = true;
string gy = "";
string zgy = "";//主高压初始片选
string pza = "";//偏转正初始片选
string pzb = "";//偏转负初始片选
string jja = "";//聚集极一初始片选
string jjb = "";//聚集极二初始片选
string yjja = "";//预聚集极一初始片选
string yjjb = "";//预聚集极二初始片选
string yjc = "";//预聚集极三初始片选
double jjbs = ;//聚集二设置前的值
double jjas = ;//聚集一设置前的值
double yjjas = ;//预聚集一设置前的值
double yjjbs = ;//预聚集二设置前的值
double yjjcs = ;//预聚集三设置前的值
double pzas = ;//偏转正设置前的值
double pzbs = ;//偏转负设置前的值
double zgys = ;//主高压设置前的值
double rss = ;
int count = ;
System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();//热丝电源等待时间加引出极
List<Dictionary<int, CheckBox>> cbos = new List<Dictionary<int, CheckBox>>();//check按钮
List<Button> btns = new List<Button>();//button按钮
SerialPort sp = new SerialPort();
PointPairList listzgy = new PointPairList();
LineItem myCurvezgy;
PointPairList listyzj = new PointPairList();
LineItem myCurveyzj;
PointPairList listycj = new PointPairList();
LineItem myCurveycj;
PointPairList listjja = new PointPairList();
LineItem myCurvejja;
PointPairList listjjb = new PointPairList();
LineItem myCurvejjb;
PointPairList listyjja = new PointPairList();
LineItem myCurveyjja;
PointPairList listyjjb = new PointPairList();
LineItem myCurveyjjb;
PointPairList listyjjc = new PointPairList();
LineItem myCurveyjjc;
PointPairList listymc = new PointPairList();
LineItem myCurveymc;
PointPairList listzl = new PointPairList();
LineItem myCurvezl;
PointPairList listrs = new PointPairList();
LineItem myCurvers;
PointPairList listpza = new PointPairList();
LineItem myCurvepza;
PointPairList listpzb = new PointPairList();
LineItem myCurvepzb;
bool b = false;
List<byte[]> js = new List<byte[]>();
List<List<string>> ss = new List<List<string>>();
readonly string whitePath = Application.StartupPath + @"\Images\白色.png";
readonly string redPath = Application.StartupPath + @"\Images\红色.png";
readonly string greenPath = Application.StartupPath + @"\Images\绿色.png";
public RFD_Form() {
InitializeComponent();
zedGraph zg = new zedGraph();
zg.JiaZai(this.zgcZGYDY, "主高压电源");
zg.JiaZai(this.zgcYZJDY, "抑制极电源");
zg.JiaZai(this.zgcYCJDY, "引出极电源");
zg.JiaZai(this.zgcJJDYA, "聚焦电源一");
zg.JiaZai(this.zgcJJDYB, "聚焦电源二");
zg.JiaZai(this.zgcYJJDYA, "预聚焦电源一");
zg.JiaZai(this.zgcYJJDYB, "预聚焦电源二");
zg.JiaZai(this.zgcYJJDYC, "预聚焦电源三");
zg.JiaZai(this.zgcZLDY, "60V整流电源");
zg.JiaZai(this.zgcRSDY, "热丝电源");
zg.JiaZai(this.zgcMCSCDYA, "脉冲电源");
zg.JiaZai(this.zgcPZDYA, "偏转电源一");
zg.JiaZai(this.zgcPZDYB, "偏转电源二");
CheckBox[] cbo = new CheckBox[] { cboZGY, cboYZJ, cboYCJ, cboJJA, cboJJB, cboYJJA, cboYJJB, cboYJJC, cboMC, cboZL, cboRS, cboPZ };
Button[] b = new Button[] { button11, button1, button2, button36, button41, button5, button23, button29, button8, button9, button10, button4 };
btns.AddRange(b);
for (int i = ; i < ; i++) {
Dictionary<int, CheckBox> c = new Dictionary<int, CheckBox>();
c.Add(i, cbo[i]);
cbos.Add(c);
} }
//重复读取数据
void NewXianCheng() {
do { if (sp.IsOpen) { if (count > ) {
#region MyRegion
// 整流
if (this.button9.Text == "断电") {
string gy = "FD010610000401010000";
string gl = "FD010610000401020000";
chuansong(gy);
shuchu(xianshi());
chuansong(gl);
shuchu(xianshi());
string str = "FD010618000201010000";
chuansong(str);
shuchu(xianshi());
string strs = "FD010618000201020000";
chuansong(strs);
shuchu(xianshi()); }
//抑制极
if (this.button1.Text == "断电") {
string str = "";
string strs = "";
string gl = "";
string gy = ""; //正
if (ZF) { str = "FD010118000201010000";
strs = "FD010118000201020000";
gy = "FD010110000401010000";
chuansong(gy);
shuchu(xianshi()); }
//负
else { str = "FD010118000202010000";
strs = "FD010118000202020000";
gl = "FD010110000402020000";
chuansong(gl);
shuchu(xianshi()); }
chuansong(strs);
shuchu(xianshi());
chuansong(str);
shuchu(xianshi()); }
//脉冲A
if (button8.Text == "断电") {
string gy = "FD010510000401010000";
string gl = "FD010510000401020000";
chuansong(gy);
shuchu(xianshi());
chuansong(gl);
shuchu(xianshi());
string str = "FD010510000201010000";
string strs = "FD010510000201020000";
chuansong(str);
shuchu(xianshi());
chuansong(strs);
shuchu(xianshi()); }
//聚焦一
if (button36.Text == "断电") {
string gy = "FD0103" + jja + "";
string gl = "FD0103" + jja + "";
chuansong(gy);
shuchu(xianshi());
chuansong(gl);
shuchu(xianshi());
string str = "FD0103" + jja + "";
string strs = "FD0103" + jja + "";
chuansong(str);
shuchu(xianshi());
chuansong(strs);
shuchu(xianshi()); }
//聚焦二
if (button41.Text == "断电") {
string gy = "FD0103" + jjb + "";
string gl = "FD0103" + jjb + "";
chuansong(gy);
shuchu(xianshi());
chuansong(gl);
shuchu(xianshi());
string str = "FD0103" + jjb + "";
string strs = "FD0103" + jjb + "";
chuansong(str);
shuchu(xianshi()); chuansong(strs);
shuchu(xianshi()); }
//预聚焦一
if (button5.Text == "断电") {
string gy = "FD0104" + yjja + "";
string gl = "FD0104" + yjja + "";
chuansong(gy);
shuchu(xianshi());
chuansong(gl);
shuchu(xianshi());
string str = "FD0104" + yjja + "";
string strs = "FD0104" + yjja + "";
chuansong(str);
shuchu(xianshi()); chuansong(strs);
shuchu(xianshi()); }
//预聚焦二
if (button23.Text == "断电") {
string gy = "FD0104" + yjjb + "";
string gl = "FD0104" + yjjb + "";
chuansong(gy);
shuchu(xianshi());
chuansong(gl);
shuchu(xianshi());
string str = "FD0104" + yjjb + "";
string strs = "FD0104" + yjjb + "";
chuansong(str);
shuchu(xianshi());
chuansong(strs);
shuchu(xianshi()); }
//预聚焦三
if (button29.Text == "断电") {
string gy = "FD0104" + yjc + "";
string gl = "FD0104" + yjc + "";
chuansong(gy);
shuchu(xianshi());
chuansong(gl);
shuchu(xianshi());
string str = "FD0104" + yjc + "";
string strs = "FD0104" + yjc + "";
chuansong(str);
shuchu(xianshi());
chuansong(strs);
shuchu(xianshi());
}
//主高压
if (button11.Text == "断电") {
string gl = "FD020B" + zgy + "";
chuansong(gl);
shuchu(xianshi());
string gy = "FD020B" + zgy + "";
chuansong(gy);
shuchu(xianshi());
string str = "FD020B" + zgy + "";
string strs = "FD020B" + zgy + "";
chuansong(str);
shuchu(xianshi());
chuansong(strs);
shuchu(xianshi());
}
//偏转正
if (this.button4.Text == "断电") {
string gl = "FD0209" + pza + "";
chuansong(gl);
shuchu(xianshi());
string gy = "FD0209" + pza + "";
chuansong(gy);
shuchu(xianshi());
string str2 = "FD0209" + pza + "";
chuansong(str2);
shuchu(xianshi());
string strs = "FD0209" + pza + "";
chuansong(strs);
shuchu(xianshi());
string gl2 = "FD0209" + pzb + "";
chuansong(gl2);
shuchu(xianshi());
string gy2 = "FD0209" + pzb + "";
chuansong(gy2);
shuchu(xianshi());
string str = "FD0209" + pzb + "";
string strs2 = "FD0209" + pzb + "";
chuansong(str);
shuchu(xianshi());
chuansong(strs2);
shuchu(xianshi());
}
//引出极
if (this.button2.Text == "断电") {
string gl = "FD010210000401020000";
chuansong(gl);
shuchu(xianshi());
string gy = "FD010210000401010000";
chuansong(gy);
shuchu(xianshi());
string str = "FD010218000201010000";
chuansong(str);
shuchu(xianshi());
string strs = "FD010218000201020000";
chuansong(strs);
shuchu(xianshi()); } //热丝
if (this.button10.Text == "断电") {
string gy = "FD010810000401010000";
string gl = "FD010810000401020000";
chuansong(gy);
shuchu(xianshi());
chuansong(gl);
shuchu(xianshi());
string str = "FD010818000201010000";
chuansong(str);
shuchu(xianshi());
string strs = "FD010818000201020000";
chuansong(strs);
shuchu(xianshi());
}
#endregion
} else {
Thread.Sleep();
}
} else {
Thread.Sleep();
}
} while (true); }
//接受协议
public byte[] xianshi() {
try { bool bGet = false;
byte[] received = new byte[];
int nTimeout = ;
if (sp.BytesToRead > ) {
do { int zhi = sp.ReadByte();
received[nTimeout] = Convert.ToByte(zhi); if (received[nTimeout].ToString().IndexOf("") >= )//这个地方要换成你的结束符
{
bGet = true;
} nTimeout++; if (nTimeout > ) {
bGet = true;
}
Thread.Sleep();
}
while (!bGet);
sp.DiscardOutBuffer();
sp.DiscardInBuffer();
return received;
} else {
return null;
} } catch {
return null;
}
}
//发送协议
public void chuansong(string str) { if (sp.IsOpen == true) {
Byte[] sendstrs = BLL.ZhuanHuan.GetByte(str);
sp.Write(sendstrs, , sendstrs.Length);
Thread.Sleep();
} }
//过流过压图片显示
public void GLGY(PictureBox pbR, PictureBox pbG, string jiu, string qi) {
//过压
if (qi == "") { if (jiu == "") { // Closes();
pbR.Image = Image.FromFile(redPath);
} else if (jiu == "") {
pbG.Image = Image.FromFile(greenPath);
pbR.Image = Image.FromFile(whitePath);
}
}
//过流
else if (qi == "") {
if (jiu == "") { // Closes();
pbR.Image = Image.FromFile(redPath);
} else if (jiu == "") {
pbG.Image = Image.FromFile(greenPath);
pbR.Image = Image.FromFile(whitePath);
}
}
}
//输出显示
public void shuchu(byte[] buf) {
if (buf != null) {
if (buf.Count() > ) {
string[] bufd = BLL.ZhuanHuan.ByteToByteString(buf);
#region 算法
switch (bufd[]) {
//抑制极电源
#region 抑制极
case "": {
//设置与开关
if (bufd[] == "") {
//查询电压电流
if (bufd[] == "") {
//正
if (bufd[] == "") {
//电压
if (bufd[] == "") {
this.txtYZJDYS.Text = BLL.YiZhiJi.YZJSZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcYZJDY, listyzj, myCurveyzj);
}
//电流
else if (bufd[] == "") {
double zhi = BLL.YiZhiJi.DLJSZ(bufd[] + bufd[]);
if (zhi > BLL.Model.YZJZ.SCDLG * ( + 0.1)) {
//发送过流保护信号
this.pbxYZJDYR.Image = Image.FromFile(redPath);
Closes();
}
this.txtYZJDL.Text = BLL.YiZhiJi.DLJSZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
} }
//负
else if (bufd[] == "") {
//电压
if (bufd[] == "") { this.txtYZJDYS.Text = BLL.YiZhiJi.YZJSF(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcYZJDY, listyzj, myCurveyzj);
}
//电流
else if (bufd[] == "") { this.txtYZJDL.Text = BLL.YiZhiJi.YZJSZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, ); }
}
}
//过流过压
else if (bufd[] == "") {
//正
if (bufd[] == "") {
GLGY(this.pbxYZJDYR, pbxYZJDYG, bufd[], bufd[]);
}
//负
else if (bufd[] == "") {
GLGY(this.pbxYZJDYR, pbxYZJDYG, bufd[], bufd[]);
}
}
}
break;
}
#endregion
//引出极电源
#region 引出极
case "": {
//设置
if (bufd[] == "") {
//查询电流电压
if (bufd[] == "") {
//电压
if (bufd[] == "") { this.txtYCJDYS.Text = BLL.YinChuJi.YCJSZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcYCJDY, listycj, myCurveycj);
}
//电流
else if (bufd[] == "") { this.txtYCJDL.Text = BLL.YinChuJi.YCJSZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
} }
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxYCJDYR, this.pbxYCJDYG, bufd[], bufd[]); }
}
break;
}
#endregion
//聚焦电源
#region 聚焦
case "": {
//一
switch (bufd[]) {
case "": {
if (bufd[] == "") { if (bufd[] == "") { this.txtJJDYAS.Text = BLL.JuJiJi.JJJAASZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcJJDYA, listjja, myCurvejja);
} else if (bufd[] == "") { this.txtJJDLA.Text = BLL.JuJiJi.JJJAASZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
} }
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxJJDYAR, pbxJJDYAG, bufd[], bufd[]);
} break;
}
//二
case "": {
if (bufd[] == "") {
if (bufd[] == "") { this.txtJJDYAS.Text = BLL.JuJiJi.JJJABSZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcJJDYA, listjja, myCurvejja); } else if (bufd[] == "") { this.txtJJDLA.Text = BLL.JuJiJi.JJJABSZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
}
}
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxJJDYAR, pbxJJDYAG, bufd[], bufd[]);
} break;
}
case "": {
//三
if (bufd[] == "") {
//因为要访问ui资源,所以需要使用invoke方式同步ui。
if (bufd[] == "") {
this.txtJJDYAS.Text = BLL.JuJiJi.JJJACSZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcJJDYA, listjja, myCurvejja);
} else if (bufd[] == "") { this.txtJJDLA.Text = BLL.JuJiJi.JJJACSZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
}
}
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxJJDYAR, pbxJJDYAG, bufd[], bufd[]);
} break;
}
//一
case "": { if (bufd[] == "") {
if (bufd[] == "") {
this.txtJJDYBS.Text = BLL.JuJiJi.JJJBASZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcJJDYB, listjjb, myCurvejjb);
} else if (bufd[] == "") { this.txtJJDLB.Text = BLL.JuJiJi.JJJBASZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
}
}
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxJJDYBR, pbxJJDYBG, bufd[], bufd[]);
}
break;
}
//二
case "": { if (bufd[] == "") {
if (bufd[] == "") {
this.txtJJDYBS.Text = BLL.JuJiJi.JJJBBSZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcJJDYB, listjjb, myCurvejjb);
} else if (bufd[] == "") {
this.txtJJDLB.Text = BLL.JuJiJi.JJJBBSZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
}
}
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxJJDYBR, pbxJJDYBG, bufd[], bufd[]);
}
break;
}
//三
case "": { if (bufd[] == "") {
//因为要访问ui资源,所以需要使用invoke方式同步ui。
if (bufd[] == "") {
this.txtJJDYBS.Text = BLL.JuJiJi.JJJBCSZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcJJDYB, listjjb, myCurvejjb);
} else if (bufd[] == "") {
this.txtJJDLB.Text = BLL.JuJiJi.JJJBCSZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
}
}
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxJJDYBR, pbxJJDYBG, bufd[], bufd[]);
}
break;
}
}
break;
}
#endregion
//预聚焦电源
#region 预聚焦
case "": {
{
//一
switch (bufd[]) {
case "": {
if (bufd[] == "") {
if (bufd[] == "") {
this.txtYJJDYAS.Text = BLL.YuJuJiJi.YJJJAASZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcYJJDYA, listyjja, myCurveyjja);
} else if (bufd[] == "") {
this.txtYJJDLA.Text = BLL.YuJuJiJi.YJJJAASZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
}
}
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxYJJDYAGR, pbxYJJDYAG, bufd[], bufd[]);
}
break;
}
//二
case "": {
if (bufd[] == "") {
if (bufd[] == "") {
this.txtYJJDYAS.Text = BLL.YuJuJiJi.YJJJABSZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcYJJDYA, listyjja, myCurveyjja);
} else if (bufd[] == "") {
this.txtYJJDLA.Text = BLL.YuJuJiJi.YJJJABSZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
}
}
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxYJJDYBR, pbxYJJDYAG, bufd[], bufd[]);
}
break;
}
case "": {
//三
if (bufd[] == "") {
if (bufd[] == "") {
this.txtYJJDYAS.Text = BLL.YuJuJiJi.YJJJACSZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcYJJDYA, listyjja, myCurveyjja);
} else if (bufd[] == "") {
this.txtYJJDLA.Text = BLL.YuJuJiJi.YJJJACSZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
}
}
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxYJJDYCR, pbxYJJDYAG, bufd[], bufd[]);
}
break;
}
//一
case "": {
if (bufd[] == "") {
if (bufd[] == "") {
this.txtYJJDYBS.Text = BLL.YuJuJiJi.YJJJBASZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcYJJDYB, listyjjb, myCurveyjjb);
} else if (bufd[] == "") {
this.txtYJJDLB.Text = BLL.YuJuJiJi.YJJJBASZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
} }
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxYJJDYBR, pbxYJJDYBG, bufd[], bufd[]);
}
break;
}
//二
case "": {
if (bufd[] == "") {
if (bufd[] == "") {
this.txtYJJDYBS.Text = BLL.YuJuJiJi.YJJJBBSZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcYJJDYB, listyjjb, myCurveyjjb);
} else if (bufd[] == "") {
this.txtYJJDLB.Text = BLL.YuJuJiJi.YJJJBBSZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
}
}
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxYJJDYBR, pbxYJJDYBG, bufd[], bufd[]);
}
break;
}
//三
case "": {
if (bufd[] == "") {
if (bufd[] == "") {
this.txtYJJDYBS.Text = BLL.YuJuJiJi.YJJJBCSZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcYJJDYB, listyjjb, myCurveyjjb);
} else if (bufd[] == "") {
this.txtYJJDLB.Text = BLL.YuJuJiJi.YJJJBCSZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
}
}
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxYJJDYBR, pbxYJJDYBG, bufd[], bufd[]);
}
break;
}
//一
case "": {
if (bufd[] == "") {
if (bufd[] == "") {
this.txtYJJDYCS.Text = BLL.YuJuJiJi.YJJJCASZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcYJJDYC, listyjjc, myCurveyjjc);
} else if (bufd[] == "") {
this.txtYJJDLC.Text = BLL.YuJuJiJi.YJJJCASZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
}
}
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxYJJDYCR, pbxYJJDYCG, bufd[], bufd[]);
}
break;
}
//二
case "": {
if (bufd[] == "") {
if (bufd[] == "") {
this.txtYJJDYCS.Text = BLL.YuJuJiJi.YJJJCBSZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcYJJDYC, listyjjc, myCurveyjjc);
} else if (bufd[] == "") {
this.txtYJJDLC.Text = BLL.YuJuJiJi.YJJJCBSZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
}
}
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxYJJDYCR, pbxYJJDYCG, bufd[], bufd[]);
}
break;
}
//三
case "": {
if (bufd[] == "") {
if (bufd[] == "") {
this.txtYJJDYCS.Text = BLL.YuJuJiJi.YJJJCCSZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcYJJDYC, listyjjc, myCurveyjjc);
} else if (bufd[] == "") {
this.txtYJJDLC.Text = BLL.YuJuJiJi.YJJJCCSZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
}
}
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxYJJDYCR, pbxYJJDYCG, bufd[], bufd[]);
}
break;
}
}
break;
}
}
#endregion
//脉冲输出电源
#region 脉冲输出
case "": {
if (bufd[] == "") {
if (bufd[] == "") {
if (bufd[] == "") {
this.txtMCSCDYS.Text = BLL.TiaoZhiJi.TZJSZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcMCSCDYA, listymc, myCurveymc);
} else if (bufd[] == "") {
this.txtMCSCDL.Text = BLL.TiaoZhiJi.TZJSZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
}
}
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxMCSCDYR, pbxMCSCDYG, bufd[], bufd[]);
}
}
break;
}
#endregion
//60V整流电源
#region 60V整流
case "": {
if (bufd[] == "") {
if (bufd[] == "") {
if (bufd[] == "") {
if (bufd[] == "") {
this.txtZLDYS.Text = BLL._60V.VSZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcZLDY, listzl, myCurvezl);
} else if (bufd[] == "") {
this.txtZLDL.Text = BLL._60V.VSZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
}
} }
//过流过压
else if (bufd[] == "") {
if (bufd[] == "") {
string str = "FD020610000101110000"; chuansong(str); }
GLGY(this.pbxZLDYR, pbxZLDYG, bufd[], bufd[]); }
}
break;
}
#endregion
// 热丝电源预热(0-10)分钟
#region 热丝预热
case "": {
break; }
#endregion
//热丝电源
#region 热丝
case "": {
if (bufd[] == "") {
if (bufd[] == "") {
if (bufd[] == "") {
this.txtRSDYS.Text = BLL.DengSi.DSSZ(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(jieguo, this.zgcRSDY, listrs, myCurvers);
} else if (bufd[] == "") {
this.txtRSDL.Text = BLL.DengSi.DSSZDL(bufd[] + bufd[]).ToString();
double jieguo = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
}
}
//过流过压
else if (bufd[] == "") {
GLGY(this.pbxRSDYR, pbxRSDYG, bufd[], bufd[]);
}
}
break;
}
#endregion
//偏转电源
#region 偏转
case "": {
if (bufd[] == "") {
if (bufd[] == "") {
if (bufd[] == "") { double zhi = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(zhi, this.zgcPZDYA, listpza, myCurvepza);
if (zhi <= BLL.Model.PZDYZ1.DYXSG) {
this.txtPZDYAS.Text = BLL.PianZhuan.PZASZ(bufd[] + bufd[]).ToString();
} else if (zhi <= BLL.Model.PZDYZ2.DYXSG) {
this.txtPZDYAS.Text = BLL.PianZhuan.PZBSZ(bufd[] + bufd[]).ToString();
} else if (zhi <= BLL.Model.PZDYZ3.DYXSG) {
this.txtPZDYAS.Text = BLL.PianZhuan.PZCSZ(bufd[] + bufd[]).ToString();
} } else if (bufd[] == "") {
double zhi = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
if (zhi <= BLL.Model.PZDYZ1.DLXSG) {
this.txtPZDLA.Text = BLL.PianZhuan.PZASZDL(bufd[] + bufd[]).ToString();
} else if (zhi <= BLL.Model.PZDYZ2.DLXSG) {
this.txtPZDLA.Text = BLL.PianZhuan.PZBSZDL(bufd[] + bufd[]).ToString();
} else if (zhi <= BLL.Model.PZDYZ3.DLXSG) {
this.txtPZDLA.Text = BLL.PianZhuan.PZCSZDL(bufd[] + bufd[]).ToString();
} } } else if (bufd[] == "") {
if (bufd[] == "") { double zhi = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
shuaxin(zhi, this.zgcPZDYB, listpzb, myCurvepzb); if (zhi <= BLL.Model.PZDYF1.DYXSG) {
this.txtPZDYBS.Text = BLL.PianZhuan.PZASF(bufd[] + bufd[]).ToString();
} else if (zhi <= BLL.Model.PZDYF2.DYXSG) {
this.txtPZDYBS.Text = BLL.PianZhuan.PZBSF(bufd[] + bufd[]).ToString();
} else if (zhi <= BLL.Model.PZDYF3.DYXSG) {
this.txtPZDYBS.Text = BLL.PianZhuan.PZCSF(bufd[] + bufd[]).ToString();
}
} else if (bufd[] == "") {
double zhi = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
if (zhi <= BLL.Model.PZDYF1.DLXSG) {
this.txtPZDLB.Text = BLL.PianZhuan.PZASFDL(bufd[] + bufd[]).ToString();
} else if (zhi <= BLL.Model.PZDYF2.DLXSG) {
this.txtPZDLB.Text = BLL.PianZhuan.PZBSFDL(bufd[] + bufd[]).ToString();
} else if (zhi <= BLL.Model.PZDYF3.DLXSG) {
this.txtPZDLB.Text = BLL.PianZhuan.PZCSFDL(bufd[] + bufd[]).ToString();
} } } }
//过流过压
else if (bufd[] == "") {
//正
if (bufd[] == "") {
GLGY(this.pbxPZDYAR, pbxPZDYAG, bufd[], bufd[]);
}
//负
else if (bufd[] == "") {
GLGY(this.pbxPZDYBR, pbxPZDYBG, bufd[], bufd[]);
}
}
break;
}
#endregion
//主高电源
#region 主高压
case "0B": {
if (bufd[] == "") {
if (bufd[] == "") {
double zhi = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
if (zhi <= BLL.Model.ZGY1.DYXSG) {
this.txtZGYDYS.Text = BLL.ZhuGaoYa.GYSZA(bufd[] + bufd[]).ToString();
} else if (zhi <= BLL.Model.ZGY2.DYXSG) {
this.txtZGYDYS.Text = BLL.ZhuGaoYa.GYSZB(bufd[] + bufd[]).ToString();
} else if (zhi <= BLL.Model.ZGY3.DYXSG) {
this.txtZGYDYS.Text = BLL.ZhuGaoYa.GYSZC(bufd[] + bufd[]).ToString();
}
shuaxin(zhi, this.zgcZGYDY, listzgy, myCurvezgy); }
if (bufd[] == "") {
double zhi = Math.Round(BLL.ZhuanHuan.Shi(bufd[] + bufd[]) / 16383.0 * 5.0, );
if (zhi <= BLL.Model.ZGY1.DLXSG) {
this.txtZGYDL.Text = BLL.ZhuGaoYa.GYSZDLA(bufd[] + bufd[]).ToString();
} else if (zhi <= BLL.Model.ZGY2.DLXSG) {
this.txtZGYDL.Text = BLL.ZhuGaoYa.GYSZDLB(bufd[] + bufd[]).ToString();
} else if (zhi <= BLL.Model.ZGY3.DLXSG) {
this.txtZGYDL.Text = BLL.ZhuGaoYa.GYSZDLC(bufd[] + bufd[]).ToString();
}
}
}
//过流过压
else if (bufd[] == "") { GLGY(this.pbxZGYDLR, pbxZGYDLG, bufd[], bufd[]);
}
break; }
#endregion
} #endregion
sp.DiscardInBuffer();
} } }
//关闭所有电源
public void Closes() {
ltr[].Suspend();
if (count > ) { this.button8.Text = "加电";
this.button29.Text = "加电";
this.button23.Text = "加电";
this.button5.Text = "加电";
this.button41.Text = "加电";
this.button36.Text = "加电";
this.button2.Text = "加电";
this.button1.Text = "加电";
this.button11.Text = "加电";
this.button9.Text = "加电";
this.button10.Text = "加电";
this.button4.Text = "加电";
if (sp.IsOpen) {
string str = "FD010110020401010000";
chuansong(str);
Thread.Sleep();
string strs1 = "FD010110020402010000";
chuansong(strs1);
Thread.Sleep();
string str2 = "FD010210020401010000";
chuansong(str2);
Thread.Sleep();
string strs3 = "FD010318020402010000";
chuansong(strs3);
Thread.Sleep();
string strs4 = "FD010328020401010000";
chuansong(strs4);
Thread.Sleep();
string strs5 = "FD010418020401010000";
chuansong(strs5);
Thread.Sleep();
string strs6 = "FD010428020401010000";
chuansong(strs6);
Thread.Sleep();
string strs7 = "FD010438020401010000";
chuansong(strs7);
Thread.Sleep();
string str8 = "FD010510020401010000";
chuansong(str8);
Thread.Sleep();
string str10 = "FD010810020401010000";
chuansong(str10);
Thread.Sleep();
string strs11 = "FD020910020401010000";
chuansong(strs11);
Thread.Sleep();
string strs12 = "FD020910020402010000";
chuansong(strs12);
Thread.Sleep();
string strs13 = "FD020B10020401010000";
chuansong(strs13);
Thread.Sleep();
string str9 = "FD010610020401010000";
chuansong(str9);
}
for (int i = ; i < cbos.Count ; i++) {
cbos[i][i].Enabled = true;
btns[i].Enabled = true;
}
}
ltr[].Resume();
sp.Close();
PictureBox pb = new PictureBox();
pb.Name = "qb";
guandeng(pb);
fc.Hide();
btnCom.Text = "打开";
this.pictureBox1.Image = Image.FromFile(whitePath);
}
/// <summary>
/// 输入验证
/// </summary>
/// <param name="tb">TextBox文本框</param>
/// <param name="min">最小值</param>
/// <param name="max">最大值</param>
/// <returns></returns>
public bool tanchukuang(TextBox tb, double min, double max) {
try {
double zhi = Convert.ToDouble(tb.Text.Trim());
if (zhi < min || zhi > max) {
MessageBox.Show("请输入" + min + "-" + max + "之间的电压");
return false;
} else {
return true;
}
} catch {
MessageBox.Show("请输入正确的数字");
return false; }
}
//主高压开关
private void button11_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtZGYDY, , )) {
if (this.button11.Text == "加电") {
count++;
this.button11.Text = "断电";
string str1 = "FD020B1800010101" + BLL.ZhuGaoYa.GYXZA();
chuansong(str1);
string strk = "FD020B00010100020000";
chuansong(strk);
int counts = ;
string[] jieguo = ZGY.SheZhi(this.txtZGYDY.Text.Trim(), gy, zgys);
zgy = jieguo[];
if (zgys >= Convert.ToDouble(this.txtZGYDY.Text.Trim())) {
chuansong(jieguo[]);
Thread.Sleep();
chuansong(jieguo[]);
} else {
chuansong(jieguo[]);
double d = Convert.ToDouble(this.txtZGYDY.Text.Trim()) - zgys;
//判断之前设置和现在设置的电压差距·根据差距设置循环加电次数
if (d >= ) {
counts = ;
} else if (d >= ) {
counts = ;
} else if (d >= ) {
counts = ;
} else if (d >= ) {
counts = ;
} else {
counts = ;
}
if (jieguo[] != "") {
chuansong(jieguo[]);
if (jieguo[] == "") {
string str = "FD020B1000010101" + BLL.ZhuanHuan.ShiLiu(4.9 * / );
chuansong(str);
}
double dizeng = Math.Round((4.9 - Convert.ToDouble(jieguo[])) / counts, );
double dq = 4.9;
for (int i = ; i < counts ; i++) {
if (jieguo[] == "") {
dq -= dizeng;
string strs = "FD020B1800010101" + BLL.ZhuanHuan.ShiLiu(dq * / );
chuansong(strs);
} else if (jieguo[] == "") {
dq -= dizeng;
string strs = "FD020B1000010101" + BLL.ZhuanHuan.ShiLiu(dq * / );
chuansong(strs);
} else if (jieguo[] == "") {
dq -= dizeng;
string strs = "FD020B1100010101" + BLL.ZhuanHuan.ShiLiu(dq * / );
chuansong(strs);
}
}
} else {
double tizeng = (Convert.ToDouble(this.txtZGYDY.Text.Trim()) - zgys) / counts;
double dq = zgys;
for (int i = ; i < counts ; i++) {
if (jieguo[] == "") {
dq += tizeng;
string strs = "FD020B1800010101" + BLL.ZhuGaoYa.GYXZA(dq);
chuansong(strs);
} else if (jieguo[] == "") {
dq += tizeng;
string strs = "FD020B1000010101" + BLL.ZhuGaoYa.GYXZB(dq);
chuansong(strs);
} else if (jieguo[] == "") {
dq += tizeng;
string strs = "FD020B1100010101" + BLL.ZhuGaoYa.GYXZC(dq);
chuansong(strs);
}
}
}
}
zgys = Convert.ToDouble(this.txtZGYDY.Text.Trim()); } else {
count--;
zgys = ; this.button11.Text = "加电";
string str = "FD020B00020100020000";
guandeng(pbxZGYDLG);
chuansong(str);
string strs = "FD020B1800010101" + BLL.ZhuGaoYa.GYXZA();
chuansong(strs);
txtZGYDYS.Text = "";
txtZGYDL.Text = "";
}
}
ltr[].Resume();
}
//偏转A开关
private void button4_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtPZDYA, , )) {
if (this.button4.Text == "加电") {
count++; this.button4.Text = "断电";
string[] jieguo = new PZA().shezhi(this.txtPZDYA.Text.Trim(), gy, pzas);
pza = jieguo[];
if (pzas >= Convert.ToDouble(this.txtPZDYA.Text.Trim())) {
chuansong(jieguo[]);
Thread.Sleep();
chuansong(jieguo[]);
} else {
chuansong(jieguo[]);
chuansong(jieguo[]);
}
string[] jieguo2 = new PZB().shezhi(this.txtPZDYA.Text.Trim(), gy, pzbs);
pzb = jieguo2[];
if (pzbs >= Convert.ToDouble(this.txtPZDYA.Text.Trim())) {
chuansong(jieguo2[]);
Thread.Sleep();
chuansong(jieguo2[]);
} else {
chuansong(jieguo2[]);
chuansong(jieguo2[]);
}
pzas = Convert.ToDouble(this.txtPZDYA.Text.Trim());
string str = "FD020900010001010000";
chuansong(str);
pzbs = Convert.ToDouble(this.txtPZDYA.Text.Trim());
string str2 = "FD020900010002010000";
chuansong(str2);
} else {
count--;
guandeng(pbxPZDYAG);
this.button4.Text = "加电";
string str = "FD020900020101010000";
chuansong(str);
string str2 = "FD020928020102010000";
chuansong(str2);
txtPZDYAS.Text = "";
txtPZDLA.Text = "";
txtPZDYBS.Text = "";
txtPZDLB.Text = "";
}
}
ltr[].Resume();
}
//电流图
public void shuaxin(double shuju, ZedGraphControl zedGraphControl1, PointPairList list, LineItem myCurve) {
int lenth = ;
try {
zedGraphControl1.GraphPane.XAxis.Type = ZedGraph.AxisType.DateAsOrdinal;
} catch {
}
for (int i = ; i < lenth ; i++) {
double x = (double)new XDate(DateTime.Now.AddSeconds(-( - i)));
list.Add(x, shuju);
if (lenth > ) {
list.RemoveAt();
}
}
DateTime dt = DateTime.Now;
myCurve = zedGraphControl1.GraphPane.AddCurve("", list, Color.DarkGreen, SymbolType.None);
zedGraphControl1.AxisChange();
zedGraphControl1.Refresh();
lenth++;
}
//引出极开关
private void button2_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtYCJDY, , )) {
if (this.button2.Text == "加电") {
count++; this.button2.Text = "断电";
string[] jieguo = new YCJ().shezhi(this.txtYCJDY.Text.Trim(), gy);
chuansong(jieguo[]);
chuansong(jieguo[]);
string str = "FD010210010401010000";
chuansong(str);
t.Stop();
this.button2.Enabled = true;
} else {
count--;
guandeng(pbxYCJDYG);
this.button2.Text = "加电";
string str = "FD010210020401020000";
chuansong(str);
txtYCJDYS.Text = "";
txtYCJDL.Text = "";
}
}
ltr[].Resume();
}
//聚焦A开关
private void button36_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtJJDYA, , )) {
if (this.button36.Text == "加电") {
count++;
this.button36.Text = "断电";
string[] jieguo = new JJA().shezhi(this.txtJJDYA.Text.Trim(), gy, jjas);
jja = jieguo[];
if (jjas >= Convert.ToDouble(this.txtJJDYA.Text.Trim())) {
chuansong(jieguo[]);
Thread.Sleep();
chuansong(jieguo[]);
} else {
chuansong(jieguo[]); chuansong(jieguo[]);
}
jjas = Convert.ToDouble(this.txtJJDYA.Text.Trim());
string str = "FD010318010101010000";
chuansong(str);
} else {
count--;
guandeng(pbxJJDYAG);
this.button36.Text = "加电";
string str = "FD010318020101010000";
chuansong(str);
txtJJDYAS.Text = "";
txtJJDLA.Text = "";
}
}
ltr[].Resume();
}
//聚集B开关
private void button41_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtJJDYB, , )) {
if (this.button41.Text == "加电") {
count++;
this.button41.Text = "断电";
string[] jieguo = JJB.shezhi(this.txtJJDYB.Text.Trim(), gy, jjbs);
jjb = jieguo[];
if (jjbs >= Convert.ToDouble(this.txtJJDYB.Text.Trim())) {
chuansong(jieguo[]);
Thread.Sleep();
chuansong(jieguo[]);
} else {
chuansong(jieguo[]);
chuansong(jieguo[]);
}
jjbs = Convert.ToDouble(this.txtJJDYB.Text.Trim());
string str = "FD010328010101010000";
chuansong(str); } else {
count--;
guandeng(pbxJJDYBG);
this.button41.Text = "加电";
string str = "FD010328020101010000";
chuansong(str);
txtJJDYBS.Text = "";
txtJJDLB.Text = "";
}
}
ltr[].Resume();
}
//预聚集A开关
private void button5_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtYJJDYA, , )) {
if (this.button5.Text == "加电") {
count++;
this.button5.Text = "断电";
string[] jieguo = new YJJA().shezhi(this.txtYJJDYA.Text.Trim(), gy, yjjas);
yjja = jieguo[];
if (yjjas >= Convert.ToDouble(this.txtYJJDYA.Text.Trim())) {
chuansong(jieguo[]);
Thread.Sleep();
chuansong(jieguo[]);
} else {
chuansong(jieguo[]);
chuansong(jieguo[]);
}
yjjas = Convert.ToDouble(this.txtYJJDYA.Text.Trim());
string str = "FD010418010101010000";
chuansong(str);
} else {
count--;
guandeng(pbxYJJDYAG);
this.button5.Text = "加电";
string str = "FD010418020101010000";
chuansong(str);
txtYJJDYAS.Text = "";
txtYJJDLA.Text = "";
}
}
ltr[].Resume();
}
//预聚集B开关
private void button23_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtYJJDYB, , )) {
if (this.button23.Text == "加电") {
count++;
this.button23.Text = "断电";
string[] jieguo = new YJJB().shezhi(this.txtYJJDYB.Text.Trim(), gy, yjjbs);
yjjb = jieguo[];
if (yjjbs >= Convert.ToDouble(this.txtYJJDYB.Text.Trim())) {
chuansong(jieguo[]);
Thread.Sleep();
chuansong(jieguo[]);
} else { chuansong(jieguo[]);
chuansong(jieguo[]); }
yjjbs = Convert.ToDouble(this.txtYJJDYB.Text.Trim());
string str = "FD010428010101010000";
chuansong(str);
} else {
count--;
guandeng(pbxYJJDYBG);
this.button23.Text = "加电";
string str = "FD010428020101010000";
chuansong(str);
txtYJJDYBS.Text = "";
txtYJJDLB.Text = "";
}
}
ltr[].Resume();
}
//预聚集C开关
private void button29_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtYJJDYC, , )) {
if (this.button29.Text == "加电") {
count++;
this.button29.Text = "断电";
string[] jieguo = new YJJC().shezhi(this.txtYJJDYC.Text.Trim(), gy, yjjcs);
yjc = jieguo[];
if (yjjcs >= Convert.ToDouble(this.txtYJJDYC.Text.Trim())) {
chuansong(jieguo[]);
Thread.Sleep();
chuansong(jieguo[]);
} else {
chuansong(jieguo[]);
chuansong(jieguo[]);
}
yjjcs = Convert.ToDouble(this.txtYJJDYC.Text.Trim());
string str = "FD010438010101010000";
chuansong(str);
} else {
count--;
guandeng(pbxYJJDYCG);
this.button29.Text = "加电";
string str = "FD010438020101010000";
chuansong(str);
txtYJJDYCS.Text = "";
txtYJJDLC.Text = "";
}
}
ltr[].Resume();
}
//主高压
private void button22_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtZGYDY, , )) {
double newzgy = Convert.ToDouble(this.txtZGYDY.Text.Trim());
string[] jieguo = ZGY.SheZhi(this.txtZGYDY.Text.Trim(), gy, zgys);
if (zgys >= Convert.ToDouble(this.txtZGYDY.Text.Trim())) {
chuansong(jieguo[]);
Thread.Sleep();
chuansong(jieguo[]);
} else {
int counts = ;
chuansong(jieguo[]);
double d = Convert.ToDouble(this.txtZGYDY.Text.Trim()) - zgys;
//判断之前设置和现在设置的电压差距·根据差距设置循环加电次数
if (d >= ) { counts = ;
} else if (d >= ) {
counts = ;
} else if (d >= ) {
counts = ;
} else if (d >= ) {
counts = ;
} else {
counts = ;
}
if (jieguo[] != "") {
chuansong(jieguo[]);
if (jieguo[] == "") {
string str = "FD020B1000010101" + BLL.ZhuanHuan.ShiLiu(4.9 * / );
chuansong(str);
}
double dizeng = Math.Round((4.9 - Convert.ToDouble(jieguo[])) / counts, );
double dq = 4.9;
for (int i = ; i < counts ; i++) {
if (jieguo[] == "") {
dq -= dizeng;
string strs = "FD020B1800010101" + BLL.ZhuanHuan.ShiLiu(dq * / );
chuansong(strs);
} else if (jieguo[] == "") {
dq -= dizeng;
string strs = "FD020B1000010101" + BLL.ZhuanHuan.ShiLiu(dq * / );
chuansong(strs);
} else if (jieguo[] == "") {
dq -= dizeng;
string strs = "FD020B1100010101" + BLL.ZhuanHuan.ShiLiu(dq * / );
chuansong(strs);
}
}
} else {
double tizeng = (Convert.ToDouble(this.txtZGYDY.Text.Trim()) - zgys) / counts;
double dq = zgys;
for (int i = ; i < counts ; i++) {
if (jieguo[] == "") {
dq += tizeng;
string strs = "FD020B1800010101" + BLL.ZhuGaoYa.GYXZA(dq);
chuansong(strs);
} else if (jieguo[] == "") {
dq += tizeng;
string strs = "FD020B1000010101" + BLL.ZhuGaoYa.GYXZB(dq);
chuansong(strs);
} else if (jieguo[] == "") {
dq += tizeng;
string strs = "FD020B1100010101" + BLL.ZhuGaoYa.GYXZC(dq);
chuansong(strs);
}
}
} }
zgy = jieguo[];
zgys = Convert.ToDouble(this.txtZGYDY.Text.Trim()); }
ltr[].Resume();
}
//引出极
private void button13_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtYCJDY, , )) {
string[] jieguo = new YCJ().shezhi(this.txtYCJDY.Text.Trim(), gy.Trim());
chuansong(jieguo[]);
chuansong(jieguo[]);
}
ltr[].Resume();
}
//聚焦A
private void button14_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtJJDYA, , )) {
string[] jieguo = new JJA().shezhi(this.txtJJDYA.Text.Trim(), gy, jjas);
if (jjas >= Convert.ToDouble(this.txtJJDYA.Text.Trim())) {
chuansong(jieguo[]);
Thread.Sleep();
chuansong(jieguo[]);
} else {
chuansong(jieguo[]);
if (jieguo[] != "") {
chuansong(jieguo[]);
}
chuansong(jieguo[]);
}
jjas = Convert.ToDouble(this.txtJJDYA.Text.Trim());
}
ltr[].Resume();
}
//聚集B
private void button38_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtJJDYB, , )) {
string[] jieguo = JJB.shezhi(this.txtJJDYB.Text.Trim(), gy, jjbs);
if (jjbs >= Convert.ToDouble(this.txtJJDYB.Text.Trim())) {
chuansong(jieguo[]);
Thread.Sleep();
chuansong(jieguo[]);
} else {
chuansong(jieguo[]);
if (jieguo[] != "") {
chuansong(jieguo[]);
}
chuansong(jieguo[]);
}
jjbs = Convert.ToDouble(this.txtJJDYB.Text.Trim());
}
ltr[].Resume();
}
//预聚集A
private void button16_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtYJJDYA, , )) {
string[] jieguo = new YJJA().shezhi(this.txtYJJDYA.Text.Trim(), gy, yjjas); if (yjjas >= Convert.ToDouble(this.txtYJJDYA.Text.Trim())) {
chuansong(jieguo[]);
Thread.Sleep();
chuansong(jieguo[]);
} else {
chuansong(jieguo[]);
if (jieguo[] != "") {
chuansong(jieguo[]);
}
chuansong(jieguo[]);
}
yjjas = Convert.ToDouble(this.txtYJJDYA.Text.Trim());
}
ltr[].Resume();
}
//预聚集B
private void button24_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtYJJDYB, , )) {
string[] jieguo = new YJJB().shezhi(this.txtYJJDYB.Text.Trim(), gy, yjjbs);
if (yjjbs >= Convert.ToDouble(this.txtYJJDYB.Text.Trim())) {
chuansong(jieguo[]);
Thread.Sleep();
chuansong(jieguo[]);
} else {
chuansong(jieguo[]);
if (jieguo[] != "") {
chuansong(jieguo[]);
}
chuansong(jieguo[]);
}
yjjbs = Convert.ToDouble(this.txtYJJDYB.Text.Trim());
}
ltr[].Resume();
}
//预聚集C
private void button30_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtYJJDYC, , )) {
string[] jieguo = new YJJC().shezhi(this.txtYJJDYC.Text.Trim(), gy, yjjcs);
if (yjjcs >= Convert.ToDouble(this.txtYJJDYC.Text.Trim())) {
chuansong(jieguo[]);
Thread.Sleep();
chuansong(jieguo[]);
} else {
chuansong(jieguo[]);
if (jieguo[] != "") {
chuansong(jieguo[]);
}
chuansong(jieguo[]);
}
yjjcs = Convert.ToDouble(this.txtYJJDYC.Text.Trim());
}
ltr[].Resume();
}
//偏转A
private void button3_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtPZDYA, , )) {
string[] jieguo = new PZA().shezhi(this.txtPZDYA.Text.Trim(), gy, pzas);
if (pzas >= Convert.ToDouble(this.txtPZDYA.Text.Trim())) {
chuansong(jieguo[]);
Thread.Sleep();
chuansong(jieguo[]);
} else {
chuansong(jieguo[]);
if (jieguo[] != "") {
chuansong(jieguo[]);
}
chuansong(jieguo[]);
}
pzas = Convert.ToDouble(this.txtPZDYA.Text.Trim());
string[] jieguo2 = new PZB().shezhi(this.txtPZDYA.Text.Trim(), gy, pzbs);
if (pzbs >= Convert.ToDouble(this.txtPZDYA.Text.Trim())) {
chuansong(jieguo2[]);
Thread.Sleep();
chuansong(jieguo2[]);
} else {
chuansong(jieguo2[]);
if (jieguo2[] != "") {
chuansong(jieguo2[]);
}
chuansong(jieguo2[]);
}
pzbs = Convert.ToDouble(this.txtPZDYA.Text.Trim());
}
ltr[].Resume();
}
//关闭状态图片
public void guandeng(PictureBox pb) {
if (pb.Name == "qb") {
this.pbxZGYDLG.Image = Image.FromFile(whitePath);
this.pbxYCJDYG.Image = Image.FromFile(whitePath);
this.pbxJJDYAG.Image = Image.FromFile(whitePath);
this.pbxJJDYBG.Image = Image.FromFile(whitePath);
this.pbxYJJDYAG.Image = Image.FromFile(whitePath);
this.pbxYJJDYBG.Image = Image.FromFile(whitePath);
this.pbxYJJDYCG.Image = Image.FromFile(whitePath);
this.pbxPZDYAG.Image = Image.FromFile(whitePath);
this.pbxPZDYBG.Image = Image.FromFile(whitePath);
} else {
pb.Image = Image.FromFile(whitePath);
}
}
//切换模式
private void RFD_Form_Deactivate(object sender, EventArgs e) {
Closes();
ltr[].Abort();
ltr.RemoveAt();
}
//模式加载
private void RFD_Form_Activated(object sender, EventArgs e) {
Control.CheckForIllegalCrossThreadCalls = false;
this.cboCom.SelectedIndex = ;
this.cboMCA.SelectedIndex = ;
fc.Hide();
count = ;
jjas = ;
jjbs = ;
yjjas = ;
yjjbs = ;
yjjcs = ;
rss = ;
zgys = ;
pzas = ;
pzbs = ;
Thread td = new Thread(new ThreadStart(NewXianCheng));
ltr.Add(td);
td.Start();
if (!sp.IsOpen) {
for (int i = ; i < this.cboCom.Items.Count ; i++) {
try {
sp.PortName = cboCom.Items[i].ToString();
sp.BaudRate = ;
sp.Parity = Parity.None;
sp.DataBits = ;
sp.StopBits = StopBits.One;
sp.Open();
this.btnCom.Text = "关闭";
this.pictureBox1.Image = Image.FromFile(greenPath);
continue;
} catch { }
}
}
}
//串口设置
private void btnCom_Click(object sender, EventArgs e) {
if (sp.IsOpen == false) {
if (cboCom.Text != "") {
try {
sp.PortName = cboCom.SelectedItem.ToString();
sp.BaudRate = ;
sp.Parity = Parity.None;
sp.DataBits = ;
sp.StopBits = StopBits.One;
sp.Open();
this.btnCom.Text = "关闭";
this.pictureBox1.Image = Image.FromFile(greenPath); } catch { MessageBox.Show(cboCom.SelectedItem.ToString() + "不存在");
} }
} else {
if (MessageBox.Show("是否关闭端口?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) { fc.Show();
Thread t = new Thread(new ThreadStart(Closes));
t.Start();
} }
}
//刷新显示
private void button15_Click(object sender, EventArgs e) {
if (ltr[].IsAlive) {
try {
ltr[].Abort();
ltr.RemoveAt();
Thread td = new Thread(new ThreadStart(NewXianCheng));
ltr.Add(td);
td.Start();
} catch { }
} else {
ltr.RemoveAt();
Thread td = new Thread(new ThreadStart(NewXianCheng));
ltr.Add(td);
td.Start();
}
}
//关闭窗口
private void RFD_Form_FormClosing(object sender, FormClosingEventArgs e) {
if (ltr[].IsAlive) {
ltr[].Abort();
}
}
//抑制极开关
private void button1_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtYZJDY, -, )) {
if (this.button1.Text == "加电") {
count++;
double dy = Convert.ToDouble(this.txtYZJDY.Text);
if (dy >= ) {
ZF = true;
string[] jieguo = YZJ.shezhi(this.txtYZJDY.Text.Trim(), "正");
chuansong(jieguo[]);
string strs = "FD010110030001000000";
chuansong(strs);
string[] fu = YZJ.shezhi("", "负");
chuansong(fu[]);
string str3 = "FD010110020402010000";
chuansong(str3);
string str = "FD010110010001010000";
chuansong(str); } else {
ZF = false;
string[] jieguo = YZJ.shezhi(this.txtYZJDY.Text.Trim(), "负");
chuansong(jieguo[]);
string strs = "FD010110030002000000";
chuansong(strs);
string[] zheng = YZJ.shezhi("", "正");
chuansong(zheng[]);
string str3 = "FD010110020401010000";
chuansong(str3);
string str2 = "FD010110010002010000";
chuansong(str2); } this.button1.Text = "断电";
} else {
count--;
this.button1.Text = "加电";
string str = "";
if (ZF) {
str = "FD010110020401010000";
chuansong(str);
} else {
str = "FD010110020402010000";
chuansong(str);
}
guandeng(pbxYZJDYG);
txtYZJDYS.Text = "";
txtYZJDL.Text = "";
}
}
ltr[].Resume();
}
//抑制极
private void button12_Click(object sender, EventArgs e) {
if (tanchukuang(this.txtYZJDY, -, )) {
ltr[].Suspend();
double dy = Convert.ToDouble(this.txtYZJDY.Text);
if (dy >= ) {
ZF = true;
string[] jieguo = YZJ.shezhi(this.txtYZJDY.Text.Trim(), "正");
chuansong(jieguo[]);
string strs = "FD010110030001000000";
chuansong(strs);
string[] fu = YZJ.shezhi("", "负");
chuansong(fu[]);
string str3 = "FD010110020402010000";
chuansong(str3);
string str = "FD010110010001010000";
chuansong(str); } else {
ZF = false;
string[] jieguo = YZJ.shezhi(this.txtYZJDY.Text.Trim(), "负");
chuansong(jieguo[]);
string strs = "FD010110030002000000";
chuansong(strs);
string[] zheng = YZJ.shezhi("", "正");
chuansong(zheng[]);
string str3 = "FD010110020401010000";
chuansong(str3);
string str2 = "FD010110010002010000";
chuansong(str2); } ltr[].Resume();
}
}
//脉冲开关A
private void button8_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtMCSCDY, , )) {
if (this.button8.Text == "加电") {
count++;
string jieguo2 = new MCSZ().shezhi("20/100");
chuansong(jieguo2);
this.button8.Text = "断电";
string[] jieguo = new MC().shezhi(this.txtMCSCDY.Text.Trim(), gy);
chuansong(jieguo[]);
double z = Convert.ToDouble(this.txtMCSCDY.Text.Trim());
double j = z / ;
double s = j;
for (int i = ; i < ; i++) {
string[] jieguo3 = new MC().shezhi(j.ToString(), gy);
chuansong(jieguo3[]);
j = j + s;
if (i == ) {
string str = "FD010510010101010000";
chuansong(str);
}
} chuansong(jieguo[]); } else {
count--;
guandeng(pbxMCSCDYG);
this.button8.Text = "加电";
string str = "FD010510020101010000";
chuansong(str);
txtMCSCDYS.Text = "";
txtMCSCDL.Text = "";
}
}
ltr[].Resume();
}
//脉冲A设置
private void button17_Click(object sender, EventArgs e) {
ltr[].Suspend();
string[] jieguo = new MC().shezhi(this.txtMCSCDY.Text.Trim(), gy);
chuansong(jieguo[]);
string[] jieguo3 = new MC().shezhi("", gy);
chuansong(jieguo3[]);
Thread.Sleep();
if (this.cboMCA.Text != "") {
string jieguo2 = new MCSZ().shezhi(this.cboMCA.SelectedItem.ToString());
chuansong(jieguo2);
}
double z = Convert.ToDouble(this.txtMCSCDY.Text.Trim());
double j = z / ;
double s = j;
for (int i = ; i < ; i++) {
string[] jieguo2 = new MC().shezhi(j.ToString(), gy);
chuansong(jieguo2[]);
j = j + s;
} ltr[].Resume(); }
//热丝开关
private void button10_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtRSDY, , )) {
if (this.button10.Text == "加电") {
count++; this.button10.Text = "断电";
string[] jieguo = new RS().shezhi(this.txtRSDY.Text.Trim(), gy);
if (rss >= Convert.ToDouble(this.txtRSDY.Text.Trim())) {
chuansong(jieguo[]);
chuansong(jieguo[]);
} else {
chuansong(jieguo[]);
chuansong(jieguo[]);
}
rss = Convert.ToDouble(this.txtRSDY.Text.Trim());
string str = "FD010810010101010000";
chuansong(str);
} else {
count--;
guandeng(pbxRSDYG);
this.button10.Text = "加电";
string str = "FD010810020101020000";
chuansong(str);
txtRSDYS.Text = "";
txtRSDL.Text = "";
}
}
ltr[].Resume();
} void t_Tick(object sender, EventArgs e) {
if (button2.Text == "加电") {
button2_Click(sender, e);
}
button2.Enabled = false;
}
//60v整流开关
private void button9_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (this.button9.Text == "加电") {
string str1 = "FD010510020101010000";
chuansong(str1);
count++;
this.button9.Text = "断电";
string str = "FD020600010101000000";
chuansong(str); } else {
count--;
guandeng(pbxZLDYG);
this.button9.Text = "加电";
string str = "FD020600020101000000";
chuansong(str);
txtZLDYS.Text = "";
txtZLDL.Text = "";
}
ltr[].Resume();
}
//热丝
private void button21_Click(object sender, EventArgs e) {
ltr[].Suspend();
if (tanchukuang(this.txtRSDY, , )) {
string[] jieguo = new RS().shezhi(this.txtRSDY.Text.Trim(), gy);
if (rss >= Convert.ToDouble(this.txtRSDY.Text.Trim())) {
chuansong(jieguo[]);
chuansong(jieguo[]);
} else {
chuansong(jieguo[]);
chuansong(jieguo[]);
}
rss = Convert.ToDouble(this.txtRSDY.Text.Trim());
}
ltr[].Resume();
}
//脉冲A
private void button20_Click(object sender, EventArgs e) {
if (tanchukuang(this.txtMCSCDY, , )) {
string[] jieguo = new MC().shezhi(this.txtMCSCDY.Text.Trim(), gy);
chuansong(jieguo[]);
double z = Convert.ToDouble(this.txtMCSCDY.Text.Trim());
double j = z / ;
double s = j;
for (int i = ; i < ; i++) {
string[] jieguo2 = new MC().shezhi(j.ToString(), gy);
chuansong(jieguo2[]);
j = j + s;
} chuansong(jieguo[]);
}
}
//自动加断电
private void button6_Click(object sender, EventArgs e) {
if (this.button6.Text == "热发射模式加电") {
#region 加电
int[] sx = new int[] { , , , , , , , , , , , };
int[] sx2 = new int[] { -, -, -, -, -, -, -, -, -, -, -, - };
for (int i = ; i < cbos.Count ; i++) {
if (cbos[i][i].Checked) {
for (int j = ; j < sx.Count() ; j++) {
if (sx[j] == i) {
sx2[j] = i;
}
} }
}
for (int i = ; i < sx2.Count() ; i++) {
switch (sx2[i]) {
//热丝
case : {
if (this.button10.Text == "加电") { button10_Click(sender, e);
button10.Enabled = false;
//等待2分钟后加引出极
if (cboYCJ.Checked) { t.Interval = ;
t.Tick += new EventHandler(t_Tick);
t.Start();
this.button2.Enabled = false;
} }
break;
} ////引出极
//case 2:
// {
// button2_Click(sender, e);
// break;
// }
//抑制极
case : {
if (this.button1.Text == "加电") {
button1_Click(sender, e);
button1.Enabled = false;
}
break;
}
//聚集A
case : {
if (this.button36.Text == "加电") {
button36_Click(sender, e);
button36.Enabled = false;
}
break;
}
//聚集B
case : {
if (this.button41.Text == "加电") {
button41_Click(sender, e);
button41.Enabled = false;
}
break;
}
//预聚集A
case : {
if (this.button5.Text == "加电") {
button5_Click(sender, e);
button5.Enabled = false;
}
break;
}
//预聚集B
case : {
if (this.button23.Text == "加电") {
button23_Click(sender, e);
button23.Enabled = false;
}
break;
}
//预聚集C
case : {
if (this.button29.Text == "加电") {
button29_Click(sender, e);
button29.Enabled = false;
}
break;
}
//偏转
case : {
if (this.button4.Text == "加电") {
button4_Click(sender, e);
button4.Enabled = false;
}
break;
}
//脉冲
case : {
if (this.button8.Text == "加电") {
button8_Click(sender, e);
button8.Enabled = false;
}
break;
}
//整流
case : {
if (this.button9.Text == "加电") {
button9_Click(sender, e);
button9.Enabled = false;
Thread.Sleep();
}
break;
}
//主高压
case : {
if (this.button11.Text == "加电") {
button11_Click(sender, e);
button11.Enabled = false;
}
break;
}
default:
break;
}
}
#endregion
this.button6.Text = "热发射模式断电";
for (int i = ; i < cbos.Count ; i++) {
cbos[i][i].Enabled = false;
} } else {
#region 断电
int[] sx = new int[] { , , , , , , , , , , , };
int[] sx2 = new int[] { -, -, -, -, -, -, -, -, -, -, -, - };
for (int i = ; i < cbos.Count ; i++) {
if (cbos[i][i].Checked) {
for (int j = ; j < sx.Count() ; j++) {
if (sx[j] == i) {
sx2[j] = i;
}
} }
}
//抑制极调到负的最极大,但不断电
if (button1.Text == "断电") {
ZF = false;
string[] jieguo = YZJ.shezhi("-1000", "负");
chuansong(jieguo[]);
string strs = "FD010110030002000000";
chuansong(strs);
}
for (int i = ; i < sx2.Count() ; i++) {
switch (sx2[i]) { //热丝
case : {
if (button10.Text == "断电") {
button10_Click(sender, e);
button10.Enabled = true;
if (t.Enabled) {
t.Stop();
} }
break;
} //引出极
case : {
if (button2.Text == "断电") {
button2_Click(sender, e);
}
button2.Enabled = true;
break;
}
//抑制极
case : {
if (button1.Text == "断电") {
button1_Click(sender, e);
button1.Enabled = true;
}
break;
}
//聚集A
case : {
if (button36.Text == "断电") {
button36_Click(sender, e);
button36.Enabled = true;
}
break;
}
//聚集B
case : {
if (button41.Text == "断电") {
button41_Click(sender, e);
button41.Enabled = true;
}
break;
}
//预聚集A
case : {
if (button5.Text == "断电") {
button5_Click(sender, e);
button5.Enabled = true;
}
break;
}
//预聚集B
case : {
if (button23.Text == "断电") {
button23_Click(sender, e);
button23.Enabled = true;
}
break;
}
//预聚集C
case : {
if (button29.Text == "断电") {
button29_Click(sender, e);
button29.Enabled = true;
}
break;
}
//偏转
case : {
if (button4.Text == "断电") {
button4_Click(sender, e);
button4.Enabled = true;
}
break;
}
//脉冲
case : {
if (button8.Text == "断电") {
button8_Click(sender, e);
button8.Enabled = true;
}
break;
}
//整流
case : {
if (button9.Text == "断电") {
button9_Click(sender, e);
button9.Enabled = true;
}
break;
}
//主高压
case : {
if (button11.Text == "断电") {
button11_Click(sender, e);
button11.Enabled = true;
}
break;
}
default:
break;
}
}
#endregion
this.button6.Text = "热发射模式加电";
for (int i = ; i < cbos.Count ; i++) {
cbos[i][i].Enabled = true;
} } }
//全选/取消
private void checkBox1_CheckedChanged(object sender, EventArgs e) {
if (checkBox1.Checked) {
for (int i = ; i < cbos.Count ; i++) {
cbos[i][i].Checked = true;
}
} else {
for (int i = ; i < cbos.Count ; i++) {
cbos[i][i].Checked = false;
}
}
}
}
}

RFD_Form