CutHole.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. //时间:20200608
  2. //作者:郝爽
  3. //功能:切割孔
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using FileManager;
  10. using System.Xml;
  11. using System.IO;
  12. namespace MeasureData
  13. {
  14. //操作步骤,在操作失败时,反馈的状态
  15. public enum Operation
  16. {
  17. Init,
  18. PTInsert,
  19. GetCutPosition,
  20. Cut,
  21. PTOut,
  22. GetHole,
  23. Image,
  24. Analysis,
  25. Element
  26. }
  27. //测试结果
  28. public enum State
  29. {
  30. Ready, //就绪
  31. InProcess, //进行中
  32. Waiting, //等待,半自动化测试过程的状态
  33. Failed, //失败
  34. Success //成功
  35. }
  36. //切割孔
  37. public class CutHole: ISlo
  38. {
  39. #region 切割孔名
  40. /// <summary>
  41. /// 切割孔名
  42. /// </summary>
  43. private string m_HoleName;
  44. public int HoleNo;
  45. public string data_path;
  46. public string focus_path;
  47. public string StigX_path;
  48. public string StigY_path;
  49. public string EDS_path;
  50. public string workingFolder;
  51. public string HoleName
  52. {
  53. get { return this.m_HoleName; }
  54. set { this.m_HoleName = value; }
  55. }
  56. #endregion
  57. #region 坐标位置
  58. private SemPosition m_Position;
  59. public SemPosition Position
  60. {
  61. get { return this.m_Position; }
  62. set { this.m_Position = value; }
  63. }
  64. #endregion
  65. #region 工作状态
  66. //开始时间
  67. private DateTime m_start;
  68. public DateTime START
  69. {
  70. get { return this.m_start; }
  71. set { this.m_start = value; }
  72. }
  73. //结束时间
  74. private DateTime m_end;
  75. public DateTime END
  76. {
  77. get { return this.m_end; }
  78. set { this.m_end = value; }
  79. }
  80. //测试结果
  81. private State m_state;
  82. public State STATE
  83. {
  84. get { return this.m_state; }
  85. set { this.m_state = value; }
  86. }
  87. //测量开关
  88. private bool m_switch;
  89. public bool SWITCH
  90. {
  91. get { return this.m_switch; }
  92. set { this.m_switch = value; }
  93. }
  94. #endregion
  95. //构造函数
  96. public CutHole()
  97. {
  98. Init();
  99. }
  100. //初始化函数
  101. private void Init()
  102. {
  103. //设定初始值
  104. m_state = State.Ready;
  105. m_switch = false;
  106. Position = new SemPosition();
  107. }
  108. public void InitPath(int holeNo,string currentWorkingFolder)
  109. {
  110. HoleNo = holeNo;
  111. // arg.HoleName = this.HoleName;
  112. //最终数据存放目录
  113. workingFolder = currentWorkingFolder;
  114. data_path = workingFolder + "\\" + this.HoleName;
  115. //对焦数据存放目录
  116. focus_path = workingFolder + "\\" + this.HoleName + "\\Focus";
  117. //MParam.AutoFocus.Path = focus_path;
  118. if (!Directory.Exists(focus_path))
  119. {
  120. Directory.CreateDirectory(focus_path);
  121. }
  122. //StigX数据存放目录
  123. StigX_path = workingFolder + "\\" + this.HoleName + "\\StigX";
  124. //MParam.AutoStigX.Path = StigX_path;
  125. if (!Directory.Exists(StigX_path))
  126. {
  127. Directory.CreateDirectory(StigX_path);
  128. }
  129. //StigY数据存放目录
  130. StigY_path = workingFolder + "\\" + this.HoleName + "\\StigY";
  131. //MParam.AutoStigY.Path = StigY_path;
  132. if (!Directory.Exists(StigY_path))
  133. {
  134. Directory.CreateDirectory(StigY_path);
  135. }
  136. //EDS数据存放路径
  137. EDS_path = workingFolder + "\\" + this.HoleName + "\\EDS";
  138. // MParam.EDSParam.Path = EDS_path;
  139. if (!Directory.Exists(EDS_path))
  140. {
  141. Directory.CreateDirectory(EDS_path);
  142. }
  143. }
  144. //样品孔存储xml文档
  145. public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
  146. {
  147. Slo slo_cuthole = new Slo();
  148. xString regName = new xString();
  149. regName.AssignValue("CutHole");
  150. slo_cuthole.Register("RegName", regName);
  151. //样品名称
  152. xString SampleName = new xString();
  153. SampleName.AssignValue(this.HoleName);
  154. slo_cuthole.Register("SampleName", SampleName);
  155. slo_cuthole.Register("Position", this.Position);
  156. //开始时间
  157. xTime_t START = new xTime_t();
  158. START.AssignValue(this.START);
  159. slo_cuthole.Register("START", START);
  160. //结束时间
  161. xTime_t END = new xTime_t();
  162. END.AssignValue(this.END);
  163. slo_cuthole.Register("END", END);
  164. //测量结果
  165. xInt STATE = new xInt();
  166. STATE.AssignValue(this.STATE.GetHashCode());
  167. slo_cuthole.Register("STATE", STATE);
  168. //测量开关
  169. xBool SWITCH = new xBool();
  170. SWITCH.AssignValue(this.SWITCH);
  171. slo_cuthole.Register("SWITCH", SWITCH);
  172. if (isStoring)
  173. {
  174. slo_cuthole.Serialize(true, xml, rootNode);
  175. }
  176. else
  177. {
  178. slo_cuthole.Serialize(false, xml, rootNode);
  179. this.START = START.value();
  180. this.END = END.value();
  181. this.STATE = (State)STATE.value();
  182. this.SWITCH = SWITCH.value();
  183. this.HoleName = SampleName.value();
  184. }
  185. }
  186. }
  187. }