STC-单片机控制系统
电源测量命令
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
STC-单片机控制系统的更多相关文章
- STC单片机控制28BYJ-48步进电机
STC单片机4*4按键控制步进电机旋转 28BYJ-48型步进电机说明 四相永磁式的含义 28BYJ-48工作原理 让电机转起来 最简单的电机转动程序 电机转速缓慢的原因分析 便于控制转过圈数的改进程 ...
- 单片机成长之路(51基础篇) - 002 STC单片机冷启动和复位有什么区别
STC单片机简介 STC单片机是一款增强型51单片机,完全兼容MCS-51,还增加了新的功能,比如新增两级中断优先级,多一个外中断,内置EEPROM,硬件看门狗,具有掉电模式,512B内存等.还支持I ...
- STC单片机 IAP(EEPROM)的使用
STC89C51.52内部都自带有2K字节的EEPROM,54.55和58都自带有16K字节的EEPROM,STC单片机是利用IAP技术实现的EEPROM,内部Flash擦写次数可达100,000 次 ...
- STC单片机串口输出ADXL335角度值
STC单片机串口输出ADXL335角度值: //***************************************************** //名称:单片机串口输出ADXL335角度值 ...
- STC 单片机ADC实现原理
模数转换器原理 数模转换器( analog to digitI converter,ADC),简称为A/D,ADC是链接模拟世界和数字世界的桥梁.它用于将连续的模拟信号转换为数字形式离散信号.典型的, ...
- STC单片机Flash做EEPROM的代码
STC官方给出的建议: /***************************************************************Author:Liming*** * @brie ...
- Linux(Ubuntu12.04)上玩儿STC单片机(转)
操作系统:Ubuntu16.04 TLS 单片机:STC的STC89C52RC系列及 Atmel的AT89S52... 所需工具: 1.编辑器- Vim(不钟情于IDE,个人喜好,高手勿喷) 2.编译 ...
- 宏晶STC单片机使用STC-ISP串口烧录失败的原因与解决方法汇总
官方网址: http://www.stcisp.com/q_and_a_stcisp.html 个人小结 芯片:STC12C5A60S2 封装:LQFP-48 晶振大小:SD22.1184M 最小系统 ...
- STC单片机掉电断电失电瞬间EEPROM数据保存处理办法(转)
由于客户在请人设计开发一设备,但是设备用户处总停电,造成设备及其周边耗材损耗严重,因此请我司在现有STC为主要芯片的基础上做掉电瞬间EEPROM里的20个参数保存,上电后通过读取EEPROM中的参数回 ...
- stc单片机笔记
volatile是一个类型修饰符(type specifier).volatile的作用是作为指令关键字,确保本条指令不会因编译器的优化而省略,且要求每次直接读值. 简单地说就是防止编译器对代码进行优 ...
随机推荐
- 在JS中使用COM组件的方法
首先创建一个COM组件,插入一个双接口Itest,在此接口上实现以下三个方法: STDMETHODIMP Ctest::test(void) //无输入输出参数 { // TODO: 在此添加实现代码 ...
- SQL2008实现数据库自动定时备份——维护计划
在SQL Server中出于数据安全的考虑,所以需要定期的备份数据库.而备份数据库一般又是在凌晨时间基本没有数据库操作的时候进行,所以我们不可能要求管理员 每天守到晚上1点去备份数据库.要实现数据库的 ...
- Paxos 实现日志复制同步(Multi-Paxos)
Paxos 实现日志复制同步 这篇文章以一种易于理解的方式来解释 Multi-Paxos 的机制. Multi-Paxos 的是为了创建日志复制 一种实现方式是用一组基础 Paxos 实例,每条记录都 ...
- 蓝桥杯java试题《洗牌》
问题描述 小弱T在闲暇的时候会和室友打扑克,输的人就要负责洗牌.虽然小弱T不怎么会洗牌,但是他却总是输. 渐渐地小弱T发现了一个规律:只要自己洗牌,自己就一定会输.所以小弱T认为自己洗牌不够均匀,就独 ...
- 通过spring实现javamail发送邮件功能
以前很早的时候大家都用javamail实现发送邮件的功能,而且我们也一直沿用至今,代码拷过来用用就行了,现在我们改为用spring来实现,这样一来减少代码的复杂度,也能更好的契合spring理念 首先 ...
- CI Weekly #13 | 用更 Geek 的方式配置你的 CI 工作流
flow.ci 的重大更新来了--支持通过 .yml 文件配置工作流(测试阶段),具体的使用方法可参考文档:同时 flow.ci 也开放了社区>> club.flow.ci,使用的任何问题 ...
- arcpy.mapping常用四大件-MapDocument
arcpy.mapping常用四大件-MapDocument by 李远祥 点开arcpy.mapping的帮助,可以看到其有限的几个类,看起来东西不是很多,但却是非常的使用.由于arcpy定位就是粗 ...
- 图片上传裁剪zyupload
图片上传控件用的是zyupload控件,使用过程中遇到了一些问题,特别记录下来 上图是目前的使用效果,这个控件我是用js代码动态添加出来的 HTML代码: <div class="wi ...
- 【物联网云端对接-1】 通过HTTP协议与微软Azure IoT hub进行云端通信
在2015年曾写过一篇文章<从微软build 2015,展望微软未来发展>,提到了微软的Azure和Windows 10 IoT,那算是初次接触微软物联网技术.比较幸运的是在后续的时间里, ...
- 【2017年新篇章】 .NET 面试题汇总(一)
开篇 本次给大家介绍的是我收集以及自己个人保存一些.NET面试题 简介 此次包含的不止是.NET知识,也包含少许前端知识以及.net面试时所涉及的种种考点,希望能给找工作的同学们哪怕一点点帮助. 古人 ...