FibWork.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. using System.Xml;
  8. namespace MeasureThread
  9. {
  10. class FibWork
  11. {
  12. NLog.Logger log;
  13. SmartSEMControl.ISEMControl iSEM;
  14. string remoteoriginalEly;
  15. public FibWork(SmartSEMControl.ISEMControl aSEM,string a_originalFibEly)
  16. {
  17. log = NLog.LogManager.GetCurrentClassLogger();
  18. iSEM = aSEM;
  19. remoteoriginalEly = a_originalFibEly;
  20. }
  21. //FIB切割
  22. public bool DoFIBWork()
  23. {
  24. //执行PT沉积的ELY文件
  25. if (!ExcuteEly(remoteoriginalEly))
  26. {
  27. return false;
  28. }
  29. //等待切割完成
  30. while (true)
  31. {
  32. Thread.Sleep(10000);
  33. if (iSEM.GetFIBMode() == 0)
  34. {
  35. break;
  36. }
  37. }
  38. return true;
  39. }
  40. public bool ModifyCutTemplate(float x1,float y1,float x2,float y2)
  41. {
  42. float x0 = 0, y0 = 0, px = 0;
  43. //20201128将移动光束改为移动ely文件中的参数来实现沉积和切割
  44. float xc = (x1 + x2) / 2;
  45. float yc = (y1 + y2) / 2;
  46. x0 = xc - 512;
  47. y0 = 384 - yc;
  48. log.Info("移动像素 x = " + x0.ToString() + ",y=" + y0.ToString(), true);
  49. px = iSEM.GetPixelSize();
  50. //修改FIB切割的ELY文件坐标
  51. XmlDocument xmlDoc = new XmlDocument();
  52. xmlDoc.Load(remoteoriginalEly);//加载baixml文件,xmlpath 为XML文件的路径du
  53. XmlNode xns = xmlDoc.SelectSingleNode("ELAYOUT/STRUCTURE_LIST/STRUCTURE/LAYER_REFERENCE/TRAPEZOID");
  54. if (xns != null)
  55. {
  56. XmlAttributeCollection attributeCol = xns.Attributes;
  57. //遍历自己点属性
  58. double width_a = Convert.ToDouble(attributeCol.GetNamedItem("width_a").Value) / 2.0;
  59. log.Info("XML-Width_a = " + width_a.ToString(), true);
  60. foreach (XmlAttribute attri in attributeCol)
  61. {
  62. if (attri.Name == "x")
  63. {
  64. attri.InnerText = ((x0 * px) * 1000000 - width_a).ToString();
  65. log.Info("XML-TopLeft-X = " + attri.InnerText, true);
  66. }
  67. else if (attri.Name == "y")
  68. {
  69. attri.InnerText = ((y0 * px) * 1000000 - 2.791).ToString();
  70. log.Info("XML-TopLeft-Y = " + attri.InnerText, true);
  71. }
  72. }
  73. }
  74. xns = xmlDoc.SelectSingleNode("ELAYOUT/STRUCTURE_LIST/STRUCTURE/LAYER_REFERENCE/RECT");
  75. if (xns != null)
  76. {
  77. XmlAttributeCollection attributeCol = xns.Attributes;
  78. double width = Convert.ToDouble(attributeCol.GetNamedItem("width").Value) / 2.0;
  79. //遍历自己点属性
  80. foreach (XmlAttribute attri in attributeCol)
  81. {
  82. if (attri.Name == "x")
  83. {
  84. attri.InnerText = ((x0 * px) * 1000000 - width).ToString();
  85. }
  86. else if (attri.Name == "y")
  87. {
  88. attri.InnerText = (((y0 * px) * 1000000) + 2 - 2.791).ToString();
  89. }
  90. }
  91. }
  92. xmlDoc.Save(remoteoriginalEly);//保存的该XML文件,否则更新无效
  93. return true;
  94. }
  95. //执行ELY文件的步骤
  96. public bool ExcuteEly(string a_filename)
  97. {
  98. //执行ELy文件有三个动作
  99. //1. 选择ELY文件
  100. //SendMsg("选择ELY文件");
  101. if (!iSEM.CmdFIBLoadELY(a_filename))
  102. {
  103. //SendMsg("选择ELY文件失败");
  104. return false;
  105. }
  106. Thread.Sleep(1000);
  107. //2. 确认ELY文件
  108. //SendMsg("确认ELY文件");
  109. if (!iSEM.CmdFIBEXPOSUREELY())
  110. {
  111. //SendMsg("确认ELY文件失败");
  112. return false;
  113. }
  114. Thread.Sleep(1000);
  115. //3. 执行ELY文件
  116. //SendMsg("执行ELY文件");
  117. if (!iSEM.CmdFIBSTARTELY())
  118. {
  119. //SendMsg("执行ELY文件失败");
  120. return false;
  121. }
  122. Thread.Sleep(1000);
  123. return true;
  124. }
  125. }
  126. }