| | |
| | | #include <fstream> |
| | | #include <afxwin.h> |
| | | |
| | | #include <sstream> /* < KJG 20230605 - #4517 ADD >*/ |
| | | #include <filesystem> /* < KJG 20230605 - #4517 ADD >*/ |
| | | |
| | | namespace fs = std::experimental::filesystem::v1; /* < KJG 20230605 - #4517 ADD >*/ |
| | | |
| | | |
| | | #define GLASS_GD_FILE_PATH _T("GD") |
| | | #define SIGNAL_SEND_RESULT_SUCCESS _T("OK") |
| | |
| | | { |
| | | m_bUseAFMHomePosition = TRUE; |
| | | m_nGlassCount = 0; |
| | | m_nStackZeroReviewCondition = 0; |
| | | m_nUploadResultFailCount = 0; |
| | | m_nStackUploadFailGlassCount = 0; |
| | | CDitGlassRawClient* pDitGlassRaw = CDitGlassRawClient::GetInstance(); |
| | | if(pDitGlassRaw->ConnectServer() == FALSE) |
| | | { |
| | |
| | | // m_pSP2P->ISP2P_GetWSIControl(1)->SendWsiAfmSafePosMove(); |
| | | //} |
| | | //Sleep(5000); |
| | | if (GetProcessStatus() != ProcessReviewEnd_CPJT && GetProcessStatus() != ProcessReviewUnloding_CPJT) |
| | | //if (GetProcessStatus() != ProcessReviewEnd_CPJT && GetProcessStatus() != ProcessReviewUnloding_CPJT) |
| | | if (GetReviewComplete() == FALSE) |
| | | { |
| | | SendResultToSignalControl(PCControlSendData_ReviewResult_CPJT, SIGNAL_SEND_RESULT_SUCCESS); |
| | | SendSignalToSignalControl(PCControlSendSignalIndex_Seq, PCControlSend_ReviewComplete_CPJT); |
| | | SetReviewComplete(TRUE); |
| | | } |
| | | |
| | | m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewStart] Send Review Success Signal!")); |
| | |
| | | SetCheckWSIEnd(-1); //190726 |
| | | SetWsiType(-1); //wsi reflow |
| | | SetLastPointCheck(FALSE); |
| | | |
| | | SetReviewComplete(FALSE); |
| | | //SetUploadResultFailCount(0); |
| | | |
| | | bFileFind = FALSE; |
| | | |
| | |
| | | m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] Send Review End Ack!")); |
| | | } |
| | | |
| | | SetUploadResultFailCount(0); |
| | | |
| | | CGlassResult* pGlassResult = m_pSP2P->ISP2P_GetCurrentGlassResult(); |
| | | if (pGlassResult == NULL) return; |
| | | |
| | |
| | | m_pDitGlassRaw->GetGlassData()->m_nReviewNum = m_pSP2P->ISP2P_GetReviewProcessor()->GetPlanReviewCount(); |
| | | //SendDVDataToSignalControl(); |
| | | |
| | | if (GetLastPointCheck() == FALSE) |
| | | //if (GetLastPointCheck() == FALSE) |
| | | if (GetReviewComplete() == FALSE) |
| | | { |
| | | //#3584 210817 LYW CF AOI Review 시뮬레이션 기능 정상화 MOD START |
| | | if (GetSimulationMode() == FALSE) |
| | |
| | | SendResultToSignalControl(PCControlSendData_ReviewResult_CPJT, SIGNAL_SEND_RESULT_SUCCESS); |
| | | SendSignalToSignalControl(PCControlSendSignalIndex_Seq, PCControlSend_ReviewComplete_CPJT); |
| | | m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewStart] Send Review Success Signal!")); |
| | | SetReviewComplete(TRUE); |
| | | } |
| | | //#3584 210817 LYW CF AOI Review 시뮬레이션 기능 정상화 MOD END |
| | | //original |
| | |
| | | CDlgDefocusList::GetInstance()->SetDefocusData(strTime,pGlassResult->m_strGlassID,pGlassResult->m_nDeFocusCount); |
| | | |
| | | } |
| | | |
| | | if (CheckZeroReviewAlarm() == FALSE && m_pSP2P->ISP2P_System_GetNetworkInfo()->m_nZeroReviewAlarm != 0) |
| | | { |
| | | STransferData* pTransferData = m_pSP2P->ISP2P_GetCurrentTransferData(); |
| | | if (pTransferData->strProdType != m_pSP2P->ISP2P_System_GetNetworkInfo()->m_strZeroReviewAlarmExcept) |
| | | { |
| | | m_nStackZeroReviewCondition++; |
| | | m_pSP2P->ISP2P_DisplayMessage(_T("Zero Review Condition ProdType = %s, ConditionStack = %d, AlarmExcept = %s, AlarmCondition = %d"), pTransferData->strProdType, m_nStackZeroReviewCondition, m_pSP2P->ISP2P_System_GetNetworkInfo()->m_strZeroReviewAlarmExcept, m_pSP2P->ISP2P_System_GetNetworkInfo()->m_nZeroReviewAlarm); |
| | | if (m_nStackZeroReviewCondition >= m_pSP2P->ISP2P_System_GetNetworkInfo()->m_nZeroReviewAlarm) |
| | | { |
| | | m_pSP2P->ISP2P_DisplayMessage(_T("Zero Review Alarm! %d ea Glass Is Zero Review!"), m_nStackZeroReviewCondition); |
| | | SendSignalToSignalControl(PCControlSendSignalIndex_State, PCControlSend_Review_0Count_Alarm, 1000); |
| | | m_nStackZeroReviewCondition = 0; |
| | | } |
| | | } |
| | | else m_nStackZeroReviewCondition = 0; |
| | | } |
| | | else m_nStackZeroReviewCondition = 0; |
| | | |
| | | /*< LYW 20211109 - #3662 Delete Start >*/ |
| | | // g_pLog->DisplayMessage(_T("History map Start")); |
| | |
| | | |
| | | BOOL CSequenceProcessor_CPJT::FindRawBinFile(CString strFileName) |
| | | { |
| | | /* < KJG 20230605 - #4517 ADD Start >*/ |
| | | auto FuncStringSplit = [](string Sentence, char Separator, vector<string>& vec) |
| | | { |
| | | stringstream ss(Sentence); |
| | | string tmp; |
| | | |
| | | while (getline(ss, tmp, Separator)) { |
| | | vec.push_back(tmp); |
| | | } |
| | | }; |
| | | /* < KJG 20230605 - #4517 ADD End >*/ |
| | | |
| | | //210128 |
| | | CString strFilePath = _T(""); |
| | | //pData->GetGlassData()->m_strFileName; |
| | |
| | | //#3359_LYW CF AOI Review REVIEW_LOADING_COMPLETE_TIMEOVER START |
| | | if (nReTryTime%2 == 0) |
| | | { |
| | | strFilePath = AOIRAWBIN_PATH; |
| | | strFilePath = AOIRAWBIN_NETWORK_DRIVE_PATH; |
| | | } |
| | | else strFilePath = AOIRAWBIN_NETWORK_DRIVE_PATH; |
| | | else strFilePath = AOIRAWBIN_PATH; |
| | | |
| | | strWild.Format("%s\\%s_*.bin", strFilePath, strFileName); |
| | | akFileFinder.FindFile(strWild.GetBuffer(0), FALSE); |
| | | //LYW LOG |
| | | g_pLog->DisplayMessage(_T("[GlassLoading][FindRawBinFile] Find Path = %s, RetryCount = %d, ResultCode = [%d]"), strFilePath, 30-nReTryTime, GetLastError()); |
| | | //#3359_LYW CF AOI Review REVIEW_LOADING_COMPLETE_TIMEOVER END |
| | | VECFINDDATA* pFindData = akFileFinder.getFindData(); |
| | | int nFileNamePos = strlen(akFileFinder.getProcessPath()); |
| | | std::map<LONGLONG, CString> mapSpanFileName; |
| | | for (int i = 0; i < pFindData->size(); i++) |
| | | //strWild.Format("%s\\%s_*.bin", strFilePath, strFileName); /* < KJG 20230605 - #4517 DEL >*/ |
| | | //akFileFinder.FindFile(strWild.GetBuffer(0), FALSE); /* < KJG 20230605 - #4517 DEL >*/ |
| | | |
| | | /* < KJG 20230605 - #4517 ADD Start >*/ |
| | | auto timeStart = chrono::steady_clock::now(); |
| | | g_pLog->DisplayMessage(_T("[GlassLoading][FindRawBinFile] Start Find Path = %s, File Name = %s, TryCount = %d"), strFilePath, strFileName, 30 - nReTryTime); |
| | | |
| | | std::error_code err; |
| | | vector<std::string> vtFileList; |
| | | fs::path pathBinFile(strFilePath.GetBuffer(0)); |
| | | int constexpr SaperatorCount = 4, DateSize = 8, TimeSize = 6; // GLASSID_STEPID_'YYYYMMDD'_'HHMMSS' 포맷 확인 |
| | | for (auto iter = fs::directory_iterator(pathBinFile, err); iter != fs::directory_iterator(); iter++) |
| | | { |
| | | char* pFileName = &((*pFindData)[i]).name[nFileNamePos]; |
| | | fs::path p = iter->path(); |
| | | if (p.filename().stem().string().find(strFileName) != string::npos) |
| | | { |
| | | CakParser parser; |
| | | parser.process(pFileName, "_."); |
| | | if (parser.getTokNum() < 4) continue; |
| | | |
| | | if (parser.getTokNum() >= 6) continue; // 0401 |
| | | |
| | | int nDataTime[8] = {}; |
| | | std::string strSearchFile = p.filename().stem().string(); |
| | | if (p.extension().string() == _T(".bin")) |
| | | { |
| | | int nTokIndex = 0; |
| | | const char* pGlassId = parser.getTokStr(nTokIndex++); |
| | | const char* pStepId = parser.getTokStr(nTokIndex++); |
| | | char* pDate = &pFileName[parser.getTokPos(nTokIndex++)]; |
| | | char* pTime = &pFileName[parser.getTokPos(nTokIndex++)]; |
| | | |
| | | nDataTime[0] = (pDate[0] - '0') * 1000 + (pDate[1] - '0') * 100 + (pDate[2] - '0') * 10 + (pDate[3] - '0') * 1; |
| | | nDataTime[1] = (pDate[4] - '0') * 10 + (pDate[5] - '0') * 1; |
| | | nDataTime[2] = (pDate[6] - '0') * 10 + (pDate[7] - '0') * 1; |
| | | nDataTime[3] = (pTime[0] - '0') * 10 + (pTime[1] - '0') * 1; |
| | | nDataTime[4] = (pTime[2] - '0') * 10 + (pTime[3] - '0') * 1; |
| | | nDataTime[5] = (pTime[4] - '0') * 10 + (pTime[5] - '0') * 1; |
| | | vtFileList.push_back(p.filename().stem().string()); |
| | | } |
| | | |
| | | CTime tmTemp(nDataTime[0], nDataTime[1], nDataTime[2], nDataTime[3], nDataTime[4], nDataTime[5]); |
| | | CTimeSpan tmSpan = tmReviewLoading - tmTemp; |
| | | mapSpanFileName.insert(std::make_pair(tmSpan.GetTotalSeconds(), pFileName)); |
| | | } |
| | | } |
| | | |
| | | if (mapSpanFileName.empty() == FALSE) |
| | | for (auto iter = vtFileList.begin(); iter != vtFileList.end(); ) |
| | | { |
| | | if (mapSpanFileName.begin()->first < nCloseTime) |
| | | vector<string> vtSplit; |
| | | FuncStringSplit(*iter, _T('_'), vtSplit); |
| | | |
| | | if (vtSplit.size() == SaperatorCount && vtSplit[2].size() == DateSize && vtSplit[3].size() == TimeSize) |
| | | { |
| | | strFindFile = mapSpanFileName.begin()->second; |
| | | break; |
| | | iter++; |
| | | } |
| | | else |
| | | { |
| | | vtFileList.erase(iter); |
| | | } |
| | | } |
| | | |
| | | akFileFinder.clear(); |
| | | sort(vtFileList.begin(), vtFileList.end(), greater<>()); // 최신순으로 정렬 |
| | | |
| | | string strPickFileName = vtFileList.empty() ? _T("NULL") : vtFileList.front(); |
| | | g_pLog->DisplayMessage(_T("[GlassLoading][FindRawBinFile] End File Count = %d, Pick File Name = %s, Tact = %d, ErrorCode = %d, ErrorMsg = %s"), vtFileList.size(), strPickFileName.c_str(), chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now() - timeStart).count(),err.value(), err.message().c_str()); |
| | | |
| | | if (vtFileList.empty() == FALSE) |
| | | { |
| | | vector<string> vtSplit; |
| | | FuncStringSplit(strPickFileName, _T('_'), vtSplit); |
| | | |
| | | CTime tmTemp(stoi(vtSplit[2].substr(0, 4)), stoi(vtSplit[2].substr(4, 2)), stoi(vtSplit[2].substr(6, 2)), stoi(vtSplit[3].substr(0, 2)), stoi(vtSplit[3].substr(2, 2)), stoi(vtSplit[3].substr(4, 2))); |
| | | CTimeSpan tmSpan = tmReviewLoading - tmTemp; |
| | | |
| | | if (tmSpan < nCloseTime) |
| | | break; |
| | | } |
| | | /* < KJG 20230605 - #4517 ADD End >*/ |
| | | |
| | | /* < KJG 20230605 - #4517 DEL Start >*/ |
| | | //#3359_LYW CF AOI Review REVIEW_LOADING_COMPLETE_TIMEOVER END |
| | | //VECFINDDATA* pFindData = akFileFinder.getFindData(); |
| | | //int nFileNamePos = strlen(akFileFinder.getProcessPath()); |
| | | //std::map<LONGLONG, CString> mapSpanFileName; |
| | | //for (int i = 0; i < pFindData->size(); i++) |
| | | //{ |
| | | // char* pFileName = &((*pFindData)[i]).name[nFileNamePos]; |
| | | // { |
| | | // CakParser parser; |
| | | // parser.process(pFileName, "_."); |
| | | // if (parser.getTokNum() < 4) continue; |
| | | // |
| | | // if (parser.getTokNum() >= 6) continue; // 0401 |
| | | // |
| | | // int nDataTime[8] = {}; |
| | | // { |
| | | // int nTokIndex = 0; |
| | | // const char* pGlassId = parser.getTokStr(nTokIndex++); |
| | | // const char* pStepId = parser.getTokStr(nTokIndex++); |
| | | // char* pDate = &pFileName[parser.getTokPos(nTokIndex++)]; |
| | | // char* pTime = &pFileName[parser.getTokPos(nTokIndex++)]; |
| | | // |
| | | // nDataTime[0] = (pDate[0] - '0') * 1000 + (pDate[1] - '0') * 100 + (pDate[2] - '0') * 10 + (pDate[3] - '0') * 1; |
| | | // nDataTime[1] = (pDate[4] - '0') * 10 + (pDate[5] - '0') * 1; |
| | | // nDataTime[2] = (pDate[6] - '0') * 10 + (pDate[7] - '0') * 1; |
| | | // nDataTime[3] = (pTime[0] - '0') * 10 + (pTime[1] - '0') * 1; |
| | | // nDataTime[4] = (pTime[2] - '0') * 10 + (pTime[3] - '0') * 1; |
| | | // nDataTime[5] = (pTime[4] - '0') * 10 + (pTime[5] - '0') * 1; |
| | | // } |
| | | // |
| | | // CTime tmTemp(nDataTime[0], nDataTime[1], nDataTime[2], nDataTime[3], nDataTime[4], nDataTime[5]); |
| | | // CTimeSpan tmSpan = tmReviewLoading - tmTemp; |
| | | // mapSpanFileName.insert(std::make_pair(tmSpan.GetTotalSeconds(), pFileName)); |
| | | // } |
| | | //} |
| | | // |
| | | //if (mapSpanFileName.empty() == FALSE) |
| | | //{ |
| | | // if (mapSpanFileName.begin()->first < nCloseTime) |
| | | // { |
| | | // strFindFile = mapSpanFileName.begin()->second; |
| | | // break; |
| | | // } |
| | | //} |
| | | // |
| | | //akFileFinder.clear(); |
| | | /* < KJG 20230605 - #4517 DEL End >*/ |
| | | |
| | | |
| | | Sleep(100); |
| | | } |
| | | } |
| | |
| | | |
| | | return; |
| | | } |
| | | |
| | | BOOL CSequenceProcessor_CPJT::CheckZeroReviewAlarm() |
| | | { |
| | | CGlassResult* pGlassResult = m_pSP2P->ISP2P_GetCurrentGlassResult(); |
| | | if (pGlassResult == NULL) return FALSE; |
| | | |
| | | int TotalCount = 0; |
| | | |
| | | //Defect |
| | | const VectorReviewResult *pVecReviewResult = pGlassResult->GetVectorReviewResult(); |
| | | if (pVecReviewResult != NULL) |
| | | { |
| | | for (constVectorReviewResultIt it = pVecReviewResult->begin(); it != pVecReviewResult->end(); it++) |
| | | { |
| | | const CReviewResult *pReviewResult = static_cast<const CReviewResult*>(&(*it)); |
| | | |
| | | TotalCount += pReviewResult->m_vecSReviewResult.size(); |
| | | |
| | | for (constVectorSReviewResultIt its = pReviewResult->m_vecSReviewResult.begin(); its != pReviewResult->m_vecSReviewResult.end(); its++) |
| | | { |
| | | if (its->nResultCode > ReviewResult_None) |
| | | { |
| | | return TRUE; |
| | | } |
| | | else |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //DefectWSI |
| | | const VectorReviewResult *pVecWsiResult = pGlassResult->GetVectorWsiResult(); |
| | | if (pVecWsiResult != NULL) |
| | | { |
| | | for (constVectorReviewResultIt it = pVecWsiResult->begin(); it != pVecWsiResult->end(); it++) |
| | | { |
| | | const CReviewResult *pWsiResult = static_cast<const CReviewResult*>(&(*it)); |
| | | |
| | | TotalCount += pWsiResult->m_vecSReviewResult.size(); |
| | | |
| | | for (constVectorSReviewResultIt its = pWsiResult->m_vecSReviewResult.begin(); its != pWsiResult->m_vecSReviewResult.end(); its++) |
| | | { |
| | | if (its->nResultCode > WsiResult_None) |
| | | { |
| | | return TRUE; |
| | | } |
| | | else |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //User Review |
| | | const VectorReviewResult *pVecUserReviewResult = pGlassResult->GetVectorUserResult(); |
| | | if (pVecUserReviewResult != NULL) |
| | | { |
| | | for (constVectorReviewResultIt it = pVecUserReviewResult->begin(); it != pVecUserReviewResult->end(); it++) |
| | | { |
| | | const CReviewResult *pUserReviewResult = static_cast<const CReviewResult*>(&(*it)); |
| | | |
| | | TotalCount += pUserReviewResult->m_vecSReviewResult.size(); |
| | | |
| | | for (constVectorSReviewResultIt its = pUserReviewResult->m_vecSReviewResult.begin(); its != pUserReviewResult->m_vecSReviewResult.end(); its++) |
| | | { |
| | | if (its->nResultCode > ReviewResult_None) |
| | | { |
| | | return TRUE; |
| | | } |
| | | else |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //User WSI |
| | | const VectorReviewResult *pVecUserWsiResult = pGlassResult->GetVectorUserWsiResult(); |
| | | if (pVecUserWsiResult != NULL) |
| | | { |
| | | for (constVectorReviewResultIt it = pVecUserWsiResult->begin(); it != pVecUserWsiResult->end(); it++) |
| | | { |
| | | const CReviewResult *pUserWsiResult = static_cast<const CReviewResult*>(&(*it)); |
| | | |
| | | TotalCount += pUserWsiResult->m_vecSReviewResult.size(); |
| | | |
| | | for (constVectorSReviewResultIt its = pUserWsiResult->m_vecSReviewResult.begin(); its != pUserWsiResult->m_vecSReviewResult.end(); its++) |
| | | { |
| | | if (its->nResultCode > WsiResult_None) |
| | | { |
| | | return TRUE; |
| | | } |
| | | else |
| | | { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (TotalCount == 0) return TRUE; |
| | | |
| | | return FALSE; |
| | | } |
| | | |
| | | void CSequenceProcessor_CPJT::sendUploadResult2SequenceProcessor(int UploadResult) |
| | | { |
| | | int UploadResultFailCount = GetUploadResultFailCount(); |
| | | if (UploadResult == FALSE) |
| | | { |
| | | UploadResultFailCount++; |
| | | m_pSP2P->ISP2P_DisplayMessage(_T("Upload Ack is False")); |
| | | if (UploadResultFailCount >= 3) |
| | | { |
| | | //SendSignalToSignalControl(PCControlSendSignalIndex_State, PCControlSend_ResultData_Upload_Fail, 1000); |
| | | m_nStackUploadFailGlassCount++; |
| | | m_pSP2P->ISP2P_DisplayMessage(_T("ResultFile Upload Fail Glass Count = %d"),m_nStackUploadFailGlassCount); |
| | | if (m_nStackUploadFailGlassCount >= m_pSP2P->ISP2P_System_GetNetworkInfo()->m_nResultFileUploadFailAlarmCondition) |
| | | { |
| | | SendSignalToSignalControl(PCControlSendSignalIndex_State, PCControlSend_ResultData_Upload_Fail, 1000); |
| | | m_nStackUploadFailGlassCount = 0; |
| | | m_pSP2P->ISP2P_DisplayMessage(_T("ResultFile Upload Fail Alarm!")); |
| | | } |
| | | SetUploadResultFailCount(-1); |
| | | } |
| | | else |
| | | { |
| | | SetUploadResultFailCount(UploadResultFailCount); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | m_pSP2P->ISP2P_DisplayMessage(_T("Upload Ack is True")); |
| | | m_nStackUploadFailGlassCount = 0; |
| | | } |
| | | } |
| | | |
| | | //#3358 KYH FDC ADD END |
| | | |
| | | DWORD CSequenceProcessor_CPJT::GetDiskUsage() |