From 0c66940a8e2cf64c9890519901f433b3668216b6 Mon Sep 17 00:00:00 2001
From: KEJ <kimeungju@diteam.co.kr>
Date: 수, 26 6월 2024 15:13:18 +0900
Subject: [PATCH] Ongoing80 #4942 CF AOI Review Bin File Loading 실패 개선  1. GlassRawMessenger 동기화  2. BIN파일 FindFile 제거(RawMessenger, Review 공통)  3. Unloading 시 BIN파일 제거

---
 ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp |  513 +++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 413 insertions(+), 100 deletions(-)

diff --git a/ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp b/ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp
index d9e48c2..ee28e1c 100644
--- a/ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp
+++ b/ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp
@@ -40,6 +40,11 @@
 #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")
@@ -48,6 +53,7 @@
 
 #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 };
@@ -62,7 +68,8 @@
 enum CPJT_GANTRY_TYPE { GantryType_Left, GantryType_Right };
 
 enum Judgement_CPJT {
-	Judge_OK_CPJT = 0, Judge_RP_CPJT, Judge_NG_CPJT, Judge_TR_CPJT, Judge_PR_CPJT, Judge_PT_CPJT, Judge_Review_CPJT, Judge_RC_CPJT, Judge_Size_CPJT, Judge_VI_CPJT, Judge_Rework_CPJT, Judge_Unknown_CPJT
+//	Judge_OK_CPJT = 0, Judge_RP_CPJT, Judge_NG_CPJT, Judge_TR_CPJT, Judge_PR_CPJT, Judge_PT_CPJT, Judge_Review_CPJT, Judge_RC_CPJT, Judge_Size_CPJT, Judge_VI_CPJT, Judge_Rework_CPJT, Judge_Unknown_CPJT
+	Judge_OK_CPJT = 0, Judge_RP_CPJT, Judge_NG_CPJT, Judge_TR_CPJT, Judge_PR_CPJT, Judge_ND_CPJT, Judge_PT_CPJT, Judge_Review_CPJT, Judge_RC_CPJT, Judge_Size_CPJT, Judge_VI_CPJT, Judge_Rework_CPJT, Judge_LN_CPJT, Judge_Unknown_CPJT, Judge_SR_CPJT		////< KEJ 20231123 - #4669 MOD >
 };
 enum JudgeCode_CPJT {
 	TRDF_CPJT = 0, BATR_CPJT, DOBB_CPJT, DOBS_CPJT, DOWW_CPJT, DOWB_CPJT, DOWS_CPJT
@@ -550,10 +557,16 @@
 		m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::AlignStart] Send Align Fail Data!"));
 	}
 
-	AlignCamera_CameraControl(CameraControlStop);  // 210805 Align Camera Sequence 蹂�寃�
-
+	/*< SWK 20221226 - #4403 MOD Start >*/
+// 	AlignCamera_CameraControl(CameraControlStop);  // 210805 Align Camera Sequence 蹂�寃�
+// 
+// 	SendSignalToSignalControl(PCControlSendSignalIndex_Seq, PCControlSend_AlignComplete_CPJT);
+// 	m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::AlignStart] Send Align Complete Signal!"));
 	SendSignalToSignalControl(PCControlSendSignalIndex_Seq, PCControlSend_AlignComplete_CPJT);
 	m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::AlignStart] Send Align Complete Signal!"));
+
+	AlignCamera_CameraControl(CameraControlStop);
+	/*< SWK 20221226 - #4403 MOD End >*/
 
 	// LJY-20180905
 	m_pSP2P->ISP2P_UpdateAlignResultStatus(0, pGlassResult);
@@ -949,6 +962,10 @@
 	//SetUploadResultFailCount(0);
 
 	bFileFind = FALSE;
+	
+	m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::GlassLoading] FileMonitor Thread Stop Ready"));
+	m_pSP2P->ISP2P_GetReviewProcessor()->FileMonitorThreadStop(); /* < KJG 20230630 - #4517 ADD Start >*/
+	m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::GlassLoading] FileMonitor Thread Stop Complete"));
 
 	/*< LYW 20211109 - #3662 Delete Start >*/
 	//m_pSP2P->ISP2P_GetDiagnosisHistory();
@@ -1101,7 +1118,8 @@
 			/*bFileFind = FindRawBinFile(strFileName);*/
 
 			pDitRawClient->SetReviewStart();
-			Sleep(1000);
+			//< SWK 20221226 - #4403 DEL >
+//			Sleep(1000);
 
  			m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::Loading] Transfer Data Read Success!"));
  
@@ -1318,7 +1336,8 @@
 	}
 	//#3561 210908 LYW ADD End
 
-	Sleep(300);
+	//< SWK 20221226 - #4403 MOD >
+	Sleep(100);
 
 	//original
 // 	if (SendSignalToSignalControl(PCControlSendSignalIndex_Ack, PCControlSend_AlignStartAck_CPJT))
@@ -1440,7 +1459,9 @@
 	
 	//pDitRawClient->SetReviewStart();
 
-	Sleep(500);
+	//< SWK 20221226 - #4403 DEL >
+//	Sleep(500);
+
 	//CString strJudgeData;
 	m_pSP2P->ISP2P_GetSignalControl()->WriteData(_T("17110"), sizeof(pDitRawClient->GetGlassData()->m_strGlassJudge), pDitRawClient->GetGlassData()->m_strGlassJudge);
 	m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::IN] ReadRawFile!"));
@@ -1501,7 +1522,8 @@
 		int nTotalPlanCount = CalculatePlanData(pGlassResult);
 		m_pSP2P->ISP2P_DisplayMessage(_T("[Read Raw File] Review All Plan Total Count : %d"), nTotalPlanCount);
 
-		Sleep(1000);
+		//< SWK 20221226 - #4403 DEL >
+//		Sleep(1000);
 		// send review ready
 		//#3584 210817 LYW CF AOI Review �떆裕щ젅�씠�뀡 湲곕뒫 �젙�긽�솕 MOD START
 		if (GetSimulationMode() == FALSE)
@@ -1877,7 +1899,28 @@
 	//#3584 210817 LYW CF AOI Review �떆裕щ젅�씠�뀡 湲곕뒫 �젙�긽�솕 MOD END
 // 	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"));
 }
 
 
@@ -2346,7 +2389,7 @@
 	int nCount = pRcpReviewInfo->GetRcpJudgeCellDefectCount();
 	int nOK;
 
-	int nCellTRJudge = 0, nCelllOKJuge = 0, nCelllPRJuge = 0;
+	int nCellTRJudge = 0, nCelllOKJuge = 0, nCelllPRJuge = 0, nCelllPTJuge = 0;
 	m_pSP2P->ISP2P_DisplayMessage(_T("[ReviewEnd] Start Cell Defect Rejudge"));
 	for (int nCellIndex = 0; nCellIndex < nCellCount; nCellIndex++)
 	{
@@ -2363,6 +2406,12 @@
 		{
 			nCelllPRJuge = nCelllPRJuge + 1;
 		}
+		/* < KEJ 20231123 - #4669 ADD Start > */
+		else if (pRawData->GetCellData(nCellIndex)->m_nJudgement == Judge_PT_CPJT)
+		{
+			nCelllPTJuge = nCelllPTJuge + 1;
+		}
+		/* < KEJ 20231123 - #4669 ADD End > */
 
 		BOOL bReJudge = FALSE, bSubReJudge = FALSE;
 
@@ -2416,6 +2465,19 @@
 					m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]ELSE Cell DefectPRCount[%d] [%d]"), nCellIndex, pRawData->GetCellData(nCellIndex)->m_nDefectNumJudgePR, pRcpJudgeInfo->GetJudgeCount());
 				}
 				break;
+				/* < KEJ 20231123 - #4669 ADD Start > */
+			case JudgeType_T8_PT:
+				if (pRawData->GetCellData(nCellIndex)->m_nDefectNumJudgePT >= pRcpJudgeInfo->GetJudgeCount())
+				{
+					m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell DefectPTCount[%d] >= [%d]"), nCellIndex, pRawData->GetCellData(nCellIndex)->m_nDefectNumJudgePT, pRcpJudgeInfo->GetJudgeCount());
+					bReJudge = TRUE;
+				}
+				else
+				{
+					m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]ELSE Cell DefectPTCount[%d] [%d]"), nCellIndex, pRawData->GetCellData(nCellIndex)->m_nDefectNumJudgePT, pRcpJudgeInfo->GetJudgeCount());
+				}
+				break;
+				/* < KEJ 20231123 - #4669 ADD End > */
 			}
 
 			// 2nd condition
@@ -2466,6 +2528,19 @@
 					m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]ELSE Cell DefectPRCount[%d] [%d]"), nCellIndex, pRawData->GetCellData(nCellIndex)->m_nDefectNumJudgePR, pRcpJudgeInfo->GetSubJudgeCount());
 				}
 				break;
+				/* < KEJ 20231123 - #4669 ADD Start > */
+			case JudgeType_T8_PT:
+				if (pRawData->GetCellData(nCellIndex)->m_nDefectNumJudgePT <= pRcpJudgeInfo->GetSubJudgeCount())
+				{
+					m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell DefectPTCount[%d] <= [%d]"), nCellIndex, pRawData->GetCellData(nCellIndex)->m_nDefectNumJudgePT, pRcpJudgeInfo->GetSubJudgeCount());
+					bSubReJudge = TRUE;
+				}
+				else
+				{
+					m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]ELSE Cell DefectPTCount[%d] [%d]"), nCellIndex, pRawData->GetCellData(nCellIndex)->m_nDefectNumJudgePT, pRcpJudgeInfo->GetSubJudgeCount());
+				}
+				break;
+				/* < KEJ 20231123 - #4669 ADD End > */
 			}
 
 			if (bReJudge & bSubReJudge)
@@ -2488,7 +2563,7 @@
 						{
 							nCelllOKJuge = 0;
 						}
-						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d]")
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d] PT[%d]")
 							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge,nCelllPRJuge);
 					}
 					else if (pRawData->GetCellData(nCellIndex)->m_nJudgement==Judge_PR_CPJT)
@@ -2506,15 +2581,35 @@
 						{
 							nCelllPRJuge = 0;
 						}
-						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d]")
-							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge);
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d] PT[%d]")
+							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge, nCelllPTJuge);
 					}
+					/* < KEJ 20231123 - #4669 ADD Start > */
+					else if (pRawData->GetCellData(nCellIndex)->m_nJudgement == Judge_PT_CPJT)
+					{
+						int nbfJudge = pRawData->GetCellData(nCellIndex)->m_nJudgement;
+						pRawData->GetCellData(nCellIndex)->m_nJudgement = Judge_TR_CPJT;
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition : ReJudge Cell Defect Grade! [%d]->[%s]")
+							, nCellIndex, nIdx, nbfJudge, pRcpJudgeInfo->GetReJudgeCode());
+
+
+						nCelllPTJuge -= 1;
+						nCellTRJudge += 1;
+
+						if (nCelllPTJuge < 0)
+						{
+							nCelllPTJuge = 0;
+						}
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d] PT[%d]")
+							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge, nCelllPTJuge);
+					}
+					/* < KEJ 20231123 - #4669 ADD End > */
 					else
 					{
 
 						m_pSP2P->ISP2P_DisplayMessage(_T("[TEST Process::ReviewEnd][%02d]Cell [%02d] ReJudge  Cell Defect Grade! [%s]->[%s]"), nCellIndex, nIdx,_T("TR"), _T("TR"));
-						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d]")
-							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge);
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d] PT[%d]")
+							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge, nCelllPTJuge);
 					}
 				}
 				else if (pRcpJudgeInfo->GetReJudgeType() == JudgeType_T8_PR)
@@ -2534,8 +2629,8 @@
 						{
 							nCelllOKJuge = 0;
 						}
-						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d]")
-							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge);
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d] PT[%d]")
+							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge, nCelllPTJuge);
 					}
 					if (pRawData->GetCellData(nCellIndex)->m_nJudgement == Judge_TR_CPJT)
 					{
@@ -2552,24 +2647,110 @@
 						{
 							nCellTRJudge = 0;
 						}
-						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d]")
-							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge);
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d] PT[%d]")
+							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge, nCelllPTJuge);
 					}
+					/* < KEJ 20231123 - #4669 ADD Start > */
+					if (pRawData->GetCellData(nCellIndex)->m_nJudgement == Judge_PT_CPJT)
+					{
+						int nbfJudge = pRawData->GetCellData(nCellIndex)->m_nJudgement;
+						pRawData->GetCellData(nCellIndex)->m_nJudgement = Judge_PR_CPJT;
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition : ReJudge Cell Defect Grade! [%d]->[%s]")
+							, nCellIndex, nIdx, nbfJudge, pRcpJudgeInfo->GetReJudgeCode());
+
+
+						nCelllPTJuge -= 1;
+						nCelllPRJuge += 1;
+
+						if (nCelllPTJuge < 0)
+						{
+							nCelllPTJuge = 0;
+						}
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d] PT[%d]")
+							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge, nCelllPTJuge);
+					}
+					/* < KEJ 20231123 - #4669 ADD End > */
 					else
 					{
 
 						m_pSP2P->ISP2P_DisplayMessage(_T("[TEST Process::ReviewEnd][%02d]Cell [%02d] ReJudge  Cell Defect Grade! [%s]->[%s]"), nCellIndex, nIdx, _T("PR"), _T("PR"));
-						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d]")
-							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge);
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d] PT[%d]")
+							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge, nCelllPTJuge);
 					}
 				}
+				/* < KEJ 20231123 - #4669 ADD Start > */
+				else if (pRcpJudgeInfo->GetReJudgeType() == JudgeType_T8_PT)
+				{
+					if (pRawData->GetCellData(nCellIndex)->m_nJudgement == Judge_OK_CPJT)
+					{
+						int nbfJudge = pRawData->GetCellData(nCellIndex)->m_nJudgement;
+						pRawData->GetCellData(nCellIndex)->m_nJudgement = Judge_PT_CPJT;
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition : ReJudge Cell Defect Grade! [%d]->[%s]")
+							, nCellIndex, nIdx, nbfJudge, pRcpJudgeInfo->GetReJudgeCode());
+
+
+						nCelllOKJuge -= 1;
+						nCelllPTJuge += 1;
+
+						if (nCelllOKJuge < 0)
+						{
+							nCelllOKJuge = 0;
+						}
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d] PT[%d]")
+							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge, nCelllPTJuge);
+					}
+					if (pRawData->GetCellData(nCellIndex)->m_nJudgement == Judge_TR_CPJT)
+					{
+						int nbfJudge = pRawData->GetCellData(nCellIndex)->m_nJudgement;
+						pRawData->GetCellData(nCellIndex)->m_nJudgement = Judge_PT_CPJT;
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition : ReJudge Cell Defect Grade! [%d]->[%s]")
+							, nCellIndex, nIdx, nbfJudge, pRcpJudgeInfo->GetReJudgeCode());
+
+
+						nCellTRJudge -= 1;
+						nCelllPTJuge += 1;
+
+						if (nCellTRJudge < 0)
+						{
+							nCellTRJudge = 0;
+						}
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d] PT[%d]")
+							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge, nCelllPTJuge);
+					}
+					if (pRawData->GetCellData(nCellIndex)->m_nJudgement == Judge_PR_CPJT)
+					{
+						int nbfJudge = pRawData->GetCellData(nCellIndex)->m_nJudgement;
+						pRawData->GetCellData(nCellIndex)->m_nJudgement = Judge_PT_CPJT;
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition : ReJudge Cell Defect Grade! [%d]->[%s]")
+							, nCellIndex, nIdx, nbfJudge, pRcpJudgeInfo->GetReJudgeCode());
+
+
+						nCelllPRJuge -= 1;
+						nCelllPTJuge += 1;
+
+						if (nCelllPRJuge < 0)
+						{
+							nCelllPRJuge = 0;
+						}
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d] PT[%d]")
+							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge, nCelllPTJuge);
+					}
+					else
+					{
+
+						m_pSP2P->ISP2P_DisplayMessage(_T("[TEST Process::ReviewEnd][%02d]Cell [%02d] ReJudge  Cell Defect Grade! [%s]->[%s]"), nCellIndex, nIdx, _T("PT"), _T("PT"));
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d] PT[%d]")
+							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge, nCelllPTJuge);
+					}
+				}
+				/* < KEJ 20231123 - #4669 ADD End > */
 				else//OK
 				{
 					if (pRawData->GetCellData(nCellIndex)->m_nJudgement == Judge_OK_CPJT || pRawData->GetCellData(nCellIndex)->m_nJudgement == Judge_Unknown_CPJT)
 					{
 						m_pSP2P->ISP2P_DisplayMessage(_T("[TEST Process::ReviewEnd][%02d]Cell [%02d] ReJudge  Cell Defect Grade! [%s]->[%s]"), nCellIndex, nIdx,_T("OK"), _T("OK"));
-						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d]")
-							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge);
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d] PT[%d]")
+							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge, nCelllPTJuge);
 					}
 					else
 					{
@@ -2598,8 +2779,20 @@
 								nCelllPRJuge = 0;
 							}
 						}
-						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d]")
-							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge);
+						/* < KEJ 20231123 - #4669 ADD Start > */
+						else if (pRawData->GetCellData(nCellIndex)->m_nJudgement == Judge_PT_CPJT)
+						{
+							nCelllOKJuge += 1;
+							nCelllPTJuge -= 1;
+
+							if (nCelllPTJuge < 0)
+							{
+								nCelllPTJuge = 0;
+							}
+						}
+						/* < KEJ 20231123 - #4669 ADD End > */
+						m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]Cell [%02d]Condition CELL COUNT OK:[%d] TR[%d] PR[%d] PT[%d]")
+							, nCellIndex, nIdx, nCelllOKJuge, nCellTRJudge, nCelllPRJuge, nCelllPTJuge);
 	
 					}
 				}
@@ -2678,6 +2871,19 @@
 					m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]ELSE GLASS Defect PR Count[%d] [%d]"), nIdx, pRawData->GetGlassData()->m_nDefectNumJudgePR, pRcpJudgeInfo->GetJudgeCount());
 				}
 			break;
+			/* < KEJ 20231123 - #4669 ADD Start > */
+		case JudgeType_T8_PT:
+			if (pRawData->GetGlassData()->m_nDefectNumJudgePT >= pRcpJudgeInfo->GetJudgeCount())
+			{
+				m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]GLASS Defect PT Count[%d] >= [%d]"), nIdx, pRawData->GetGlassData()->m_nDefectNumJudgePT, pRcpJudgeInfo->GetJudgeCount());
+				bReJudge = TRUE;
+			}
+			else
+			{
+				m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]ELSE GLASS Defect PT Count[%d] [%d]"), nIdx, pRawData->GetGlassData()->m_nDefectNumJudgePT, pRcpJudgeInfo->GetJudgeCount());
+			}
+			break;
+			/* < KEJ 20231123 - #4669 ADD End > */
 			
 		}
 
@@ -2727,6 +2933,18 @@
 				m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]ELSE GLASS Defect PR Count[%d] [%d]"), nIdx, pRawData->GetGlassData()->m_nDefectNumJudgePR, pRcpJudgeInfo->GetSubJudgeCount());
 			}
 			break;
+			/* < KEJ 20231123 - #4669 ADD Start > */
+		case JudgeType_T8_PT:
+			if (pRawData->GetGlassData()->m_nDefectNumJudgePT <= pRcpJudgeInfo->GetSubJudgeCount())
+			{
+				bSubReJudge = TRUE;
+				m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]GLASS Defect PT Count[%d] <= [%d]"), nIdx, pRawData->GetGlassData()->m_nDefectNumJudgePT, pRcpJudgeInfo->GetSubJudgeCount());
+			}
+			else {
+				m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] [%02d]ELSE GLASS Defect PT Count[%d] [%d]"), nIdx, pRawData->GetGlassData()->m_nDefectNumJudgePT, pRcpJudgeInfo->GetSubJudgeCount());
+			}
+			break;
+			/* < KEJ 20231123 - #4669 ADD End > */
 		
 		}
 
@@ -2884,86 +3102,175 @@
 
 BOOL CSequenceProcessor_CPJT::FindRawBinFile(CString strFileName)
 {
-	//210128
-	CString strFilePath = _T("");
-	//pData->GetGlassData()->m_strFileName;
-	//strcpy(pData->GetGlassData()->m_strPath, AOIRAWBIN_PATH);
-	//strcpy(pData->GetGlassData()->m_strPath, LOCAL_AOIRAWBIN_PATH);
+	/* < KEJ 20240621 - #4942 MOD Start > */
+// 	/* < 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++)
+// 			//{
+// 			//	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;
 
-	strFilePath = AOIRAWBIN_PATH;
-
+ 	CString strFilePath = _T("");
+ 
+ 	strFilePath = AOIRAWBIN_LOCAL_PATH;
 	CString strFindFile;
-	int nCloseTime = 600 * 100000;//sec
-	int nReTryTime = 30;
+	strFindFile.Format(_T("%s\\%s.bin"), strFilePath, strFileName);
+
+	CFile file;
+	if (!file.Open(strFindFile, CFile::modeRead))
 	{
-		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_PATH;
-			}
-			else strFilePath = AOIRAWBIN_NETWORK_DRIVE_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++)
-			{
-				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();
-			Sleep(100);
-		}
+		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;
 }
@@ -3674,7 +3981,9 @@
 			tmServerLoadingTime = CTime::GetCurrentTime();
 			m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::GlassLoading] access Shared Memory Fail"));
 			strPath.Format(_T("%s\\%s_%04d%02d%02d%02d%02d%02d"), pNetworkInfo->m_strUploadImagePath, strGlassID, tmServerLoadingTime.GetYear(), tmServerLoadingTime.GetMonth(), tmServerLoadingTime.GetDay(), tmServerLoadingTime.GetHour(), tmServerLoadingTime.GetMinute(), tmServerLoadingTime.GetSecond());
-			strImagePath.Format(_T("%s\\%s_%04d%02d%02d%02d%02d%02d"), strGlassID, tmServerLoadingTime.GetYear(), tmServerLoadingTime.GetMonth(), tmServerLoadingTime.GetDay(), tmServerLoadingTime.GetHour(), tmServerLoadingTime.GetMinute(), tmServerLoadingTime.GetSecond());
+			//< SWK 20221226 - #4403 MOD >
+//			strImagePath.Format(_T("%s\\%s_%04d%02d%02d%02d%02d%02d"), strGlassID, tmServerLoadingTime.GetYear(), tmServerLoadingTime.GetMonth(), tmServerLoadingTime.GetDay(), tmServerLoadingTime.GetHour(), tmServerLoadingTime.GetMinute(), tmServerLoadingTime.GetSecond());
+			strImagePath.Format(_T("%s_%04d%02d%02d%02d%02d%02d"), strGlassID, tmServerLoadingTime.GetYear(), tmServerLoadingTime.GetMonth(), tmServerLoadingTime.GetDay(), tmServerLoadingTime.GetHour(), tmServerLoadingTime.GetMinute(), tmServerLoadingTime.GetSecond());
 			CreateDirectory(strPath, NULL);
 			pReviewProcessor->SetUploadImagePath(strPath);
 			pReviewProcessor->SetReviewImagePath(strImagePath);
@@ -4363,6 +4672,7 @@
 			// set offset
 			ApplyMotorOffset(pReview->nModuleIdx, pReview->nZoomIdx, MotorOffsetCamera + MotorOffsetMag+MotorOffset_Glass, dDefectPosX, dDefectPosY);
 		
+			m_pSP2P->CalcMotorOffSetValue(pReview->nModuleIdx, dDefectPosX, dDefectPosY);		//< KEJ 20230622 - #4526 ADD >
 			//xpostemp = dDefectPosX;
 			//ypostemp = dDefectPosY;
 
@@ -4663,6 +4973,7 @@
 			// set offset
 			ApplyMotorOffset(pReview->nModuleIdx, pReview->nZoomIdx, MotorOffsetCamera + MotorOffsetMag + MotorOffset_Glass, dDefectPosX, dDefectPosY);
 
+			m_pSP2P->CalcMotorOffSetValue(pReview->nModuleIdx, dDefectPosX, dDefectPosY);		//< KEJ 20230622 - #4526 ADD >
 			//xpostemp = dDefectPosX;
 			//ypostemp = dDefectPosY;
 
@@ -4920,6 +5231,8 @@
 			// set offset
 			ApplyMotorOffset(pWsi->nModuleIdx, -1, MotorOffsetCamera + MotorOffsetWSI + MotorOffset_Glass, dDefectPosX, dDefectPosY);
 
+			m_pSP2P->CalcMotorOffSetValue(pWsi->nModuleIdx, dDefectPosX, dDefectPosY);		//< KEJ 20230622 - #4526 ADD >
+
 			m_pSP2P->GetOffSetValue(nModuleIdx, pWsi->nAOICameraIdx, pWsi->nAOIScanIdx, pWsi->nUMOriginX / 1000.0, xpostemp, ypostemp);
 
 			xpostemp = floor(xpostemp * 1000);

--
Gitblit v1.9.3