SemTestForms.cs 35 KB

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