COTSImageScanParam.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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. public void CopyFrom( 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 Duplicate()
  81. {
  82. COTSImgScanPrm a_oSource = this;
  83. COTSImgScanPrm prm = new COTSImgScanPrm();
  84. // copy data over
  85. prm.m_nStopMode = a_oSource.m_nStopMode;
  86. prm.m_nStopParamMeasTime = a_oSource.m_nStopParamMeasTime;
  87. prm.m_nStopParamFields = a_oSource.m_nStopParamFields;
  88. prm.m_nStopParamParticles = a_oSource.m_nStopParamParticles;
  89. prm.m_nStopParamArea = a_oSource.m_nStopParamArea;
  90. prm.m_nSatrtImageMode = a_oSource.m_nSatrtImageMode;
  91. prm.m_nImageResulotion = a_oSource.m_nImageResulotion;
  92. prm.m_nScanImageSpeed = a_oSource.m_nScanImageSpeed;
  93. prm.m_nFieldStopMode = a_oSource.m_nFieldStopMode;
  94. prm.m_nFieldAreaPercentage = a_oSource.m_nFieldAreaPercentage;
  95. prm.m_nFieldLargeParticles = a_oSource.m_nFieldLargeParticles;
  96. prm.m_nFieldLargeParticlesPercentage = a_oSource.m_nFieldLargeParticlesPercentage;
  97. prm.m_nFieldSmallParticles = a_oSource.m_nFieldSmallParticles;
  98. prm.m_nFieldSmallParticlesPercentage = a_oSource.m_nFieldSmallParticlesPercentage;
  99. //m_OverlapParam = a_oSource.m_OverlapParam;
  100. return prm;
  101. }
  102. public COTSImgScanPrm ( COTSImgScanPrm a_oSource)
  103. {
  104. // copy data over
  105. CopyFrom(a_oSource);
  106. }
  107. public bool Equals(COTSImgScanPrm a_oSource)
  108. {
  109. // return test result
  110. return((m_nStopMode == a_oSource.m_nStopMode) &&
  111. (m_nStopParamMeasTime == a_oSource.m_nStopParamMeasTime) &&
  112. (m_nStopParamFields == a_oSource.m_nStopParamFields) &&
  113. (m_nStopParamParticles == a_oSource.m_nStopParamParticles) &&
  114. (m_nStopParamArea == a_oSource.m_nStopParamArea) &&
  115. (m_nSatrtImageMode == a_oSource.m_nSatrtImageMode) &&
  116. (m_nImageResulotion == a_oSource.m_nImageResulotion));
  117. }
  118. //测量终止方式
  119. public string GetStopMode() { return m_nStopMode; }
  120. public void SetStopMode(string a_nStopMode) { m_nStopMode = a_nStopMode; }
  121. //测量时间
  122. public int GetStopParamMeasTime() { return m_nStopParamMeasTime; }
  123. public void SetStopParamMeasTime(int a_nStopParamMeasTime) { m_nStopParamMeasTime = a_nStopParamMeasTime; }
  124. //帧图数
  125. public int GetStopParamFields() { return m_nStopParamFields; }
  126. public void SetStopParamFields(int a_nStopParamFields) { m_nStopParamFields = a_nStopParamFields; }
  127. //夹杂物数
  128. public int GetStopParamParticles() { return m_nStopParamParticles; }
  129. public void SetStopParamParticles(int a_nStopParamParticles) { m_nStopParamParticles = a_nStopParamParticles; }
  130. //测量面积
  131. public int GetStopParamArea() { return m_nStopParamArea; }
  132. public void SetStopParamArea(int a_nStopParamArea) { m_nStopParamArea = a_nStopParamArea; }
  133. //测量帧终止方式
  134. //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.
  135. public OTS_MEASURE_FIELD_STOP_MODE GetFieldStopMode() { return m_nFieldStopMode; }
  136. public void SetFieldStopMode(OTS_MEASURE_FIELD_STOP_MODE a_nFieldStopMode) { m_nFieldStopMode = a_nFieldStopMode; }
  137. //帧完成面积百分比
  138. public int GetFieldAreaPercentage() { return m_nFieldAreaPercentage; }
  139. public void SetFieldAreaPercentage(int a_nAreaPercentage) { m_nFieldAreaPercentage = a_nAreaPercentage; }
  140. //帧完成大颗粒数
  141. public int GetFieldLargeParticleNum() { return m_nFieldLargeParticles; }
  142. public void SetFieldLargeParticleNum(int a_nLargeParticles) { m_nFieldLargeParticles = a_nLargeParticles; }
  143. //帧完成大颗粒百分比
  144. public int GetFieldLargeParticlesPercentage() { return m_nFieldLargeParticlesPercentage; }
  145. public void SetFieldLargeParticlePercentage(int a_nLargeParticlesPercentage) { m_nFieldLargeParticlesPercentage = a_nLargeParticlesPercentage; }
  146. //帧完成小颗粒数
  147. public int GetFieldSmallParticleNum() { return m_nFieldSmallParticles; }
  148. public void SetFieldSmallParticleNum(int a_nSmallParticles) { m_nFieldSmallParticles = a_nSmallParticles; }
  149. //帧完成小颗粒数百分比
  150. public int GetFieldSmallParticlesPercentage() { return m_nFieldSmallParticlesPercentage; }
  151. public void SetFieldSmallParticlePercentage(int a_nSmallParticlesPercentage) { m_nFieldSmallParticlesPercentage = a_nSmallParticlesPercentage; }
  152. //取图方式
  153. public OTS_GET_IMAGE_MODE GetFieldStartMode() { return m_nSatrtImageMode; }
  154. public void SetStartImageMode(OTS_GET_IMAGE_MODE a_nSatrtImageMode) { m_nSatrtImageMode = a_nSatrtImageMode; }
  155. //扫描图尺寸
  156. public OTS_IMAGE_RESULOTION_OPTIONS GetImageResulotion() { return m_nImageResulotion; }
  157. public CSize GetImageResolutionSize()
  158. {
  159. string sReso = m_nImageResulotion.ToString();
  160. int w=Convert.ToInt32(sReso.Split('_')[1]);
  161. int h = Convert.ToInt32(sReso.Split('_')[2]);
  162. return new CSize(w,h);
  163. }
  164. public void SetImageResulotion(OTS_IMAGE_RESULOTION_OPTIONS a_nImagePixelSize) { m_nImageResulotion = a_nImagePixelSize; }
  165. //扫描图精度
  166. public OTS_IMAGE_SCANSPEED_OPTIONS GetScanImageSpeed() { return m_nScanImageSpeed; }
  167. public void SetScanImageSpeed(OTS_IMAGE_SCANSPEED_OPTIONS a_nScanImageSpeed) { m_nScanImageSpeed = a_nScanImageSpeed; }
  168. public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
  169. {
  170. xString xnStopMode=new xString();
  171. xInt xnStopParamMeasTime=new xInt();
  172. xInt xnStopParamFields = new xInt();
  173. xInt xnStopParamParticles = new xInt();
  174. xInt xnStopParamArea = new xInt();
  175. xString xnSatrtImageMode = new xString();
  176. xString xnScanImageSpeed = new xString();
  177. xString xnImageSize = new xString();
  178. Slo slo=new Slo();
  179. slo.Register("StopMode", xnStopMode);
  180. slo.Register("StopParamMeasTime", xnStopParamMeasTime);
  181. slo.Register("StopParamFields", xnStopParamFields);
  182. slo.Register("StopParamParticles", xnStopParamParticles);
  183. slo.Register("StopParamArea", xnStopParamArea);
  184. slo.Register("SatrtImageMode", xnSatrtImageMode);
  185. slo.Register("ScanImageSpeed", xnScanImageSpeed);
  186. slo.Register("ImageResolution", xnImageSize);
  187. if (isStoring)
  188. {
  189. string[] st = m_nStopMode.Replace(" ","").Split('+');
  190. string str = "";
  191. for (int k = 0; k < st.Length; k++)
  192. {
  193. str += (int.Parse(st[k]) - 1).ToString() + ":" + ((OTS_MEASURE_STOP_MODE)int.Parse(st[k])-1).ToString()+",";
  194. }
  195. xnStopMode.AssignValue(str.Substring(0, str.Length-1));//
  196. xnStopParamMeasTime.AssignValue( m_nStopParamMeasTime);
  197. xnStopParamFields.AssignValue(m_nStopParamFields);
  198. xnStopParamParticles.AssignValue(m_nStopParamParticles);
  199. xnStopParamArea.AssignValue(m_nStopParamArea);
  200. xnSatrtImageMode.AssignValue((int)m_nSatrtImageMode+":"+m_nSatrtImageMode.ToString());
  201. xnScanImageSpeed.AssignValue((int)m_nScanImageSpeed+":"+ m_nScanImageSpeed.ToString());
  202. xnImageSize.AssignValue( (int)m_nImageResulotion+":"+m_nImageResulotion.ToString());
  203. slo.Serialize(true, classDoc, rootNode);
  204. }
  205. else
  206. {
  207. slo.Serialize(false, classDoc, rootNode);
  208. string[] st = xnStopMode.value().Split(',');
  209. string str = "";
  210. for (int k = 0; k < st.Length; k++)
  211. {
  212. str += (int.Parse(st[k].Split(':')[0])+1) + " + ";
  213. }
  214. m_nStopMode = str.Substring(0, str.Length - 3);
  215. m_nStopParamMeasTime = xnStopParamMeasTime.value();
  216. m_nStopParamFields = xnStopParamFields.value();
  217. m_nStopParamParticles = xnStopParamParticles.value();
  218. m_nStopParamArea = xnStopParamArea.value();
  219. m_nSatrtImageMode = (OTS_GET_IMAGE_MODE)Convert.ToInt32(xnSatrtImageMode.value().Split(':')[0]);
  220. m_nScanImageSpeed = (OTS_IMAGE_SCANSPEED_OPTIONS)Convert.ToInt32(xnScanImageSpeed.value().Split(':')[0]);
  221. m_nImageResulotion = (OTS_IMAGE_RESULOTION_OPTIONS)Convert.ToInt32(xnImageSize.value().Split(':')[0]);
  222. }
  223. }
  224. }
  225. }