SemPosition.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. //时间:20200610
  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 class SemPosition : ISlo
  15. {
  16. private float m_x, m_y, m_z, m_r, m_t, m_m;
  17. #region X
  18. //限定范围
  19. const float Xmax = 100;
  20. const float Xmin = 0;
  21. public float X
  22. {
  23. get { return this.m_x; }
  24. set => this.m_x = rangeCheckedX(value);
  25. }
  26. private static float rangeCheckedX(float x)
  27. {
  28. if (x > Xmax) x = Xmax;
  29. else if (x < Xmin) x = Xmin;
  30. return x;
  31. }
  32. #endregion
  33. #region Y
  34. //限定范围
  35. const float Ymax = 100;
  36. const float Ymin = 0;
  37. public float Y
  38. {
  39. get { return this.m_y; }
  40. set => this.m_y = rangeCheckedY(value);
  41. }
  42. private static float rangeCheckedY(float y)
  43. {
  44. if (y > Ymax) y = Ymax;
  45. else if (y < Ymin) y = Ymin;
  46. return y;
  47. }
  48. #endregion
  49. #region Z
  50. //限定范围
  51. const float Zmax = 100;
  52. const float Zmin = (float)0.005;
  53. public float Z
  54. {
  55. get { return this.m_z; }
  56. set => this.m_z = rangeCheckedZ(value);
  57. }
  58. private static float rangeCheckedZ(float z)
  59. {
  60. if (z > Zmax) z = Zmax;
  61. else if (z < Zmin) z = Zmin;
  62. return z;
  63. }
  64. #endregion
  65. #region R
  66. //限定范围
  67. const float Rmax = 360;
  68. const float Rmin = 0;
  69. public float R
  70. {
  71. get { return this.m_r; }
  72. set => this.m_r = rangeCheckedR(value);
  73. }
  74. private static float rangeCheckedR(float r)
  75. {
  76. if (r > Rmax) r = Rmax;
  77. else if (r < Rmin) r = Rmin;
  78. return r;
  79. }
  80. #endregion
  81. #region T
  82. //限定范围
  83. const float Tmax = 180;
  84. const float Tmin = 0;
  85. public float T
  86. {
  87. get { return this.m_t; }
  88. set => this.m_t = rangeCheckedT(value);
  89. }
  90. private static float rangeCheckedT(float t)
  91. {
  92. if (t > Tmax) t = Tmax;
  93. else if (t < Tmin) t = Tmin;
  94. return t;
  95. }
  96. #endregion
  97. #region M
  98. //限定范围
  99. const float Mmax = 100;
  100. const float Mmin = 0;
  101. public float M
  102. {
  103. get { return this.m_m; }
  104. set => this.m_m = rangeCheckedM(value);
  105. }
  106. private static float rangeCheckedM(float m)
  107. {
  108. if (m > Mmax) m = Mmax;
  109. else if (m < Mmin) m = Mmin;
  110. return m;
  111. }
  112. #endregion
  113. #region WD
  114. private float m_wd;
  115. public float WD
  116. {
  117. get { return m_wd; }
  118. set { this.m_wd = value; }
  119. }
  120. #endregion
  121. #region BeamShiftX
  122. private float beamShiftX;
  123. public float BeamShiftX
  124. {
  125. get { return beamShiftX; }
  126. set { this.beamShiftX = value; }
  127. }
  128. #endregion
  129. #region BeamShiftY
  130. private float beamShiftY;
  131. public float BeamShiftY
  132. {
  133. get { return beamShiftY; }
  134. set { this.beamShiftY = value; }
  135. }
  136. #endregion
  137. public SemPosition()
  138. {
  139. m_x = 0;
  140. m_y = 0;
  141. m_z = 0;
  142. m_r = 0;
  143. m_t = 0;
  144. m_m = 0;
  145. m_wd = 0;
  146. BeamShiftX = 0;
  147. BeamShiftY = 0;
  148. }
  149. public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
  150. {
  151. Slo slo_sp = new Slo();
  152. xDouble ptx = new xDouble();
  153. ptx.AssignValue(this.X);
  154. slo_sp.Register("X", ptx);
  155. xDouble pty = new xDouble();
  156. pty.AssignValue(this.Y);
  157. slo_sp.Register("Y", pty);
  158. xDouble ptz = new xDouble();
  159. ptz.AssignValue(this.Z);
  160. slo_sp.Register("Z", ptz);
  161. xDouble ptt = new xDouble();
  162. ptt.AssignValue(this.T);
  163. slo_sp.Register("T", ptt);
  164. xDouble ptr = new xDouble();
  165. ptr.AssignValue(this.R);
  166. slo_sp.Register("R", ptr);
  167. xDouble ptm = new xDouble();
  168. ptm.AssignValue(this.M);
  169. slo_sp.Register("M", ptm);
  170. xDouble ptwd = new xDouble();
  171. ptm.AssignValue(this.WD);
  172. slo_sp.Register("WD", ptwd);
  173. xDouble ptbsx = new xDouble();
  174. ptm.AssignValue(this.beamShiftX);
  175. slo_sp.Register("BeamShiftX", ptbsx);
  176. xDouble ptbsy = new xDouble();
  177. ptm.AssignValue(this.beamShiftY);
  178. slo_sp.Register("BeamShiftY", ptbsy);
  179. if (isStoring)
  180. {
  181. slo_sp.Serialize(true, xml, rootNode);
  182. }
  183. else
  184. {
  185. slo_sp.Serialize(false, xml, rootNode);
  186. this.X = (float)ptx.value();
  187. this.Y = (float)pty.value();
  188. this.Z = (float)ptz.value();
  189. this.T = (float)ptt.value();
  190. this.R = (float)ptr.value();
  191. this.M = (float)ptm.value();
  192. this.WD = (float)ptwd.value();
  193. this.BeamShiftX = (float)ptbsx.value();
  194. this.BeamShiftY = (float)ptbsy.value();
  195. }
  196. }
  197. }
  198. }