OTSImageScanParam.cpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. #include "stdafx.h"
  2. #include "OTSImageScanParam.h"
  3. namespace OTSMODEL
  4. {
  5. // constructor
  6. COTSImageScanParam::COTSImageScanParam()
  7. {
  8. Init();
  9. }
  10. // copy constructor
  11. COTSImageScanParam::COTSImageScanParam(const COTSImageScanParam& a_oSource)
  12. {
  13. // can't copy itself
  14. if (&a_oSource == this)
  15. {
  16. return;
  17. }
  18. // copy data over
  19. Duplicate(a_oSource);
  20. }
  21. // copy constructor
  22. COTSImageScanParam::COTSImageScanParam(COTSImageScanParam* a_poSource)
  23. {
  24. // input check
  25. ASSERT(a_poSource);
  26. if (!a_poSource)
  27. {
  28. return;
  29. }
  30. // can't copy itself
  31. if (a_poSource == this)
  32. {
  33. return;
  34. }
  35. // copy data over
  36. Duplicate(*a_poSource);
  37. }
  38. // =operator
  39. COTSImageScanParam& COTSImageScanParam::operator=(const COTSImageScanParam& a_oSource)
  40. {
  41. // cleanup
  42. Cleanup();
  43. // copy the class data over
  44. Duplicate(a_oSource);
  45. // return class
  46. return *this;
  47. }
  48. // ==operator
  49. BOOL COTSImageScanParam::operator==(const COTSImageScanParam& a_oSource)
  50. {
  51. // return test result
  52. return((m_nStopMode == a_oSource.m_nStopMode) &&
  53. (m_nStopParamMeasTime == a_oSource.m_nStopParamMeasTime) &&
  54. (m_nStopParamFields == a_oSource.m_nStopParamFields) &&
  55. (m_nStopParamParticles == a_oSource.m_nStopParamParticles) &&
  56. (m_nSatrtImageMode == a_oSource.m_nSatrtImageMode) &&
  57. (m_nImagePixelSize == a_oSource.m_nImagePixelSize) &&
  58. (m_bShowStopMode == a_oSource.m_bShowStopMode) &&
  59. (m_bShowMeasTime == a_oSource.m_bShowMeasTime) &&
  60. (m_bShowParamFields == a_oSource.m_bShowParamFields) &&
  61. (m_bShowParticles == a_oSource.m_bShowParticles) &&
  62. (m_bShowStartImageMode == a_oSource.m_bShowStartImageMode) &&
  63. (m_bShowImageSpeed == a_oSource.m_bShowImageSpeed) &&
  64. (m_bShowPixelSize == a_oSource.m_bShowPixelSize));
  65. }
  66. // detractor
  67. COTSImageScanParam::~COTSImageScanParam()
  68. {
  69. Cleanup();
  70. }
  71. // COTSStageData member functions
  72. // serialization
  73. void COTSImageScanParam::Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode)
  74. {
  75. xmls::xInt xnStopMode;
  76. xmls::xInt xnStopParamMeasTime;
  77. xmls::xInt xnStopParamFields;
  78. xmls::xInt xnStopParamParticles;
  79. xmls::xInt xnSatrtImageMode;
  80. xmls::xInt xnScanImageSpeed;
  81. xmls::xInt xnImagePixelSize;
  82. xmls::xBool xbShowStopMode;
  83. xmls::xBool xbShowMeasTime;
  84. xmls::xBool xbShowParamFields;
  85. xmls::xBool xbShowParticles;
  86. xmls::xBool xbShowStartImageMode;
  87. xmls::xBool xbShowImageSpeed;
  88. xmls::xBool xbShowPixelSize;
  89. xmls::Slo slo;
  90. slo.Register("StopMode", &xnStopMode);
  91. slo.Register("StopParamMeasTime", &xnStopParamMeasTime);
  92. slo.Register("StopParamFields", &xnStopParamFields);
  93. slo.Register("StopParamParticles", &xnStopParamParticles);
  94. slo.Register("SatrtImageMode", &xnSatrtImageMode);
  95. slo.Register("ScanImageSpeed", &xnScanImageSpeed);
  96. slo.Register("ImagePixelSize", &xnImagePixelSize);
  97. slo.Register("ShowStopMode", &xbShowStopMode);
  98. slo.Register("ShowMeasTime", &xbShowMeasTime);
  99. slo.Register("ShowParamFields", &xbShowParamFields);
  100. slo.Register("ShowParticles", &xbShowParticles);
  101. slo.Register("ShowStartImageMode", &xbShowStartImageMode);
  102. slo.Register("ShowImageSpeed", &xbShowImageSpeed);
  103. slo.Register("ShowPixelSize", &xbShowPixelSize);
  104. if (isStoring)
  105. {
  106. xnStopMode = (int)m_nStopMode;
  107. xnStopParamMeasTime = m_nStopParamMeasTime;
  108. xnStopParamFields = m_nStopParamFields;
  109. xnStopParamParticles = m_nStopParamParticles;
  110. xnSatrtImageMode = (int)m_nSatrtImageMode;
  111. xnScanImageSpeed = (int)m_nScanImageSpeed;
  112. xnImagePixelSize = (int)m_nImagePixelSize;
  113. xbShowStopMode = m_bShowStopMode;
  114. xbShowMeasTime = m_bShowMeasTime;
  115. xbShowParamFields = m_bShowParamFields;
  116. xbShowParticles = m_bShowParticles;
  117. xbShowStartImageMode = m_bShowStartImageMode;
  118. xbShowImageSpeed = m_bShowImageSpeed;
  119. xbShowPixelSize = m_bShowPixelSize;
  120. slo.Serialize(true, classDoc, rootNode);
  121. }
  122. else
  123. {
  124. slo.Serialize(false, classDoc, rootNode);
  125. m_nStopMode = (OTS_MEASURE_STOP_MODE)xnStopMode.value();
  126. m_nStopParamMeasTime = xnStopParamMeasTime.value();
  127. m_nStopParamFields = xnStopParamFields.value();
  128. m_nSatrtImageMode = (OTS_GET_IMAGE_MODE)xnSatrtImageMode.value();
  129. m_nScanImageSpeed = (OTS_THREE_TIES_OPTIONS)xnScanImageSpeed.value();
  130. m_nImagePixelSize = (OTS_FIVE_TIES_OPTIONS)xnImagePixelSize.value();
  131. m_bShowStopMode = xbShowStopMode.value();
  132. m_bShowMeasTime = xbShowMeasTime.value();
  133. m_bShowParamFields = xbShowParamFields.value();
  134. m_bShowParticles = xbShowParticles.value();
  135. m_bShowStartImageMode = xbShowStartImageMode.value();
  136. m_bShowImageSpeed = xbShowImageSpeed.value();
  137. m_bShowPixelSize = xbShowPixelSize.value();
  138. }
  139. }
  140. // cleanup
  141. void COTSImageScanParam::Cleanup()
  142. {
  143. // nothing needs to be done at the moment
  144. }
  145. // initialization
  146. void COTSImageScanParam::Init()
  147. {
  148. m_nStopMode = DEFUALT_MEASURE_STOP_MODE; //测量终止方式
  149. m_nStopParamMeasTime = DEFUALT_PARAM_TIME; //测量时间
  150. m_nStopParamFields = DEFUALT_PARAM_FIELD; //帧图数
  151. m_nStopParamParticles = DEFUALT_PARAM_PARTICLE; //夹杂物数
  152. m_nSatrtImageMode = DEFAULT_IMAGEMODE; //取图方式
  153. m_nScanImageSpeed = DEFAULE_SCAN_SPEED;
  154. m_nImagePixelSize = DEFAULE_IMAGE_SIZE;
  155. m_bShowStopMode = TRUE;
  156. m_bShowMeasTime = TRUE;
  157. m_bShowParamFields = TRUE;
  158. m_bShowParticles = TRUE;
  159. m_bShowStartImageMode = TRUE;
  160. m_bShowImageSpeed = TRUE;
  161. m_bShowPixelSize = TRUE;
  162. }
  163. // duplication
  164. void COTSImageScanParam::Duplicate(const COTSImageScanParam& a_oSource)
  165. {
  166. // initialization
  167. Init();
  168. // copy data over
  169. m_nStopMode = a_oSource.m_nStopMode;
  170. m_nStopParamMeasTime = a_oSource.m_nStopParamMeasTime;
  171. m_nStopParamFields = a_oSource.m_nStopParamFields;
  172. m_nStopParamParticles = a_oSource.m_nStopParamParticles;
  173. m_nSatrtImageMode = a_oSource.m_nSatrtImageMode;
  174. m_nImagePixelSize = a_oSource.m_nImagePixelSize;
  175. m_nScanImageSpeed = a_oSource.m_nScanImageSpeed;
  176. m_bShowStopMode = a_oSource.m_bShowStopMode;
  177. m_bShowMeasTime = a_oSource.m_bShowMeasTime;
  178. m_bShowParamFields = a_oSource.m_bShowParamFields;
  179. m_bShowParticles = a_oSource.m_bShowParticles;
  180. m_bShowStartImageMode = a_oSource.m_bShowStartImageMode;
  181. m_bShowImageSpeed = a_oSource.m_bShowImageSpeed;
  182. m_bShowPixelSize = a_oSource.m_bShowPixelSize;
  183. }
  184. }