From 63439977901d54a01924ed76290931aeddbce66c Mon Sep 17 00:00:00 2001
From: LYW <leeyeanwoo@diteam.co.kr>
Date: 화, 05 7월 2022 18:16:55 +0900
Subject: [PATCH] Ongoing80 #4220 CF AOI Review 알람 추가

---
 ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp |  205 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 197 insertions(+), 8 deletions(-)

diff --git a/ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp b/ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp
index 8d8d1e5..267abef 100644
--- a/ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp
+++ b/ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp
@@ -166,6 +166,8 @@
 {
 	m_bUseAFMHomePosition = TRUE;
 	m_nGlassCount = 0;
+	m_nStackZeroReviewCondition = 0;
+	m_nUploadResultFailCount = 0;
 	CDitGlassRawClient* pDitGlassRaw = CDitGlassRawClient::GetInstance();
 	if(pDitGlassRaw->ConnectServer() == FALSE)
 	{
@@ -665,10 +667,12 @@
 		//	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!"));
@@ -940,6 +944,9 @@
 	SetWsiType(-1);    //wsi reflow
 	SetLastPointCheck(FALSE);
 
+	SetReviewComplete(FALSE);
+	SetUploadResultFailCount(0);
+
 	bFileFind = FALSE;
 
 	/*< LYW 20211109 - #3662 Delete Start >*/
@@ -1120,6 +1127,10 @@
  			}
  			
 			m_pSP2P->ISP2P_DisplayMessage(_T("[Glass Loading] Current Apply Recipe Name : %s"), strRecipefile);
+
+			/*< LYW 20220610 - #4185 ADD Start >*/
+			CheckGantryMode();
+			/*< LYW 20220610 - #4185 ADD End >*/
  
 			// recipe data apply
 			if(ApplyRecipeDataToGlassResult(pGlassResult)==FALSE)
@@ -1741,7 +1752,8 @@
 	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)
@@ -1749,6 +1761,7 @@
 			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
@@ -1787,6 +1800,23 @@
 		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++;
+			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"));
@@ -4289,7 +4319,9 @@
 		{
 			int XAddr = pMotorControl->GetGantryCollisionXAddr(pModuleStatus->GetGantryIndex());
 			g_pLog->DisplayMessage(_T("[Collision Position Set Fail] %d Module, Addr: %d, PosX: %.3lfmm"), nModuleIdx, XAddr, dCollisionPosX);
-			return 0;
+			/*< LYW 20220610 - #4185 Delete Start >*/
+			//return 0;
+			/*< LYW 20220610 - #4185 Delete End >*/
 		}
 
 		}
@@ -4587,7 +4619,9 @@
 			{
 				int XAddr = pMotorControl->GetGantryCollisionXAddr(pModuleStatus->GetGantryIndex());
 				g_pLog->DisplayMessage(_T("[Collision Position Set Fail] %d Module, Addr: %d, PosX: %.3lfmm"), nModuleIdx, XAddr, dCollisionPosX);
-				return 0;
+				/*< LYW 20220610 - #4185 Delete Start >*/
+				//return 0;
+				/*< LYW 20220610 - #4185 Delete End >*/
 			}
 
 		}
@@ -4840,7 +4874,9 @@
 			{
 				int XAddr = pMotorControl->GetGantryCollisionXAddr(pModuleStatus->GetGantryIndex());
 				g_pLog->DisplayMessage(_T("[Collision Position Set Fail] %d Module, Addr: %d, PosX: %.3lfmm"), nModuleIdx, XAddr, dCollisionPosX);
-				return 0;
+				/*< LYW 20220610 - #4185 Delete Start >*/
+				//return 0;
+				/*< LYW 20220610 - #4185 Delete End >*/
 			}
 		}
 
@@ -8241,6 +8277,131 @@
 
 	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++;
+		if (UploadResultFailCount >= 2)
+		{
+			m_pSP2P->ISP2P_DisplayMessage(_T("ResultFile Upload Fail!"));
+			SendSignalToSignalControl(PCControlSendSignalIndex_State, PCControlSend_ResultData_Upload_Fail, 1000);
+			SetUploadResultFailCount(-1);
+		}
+		SetUploadResultFailCount(UploadResultFailCount);
+	}
+}
+
 //#3358 KYH FDC  ADD END
 
 DWORD CSequenceProcessor_CPJT::GetDiskUsage()
@@ -9566,7 +9727,9 @@
 			{
 				int XAddr = pMotorControl->GetGantryCollisionXAddr(pModuleStatus->GetGantryIndex());
 				g_pLog->DisplayMessage(_T("[Collision Position Set Fail] %d Module, Addr: %d, PosX: %.3lfmm"), nModuleIdx, XAddr, dCollisionPosX);
-				return 0;
+				/*< LYW 20220610 - #4185 Delete Start >*/
+				//return 0;
+				/*< LYW 20220610 - #4185 Delete End >*/
 			}
 
 		}
@@ -9977,13 +10140,15 @@
 				int XAddr = pMotorControl->GetGantryCollisionXAddr(pModuleStatus->GetGantryIndex());
 				g_pLog->DisplayMessage(_T("[Review_CollisionPos] %d Module, Addr: %d, PosX: %.3lf mm"), nModuleIdx, XAddr, dCollisionPosX);
 
-				///pGlassResult->SetCollisionXPos(nModuleIdx, dCollisionPosX);
+				//pGlassResult->SetCollisionXPos(nModuleIdx, dCollisionPosX);
 			}
 			else
 			{
 				int XAddr = pMotorControl->GetGantryCollisionXAddr(pModuleStatus->GetGantryIndex());
 				g_pLog->DisplayMessage(_T("[Collision Position Set Fail] %d Module, Addr: %d, PosX: %.3lfmm"), nModuleIdx, XAddr, dCollisionPosX);
-				return 0;
+				/*< LYW 20220610 - #4185 Delete Start >*/
+				//return 0;
+				/*< LYW 20220610 - #4185 Delete End >*/
 			}
 			// get result index
 			int nStartIdx = pWsiMultiShotResult->GetStartSReviewResultIndex();
@@ -10482,6 +10647,30 @@
 	}	
 }
 
+/*< LYW 20220610 - #4185 ADD Start >*/
+void CSequenceProcessor_CPJT::CheckGantryMode()
+{
+	CSignalControl* pSignalControl = m_pSP2P->ISP2P_GetSignalControl();
+	if (pSignalControl == NULL) m_pSP2P->ISP2P_DisplayMessage(_T("[CheckGantryMode] SignalControl is NULL"));
+	if (pSignalControl->IsConnected() == FALSE) m_pSP2P->ISP2P_DisplayMessage(_T("[CheckGantryMode] SignalControl is Not Connect"));
+
+	int LeftGantryUse = 0;
+	int RightGantryUse = 0;
+
+	pSignalControl->ReadData(_T("10003"), 1, 1, LeftGantryUse);
+	pSignalControl->ReadData(_T("10003"), 2, 1, RightGantryUse);
+
+	if (LeftGantryUse == 1 && RightGantryUse == 0) 
+		m_pSP2P->ISP2P_Recipe_GetRsRcpReviewInfo()->GetRcpSchedulingInfo()->SetSingleGantryPath(1);
+	else if (LeftGantryUse == 0 && RightGantryUse == 1)
+		m_pSP2P->ISP2P_Recipe_GetRsRcpReviewInfo()->GetRcpSchedulingInfo()->SetSingleGantryPath(2);
+	else
+		m_pSP2P->ISP2P_Recipe_GetRsRcpReviewInfo()->GetRcpSchedulingInfo()->SetSingleGantryPath(0);
+
+	m_pSP2P->ISP2P_DisplayMessage(_T("[CheckGantryMode] GantryMode LeftBit = %d, RightBit = %d"), LeftGantryUse, RightGantryUse);
+}
+/*< LYW 20220610 - #4185 ADD End >*/
+
 BOOL CSequenceProcessor_CPJT::UpdateMemoryUserReflowPlanInfo(CDitGlassRawClient* pDitSharedGlassRaw)
 {
 	CRsRcpReviewInfo* pRecipeinfo = m_pSP2P->ISP2P_Recipe_GetRsRcpReviewInfo();

--
Gitblit v1.9.3