COTSImageScanParam.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Xml;
  7. using static OTSDataType.otsdataconst;
  8. namespace OTSDataType
  9. {
  10. public class COTSImgScanPrm : ISlo
  11. {
  12. private OTS_MEASURE_STOP_MODE m_nStopMode;
  13. private int m_nStopParamMeasTime;
  14. private int m_nStopParamFields;
  15. private int m_nStopParamParticles;
  16. private OTS_GET_IMAGE_MODE m_nSatrtImageMode;
  17. private OTS_THREE_TIES_OPTIONS m_nScanImageSpeed;
  18. private OTS_FIVE_TIES_OPTIONS m_nImagePixelSize;
  19. private OTS_MEASURE_FIELD_STOP_MODE m_nFieldStopMode;
  20. private int m_nFieldAreaPercentage;
  21. private int m_nFieldLargeParticles;
  22. private int m_nFieldLargeParticlesPercentage;
  23. private int m_nFieldSmallParticles;
  24. private int m_nFieldSmallParticlesPercentage;
  25. const OTS_MEASURE_STOP_MODE DEFUALT_MEASURE_STOP_MODE = OTS_MEASURE_STOP_MODE.CoverMode;
  26. // stop parameters
  27. const int DEFUALT_PARAM_FIELD = 500;
  28. const int DEFUALT_PARAM_TIME = 300;
  29. const int DEFUALT_PARAM_PARTICLE = 5000;
  30. // image mode
  31. const OTS_GET_IMAGE_MODE DEFAULT_IMAGEMODE = OTS_GET_IMAGE_MODE.FROM_CENTER;
  32. // scan speed
  33. const OTS_THREE_TIES_OPTIONS DEFAULE_SCAN_SPEED = OTS_THREE_TIES_OPTIONS.meddium;
  34. // image size
  35. const OTS_FIVE_TIES_OPTIONS DEFAULE_IMAGE_SIZE = OTS_FIVE_TIES_OPTIONS.TIE3;
  36. void Init()
  37. {
  38. m_nStopMode = DEFUALT_MEASURE_STOP_MODE; //测量终止方式
  39. m_nStopParamMeasTime = DEFUALT_PARAM_TIME; //测量时间
  40. m_nStopParamFields = DEFUALT_PARAM_FIELD; //帧图数
  41. m_nStopParamParticles = DEFUALT_PARAM_PARTICLE; //夹杂物数
  42. m_nSatrtImageMode = DEFAULT_IMAGEMODE; //取图方式
  43. m_nScanImageSpeed = DEFAULE_SCAN_SPEED;
  44. m_nImagePixelSize = DEFAULE_IMAGE_SIZE;
  45. m_nFieldStopMode = OTS_MEASURE_FIELD_STOP_MODE.ParticlesPercentage;
  46. m_nFieldAreaPercentage = 100;
  47. m_nFieldLargeParticles = 1000;
  48. m_nFieldLargeParticlesPercentage = 100;
  49. m_nFieldSmallParticles = 10000;
  50. m_nFieldSmallParticlesPercentage = 100;
  51. }
  52. public COTSImgScanPrm ()
  53. {
  54. // copy data over
  55. Init();
  56. }
  57. void Duplicate( COTSImgScanPrm a_oSource)
  58. {
  59. // copy data over
  60. m_nStopMode = a_oSource.m_nStopMode;
  61. m_nStopParamMeasTime = a_oSource.m_nStopParamMeasTime;
  62. m_nStopParamFields = a_oSource.m_nStopParamFields;
  63. m_nStopParamParticles = a_oSource.m_nStopParamParticles;
  64. m_nSatrtImageMode = a_oSource.m_nSatrtImageMode;
  65. m_nImagePixelSize = a_oSource.m_nImagePixelSize;
  66. m_nScanImageSpeed = a_oSource.m_nScanImageSpeed;
  67. m_nFieldStopMode = a_oSource.m_nFieldStopMode;
  68. m_nFieldAreaPercentage = a_oSource.m_nFieldAreaPercentage;
  69. m_nFieldLargeParticles = a_oSource.m_nFieldLargeParticles;
  70. m_nFieldLargeParticlesPercentage = a_oSource.m_nFieldLargeParticlesPercentage;
  71. m_nFieldSmallParticles = a_oSource.m_nFieldSmallParticles;
  72. m_nFieldSmallParticlesPercentage = a_oSource.m_nFieldSmallParticlesPercentage;
  73. }
  74. public COTSImgScanPrm ( COTSImgScanPrm a_oSource)
  75. {
  76. // copy data over
  77. Duplicate(a_oSource);
  78. }
  79. public bool Equals(COTSImgScanPrm a_oSource)
  80. {
  81. // return test result
  82. return((m_nStopMode == a_oSource.m_nStopMode) &&
  83. (m_nStopParamMeasTime == a_oSource.m_nStopParamMeasTime) &&
  84. (m_nStopParamFields == a_oSource.m_nStopParamFields) &&
  85. (m_nStopParamParticles == a_oSource.m_nStopParamParticles) &&
  86. (m_nSatrtImageMode == a_oSource.m_nSatrtImageMode) &&
  87. (m_nImagePixelSize == a_oSource.m_nImagePixelSize));
  88. }
  89. //测量终止方式
  90. public OTS_MEASURE_STOP_MODE GetStopMode() { return m_nStopMode; }
  91. public void SetStopMode(OTS_MEASURE_STOP_MODE a_nStopMode) { m_nStopMode = a_nStopMode; }
  92. //测量时间
  93. public int GetStopParamMeasTime() { return m_nStopParamMeasTime; }
  94. public void SetStopParamMeasTime(int a_nStopParamMeasTime) { m_nStopParamMeasTime = a_nStopParamMeasTime; }
  95. //帧图数
  96. public int GetStopParamFields() { return m_nStopParamFields; }
  97. public void SetStopParamFields(int a_nStopParamFields) { m_nStopParamFields = a_nStopParamFields; }
  98. //夹杂物数
  99. public int GetStopParamParticles() { return m_nStopParamParticles; }
  100. public void SetStopParamParticles(int a_nStopParamParticles) { m_nStopParamParticles = a_nStopParamParticles; }
  101. //测量帧终止方式
  102. //no longer consider the field stop mode ,for we can get the same result by regulate the min size of particle to filter the too small particles.
  103. public OTS_MEASURE_FIELD_STOP_MODE GetFieldStopMode() { return m_nFieldStopMode; }
  104. public void SetFieldStopMode(OTS_MEASURE_FIELD_STOP_MODE a_nFieldStopMode) { m_nFieldStopMode = a_nFieldStopMode; }
  105. //帧完成面积百分比
  106. public int GetFieldAreaPercentage() { return m_nFieldAreaPercentage; }
  107. public void SetFieldAreaPercentage(int a_nAreaPercentage) { m_nFieldAreaPercentage = a_nAreaPercentage; }
  108. //帧完成大颗粒数
  109. public int GetFieldLargeParticleNum() { return m_nFieldLargeParticles; }
  110. public void SetFieldLargeParticleNum(int a_nLargeParticles) { m_nFieldLargeParticles = a_nLargeParticles; }
  111. //帧完成大颗粒百分比
  112. public int GetFieldLargeParticlesPercentage() { return m_nFieldLargeParticlesPercentage; }
  113. public void SetFieldLargeParticlePercentage(int a_nLargeParticlesPercentage) { m_nFieldLargeParticlesPercentage = a_nLargeParticlesPercentage; }
  114. //帧完成小颗粒数
  115. public int GetFieldSmallParticleNum() { return m_nFieldSmallParticles; }
  116. public void SetFieldSmallParticleNum(int a_nSmallParticles) { m_nFieldSmallParticles = a_nSmallParticles; }
  117. //帧完成小颗粒数百分比
  118. public int GetFieldSmallParticlesPercentage() { return m_nFieldSmallParticlesPercentage; }
  119. public void SetFieldSmallParticlePercentage(int a_nSmallParticlesPercentage) { m_nFieldSmallParticlesPercentage = a_nSmallParticlesPercentage; }
  120. //取图方式
  121. public OTS_GET_IMAGE_MODE GetFieldStartMode() { return m_nSatrtImageMode; }
  122. public void SetStartImageMode(OTS_GET_IMAGE_MODE a_nSatrtImageMode) { m_nSatrtImageMode = a_nSatrtImageMode; }
  123. //扫描图尺寸
  124. public OTS_FIVE_TIES_OPTIONS GetImagePixelSize() { return m_nImagePixelSize; }
  125. public void SetImagePixelSize(OTS_FIVE_TIES_OPTIONS a_nImagePixelSize) { m_nImagePixelSize = a_nImagePixelSize; }
  126. //扫描图精度
  127. public OTS_THREE_TIES_OPTIONS GetScanImageSpeed() { return m_nScanImageSpeed; }
  128. public void SetScanImageSpeed(OTS_THREE_TIES_OPTIONS a_nScanImageSpeed) { m_nScanImageSpeed = a_nScanImageSpeed; }
  129. public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
  130. {
  131. xInt xnStopMode=new xInt();
  132. xInt xnStopParamMeasTime=new xInt();
  133. xInt xnStopParamFields = new xInt();
  134. xInt xnStopParamParticles = new xInt();
  135. xInt xnSatrtImageMode = new xInt();
  136. xInt xnScanImageSpeed = new xInt();
  137. xInt xnImagePixelSize = new xInt();
  138. xInt xnFieldStopMode = new xInt();
  139. xInt xnFieldAreaPercentage = new xInt();
  140. xInt xnFieldLargeParticles = new xInt();
  141. xInt xnFieldLargeParticlePercentage = new xInt();
  142. xInt xnFieldSmallParticles = new xInt();
  143. xInt xnFieldSmallParticlePercentage = new xInt();
  144. Slo slo=new Slo();
  145. slo.Register("StopMode", xnStopMode);
  146. slo.Register("StopParamMeasTime", xnStopParamMeasTime);
  147. slo.Register("StopParamFields", xnStopParamFields);
  148. slo.Register("StopParamParticles", xnStopParamParticles);
  149. slo.Register("SatrtImageMode", xnSatrtImageMode);
  150. slo.Register("ScanImageSpeed", xnScanImageSpeed);
  151. slo.Register("ImagePixelSize", xnImagePixelSize);
  152. slo.Register("FieldStopMode", xnFieldStopMode);
  153. slo.Register("FieldAreaPercentage", xnFieldAreaPercentage);
  154. slo.Register("FieldLargeParticles", xnFieldLargeParticles);
  155. slo.Register("FieldLargeParticlePercentage", xnFieldLargeParticlePercentage);
  156. slo.Register("FieldSmallParticles", xnFieldSmallParticles);
  157. slo.Register("FieldSmallParticlePercentage", xnFieldSmallParticlePercentage);
  158. if (isStoring)
  159. {
  160. xnStopMode.AssignValue((int)m_nStopMode);
  161. xnStopParamMeasTime.AssignValue((int) m_nStopParamMeasTime);
  162. xnStopParamFields.AssignValue((int)m_nStopParamFields);
  163. xnStopParamParticles.AssignValue((int)m_nStopParamParticles);
  164. xnSatrtImageMode.AssignValue((int)m_nSatrtImageMode);
  165. xnScanImageSpeed.AssignValue( (int)m_nScanImageSpeed);
  166. xnImagePixelSize.AssignValue( (int)m_nImagePixelSize);
  167. xnFieldStopMode.AssignValue((int)m_nFieldStopMode);
  168. xnFieldSmallParticles.AssignValue((int)m_nFieldSmallParticles);
  169. xnFieldSmallParticlePercentage .AssignValue((int)m_nFieldSmallParticlesPercentage);
  170. slo.Serialize(true, classDoc, rootNode);
  171. }
  172. else
  173. {
  174. slo.Serialize(false, classDoc, rootNode);
  175. m_nStopMode = (OTS_MEASURE_STOP_MODE)xnStopMode.value();
  176. m_nStopParamMeasTime = xnStopParamMeasTime.value();
  177. m_nStopParamFields = xnStopParamFields.value();
  178. m_nStopParamParticles = xnStopParamParticles.value();
  179. m_nSatrtImageMode = (OTS_GET_IMAGE_MODE)xnSatrtImageMode.value();
  180. m_nScanImageSpeed = (OTS_THREE_TIES_OPTIONS)xnScanImageSpeed.value();
  181. m_nImagePixelSize = (OTS_FIVE_TIES_OPTIONS)xnImagePixelSize.value();
  182. m_nFieldStopMode = (OTS_MEASURE_FIELD_STOP_MODE)xnFieldStopMode.value();
  183. m_nFieldAreaPercentage = xnFieldAreaPercentage.value();
  184. m_nFieldLargeParticles = xnFieldLargeParticles.value();
  185. m_nFieldLargeParticlesPercentage = xnFieldLargeParticlePercentage.value();
  186. m_nFieldSmallParticles = xnFieldSmallParticles.value();
  187. m_nFieldSmallParticlesPercentage = xnFieldSmallParticlePercentage.value();
  188. }
  189. }
  190. }
  191. }