COTSImageScanParam.cs 12 KB

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