| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335 | using System;using System.Collections;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.IO;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.Xml;using OTSCLRINTERFACE;using OTSDataType;using OTSModelSharp.ServiceInterface;namespace OTSSysMgrApp{    public partial class SemTestForms : Form    {        #region 全部变量声明        //连接状态        bool ConnectionState = false;        // 判断是否是模拟状态 FASE:    不是在模拟环境下  True:    在模拟环境下        //bool IsSimulationStatus = false;        //获取当前电镜的ID号        int SemType = 0;        //获取XML 路径        static string xmlFilePath = System.Configuration.ConfigurationManager.ConnectionStrings["XMLFilePath"].ConnectionString;        //日志路径        //static string LogPath = System.Configuration.ConfigurationManager.ConnectionStrings["LogPath"].ConnectionString;        static NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();        //电镜设置对象        //OTSCLRINTERFACE.COTSControlFunExport cfun = null;        SemController m_SemHardwareMgr = null;        //国际化        Language lan;        //国际化存储信息        Hashtable table;        #endregion        #region 构造方法        public SemTestForms()        {            InitializeComponent();            //控制类对象初始化            //cfun = COTSControlFunExport.GetControllerInstance();            m_SemHardwareMgr = SemController.GetSEMController();            //国际化            lan = new Language(this);            table = lan.GetNameTable(this.Name);        }            #endregion        #region 保存设置        /// <summary>        /// 保存设置        /// </summary>        /// <param name="Name">节点名称</param>        /// <param name="Value">节点参数值</param>        public void SaveSetting(string Name, string Value)        {            try            {                //判断XML文件中是否存在                if (!XMLOperationClass.ExistsXmlInfo(Name))                {                    //调用添加XML节点功能                    XMLOperationClass.AddXmlInfo(Name, Value);                }                else                {                    //调用修改XML节点功能                    XMLOperationClass.EditXmlInfo(Name, Value);                }            }            catch (Exception ex)            {                //记录日志信息                log.Error(ex.Message.ToString());            }        }        #endregion        #region 修改设置        public void EditSetting(string Name, string Value)        {            try            {                //调用修改XML节点功能                XMLOperationClass.EditXmlInfo(Name, Value);            }            catch (Exception ex)            {                //记录日志信息                log.Error(ex.Message.ToString());            }        }        #endregion        #region 判断文件路径        /// <summary>        /// 判断文件路径        /// </summary>        /// <param name="path"></param>        /// <returns></returns>        public bool CreateFile(string path)        {            Directory.CreateDirectory(path);            return false;        }        #endregion        #region 判断文件是否存在        /// <summary>        /// 判断文件是否存在        /// </summary>        /// <param name="path">文件路径</param>        /// <returns></returns>        public bool ExistsFile(string path)        {            try            {                if (File.Exists(path))                {                    return true;                }                return false;            }            catch (Exception ex)            {                //记录日志信息                log.Error(ex.Message.ToString());                return false;            }        }        #endregion        public void GetBtnState(bool btnState)        {            //循环窗体中            foreach (Control item in gbGetMethods.Controls)            {                if (item is Button)                {                    //if(!(((Button)item).Name== "btnGLineTime"))                    //{                     ((Button)item).Enabled = btnState;                    //}                }            }            foreach (Control item in gbSetMethods.Controls)            {                if (item is Button)                {                    //if (!(((Button)item).Name == "btnGLineTime"))                    //{                    ((Button)item).Enabled = btnState;                    //}                }            }        }        #region 用户信息提示        /// <summary>        /// 提示        /// </summary>        /// <param name="Message"></param>        private void ShowMessage(int MessageType)        {            string message1 = table["message1"].ToString();            string message2 = table["message2"].ToString();            string message3 = table["message3"].ToString();            string message4 = table["message4"].ToString();            string message5 = table["message5"].ToString();            string message6 = table["message6"].ToString();            string message7 = table["message7"].ToString();            string message8 = table["message8"].ToString();            string message9 = table["message9"].ToString();            string message10 = table["message10"].ToString();            string MessageInfo = string.Empty;            switch (MessageType)            {                case 0:                    MessageInfo = message1;                    break;                case 1:                    MessageInfo = message2;                    break;                case 2:                    MessageInfo = message3;                    break;                case 3:                    MessageInfo = message4;                    break;                case 4:                    MessageInfo = message5;                    break;                case 5:                    MessageInfo = message6;                    break;                case 6:                    MessageInfo = message7;                    break;                case 7:                    MessageInfo = message8;                    break;                case 8:                    MessageInfo = message9;                    break;                case 9:                    MessageInfo = message10;                    break;            }            MessageBox.Show(MessageInfo, "Tip");        }        #endregion        #region 判断控制内容是否为空 与 判断输入的格式是否正确        /// <summary>        /// 判断控制内容是否为空        /// </summary>        /// <param name="tbContent"></param>        /// <returns></returns>        public bool IsNull(TextBox tbContent)        {            if (tbContent.Text.Trim().Equals(""))            {                //为空提示                ShowMessage(0);                //获取焦点                tbContent.Focus();                return false;            }            return true;        }        /// <summary>        ///         /// </summary>        /// <param name="objValue"></param>        /// <param name="objType"></param>        /// <returns></returns>        public bool IsType(object ObjValue, int ObjType)        {            try            {                switch (ObjType)                {                    case 1:                        int intValue = Convert.ToInt32(ObjValue);                        break;                    case 2:                        double douValue = Convert.ToDouble(ObjValue);                        break;                    case 3:                        float floValue = Convert.ToSingle(ObjValue);                        break;                }                return true;            }            catch (Exception)            {                //为空提示                ShowMessage(7);                return false;            }        }        /// <summary>        /// 判断是否连接        /// </summary>        /// <returns></returns>        public bool IsConnection()        {            try            {                if (ConnectionState)                {                    return true;                }                return false;            }            catch (Exception)            {                //为空提示                ShowMessage(7);                return false;            }        }        #endregion        #region 窗体控制的事件汇总        private void SemTestForms_Load(object sender, EventArgs e)        {            ////循环窗体中            foreach (Control item in gbGetMethods.Controls)            {                if (item is Button)                {                    //绑定按钮点击事件                    //item.Click += new System.EventHandler(btnGetInfo_Click);                    ((Button)item).Enabled = false;                }            }            foreach (Control item in gbSetMethods.Controls)            {                if (item is Button)                {                    //绑定按钮点击事件                    //item.Click += new System.EventHandler(btnSetInfo_Click);                    ((Button)item).Enabled = false;                }            }                  }        private void btnDone_Click(object sender, EventArgs e)        {            //遍历tabHardwareSet标签中所有的TextBox控件             //foreach (Control control in this.gbSetMethods.Controls)            //{            //    //节点名称与节点参数值            //    string Name = string.Empty;            //    string Value = string.Empty;            //    //判断类型名称            //    if (control is TextBox)            //    {            //        Name = (control as TextBox).Name.Substring(2);            //        //获取节点名称与节点参数值            //        Value = (control as TextBox).Text;            //        if(!Value.Equals(""))            //        SaveSetting(Name, Value);            //    }            //    //判断类型名称            //    if (control is CheckBox)            //    {            //        Name = (control as CheckBox).Name.Substring(2);            //        //获取节点名称与节点参数值            //        Value = (control as CheckBox).Checked ? "true" : "false";            //        SaveSetting(Name, Value);            //    }            //}            //返回关闭窗口返回值            this.DialogResult = DialogResult.OK;        }        private void btnGetInfo_Click(object sender, EventArgs e)        {            if (!IsConnection())            {                return;            }            //获取响应按钮            Button btnTest = (Button)sender;            try            {                //节点名称与节点参数值                string Name = string.Empty;                string Value = string.Empty;                //判断本地中是否存在文件路径                if (ExistsFile(xmlFilePath))                {                    //遍历tabHardwareSet标签中所有的ComboBox控件                     foreach (Control control in this.gbGetMethods.Controls)                    {                        //判断类型名称                        if (control is TextBox)                        {                            Name = (control as TextBox).Name.Substring(2);                            if (btnTest.Name.Contains(Name))                            {                                //获取节点名称与节点参数值                                System.Xml.XmlNode xmlNode = XMLOperationClass.GetXMLInformationValue("S" + Name);                                (control as TextBox).Text = ((XmlElement)xmlNode).GetAttribute("Value");                            }                        }                        //判断类型名称                        if (control is CheckBox)                        {                            Name = (control as CheckBox).Name.Substring(2);                            if (btnTest.Name.Contains(Name))                            {                                //获取节点名称与节点参数值                                System.Xml.XmlNode xmlNode = XMLOperationClass.GetXMLInformationValue(Name);                                (control as CheckBox).Checked = ((XmlElement)xmlNode).GetAttribute("Value").Equals("true") ? true : false;                            }                        }                    }                }                else                {                    //如果文件不存在,则创建文件                    CreateFile(xmlFilePath);                }            }            catch (Exception ex)            {                //记录日志信息                log.Error(ex.Message.ToString());            }        }        private void btnSetInfo_Click(object sender, EventArgs e)        {            if (!IsConnection())            {                return;            }            //获取响应按钮            Button btnTest = (Button)sender;            try            {                //节点名称与节点参数值                string Name = string.Empty;                string Value = string.Empty;                //判断本地中是否存在文件路径                if (ExistsFile(xmlFilePath))                {                    //遍历tabHardwareSet标签中所有的TextBox控件                     foreach (Control control in this.gbSetMethods.Controls)                    {                        //判断类型名称                        if (control is TextBox)                        {                            Name = (control as TextBox).Name.Substring(2);                            if (btnTest.Name.Contains(Name))                            {                                //获取节点名称与节点参数值                                Value = (control as TextBox).Text;                                SaveSetting(Name, Value);                            }                        }                        //判断类型名称                        if (control is CheckBox)                        {                            Name = (control as CheckBox).Name.Substring(2);                            if (btnTest.Name.Contains(Name))                            {                                //获取节点名称与节点参数值                                Value = (control as CheckBox).Checked ? "true" : "false";                                SaveSetting(Name, Value);                            }                        }                    }                }                else                {                    //如果文件不存在,则创建文件                    CreateFile(xmlFilePath);                }            }            catch (Exception ex)            {                //记录日志信息                log.Error(ex.Message.ToString());            }        }        private void btnGetAll_Click(object sender, EventArgs e)        {                 }        private void BtnConnect_Click(object sender, EventArgs e)        {            if (!ConnectionState)            {                //和电镜建立通讯连接                ConnectionState = m_SemHardwareMgr.Connect();                ///获取当前电镜的ID号                //SemType = cfun.GetSemType();                if (!ConnectionState)                {                    ShowMessage(2);                    log.Error(table["message3"].ToString());                }                else                {                    string str = table["str1"].ToString();                                        BtnConnect.Text = str;                    GetBtnState(true);                    log.Info("The energy spectrum is connected");                }            }            else            {                string str = table["str2"].ToString();                //断开电镜连接                //if (cfun.DisConnectSem())                //{                //    log.Info(table["message10"].ToString());                //}                //else                //{                //    //ShowMessage(9);                //}                BtnConnect.Text = str;                ConnectionState = false;                GetBtnState(false);            }        }        private void SemTestForms_FormClosing(object sender, FormClosingEventArgs e)        {            m_SemHardwareMgr.DisConnect();        }        private void btnGPositionXYR_Click(object sender, EventArgs e)        {            try            {                //赋值                double PositionX = 0;                double PositionY = 0;                double PositionR = 0;                //获取参数                bool result = m_SemHardwareMgr.GetSemPositionXY(ref PositionX, ref PositionY, ref PositionR);                if (result)                {                    //赋值 显示                    tbPositionX.Text = Convert.ToDouble(PositionX).ToString();                    tbPositionY.Text = Convert.ToDouble(PositionY).ToString();                    tbPositionR.Text = Convert.ToDouble(PositionR).ToString();                    log.Info("X,Y-axis coordinates:(" + tbPositionX.Text + "," + tbPositionY.Text+")");                }                else                {                    //配置结果提示                    ShowMessage(6);                    log.Error("Failed to obtain the X and Y coordinates");                }            }            catch (Exception ex)            {                //记录日志信息(异常日志)                log.Error(ex.Message.ToString());            }        }        private void btnSPositionXYR_Click(object sender, EventArgs e)        {            try            {                //判断是否为空                if (!IsNull(tbSPositionX))                {                    this.Focus();                    return;                }                if (!IsType(tbSPositionX.Text, 2))                {                    this.Focus();                    return;                }                if (!IsNull(tbSPositionY))                {                    this.Focus();                    return;                }                if (!IsType(tbSPositionY.Text, 2))                {                    this.Focus();                    return;                }                //if (!IsNull(tbSPositionR))                //{                //    this.Focus();                //    return;                //}                //if (!IsType(tbSPositionR.Text, 2))                //{                //    this.Focus();                //    return;                //}                //赋值                double PositionX = Convert.ToDouble(tbSPositionX.Text);                double PositionY = Convert.ToDouble(tbSPositionY.Text);                //double PositionR = Convert.ToDouble(tbSPositionR.Text);                bool result = m_SemHardwareMgr.MoveSEMToPoint(PositionX, PositionY);                if (result)                {                    //配置结果提示                    ShowMessage(3);                    log.Info("Set successfully, current X and Y coordinates should be:(" + PositionX.ToString() + "," + PositionY.ToString() + ")");                }                else                {                    ShowMessage(4);                    log.Error("Failed to set X and Y coordinates!");                }            }            catch (Exception ex)            {                //记录日志信息                log.Error(ex.Message.ToString());            }        }        private void btnMoveSEMToPoint_Click(object sender, EventArgs e)        {            try            {                //判断是否为空                if (!IsNull(tbSPositionX))                {                    this.Focus();                    return;                }                if (!IsType(tbSPositionX.Text, 2))                {                    this.Focus();                    return;                }                if (!IsNull(tbSPositionY))                {                    this.Focus();                    return;                }                if (!IsType(tbSPositionY.Text, 2))                {                    this.Focus();                    return;                }                if (!IsNull(tbSPositionR))                {                    this.Focus();                    return;                }                if (!IsType(tbSPositionR.Text, 2))                {                    this.Focus();                    return;                }                //赋值                double PositionX = Convert.ToDouble(tbSPositionX.Text);                double PositionY = Convert.ToDouble(tbSPositionY.Text);                double PositionR = Convert.ToDouble(tbSPositionR.Text);                bool result = m_SemHardwareMgr.MoveSEMToPoint(PositionX, PositionY, PositionR);            }            catch (Exception ex)            {                //记录日志信息                log.Error(ex.Message.ToString());            }        }        private void btnGBeamBlank_Click(object sender, EventArgs e)        {            try            {                int a_nBeamBlank = 0;                //获取参数                bool result = m_SemHardwareMgr.GetSemBeamBlank(ref a_nBeamBlank);                if (result)                {                    //赋值 显示                    tbBeamBlank.Text = Convert.ToString(a_nBeamBlank);                    log.Info("Beam baffle:" + tbBeamBlank.Text);                }                else                {                    //配置结果提示                    ShowMessage(6);                    log.Error("Failed to obtain the Beam baffle!");                }            }            catch (Exception ex)            {                //记录日志信息(异常日志)                log.Error(ex.Message.ToString());            }        }        private void btnSBeamBlank_Click(object sender, EventArgs e)        {            try            {                bool a_nBeamBlank = false;                //判断是否为空与类型                if (!IsNull(tbSBeamBlank))                {                    tbSBeamBlank.Focus();                    return;                }                if (!IsType(tbSBeamBlank.Text, 1))                {                    tbSBeamBlank.Focus();                    return;                }                //获取参数与设置参数                a_nBeamBlank = Convert.ToBoolean(tbSBeamBlank.Text);                bool result = m_SemHardwareMgr.SetSemBeamBlank(a_nBeamBlank);                if (result)                {                    //配置结果提示                    ShowMessage(3);                    log.Info("etting successful!The current beam baffle should be:" + tbSBeamBlank.Text);                }                else                {                    ShowMessage(4);                    log.Error("Beam baffle setting failed!");                }            }            catch (Exception ex)            {                //记录日志信息(异常日志)                log.Error(ex.Message.ToString());            }        }        private void btnGBrightness_Click(object sender, EventArgs e)        {            try            {                double a_dBrightness = 0;                //获取参数                bool result = m_SemHardwareMgr.GetSemBrightness(ref a_dBrightness);                if (result)                {                    //赋值 显示                    tbBrightness.Text = Convert.ToString(a_dBrightness);                    log.Info("Brightness:" + tbBrightness.Text);                }                else                {                    //配置结果提示                    ShowMessage(6);                    log.Error("Failed to obtain the Brightness");                }            }            catch (Exception ex)            {                //记录日志信息(异常日志)                log.Error(ex.Message.ToString());            }        }        private void btnSBrightness_Click(object sender, EventArgs e)        {            try            {                double a_dBrightness = 0;                //判断是否为空与类型                if (!IsNull(tbSBrightness))                {                    tbSBrightness.Focus();                    return;                }                if (!IsType(tbSBrightness.Text, 2))                {                    tbSBrightness.Focus();                    return;                }                //获取参数与设置参数                a_dBrightness = Convert.ToInt32(tbSBrightness.Text);                //获取参数                bool result = m_SemHardwareMgr.SetSemBrightness(a_dBrightness);                if (result)                {                    //配置结果提示                    ShowMessage(3);                    log.Info("Setting successful!, the current brightness should be:" + tbSBrightness.Text);                }                else                {                    ShowMessage(4);                    log.Error("Brightness setting failed!");                }            }            catch (Exception ex)            {                //记录日志信息(异常日志)                log.Error(ex.Message.ToString());            }        }        private void btnGContrast_Click(object sender, EventArgs e)        {            try            {                double a_dContrast = 0;                //获取参数                bool result = m_SemHardwareMgr.GetSemContrast(ref a_dContrast);                if (result)                {                    //赋值 显示                    tbContrast.Text = Convert.ToString(a_dContrast);                    log.Info("Contrast:" + tbContrast.Text);                }                else                {                    //配置结果提示                    ShowMessage(6);                    log.Error("Failed to obtain contrast!");                }            }            catch (Exception ex)            {                //记录日志信息(异常日志)                log.Error(ex.Message.ToString());            }        }        private void btnSContrast_Click(object sender, EventArgs e)        {            try            {                double a_dContrast = 0;                //判断是否为空与类型                if (!IsNull(tbSContrast))                {                    tbSContrast.Focus();                    return;                }                if (!IsType(tbSContrast.Text, 2))                {                    tbSContrast.Focus();                    return;                }                //赋值                a_dContrast = Convert.ToInt32(tbSContrast.Text);                //获取结果参数                bool result = m_SemHardwareMgr.SetSemContrast(a_dContrast);                if (result)                {                    //配置结果提示                    ShowMessage(3);                    log.Info("Set successfully, the current contrast should be:" + tbSContrast.Text);                }                else                {                    ShowMessage(4);                    log.Error("Contrast setting failed!");                }            }            catch (Exception ex)            {                //记录日志信息(异常日志)                log.Error(ex.Message.ToString());            }        }        private void btnGFWD_Click(object sender, EventArgs e)        {            try            {                double a_dWorkingDistance = 0;                //获取参数                bool result = m_SemHardwareMgr.GetWorkingDistance(ref a_dWorkingDistance);                if (result)                {                    //赋值 显示                    tbFWD.Text = Convert.ToString(a_dWorkingDistance);                    log.Info("WorkingDistance:" + tbFWD.Text);                }                else                {                    //配置结果提示                    ShowMessage(6);                    log.Error("Fail to obtain the WorkingDistance!");                }            }            catch (Exception ex)            {                //记录日志信息(异常日志)                log.Error(ex.Message.ToString());            }        }        private void btnSFWD_Click(object sender, EventArgs e)        {            try            {                double a_dWorkingDistance = 0;                //判断是否为空与类型                if (!IsNull(tbSFWD))                {                    tbSFWD.Focus();                    return;                }                if (!IsType(tbSFWD.Text, 2))                {                    tbSFWD.Focus();                    return;                }                //赋值                a_dWorkingDistance = Convert.ToDouble(tbSFWD.Text);                //获取结果参数                bool result = m_SemHardwareMgr.SetWorkingDistance(a_dWorkingDistance);                if (result)                {                    //配置结果提示                    ShowMessage(3);                    log.Info("Setting successful!, the current working distance should be:"+ tbSFWD.Text);                }                else                {                    ShowMessage(4);                    log.Error("Working distance setting failed!");                }            }            catch (Exception ex)            {                //记录日志信息(异常日志)                log.Error(ex.Message.ToString());            }        }        private void btnGKV_Click(object sender, EventArgs e)        {            try            {                double a_dKV = 0;                //获取参数                bool result = m_SemHardwareMgr.GetSemHighTension(ref a_dKV);                if (result)                {                    //赋值 显示                    tbKV.Text = Convert.ToString(a_dKV);                    log.Info("Electron microscope voltage:" + tbKV.Text);                }                else                {                    //配置结果提示                    ShowMessage(6);                    log.Error("Failed to obtain electron microscope voltage value!");                }            }            catch (Exception ex)            {                //记录日志信息(异常日志)                log.Error(ex.Message.ToString());            }        }        private void btnSKV_Click(object sender, EventArgs e)        {            try            {                double a_dKV = 0;                //判断是否为空与类型                if (!IsNull(tbSKV))                {                    tbSKV.Focus();                    return;                }                if (!IsType(tbSKV.Text, 2))                {                    tbSKV.Focus();                    return;                }                //赋值                a_dKV = Convert.ToInt32(tbSKV.Text);                //获取结果参数                bool result = m_SemHardwareMgr.SetSemHighTension(a_dKV);                if (result)                {                    //配置结果提示                    ShowMessage(3);                    log.Info("Setting successful!, the current voltage value should be:" + tbSKV.Text);                }                else                {                    ShowMessage(4);                    log.Error("Voltage setting failed!");                }            }            catch (Exception ex)            {                //记录日志信息(异常日志)                log.Error(ex.Message.ToString());            }        }        private void btnGMagnification_Click(object sender, EventArgs e)        {            try            {                double a_dMagnification = 0;                //获取参数                bool result = m_SemHardwareMgr.GetMagnification(ref a_dMagnification);                if (result)                {                    //赋值 显示                    tbMagnification.Text = Convert.ToString(a_dMagnification);                    log.Info("SemMagnification:" + tbMagnification.Text);                }                else                {                    //配置结果提示                    ShowMessage(6);                    log.Error("Fail to obtain the SemMagnification!");                }            }            catch (Exception ex)            {                //记录日志信息(异常日志)                log.Error(ex.Message.ToString());            }        }        private void btnSMagnification_Click(object sender, EventArgs e)        {            try            {                double a_dMagnification = 0;                //判断是否为空与类型                if (!IsNull(tbSMagnification))                {                    tbSMagnification.Focus();                    return;                }                if (!IsType(tbSMagnification.Text, 2))                {                    tbSMagnification.Focus();                    return;                }                //赋值                a_dMagnification = Convert.ToInt32(tbSMagnification.Text);                //获取结果参数                bool result = m_SemHardwareMgr.SetMagnification(a_dMagnification);                if (result)                {                    //配置结果提示                    ShowMessage(3);                    log.Info("Setting successful!, the current magnification should be:");                }                else                {                    ShowMessage(4);                    log.Error("Magnification setting failed!");                }            }            catch (Exception ex)            {                //记录日志信息(异常日志)                log.Error(ex.Message.ToString());            }        }        private void btnGSpotSize_Click(object sender, EventArgs e)        {            //try            //{            //    double a_dSpotSize = 0;            //    //获取参数            //    //记录日志信息(异常日志)            //    bool result = cfun.GetSemSpotSize(ref a_dSpotSize);            //    if (result)            //    {            //        //赋值 显示            //        tbSpotSize.Text = Convert.ToString(a_dSpotSize);            //        log.Info("Spot size:" + tbSpotSize.Text);            //    }            //    else            //    {            //        //配置结果提示            //        ShowMessage(6);            //    }            //}            //catch (Exception ex)            //{            //    //记录日志信息(异常日志)            //    log.Error(ex.Message.ToString());            //}        }        private void btnSSpotSize_Click(object sender, EventArgs e)        {            //try            //{            //    double a_dSpotSize = 0;            //    //判断是否为空与类型            //    if (!IsNull(tbSSpotSize))            //    {            //        tbSSpotSize.Focus();            //        return;            //    }            //    if (!IsType(tbSSpotSize.Text, 2))            //    {            //        tbSSpotSize.Focus();            //        return;            //    }            //    //赋值            //    a_dSpotSize = Convert.ToInt32(tbSSpotSize.Text);            //    //获取结果参数            //    bool result = cfun.SetSemSpotSize(a_dSpotSize);            //    if (result)            //    {            //        //配置结果提示            //        ShowMessage(3);            //        log.Info("Setting successful!, the current spot size should be:");            //    }            //    else            //    {            //        ShowMessage(4);            //        log.Error("Spot size setting failed!");            //    }            //}            //catch (Exception ex)            //{            //    //记录日志信息(异常日志)            //    log.Error(ex.Message.ToString());            //}        }        private void btnHT_Click(object sender, EventArgs e)        {            try            {                double a_bHTValue = 0;                //获取参数                bool result = m_SemHardwareMgr.GetSemHighTension(ref a_bHTValue);                if (a_bHTValue > 0)                {                    //赋值 显示                    cbHT.Checked = true;                    log.Info("HT:" + cbHT.Checked.ToString());                }                else                {                    //配置结果提示                    ShowMessage(6);                    log.Error("Fail to obtain the HT!");                }            }            catch (Exception ex)            {                //记录日志信息(异常日志)                log.Error(ex.Message.ToString());            }        }        private void btnSHT_Click(object sender, EventArgs e)        {            try            {bool a_bHTValue = false;                //判断是否为空与类型                //赋值                a_bHTValue = cbSHT.Checked;                //获取结果参数                bool result = m_SemHardwareMgr.SetSemBeamBlank(a_bHTValue);                if (result)                {                    //配置结果提示                    ShowMessage(3);                    log.Info("Setting successful!, the current voltage should be:" + cbSHT.Checked.ToString());                }                else                {                    ShowMessage(4);                    log.Error("Voltage setting failed!");                }            }            catch (Exception ex)            {                //记录日志信息(异常日志)                log.Error(ex.Message.ToString());            }        }        private void btnGSemScanFieldXY_Click(object sender, EventArgs e)        {            try            {                //获取参数                double dScanFieldSizeX = 0;                double dScanFieldSizeY = 0;                m_SemHardwareMgr.GetScanFieldSize100(ref dScanFieldSizeX, ref dScanFieldSizeY);                if (dScanFieldSizeX != 0)                {                    //赋值 显示                    tbGSemScanFieldX.Text = dScanFieldSizeX.ToString();                    tbSemScanFieldY.Text = dScanFieldSizeY.ToString();                    log.Info("SemScanFieldX,SemScanFieldY:(" + tbGSemScanFieldX.Text + "," + tbSemScanFieldY.Text + ")");                }                else                {                    //配置结果提示                    ShowMessage(6);                    log.Error("Fail to obtain the SemScanFieldX,SemScanFieldY!");                }            }            catch (Exception ex)            {                //记录日志信息(异常日志)                log.Error(ex.Message.ToString());            }        }        private void btnSSemScanFieldXY_Click(object sender, EventArgs e)        {            try            {                //判断是否为空                if (!IsNull(tbGSemScanFieldX))                {                    return;                }                if (!IsNull(tbSemScanFieldY))                {                    return;                }                Size xySize = new Size();                //赋值                xySize.Width = Convert.ToInt32(tbGSemScanFieldX.Text);                xySize.Height = Convert.ToInt32(tbSemScanFieldY.Text);                m_SemHardwareMgr.SetScanFieldSize100(xySize.Width, xySize.Height);                //配置结果提示                ShowMessage(3);                log.Info("etting successful!, the current scanning matrix X, the Y-axis should be:(" + tbGSemScanFieldX.Text + "," + tbSemScanFieldY.Text + ")");            }            catch (Exception ex)            {                //记录日志信息                log.Error(ex.Message.ToString());            }        }        private void btnGScanMode_Click(object sender, EventArgs e)        {            //try            //{            //    int a_nScanMode = 0;            //    //获取参数            //    bool result = cfun.GetSemScanMode(ref a_nScanMode);            //    if (result)            //    {            //        //赋值 显示            //        tbScanMode.Text = Convert.ToString(a_nScanMode);            //    }            //    else            //    {            //        //配置结果提示            //        ShowMessage(6);            //    }            //}            //catch (Exception ex)            //{            //    //记录日志信息(异常日志)            //    log.Error(ex.Message.ToString());            //}        }        private void btnScanMode_Click(object sender, EventArgs e)        {            //try            //{            //    int a_nScanMode = 0;            //    //判断是否为空与类型            //    if (!IsNull(tbSScanMode))            //    {            //        return;            //    }            //    //赋值            //    a_nScanMode = Convert.ToInt32(tbSScanMode.Text);            //    //获取结果参数            //    bool result = cfun.SetSemScanMode(a_nScanMode);            //    if (result)            //    {            //        //配置结果提示            //        ShowMessage(3);            //    }            //    else            //    {            //        ShowMessage(4);            //    }            //}            //catch (Exception ex)            //{            //    //记录日志信息(异常日志)            //    log.Error(ex.Message.ToString());            //}        }        #endregion        private void btnGLienTime_Click(object sender, EventArgs e)        {        }        private void bVoltageClose_Click(object sender, EventArgs e)        {            bool a_HTValue = true;            bool result = m_SemHardwareMgr.SetSemBeamCurrent(a_HTValue);            //bool result = cfun.SetSemBeamBlank(a_HTValue);            //bool result = cfun.SetSemHTOnOff(a_HTValue);            //MessageBox.Show("Whether the shutdown voltage was successful:" + Convert.ToBoolean(result).ToString());        }        private void bVoltageStatus_Click(object sender, EventArgs e)        {            bool a_HTValue = true;            //bool result = cfun.SetSemBeamCurrent(a_HTValue);            bool result = m_SemHardwareMgr.SetSemBeamBlank(a_HTValue);            //bool result = cfun.SetSemHTOnOff(a_HTValue);            //MessageBox.Show("Whether the shutdown voltage was successful:" + Convert.ToBoolean(result).ToString());        }        private void button1_Click(object sender, EventArgs e)        {            bool result = m_SemHardwareMgr.SetScanExternal(true);            if (!result)            {                MessageBox.Show("SetExternalOn failed!");                        }        }        private void button2_Click(object sender, EventArgs e)        {            bool result = m_SemHardwareMgr.SetScanExternal(false);            if (!result)            {                MessageBox.Show("SetExternalOn failed!");            }        }        private void label17_Click(object sender, EventArgs e)        {        }    }}
 |