From b4a18bfef6cb9f5d48a12b455dfa78f9ef67e348 Mon Sep 17 00:00:00 2001
From: kojingeun <diteam.co.kr>
Date: 수, 07 6월 2023 10:29:07 +0900
Subject: [PATCH] Revert "Ongoing50 #4517 CF AOI Review 결과 파일 찾기 실패 개선"

---
 ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp |  194 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 185 insertions(+), 9 deletions(-)

diff --git a/ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp b/ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp
index 9cbdfb2..4885de2 100644
--- a/ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp
+++ b/ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp
@@ -166,6 +166,9 @@
 {
 	m_bUseAFMHomePosition = TRUE;
 	m_nGlassCount = 0;
+	m_nStackZeroReviewCondition = 0;
+	m_nUploadResultFailCount = 0;
+	m_nStackUploadFailGlassCount = 0;
 	CDitGlassRawClient* pDitGlassRaw = CDitGlassRawClient::GetInstance();
 	if(pDitGlassRaw->ConnectServer() == FALSE)
 	{
@@ -547,10 +550,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);
@@ -943,6 +952,7 @@
 	SetLastPointCheck(FALSE);
 
 	SetReviewComplete(FALSE);
+	//SetUploadResultFailCount(0);
 
 	bFileFind = FALSE;
 
@@ -1066,7 +1076,6 @@
 			// #3381 LYW CF AOI Review FDC TackTime ADD START
 			pDitRawClient->GetGlassData()->m_tmReviewLoading = CTime::GetCurrentTime();
 			// #3381 LYW CF AOI Review FDC TackTime ADD END
-			
 
 			CString strGlassIDTemp = NULL;
 			CString strGlassStepIdTemp = NULL;
@@ -1074,7 +1083,6 @@
 
 			strGlassIDTemp = pTransferData->strGlassID;
 			strGlassStepIdTemp = pTransferData->strStepID;
-			
 
 			strGlassIDTemp = pTransferData->strGlassID;
 			strcpy(pDitRawClient->GetGlassData()->m_strGlassID, strGlassIDTemp);
@@ -1099,7 +1107,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!"));
  
@@ -1316,7 +1325,8 @@
 	}
 	//#3561 210908 LYW ADD End
 
-	Sleep(300);
+	//< SWK 20221226 - #4403 MOD >
+	Sleep(100);
 
 	//original
 // 	if (SendSignalToSignalControl(PCControlSendSignalIndex_Ack, PCControlSend_AlignStartAck_CPJT))
@@ -1438,7 +1448,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!"));
@@ -1499,7 +1511,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)
@@ -1704,6 +1717,8 @@
 			m_pSP2P->ISP2P_DisplayMessage(_T("[SequenceProcessor::ReviewEnd] Send Review End Ack!"));
 	}
 
+	SetUploadResultFailCount(0);
+
 	CGlassResult* pGlassResult = m_pSP2P->ISP2P_GetCurrentGlassResult();
 	if (pGlassResult == NULL) return;
 
@@ -1797,6 +1812,24 @@
 		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"));
@@ -3652,7 +3685,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);
@@ -8257,6 +8292,147 @@
 
 	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()

--
Gitblit v1.9.3