OTSScanSim.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #include "stdafx.h"
  2. #include "OTSScanSim.h"
  3. #include "otsdataconst.h"
  4. namespace OTSController {
  5. COTSScanSim::COTSScanSim()
  6. {
  7. }
  8. COTSScanSim::~COTSScanSim()
  9. {
  10. }
  11. /// instance termination
  12. void COTSScanSim::FinishedInstance()
  13. {
  14. }
  15. // initialization
  16. BOOL COTSScanSim::Init()
  17. {
  18. // ok, return TRUE
  19. return TRUE;
  20. }
  21. // get the size of matrix.
  22. CSize COTSScanSim::GetMatrixSize(int /*a_nMatrixIndex*/)
  23. {
  24. return CSize(0);
  25. }
  26. // acquire BSE image
  27. CBSEImgPtr COTSScanSim::AcquireBSEImage(int /*a_nMatrixIndex*/, int /*nReads*/, int /*nDwell*/)
  28. {
  29. // BSE image
  30. CBSEImgPtr poBSEImgPtr = nullptr;
  31. // load simulation image
  32. poBSEImgPtr = AcquireBSEImageFromBitmapFile();
  33. // check simulation image
  34. ASSERT(poBSEImgPtr);
  35. if (!poBSEImgPtr)
  36. {
  37. // failed to load simulation image
  38. LogErrorTrace(__FILE__, __LINE__, _T("COTSScanSim::AcquireBSEImage: failed to load simulation image"));
  39. }
  40. Sleep(1000);//simulate the real sem time delay.
  41. // return simulation image, nullptr if load simulation image failed
  42. return poBSEImgPtr;
  43. }
  44. // move beam to point
  45. BOOL COTSScanSim::MoveBeamTo(CPoint& a_beamPos)
  46. {
  47. return FALSE;
  48. }
  49. // start scan table
  50. BOOL COTSScanSim::StartScanTable(int /*a_nMatrixIndex*/, unsigned int /*nP*/, int* /*px*/, int* /*py*/)
  51. {
  52. return TRUE;
  53. }
  54. // set image size
  55. BOOL COTSScanSim::SetImageSize(long a_nImageSizeX)
  56. {
  57. return TRUE;
  58. }
  59. // set dwell time
  60. BOOL COTSScanSim::SetDwellTime(long a_nDwellTime)
  61. {
  62. return TRUE;
  63. }
  64. // get field resolution by index
  65. CSize COTSScanSim::GetFrameResolutionByIndex(const long a_nIndex)
  66. {
  67. // check index
  68. if (a_nIndex < RESOLUTION_ID_MIN || a_nIndex > RESOLUTION_ID_MAX)
  69. {
  70. // invalid index
  71. ASSERT(FALSE);
  72. LogInfoTrace(__FILE__, __LINE__, _T("COTSScanSim::GetFrameResolutionByIndex: invalid index"));
  73. return CSize(0);
  74. }
  75. // get field resolution
  76. CSize sizeFieldResolution = RESOLUTION_VALUE[a_nIndex];
  77. return sizeFieldResolution;
  78. }
  79. // set field resolution by index
  80. BOOL COTSScanSim::SetFrameResolutionByIndex(const long a_nIndex)
  81. {
  82. // check index
  83. if (a_nIndex < RESOLUTION_ID_MIN || a_nIndex > RESOLUTION_ID_MAX)
  84. {
  85. // invalid index
  86. ASSERT(FALSE);
  87. LogInfoTrace(__FILE__, __LINE__, _T("COTSScanSim::SetFrameResolutionByIndex: invalid index"));
  88. return FALSE;
  89. }
  90. // get field resolution
  91. CSize sizeFieldResolution = RESOLUTION_VALUE[a_nIndex];
  92. // set image size
  93. if (!SetImageSize(sizeFieldResolution.cx))
  94. {
  95. // failed to call SetImageSize method
  96. LogErrorTrace(__FILE__, __LINE__, _T("COTSScanSim::SetFrameResolutionByIndex: failed to call SetImageSize method."));
  97. return FALSE;
  98. }
  99. // ok, return TRUE
  100. return TRUE;
  101. }
  102. // get dwell time by index
  103. long COTSScanSim::GetDwellTimeByIndex(const long a_nIndex)
  104. {
  105. // check index
  106. if (a_nIndex < DWELLTIME_BRUKER_ID_MIN || a_nIndex > DWELLTIME_BRUKER_ID_MAX)
  107. {
  108. // invalid index
  109. ASSERT(FALSE);
  110. LogInfoTrace(__FILE__, __LINE__, _T("COTSScanSim::GetDwellTimeByIndex: invalid index"));
  111. return -1;
  112. }
  113. // get dwell time by index
  114. long nDwellTime = DWELLTIME_BRUKER_VALUES[a_nIndex];
  115. return nDwellTime;
  116. }
  117. // set dwell time by index
  118. BOOL COTSScanSim::SetDwellTimeByIndex(const long a_nIndex)
  119. {
  120. // check index
  121. if (a_nIndex < DWELLTIME_BRUKER_ID_MIN || a_nIndex > DWELLTIME_BRUKER_ID_MIN)
  122. {
  123. // invalid index
  124. ASSERT(FALSE);
  125. LogInfoTrace(__FILE__, __LINE__, _T("COTSScanSim::SetDwellTimeByIndex: invalid index"));
  126. return FALSE;
  127. }
  128. // get dwell time
  129. long nDwellTime = DWELLTIME_BRUKER_VALUES[a_nIndex];
  130. if (!SetDwellTime(nDwellTime))
  131. {
  132. // failed to call SetDwellTime method
  133. LogErrorTrace(__FILE__, __LINE__, _T("COTSScanSim::SetDwellTimeByIndex: failed to call SetDwellTime method."));
  134. return FALSE;
  135. }
  136. // ok, return TRUE
  137. return TRUE;
  138. }
  139. // scan field size
  140. BOOL COTSScanSim::SetScanFieldSize(const int a_nWidth, const int a_nHeight)
  141. {
  142. m_nScanFieldSizeX = a_nWidth;
  143. m_nScanFieldSizeY = a_nHeight;
  144. return TRUE;
  145. }
  146. // set the SEM position
  147. BOOL COTSScanSim::SetEMPosition(const int a_nPosX, const int a_nPosY)
  148. {
  149. m_nCurrentBSEPositionX = a_nPosX;
  150. m_nCurrentBSEPositionY = a_nPosY;
  151. return TRUE;
  152. }
  153. }