OTSImageScanParam.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #include "stdafx.h"
  2. #include "OTSImageScanParam.h"
  3. namespace OTSIMGPROC
  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. }
  59. // detractor
  60. COTSImageScanParam::~COTSImageScanParam()
  61. {
  62. Cleanup();
  63. }
  64. // COTSStageData member functions
  65. // serialization
  66. void COTSImageScanParam::Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode)
  67. {
  68. xmls::xInt xnStopMode;
  69. xmls::xInt xnStopParamMeasTime;
  70. xmls::xInt xnStopParamFields;
  71. xmls::xInt xnStopParamParticles;
  72. xmls::xInt xnSatrtImageMode;
  73. xmls::xInt xnScanImageSpeed;
  74. xmls::xInt xnImagePixelSize;
  75. xmls::Slo slo;
  76. slo.Register("StopMode", &xnStopMode);
  77. slo.Register("StopParamMeasTime", &xnStopParamMeasTime);
  78. slo.Register("StopParamFields", &xnStopParamFields);
  79. slo.Register("StopParamParticles", &xnStopParamParticles);
  80. slo.Register("SatrtImageMode", &xnSatrtImageMode);
  81. slo.Register("ScanImageSpeed", &xnScanImageSpeed);
  82. slo.Register("ImagePixelSize", &xnImagePixelSize);
  83. if (isStoring)
  84. {
  85. xnStopMode = (int)m_nStopMode;
  86. xnStopParamMeasTime = m_nStopParamMeasTime;
  87. xnStopParamFields = m_nStopParamFields;
  88. xnStopParamParticles = m_nStopParamParticles;
  89. xnSatrtImageMode = (int)m_nSatrtImageMode;
  90. xnScanImageSpeed = (int)m_nScanImageSpeed;
  91. xnImagePixelSize = (int)m_nImagePixelSize;
  92. slo.Serialize(true, classDoc, rootNode);
  93. }
  94. else
  95. {
  96. slo.Serialize(false, classDoc, rootNode);
  97. m_nStopMode = (OTS_MEASURE_STOP_MODE)xnStopMode.value();
  98. m_nStopParamMeasTime = xnStopParamMeasTime.value();
  99. m_nStopParamFields = xnStopParamFields.value();
  100. m_nSatrtImageMode = (OTS_GET_IMAGE_MODE)xnSatrtImageMode.value();
  101. m_nScanImageSpeed = (OTS_THREE_TIES_OPTIONS)xnScanImageSpeed.value();
  102. m_nImagePixelSize = (OTS_FIVE_TIES_OPTIONS)xnImagePixelSize.value();
  103. }
  104. }
  105. // cleanup
  106. void COTSImageScanParam::Cleanup()
  107. {
  108. // nothing needs to be done at the moment
  109. }
  110. // initialization
  111. void COTSImageScanParam::Init()
  112. {
  113. m_nStopMode = DEFUALT_MEASURE_STOP_MODE; //测量终止方式
  114. m_nStopParamMeasTime = DEFUALT_PARAM_TIME; //测量时间
  115. m_nStopParamFields = DEFUALT_PARAM_FIELD; //帧图数
  116. m_nStopParamParticles = DEFUALT_PARAM_PARTICLE; //夹杂物数
  117. m_nSatrtImageMode = DEFAULT_IMAGEMODE; //取图方式
  118. m_nScanImageSpeed = DEFAULE_SCAN_SPEED;
  119. m_nImagePixelSize = DEFAULE_IMAGE_SIZE;
  120. }
  121. // duplication
  122. void COTSImageScanParam::Duplicate(const COTSImageScanParam& a_oSource)
  123. {
  124. // initialization
  125. Init();
  126. // copy data over
  127. m_nStopMode = a_oSource.m_nStopMode;
  128. m_nStopParamMeasTime = a_oSource.m_nStopParamMeasTime;
  129. m_nStopParamFields = a_oSource.m_nStopParamFields;
  130. m_nStopParamParticles = a_oSource.m_nStopParamParticles;
  131. m_nSatrtImageMode = a_oSource.m_nSatrtImageMode;
  132. m_nImagePixelSize = a_oSource.m_nImagePixelSize;
  133. m_nScanImageSpeed = a_oSource.m_nScanImageSpeed;
  134. }
  135. }