OTSImageScanParam.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. #include "stdafx.h"
  2. #include "OTSImageScanParam.h"
  3. #include <XMLSerialization.h>
  4. namespace OTSIMGPROC
  5. {
  6. // constructor
  7. COTSImageScanParam::COTSImageScanParam()
  8. {
  9. Init();
  10. }
  11. // copy constructor
  12. COTSImageScanParam::COTSImageScanParam(const COTSImageScanParam& a_oSource)
  13. {
  14. // can't copy itself
  15. if (&a_oSource == this)
  16. {
  17. return;
  18. }
  19. // copy data over
  20. Duplicate(a_oSource);
  21. }
  22. // copy constructor
  23. COTSImageScanParam::COTSImageScanParam(COTSImageScanParam* a_poSource)
  24. {
  25. // input check
  26. ASSERT(a_poSource);
  27. if (!a_poSource)
  28. {
  29. return;
  30. }
  31. // can't copy itself
  32. if (a_poSource == this)
  33. {
  34. return;
  35. }
  36. // copy data over
  37. Duplicate(*a_poSource);
  38. }
  39. // =operator
  40. COTSImageScanParam& COTSImageScanParam::operator=(const COTSImageScanParam& a_oSource)
  41. {
  42. // cleanup
  43. Cleanup();
  44. // copy the class data over
  45. Duplicate(a_oSource);
  46. // return class
  47. return *this;
  48. }
  49. // ==operator
  50. BOOL COTSImageScanParam::operator==(const COTSImageScanParam& a_oSource)
  51. {
  52. // return test result
  53. return((m_nStopMode == a_oSource.m_nStopMode) &&
  54. (m_nStopParamMeasTime == a_oSource.m_nStopParamMeasTime) &&
  55. (m_nStopParamFields == a_oSource.m_nStopParamFields) &&
  56. (m_nStopParamParticles == a_oSource.m_nStopParamParticles) &&
  57. (m_nSatrtImageMode == a_oSource.m_nSatrtImageMode) &&
  58. (m_nImagePixelSize == a_oSource.m_nImagePixelSize));
  59. }
  60. // detractor
  61. COTSImageScanParam::~COTSImageScanParam()
  62. {
  63. Cleanup();
  64. }
  65. // COTSStageData member functions
  66. // serialization
  67. void COTSImageScanParam::Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode)
  68. {
  69. xmls::xString xnStopMode;
  70. xmls::xInt xnStopParamMeasTime;
  71. xmls::xInt xnStopParamFields;
  72. xmls::xInt xnStopParamParticles;
  73. xmls::xString xnSatrtImageMode;
  74. xmls::xString xnScanImageSpeed;
  75. xmls::xString xnImageResolution;
  76. xmls::Slo slo;
  77. slo.Register("StopMode", &xnStopMode);
  78. slo.Register("StopParamMeasTime", &xnStopParamMeasTime);
  79. slo.Register("StopParamFields", &xnStopParamFields);
  80. slo.Register("StopParamParticles", &xnStopParamParticles);
  81. slo.Register("SatrtImageMode", &xnSatrtImageMode);
  82. slo.Register("ScanImageSpeed", &xnScanImageSpeed);
  83. slo.Register("ImageResolution", &xnImageResolution);
  84. if (isStoring)
  85. {
  86. /*xnStopMode = std::to_string((int)m_nStopMode);
  87. xnStopParamMeasTime = m_nStopParamMeasTime;
  88. xnStopParamFields = m_nStopParamFields;
  89. xnStopParamParticles = m_nStopParamParticles;
  90. xnSatrtImageMode = (int)m_nSatrtImageMode;
  91. xnScanImageSpeed = (int)m_nScanImageSpeed;
  92. xnImagePixelSize = (int)m_nImagePixelSize;
  93. slo.Serialize(true, classDoc, rootNode);*/
  94. }
  95. else
  96. {
  97. slo.Serialize(false, classDoc, rootNode);
  98. m_nStopMode = (OTS_MEASURE_STOP_MODE)stoi(xmls::SplitString(xnStopMode.value(),":")[0]);
  99. m_nStopParamMeasTime = xnStopParamMeasTime.value();
  100. m_nStopParamFields = xnStopParamFields.value();
  101. m_nSatrtImageMode = (OTS_GET_IMAGE_MODE)stoi(xmls::SplitString(xnSatrtImageMode.value(),":")[0]);
  102. m_nScanImageSpeed = (OTS_THREE_TIES_OPTIONS)stoi(xmls::SplitString(xnScanImageSpeed.value(),":")[0]);
  103. m_nImagePixelSize = (OTS_FIVE_TIES_OPTIONS)stoi(xmls::SplitString(xnImageResolution.value(), ":")[0]);
  104. }
  105. }
  106. // cleanup
  107. void COTSImageScanParam::Cleanup()
  108. {
  109. // nothing needs to be done at the moment
  110. }
  111. // initialization
  112. void COTSImageScanParam::Init()
  113. {
  114. m_nStopMode = DEFUALT_MEASURE_STOP_MODE; //测量终止方式
  115. m_nStopParamMeasTime = DEFUALT_PARAM_TIME; //测量时间
  116. m_nStopParamFields = DEFUALT_PARAM_FIELD; //帧图数
  117. m_nStopParamParticles = DEFUALT_PARAM_PARTICLE; //夹杂物数
  118. m_nSatrtImageMode = DEFAULT_IMAGEMODE; //取图方式
  119. m_nScanImageSpeed = DEFAULE_SCAN_SPEED;
  120. m_nImagePixelSize = DEFAULE_IMAGE_SIZE;
  121. }
  122. // duplication
  123. void COTSImageScanParam::Duplicate(const COTSImageScanParam& a_oSource)
  124. {
  125. // initialization
  126. Init();
  127. // copy data over
  128. m_nStopMode = a_oSource.m_nStopMode;
  129. m_nStopParamMeasTime = a_oSource.m_nStopParamMeasTime;
  130. m_nStopParamFields = a_oSource.m_nStopParamFields;
  131. m_nStopParamParticles = a_oSource.m_nStopParamParticles;
  132. m_nSatrtImageMode = a_oSource.m_nSatrtImageMode;
  133. m_nImagePixelSize = a_oSource.m_nImagePixelSize;
  134. m_nScanImageSpeed = a_oSource.m_nScanImageSpeed;
  135. }
  136. }