COTSImageScanParam.cs 13 KB

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