| | |
| | | |
| | | #define AOIRAWBIN_PATH "\\\\126.100.100.1\\d\\DIT_ResultData\\RawBin" |
| | | #define AOIRAWBIN_TEST_PATH "d:\\DIT_ResultData\\RawBin" |
| | | #define AOIRAWBIN_LOCAL_PATH "D:\\DIT_ResultData\\RawBin" |
| | | #define AOIRAWBIN_NETWORK_DRIVE_PATH "Y:\\RawBin" |
| | | |
| | | enum CPJT_MeasureMode { CPJT_ModeAuto = 0, CPJT_ModeManual }; |
| | |
| | | // if (SendSignalToSignalControl(PCControlSendSignalIndex_Ack, PCControlSend_ReviewUnloadingAck_CPJT)) |
| | | // m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewStart] Send Review Unloading Ack!")); |
| | | |
| | | /* < KEJ 20240621 - #4942 ADD Start > */ |
| | | STransferData* pTransferData = m_pSP2P->ISP2P_GetCurrentTransferData(); |
| | | CString strGlassStepIdTemp = pTransferData->strStepID; |
| | | CString strGlassIDTemp = pTransferData->strGlassID; |
| | | |
| | | CString strFileName; |
| | | strFileName.Format(_T("%s\\%s_%s.bin"), AOIRAWBIN_LOCAL_PATH, strGlassIDTemp, strGlassStepIdTemp); |
| | | |
| | | CFile file; |
| | | if (file.Open(strFileName, CFile::modeRead)) |
| | | { |
| | | file.Close(); |
| | | DeleteFile(strFileName); |
| | | g_pLog->DisplayMessage(_T("[SequenceProcessor] Delete RAW BIN File [%s]"), strFileName); |
| | | } |
| | | file.Close(); |
| | | /* < KEJ 20240621 - #4942 ADD End > */ |
| | | |
| | | m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::IN] FileMonitor Thread Start Ready")); |
| | | m_pSP2P->ISP2P_GetReviewProcessor()->FileMonitorThreadStart(); /* < KJG 20230630 - #4517 ADD Start >*/ |
| | | m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::IN] FileMonitor Thread Start Complete")); |
| | |
| | | |
| | | 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; |
| | | //strcpy(pData->GetGlassData()->m_strPath, AOIRAWBIN_PATH); |
| | | //strcpy(pData->GetGlassData()->m_strPath, LOCAL_AOIRAWBIN_PATH); |
| | | |
| | | strFilePath = AOIRAWBIN_PATH; |
| | | |
| | | CString strFindFile; |
| | | int nCloseTime = 600 * 100000;//sec |
| | | int nReTryTime = 30; |
| | | { |
| | | CTime tmReviewLoading = CTime::GetCurrentTime(); |
| | | CString strWild; |
| | | //strWild.Format("%s\\%s_*.bin", strFilePath, strFileName); |
| | | CakFileUtil akFileFinder; |
| | | while (nReTryTime--) |
| | | { |
| | | //#3359_LYW CF AOI Review REVIEW_LOADING_COMPLETE_TIMEOVER START |
| | | if (nReTryTime%2 == 0) |
| | | { |
| | | strFilePath = AOIRAWBIN_NETWORK_DRIVE_PATH; |
| | | } |
| | | else strFilePath = AOIRAWBIN_PATH; |
| | | |
| | | //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++) |
| | | { |
| | | fs::path p = iter->path(); |
| | | if (p.filename().stem().string().find(strFileName) != string::npos) |
| | | { |
| | | std::string strSearchFile = p.filename().stem().string(); |
| | | if (p.extension().string() == _T(".bin")) |
| | | { |
| | | vtFileList.push_back(p.filename().stem().string()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (auto iter = vtFileList.begin(); iter != vtFileList.end(); ) |
| | | { |
| | | vector<string> vtSplit; |
| | | FuncStringSplit(*iter, _T('_'), vtSplit); |
| | | |
| | | if (vtSplit.size() == SaperatorCount && vtSplit[2].size() == DateSize && vtSplit[3].size() == TimeSize) |
| | | { |
| | | iter++; |
| | | } |
| | | else |
| | | { |
| | | vtFileList.erase(iter); |
| | | } |
| | | } |
| | | |
| | | 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) |
| | | { |
| | | strFindFile = strPickFileName.c_str(); |
| | | g_pLog->DisplayMessage(_T("[GlassLoading][FindRawBinFile] Find File Success")); |
| | | 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++) |
| | | /* < KEJ 20240621 - #4942 MOD Start > */ |
| | | // /* < KJG 20230605 - #4517 ADD Start >*/ |
| | | // auto FuncStringSplit = [](string Sentence, char Separator, vector<string>& vec) |
| | | //{ |
| | | // char* pFileName = &((*pFindData)[i]).name[nFileNamePos]; |
| | | // 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; |
| | | // //strcpy(pData->GetGlassData()->m_strPath, AOIRAWBIN_PATH); |
| | | // //strcpy(pData->GetGlassData()->m_strPath, LOCAL_AOIRAWBIN_PATH); |
| | | // |
| | | // strFilePath = AOIRAWBIN_PATH; |
| | | // |
| | | // CString strFindFile; |
| | | // int nCloseTime = 600 * 100000;//sec |
| | | // int nReTryTime = 30; |
| | | // { |
| | | // CakParser parser; |
| | | // parser.process(pFileName, "_."); |
| | | // if (parser.getTokNum() < 4) continue; |
| | | // |
| | | // if (parser.getTokNum() >= 6) continue; // 0401 |
| | | // |
| | | // int nDataTime[8] = {}; |
| | | // CTime tmReviewLoading = CTime::GetCurrentTime(); |
| | | // CString strWild; |
| | | // //strWild.Format("%s\\%s_*.bin", strFilePath, strFileName); |
| | | // CakFileUtil akFileFinder; |
| | | // while (nReTryTime--) |
| | | // { |
| | | // 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++)]; |
| | | // //#3359_LYW CF AOI Review REVIEW_LOADING_COMPLETE_TIMEOVER START |
| | | // if (nReTryTime%2 == 0) |
| | | // { |
| | | // strFilePath = AOIRAWBIN_NETWORK_DRIVE_PATH; |
| | | // } |
| | | // else strFilePath = AOIRAWBIN_PATH; |
| | | // |
| | | // 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; |
| | | // //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++) |
| | | // { |
| | | // fs::path p = iter->path(); |
| | | // if (p.filename().stem().string().find(strFileName) != string::npos) |
| | | // { |
| | | // std::string strSearchFile = p.filename().stem().string(); |
| | | // if (p.extension().string() == _T(".bin")) |
| | | // { |
| | | // vtFileList.push_back(p.filename().stem().string()); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // CTime tmTemp(nDataTime[0], nDataTime[1], nDataTime[2], nDataTime[3], nDataTime[4], nDataTime[5]); |
| | | // for (auto iter = vtFileList.begin(); iter != vtFileList.end(); ) |
| | | // { |
| | | // vector<string> vtSplit; |
| | | // FuncStringSplit(*iter, _T('_'), vtSplit); |
| | | // |
| | | // if (vtSplit.size() == SaperatorCount && vtSplit[2].size() == DateSize && vtSplit[3].size() == TimeSize) |
| | | // { |
| | | // iter++; |
| | | // } |
| | | // else |
| | | // { |
| | | // vtFileList.erase(iter); |
| | | // } |
| | | // } |
| | | // |
| | | // 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; |
| | | // mapSpanFileName.insert(std::make_pair(tmSpan.GetTotalSeconds(), pFileName)); |
| | | // } |
| | | //} |
| | | // |
| | | //if (mapSpanFileName.empty() == FALSE) |
| | | // if (tmSpan < nCloseTime) |
| | | //{ |
| | | // if (mapSpanFileName.begin()->first < nCloseTime) |
| | | // { |
| | | // strFindFile = mapSpanFileName.begin()->second; |
| | | // strFindFile = strPickFileName.c_str(); |
| | | // g_pLog->DisplayMessage(_T("[GlassLoading][FindRawBinFile] Find File Success")); |
| | | // break; |
| | | // } |
| | | //} |
| | | // /* < KJG 20230605 - #4517 ADD End >*/ |
| | | // |
| | | //akFileFinder.clear(); |
| | | /* < KJG 20230605 - #4517 DEL 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); |
| | | // } |
| | | // } |
| | | // if (strFindFile.IsEmpty()) return FALSE; |
| | | |
| | | CString strFilePath = _T(""); |
| | | |
| | | Sleep(100); |
| | | strFilePath = AOIRAWBIN_LOCAL_PATH; |
| | | CString strFindFile; |
| | | strFindFile.Format(_T("%s\\%s.bin"), strFilePath, strFileName); |
| | | |
| | | CFile file; |
| | | if (!file.Open(strFindFile, CFile::modeRead)) |
| | | { |
| | | g_pLog->DisplayMessage(_T("[GlassLoading][FindRawBinFile] Bin File Is Not Collect [%s]"), strFindFile); |
| | | return FALSE; |
| | | } |
| | | } |
| | | file.Close(); |
| | | |
| | | if (strFindFile.IsEmpty()) return FALSE; |
| | | /* < KEJ 20240621 - #4942 MOD End > */ |
| | | |
| | | return TRUE; |
| | | } |