// Glass.cpp: implementation of the CGlass class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "Glass_Data.h" #include #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CGlass_Data::CGlass_Data(void) { m_pGlassRecipe = NULL; m_pHardwareSetting = NULL; InitializeCriticalSection(&m_csGlassDefect); ResetGlass(); } CGlass_Data::~CGlass_Data() { DeleteCriticalSection(&m_csGlassDefect); ResetDefect(); } void CGlass_Data::ResetDefect() { CInspectDefect* pData; for (MapDefectIt it = m_MapDefect.begin(); it != m_MapDefect.end(); it++) { pData = static_cast(it->second); delete pData; } m_MapDefect.clear(); m_nCurDefectIdx = 0; m_nJudgeDefectCount = 0; LeaveCriticalSection(&m_csGlassDefect); } void CGlass_Data::ResetGlass() { ResetDefect(); m_strLoadingTime = _T(""); m_strUnloadingTime = _T(""); m_strScanStartTime = _T(""); m_strScanEndTime = _T(""); m_bPostProcessing = FALSE; ZeroMemory(m_EdgeResultInfo,sizeof(INS_EDGE_RESULT_INFO)*MAX_DIMENSION_COUNT); m_stProfileResult.Reset(); ZeroMemory(m_nGlassResult,sizeof(short) * 11); m_ProfileInspectData.Reset(); ZeroMemory(m_nStageLongTheta,sizeof(short)*2); ZeroMemory(m_nStageShortTheta,sizeof(short)*2); ZeroMemory(m_bScanEnd,sizeof(m_bScanEnd)); m_bScanStart = FALSE; m_nStartCount = 0; ZeroMemory(m_bScanEndCamera,sizeof(m_bScanEndCamera)); m_bOnly_Profile_NG = TRUE; for(int i=0; im_InspectInfoParm; if(pInsPrm == NULL) return bUse; switch(emIns) { case EM_INS_EDGE: bUse = pInsPrm->GetCutAreaUse(DIMENSION_NONE); break; case EM_INS_CORNER: break; case EM_INS_DIMENSION: bUse = pInsPrm->GetDimenUse(DIMENSION_NONE); break; case EM_INS_SPLINE: bUse = pInsPrm->GetSplineUse(DIMENSION_NONE); break; case EM_INS_NOTCH: bUse = pInsPrm->GetNotchSizeUse(DIMENSION_NONE); break; case EM_INS_SPLINE_POINT_JUDGE: bUse = pInsPrm->GetSplineUsePointJudge(-1); break; } return bUse; } CInspectDefect* CGlass_Data::GetDefect(int nDefecIdx) { CInspectDefect *pDefect = NULL; for(MapDefectIt it=m_MapDefect.begin();it!=m_MapDefect.end();it++) { pDefect = static_cast(it->second); if(pDefect != NULL && pDefect->m_nGlassDefectIdx == nDefecIdx) { return pDefect; } } return NULL; } BOOL CGlass_Data::SetDefect(CInspectDefect* pDefect) { EnterCriticalSection(&m_csGlassDefect); if (!pDefect) { LeaveCriticalSection(&m_csGlassDefect); return FALSE; } pDefect->m_nGlassDefectIdx = m_nCurDefectIdx; m_MapDefect.insert(std::make_pair(pDefect->m_nUMOriginX, pDefect)); m_nCurDefectIdx++; if(pDefect->m_bJudgeDefect == TRUE) m_nJudgeDefectCount++; // 22.06.30 - PROFILE NG COUNTING.. if(pDefect->m_bJudgeDefect == TRUE && pDefect->m_sDefectLoc == DefectLoc_Profile) { int nSideIdx = pDefect->m_nSideLoc; int nProfileIdx = pDefect->m_nProfileIdx; if(0<=nSideIdx && nSideIdx < MAX_DIMENSION_COUNT) { m_nSide_Profile_NG_Count[nSideIdx]++; int nProfileIdx = pDefect->m_nProfileIdx; if(0 <= nProfileIdx && nProfileIdx < MAX_PROFILE_SETTING_COUNT) { int nAbsDiff = abs(m_ProfileInspectData.ProfileData[nProfileIdx].nProfileDiff); if(m_nSide_Profile_NG_Max_Diff[nSideIdx] < nAbsDiff) m_nSide_Profile_NG_Max_Diff[nSideIdx] = nAbsDiff; } } } if(pDefect->m_bJudgeDefect == TRUE && pDefect->m_sDefectLoc != DefectLoc_Profile) m_bOnly_Profile_NG = FALSE; LeaveCriticalSection(&m_csGlassDefect); return TRUE; } ////////////////////////////////////////////////////////////////////////// // Scan void CGlass_Data::SetLoadingTime() { CTime time = CTime::GetCurrentTime(); m_strLoadingTime.Format(_T("%04d%02d%02d_%02d%02d%02d"),time.GetYear(),time.GetMonth(),time.GetDay(),time.GetHour(),time.GetMinute(),time.GetSecond()); m_strLoadingDayFileName.Format(_T("%04d%02d%02d"),time.GetYear(),time.GetMonth(),time.GetDay()); m_strLoadingTimeFileName.Format(_T("%02d%02d%02d"),time.GetHour(),time.GetMinute(),time.GetSecond()); } void CGlass_Data::SetUnloadingTime() { CTime time = CTime::GetCurrentTime(); m_strUnloadingTime.Format(_T("%04d%02d%02d_%02d%02d%02d"),time.GetYear(),time.GetMonth(),time.GetDay(),time.GetHour(),time.GetMinute(),time.GetSecond()); } void CGlass_Data::SetScanStartTime() { CTime time = CTime::GetCurrentTime(); m_strScanStartTime.Format(_T("%04d%02d%02d_%02d%02d%02d"),time.GetYear(),time.GetMonth(),time.GetDay(),time.GetHour(),time.GetMinute(),time.GetSecond()); } void CGlass_Data::SetScanEndTime() { CTime time = CTime::GetCurrentTime(); m_strScanEndTime.Format(_T("%04d%02d%02d_%02d%02d%02d"),time.GetYear(),time.GetMonth(),time.GetDay(),time.GetHour(),time.GetMinute(),time.GetSecond()); m_strScanEndTimeFileName.Format(_T("%04d_%02d_%02d"),time.GetYear(),time.GetMonth(),time.GetDay()); } UINT eProfileIndex[] = {PROFILE_INSPECT_INDEX_A,PROFILE_INSPECT_INDEX_B,PROFILE_INSPECT_INDEX_C,PROFILE_INSPECT_INDEX_D,PROFILE_INSPECT_INDEX_CF}; TCHAR *strProfileString[] = {_T("A"),_T("B"),_T("C"),_T("D"),_T("A")}; UINT eProfileRCutIndex[] = {PROFILE_RCUT_INSPECT_INDEX_A,PROFILE_RCUT_INSPECT_INDEX_D,PROFILE_RCUT_INSPECT_INDEX_B,PROFILE_RCUT_INSPECT_INDEX_C}; TCHAR *strProfileRCutString[] = {_T("RA"),_T("RB"),_T("RC"),_T("RD")}; UINT eProfileSize[] = {PROFILE_INSPECT_SIZE_A_C,PROFILE_INSPECT_SIZE_B_D}; #define MAX_RCUT_PROFILE_COUNT 5 BOOL CGlass_Data::GetProfileInspectIndex(int iSide,int &nIndex,int &nSize,CString &str) { nIndex = nSize = -1; if(iSide < 0 || iSide >=MAX_DIMENSION_COUNT) return FALSE; nIndex = eProfileIndex[iSide%MAX_PANEL_SIDE]; str = strProfileString[iSide%MAX_PANEL_SIDE]; if(iSide%2 == 0) nSize = eProfileSize[0]; else nSize = eProfileSize[1]; return TRUE; } BOOL CGlass_Data::GetProfileRCutInspectIndex(int iSide,int &nIndex,int &nSize,CString &str) { nIndex = nSize = -1; if(iSide < 0 || iSide >=MAX_DIMENSION_COUNT) return FALSE; nIndex = eProfileRCutIndex[iSide]; str = strProfileRCutString[iSide]; nSize = MAX_RCUT_PROFILE_COUNT; return TRUE; } void CGlass_Data::GetStageTheta(int iStage,short &nLongTheta,short &nShortTheta) { nLongTheta = m_nStageLongTheta[iStage]; nShortTheta = m_nStageShortTheta[iStage]; } void CGlass_Data::SetStageTheta(int iStage,BOOL bLong,short nTheta) { if(iStage < 0 || iStage > 1) { g_pLog->DisplayMessage(_T("Stage Theta Index Not Normal : %d"),iStage); return; } if(bLong == TRUE) { m_nStageLongTheta[iStage] = nTheta; } else { m_nStageShortTheta[iStage] = nTheta; } } void CGlass_Data::SetProfileChamferInspectData(int nIndex,int nUp,CHAMFER_RESULT *pChamferResult) { if(nIndex < 0 || nIndex >= MAX_PROFILE_SETTING_COUNT) return; if(nUp < 0 || nUp > 1) return; CSingleLock cLock(&m_csProfileData); cLock.Lock(); PROFILECHAMFER_RESULT_DATA *pProfile = GetProfileInspectData(); CopyMemory(&pProfile->ResultChamfer[nIndex][nUp],pChamferResult,sizeof(CHAMFER_RESULT)); cLock.Unlock(); } void CGlass_Data::SetProfileInspectData(int nIndex,PROFILE_RESULT *pProfileResult) { if(nIndex < 0 || nIndex >= MAX_PROFILE_SETTING_COUNT) return; CSingleLock cLock(&m_csProfileData); cLock.Lock(); PROFILECHAMFER_RESULT_DATA *pProfile = GetProfileInspectData(); CopyMemory(&pProfile->ProfileData[nIndex],pProfileResult,sizeof(PROFILE_RESULT)); cLock.Unlock(); } void CGlass_Data::SetRCutProfileInspectData(int nIndex,PROFILE_RCUT_PROCESSDATA *pProfileResult) { if(nIndex < 0 || nIndex >= MAX_PROFILE_SETTING_COUNT) return; CSingleLock cLock(&m_csProfileData); cLock.Lock(); PROFILECHAMFER_RESULT_DATA *pProfile = GetProfileInspectData(); CopyMemory(&pProfile->RCutProcessData[nIndex],pProfileResult,sizeof(PROFILE_RCUT_PROCESSDATA)); cLock.Unlock(); }