COTSImageScanParam.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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 string m_nStopMode;
  13. private int m_nStopParamMeasTime;
  14. private int m_nStopParamFields;
  15. private int m_nStopParamParticles;
  16. private int m_nStopParamArea;
  17. private OTS_GET_IMAGE_MODE m_nSatrtImageMode;
  18. private OTS_IMAGE_SCANSPEED_OPTIONS m_nScanImageSpeed;
  19. private OTS_IMAGE_RESULOTION_OPTIONS m_nImageResulotion;
  20. private OTS_MEASURE_FIELD_STOP_MODE m_nFieldStopMode;
  21. private int m_nFieldAreaPercentage;
  22. private int m_nFieldLargeParticles;
  23. private int m_nFieldLargeParticlesPercentage;
  24. private int m_nFieldSmallParticles;
  25. private int m_nFieldSmallParticlesPercentage;
  26. //private int m_OverlapParam;
  27. //const OTS_MEASURE_STOP_MODE DEFUALT_MEASURE_STOP_MODE = OTS_MEASURE_STOP_MODE.CoverMode;
  28. // stop parameters
  29. const int DEFUALT_PARAM_FIELD = 500;
  30. const int DEFUALT_PARAM_TIME = 300;
  31. const int DEFUALT_PARAM_PARTICLE = 5000;
  32. const int DEFUALT_PARAM_AREA = 100;
  33. // image mode
  34. const OTS_GET_IMAGE_MODE DEFAULT_IMAGEMODE = OTS_GET_IMAGE_MODE.Spiral;
  35. // scan speed
  36. const OTS_IMAGE_SCANSPEED_OPTIONS DEFAULE_SCAN_SPEED = OTS_IMAGE_SCANSPEED_OPTIONS.meddium;
  37. // image size
  38. const OTS_IMAGE_RESULOTION_OPTIONS DEFAULE_IMAGE_SIZE = OTS_IMAGE_RESULOTION_OPTIONS._1024_768;
  39. void Init()
  40. {
  41. m_nStopMode = ((int)OTS_MEASURE_STOP_MODE.CoverMode+1).ToString(); //测量终止方式
  42. m_nStopParamMeasTime = DEFUALT_PARAM_TIME; //测量时间
  43. m_nStopParamFields = DEFUALT_PARAM_FIELD; //帧图数
  44. m_nStopParamParticles = DEFUALT_PARAM_PARTICLE; //夹杂物数
  45. m_nSatrtImageMode = DEFAULT_IMAGEMODE; //取图方式
  46. m_nScanImageSpeed = DEFAULE_SCAN_SPEED;
  47. m_nImageResulotion = DEFAULE_IMAGE_SIZE;
  48. m_nStopParamArea = DEFUALT_PARAM_AREA;
  49. m_nFieldStopMode = OTS_MEASURE_FIELD_STOP_MODE.ParticlesPercentage;
  50. m_nFieldAreaPercentage = 100;
  51. m_nFieldLargeParticles = 1000;
  52. m_nFieldLargeParticlesPercentage = 100;
  53. m_nFieldSmallParticles = 10000;
  54. m_nFieldSmallParticlesPercentage = 100;
  55. }
  56. public COTSImgScanPrm ()
  57. {
  58. // copy data over
  59. Init();
  60. }
  61. void Duplicate( COTSImgScanPrm a_oSource)
  62. {
  63. // copy data over
  64. m_nStopMode = a_oSource.m_nStopMode;
  65. m_nStopParamMeasTime = a_oSource.m_nStopParamMeasTime;
  66. m_nStopParamFields = a_oSource.m_nStopParamFields;
  67. m_nStopParamParticles = a_oSource.m_nStopParamParticles;
  68. m_nStopParamArea = a_oSource.m_nStopParamArea;
  69. m_nSatrtImageMode = a_oSource.m_nSatrtImageMode;
  70. m_nImageResulotion = a_oSource.m_nImageResulotion;
  71. m_nScanImageSpeed = a_oSource.m_nScanImageSpeed;
  72. m_nFieldStopMode = a_oSource.m_nFieldStopMode;
  73. m_nFieldAreaPercentage = a_oSource.m_nFieldAreaPercentage;
  74. m_nFieldLargeParticles = a_oSource.m_nFieldLargeParticles;
  75. m_nFieldLargeParticlesPercentage = a_oSource.m_nFieldLargeParticlesPercentage;
  76. m_nFieldSmallParticles = a_oSource.m_nFieldSmallParticles;
  77. m_nFieldSmallParticlesPercentage = a_oSource.m_nFieldSmallParticlesPercentage;
  78. //m_OverlapParam = a_oSource.m_OverlapParam;
  79. }
  80. public COTSImgScanPrm ( COTSImgScanPrm a_oSource)
  81. {
  82. // copy data over
  83. Duplicate(a_oSource);
  84. }
  85. public bool Equals(COTSImgScanPrm a_oSource)
  86. {
  87. // return test result
  88. return((m_nStopMode == a_oSource.m_nStopMode) &&
  89. (m_nStopParamMeasTime == a_oSource.m_nStopParamMeasTime) &&
  90. (m_nStopParamFields == a_oSource.m_nStopParamFields) &&
  91. (m_nStopParamParticles == a_oSource.m_nStopParamParticles) &&
  92. (m_nStopParamArea == a_oSource.m_nStopParamArea) &&
  93. (m_nSatrtImageMode == a_oSource.m_nSatrtImageMode) &&
  94. (m_nImageResulotion == a_oSource.m_nImageResulotion));
  95. }
  96. //测量终止方式
  97. public string GetStopMode() { return m_nStopMode; }
  98. public void SetStopMode(string a_nStopMode) { m_nStopMode = a_nStopMode; }
  99. //测量时间
  100. public int GetStopParamMeasTime() { return m_nStopParamMeasTime; }
  101. public void SetStopParamMeasTime(int a_nStopParamMeasTime) { m_nStopParamMeasTime = a_nStopParamMeasTime; }
  102. //帧图数
  103. public int GetStopParamFields() { return m_nStopParamFields; }
  104. public void SetStopParamFields(int a_nStopParamFields) { m_nStopParamFields = a_nStopParamFields; }
  105. //夹杂物数
  106. public int GetStopParamParticles() { return m_nStopParamParticles; }
  107. public void SetStopParamParticles(int a_nStopParamParticles) { m_nStopParamParticles = a_nStopParamParticles; }
  108. //测量面积
  109. public int GetStopParamArea() { return m_nStopParamArea; }
  110. public void SetStopParamArea(int a_nStopParamArea) { m_nStopParamArea = a_nStopParamArea; }
  111. //测量帧终止方式
  112. //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.
  113. public OTS_MEASURE_FIELD_STOP_MODE GetFieldStopMode() { return m_nFieldStopMode; }
  114. public void SetFieldStopMode(OTS_MEASURE_FIELD_STOP_MODE a_nFieldStopMode) { m_nFieldStopMode = a_nFieldStopMode; }
  115. //帧完成面积百分比
  116. public int GetFieldAreaPercentage() { return m_nFieldAreaPercentage; }
  117. public void SetFieldAreaPercentage(int a_nAreaPercentage) { m_nFieldAreaPercentage = a_nAreaPercentage; }
  118. //帧完成大颗粒数
  119. public int GetFieldLargeParticleNum() { return m_nFieldLargeParticles; }
  120. public void SetFieldLargeParticleNum(int a_nLargeParticles) { m_nFieldLargeParticles = a_nLargeParticles; }
  121. //帧完成大颗粒百分比
  122. public int GetFieldLargeParticlesPercentage() { return m_nFieldLargeParticlesPercentage; }
  123. public void SetFieldLargeParticlePercentage(int a_nLargeParticlesPercentage) { m_nFieldLargeParticlesPercentage = a_nLargeParticlesPercentage; }
  124. //帧完成小颗粒数
  125. public int GetFieldSmallParticleNum() { return m_nFieldSmallParticles; }
  126. public void SetFieldSmallParticleNum(int a_nSmallParticles) { m_nFieldSmallParticles = a_nSmallParticles; }
  127. //帧完成小颗粒数百分比
  128. public int GetFieldSmallParticlesPercentage() { return m_nFieldSmallParticlesPercentage; }
  129. public void SetFieldSmallParticlePercentage(int a_nSmallParticlesPercentage) { m_nFieldSmallParticlesPercentage = a_nSmallParticlesPercentage; }
  130. //取图方式
  131. public OTS_GET_IMAGE_MODE GetFieldStartMode() { return m_nSatrtImageMode; }
  132. public void SetStartImageMode(OTS_GET_IMAGE_MODE a_nSatrtImageMode) { m_nSatrtImageMode = a_nSatrtImageMode; }
  133. //扫描图尺寸
  134. public OTS_IMAGE_RESULOTION_OPTIONS GetImageResulotion() { return m_nImageResulotion; }
  135. public CSize GetImageResolutionSize()
  136. {
  137. string sReso = m_nImageResulotion.ToString();
  138. int w=Convert.ToInt32(sReso.Split('_')[1]);
  139. int h = Convert.ToInt32(sReso.Split('_')[2]);
  140. return new CSize(w,h);
  141. }
  142. public void SetImageResulotion(OTS_IMAGE_RESULOTION_OPTIONS a_nImagePixelSize) { m_nImageResulotion = a_nImagePixelSize; }
  143. //扫描图精度
  144. public OTS_IMAGE_SCANSPEED_OPTIONS GetScanImageSpeed() { return m_nScanImageSpeed; }
  145. public void SetScanImageSpeed(OTS_IMAGE_SCANSPEED_OPTIONS a_nScanImageSpeed) { m_nScanImageSpeed = a_nScanImageSpeed; }
  146. public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
  147. {
  148. xString xnStopMode=new xString();
  149. xInt xnStopParamMeasTime=new xInt();
  150. xInt xnStopParamFields = new xInt();
  151. xInt xnStopParamParticles = new xInt();
  152. xInt xnStopParamArea = new xInt();
  153. xString xnSatrtImageMode = new xString();
  154. xString xnScanImageSpeed = new xString();
  155. xString xnImageSize = new xString();
  156. Slo slo=new Slo();
  157. slo.Register("StopMode", xnStopMode);
  158. slo.Register("StopParamMeasTime", xnStopParamMeasTime);
  159. slo.Register("StopParamFields", xnStopParamFields);
  160. slo.Register("StopParamParticles", xnStopParamParticles);
  161. slo.Register("StopParamArea", xnStopParamArea);
  162. slo.Register("SatrtImageMode", xnSatrtImageMode);
  163. slo.Register("ScanImageSpeed", xnScanImageSpeed);
  164. slo.Register("ImageResolution", xnImageSize);
  165. if (isStoring)
  166. {
  167. string[] st = m_nStopMode.Replace(" ","").Split('+');
  168. string str = "";
  169. for (int k = 0; k < st.Length; k++)
  170. {
  171. str += (int.Parse(st[k]) - 1).ToString() + ":" + ((OTS_MEASURE_STOP_MODE)int.Parse(st[k])-1).ToString()+",";
  172. }
  173. xnStopMode.AssignValue(str.Substring(0, str.Length-1));//
  174. xnStopParamMeasTime.AssignValue( m_nStopParamMeasTime);
  175. xnStopParamFields.AssignValue(m_nStopParamFields);
  176. xnStopParamParticles.AssignValue(m_nStopParamParticles);
  177. xnStopParamArea.AssignValue(m_nStopParamArea);
  178. xnSatrtImageMode.AssignValue((int)m_nSatrtImageMode+":"+m_nSatrtImageMode.ToString());
  179. xnScanImageSpeed.AssignValue((int)m_nScanImageSpeed+":"+ m_nScanImageSpeed.ToString());
  180. xnImageSize.AssignValue( (int)m_nImageResulotion+":"+m_nImageResulotion.ToString());
  181. slo.Serialize(true, classDoc, rootNode);
  182. }
  183. else
  184. {
  185. slo.Serialize(false, classDoc, rootNode);
  186. string[] st = xnStopMode.value().Split(',');
  187. string str = "";
  188. for (int k = 0; k < st.Length; k++)
  189. {
  190. str += (int.Parse(st[k].Split(':')[0])+1) + " + ";
  191. }
  192. m_nStopMode = str.Substring(0, str.Length - 3);
  193. m_nStopParamMeasTime = xnStopParamMeasTime.value();
  194. m_nStopParamFields = xnStopParamFields.value();
  195. m_nStopParamParticles = xnStopParamParticles.value();
  196. m_nStopParamArea = xnStopParamArea.value();
  197. m_nSatrtImageMode = (OTS_GET_IMAGE_MODE)Convert.ToInt32(xnSatrtImageMode.value().Split(':')[0]);
  198. m_nScanImageSpeed = (OTS_IMAGE_SCANSPEED_OPTIONS)Convert.ToInt32(xnScanImageSpeed.value().Split(':')[0]);
  199. m_nImageResulotion = (OTS_IMAGE_RESULOTION_OPTIONS)Convert.ToInt32(xnImageSize.value().Split(':')[0]);
  200. }
  201. }
  202. }
  203. }