OTSScanBase.h 5.4 KB

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