| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- #include "stdafx.h"
- #include "OTSScanSim.h"
- #include "otsdataconst.h"
- namespace OTSController {
- //private method
- namespace
- {
- // get system common data folder pathname
- // return "" if failed
- CString GetOSCommonDataPathName()
- {
- CString strPathName = _T(".\\");
- return strPathName;
- }
- // 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;
- }
-
- // check if the file exists or not
- BOOL Exists(LPCTSTR a_sPath)
- {
- return ::PathFileExists(a_sPath) == TRUE;
- }
- }
- const CString SIMULATION_IMAGE_FILEPATH = _T("Simulate");
- const CString SIMULATION_IMAGE_FILENAME = _T("SimImage.bmp");
- COTSScanSim::COTSScanSim()
- {
- }
- COTSScanSim::~COTSScanSim()
- {
- }
- // initialization
- BOOL COTSScanSim::Init()
- {
- // ok, return TRUE
- return TRUE;
- }
- // get the size of matrix.
- //CSize COTSScanSim::GetMatrixSize(int /*a_nMatrixIndex*/)
- //{
- // return CSize(0);
- //}
- // acquire BSE image
- CBSEImgPtr COTSScanSim::AcquireBSEImage()
- {
- // BSE image
- CBSEImgPtr poBSEImgPtr = nullptr;
-
- // load simulation image
- poBSEImgPtr = AcquireBSEImageFromBitmapFile();
- // check simulation image
- ASSERT(poBSEImgPtr);
- if (!poBSEImgPtr)
- {
- // failed to load simulation image
- LogErrorTrace(__FILE__, __LINE__, _T("COTSScanSim::AcquireBSEImage: failed to load simulation image"));
- }
- Sleep(1000);//simulate the real sem time delay.
- // return simulation image, nullptr if load simulation image failed
- return poBSEImgPtr;
- }
- // get image from a file
- CBSEImgPtr COTSScanSim::AcquireBSEImageFromBitmapFile()
- {
- // prepare file
- CFile file;
- CFileException fe;
- BYTE* m_pPixel;
- BYTE* m_pBmInfo;
- BITMAPFILEHEADER* m_pBmfh;
- m_pBmfh = new BITMAPFILEHEADER;
- CBSEImgPtr bseImage;
- // get simulation image file name
- CString strOTSSysDataPath = GetCompanySysDataPathName();
- CString strBitmapFilePathName = strOTSSysDataPath + SIMULATION_IMAGE_FILEPATH + _T("\\") + SIMULATION_IMAGE_FILENAME;
- // check if the file exist
- if (Exists(strBitmapFilePathName))
- {
- if (!file.Open(strBitmapFilePathName, CFile::modeRead, &fe))
- {
- LogInfoTrace(__FILE__, __LINE__, _T("COTSEDSBase::AcquireBSEImageFromBitmapFile: failed to open simulation image file %s."), strBitmapFilePathName);
- return nullptr;
- }
- // read file header
- file.Read(m_pBmfh, sizeof(BITMAPFILEHEADER));
- m_pBmInfo = new BYTE[m_pBmfh->bfOffBits - 14];
- file.Read(m_pBmInfo, m_pBmfh->bfOffBits - 14);
- BITMAPINFOHEADER bmih;
- memcpy(&bmih, m_pBmInfo, sizeof(BITMAPINFOHEADER));
- long width = bmih.biWidth;//获取宽度
- int bitCount = bmih.biBitCount;//获取位数
- long height = bmih.biHeight;//获取高度
- long LineBytes = (width * bitCount + 31) / 32 * 4;//计算每行像素所占的字节数
- m_pPixel = new BYTE[height * LineBytes];
- file.Read(m_pPixel, height * LineBytes);
- file.Close();
- CRect imageRect(0, 0, width, height);
- bseImage = CBSEImgPtr(new CBSEImg(imageRect));
- /*bseImage->SetImageRect(imageRect);*/
- bseImage->InitImageData(width, height);
- BYTE* pImageData = bseImage->GetImageDataPointer();
- long nActImageSize = width * height;
- for (int i = 0; i < height; i++)
- {
- memcpy(pImageData + i * width, m_pPixel + (height - i) * width, width);
- }
- delete[]m_pPixel;
- delete[]m_pBmInfo;
- delete m_pBmfh;
- }
- else
- {
- LogInfoTrace(__FILE__, __LINE__, _T("COTSEDSBase::AcquireBSEImageFromBitmapFile: failed to open simulation image file %s."), strBitmapFilePathName);
- return nullptr;
- }
- return bseImage;
- }
-
- // move beam to point
- BOOL COTSScanSim::MoveBeamTo(CPoint& a_beamPos)
- {
-
- return FALSE;
- }
- // start scan table
- //BOOL COTSScanSim::StartScanTable(int /*a_nMatrixIndex*/, unsigned int /*nP*/, int* /*px*/, int* /*py*/)
- //{
- // return TRUE;
- //}
- // set image size
- BOOL COTSScanSim::SetImageSize(long a_nImageSizeX,long nHeight)
- {
- return TRUE;
- }
- // set dwell time
- BOOL COTSScanSim::SetDwellTime(long a_nDwellTime)
- {
- return TRUE;
- }
- // get dwell time by index
- //long COTSScanSim::GetDwellTimeByIndex(const long a_nIndex)
- //{
- // // check index
- // if (a_nIndex < DWELLTIME_BRUKER_ID_MIN || a_nIndex > DWELLTIME_BRUKER_ID_MAX)
- // {
- // // invalid index
- // ASSERT(FALSE);
- // LogInfoTrace(__FILE__, __LINE__, _T("COTSScanSim::GetDwellTimeByIndex: invalid index"));
- // return -1;
- // }
- // // get dwell time by index
- // long nDwellTime = DWELLTIME_BRUKER_VALUES[a_nIndex];
- // return nDwellTime;
- //}
- // set dwell time by index
- //BOOL COTSScanSim::SetDwellTimeByIndex(const long a_nIndex)
- //{
- // // check index
- // if (a_nIndex < DWELLTIME_BRUKER_ID_MIN || a_nIndex > DWELLTIME_BRUKER_ID_MIN)
- // {
- // // invalid index
- // ASSERT(FALSE);
- // LogInfoTrace(__FILE__, __LINE__, _T("COTSScanSim::SetDwellTimeByIndex: invalid index"));
- // return FALSE;
- // }
- // // get dwell time
- // long nDwellTime = DWELLTIME_BRUKER_VALUES[a_nIndex];
- // if (!SetDwellTime(nDwellTime))
- // {
- // // failed to call SetDwellTime method
- // LogErrorTrace(__FILE__, __LINE__, _T("COTSScanSim::SetDwellTimeByIndex: failed to call SetDwellTime method."));
- // return FALSE;
- // }
- // // ok, return TRUE
- // return TRUE;
- //}
- // scan field size
- /*BOOL COTSScanSim::SetScanFieldSize(const int a_nWidth, const int a_nHeight)
- {
- m_nScanFieldSizeX = a_nWidth;
- m_nScanFieldSizeY = a_nHeight;
- return TRUE;
- }*/
- // set the SEM position
- /*BOOL COTSScanSim::SetEMPosition(const int a_nPosX, const int a_nPosY)
- {
- m_nCurrentBSEPositionX = a_nPosX;
- m_nCurrentBSEPositionY = a_nPosY;
- return TRUE;
- }*/
- }
|