CutHole.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. Unmeasured,
  30. Failed,
  31. Success
  32. }
  33. //切割孔
  34. public class CutHole: ISlo
  35. {
  36. #region 切割孔名
  37. /// <summary>
  38. /// 切割孔名
  39. /// </summary>
  40. private string m_HoleName;
  41. public string HoleName
  42. {
  43. get { return this.m_HoleName; }
  44. set { this.m_HoleName = value; }
  45. }
  46. #endregion
  47. #region 坐标位置
  48. private SemPosition m_Position;
  49. public SemPosition Position
  50. {
  51. get { return this.m_Position; }
  52. set { this.m_Position = value; }
  53. }
  54. #endregion
  55. #region 工作状态
  56. //操作步骤
  57. private Operation m_opt;
  58. public Operation OPT
  59. {
  60. get { return this.m_opt; }
  61. set { this.m_opt = value; }
  62. }
  63. //开始时间
  64. private DateTime m_start;
  65. public DateTime START
  66. {
  67. get { return this.m_start; }
  68. set { this.m_start = value; }
  69. }
  70. //结束时间
  71. private DateTime m_end;
  72. public DateTime END
  73. {
  74. get { return this.m_end; }
  75. set { this.m_end = value; }
  76. }
  77. //测试结果
  78. private State m_state;
  79. public State STATE
  80. {
  81. get { return this.m_state; }
  82. set { this.m_state = value; }
  83. }
  84. //测量开关
  85. private bool m_switch;
  86. public bool SWITCH
  87. {
  88. get { return this.m_switch; }
  89. set { this.m_switch = value; }
  90. }
  91. #endregion
  92. //构造函数
  93. public CutHole()
  94. {
  95. Init();
  96. }
  97. //初始化函数
  98. private void Init()
  99. {
  100. //设定初始值
  101. m_opt = Operation.Init;
  102. m_state = State.Unmeasured;
  103. m_switch = false;
  104. Position = new SemPosition();
  105. }
  106. //样品孔存储xml文档
  107. public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
  108. {
  109. Slo<CutHole> slo_cuthole = new Slo<CutHole>();
  110. xString regName = new xString();
  111. regName.AssignValue("CutHole");
  112. slo_cuthole.Register("RegName", regName);
  113. //样品名称
  114. xString SampleName = new xString();
  115. SampleName.AssignValue(this.HoleName);
  116. slo_cuthole.Register("SampleName", SampleName);
  117. Slo<SemPosition> slo_sp = new Slo<SemPosition>();
  118. xDouble ptx = new xDouble();
  119. ptx.AssignValue(this.Position.X);
  120. slo_sp.Register("X", ptx);
  121. xDouble pty = new xDouble();
  122. pty.AssignValue(this.Position.X);
  123. slo_sp.Register("Y", pty);
  124. xDouble ptz = new xDouble();
  125. ptz.AssignValue(this.Position.Z);
  126. slo_sp.Register("Z", ptz);
  127. xDouble ptt = new xDouble();
  128. ptt.AssignValue(this.Position.T);
  129. slo_sp.Register("T", ptt);
  130. xDouble ptr = new xDouble();
  131. ptr.AssignValue(this.Position.R);
  132. slo_sp.Register("R", ptr);
  133. xDouble ptm = new xDouble();
  134. ptx.AssignValue(this.Position.M);
  135. slo_sp.Register("M", ptm);
  136. slo_cuthole.Register("Position", slo_sp);
  137. //操作步骤
  138. xInt OPT = new xInt();
  139. OPT.AssignValue(this.OPT.GetHashCode());
  140. slo_cuthole.Register("OPT", OPT);
  141. //开始时间
  142. xTime_t START = new xTime_t();
  143. START.AssignValue(this.START);
  144. slo_cuthole.Register("START", START);
  145. //结束时间
  146. xTime_t END = new xTime_t();
  147. END.AssignValue(this.END);
  148. slo_cuthole.Register("END", END);
  149. //测量结果
  150. xInt STATE = new xInt();
  151. STATE.AssignValue(this.STATE.GetHashCode());
  152. slo_cuthole.Register("STATE", STATE);
  153. //测量开关
  154. xBool SWITCH = new xBool();
  155. SWITCH.AssignValue(this.SWITCH);
  156. slo_cuthole.Register("SWITCH", SWITCH);
  157. if (isStoring)
  158. {
  159. slo_cuthole.Serialize(true, xml, rootNode);
  160. }
  161. else
  162. {
  163. slo_cuthole.Serialize(false, xml, rootNode);
  164. this.OPT = (Operation)OPT.value();
  165. this.START = START.value();
  166. this.END = END.value();
  167. this.STATE = (State)STATE.value();
  168. this.SWITCH = SWITCH.value();
  169. this.Position.X = (float)ptx.value();
  170. this.Position.Y = (float)pty.value();
  171. this.Position.Z = (float)ptz.value();
  172. this.Position.T = (float)ptt.value();
  173. this.Position.R = (float)ptr.value();
  174. this.Position.M = (float)ptm.value();
  175. }
  176. }
  177. }
  178. }