#include "StdAfx.h"
|
#include "StatusMonitor.h"
|
|
#define VALID_IDX(i, max) ((unsigned)(i) < (unsigned)(max))
|
#define VALID_CAM(c) VALID_IDX((c), MAX_CAMERA_COUNT)
|
#define VALID_SCAN(s) VALID_IDX((s), MAX_SCAN_COUNT)
|
#define VALID_CAM_SCAN(c, s) (VALID_CAM(c) && VALID_SCAN(s))
|
|
//////////////////////////////////////////////////////////////////////////
|
|
CStatusMonitor::CStatusMonitor(void)
|
{
|
m_iScanIdx = -1;
|
for (int iCam = 0; iCam < MAX_CAMERA_COUNT; iCam++) {
|
m_pFrameBuffer[iCam] = NULL;
|
}
|
|
m_pControlInterface = NULL;
|
m_pLightManager = NULL;
|
m_pTransData = NULL;
|
m_pGlassData = NULL;
|
m_pRecipe = NULL;
|
m_pHWSettings = NULL;
|
m_pLanguageControl = NULL;
|
m_pLicenseChecker = NULL;
|
|
InitGlassLoading();
|
}
|
|
CStatusMonitor::~CStatusMonitor(void)
|
{
|
}
|
|
void CStatusMonitor::InitGlassLoading()
|
{
|
ZeroMemory(m_nGrabFrame, sizeof(m_nGrabFrame));
|
ZeroMemory(m_bGrabEnd, sizeof(m_bGrabEnd));
|
}
|
|
int CStatusMonitor::GetGrabFrameCount(int nCamera, int iScan)
|
{
|
if (VALID_CAM_SCAN(nCamera, iScan)) {
|
return m_nGrabFrame[nCamera][iScan];
|
}
|
|
return 0;
|
}
|
|
void CStatusMonitor::SetGrabEnd(int nCamera, int iScan)
|
{
|
if (VALID_CAM_SCAN(nCamera, iScan)) {
|
m_bGrabEnd[nCamera][iScan] = TRUE;
|
}
|
}
|
|
void CStatusMonitor::SetGrabFrametoScan(int nCamera, int iScan,int nFrame)
|
{
|
if (VALID_CAM_SCAN(nCamera, iScan)) {
|
m_nGrabFrame[nCamera][iScan] = nFrame;
|
}
|
}
|
|
BOOL CStatusMonitor::DeleteFolder(const CString &strFolder)
|
{
|
SHFILEOPSTRUCT FileOp = {0};
|
TCHAR szTemp[MAX_PATH];
|
|
wcscpy_s(szTemp, MAX_PATH, strFolder);
|
szTemp[strFolder.GetLength() + 1] = NULL; // NULL巩磊啊 滴俺 甸绢啊具 茄促.
|
|
FileOp.hwnd = NULL;
|
FileOp.wFunc = FO_DELETE;
|
FileOp.pFrom = NULL;
|
FileOp.pTo = NULL;
|
FileOp.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI; // 犬牢皋矫瘤啊 救哆档废 汲沥
|
FileOp.fAnyOperationsAborted = false;
|
FileOp.hNameMappings = NULL;
|
FileOp.lpszProgressTitle = NULL;
|
FileOp.pFrom = szTemp;
|
|
SHFileOperation(&FileOp);
|
|
return true;
|
}
|
|
BOOL CStatusMonitor::CheckDirectory(const TCHAR szPathName[], BOOL bDelete/* = FALSE*/)
|
{
|
CFileFind finder;
|
CString strTemp;
|
CString strDir = szPathName;
|
int nPos;
|
|
BOOL bExist = finder.FindFile(szPathName);
|
|
if(bDelete == TRUE)
|
{
|
DeleteFolder(szPathName);
|
bExist = FALSE;
|
}
|
|
if (bExist == FALSE)
|
{
|
nPos = strDir.Find(_T("\\"));
|
nPos = strDir.Find(_T("\\"), nPos+1);
|
while(nPos > 0)
|
{
|
strTemp = strDir.Mid(0,nPos);
|
if(0 < strTemp.GetLength())
|
{
|
if(CString("\\") == strTemp.GetAt(strTemp.GetLength()-1))
|
{
|
nPos = strDir.Find(_T("\\"), nPos+1);
|
continue;
|
}
|
}
|
if (finder.FindFile(strTemp) == FALSE)
|
{
|
if(::CreateDirectory(strTemp, NULL) == FALSE)
|
{
|
strTemp.Format(_T("[%s]Folder Create Fail. "), szPathName);
|
|
//LogMessage(strTemp, 2);
|
return FALSE;
|
}
|
}
|
nPos = strDir.Find(_T("\\"), nPos+1);
|
}
|
}
|
return TRUE;
|
}
|