OTSScanBase.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. #pragma once
  2. #include "BSEImg.h"
  3. #include "stdafx.h"
  4. #include "SEMCommonConst.h"
  5. namespace OTSController
  6. {
  7. using namespace OTSDATA;
  8. const CString SIMULATION_IMAGE_FILEPATH = _T("Simulate");
  9. const CString SIMULATION_IMAGE_FILENAME = _T("SimImage.bmp");
  10. /// <summary>
  11. /// Interface of Image Acquisition Device
  12. /// </summary>
  13. class __declspec(dllexport) COTSScanBase
  14. {
  15. public:
  16. enum DEFAULT_SCAN_PARAMETER
  17. {
  18. SCAN_MAX_X = 4096,
  19. SCAN_MAX_Y = 3200,
  20. SCAN_STEP_SIZE = 4,
  21. SCAN_PIXEL_DWELL = 1,
  22. SCAN_INTER_PIXEL_DWELL = 1,
  23. SCAN_NUMBER_OF_READS = 1,
  24. SCAN_IMATRIX = 4
  25. };
  26. public:
  27. COTSScanBase();
  28. ~COTSScanBase();
  29. /// instance termination
  30. virtual void FinishedInstance() = 0;
  31. // get name
  32. CString GetName()
  33. {
  34. CString strR = ScanController::GetName((int)GetType());
  35. return strR;
  36. }
  37. virtual ScanController::SCANNER_ID GetType() = 0;
  38. // initialization
  39. virtual BOOL Init() = 0;
  40. /// <summary>
  41. /// Capture a backscatter image, and apply any post processing.
  42. /// Note: The scanner interface seems to be heavily polluted by edax specific parameters
  43. /// passed to this and many other functions. The edax scanner collects a frame based
  44. /// on these parameters, other scanners (e.g. bruker,) rely on internal state set
  45. /// via SetImageSize, SetDwellTime etc.
  46. /// </summary>
  47. virtual CBSEImgPtr AcquireBSEImage(int a_nMatrixIndex, int a_nReads, int a_nDwell) = 0;
  48. // move beam to point
  49. virtual BOOL MoveBeamTo(CPoint& a_beamPos) = 0;
  50. // Set and Start Scan
  51. virtual BOOL SetAndStartScan(void) = 0;
  52. // Set point Scan
  53. virtual BOOL SetPointScan(int a_nMatrixIndex) = 0;
  54. // Start Scan Table
  55. virtual BOOL StartScanTable(int a_nMatrixIndex, unsigned int nP, int* pnx, int* pny) = 0;
  56. /// set dwell time
  57. virtual BOOL SetDwellTime(long a_nDwellTime) = 0;
  58. // set Image Size
  59. virtual BOOL SetImageSize(long a_nImageSize) = 0;
  60. /// <summary>
  61. /// Gets the size of the matrix.
  62. /// </summary>
  63. /// <param name="a_nMatrixIndex">Index of the matrix.</param>
  64. /// <returns>the size of Matrix</returns>
  65. virtual CSize GetMatrixSize(int a_nMatrixIndex) = 0;
  66. /// <summary>
  67. /// Sets the size of the scan field.
  68. /// Note: only for simulation mode
  69. /// </summary>
  70. /// <param name="a_nWidth">The scan field width</param>
  71. /// <param name="a_nHeight">The scan field height</param>
  72. /// <returns>TRUE: successful</returns>
  73. virtual BOOL SetScanFieldSize(const int a_nWidth, const int a_nHeight) = 0;
  74. /// <summary>
  75. /// Set the em position
  76. /// Note: only for simulation mode
  77. /// </summary>
  78. /// <param name="a_nPosX">The EM position X</param>
  79. /// <param name="a_nPosY">The EM position Y</param>
  80. /// <returns>TRUE: successful</returns>
  81. virtual BOOL SetEMPosition(const int a_nPosX, const int a_nPosY) = 0;
  82. virtual CSize GetFrameResolutionByIndex(const long a_nIndex) = 0;
  83. virtual BOOL SetFrameResolutionByIndex(const long a_nIndex) = 0;
  84. virtual long GetDwellTimeByIndex(const long a_nIndex) = 0;
  85. virtual BOOL SetDwellTimeByIndex(const long a_nIndex) = 0;
  86. /// <summary>
  87. /// Determines whether this instance is bruker controller.
  88. /// </summary>
  89. /// <returns>TRUE: is bruker type</returns>
  90. BOOL IsBruker();
  91. CBSEImgPtr AcquireBSEImageFromBitmapFile();
  92. CSize GetScanRange() { return m_szScanRange; }
  93. void SetScanRange(CSize a_szScanRange) { m_szScanRange = a_szScanRange; }
  94. int GetScanStepSize() { return m_nScanStepSize; }
  95. void SetScanStepSize(int size) { m_nScanStepSize = size; }
  96. int GetInterPixelDwell() { return m_nInterPixelDwell; }
  97. void SetInterPixelDwell(int i) { m_nInterPixelDwell = i; }
  98. int GetNumberOfReads() { return m_nNumberOfReads; }
  99. void SetNumberOfReads(int i) { m_nNumberOfReads = i; }
  100. double GetMagnification() { return m_dMag; }
  101. void SetMagnification(double a_dMag) { m_dMag = a_dMag; }
  102. int GetMaxSizeIndex();
  103. public:
  104. CSize m_fieldSizes[7];
  105. CSize m_szScanRange;
  106. DWORD m_nFrameStoreSizeWords;
  107. WORD* m_pnFrameStore;
  108. int m_nScanStepSize;
  109. int m_nPixelDwell;
  110. int m_nInterPixelDwell;
  111. int m_nNumberOfReads;
  112. int m_nMatrix;
  113. double m_dMag;
  114. // for simulation:
  115. CBSEImgPtrVec m_simFieldList;
  116. std::vector<CPoint> m_simFieldPos;
  117. CRect m_simRect;
  118. int m_nCurrentBSEPositionX;
  119. int m_nCurrentBSEPositionY;
  120. int m_nScanFieldSizeX;
  121. int m_nScanFieldSizeY;
  122. BOOL m_bIsSimuation;
  123. // get company system data path
  124. CString GetCompanySysDataPathName()
  125. {
  126. // get common data pathname string
  127. CString strCommonDataPathName = GetOSCommonDataPathName();
  128. if (strCommonDataPathName.IsEmpty())
  129. {
  130. // failed to get common data pathname string
  131. LogErrorTrace(__FILE__, __LINE__, _T("GetOTSPackSysDataPathName: failed to common data pathname string."));
  132. return _T("");
  133. }
  134. // company system data pathname
  135. //CString strCmpSysDataPath = strCommonDataPathName + STR_COMPANYNAME + _T("\\") + STR_SYSTEM_DATA + _T("\\");
  136. CString strCmpSysDataPath = strCommonDataPathName + STR_COMPANYNAME + _T("\\");
  137. // return company system data pathname
  138. return strCmpSysDataPath;
  139. }
  140. // get system common data folder pathname
  141. // return "" if failed
  142. CString GetOSCommonDataPathName()
  143. {
  144. CString strPathName = _T(".\\");
  145. return strPathName;
  146. }
  147. // check if the file exists or not
  148. BOOL Exists(LPCTSTR a_sPath)
  149. {
  150. return ::PathFileExists(a_sPath) == TRUE;
  151. }
  152. };
  153. typedef std::shared_ptr<COTSScanBase> COTSScanBasePtr;
  154. } // namespace Controller