CutHole.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. namespace MeasureData
  12. {
  13. //操作步骤,在操作失败时,反馈的状态
  14. public enum Operation
  15. {
  16. Init,
  17. PTInsert,
  18. GetCutPosition,
  19. Cut,
  20. PTOut,
  21. GetHole,
  22. Image,
  23. Analysis,
  24. Element
  25. }
  26. //测试结果
  27. public enum State
  28. {
  29. Ready, //就绪
  30. InProcess, //进行中
  31. Waiting, //等待,半自动化测试过程的状态
  32. Failed, //失败
  33. Success //成功
  34. }
  35. //切割孔
  36. public class CutHole: ISlo
  37. {
  38. #region 切割孔名
  39. /// <summary>
  40. /// 切割孔名
  41. /// </summary>
  42. private string m_HoleName;
  43. public string HoleName
  44. {
  45. get { return this.m_HoleName; }
  46. set { this.m_HoleName = value; }
  47. }
  48. #endregion
  49. #region 坐标位置
  50. private SemPosition m_Position;
  51. public SemPosition Position
  52. {
  53. get { return this.m_Position; }
  54. set { this.m_Position = value; }
  55. }
  56. #endregion
  57. #region 工作状态
  58. //操作步骤
  59. private Operation m_opt;
  60. public Operation OPT
  61. {
  62. get { return this.m_opt; }
  63. set { this.m_opt = value; }
  64. }
  65. //开始时间
  66. private DateTime m_start;
  67. public DateTime START
  68. {
  69. get { return this.m_start; }
  70. set { this.m_start = value; }
  71. }
  72. //结束时间
  73. private DateTime m_end;
  74. public DateTime END
  75. {
  76. get { return this.m_end; }
  77. set { this.m_end = value; }
  78. }
  79. //测试结果
  80. private State m_state;
  81. public State STATE
  82. {
  83. get { return this.m_state; }
  84. set { this.m_state = value; }
  85. }
  86. //测量开关
  87. private bool m_switch;
  88. public bool SWITCH
  89. {
  90. get { return this.m_switch; }
  91. set { this.m_switch = value; }
  92. }
  93. #endregion
  94. //构造函数
  95. public CutHole()
  96. {
  97. Init();
  98. }
  99. //初始化函数
  100. private void Init()
  101. {
  102. //设定初始值
  103. m_opt = Operation.Init;
  104. m_state = State.Ready;
  105. m_switch = false;
  106. Position = new SemPosition();
  107. }
  108. //样品孔存储xml文档
  109. public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
  110. {
  111. Slo slo_cuthole = new Slo();
  112. xString regName = new xString();
  113. regName.AssignValue("CutHole");
  114. slo_cuthole.Register("RegName", regName);
  115. //样品名称
  116. xString SampleName = new xString();
  117. SampleName.AssignValue(this.HoleName);
  118. slo_cuthole.Register("SampleName", SampleName);
  119. slo_cuthole.Register("Position", this.Position);
  120. //操作步骤
  121. xInt OPT = new xInt();
  122. OPT.AssignValue(this.OPT.GetHashCode());
  123. slo_cuthole.Register("OPT", OPT);
  124. //开始时间
  125. xTime_t START = new xTime_t();
  126. START.AssignValue(this.START);
  127. slo_cuthole.Register("START", START);
  128. //结束时间
  129. xTime_t END = new xTime_t();
  130. END.AssignValue(this.END);
  131. slo_cuthole.Register("END", END);
  132. //测量结果
  133. xInt STATE = new xInt();
  134. STATE.AssignValue(this.STATE.GetHashCode());
  135. slo_cuthole.Register("STATE", STATE);
  136. //测量开关
  137. xBool SWITCH = new xBool();
  138. SWITCH.AssignValue(this.SWITCH);
  139. slo_cuthole.Register("SWITCH", SWITCH);
  140. if (isStoring)
  141. {
  142. slo_cuthole.Serialize(true, xml, rootNode);
  143. }
  144. else
  145. {
  146. slo_cuthole.Serialize(false, xml, rootNode);
  147. this.OPT = (Operation)OPT.value();
  148. this.START = START.value();
  149. this.END = END.value();
  150. this.STATE = (State)STATE.value();
  151. this.SWITCH = SWITCH.value();
  152. this.HoleName = SampleName.value();
  153. }
  154. }
  155. }
  156. }