#pragma once
#include "BSEImg.h"
#include "stdafx.h"
#include "SEMCommonConst.h"
namespace OTSController
{
using namespace OTSDATA;
const CString SIMULATION_IMAGE_FILEPATH = _T("Simulate");
const CString SIMULATION_IMAGE_FILENAME = _T("SimImage.bmp");
const CString SIMULATION_TIFFIMAGE_FILENAME = _T("SimImage.tif");
const CString SIMULATION_JPEGIMAGE_FILENAME = _T("SimImage.jpg");
const CString SIMULATION_PNGIMAGE_FILENAME = _T("SimImage.png");
///
/// Interface of Image Acquisition Device
///
class __declspec(dllexport) COTSScanBase
{
public:
enum DEFAULT_SCAN_PARAMETER
{
SCAN_MAX_X = 4096,
SCAN_MAX_Y = 3200,
SCAN_STEP_SIZE = 4,
SCAN_PIXEL_DWELL = 1,
SCAN_INTER_PIXEL_DWELL = 1,
SCAN_NUMBER_OF_READS = 1,
SCAN_IMATRIX = 4
};
public:
COTSScanBase();
~COTSScanBase();
/// instance termination
//virtual void FinishedInstance() = 0;
// get name
CString GetName()
{
CString strR = ScanController::GetName((int)GetType());
return strR;
}
virtual ScanController::SCANNER_ID GetType() = 0;
// initialization
virtual BOOL Init() = 0;
///
/// Capture a backscatter image, and apply any post processing.
/// Note: The scanner interface seems to be heavily polluted by edax specific parameters
/// passed to this and many other functions. The edax scanner collects a frame based
/// on these parameters, other scanners (e.g. bruker,) rely on internal state set
/// via SetImageSize, SetDwellTime etc.
///
virtual CBSEImgPtr AcquireBSEImage(int a_nMatrixIndex, int a_nReads, int a_nDwell) = 0;
// move beam to point
virtual BOOL MoveBeamTo(CPoint& a_beamPos) = 0;
// Set and Start Scan
//virtual BOOL SetAndStartScan(void) = 0;
// Set point Scan
virtual BOOL SetPointScan(int a_nMatrixIndex) = 0;
// Start Scan Table
virtual BOOL StartScanTable(int a_nMatrixIndex, unsigned int nP, int* pnx, int* pny) = 0;
/// set dwell time
virtual BOOL SetDwellTime(long a_nDwellTime) = 0;
// set Image Size
virtual BOOL SetImageSize(long a_nImageSize,long nHeight) = 0;
///
/// Gets the size of the matrix.
///
/// Index of the matrix.
/// the size of Matrix
virtual CSize GetMatrixSize(int a_nMatrixIndex) = 0;
///
/// Sets the size of the scan field.
/// Note: only for simulation mode
///
/// The scan field width
/// The scan field height
/// TRUE: successful
virtual BOOL SetScanFieldSize(const int a_nWidth, const int a_nHeight) = 0;
///
/// Set the em position
/// Note: only for simulation mode
///
/// The EM position X
/// The EM position Y
/// TRUE: successful
virtual BOOL SetEMPosition(const int a_nPosX, const int a_nPosY) = 0;
virtual long GetDwellTimeByIndex(const long a_nIndex) = 0;
virtual BOOL SetDwellTimeByIndex(const long a_nIndex) = 0;
///
/// Determines whether this instance is bruker controller.
///
/// TRUE: is bruker type
BOOL IsBruker();
CBSEImgPtr AcquireBSEImageFromBitmapFile();
CBSEImgPtr AcquireBSEImageFromTiffFile();
CBSEImgPtr AcquireBSEImageFromJpegFile();
CBSEImgPtr AcquireBSEImageFromPngFile();
CSize GetScanRange() { return m_szScanRange; }
void SetScanRange(CSize a_szScanRange) { m_szScanRange = a_szScanRange; }
int GetScanStepSize() { return m_nScanStepSize; }
void SetScanStepSize(int size) { m_nScanStepSize = size; }
int GetInterPixelDwell() { return m_nInterPixelDwell; }
void SetInterPixelDwell(int i) { m_nInterPixelDwell = i; }
int GetNumberOfReads() { return m_nNumberOfReads; }
void SetNumberOfReads(int i) { m_nNumberOfReads = i; }
double GetMagnification() { return m_dMag; }
void SetMagnification(double a_dMag) { m_dMag = a_dMag; }
int GetMaxSizeIndex();
public:
CSize m_fieldSizes[7];
CSize m_szScanRange;
DWORD m_nFrameStoreSizeWords;
WORD* m_pnFrameStore;
int m_nScanStepSize;
int m_nPixelDwell;
int m_nInterPixelDwell;
int m_nNumberOfReads;
int m_nMatrix;
double m_dMag;
// for simulation:
CBSEImgPtrVec m_simFieldList;
std::vector m_simFieldPos;
CRect m_simRect;
int m_nCurrentBSEPositionX;
int m_nCurrentBSEPositionY;
int m_nScanFieldSizeX;
int m_nScanFieldSizeY;
BOOL m_bIsSimuation;
// get company system data path
CString GetCompanySysDataPathName()
{
// get common data pathname string
CString strCommonDataPathName = GetOSCommonDataPathName();
if (strCommonDataPathName.IsEmpty())
{
// failed to get common data pathname string
LogErrorTrace(__FILE__, __LINE__, _T("GetOTSPackSysDataPathName: failed to common data pathname string."));
return _T("");
}
// company system data pathname
CString strCmpSysDataPath = strCommonDataPathName + STR_COMPANYNAME + _T("\\");
// return company system data pathname
return strCmpSysDataPath;
}
// get system common data folder pathname
// return "" if failed
CString GetOSCommonDataPathName()
{
CString strPathName = _T(".\\");
return strPathName;
}
// check if the file exists or not
BOOL Exists(LPCTSTR a_sPath)
{
return ::PathFileExists(a_sPath) == TRUE;
}
};
typedef std::shared_ptr COTSScanBasePtr;
} // namespace Controller