OTSScanBase.h 5.3 KB

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