ControllerSettingForm.cs 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using System.Xml;
  5. using System.IO;
  6. using System.Windows.Forms.DataVisualization.Charting;
  7. using System.Threading;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using OTSCLRINTERFACE;
  11. using OTSModelSharp.ServiceCenter;
  12. namespace OTSSysMgrApp
  13. {
  14. public partial class ControllerSettingForm : Form
  15. {
  16. #region 全部变量声明
  17. RecommendedConfiguration recommendedConfiguration;
  18. //连接状态
  19. bool ConnectionState = false;
  20. static string xmlFilePath = System.Configuration.ConfigurationManager.ConnectionStrings["XMLFilePath"].ConnectionString;
  21. //日志路径
  22. static string LogPath = System.Configuration.ConfigurationManager.ConnectionStrings["LogPath"].ConnectionString;
  23. static NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
  24. IEDSController m_EDSHardwareMgr = null;
  25. //图片
  26. Bitmap bitmap = null;
  27. //国际化
  28. Language lan;
  29. //国际化存储信息
  30. Hashtable table;
  31. #endregion
  32. public enum connectionEnumType
  33. {
  34. EDSOnlyPointXRay = 0,
  35. EDSMultiPointXRay = 1,
  36. EDSAreaXRay = 2,
  37. ScanImage = 3
  38. }
  39. #region 构造函数
  40. public ControllerSettingForm()
  41. {
  42. InitializeComponent();
  43. m_EDSHardwareMgr = EDSController.GetEDSController(Convert.ToInt32(tbRWidth.Text), Convert.ToInt32(tbRHeight.Text), 5000);
  44. lan = new Language(this);
  45. table = lan.GetNameTable(this.Name);
  46. }
  47. /// <summary>
  48. /// 连接电镜
  49. /// </summary>
  50. /// <param name="connectionType"></param>
  51. public bool ConnectionSem(connectionEnumType connectionType)
  52. {
  53. //连接电镜标识
  54. bool DisConnResult = false;
  55. //判断连接状态
  56. if (!ConnectionState)
  57. {
  58. //连接电镜设置
  59. DisConnResult = m_EDSHardwareMgr.Init();
  60. }
  61. if (DisConnResult)
  62. {
  63. ConnectionState = true;
  64. }
  65. else
  66. {
  67. ConnectionState = false;
  68. }
  69. return DisConnResult;
  70. }
  71. /// <summary>
  72. /// EDS初始化
  73. /// </summary>
  74. public bool EDSInit()
  75. {
  76. bool initResult = false;
  77. //线程调用 加载
  78. initResult = m_EDSHardwareMgr.Init();
  79. return initResult;
  80. }
  81. #endregion
  82. #region 窗体中控件事件汇总
  83. private void btnClearXRay_Click(object sender, EventArgs e)
  84. {
  85. chartXRay.Series.RemoveAt(0);
  86. }
  87. private void btnCollectionTime_Click(object sender, EventArgs e)
  88. {
  89. try
  90. {
  91. int CollectionTime = 0;
  92. //判断是否为空与类型
  93. if (!IsNull(tbCollectionTime))
  94. {
  95. tbCollectionTime.Focus();
  96. return;
  97. }
  98. if (!IsType(tbCollectionTime.Text, 1))
  99. {
  100. tbCollectionTime.Focus();
  101. return;
  102. }
  103. //获取参数与设置参数
  104. CollectionTime = Convert.ToInt32(tbCollectionTime.Text);
  105. bool result = false;
  106. if (result)
  107. {
  108. //配置结果提示
  109. ShowMessage(3);
  110. }
  111. else
  112. {
  113. ShowMessage(4);
  114. }
  115. }
  116. catch (Exception ex)
  117. {
  118. //记录日志信息(异常日志)
  119. log.Error(ex.Message.ToString());
  120. }
  121. }
  122. private void ControllerSettingForm_Load(object sender, EventArgs e)
  123. {
  124. //设置窗体图表
  125. Control.CheckForIllegalCrossThreadCalls = false;
  126. ddlDwellTime.SelectedIndex = 0;
  127. InitXRayData();
  128. int width = Convert.ToInt32(tbRWidth.Text);
  129. int height = Convert.ToInt32(tbRHeight.Text);
  130. m_EDSHardwareMgr = EDSController.GetEDSController(width, height, 5000);
  131. cb_Xdirection.Items.Add("LEFT_TOWARD");
  132. cb_Xdirection.Items.Add("RIGHT_TOWARD");
  133. cb_Ydirection.Items.Add("UP_TOWARD");
  134. cb_Ydirection.Items.Add("DOWN_TOWARD");
  135. tB_scanFieldSize100.Text = "1270";
  136. cb_imageresolution.Items.Add("1024*768");
  137. cb_imageresolution.Items.Add("1024*704");
  138. cb_imageresolution.Items.Add("1536*1024");
  139. string xmlpath = Application.StartupPath + @"\Config\SysData\OTSProgMgrParam.pmf";
  140. string xAxisDir = "";
  141. string yAxisDir = "";
  142. string scanFieldSize = "";
  143. ReadConfigXml(xmlpath, ref xAxisDir, ref yAxisDir, ref scanFieldSize);
  144. if (xAxisDir.Split(':')[1] == "LEFT_TOWARD")
  145. {
  146. cb_Xdirection.SelectedIndex = 0;
  147. }
  148. else
  149. {
  150. cb_Xdirection.SelectedIndex = 1;
  151. }
  152. if (yAxisDir.Split(':')[1] == "UP_TOWARD")
  153. {
  154. cb_Ydirection.SelectedIndex = 0;
  155. }
  156. else
  157. {
  158. cb_Ydirection.SelectedIndex = 1;
  159. }
  160. tB_scanFieldSize100.Text = scanFieldSize;
  161. cb_imageresolution.SelectedIndex = 0;
  162. }
  163. Thread ScanThread = null;
  164. private void btnDisplay_Click(object sender, EventArgs e)
  165. {
  166. GetBSEDisplay();
  167. }
  168. private bool GetScanImage(int iWidth, int iHeigh, string DwellTime, ref byte[] bImageData)
  169. {
  170. //电镜设置对象
  171. var scan = ScanController.GetScanController();
  172. int GetImgCount = 0;
  173. try
  174. {
  175. //连接电镜
  176. bool IsConnec = scan.Init();
  177. if (!IsConnec)
  178. {
  179. return false;
  180. }
  181. #region 设置图像分辨率
  182. //设置宽度
  183. if (!scan.SetImageSize(iWidth, iHeigh))
  184. {
  185. return false;
  186. }
  187. #endregion
  188. #region 采集时间
  189. //采集时间
  190. int nDwellTime = Convert.ToInt32(DwellTime);
  191. //设置采集时间
  192. if (!scan.SetDwellTime(nDwellTime))
  193. {
  194. return false;
  195. }
  196. #endregion
  197. int resultCount = iWidth * iHeigh;
  198. var img = scan.AcquireBSEImage();
  199. bImageData = img.GetImageDataPtr();
  200. }
  201. catch (Exception ex)
  202. {
  203. NLog.LogManager.GetCurrentClassLogger().Error(ex.ToString());
  204. return false;
  205. }
  206. return true;
  207. }
  208. protected void GetBSEDisplay()
  209. {
  210. try
  211. {
  212. string str1 = table["str1"].ToString();
  213. btnDisplay.Text = str1;
  214. btnDisplay.Enabled = false;
  215. btnDisplay.Refresh();
  216. if (pbImage.Image != null)
  217. {
  218. pbImage.Image = null;
  219. pbImage.Refresh();
  220. }
  221. Thread.Sleep(100);
  222. //设置图像分辨率
  223. int width = 0;
  224. int height = 0;
  225. //获取宽度
  226. width = Convert.ToInt32(tbRWidth.Text);
  227. height = Convert.ToInt32(tbRHeight.Text);
  228. byte[] ImageByte = new byte[width * height];
  229. Bitmap bitmap = null;
  230. int iWidth = Convert.ToInt32(tbRWidth.Text);
  231. int iHeight = Convert.ToInt32(tbRHeight.Text);
  232. bool resultValue = GetScanImage(iWidth, iHeight, ddlDwellTime.Text, ref ImageByte);
  233. string str2 = table["str2"].ToString();
  234. if (resultValue )
  235. {
  236. if (ImageByte != null)
  237. {
  238. bitmap = CImageHandler.ToGrayBitmap(ImageByte, width, height);
  239. pbImage.Image = bitmap;
  240. btnSaveImage.Enabled = true;
  241. log.Info("Image capture success!\nImage resolution:" + tbRWidth.Text + "X" + tbRHeight.Text + ";");
  242. }
  243. else
  244. {
  245. MessageBox.Show(str2, "Tip");
  246. }
  247. }
  248. else
  249. {
  250. MessageBox.Show(str2, "Tip");
  251. }
  252. }
  253. catch (Exception ex)
  254. {
  255. log.Error("ControllerSettingForm_btnDisplay_Click--错误信息:" + ex.ToString());
  256. }
  257. finally
  258. {
  259. string str = table["btndisplay"].ToString();
  260. btnDisplay.Text = str;
  261. btnDisplay.Enabled = true;
  262. btnDisplay.Refresh();
  263. }
  264. }
  265. private void btnClear_Click(object sender, EventArgs e)
  266. {
  267. pbImage.BackgroundImage = null;
  268. }
  269. Thread EDSThread = null;
  270. private void btnDisplayXRay_Click(object sender, EventArgs e)
  271. {
  272. try
  273. {
  274. string str1 = table["str1"].ToString();
  275. btnDisplayXRay.Text = str1;
  276. btnDisplayXRay.Enabled = false;
  277. btnDisplayXRay.Refresh();
  278. btnPointXRay.Enabled = false;
  279. btnPointXRay.Refresh();
  280. btnAreaRay.Enabled = false;
  281. btnAreaRay.Refresh();
  282. btnClearData.Enabled = false;
  283. btnClearData.Refresh();
  284. InitXRayData();
  285. if (ConnectionSem(connectionEnumType.EDSOnlyPointXRay))
  286. {
  287. if (EDSInit())
  288. {
  289. //图像数据
  290. uint[] a_XrayData = new uint[2000];
  291. uint a_Milliseconds = 0;
  292. //采集时间
  293. a_Milliseconds = Convert.ToUInt32(tbCollectionTime.Text);
  294. //采集XRay数据
  295. bool result = m_EDSHardwareMgr.CollectSpectrum(a_Milliseconds, ref a_XrayData);
  296. if (!result)
  297. {
  298. log.Info("CollectSpectrum failed!");
  299. }
  300. int[] XData = new int[2000];
  301. uint nXrayCount = 0;
  302. for (int i = 1; i <= 2000; i++)
  303. {
  304. XData[i - 1] = i;
  305. nXrayCount += a_XrayData[i - 1];
  306. }
  307. //绑定数据源
  308. chartData(XData, a_XrayData);
  309. //显示Xray计数
  310. lbXrayCount.Text = nXrayCount.ToString();
  311. }
  312. }
  313. log.Info("Single point collection succeeded!");
  314. }
  315. catch (Exception ex)
  316. {
  317. //记录日志
  318. log.Error(ex.Message.ToString());
  319. }
  320. finally
  321. {
  322. string str = table["btndisplayxray"].ToString();
  323. btnDisplayXRay.Text = str;
  324. btnDisplayXRay.Enabled = true;
  325. btnDisplayXRay.Refresh();
  326. btnPointXRay.Enabled = true;
  327. btnPointXRay.Refresh();
  328. btnAreaRay.Enabled = true;
  329. btnAreaRay.Refresh();
  330. btnClearData.Enabled = true;
  331. btnClearData.Refresh();
  332. }
  333. }
  334. public void RunEDSThread()
  335. {
  336. try
  337. {
  338. //图像数据
  339. uint[] a_XrayData = new uint[2000];
  340. uint a_Milliseconds = 0;
  341. //采集时间
  342. a_Milliseconds = Convert.ToUInt32(tbCollectionTime.Text);
  343. //采集XRay数据
  344. m_EDSHardwareMgr.CollectSpectrum(a_Milliseconds, ref a_XrayData);
  345. int[] XData = new int[2000];
  346. for (int i = 1; i <= 2000; i++)
  347. {
  348. XData[i - 1] = i;
  349. }
  350. //绑定数据源
  351. chartData(XData, a_XrayData);
  352. }
  353. catch (Exception ex)
  354. {
  355. //记录日志
  356. log.Error(ex.Message.ToString());
  357. }
  358. }
  359. public void chartData(int[] XData, uint[] YData)
  360. {
  361. //chartXRay = new Chart();
  362. //背景
  363. if (chartXRay.ChartAreas.Count == 0)
  364. {
  365. chartXRay.ChartAreas.Add(new ChartArea() { Name = "" }); //背景框
  366. }
  367. chartXRay.ChartAreas[0].Axes[0].MajorGrid.Enabled = false; //X轴上网格
  368. chartXRay.ChartAreas[0].Axes[1].MajorGrid.Enabled = false; //y轴上网格
  369. chartXRay.ChartAreas[0].Axes[0].MajorGrid.LineDashStyle = ChartDashStyle.Dash; //网格类型 短横线
  370. chartXRay.ChartAreas[0].Axes[0].MajorGrid.LineColor = Color.Gray;
  371. chartXRay.ChartAreas[0].Axes[0].MajorTickMark.Enabled = false; // x轴上突出的小点
  372. chartXRay.ChartAreas[0].Axes[1].MajorTickMark.Enabled = false; //
  373. chartXRay.ChartAreas[0].Axes[1].MajorGrid.LineWidth = 1;
  374. //图表数据区,有多个重叠则循环添加
  375. if (chartXRay.Series.Count == 0)
  376. {
  377. chartXRay.Series.Add(new Series() { Name = "" });
  378. }
  379. chartXRay.Series[0].ChartType = SeriesChartType.Line; //图类型(折线)
  380. chartXRay.Series[0].Points.DataBindXY(XData, YData); //添加数据
  381. chartXRay.Series[0].Label = "";
  382. chartXRay.Series[0].LegendText = "";
  383. //折线段配置
  384. chartXRay.Series[0].Color = Color.Blue; //线条颜色
  385. chartXRay.Series[0].BorderWidth = 1; //线条粗细
  386. chartXRay.Series[0].MarkerBorderColor = Color.Red; //标记点边框颜色
  387. chartXRay.Series[0].MarkerBorderWidth = 1; //标记点边框大小
  388. chartXRay.Series[0].MarkerColor = Color.Red; //标记点中心颜色
  389. chartXRay.Series[0].MarkerSize = 0; //标记点大小
  390. //chartXRay.Series[0].BorderWidth = 500;
  391. //另外
  392. //饼图说明设置,这用来设置饼图每一块的信息显示在什么地方
  393. chartXRay.Series[0]["PieLabelStyle"] = "Outside";//将文字移到外侧
  394. chartXRay.Series[0]["PieLineColor"] = "Black";//绘制黑色的连线。
  395. //柱状图其他设置
  396. chartXRay.Series[0]["DrawingStyle"] = "Emboss"; //设置柱状平面形状
  397. chartXRay.Series[0]["PointWidth"] = "0.1"; //设置柱状大小
  398. }
  399. #endregion
  400. #region 设置按钮事件
  401. private void btnSetInfo_Click(object sender, EventArgs e)
  402. {
  403. if (!IsConnection())
  404. {
  405. //return;
  406. }
  407. //获取响应按钮
  408. Button btnTest = (Button)sender;
  409. try
  410. {
  411. //节点名称与节点参数值
  412. string Name = string.Empty;
  413. string Value = string.Empty;
  414. //判断本地中是否存在文件路径
  415. if (ExistsFile(xmlFilePath))
  416. {
  417. //遍历tabHardwareSet标签中所有的TextBox控件
  418. foreach (Control control in this.tabXRay.Controls)
  419. {
  420. //判断类型名称
  421. if (control is TextBox)
  422. {
  423. Name = (control as TextBox).Name.Substring(2);
  424. if (btnTest.Name.Contains(Name))
  425. {
  426. //判断是否为空与类型
  427. if (!IsNull(((TextBox)control)))
  428. {
  429. ((TextBox)control).Focus();
  430. return;
  431. }
  432. if (!IsType(((TextBox)control).Text, 1))
  433. {
  434. ((TextBox)control).Focus();
  435. return;
  436. }
  437. //获取节点名称与节点参数值
  438. Value = (control as TextBox).Text;
  439. SaveSetting(Name, Value);
  440. }
  441. }
  442. }
  443. //遍历tabHardwareSet标签中所有的TextBox控件
  444. foreach (Control control in this.tabImage.Controls)
  445. {
  446. //判断类型名称
  447. if (control is TextBox)
  448. {
  449. Name = (control as TextBox).Name.Substring(2);
  450. if (btnTest.Name.Contains(Name))
  451. {
  452. //判断是否为空与类型
  453. if (!IsNull(((TextBox)control)))
  454. {
  455. ((TextBox)control).Focus();
  456. return;
  457. }
  458. if (!IsType(((TextBox)control).Text, 1))
  459. {
  460. ((TextBox)control).Focus();
  461. return;
  462. }
  463. //获取节点名称与节点参数值
  464. Value = (control as TextBox).Text;
  465. SaveSetting(Name, Value);
  466. }
  467. }
  468. }
  469. }
  470. else
  471. {
  472. //如果文件不存在,则创建文件
  473. CreateFile(xmlFilePath);
  474. }
  475. }
  476. catch (Exception ex)
  477. {
  478. //记录日志信息
  479. log.Error(ex.Message.ToString());
  480. }
  481. }
  482. #endregion
  483. #region 保存设置
  484. /// <summary>
  485. /// 保存设置
  486. /// </summary>
  487. /// <param name="Name">节点名称</param>
  488. /// <param name="Value">节点参数值</param>
  489. public void SaveSetting(string Name, string Value)
  490. {
  491. try
  492. {
  493. //判断XML文件中是否存在
  494. if (!XMLOperationClass.ExistsXmlInfo(Name))
  495. {
  496. //调用添加XML节点功能
  497. XMLOperationClass.AddXmlInfo(Name, Value);
  498. }
  499. else
  500. {
  501. //调用修改XML节点功能
  502. XMLOperationClass.EditXmlInfo(Name, Value);
  503. }
  504. }
  505. catch (Exception ex)
  506. {
  507. //记录日志信息
  508. log.Error(ex.Message.ToString());
  509. }
  510. }
  511. #endregion
  512. #region 修改设置
  513. public void EditSetting(string Name, string Value)
  514. {
  515. try
  516. {
  517. //调用修改XML节点功能
  518. XMLOperationClass.EditXmlInfo(Name, Value);
  519. }
  520. catch (Exception ex)
  521. {
  522. //记录日志信息
  523. log.Error(ex.Message.ToString());
  524. }
  525. }
  526. #endregion
  527. #region 判断文件路径
  528. /// <summary>
  529. /// 判断文件路径
  530. /// </summary>
  531. /// <param name="path"></param>
  532. /// <returns></returns>
  533. public bool CreateFile(string path)
  534. {
  535. Directory.CreateDirectory(path);
  536. return false;
  537. }
  538. #endregion
  539. #region 判断文件是否存在
  540. /// <summary>
  541. /// 判断文件是否存在
  542. /// </summary>
  543. /// <param name="path">文件路径</param>
  544. /// <returns></returns>
  545. public bool ExistsFile(string path)
  546. {
  547. try
  548. {
  549. if (File.Exists(path))
  550. {
  551. return true;
  552. }
  553. return false;
  554. }
  555. catch (Exception ex)
  556. {
  557. //记录日志信息
  558. log.Error(ex.Message.ToString());
  559. return false;
  560. }
  561. }
  562. #endregion
  563. #region 获取窗体中所有参数
  564. /// <summary>
  565. /// 获取窗体中控件的所有参数
  566. /// </summary>
  567. public void GetWindowsControlValue()
  568. {
  569. try
  570. {
  571. XmlDocument doc = new XmlDocument();
  572. //加载Xml文件
  573. doc.Load(xmlFilePath);
  574. //获取根节点
  575. XmlElement root = doc.DocumentElement;
  576. //获取子节点集合
  577. XmlNodeList mainNodes = root.GetElementsByTagName("parameter");
  578. foreach (XmlNode node in mainNodes)
  579. {
  580. //获取Name属性值
  581. string text = ((XmlElement)node).GetAttribute("Name");
  582. string value = ((XmlElement)node).GetAttribute("Value");
  583. foreach (Control control in this.tabXRay.Controls)
  584. {
  585. //判断类型名称
  586. if (control.Name.Contains(text))
  587. {
  588. if (control is TextBox)
  589. {
  590. ((TextBox)control).Text = value;
  591. }
  592. else if (control is ComboBox)
  593. {
  594. ((ComboBox)control).SelectedValue = value;
  595. }
  596. else if (control is CheckBox)
  597. {
  598. ((CheckBox)control).Checked = text.Equals("1") ? true : false;
  599. }
  600. }
  601. }
  602. foreach (Control control in this.tabImage.Controls)
  603. {
  604. //判断类型名称
  605. if (control.Name.Contains(text))
  606. {
  607. if (control is TextBox)
  608. {
  609. ((TextBox)control).Text = value;
  610. }
  611. else if (control is ComboBox)
  612. {
  613. ((ComboBox)control).SelectedValue = value;
  614. }
  615. else if (control is CheckBox)
  616. {
  617. ((CheckBox)control).Checked = text.Equals("1") ? true : false;
  618. }
  619. }
  620. }
  621. }
  622. }
  623. catch (Exception ex)
  624. {
  625. //记录日志信息
  626. log.Error(ex.Message.ToString());
  627. }
  628. }
  629. #endregion
  630. #region 用户信息提示
  631. /// <summary>
  632. /// 提示
  633. /// </summary>
  634. /// <param name="Message"></param>
  635. private void ShowMessage(int MessageType)
  636. {
  637. string message1 = table["message1"].ToString();
  638. string message2 = table["message2"].ToString();
  639. string message3 = table["message3"].ToString();
  640. string message4 = table["message4"].ToString();
  641. string message5 = table["message5"].ToString();
  642. string message6 = table["message6"].ToString();
  643. string message7 = table["message7"].ToString();
  644. string message8 = table["message8"].ToString();
  645. string message9 = table["message9"].ToString();
  646. string message10 = table["message10"].ToString();
  647. string MessageInfo = string.Empty;
  648. switch (MessageType)
  649. {
  650. case 0:
  651. MessageInfo = message1;
  652. break;
  653. case 1:
  654. MessageInfo = message2;
  655. break;
  656. case 2:
  657. MessageInfo = message3;
  658. break;
  659. case 3:
  660. MessageInfo = message4;
  661. break;
  662. case 4:
  663. MessageInfo = message5;
  664. break;
  665. case 5:
  666. MessageInfo = message6;
  667. break;
  668. case 6:
  669. MessageInfo = message7;
  670. break;
  671. case 7:
  672. MessageInfo = message8;
  673. break;
  674. case 8:
  675. MessageInfo = message9;
  676. break;
  677. case 9:
  678. MessageInfo = message10;
  679. break;
  680. }
  681. MessageBox.Show(MessageInfo, "Tip");
  682. }
  683. #endregion
  684. #region 判断控制内容是否为空 与 判断输入的格式是否正确
  685. /// <summary>
  686. /// 判断控制内容是否为空
  687. /// </summary>
  688. /// <param name="tbContent"></param>
  689. /// <returns></returns>
  690. public bool IsNull(TextBox tbContent)
  691. {
  692. if (tbContent.Text.Trim().Equals(""))
  693. {
  694. //为空提示
  695. ShowMessage(0);
  696. //获取焦点
  697. tbContent.Focus();
  698. return false;
  699. }
  700. return true;
  701. }
  702. /// <summary>
  703. ///
  704. /// </summary>
  705. /// <param name="objValue"></param>
  706. /// <param name="objType"></param>
  707. /// <returns></returns>
  708. public bool IsType(object ObjValue, int ObjType)
  709. {
  710. try
  711. {
  712. switch (ObjType)
  713. {
  714. case 1:
  715. int intValue = Convert.ToInt32(ObjValue);
  716. break;
  717. case 2:
  718. double douValue = Convert.ToDouble(ObjValue);
  719. break;
  720. case 3:
  721. float floValue = Convert.ToSingle(ObjValue);
  722. break;
  723. }
  724. return true;
  725. }
  726. catch (Exception)
  727. {
  728. //为空提示
  729. ShowMessage(7);
  730. return false;
  731. }
  732. }
  733. /// <summary>
  734. /// 判断是否连接
  735. /// </summary>
  736. /// <returns></returns>
  737. public bool IsConnection()
  738. {
  739. if (ConnectionState)
  740. {
  741. return true;
  742. }
  743. return false;
  744. }
  745. #endregion
  746. private void ControllerSettingForm_FormClosing(object sender, FormClosingEventArgs e)
  747. {
  748. }
  749. private void tabSetting_SelectedIndexChanged(object sender, EventArgs e)
  750. {
  751. try
  752. {
  753. if (ScanThread != null)
  754. {
  755. ScanThread.Abort();
  756. }
  757. if (EDSThread != null)
  758. {
  759. EDSThread.Abort();
  760. }
  761. if (tabSetting.SelectedIndex == 0)
  762. {
  763. EDSInit();
  764. }
  765. }
  766. catch (Exception)
  767. {
  768. }
  769. }
  770. private void btnSaveImage_Click(object sender, EventArgs e)
  771. {
  772. if (bitmap != null)
  773. {
  774. string fileName = LogPath + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpeg";
  775. bitmap.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg);
  776. }
  777. }
  778. private void btnPointXRay_Click(object sender, EventArgs e)
  779. {
  780. GetPointXRay();
  781. }
  782. protected void GetPointXRay()
  783. {
  784. try
  785. {
  786. string str = table["str1"].ToString();
  787. btnDisplayXRay.Enabled = false;
  788. btnDisplayXRay.Refresh();
  789. btnPointXRay.Text = str;
  790. btnPointXRay.Enabled = false;
  791. btnPointXRay.Refresh();
  792. btnAreaRay.Enabled = false;
  793. btnAreaRay.Refresh();
  794. btnClearData.Enabled = false;
  795. btnClearData.Refresh();
  796. InitXRayData();
  797. if (ConnectionSem(connectionEnumType.EDSMultiPointXRay))
  798. {
  799. if (EDSInit())
  800. {
  801. //图像数据
  802. uint[] a_XrayData = new uint[2000];
  803. uint a_Milliseconds = 0;
  804. //采集时间
  805. a_Milliseconds = Convert.ToUInt32(tbCollectionTime.Text);
  806. //采集XRay数据
  807. List<COTSParticleClr> cOTSParticleClrs = new List<COTSParticleClr>();
  808. for (int i = 0; i < 5; i++)
  809. {
  810. COTSParticleClr cOTSParticle = new COTSParticleClr();
  811. CPosXrayClr cPosXray = new CPosXrayClr();
  812. cOTSParticle.SetXray(cPosXray);
  813. cOTSParticle.SetXRayPos(new Point(100 + i, 100 + i));
  814. cOTSParticleClrs.Add(cOTSParticle);
  815. }
  816. m_EDSHardwareMgr.SetResolution(int.Parse(tbRWidth.Text), int.Parse(tbRHeight.Text));
  817. bool result=m_EDSHardwareMgr.GetXRayByParts(cOTSParticleClrs, a_Milliseconds, false);
  818. if(!result)
  819. {
  820. log.Error("m_EDSHardwareMgr.GetXRayByPoints failed!");
  821. }
  822. int[] XData = new int[2000];
  823. uint nXrayCount = 0;
  824. for (int j = 0; j < 5; j++)
  825. {
  826. a_XrayData = cOTSParticleClrs[j].GetXray().GetXrayData();
  827. for (int i = 1; i <= 2000; i++)
  828. {
  829. XData[i - 1] = i;
  830. nXrayCount += a_XrayData[i - 1];
  831. }
  832. }
  833. //绑定数据源
  834. chartData(XData, a_XrayData);
  835. //显示Xray计数
  836. lbXrayCount.Text = nXrayCount.ToString();
  837. }
  838. }
  839. log.Info("Multipoint collection succeeded!");
  840. }
  841. catch (Exception ex)
  842. {
  843. //记录日志
  844. log.Error(ex.Message.ToString());
  845. }
  846. finally
  847. {
  848. string str = table["btnpointxray"].ToString();
  849. btnPointXRay.Text = str;
  850. btnPointXRay.Enabled = true;
  851. btnPointXRay.Refresh();
  852. btnDisplayXRay.Enabled = true;
  853. btnDisplayXRay.Refresh();
  854. btnAreaRay.Enabled = true;
  855. btnAreaRay.Refresh();
  856. btnClearData.Enabled = true;
  857. btnClearData.Refresh();
  858. }
  859. }
  860. private void btnAreaRay_Click(object sender, EventArgs e)
  861. {
  862. try
  863. {
  864. string str = table["str1"].ToString();
  865. btnDisplayXRay.Enabled = false;
  866. btnDisplayXRay.Refresh();
  867. btnPointXRay.Enabled = false;
  868. btnPointXRay.Refresh();
  869. btnAreaRay.Text = str;
  870. btnAreaRay.Enabled = false;
  871. btnAreaRay.Refresh();
  872. btnClearData.Enabled = false;
  873. btnClearData.Refresh();
  874. InitXRayData();
  875. if (ConnectionSem(connectionEnumType.EDSAreaXRay))
  876. {
  877. if (EDSInit())
  878. {
  879. //图像数据
  880. uint[] a_XrayData = new uint[2000];
  881. uint a_Milliseconds = 0;
  882. //采集时间
  883. a_Milliseconds = Convert.ToUInt32(tbCollectionTime.Text);
  884. //采集XRay数据
  885. var fea = new COTSFeatureClr();
  886. var segs = new List<COTSSegmentClr>();
  887. segs.Add(new COTSSegmentClr(5, 10, 12));
  888. segs.Add(new COTSSegmentClr(6, 10, 12));
  889. segs.Add(new COTSSegmentClr(7, 10, 12));
  890. fea.SetSegmentsList(segs, false);
  891. string ele = "";
  892. //设置图像分辨率
  893. int width = 0;
  894. int height = 0;
  895. //获取宽度
  896. //width = Convert.ToInt32(tbRWidth.Text);
  897. //height = Convert.ToInt32(tbRHeight.Text);
  898. //m_EDSHardwareMgr.SetResolution(width, height);
  899. bool isTrue = GetXRayBySingleFeature(a_Milliseconds, fea, ref a_XrayData,ref ele, false);
  900. int[] XData = new int[2000];
  901. uint nXrayCount = 0;
  902. for (int i = 1; i <= 2000; i++)
  903. {
  904. XData[i - 1] = i;
  905. nXrayCount += a_XrayData[i - 1];
  906. }
  907. //绑定数据源
  908. chartData(XData, a_XrayData);
  909. //显示Xray计数
  910. lbXrayCount.Text = nXrayCount.ToString();
  911. }
  912. }
  913. }
  914. catch (Exception ex)
  915. {
  916. //记录日志
  917. log.Error(ex.Message.ToString());
  918. }
  919. finally
  920. {
  921. string str = table["btnarearay"].ToString();
  922. btnPointXRay.Enabled = true;
  923. btnPointXRay.Refresh();
  924. btnDisplayXRay.Enabled = true;
  925. btnDisplayXRay.Refresh();
  926. btnAreaRay.Text = str;
  927. btnAreaRay.Enabled = true;
  928. btnAreaRay.Refresh();
  929. btnClearData.Enabled = true;
  930. btnClearData.Refresh();
  931. }
  932. }
  933. public bool GetXRayBySingleFeature(uint a_nXRayAQTime, COTSFeatureClr fea, ref uint[] a_XrayData, ref string ele, bool a_bElementInfo)
  934. {
  935. var eds = EDSController.GetEDSController(Convert.ToInt32(tbRWidth.Text),Convert.ToInt32(tbRHeight.Text),5000);
  936. var part = new COTSParticleClr();
  937. part.SetFeature(fea);
  938. var parts = new List<COTSParticleClr>();
  939. parts.Add(part);
  940. eds.GetXRayByFeatures(parts, a_nXRayAQTime, a_bElementInfo);
  941. a_XrayData = parts[0].GetXray().GetXrayData();
  942. ele = parts[0].GetXray().GetQuantifiedElementsStr();
  943. return true;
  944. }
  945. private void btnClearData_Click(object sender, EventArgs e)
  946. {
  947. try
  948. {
  949. InitXRayData();
  950. }
  951. catch (Exception ex)
  952. {
  953. //记录日志
  954. log.Error(ex.Message.ToString());
  955. }
  956. }
  957. public void InitXRayData()
  958. {
  959. try
  960. {
  961. //图像数据
  962. uint[] a_XrayData = new uint[2000];
  963. uint a_Milliseconds = 0;
  964. //采集时间
  965. a_Milliseconds = Convert.ToUInt32(tbCollectionTime.Text);
  966. //采集XRay数据
  967. int[] XData = new int[2000];
  968. uint nXrayCount = 0;
  969. for (int i = 1; i <= 2000; i++)
  970. {
  971. XData[i - 1] = i;
  972. nXrayCount += a_XrayData[i - 1];
  973. }
  974. //绑定数据源
  975. chartData(XData, a_XrayData);
  976. //显示Xray计数
  977. lbXrayCount.Text = nXrayCount.ToString();
  978. chartXRay.Refresh();
  979. ConnectionState = false;
  980. log.Info("Cleared successfully!");
  981. }
  982. catch (Exception ex)
  983. {
  984. //记录日志
  985. log.Error(ex.Message.ToString());
  986. }
  987. }
  988. #region 获取元素分析
  989. private void btnEanalysis_Click(object sender, EventArgs e)
  990. {
  991. try
  992. {
  993. string str = table["str1"].ToString();
  994. btnDisplayXRay.Enabled = false;
  995. btnDisplayXRay.Refresh();
  996. btnPointXRay.Enabled = false;
  997. btnPointXRay.Refresh();
  998. btnAreaRay.Enabled = false;
  999. btnAreaRay.Refresh();
  1000. btnEanalysis.Text = str;
  1001. btnEanalysis.Enabled = false;
  1002. btnEanalysis.Refresh();
  1003. btnClearData.Enabled = false;
  1004. btnClearData.Refresh();
  1005. InitXRayData();
  1006. if (ConnectionSem(connectionEnumType.EDSAreaXRay))
  1007. {
  1008. if (EDSInit())
  1009. {
  1010. //图像数据
  1011. uint[] a_XrayData = new uint[2000];
  1012. uint a_Milliseconds = 0;
  1013. //采集时间
  1014. a_Milliseconds = Convert.ToUInt32(tbCollectionTime.Text);
  1015. //采集元素分析数据
  1016. ValueType a_nElementNum = 0;
  1017. string a_strResult = string.Empty;
  1018. try
  1019. {
  1020. GetXRayElements(a_Milliseconds, ref a_XrayData, ref a_nElementNum, ref a_strResult);
  1021. }
  1022. catch (Exception ex)
  1023. {
  1024. log.Error("ControllerSettingForm_btnEanalysis_Click:--GetXRayElements()_Exception" + ex.Message.ToString());
  1025. }
  1026. int[] XData = new int[2000];
  1027. uint nXrayCount = 0;
  1028. for (int i = 1; i <= 2000; i++)
  1029. {
  1030. XData[i - 1] = i;
  1031. nXrayCount += a_XrayData[i - 1];
  1032. }
  1033. //绑定数据源
  1034. chartData(XData, a_XrayData);
  1035. //显示Xray计数
  1036. lbXrayCount.Text = nXrayCount.ToString();
  1037. //显示元素分析结果内容
  1038. ShowXRayElementResultForm showXRayElementResultForm = new ShowXRayElementResultForm((int)a_nElementNum, a_strResult);
  1039. showXRayElementResultForm.ShowDialog();
  1040. }
  1041. }
  1042. log.Info("Element analysis success!");
  1043. }
  1044. catch (Exception ex)
  1045. {
  1046. //记录日志
  1047. log.Error(ex.Message.ToString());
  1048. }
  1049. finally
  1050. {
  1051. string str = table["btneanalysis"].ToString();
  1052. btnPointXRay.Enabled = true;
  1053. btnPointXRay.Refresh();
  1054. btnDisplayXRay.Enabled = true;
  1055. btnDisplayXRay.Refresh();
  1056. btnAreaRay.Enabled = true;
  1057. btnAreaRay.Refresh();
  1058. btnEanalysis.Text = str;
  1059. btnEanalysis.Enabled = true;
  1060. btnEanalysis.Refresh();
  1061. btnClearData.Enabled = true;
  1062. btnClearData.Refresh();
  1063. }
  1064. }
  1065. public bool GetXRayElements(uint a_nXRayAQTime, ref uint[] a_XrayData, ref ValueType a_nElementNum, ref string a_strResult)
  1066. {
  1067. var eds = EDSController.GetEDSController(Convert.ToInt32(tbRWidth.Text), Convert.ToInt32(tbRHeight.Text), 5000);
  1068. var part = new COTSParticleClr();
  1069. var pos = new Point(10, 10);
  1070. part.SetXRayPos(pos);
  1071. var parts = new List<COTSParticleClr>();
  1072. parts.Add(part);
  1073. eds.GetXRayByParts(parts, a_nXRayAQTime, true);
  1074. a_XrayData = parts[0].GetXray().GetXrayData();
  1075. a_strResult = parts[0].GetXray().GetQuantifiedElementsStr();
  1076. a_nElementNum = parts[0].GetXray().GetElementQuantifyData().Count;
  1077. return true;
  1078. }
  1079. #endregion
  1080. private void btn_continuousshot_Click(object sender, EventArgs e)
  1081. {
  1082. pictureBox1.Image = null;
  1083. pictureBox2.Image = null;
  1084. pictureBox3.Image = null;
  1085. pictureBox4.Image = null;
  1086. btn_continuousshot.Enabled = false;
  1087. btn_confirm.Enabled = false;
  1088. this.Refresh();
  1089. ISemController m_Sem = SemController.GetSEMController();
  1090. bool flag = m_Sem.Connect();
  1091. //电镜设置对象
  1092. var cfun = ScanController.GetScanController();
  1093. bool IsConnec = cfun.Init();
  1094. double Magnification = 0;
  1095. m_Sem.GetMagnification(ref Magnification);
  1096. //double a_dScanFieldSizeX = 0;
  1097. //double a_dScanFieldSizeY = 0;
  1098. //m_Sem.GetScanFieldSize(ref a_dScanFieldSizeX,ref a_dScanFieldSizeY);
  1099. double scanFieldSize100 = 0;
  1100. double.TryParse(tB_scanFieldSize100.Text, out scanFieldSize100);
  1101. double scanFieldSize = scanFieldSize100 * 100 / Magnification;
  1102. double PositionX = 0;
  1103. double PositionY = 0;
  1104. double PositionR = 0;
  1105. m_Sem.GetSemPositionXY(ref PositionX, ref PositionY, ref PositionR);
  1106. double PositionXO = PositionX;
  1107. double PositionYO = PositionY;
  1108. //double PositionR0 = PositionR;
  1109. int width = 1024;
  1110. int height = 768;
  1111. //设置图像分辨率
  1112. if (cb_imageresolution.Text.Trim() == "")
  1113. {
  1114. MessageBox.Show("imageresolution cannot be null!");
  1115. return;
  1116. }
  1117. else
  1118. {
  1119. width = Convert.ToInt32(cb_imageresolution.Text.Split('*')[0]);
  1120. height = Convert.ToInt32(cb_imageresolution.Text.Split('*')[1]);
  1121. pictureBox1.Height = pictureBox1.Width * height / width;
  1122. pictureBox2.Height = pictureBox1.Width * height / width;
  1123. pictureBox3.Height = pictureBox1.Width * height / width;
  1124. pictureBox4.Height = pictureBox1.Width * height / width;
  1125. pictureBox2.Location = new Point(pictureBox1.Location.X + pictureBox1.Width, pictureBox1.Location.Y);
  1126. pictureBox3.Location = new Point(pictureBox1.Location.X, pictureBox1.Location.Y + pictureBox1.Height);
  1127. pictureBox4.Location = new Point(pictureBox1.Location.X + pictureBox1.Width, pictureBox1.Location.Y + pictureBox1.Height);
  1128. }
  1129. this.Refresh();
  1130. double scanFieldSizeH = scanFieldSize * height / width;
  1131. m_Sem.SetScanExternal(true);
  1132. try
  1133. {
  1134. for (int i = 0; i < 4; i++)
  1135. {
  1136. if (i == 0)
  1137. {
  1138. }
  1139. else if (i == 1)
  1140. {
  1141. switch (cb_Xdirection.SelectedItem.ToString())
  1142. {
  1143. case "RIGHT_TOWARD": PositionX += scanFieldSize; break;
  1144. default: PositionX -= scanFieldSize; break;
  1145. }
  1146. m_Sem.MoveSEMToPoint(PositionX, PositionY);
  1147. }
  1148. else if (i == 2)
  1149. {
  1150. switch (cb_Ydirection.SelectedItem.ToString())
  1151. {
  1152. case "UP_TOWARD": PositionY -= scanFieldSizeH; break;
  1153. default: PositionY += scanFieldSizeH; break;
  1154. }
  1155. m_Sem.MoveSEMToPoint(PositionX, PositionY);
  1156. }
  1157. else
  1158. {
  1159. switch (cb_Xdirection.SelectedItem.ToString())
  1160. {
  1161. case "RIGHT_TOWARD": PositionX -= scanFieldSize; break;
  1162. default: PositionX += scanFieldSize; break;
  1163. }
  1164. m_Sem.MoveSEMToPoint(PositionX, PositionY);
  1165. }
  1166. //Thread.Sleep(50);
  1167. byte[] ImageByte = new byte[width * height];
  1168. bool resultValue = GetScanImage(width, height, "2", ref ImageByte);
  1169. if (resultValue)
  1170. {
  1171. if (ImageByte != null)
  1172. {
  1173. var bitmap = CImageHandler.ToGrayBitmap(ImageByte, width, height);
  1174. switch (i)
  1175. {
  1176. case 0:
  1177. pictureBox1.Image = bitmap;
  1178. break;
  1179. case 1:
  1180. pictureBox2.Image = bitmap;
  1181. break;
  1182. case 2:
  1183. pictureBox4.Image = bitmap;
  1184. break;
  1185. case 3:
  1186. pictureBox3.Image = bitmap;
  1187. break;
  1188. }
  1189. this.Refresh();
  1190. }
  1191. }
  1192. }
  1193. m_Sem.MoveSEMToPoint(PositionXO, PositionYO);
  1194. }
  1195. catch (Exception ex)
  1196. {
  1197. log.Error("continuousshot--错误信息:" + ex.ToString());
  1198. }
  1199. finally
  1200. {
  1201. m_Sem.SetScanExternal(false);
  1202. btn_continuousshot.Enabled = true;
  1203. btn_confirm.Enabled = true;
  1204. btn_continuousshot.Refresh();
  1205. }
  1206. }
  1207. bool ReadConfigXml(string xmlpath,ref string xAxisDir,ref string yAxisDir,ref string scanFieldSize)
  1208. {
  1209. try
  1210. {
  1211. XmlDocument xmlDocument = new XmlDocument();
  1212. xmlDocument.Load(xmlpath);
  1213. XmlNodeList nodeList = xmlDocument.SelectSingleNode("XMLData").ChildNodes;
  1214. foreach (XmlNode xn in nodeList)
  1215. {
  1216. XmlElement xe = (XmlElement)xn;
  1217. if (xe.GetAttribute("RegName") == "StageData")
  1218. {
  1219. scanFieldSize=xe.GetAttribute("scanFieldSize");
  1220. xAxisDir=xe.GetAttribute("xAxisDir");
  1221. yAxisDir=xe.GetAttribute("yAxisDir");
  1222. break;
  1223. }
  1224. }
  1225. }
  1226. catch (Exception ex)
  1227. {
  1228. MessageBox.Show(ex.ToString());
  1229. return false;
  1230. }
  1231. return true;
  1232. }
  1233. bool SaveConfigXml(string xmlpath, string xAxisDir, string yAxisDir, string scanFieldSize)
  1234. {
  1235. try
  1236. {
  1237. XmlDocument xmlDocument = new XmlDocument();
  1238. xmlDocument.Load(xmlpath);
  1239. XmlNodeList nodeList = xmlDocument.SelectSingleNode("XMLData").ChildNodes;
  1240. foreach (XmlNode xn in nodeList)
  1241. {
  1242. XmlElement xe = (XmlElement)xn;
  1243. if (xe.GetAttribute("RegName") == "StageData")
  1244. {
  1245. xe.SetAttribute("scanFieldSize", scanFieldSize);
  1246. xe.SetAttribute("xAxisDir", xAxisDir);
  1247. xe.SetAttribute("yAxisDir", yAxisDir);
  1248. break;
  1249. }
  1250. }
  1251. xmlDocument.Save(xmlpath);
  1252. }
  1253. catch (Exception ex)
  1254. {
  1255. MessageBox.Show(ex.ToString());
  1256. return false;
  1257. }
  1258. return true;
  1259. }
  1260. private void btn_confirm_Click(object sender, EventArgs e)
  1261. {
  1262. double dscanFieldSize100 = 0;
  1263. if (cb_Xdirection.Text.Trim() != null && cb_imageresolution.Text.Trim() != null && cb_Ydirection.Text.Trim() != null && double.TryParse(tB_scanFieldSize100.Text, out dscanFieldSize100))
  1264. {
  1265. string xmlpath = Application.StartupPath + @"\Config\SysData\OTSProgMgrParam.pmf";
  1266. string xAxisDir = "";
  1267. string yAxisDir = "";
  1268. switch (cb_Xdirection.SelectedItem.ToString())
  1269. {
  1270. case "LEFT_TOWARD":
  1271. xAxisDir = "0:LEFT_TOWARD";
  1272. break;
  1273. default:
  1274. xAxisDir = "1:RIGHT_TOWARD";
  1275. break;
  1276. }
  1277. switch(cb_Ydirection.Text)
  1278. {
  1279. case "UP_TOWARD":
  1280. yAxisDir="0:" + cb_Ydirection.Text;
  1281. break;
  1282. default:
  1283. yAxisDir = "1:DOWN_TOWARD";
  1284. break;
  1285. }
  1286. SaveConfigXml(xmlpath, xAxisDir, yAxisDir, tB_scanFieldSize100.Text);
  1287. }
  1288. else
  1289. {
  1290. MessageBox.Show("Please check params!");
  1291. }
  1292. }
  1293. private void btn_Recommendedconfiguration_Click(object sender, EventArgs e)
  1294. {
  1295. if (recommendedConfiguration == null || recommendedConfiguration.IsDisposed)
  1296. {
  1297. recommendedConfiguration = new RecommendedConfiguration();
  1298. recommendedConfiguration.Show();
  1299. }
  1300. else
  1301. {
  1302. recommendedConfiguration.Activate();
  1303. }
  1304. }
  1305. }
  1306. }