SemTestForms.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using System.Xml;
  13. using NSOTSController;
  14. namespace OTSSysMgrApp
  15. {
  16. public partial class SemTestForms : Form
  17. {
  18. #region 全部变量声明
  19. //连接状态
  20. bool ConnectionState = false;
  21. // 判断是否是模拟状态 FASE: 不是在模拟环境下 True: 在模拟环境下
  22. //bool IsSimulationStatus = false;
  23. //获取当前电镜的ID号
  24. int SemType = 0;
  25. //获取XML 路径
  26. static string xmlFilePath = System.Configuration.ConfigurationManager.ConnectionStrings["XMLFilePath"].ConnectionString;
  27. //日志路径
  28. static string LogPath = System.Configuration.ConfigurationManager.ConnectionStrings["LogPath"].ConnectionString;
  29. static NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
  30. //电镜设置对象
  31. NSOTSController.COTSControlFunExport cfun = null;
  32. //国际化
  33. OTSSysMgrTools.Language lan;
  34. //国际化存储信息
  35. Hashtable table;
  36. #endregion
  37. #region 构造方法
  38. public SemTestForms()
  39. {
  40. InitializeComponent();
  41. //控制类对象初始化
  42. if (cfun == null)
  43. {
  44. cfun = new COTSControlFunExport();
  45. }
  46. //初始化其他参数
  47. Init();
  48. //国际化
  49. lan = new OTSSysMgrTools.Language(this);
  50. table = lan.GetNameTable(this.Name);
  51. }
  52. /// <summary>
  53. /// 初始化其他参数
  54. /// </summary>
  55. public void Init()
  56. {
  57. //获取模拟状态
  58. //IsSimulationStatus = cfun.IsSimulationStatus();
  59. }
  60. #endregion
  61. #region 保存设置
  62. /// <summary>
  63. /// 保存设置
  64. /// </summary>
  65. /// <param name="Name">节点名称</param>
  66. /// <param name="Value">节点参数值</param>
  67. public void SaveSetting(string Name, string Value)
  68. {
  69. try
  70. {
  71. //判断XML文件中是否存在
  72. if (!XMLOperationClass.ExistsXmlInfo(Name))
  73. {
  74. //调用添加XML节点功能
  75. XMLOperationClass.AddXmlInfo(Name, Value);
  76. }
  77. else
  78. {
  79. //调用修改XML节点功能
  80. XMLOperationClass.EditXmlInfo(Name, Value);
  81. }
  82. }
  83. catch (Exception ex)
  84. {
  85. //记录日志信息
  86. log.Error(ex.Message.ToString());
  87. }
  88. }
  89. #endregion
  90. #region 修改设置
  91. public void EditSetting(string Name, string Value)
  92. {
  93. try
  94. {
  95. //调用修改XML节点功能
  96. XMLOperationClass.EditXmlInfo(Name, Value);
  97. }
  98. catch (Exception ex)
  99. {
  100. //记录日志信息
  101. log.Error(ex.Message.ToString());
  102. }
  103. }
  104. #endregion
  105. #region 判断文件路径
  106. /// <summary>
  107. /// 判断文件路径
  108. /// </summary>
  109. /// <param name="path"></param>
  110. /// <returns></returns>
  111. public bool CreateFile(string path)
  112. {
  113. Directory.CreateDirectory(path);
  114. return false;
  115. }
  116. #endregion
  117. #region 判断文件是否存在
  118. /// <summary>
  119. /// 判断文件是否存在
  120. /// </summary>
  121. /// <param name="path">文件路径</param>
  122. /// <returns></returns>
  123. public bool ExistsFile(string path)
  124. {
  125. try
  126. {
  127. if (File.Exists(path))
  128. {
  129. return true;
  130. }
  131. return false;
  132. }
  133. catch (Exception ex)
  134. {
  135. //记录日志信息
  136. log.Error(ex.Message.ToString());
  137. return false;
  138. }
  139. }
  140. #endregion
  141. public void GetBtnState(bool btnState)
  142. {
  143. //循环窗体中
  144. foreach (Control item in gbGetMethods.Controls)
  145. {
  146. if (item is Button)
  147. {
  148. //if(!(((Button)item).Name== "btnGLineTime"))
  149. //{
  150. ((Button)item).Enabled = btnState;
  151. //}
  152. }
  153. }
  154. foreach (Control item in gbSetMethods.Controls)
  155. {
  156. if (item is Button)
  157. {
  158. //if (!(((Button)item).Name == "btnGLineTime"))
  159. //{
  160. ((Button)item).Enabled = btnState;
  161. //}
  162. }
  163. }
  164. }
  165. #region 用户信息提示
  166. /// <summary>
  167. /// 提示
  168. /// </summary>
  169. /// <param name="Message"></param>
  170. private void ShowMessage(int MessageType)
  171. {
  172. string message1 = table["message1"].ToString();
  173. string message2 = table["message2"].ToString();
  174. string message3 = table["message3"].ToString();
  175. string message4 = table["message4"].ToString();
  176. string message5 = table["message5"].ToString();
  177. string message6 = table["message6"].ToString();
  178. string message7 = table["message7"].ToString();
  179. string message8 = table["message8"].ToString();
  180. string message9 = table["message9"].ToString();
  181. string message10 = table["message10"].ToString();
  182. string MessageInfo = string.Empty;
  183. switch (MessageType)
  184. {
  185. case 0:
  186. MessageInfo = message1;
  187. break;
  188. case 1:
  189. MessageInfo = message2;
  190. break;
  191. case 2:
  192. MessageInfo = message3;
  193. break;
  194. case 3:
  195. MessageInfo = message4;
  196. break;
  197. case 4:
  198. MessageInfo = message5;
  199. break;
  200. case 5:
  201. MessageInfo = message6;
  202. break;
  203. case 6:
  204. MessageInfo = message7;
  205. break;
  206. case 7:
  207. MessageInfo = message8;
  208. break;
  209. case 8:
  210. MessageInfo = message9;
  211. break;
  212. case 9:
  213. MessageInfo = message10;
  214. break;
  215. }
  216. MessageBox.Show(MessageInfo, "Tip");
  217. }
  218. #endregion
  219. #region 判断控制内容是否为空 与 判断输入的格式是否正确
  220. /// <summary>
  221. /// 判断控制内容是否为空
  222. /// </summary>
  223. /// <param name="tbContent"></param>
  224. /// <returns></returns>
  225. public bool IsNull(TextBox tbContent)
  226. {
  227. if (tbContent.Text.Trim().Equals(""))
  228. {
  229. //为空提示
  230. ShowMessage(0);
  231. //获取焦点
  232. tbContent.Focus();
  233. return false;
  234. }
  235. return true;
  236. }
  237. /// <summary>
  238. ///
  239. /// </summary>
  240. /// <param name="objValue"></param>
  241. /// <param name="objType"></param>
  242. /// <returns></returns>
  243. public bool IsType(object ObjValue, int ObjType)
  244. {
  245. try
  246. {
  247. switch (ObjType)
  248. {
  249. case 1:
  250. int intValue = Convert.ToInt32(ObjValue);
  251. break;
  252. case 2:
  253. double douValue = Convert.ToDouble(ObjValue);
  254. break;
  255. case 3:
  256. float floValue = Convert.ToSingle(ObjValue);
  257. break;
  258. }
  259. return true;
  260. }
  261. catch (Exception)
  262. {
  263. //为空提示
  264. ShowMessage(7);
  265. return false;
  266. }
  267. }
  268. /// <summary>
  269. /// 判断是否连接
  270. /// </summary>
  271. /// <returns></returns>
  272. public bool IsConnection()
  273. {
  274. try
  275. {
  276. if (ConnectionState)
  277. {
  278. return true;
  279. }
  280. return false;
  281. }
  282. catch (Exception)
  283. {
  284. //为空提示
  285. ShowMessage(7);
  286. return false;
  287. }
  288. }
  289. #endregion
  290. #region 窗体控制的事件汇总
  291. private void SemTestForms_Load(object sender, EventArgs e)
  292. {
  293. ////循环窗体中
  294. foreach (Control item in gbGetMethods.Controls)
  295. {
  296. if (item is Button)
  297. {
  298. //绑定按钮点击事件
  299. //item.Click += new System.EventHandler(btnGetInfo_Click);
  300. ((Button)item).Enabled = false;
  301. }
  302. }
  303. foreach (Control item in gbSetMethods.Controls)
  304. {
  305. if (item is Button)
  306. {
  307. //绑定按钮点击事件
  308. //item.Click += new System.EventHandler(btnSetInfo_Click);
  309. ((Button)item).Enabled = false;
  310. }
  311. }
  312. }
  313. private void btnDone_Click(object sender, EventArgs e)
  314. {
  315. //遍历tabHardwareSet标签中所有的TextBox控件
  316. //foreach (Control control in this.gbSetMethods.Controls)
  317. //{
  318. // //节点名称与节点参数值
  319. // string Name = string.Empty;
  320. // string Value = string.Empty;
  321. // //判断类型名称
  322. // if (control is TextBox)
  323. // {
  324. // Name = (control as TextBox).Name.Substring(2);
  325. // //获取节点名称与节点参数值
  326. // Value = (control as TextBox).Text;
  327. // if(!Value.Equals(""))
  328. // SaveSetting(Name, Value);
  329. // }
  330. // //判断类型名称
  331. // if (control is CheckBox)
  332. // {
  333. // Name = (control as CheckBox).Name.Substring(2);
  334. // //获取节点名称与节点参数值
  335. // Value = (control as CheckBox).Checked ? "true" : "false";
  336. // SaveSetting(Name, Value);
  337. // }
  338. //}
  339. //返回关闭窗口返回值
  340. this.DialogResult = DialogResult.OK;
  341. }
  342. private void btnGetInfo_Click(object sender, EventArgs e)
  343. {
  344. if (!IsConnection())
  345. {
  346. return;
  347. }
  348. //获取响应按钮
  349. Button btnTest = (Button)sender;
  350. try
  351. {
  352. //节点名称与节点参数值
  353. string Name = string.Empty;
  354. string Value = string.Empty;
  355. //判断本地中是否存在文件路径
  356. if (ExistsFile(xmlFilePath))
  357. {
  358. //遍历tabHardwareSet标签中所有的ComboBox控件
  359. foreach (Control control in this.gbGetMethods.Controls)
  360. {
  361. //判断类型名称
  362. if (control is TextBox)
  363. {
  364. Name = (control as TextBox).Name.Substring(2);
  365. if (btnTest.Name.Contains(Name))
  366. {
  367. //获取节点名称与节点参数值
  368. System.Xml.XmlNode xmlNode = XMLOperationClass.GetXMLInformationValue("S" + Name);
  369. (control as TextBox).Text = ((XmlElement)xmlNode).GetAttribute("Value");
  370. }
  371. }
  372. //判断类型名称
  373. if (control is CheckBox)
  374. {
  375. Name = (control as CheckBox).Name.Substring(2);
  376. if (btnTest.Name.Contains(Name))
  377. {
  378. //获取节点名称与节点参数值
  379. System.Xml.XmlNode xmlNode = XMLOperationClass.GetXMLInformationValue(Name);
  380. (control as CheckBox).Checked = ((XmlElement)xmlNode).GetAttribute("Value").Equals("true") ? true : false;
  381. }
  382. }
  383. }
  384. }
  385. else
  386. {
  387. //如果文件不存在,则创建文件
  388. CreateFile(xmlFilePath);
  389. }
  390. }
  391. catch (Exception ex)
  392. {
  393. //记录日志信息
  394. log.Error(ex.Message.ToString());
  395. }
  396. }
  397. private void btnSetInfo_Click(object sender, EventArgs e)
  398. {
  399. if (!IsConnection())
  400. {
  401. return;
  402. }
  403. //获取响应按钮
  404. Button btnTest = (Button)sender;
  405. try
  406. {
  407. //节点名称与节点参数值
  408. string Name = string.Empty;
  409. string Value = string.Empty;
  410. //判断本地中是否存在文件路径
  411. if (ExistsFile(xmlFilePath))
  412. {
  413. //遍历tabHardwareSet标签中所有的TextBox控件
  414. foreach (Control control in this.gbSetMethods.Controls)
  415. {
  416. //判断类型名称
  417. if (control is TextBox)
  418. {
  419. Name = (control as TextBox).Name.Substring(2);
  420. if (btnTest.Name.Contains(Name))
  421. {
  422. //获取节点名称与节点参数值
  423. Value = (control as TextBox).Text;
  424. SaveSetting(Name, Value);
  425. }
  426. }
  427. //判断类型名称
  428. if (control is CheckBox)
  429. {
  430. Name = (control as CheckBox).Name.Substring(2);
  431. if (btnTest.Name.Contains(Name))
  432. {
  433. //获取节点名称与节点参数值
  434. Value = (control as CheckBox).Checked ? "true" : "false";
  435. SaveSetting(Name, Value);
  436. }
  437. }
  438. }
  439. }
  440. else
  441. {
  442. //如果文件不存在,则创建文件
  443. CreateFile(xmlFilePath);
  444. }
  445. }
  446. catch (Exception ex)
  447. {
  448. //记录日志信息
  449. log.Error(ex.Message.ToString());
  450. }
  451. }
  452. private void btnGetAll_Click(object sender, EventArgs e)
  453. {
  454. }
  455. private void BtnConnect_Click(object sender, EventArgs e)
  456. {
  457. if (!ConnectionState)
  458. {
  459. //和电镜建立通讯连接
  460. ConnectionState = cfun.ConncetSem();
  461. ///获取当前电镜的ID号
  462. SemType = cfun.GetSemType();
  463. if (!ConnectionState)
  464. {
  465. ShowMessage(2);
  466. }
  467. else
  468. {
  469. string str = table["str1"].ToString();
  470. BtnConnect.Text = str;
  471. GetBtnState(true);
  472. }
  473. }
  474. else
  475. {
  476. string str = table["str2"].ToString();
  477. //断开电镜连接
  478. if (cfun.DisConnectSem())
  479. {
  480. }
  481. else
  482. {
  483. //ShowMessage(9);
  484. }
  485. BtnConnect.Text = str;
  486. ConnectionState = false;
  487. GetBtnState(false);
  488. }
  489. }
  490. private void SemTestForms_FormClosing(object sender, FormClosingEventArgs e)
  491. {
  492. try
  493. {
  494. //断开电镜连接
  495. cfun.DisConnectSem();
  496. //释放DLL内存
  497. cfun.FreeHardware();
  498. }
  499. catch (Exception ex)
  500. {
  501. //记录日志信息(异常日志)
  502. log.Error(ex.Message.ToString());
  503. }
  504. }
  505. private void btnGPositionXYR_Click(object sender, EventArgs e)
  506. {
  507. try
  508. {
  509. //赋值
  510. double PositionX = 0;
  511. double PositionY = 0;
  512. double PositionR = 0;
  513. //获取参数
  514. bool result = cfun.GetSemPositionXY(ref PositionX, ref PositionY, ref PositionR);
  515. if (result)
  516. {
  517. //赋值 显示
  518. tbPositionX.Text = Convert.ToDouble(PositionX).ToString();
  519. tbPositionY.Text = Convert.ToDouble(PositionY).ToString();
  520. tbPositionR.Text = Convert.ToDouble(PositionR).ToString();
  521. }
  522. else
  523. {
  524. //配置结果提示
  525. ShowMessage(6);
  526. }
  527. }
  528. catch (Exception ex)
  529. {
  530. //记录日志信息(异常日志)
  531. log.Error(ex.Message.ToString());
  532. }
  533. }
  534. private void btnSPositionXYR_Click(object sender, EventArgs e)
  535. {
  536. try
  537. {
  538. //判断是否为空
  539. if (!IsNull(tbSPositionX))
  540. {
  541. this.Focus();
  542. return;
  543. }
  544. if (!IsType(tbSPositionX.Text, 2))
  545. {
  546. this.Focus();
  547. return;
  548. }
  549. if (!IsNull(tbSPositionY))
  550. {
  551. this.Focus();
  552. return;
  553. }
  554. if (!IsType(tbSPositionY.Text, 2))
  555. {
  556. this.Focus();
  557. return;
  558. }
  559. //if (!IsNull(tbSPositionR))
  560. //{
  561. // this.Focus();
  562. // return;
  563. //}
  564. //if (!IsType(tbSPositionR.Text, 2))
  565. //{
  566. // this.Focus();
  567. // return;
  568. //}
  569. //赋值
  570. double PositionX = Convert.ToDouble(tbSPositionX.Text);
  571. double PositionY = Convert.ToDouble(tbSPositionY.Text);
  572. double PositionR = 0;//Convert.ToDouble(tbSPositionR.Text);
  573. bool result = cfun.SetSemPositionXY(PositionX, PositionY, PositionR);
  574. if (result)
  575. {
  576. //配置结果提示
  577. ShowMessage(3);
  578. }
  579. else
  580. {
  581. ShowMessage(4);
  582. }
  583. }
  584. catch (Exception ex)
  585. {
  586. //记录日志信息
  587. log.Error(ex.Message.ToString());
  588. }
  589. }
  590. private void btnMoveSEMToPoint_Click(object sender, EventArgs e)
  591. {
  592. try
  593. {
  594. //判断是否为空
  595. if (!IsNull(tbSPositionX))
  596. {
  597. this.Focus();
  598. return;
  599. }
  600. if (!IsType(tbSPositionX.Text, 2))
  601. {
  602. this.Focus();
  603. return;
  604. }
  605. if (!IsNull(tbSPositionY))
  606. {
  607. this.Focus();
  608. return;
  609. }
  610. if (!IsType(tbSPositionY.Text, 2))
  611. {
  612. this.Focus();
  613. return;
  614. }
  615. if (!IsNull(tbSPositionR))
  616. {
  617. this.Focus();
  618. return;
  619. }
  620. if (!IsType(tbSPositionR.Text, 2))
  621. {
  622. this.Focus();
  623. return;
  624. }
  625. //赋值
  626. double PositionX = Convert.ToDouble(tbSPositionX.Text);
  627. double PositionY = Convert.ToDouble(tbSPositionY.Text);
  628. double PositionR = Convert.ToDouble(tbSPositionR.Text);
  629. bool result = cfun.MoveSEMToPoint(PositionX, PositionY, PositionR);
  630. }
  631. catch (Exception ex)
  632. {
  633. //记录日志信息
  634. log.Error(ex.Message.ToString());
  635. }
  636. }
  637. private void btnGBeamBlank_Click(object sender, EventArgs e)
  638. {
  639. try
  640. {
  641. int a_nBeamBlank = 0;
  642. //获取参数
  643. bool result = cfun.GetSemBeamBlank(ref a_nBeamBlank);
  644. if (result)
  645. {
  646. //赋值 显示
  647. tbBeamBlank.Text = Convert.ToString(a_nBeamBlank);
  648. }
  649. else
  650. {
  651. //配置结果提示
  652. ShowMessage(6);
  653. }
  654. }
  655. catch (Exception ex)
  656. {
  657. //记录日志信息(异常日志)
  658. log.Error(ex.Message.ToString());
  659. }
  660. }
  661. private void btnSBeamBlank_Click(object sender, EventArgs e)
  662. {
  663. try
  664. {
  665. int a_nBeamBlank = 0;
  666. //判断是否为空与类型
  667. if (!IsNull(tbSBeamBlank))
  668. {
  669. tbSBeamBlank.Focus();
  670. return;
  671. }
  672. if (!IsType(tbSBeamBlank.Text, 1))
  673. {
  674. tbSBeamBlank.Focus();
  675. return;
  676. }
  677. //获取参数与设置参数
  678. a_nBeamBlank = Convert.ToInt32(tbSBeamBlank.Text);
  679. bool result = cfun.SetSemBeamBlank(a_nBeamBlank);
  680. if (result)
  681. {
  682. //配置结果提示
  683. ShowMessage(3);
  684. }
  685. else
  686. {
  687. ShowMessage(4);
  688. }
  689. }
  690. catch (Exception ex)
  691. {
  692. //记录日志信息(异常日志)
  693. log.Error(ex.Message.ToString());
  694. }
  695. }
  696. private void btnGBrightness_Click(object sender, EventArgs e)
  697. {
  698. try
  699. {
  700. double a_dBrightness = 0;
  701. //获取参数
  702. bool result = cfun.GetSemBrightness(ref a_dBrightness);
  703. if (result)
  704. {
  705. //赋值 显示
  706. tbBrightness.Text = Convert.ToString(a_dBrightness);
  707. }
  708. else
  709. {
  710. //配置结果提示
  711. ShowMessage(6);
  712. }
  713. }
  714. catch (Exception ex)
  715. {
  716. //记录日志信息(异常日志)
  717. log.Error(ex.Message.ToString());
  718. }
  719. }
  720. private void btnSBrightness_Click(object sender, EventArgs e)
  721. {
  722. try
  723. {
  724. double a_dBrightness = 0;
  725. //判断是否为空与类型
  726. if (!IsNull(tbSBrightness))
  727. {
  728. tbSBrightness.Focus();
  729. return;
  730. }
  731. if (!IsType(tbSBrightness.Text, 2))
  732. {
  733. tbSBrightness.Focus();
  734. return;
  735. }
  736. //获取参数与设置参数
  737. a_dBrightness = Convert.ToInt32(tbSBrightness.Text);
  738. //获取参数
  739. bool result = cfun.SetSemBrightness(a_dBrightness);
  740. if (result)
  741. {
  742. //配置结果提示
  743. ShowMessage(3);
  744. }
  745. else
  746. {
  747. ShowMessage(4);
  748. }
  749. }
  750. catch (Exception ex)
  751. {
  752. //记录日志信息(异常日志)
  753. log.Error(ex.Message.ToString());
  754. }
  755. }
  756. private void btnGContrast_Click(object sender, EventArgs e)
  757. {
  758. try
  759. {
  760. double a_dContrast = 0;
  761. //获取参数
  762. bool result = cfun.GetSemContrast(ref a_dContrast);
  763. if (result)
  764. {
  765. //赋值 显示
  766. tbContrast.Text = Convert.ToString(a_dContrast);
  767. }
  768. else
  769. {
  770. //配置结果提示
  771. ShowMessage(6);
  772. }
  773. }
  774. catch (Exception ex)
  775. {
  776. //记录日志信息(异常日志)
  777. log.Error(ex.Message.ToString());
  778. }
  779. }
  780. private void btnSContrast_Click(object sender, EventArgs e)
  781. {
  782. try
  783. {
  784. double a_dContrast = 0;
  785. //判断是否为空与类型
  786. if (!IsNull(tbSContrast))
  787. {
  788. tbSContrast.Focus();
  789. return;
  790. }
  791. if (!IsType(tbSContrast.Text, 2))
  792. {
  793. tbSContrast.Focus();
  794. return;
  795. }
  796. //赋值
  797. a_dContrast = Convert.ToInt32(tbSContrast.Text);
  798. //获取结果参数
  799. bool result = cfun.SetSemContrast(a_dContrast);
  800. if (result)
  801. {
  802. //配置结果提示
  803. ShowMessage(3);
  804. }
  805. else
  806. {
  807. ShowMessage(4);
  808. }
  809. }
  810. catch (Exception ex)
  811. {
  812. //记录日志信息(异常日志)
  813. log.Error(ex.Message.ToString());
  814. }
  815. }
  816. private void btnGFWD_Click(object sender, EventArgs e)
  817. {
  818. try
  819. {
  820. double a_dWorkingDistance = 0;
  821. //获取参数
  822. bool result = cfun.GetSemWorkingDistance(ref a_dWorkingDistance);
  823. if (result)
  824. {
  825. //赋值 显示
  826. tbFWD.Text = Convert.ToString(a_dWorkingDistance);
  827. }
  828. else
  829. {
  830. //配置结果提示
  831. ShowMessage(6);
  832. }
  833. }
  834. catch (Exception ex)
  835. {
  836. //记录日志信息(异常日志)
  837. log.Error(ex.Message.ToString());
  838. }
  839. }
  840. private void btnSFWD_Click(object sender, EventArgs e)
  841. {
  842. try
  843. {
  844. double a_dWorkingDistance = 0;
  845. //判断是否为空与类型
  846. if (!IsNull(tbSFWD))
  847. {
  848. tbSFWD.Focus();
  849. return;
  850. }
  851. if (!IsType(tbSFWD.Text, 2))
  852. {
  853. tbSFWD.Focus();
  854. return;
  855. }
  856. //赋值
  857. a_dWorkingDistance = Convert.ToDouble(tbSFWD.Text);
  858. //获取结果参数
  859. bool result = cfun.SetSemWorkingDistance(a_dWorkingDistance);
  860. if (result)
  861. {
  862. //配置结果提示
  863. ShowMessage(3);
  864. }
  865. else
  866. {
  867. ShowMessage(4);
  868. }
  869. }
  870. catch (Exception ex)
  871. {
  872. //记录日志信息(异常日志)
  873. log.Error(ex.Message.ToString());
  874. }
  875. }
  876. private void btnGKV_Click(object sender, EventArgs e)
  877. {
  878. try
  879. {
  880. double a_dKV = 0;
  881. //获取参数
  882. bool result = cfun.GetSemHighTension(ref a_dKV);
  883. if (result)
  884. {
  885. //赋值 显示
  886. tbKV.Text = Convert.ToString(a_dKV);
  887. }
  888. else
  889. {
  890. //配置结果提示
  891. ShowMessage(6);
  892. }
  893. }
  894. catch (Exception ex)
  895. {
  896. //记录日志信息(异常日志)
  897. log.Error(ex.Message.ToString());
  898. }
  899. }
  900. private void btnSKV_Click(object sender, EventArgs e)
  901. {
  902. try
  903. {
  904. double a_dKV = 0;
  905. //判断是否为空与类型
  906. if (!IsNull(tbSKV))
  907. {
  908. tbSKV.Focus();
  909. return;
  910. }
  911. if (!IsType(tbSKV.Text, 2))
  912. {
  913. tbSKV.Focus();
  914. return;
  915. }
  916. //赋值
  917. a_dKV = Convert.ToInt32(tbSKV.Text);
  918. //获取结果参数
  919. bool result = cfun.SetSemHighTension(a_dKV);
  920. if (result)
  921. {
  922. //配置结果提示
  923. ShowMessage(3);
  924. }
  925. else
  926. {
  927. ShowMessage(4);
  928. }
  929. }
  930. catch (Exception ex)
  931. {
  932. //记录日志信息(异常日志)
  933. log.Error(ex.Message.ToString());
  934. }
  935. }
  936. private void btnGMagnification_Click(object sender, EventArgs e)
  937. {
  938. try
  939. {
  940. double a_dMagnification = 0;
  941. //获取参数
  942. bool result = cfun.GetSemMagnification(ref a_dMagnification);
  943. if (result)
  944. {
  945. //赋值 显示
  946. tbMagnification.Text = Convert.ToString(a_dMagnification);
  947. }
  948. else
  949. {
  950. //配置结果提示
  951. ShowMessage(6);
  952. }
  953. }
  954. catch (Exception ex)
  955. {
  956. //记录日志信息(异常日志)
  957. log.Error(ex.Message.ToString());
  958. }
  959. }
  960. private void btnSMagnification_Click(object sender, EventArgs e)
  961. {
  962. try
  963. {
  964. double a_dMagnification = 0;
  965. //判断是否为空与类型
  966. if (!IsNull(tbSMagnification))
  967. {
  968. tbSMagnification.Focus();
  969. return;
  970. }
  971. if (!IsType(tbSMagnification.Text, 2))
  972. {
  973. tbSMagnification.Focus();
  974. return;
  975. }
  976. //赋值
  977. a_dMagnification = Convert.ToInt32(tbSMagnification.Text);
  978. //获取结果参数
  979. bool result = cfun.SetSemMagnification(a_dMagnification);
  980. if (result)
  981. {
  982. //配置结果提示
  983. ShowMessage(3);
  984. MessageBox.Show(cfun.GetMagnification().ToString());
  985. }
  986. else
  987. {
  988. ShowMessage(4);
  989. }
  990. }
  991. catch (Exception ex)
  992. {
  993. //记录日志信息(异常日志)
  994. log.Error(ex.Message.ToString());
  995. }
  996. }
  997. private void btnGSpotSize_Click(object sender, EventArgs e)
  998. {
  999. try
  1000. {
  1001. double a_dSpotSize = 0;
  1002. //获取参数
  1003. //记录日志信息(异常日志)
  1004. bool result = cfun.GetSemSpotSize(ref a_dSpotSize);
  1005. if (result)
  1006. {
  1007. //赋值 显示
  1008. tbSpotSize.Text = Convert.ToString(a_dSpotSize);
  1009. }
  1010. else
  1011. {
  1012. //配置结果提示
  1013. ShowMessage(6);
  1014. }
  1015. }
  1016. catch (Exception ex)
  1017. {
  1018. //记录日志信息(异常日志)
  1019. log.Error(ex.Message.ToString());
  1020. }
  1021. }
  1022. private void btnSSpotSize_Click(object sender, EventArgs e)
  1023. {
  1024. try
  1025. {
  1026. double a_dSpotSize = 0;
  1027. //判断是否为空与类型
  1028. if (!IsNull(tbSSpotSize))
  1029. {
  1030. tbSSpotSize.Focus();
  1031. return;
  1032. }
  1033. if (!IsType(tbSSpotSize.Text, 2))
  1034. {
  1035. tbSSpotSize.Focus();
  1036. return;
  1037. }
  1038. //赋值
  1039. a_dSpotSize = Convert.ToInt32(tbSSpotSize.Text);
  1040. //获取结果参数
  1041. bool result = cfun.SetSemSpotSize(a_dSpotSize);
  1042. if (result)
  1043. {
  1044. //配置结果提示
  1045. ShowMessage(3);
  1046. }
  1047. else
  1048. {
  1049. ShowMessage(4);
  1050. }
  1051. }
  1052. catch (Exception ex)
  1053. {
  1054. //记录日志信息(异常日志)
  1055. log.Error(ex.Message.ToString());
  1056. }
  1057. }
  1058. private void btnHT_Click(object sender, EventArgs e)
  1059. {
  1060. try
  1061. {
  1062. int a_bHTValue = 0;
  1063. //获取参数
  1064. bool result = cfun.GetSemHTOnOff(ref a_bHTValue);
  1065. if (result)
  1066. {
  1067. //赋值 显示
  1068. cbHT.Checked = Convert.ToBoolean(a_bHTValue);
  1069. }
  1070. else
  1071. {
  1072. //配置结果提示
  1073. ShowMessage(6);
  1074. }
  1075. }
  1076. catch (Exception ex)
  1077. {
  1078. //记录日志信息(异常日志)
  1079. log.Error(ex.Message.ToString());
  1080. }
  1081. }
  1082. private void btnSHT_Click(object sender, EventArgs e)
  1083. {
  1084. try
  1085. {int a_bHTValue = 0;
  1086. //判断是否为空与类型
  1087. //赋值
  1088. a_bHTValue = Convert.ToInt32(cbSHT.Checked);
  1089. //获取结果参数
  1090. bool result = cfun.SetSemHTOnOff(a_bHTValue);
  1091. if (result)
  1092. {
  1093. //配置结果提示
  1094. ShowMessage(3);
  1095. }
  1096. else
  1097. {
  1098. ShowMessage(4);
  1099. }
  1100. }
  1101. catch (Exception ex)
  1102. {
  1103. //记录日志信息(异常日志)
  1104. log.Error(ex.Message.ToString());
  1105. }
  1106. }
  1107. private void btnGSemScanFieldXY_Click(object sender, EventArgs e)
  1108. {
  1109. try
  1110. {
  1111. //获取参数
  1112. Size result = cfun.GetSemScanField100();
  1113. if (result != null)
  1114. {
  1115. //赋值 显示
  1116. tbGSemScanFieldX.Text = Convert.ToDouble(result.Width).ToString();
  1117. tbSemScanFieldY.Text = Convert.ToDouble(result.Height).ToString();
  1118. }
  1119. else
  1120. {
  1121. //配置结果提示
  1122. ShowMessage(6);
  1123. }
  1124. }
  1125. catch (Exception ex)
  1126. {
  1127. //记录日志信息(异常日志)
  1128. log.Error(ex.Message.ToString());
  1129. }
  1130. }
  1131. private void btnSSemScanFieldXY_Click(object sender, EventArgs e)
  1132. {
  1133. try
  1134. {
  1135. //判断是否为空
  1136. if (!IsNull(tbGSemScanFieldX))
  1137. {
  1138. return;
  1139. }
  1140. if (!IsNull(tbSemScanFieldY))
  1141. {
  1142. return;
  1143. }
  1144. Size xySize = new Size();
  1145. //赋值
  1146. xySize.Width = Convert.ToInt32(tbGSemScanFieldX.Text);
  1147. xySize.Height = Convert.ToInt32(tbSemScanFieldY.Text);
  1148. cfun.SetSemScanField100(xySize);
  1149. //配置结果提示
  1150. ShowMessage(3);
  1151. }
  1152. catch (Exception ex)
  1153. {
  1154. //记录日志信息
  1155. log.Error(ex.Message.ToString());
  1156. }
  1157. }
  1158. private void btnGScanMode_Click(object sender, EventArgs e)
  1159. {
  1160. try
  1161. {
  1162. int a_nScanMode = 0;
  1163. //获取参数
  1164. bool result = cfun.GetSemScanMode(ref a_nScanMode);
  1165. if (result)
  1166. {
  1167. //赋值 显示
  1168. tbScanMode.Text = Convert.ToString(a_nScanMode);
  1169. }
  1170. else
  1171. {
  1172. //配置结果提示
  1173. ShowMessage(6);
  1174. }
  1175. }
  1176. catch (Exception ex)
  1177. {
  1178. //记录日志信息(异常日志)
  1179. log.Error(ex.Message.ToString());
  1180. }
  1181. }
  1182. private void btnScanMode_Click(object sender, EventArgs e)
  1183. {
  1184. try
  1185. {
  1186. int a_nScanMode = 0;
  1187. //判断是否为空与类型
  1188. if (!IsNull(tbSScanMode))
  1189. {
  1190. return;
  1191. }
  1192. //赋值
  1193. a_nScanMode = Convert.ToInt32(tbSScanMode.Text);
  1194. //获取结果参数
  1195. bool result = cfun.SetSemScanMode(a_nScanMode);
  1196. if (result)
  1197. {
  1198. //配置结果提示
  1199. ShowMessage(3);
  1200. }
  1201. else
  1202. {
  1203. ShowMessage(4);
  1204. }
  1205. }
  1206. catch (Exception ex)
  1207. {
  1208. //记录日志信息(异常日志)
  1209. log.Error(ex.Message.ToString());
  1210. }
  1211. }
  1212. #endregion
  1213. private void btnGLienTime_Click(object sender, EventArgs e)
  1214. {
  1215. }
  1216. }
  1217. }