From 3ab77fdb5f702156c492c7eb4bd1daf25d6fbc56 Mon Sep 17 00:00:00 2001
From: LYW <leeyeanwoo@diteam.co.kr>
Date: 수, 08 9월 2021 17:08:45 +0900
Subject: [PATCH] Ongoing90 #3561 CF AOI Review Align 카메라 끊김 현상 조치

---
 ReviewSystem/ReviewSystem/ReviewProcessor_CPJT.cpp |  509 ++++++++++++++++++++++++++++++++------------------------
 1 files changed, 288 insertions(+), 221 deletions(-)

diff --git a/ReviewSystem/ReviewSystem/ReviewProcessor_CPJT.cpp b/ReviewSystem/ReviewSystem/ReviewProcessor_CPJT.cpp
index e4e79e7..7753de9 100644
--- a/ReviewSystem/ReviewSystem/ReviewProcessor_CPJT.cpp
+++ b/ReviewSystem/ReviewSystem/ReviewProcessor_CPJT.cpp
@@ -5,6 +5,7 @@
 #include "CameraControlReview.h"
 #include "CHImageControls/CHImageProcess.h"
 #include "CHMotorControls/MotorControl.h"
+#include "CHSignalControls/SignalControl.h"
 
 #include "CHEdgeTriangle/EdgeTriangle.h"
 #include "CHEdgeTriangle/RecipeManager.h"
@@ -88,7 +89,6 @@
 	int nEndResultIdx	= pReviewResult->GetEndSReviewResultIndex();
 						
 	
-	// 인덱스가 현재 마지막 인덱스 보다 클시..
 	if (nCurResultIdx > nEndResultIdx)  
 	{
 		LeaveCriticalSection(&m_csUserCriticalSection);
@@ -96,8 +96,6 @@
 		g_pLog->DisplayMessage(_T("[ReviewProcessor]SetWsiResultData module[%d] point[%d] result[%d]"), nModuleIndex, measureResut.nResultIndex, nCurResultIdx);
 	}
 
-
-	// 현재 결과데이터 저장
 
 	wsiResult.nWsi_ResultIndex = measureResut.nResultIndex;
 	wsiResult.nResultCode = measureResut.nResultCode;
@@ -138,8 +136,6 @@
 // 		g_pLog->DisplayMessage(_T("[ReviewProcessor]JugementR [%d] JugementG [%d] JugementB [%d]"), wsiResult.nJugementR, wsiResult.nJugementG, wsiResult.nJugementB);
 // 		g_pLog->DisplayMessage(_T("[ReviewProcessor]RZoneHeight [%.03lf] GZoneHeight [%.03lf] BZoneHeight [%.03lf]"), wsiResult.dRZoneHeight, wsiResult.dGZoneHeight, wsiResult.dBZoneHeight);
 
-// 		wsiResult.추가 하세요= measureResut.nMultiShot;
-// 		wsiResult.추가 하세요= measureResut.nCurrentShotNumber;
 		break;
 	case 3: //BANK
 		wsiResult.dRZoneHeight = measureResut.dRZoneHeight;
@@ -147,14 +143,13 @@
 		wsiResult.dBZoneHeight = measureResut.dBZoneHeight;
 		wsiResult.dDefectHeight = measureResut.dDefectHeight;
 		wsiResult.nWsi_DefectType = measureResut.nDefectType;
-// 		wsiResult.추가 하세요= measureResut.nMultiShot;
-// 		wsiResult.추가 하세요= measureResut.nCurrentShotNumber;
+
 		break;
 	case 4: //CS
 		wsiResult.dCSHeight = measureResut.dCSHeight;
 		wsiResult.dDefectHeight = measureResut.dDefectHeight;
 		wsiResult.nWsi_DefectType = measureResut.nDefectType;
-// 		wsiResult.추가 하세요= measureResut.nMultiShot;
+
 		break;
 	}
 
@@ -162,8 +157,6 @@
 
 	memcpy(wsiResult.pWsi_ResultData, measureResut.pResultData, sizeof(wsiResult.pWsi_ResultData));
 
-
-	// 결과 데이터 추가
 	SReviewResult *pProcessResult = NULL;
 	if (pGlassResult->SetWsiResultData(nModuleIndex, nCurResultIdx, wsiResult, nGlassPosX, nGlassPosY, nMotorPosX, nMotorPosY, dTime))
 	{
@@ -173,10 +166,8 @@
 		pProcessResult = pReviewResult->GetSReviewResult(nCurResultIdx);
 	}
 
-	// 저장 성공시, 리뷰 프로세서에 포인터 전달
 	if (pProcessResult)
 	{
-		// 처리 쓰레드 수행
 		if (AddReviewProcessData(pProcessResult)==1)
 		{
 			g_pLog->DisplayMessage(_T("[ReviewProcessor]Add Process Data module[%d] result[%d]"), nModuleIndex, nCurResultIdx);
@@ -192,7 +183,6 @@
 	
 	LeaveCriticalSection(&m_csUserCriticalSection);
 
-	// 결과 갱신.
 	m_pRP2P->IRP2P_UpdateReviewResult(nModuleIndex, pGlassResult);
 	return;
 
@@ -238,7 +228,6 @@
 	int nEndResultIdx	= pReviewResult->GetEndSReviewResultIndex();
 
 
-	// 인덱스가 현재 마지막 인덱스 보다 클시..
 	if (nCurResultIdx > nEndResultIdx)  
 	{
 		LeaveCriticalSection(&m_csUserCriticalSection);
@@ -246,14 +235,12 @@
 		g_pLog->DisplayMessage(_T("[ReviewProcessor]SetWsiResultData module[%d] point[%d] result[%d]"), nModuleIndex, measureResut.nResultIndex, nCurResultIdx);
 	}
 
-	// 현재 결과데이터 저장
 	wsiUserResult.nWsi_ResultCode		= measureResut.nResultCode;
 	wsiUserResult.nWsi_Type				= measureResut.nResultType;
 	wsiUserResult.nWsi_SlopeWarn		= measureResut.nXSlopeWarn;
 	memcpy(wsiUserResult.pWsi_ResultData, measureResut.pResultData, sizeof(wsiUserResult.pWsi_ResultData));
 
 
-	// 결과 데이터 추가
 	SReviewResult *pProcessResult = NULL;
 	if (pGlassResult->SetUserWsiResultData(nModuleIndex, nCurResultIdx, wsiUserResult, nGlassPosX, nGlassPosY, nMotorPosX, nMotorPosY, dTime))
 	{
@@ -263,10 +250,8 @@
 		pProcessResult = pReviewResult->GetSReviewResult(nCurResultIdx);
 	}
 
-	// 저장 성공시, 리뷰 프로세서에 포인터 전달
 	if (pProcessResult)
 	{
-		// 처리 쓰레드 수행
 		if (AddReviewProcessData(pProcessResult)==1)
 		{
 			g_pLog->DisplayMessage(_T("[ReviewProcessor]Add Process Data module[%d] result[%d]"), nModuleIndex, nCurResultIdx); 
@@ -282,7 +267,6 @@
 
 	LeaveCriticalSection(&m_csUserCriticalSection);
 
-	// 결과 갱신.
 	m_pRP2P->IRP2P_UpdateReviewResult(nModuleIndex, pGlassResult);
 	return;
 
@@ -337,7 +321,6 @@
 	int nEndResultIdx = pReviewResult->GetEndSReviewResultIndex();
 
 
-	// 인덱스가 현재 마지막 인덱스 보다 클시..
 	if (nCurResultIdx > nEndResultIdx)
 	{
 		LeaveCriticalSection(&m_csUserCriticalSection);
@@ -345,7 +328,6 @@
 		g_pLog->DisplayMessage(_T("[ReviewProcessor]SetWsiMultiShotResultData module[%d] point[%d] result[%d]"), nModuleIndex, measureResut.nResultIndex, nCurResultIdx);
 	}
 
-	// 현재 결과데이터 저장
 	wsiResult.nWsi_ResultCode = measureResut.nResultCode;
 	wsiResult.nWsi_Type = measureResut.nResultType;
 	wsiResult.nWsi_SlopeWarn = measureResut.nXSlopeWarn;
@@ -353,7 +335,6 @@
 	memcpy(wsiResult.pWsi_ResultData, measureResut.pResultData, sizeof(wsiResult.pWsi_ResultData));
 
 
-	// 결과 데이터 추가
 	SReviewResult *pProcessResult = NULL;
 	if (pGlassResult->SetWsiResultData(nModuleIndex, nCurResultIdx, wsiResult, nGlassPosX, nGlassPosY, nMotorPosX, nMotorPosY, dTime))
 	{
@@ -363,10 +344,8 @@
 		pProcessResult = pReviewResult->GetSReviewResult(nCurResultIdx);
 	}
 
-	// 저장 성공시, 리뷰 프로세서에 포인터 전달
 	if (pProcessResult)
 	{
-		// 처리 쓰레드 수행
 		if (AddReviewProcessData(pProcessResult) == 1)
 		{
 			g_pLog->DisplayMessage(_T("[ReviewProcessor]Add Process Data module[%d] result[%d]"), nModuleIndex, nCurResultIdx); 
@@ -381,8 +360,6 @@
 	}
 
 	LeaveCriticalSection(&m_csUserCriticalSection);
-
-	// 결과 갱신.
 	m_pRP2P->IRP2P_UpdateReviewResult(nModuleIndex, pGlassResult);
 	return;
 
@@ -457,7 +434,6 @@
 	int nStartResultIdx	= pReviewResult->GetStartSReviewResultIndex();
 	int nEndResultIdx	= pReviewResult->GetEndSReviewResultIndex();
 	
-	// 인덱스가 현재 마지막 인덱스 보다 클시..
 	if (nCurResultIdx > nEndResultIdx)  
 	{
 		LeaveCriticalSection(&m_csUserCriticalSection);
@@ -465,7 +441,6 @@
 		g_pLog->DisplayMessage(_T("[ReviewProcessor]SetReviewResultData module[%d] point[%d] result[%d]"), nModuleIndex, nResultIndex, nCurResultIdx);
 	}
 
-	// 현재 결과이미지 저장
 	SReviewResult *pProcessResult = NULL;
 	switch(GetReviewProcessStatus())
 	{
@@ -509,10 +484,8 @@
 		break;
 	}
 
-	// 저장 성공시, 리뷰 프로세서에 포인터 전달
 	if (pProcessResult)
 	{
-		// 처리 쓰레드 수행
 		if (AddReviewProcessData(pProcessResult)==1)
 		{
 			g_pLog->DisplayMessage(_T("[ReviewProcessor]Add Process Data module[%d] result[%d]"), nModuleIndex, nCurResultIdx); 
@@ -526,9 +499,7 @@
 		pReviewResult->SetLastSReviewResultIndex(nCurResultIdx);
 	}
 		LeaveCriticalSection(&m_csUserCriticalSection);
-
-		//만약 어느 한쪽이포인트 진행을 다해버리면 아래 구문을 안타서 다시 모터좌표 안쏴줌 
-		// 신호처리 필요함 이거 ㄱㄱ 
+ 
 		if (nCurResultIdx + 1== pReviewResult->GetSReviewResultCount())
 		{
 			if (nModuleIndex == 0)
@@ -542,7 +513,7 @@
 
 			if (bLeftGantryReviewDone&&bRightGantryReviewDone)
 			{
-				::Sleep(3000); // 딜레이는 필수임. 없으면 동작 안함.
+				::Sleep(3000);
 				g_pLog->DisplayMessage(_T("[ReviewProcessor]RemainReview Started module[%d]"), nModuleIndex);
 				CSequenceProcessor* pSequenceProcessor = m_pRP2P->IRP2P_GetSequenceProcessor();
 				switch (GetReviewProcessStatus())
@@ -567,13 +538,10 @@
 			}
 			else if(m_pRP2P->IRP2P_Recipe_GetRsRcpReviewInfo()->GetRcpSchedulingInfo()->GetSingleGantryPath()>0)
 			{
-				//20210302 싱글 겐트리 사용시 모터 로직상 두개의 겐트리가 완료된 상태에서 
-				//시작을 해야됨으로 Review 에서 Count 체크 하는 기능으로 한겐트리 사용시 200개에서 멈추는 현상 발생
-				//그래서 싱글 겐트리 사용시 예외처리 하여 동작하도록 바꿔야됨 CHM
 				g_pLog->DisplayMessage(_T("[ReviewProcessor]Single GantryPath Use"), nModuleIndex);
 				if (bLeftGantryReviewDone || bRightGantryReviewDone)
 				{
-					::Sleep(3000); // 딜레이는 필수임. 없으면 동작 안함.
+					::Sleep(3000); 
 					g_pLog->DisplayMessage(_T("[ReviewProcessor]RemainReview Started module[%d]"), nModuleIndex);
 					CSequenceProcessor* pSequenceProcessor = m_pRP2P->IRP2P_GetSequenceProcessor();
 					switch (GetReviewProcessStatus())
@@ -601,7 +569,6 @@
 
 		}
 		
-		// 마지막 포인트까지 왔고, 리뷰할 결과가 남아 있으면...
 		if(nCurResultIdx==nEndResultIdx && nCurResultIdx+1 < pReviewResult->GetSReviewResultCount())
 	    {
 
@@ -624,8 +591,7 @@
 		pReviewResult->SetStartSReviewResultIndex(nStartResultIdx);
 		pReviewResult->SetEndSReviewResultIndex(nEndResultIdx);
 
-		// 나머지 포인트 리뷰 수행하자.
-		::Sleep(3000); // 딜레이는 필수임. 없으면 동작 안함.
+		::Sleep(3000); 
 		   if (bLeftGantryReviewDone&&bRightGantryReviewDone)
 		   {
 			
@@ -685,7 +651,6 @@
 		}
 	}
 
-	// 결과 갱신.
 	m_pRP2P->IRP2P_UpdateReviewResult(nModuleIndex, pGlassResult, m_nReviewPlanIndex);
 	return;
 
@@ -729,7 +694,6 @@
 {
 	if (m_pRP2P==NULL) return 0;
 
-	// 마지막 포인트인지 확인 후 PCControl ReviewEnd 전송
 	CGlassResult *pGlassResult = m_pRP2P->IRP2P_GetCurrentGlassResult();
 	CSequenceProcessor* pSequenceProcessor = m_pRP2P->IRP2P_GetSequenceProcessor();
 	if (pGlassResult==NULL || pSequenceProcessor==NULL) 
@@ -737,7 +701,6 @@
 		return 1;
 	}
 
-	// 조건확인
 	if (pGlassResult->CheckReviewComplete())
 	{
 		// check motor ready!
@@ -763,7 +726,6 @@
 {
 	if (m_pRP2P==NULL) return 0;
 
-	// 마지막 포인트인지 확인 후 PCControl ReviewEnd 전송
 	CGlassResult *pGlassResult = m_pRP2P->IRP2P_GetCurrentGlassResult();
 	CSequenceProcessor* pSequenceProcessor = m_pRP2P->IRP2P_GetSequenceProcessor();
 	if (pGlassResult==NULL || pSequenceProcessor==NULL) 
@@ -771,7 +733,6 @@
 		return 1;
 	}
 
-	// 조건확인
 	if (pGlassResult->CheckUserComplete())
 	{
 		m_pRP2P->IRP2P_DisplayMessage(_T("User Last Point Complete! "));
@@ -796,7 +757,6 @@
 {
 	if (m_pRP2P==NULL) return 0;
 
-	// 마지막 포인트인지 확인 후 PLC ReviewEnd 전송
 	CGlassResult *pGlassResult = m_pRP2P->IRP2P_GetCurrentGlassResult();
 	CSequenceProcessor* pSequenceProcessor = m_pRP2P->IRP2P_GetSequenceProcessor();
 	if (pGlassResult==NULL || pSequenceProcessor==NULL) 
@@ -804,7 +764,6 @@
 		return 1;
 	}
 
-	// 조건확인
 	if (pGlassResult->CheckReflowComplete())
 	{
 		m_pRP2P->IRP2P_DisplayMessage(_T("Reflow Last Point Complete! "));
@@ -829,7 +788,6 @@
 {
 	if (m_pRP2P==NULL) return 0;
 
-	// 마지막 포인트인지 확인 후 PCControl ReviewEnd 전송
 	CGlassResult *pGlassResult = m_pRP2P->IRP2P_GetCurrentGlassResult();
 	CSequenceProcessor* pSequenceProcessor = m_pRP2P->IRP2P_GetSequenceProcessor();
 	if (pGlassResult==NULL || pSequenceProcessor==NULL) 
@@ -837,7 +795,6 @@
 		return 1;
 	}
 
-	// 조건확인
 	if (pGlassResult->CheckWsiComplete())
 	{
 		m_pRP2P->IRP2P_DisplayMessage(_T("Wsi Last Point Complete! "));
@@ -863,7 +820,6 @@
 	g_pLog->DisplayMessage(_T("PostProcessMeasureResult[%d]"),nThreadIdx);
 	if (m_pRP2P==NULL) return 0;
 
-	// 마지막 포인트인지 확인 후 PCControl ReviewEnd 전송
 	CGlassResult *pGlassResult = m_pRP2P->IRP2P_GetCurrentGlassResult();
 	CSequenceProcessor* pSequenceProcessor = m_pRP2P->IRP2P_GetSequenceProcessor();
 	if (pGlassResult==NULL || pSequenceProcessor==NULL) 
@@ -871,7 +827,6 @@
 		return 1;
 	}
 
-	// 조건확인
 	if (pGlassResult->CheckMeasureComplete())
 	{
 		m_pRP2P->IRP2P_DisplayMessage(_T("Measure Last Point Complete! "));
@@ -900,7 +855,6 @@
 {
 	if (m_pRP2P==NULL) return 0;
 
-	// 마지막 포인트인지 확인 후 PCControl ReviewEnd 전송
 	CGlassResult *pGlassResult = m_pRP2P->IRP2P_GetCurrentGlassResult();
 	CSequenceProcessor* pSequenceProcessor = m_pRP2P->IRP2P_GetSequenceProcessor();
 	if (pGlassResult==NULL || pSequenceProcessor==NULL) 
@@ -908,7 +862,6 @@
 		return 1;
 	}
 
-	// 조건확인
 	if (pGlassResult->CheckWsiReflowComplete())
 	{
 		m_pRP2P->IRP2P_DisplayMessage(_T("Wsi Reflow Last Point Complete! "));
@@ -932,7 +885,6 @@
 {
 	if (m_pRP2P==NULL) return 0;
 
-	// 마지막 포인트인지 확인 후 PCControl ReviewEnd 전송
 	CGlassResult *pGlassResult = m_pRP2P->IRP2P_GetCurrentGlassResult();
 	CSequenceProcessor* pSequenceProcessor = m_pRP2P->IRP2P_GetSequenceProcessor();
 	if (pGlassResult==NULL || pSequenceProcessor==NULL) 
@@ -940,7 +892,6 @@
 		return 1;
 	}
 
-	// 조건확인
 	if (pGlassResult->CheckWsiUserComplete())
 	{
 		m_pRP2P->IRP2P_DisplayMessage(_T("Wsi Last Point Complete! "));
@@ -965,7 +916,6 @@
 {
 	if (m_pRP2P == NULL) return 0;
 
-	// 마지막 포인트인지 확인 후 PCControl ReviewEnd 전송
 	CGlassResult *pGlassResult = m_pRP2P->IRP2P_GetCurrentGlassResult();
 	CSequenceProcessor* pSequenceProcessor = m_pRP2P->IRP2P_GetSequenceProcessor();
 	if (pGlassResult == NULL || pSequenceProcessor == NULL)
@@ -973,7 +923,6 @@
 		return 1;
 	}
 
-	// 조건확인
 	if (pGlassResult->CheckWsiMultiShotComplete())
 	{
 		m_pRP2P->IRP2P_DisplayMessage(_T("WsiMultiShot Last Point Complete! "));
@@ -1138,23 +1087,19 @@
 		return ReviewResult_Process_Fail;
 	}
 	
-	// Snap 시간 저장.
 	CTime snapTime = CTime::GetCurrentTime();
 	pReviewResult->strSnapTime.Format(_T("%04d%02d%02d%02d%02d%02d"), snapTime.GetYear(), snapTime.GetMonth(), snapTime.GetDay(), 
 		snapTime.GetHour(), snapTime.GetMinute(), snapTime.GetSecond());	// snap_time
 
-	// 리뷰 업로드 이미지 파일 이름 만들기
 	CString strImageFileName = _T("");
 	if (MakeReviewImageFileName(pReviewResult)==FALSE)
 	{
 		
 	}
 
-	//결과파일 공유 메모리 리뷰 이미지 이름 및 좌표 채워주기
 	if(!UpdateMemoryReviewPlan(pReviewResult))
 		m_pRP2P->IRP2P_DisplayMessage(_T("[ReviewPlan] Memory Update Fail!! DefectIdx : %d"), pReviewResult->nDefectidx2);
 	
-	// 로컬 이미지 저장 파일 이름
 	pReviewResult->strImgFileName = m_strSaveImageBasePath + _T("\\") +pReviewResult->strImgFileName;
 	pReviewResult->nOpticType = 1;
 
@@ -1178,22 +1123,29 @@
 		//	UINT64 nSize = SaveReviewImage(&uploadImage, strPath, m_nReviewImageSize, m_nReviewImageQuality, m_nReviewImageStep);
 			//if (nSize > 0)
 			//	m_pRP2P->IRP2P_DisplayMessage(_T("Backup Review Image Save Success! Size: %d byte [%s]"), nSize, pReviewResult->strUploadImgFileName);
-			// 업로드 이미지 경로 수정 20190917 chm
 			strPath.Format(_T("%s\\%s"), m_strSaveImageUploadPath, pReviewResult->strUploadImgFileName);
 			nSize = SaveReviewImage(&uploadImage, strPath, m_nReviewImageSize, m_nReviewImageQuality, m_nReviewImageStep);
-			m_pRP2P->IRP2P_DisplayMessage(_T("Backup Review Image Save Success! Size: %d byte [%s]"), nSize, strPath);
 
 			if (pGlassResult != NULL)
 			{				
 				pGlassResult->m_strUploadImgFileName = m_strSaveImageUploadPath;
 				//taek 210203
 				strRTMSPath.Format(_T("\\\\126.100.100.5\\Reviewimage\\%s\\%s\\%s"), pGlassResult->m_strRTMSStepID, pGlassResult->m_strGlassID, pReviewResult->strUploadImgFileName);
-				SaveReviewImage(&uploadImage, strRTMSPath, m_nReviewImageSize, m_nReviewImageQuality, m_nReviewImageStep); //Taek Rtms 210126
+				int bRet = SaveReviewImage(&uploadImage, strRTMSPath, m_nReviewImageSize, m_nReviewImageQuality, m_nReviewImageStep); //Taek Rtms 210126
+				if (bRet == 0)
+				{
+					m_pRP2P->IRP2P_DisplayMessage(_T("RTMS Review Image Save Fail!!"));
+				}
+
+				else m_pRP2P->IRP2P_DisplayMessage(_T("RTMS Review Image Save Success! Size: %d byte [%s] index[%d]"), nSize, strRTMSPath, pReviewResult->nDefectIdx);
+
 			}
 			if (nSize > 0)
 			{
+				
 				 int aoiindex = CDitGlassRawClient::GetInstance()->GetDefectData(pReviewResult->nDefectidx2)->m_nDefectIdx;
-				m_pRP2P->IRP2P_DisplayMessage(_T("Upload Review Image Save Success! Size: %d byte [%s] index[%d] AOI NO[%d]"), nSize, strRTMSPath, pReviewResult->nDefectIdx, aoiindex); //taek 210128 속도 문제로 임시로 로그 남기지 않음
+
+				m_pRP2P->IRP2P_DisplayMessage(_T("Upload Review Image Save Success! Size: %d byte [%s] index[%d] AOI NO[%d]"), nSize, pReviewResult->strUploadImgFileName, pReviewResult->nDefectIdx, aoiindex); //taek 210128 속도 문제로 임시로 로그 남기지 않음
 				//m_pRP2P->IRP2P_DisplayMessage(_T("Upload Review Image Save Success! Size: %d byte [%s]"), nSize, pReviewResult->strUploadImgFileName);
 			}
 			else
@@ -1229,7 +1181,7 @@
 	const CRsRcpReviewInfo*  psRcpReviewInfo = m_pRP2P->IRP2P_Recipe_GetRsRcpReviewInfo();
 	if(psRcpReviewInfo== NULL) m_pRP2P->IRP2P_DisplayMessage(_T("RcpReviewInfo is NULL"));
 	
-	if(psRcpReviewInfo->m_bDefocusUse) //190819chm 디포커스 알람 사용 
+	if(psRcpReviewInfo->m_bDefocusUse) 
 	{
 	  if(pReviewResult->nLocation == DefectLoc_ASG || pReviewResult->nLocation == DefectLoc_PAD || pReviewResult->nLocation == DefectLoc_C2C)
 	  {
@@ -1270,22 +1222,39 @@
 			  }
 		  }
 
-		  if (pReviewResult->nModuleIdx == 0)
+		  if (pReviewResult->nModuleIdx == 0 && m_pRP2P->IRP2P_GetFirstReviewLeft())
 		  {
+			  const CSignalControlInfo* pSignalInfo = m_pRP2P->IRP2P_GetReviewSignalinfo();
+			  int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
+			  int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
+
 			  m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview00ImageContrast = dFocusValue;
-			  /* double dAverageGray = 0.0;
-			   if (CCHImageProcess::ImageAverage(pImageData, dAverageGray) == 1)
-			   {
-				   m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview00ImageContrast = dAverageGray;
-			   }*/
-	  }
-		  else
+			  m_pRP2P->IRP2P_SetFirstReviewLeft(FALSE);
+			  m_pRP2P->IRP2P_DisplayMessage(_T("FirstReviewLeft FDC FocusValue = %.2f "), dFocusValue);
+
+			  if (dFocusValue < nDefocusValueMin || dFocusValue > nDefocusValueMax)
+			  {
+				  m_pRP2P->IRP2P_GetSequenceProcessor()->SendSignalToSignalControl(0, 3, 1000);
+			  }
+		  }
+		  else if(pReviewResult->nModuleIdx == 1 && m_pRP2P->IRP2P_GetFirstReviewRight())
 		  {
+			  const CSignalControlInfo* pSignalInfo = m_pRP2P->IRP2P_GetReviewSignalinfo();
+			  int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
+			  int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
+
 			  m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview01ImageContrast = dFocusValue;
-			 
+			  m_pRP2P->IRP2P_SetFirstReviewRight(FALSE);
+			  m_pRP2P->IRP2P_DisplayMessage(_T("FirstReviewRight FDC FocusValue = %.2f "), dFocusValue);
+
+			  if (dFocusValue < nDefocusValueMin || dFocusValue > nDefocusValueMax)
+			  {
+				  m_pRP2P->IRP2P_GetSequenceProcessor()->SendSignalToSignalControl(0, 3, 1000);
+			  }
 		  }
 	  }
 	}
+	//#3524_210723_LYW_CF AOI Review 디포커스 알람 추가 및 FDC 보고 방식 개선 MOD Start
 	else
 	{
 		double dFocusValue = 0.;
@@ -1303,15 +1272,40 @@
 			dFocusValue = CalcFocusValue(imageConvert.GetImageBuffer(), imageConvert.GetWidth(), imageConvert.GetHeight());
 		}
 
-		if (pReviewResult->nModuleIdx == 0)
+		if (pReviewResult->nModuleIdx == 0 && m_pRP2P->IRP2P_GetFirstReviewLeft())
 		{
+			const CSignalControlInfo* pSignalInfo = m_pRP2P->IRP2P_GetReviewSignalinfo();
+			int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
+			int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
+
 			m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview00ImageContrast = dFocusValue;
+			m_pRP2P->IRP2P_SetFirstReviewLeft(FALSE);
+			m_pRP2P->IRP2P_DisplayMessage(_T("FirstReviewLeft FDC FocusValue = %.2f "), dFocusValue);
+			
+			if (dFocusValue < nDefocusValueMin || dFocusValue > nDefocusValueMax)
+			{
+				m_pRP2P->IRP2P_GetSequenceProcessor()->SendSignalToSignalControl(0, 3, 1000);
+			}
+			
 		}
-		else
+		else if (pReviewResult->nModuleIdx == 1 && m_pRP2P->IRP2P_GetFirstReviewRight())
 		{
+			const CSignalControlInfo* pSignalInfo = m_pRP2P->IRP2P_GetReviewSignalinfo();
+			int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
+			int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
+
 			m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview01ImageContrast = dFocusValue;
+			m_pRP2P->IRP2P_SetFirstReviewRight(FALSE);
+			m_pRP2P->IRP2P_DisplayMessage(_T("FirstReviewRight FDC FocusValue = %.2f "), dFocusValue);
+
+			if (dFocusValue < nDefocusValueMin || dFocusValue > nDefocusValueMax)
+			{
+				m_pRP2P->IRP2P_GetSequenceProcessor()->SendSignalToSignalControl(0, 3, 1000);
+			}
+
 		}
 	}
+	//#3524_210723_LYW_CF AOI Review 디포커스 알람 추가 및 FDC 보고 방식 개선 MOD End
 	
 	
 
@@ -1331,12 +1325,10 @@
 		return ReviewResult_Process_Fail;
 	}
 
-	// Snap 시간 저장.
 	CTime snapTime = CTime::GetCurrentTime();
 	pReviewResult->strSnapTime.Format(_T("%04d%02d%02d%02d%02d%02d"), snapTime.GetYear(), snapTime.GetMonth(), snapTime.GetDay(), 
 		snapTime.GetHour(), snapTime.GetMinute(), snapTime.GetSecond());	// snap_time
 
-	// 리뷰 업로드 이미지 파일 이름 만들기
 	CString strImageFileName = _T("");
 	if (MakeUserImageFileName(pReviewResult)==FALSE)
 	{
@@ -1348,8 +1340,6 @@
 	if(!UpdateMemoryUserPlan(pReviewResult))
 		m_pRP2P->IRP2P_DisplayMessage(_T("[UserPlan] Memory Update Fail!! DefectIdx : %d"), pReviewResult->nDefectidx2);
 
-
-	//// 로컬 이미지 저장 파일 이름
 	//strImageFileName.Format(_T("ModuleIdx[%d]_PointIdx[%d]_Zoom[%d]"), pReviewResult->nModuleIdx, pReviewResult->nResultIdx, pReviewResult->nZoomIdx);
 	//pReviewResult->strImgFileName = strImageFileName;
 
@@ -1368,10 +1358,9 @@
 			UINT64 nSize = SaveReviewImage(&uploadImage, strPath, m_nReviewImageSize, m_nReviewImageQuality, m_nReviewImageStep);
 			m_pRP2P->IRP2P_DisplayMessage(_T("Upload Review Image Save Success! Size: %d byte"), nSize);
 
-			//uploadImage.SaveImage(strPath, 40);  // 화질 60% 150k
+			//uploadImage.SaveImage(strPath, 40); 
 			if(GetReviewProcessStatus() == ReviewProcessStatus_UserStart)
 			{
-				// 업로드 이미지 경로 수정 20190917 chm
 				//strPath.Format(_T("%s\\%s\\%s"), m_strSaveImageUploadPath, m_strGlassID, pReviewResult->strUploadImgFileName);
 				strPath.Format(_T("%s\\%s"), m_strSaveImageUploadPath, pReviewResult->strUploadImgFileName);
 				nSize = SaveReviewImage(&uploadImage, strPath, m_nReviewImageSize, m_nReviewImageQuality, m_nReviewImageStep);
@@ -1393,7 +1382,7 @@
 	const CRsRcpReviewInfo*  psRcpReviewInfo = m_pRP2P->IRP2P_Recipe_GetRsRcpReviewInfo();
 	if(psRcpReviewInfo== NULL) m_pRP2P->IRP2P_DisplayMessage(_T("RcpReviewInfo is NULL"));
 
-	if(psRcpReviewInfo->m_bDefocusUse) //190819chm 디포커스 알람 사용 
+	if(psRcpReviewInfo->m_bDefocusUse)
 	{
 		if(pReviewResult->nLocation == DefectLoc_ASG || pReviewResult->nLocation == DefectLoc_PAD || pReviewResult->nLocation == DefectLoc_C2C)
 		{
@@ -1416,9 +1405,41 @@
 			if (imageConvert.GetImageExist())
 			{
 				dFocusValue = CalcFocusValue(imageConvert.GetImageBuffer(), imageConvert.GetWidth(), imageConvert.GetHeight());
+
+				if (pReviewResult->nModuleIdx == 0 && m_pRP2P->IRP2P_GetFirstReviewLeft())
+				{
+					const CSignalControlInfo* pSignalInfo = m_pRP2P->IRP2P_GetReviewSignalinfo();
+					int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
+					int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
+
+					m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview00ImageContrast = dFocusValue;
+					m_pRP2P->IRP2P_SetFirstReviewLeft(FALSE);
+					m_pRP2P->IRP2P_DisplayMessage(_T("FirstReviewLeft FDC FocusValue = %.2f "), dFocusValue);
+
+					if (dFocusValue < nDefocusValueMin || dFocusValue > nDefocusValueMax)
+					{
+						m_pRP2P->IRP2P_GetSequenceProcessor()->SendSignalToSignalControl(0, 3, 1000);
+					}
+				}
+				else if (pReviewResult->nModuleIdx == 1 && m_pRP2P->IRP2P_GetFirstReviewRight())
+				{
+					const CSignalControlInfo* pSignalInfo = m_pRP2P->IRP2P_GetReviewSignalinfo();
+					int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
+					int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
+
+					m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview01ImageContrast = dFocusValue;
+					m_pRP2P->IRP2P_SetFirstReviewRight(FALSE);
+					m_pRP2P->IRP2P_DisplayMessage(_T("FirstReviewRight FDC FocusValue = %.2f "), dFocusValue);
+
+					if (dFocusValue < nDefocusValueMin || dFocusValue > nDefocusValueMax)
+					{
+						m_pRP2P->IRP2P_GetSequenceProcessor()->SendSignalToSignalControl(0, 3, 1000);
+					}
+
+				}
+
 			}
 		
-			
 			// count defocus
 			CGlassResult* pGlassResult = m_pRP2P->IRP2P_GetCurrentGlassResult();
 			if (pGlassResult)
@@ -1438,6 +1459,57 @@
 		}
 	}
 
+	//#3524_210723_LYW_CF AOI Review 디포커스 알람 추가 및 FDC 보고 방식 개선 ADD Start
+	else
+	{
+		double dFocusValue = 0.;
+		CCHImageData imageConvert;
+		if (pImageData->GetChannels() != 1)
+		{
+			CCHImageProcess::ImageConvert(pImageData, &imageConvert, ConvertTypeRGB2Gray);
+		}
+		else
+		{
+			pImageData->CopyImageTo(&imageConvert);
+		}
+		if (imageConvert.GetImageExist())
+		{
+			dFocusValue = CalcFocusValue(imageConvert.GetImageBuffer(), imageConvert.GetWidth(), imageConvert.GetHeight());
+		}
+
+		if (pReviewResult->nModuleIdx == 0 && m_pRP2P->IRP2P_GetFirstReviewLeft())
+		{
+			const CSignalControlInfo* pSignalInfo = m_pRP2P->IRP2P_GetReviewSignalinfo();
+			int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
+			int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
+
+			m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview00ImageContrast = dFocusValue;
+			m_pRP2P->IRP2P_SetFirstReviewLeft(FALSE);
+			m_pRP2P->IRP2P_DisplayMessage(_T("FirstReviewLeft FDC FocusValue = %.2f "), dFocusValue);
+
+			if (dFocusValue < nDefocusValueMin || dFocusValue > nDefocusValueMax)
+			{
+				m_pRP2P->IRP2P_GetSequenceProcessor()->SendSignalToSignalControl(0, 3, 1000);
+			}
+		}
+		else if (pReviewResult->nModuleIdx == 1 && m_pRP2P->IRP2P_GetFirstReviewRight())
+		{
+			const CSignalControlInfo* pSignalInfo = m_pRP2P->IRP2P_GetReviewSignalinfo();
+			int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
+			int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
+
+			m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview01ImageContrast = dFocusValue;
+			m_pRP2P->IRP2P_SetFirstReviewRight(FALSE);
+			m_pRP2P->IRP2P_DisplayMessage(_T("FirstReviewRight FDC FocusValue = %.2f "), dFocusValue);
+
+			if (dFocusValue < nDefocusValueMin || dFocusValue > nDefocusValueMax)
+			{
+				m_pRP2P->IRP2P_GetSequenceProcessor()->SendSignalToSignalControl(0, 3, 1000);
+			}
+
+		}
+	}
+	//#3524_210723_LYW_CF AOI Review 디포커스 알람 추가 및 FDC 보고 방식 개선 ADD End
 
 	return ReviewResult_Process_Complete;
 }
@@ -1451,7 +1523,6 @@
 
 	int nTestMode = FALSE;
 	
-	//시뮬 돌릴려는 이미지 파일 선택 20190827 chm
 	if(nTestMode){
 		Sleep(500);
 		CString strPathName;
@@ -1473,12 +1544,10 @@
 		return ReviewResult_Process_Fail;
 	}
 
-	// Snap 시간 저장.
 	CTime snapTime = CTime::GetCurrentTime();
 	pReviewResult->strSnapTime.Format(_T("%04d%02d%02d%02d%02d%02d"), snapTime.GetYear(), snapTime.GetMonth(), snapTime.GetDay(), 
 		snapTime.GetHour(), snapTime.GetMinute(), snapTime.GetSecond());	// snap_time
 
-	// 리뷰 업로드 이미지 파일 이름 만들기
 	CString strImageFileName = _T("");
 	if (MakeReflowImageFileName(pReviewResult)==FALSE)
 	{
@@ -1494,8 +1563,8 @@
 	}
 
 
-	reflowParam reParam; //Reflow 연산 정보 
-	reflowResult reResult;//Reflow 결과 정보
+	reflowParam reParam;  
+	reflowResult reResult;
 
 	//////////////////////////////////////////////////////////////////////////////////////////////
 	BOOL btFlag =0;
@@ -1507,10 +1576,10 @@
 	CCHImageData tempImage;
 	tempImageOrigin.CopyImageFrom(pImageData);
 
-	if(pReviewResult->nReflow_Side==7) // 바텀 연산
+	if(pReviewResult->nReflow_Side==7) 
 	{
 		btFlag=1;
-		CCHImageProcess::ImageRotate(pImageData,&tempImage,135);//바텀 이미지를 Right 회전 시켜 Right 연산 실행 
+		CCHImageProcess::ImageRotate(pImageData,&tempImage,135);
 		pImageData = &tempImage;
 		//reParam.nImageWidth = 2048;
 		//reParam.nImageHeight = 2432;
@@ -1620,9 +1689,9 @@
 
 	CCHImageData tmepData2;
 	if(btFlag==1){
-		CCHImageProcess::ImageRotate(pImageData,&tmepData2,135);//Right 연산후 다시 이미지 돌리기
+		CCHImageProcess::ImageRotate(pImageData,&tmepData2,135);
 		pImageData= &tmepData2;
-		//pImageData->SaveImage(_T("D:\\Testafter.bmp"));//Test 를 위한 bmp 저장
+		//pImageData->SaveImage(_T("D:\\Testafter.bmp"));
 	}
 
 
@@ -1647,17 +1716,15 @@
 			UINT64 nSize = SaveReviewImage(&uploadImage, strPath, m_nReviewImageSize, m_nReviewImageQuality, m_nReviewImageStep);
 			m_pRP2P->IRP2P_DisplayMessage(_T("Upload Review Image Save Success! Size: %d byte"), nSize);
 
-			//uploadImage.SaveImage(strPath, 40);  // 화질 60% 150k
+			//uploadImage.SaveImage(strPath, 40);  
 			if(GetReviewProcessStatus() == ReviewProcessStatus_ReflowStart)
 			{
-				// 업로드 이미지 경로 수정 20190917 chm
 				//strPath.Format(_T("%s\\%s\\%s"), m_strSaveImageUploadPath, m_strGlassID, pReviewResult->strUploadImgFileName);
 				strPath.Format(_T("%s\\%s"), m_strSaveImageUploadPath, pReviewResult->strUploadImgFileName);
 				nSize = SaveReviewImage(&uploadImage, strPath, m_nReviewImageSize, m_nReviewImageQuality, m_nReviewImageStep);
 
 				m_pRP2P->IRP2P_DisplayMessage(_T("Upload Reflow Image Save Success! Size: %d byte"), nSize);
 				
-				//시뮬돌리고 이미지 자동으로 열어줌 20190927chm
 				if(nTestMode)
 				{
 					CString csParam;
@@ -1677,7 +1744,6 @@
 		m_pRP2P->IRP2P_DisplayMessage(_T("Upload Reflow Image Save Fail![%s]"), pReviewResult->strUploadImgFileName);
 	}
 
-	//공유메모리 업데이트
 	if(!UpdateMemoryReflowPlan(pReviewResult))
 		m_pRP2P->IRP2P_DisplayMessage(_T("[ReflowPlan] Memory Update Fail!! DefectIdx : %d"), pReviewResult->nDefectidx2);
 
@@ -1889,8 +1955,6 @@
 }
 
 
-
-//파일명 181227 cmark
 BOOL CReviewProcessor_CPJT::MakeReviewImageFileName(SReviewResult* pReviewResult)
 {
 	if (m_pRP2P==NULL || pReviewResult==NULL) return FALSE;
@@ -1903,7 +1967,7 @@
 
 	if(GetReviewProcessStatus() == ReviewProcessStatus_ReviewStart)
 	{
-		// [2017:6:5]-[WEZASW] : Review Image 파일명에 '*' 사용 금지.(예외처리)
+		// [2017:6:5]-[WEZASW] : Review Image 
 		if (pReviewResult->strDefectCode.Compare(_T("***")) == 0)
 			strDefectCodeTemp = _T("DC");	
 		else 
@@ -1994,23 +2058,23 @@
 		snapTime.GetHour(), snapTime.GetMinute(), snapTime.GetSecond());	// snap_time
 
 
-	// [2017:4:10]-[WEZASW] : 고객사 요청에 의한 bmp 파일 추가 저장. (임시사용)
+	// [2017:4:10]-[WEZASW] : 
 	pReviewResult->strOrignalImgFileName = strFileName + _T(".bmp");
 
 	strFileName += _T(".jpg");
 	pReviewResult->strUploadImgFileName = strFileName;
 	pReviewResult->strImgFileName = strFileName;
+	pReviewResult->strImgFilePath = GetReviewUploadImagePath();
 	return TRUE;
 }
 
 
 int	CReviewProcessor_CPJT::ProcessWSIReflow(int nThreadIdx, SReviewResult* pReviewResult)
 {
-	// [2016:11:15]-[WEZASW] : 점검 필요
+	// [2016:11:15]-[WEZASW] : 
 	if(!UpdateMemoryWsiReflowPlan(pReviewResult))
 		m_pRP2P->IRP2P_DisplayMessage(_T("[WsiReflowPlan] Memory Update Fail!! DefectIdx : %d"), pReviewResult->nDefectidx2);
 
-	// wsi용 return 값으로 수정 [6/20/2017 bhs]
 	return WsiResultSuccess;
 }
 
@@ -2054,7 +2118,7 @@
 	
 	if(GetReviewProcessStatus() == ReviewProcessStatus_UserStart)
 	{
-		// [2017:6:5]-[WEZASW] : Review Image 파일명에 '*' 사용 금지.(예외처리)
+		// [2017:6:5]-[WEZASW] : Review Image 
 		if (pReviewResult->strDefectCode.Compare(_T("***")) == 0)
 			strDefectCodeTemp = _T("DC");	
 		else 
@@ -2148,12 +2212,13 @@
 	// 		strFileName += pReviewResult->strSnapTime;
 	// 	}
 
-	// [2017:4:10]-[WEZASW] : 고객사 요청에 의한 bmp 파일 추가 저장. (임시사용)
+	// [2017:4:10]-[WEZASW] : 
 	pReviewResult->strOrignalImgFileName = strFileName + _T(".bmp");
 
 	strFileName += _T(".jpg");
 	pReviewResult->strUploadImgFileName = strFileName;
 	pReviewResult->strImgFileName = strFileName;
+	pReviewResult->strImgFilePath = GetReviewUploadImagePath();
 	return TRUE;
 }
 
@@ -2224,13 +2289,11 @@
 
 void CReviewProcessor_CPJT::LoadAoiImage(const CString& strGlassID, int nOpticType, int nPosX, int nPosY, CCHImageData* pAoiDark, CCHImageData *pAoiBright)
 {
-	// 3. 검사 결함 이미지 찾기
 	CString strAoiDarkPath = _T("");
 	CString strAoiBrightPath = _T("");
 
 	FindAoiDefectImagePath(strGlassID, nOpticType, nPosX, nPosY, strAoiDarkPath, strAoiBrightPath);
 
-	// Dark, Bright 모두 찾기 위해 주석처리 [2017.7.1 bhs]
 	// Dark image
 	//if(nOpticType & DEFECT_OPTIC_DARK)
 	{
@@ -2275,7 +2338,6 @@
 	CFileFind finder;
 	CString strSearchPath = _T("");
 
-	// Dark, Bright 모두 찾기 위해 주석처리 [2017.7.1 bhs]
 	//if (nOpticType & DEFECT_OPTIC_DARK)
 	{
 		// Dark field
@@ -2349,7 +2411,6 @@
 			processTimer.End();
 		}
 
-		// 4-3. 리뷰평균 밝기
 		double dAverageGray = 0.0;
 		if (CCHImageProcess::ImageAverage(&bandImage, dAverageGray)==1)
 		{
@@ -2386,14 +2447,12 @@
 	CCHImageData pReviewCam;
 	CCHImageData tempImage1;
 	
-	// 설정값 이미지 회전
 	if (m_nImageRotate > 0)
 	{
 		tempImage1.CopyImageFrom(pReviewCamSource);
 		CCHImageProcess::ImageRotate(pReviewCamSource, &tempImage1, (90.0*m_nImageRotate));
 	}
 
-	// 설정값 이미지 반전
 	if (m_nimageFlip > 0)
 	{
 		if(m_nImageRotate > 0)
@@ -2430,7 +2489,6 @@
 
 	// set total size * scale
 	int nTotalWidth		= int(m_nReviewResizeWidth * m_dReviewImageScale + 0.5);
-	// 20170817 smok Dark, Bright 이미지가 리뷰 이미지 아래에 붙도록 수정
 	int nTotalHeight	= int(m_nReviewResizeHeight * m_dReviewImageScale + 0.5 + max(pAoiDark2.GetHeight(), pAoiBright2.GetHeight()));
 	int nTotalHeight2	= int(m_nReviewResizeHeight * m_dReviewImageScale + 0.5);
 
@@ -2456,14 +2514,13 @@
 	double dRulerGab = 20.0 / m_dReviewImageScale;
 	double dScaleResolution = pReviewResult->dMeasureResolution / m_dReviewImageScale;
 
-	//DrawRuler(&memDC, nTotalWidth, nTotalHeight2, dScaleResolution, dRulerGab); // resolution, ruler gab //taek 210127 사용 X
+	//DrawRuler(&memDC, nTotalWidth, nTotalHeight2, dScaleResolution, dRulerGab); // resolution, ruler gab //taek 210127 
 
 	// draw text string
 	DrawDefectInfo(&memDC, findResult, pReviewResult);
 	
 	//DrawAoiImage(&memDC, &pAoiDark2, &pAoiBright2, &pAoiDark2, &pAoiBright2, nAoiWidth, nAoiHeight);
 
-	// draw line 히팅 검증용
 	//DrawCenterLine(&memDC, nTotalWidth, nTotalHeight);
    // DrawCenterRect(&memDC, nTotalWidth, nTotalHeight, 100, 100, pReviewResult->dMeasureResolution);
 
@@ -2491,7 +2548,7 @@
 
 	nWidthDark = nHeightDark = nWidthBright = nHeightBright = 0;
 
-	// 20170817 smok Dark, Bright 이미지가 리뷰 이미지 아래에 붙도록 수정
+	// 20170817 smok Dark, Bright
 	// dark
 	CCHImageData subImage;
 	if(pAoiDark!=NULL && pAoiDark->GetImageExist())
@@ -2572,11 +2629,9 @@
 	int nTotalWidth		= int(m_nReviewResizeWidth * m_dReviewImageScale + 0.5);
 	int nTotalHeight	= int(m_nReviewResizeHeight * m_dReviewImageScale + 0.5);
 
-	// Dark, Bright 이미지가 나란히 붙도록 수정, Dark 위, Bright 아래 - 고객사 요청[2017.6.30 bhs]
 	//int nX = nTotalWidth - nWidth;
 	//int nY = nTotalHeight - (nHeight * 2);
 
-	// 20170817 smok Dark, Bright 이미지가 리뷰 이미지 아래에 붙도록 수정
 	int nX = 0;
 	int nY = nTotalHeight;
 	pAoiDark1->ShowImage(pDC->m_hDC, nX, nY, pAoiDark1->GetWidth(), pAoiDark1->GetHeight(), 0, 0);
@@ -2584,7 +2639,6 @@
 	//pAoiDark1->ShowImage(pDC->m_hDC,	nTotalWidth - nWidth,	nTotalHei4ght-nHeight,	pAoiDark1->GetWidth(), pAoiDark1->GetHeight(), 0, 0);
 	//pAoiBright1->ShowImage(pDC->m_hDC,	nTotalWidth - nWidth,	nTotalHeight-nHeight,	pAoiBright1->GetWidth(), pAoiBright1->GetHeight(), 0, 0);
 
-	// 검사 이미지 중앙에 화살표 표시 - 고객사 요청 [2017.6.30 bhs]
 	CFont Font;
 	VERIFY(Font.CreateFont(
 		50,                        // nHeight
@@ -2808,7 +2862,6 @@
 	else {
 		wchar_t  pstrPrefix[128] ={};
 
-		//Zone 넘버 210127
 		int nValue = 0;
 		for (int i = 15; i >= 0; i--)
 		{
@@ -2819,8 +2872,6 @@
 		}
 
 		//taek 210127
-		//결과파일 좌표값 y 는 *-1을 하자
-		//설비 ID, 검사 카메라 정보, 검사 Camera 정보 : (? ) 캠 ?, Cell ID,	Review Cam 정보 : Gantry 정보,	검출 Size,	검출 Zone 정보,	Stak Flag, CODE 정보, 좌표 정보
 		
 		// PPID
 // 		strValue.Format(_T("Tool[%s].Recipe[%s].ScanNo[%d/%d].Time[%4d/%2d/%2d_%d:%d:%d].MaxGray[%d].RefGray[%d].REVCnt[%d]"),pReviewResult->strEquipID,pGlassResult->m_strPPID,pReviewResult->nAOIScanIdx,0,snapTime.GetYear(), snapTime.GetMonth(), snapTime.GetDay(),
@@ -3035,7 +3086,7 @@
 
 	if(GetReviewProcessStatus() == ReviewProcessStatus_ReflowStart)
 	{
-		// [2017:6:5]-[WEZASW] : Review Image 파일명에 '*' 사용 금지.(예외처리)
+		// [2017:6:5]-[WEZASW] : Review Image 
 		if (pReviewResult->strDefectCode.Compare(_T("***")) == 0)
 			strDefectCodeTemp = _T("DC");	
 		else 
@@ -3112,7 +3163,7 @@
 	// 		strFileName += pReviewResult->strSnapTime;
 	// 	}
 
-	// [2017:4:10]-[WEZASW] : 고객사 요청에 의한 bmp 파일 추가 저장. (임시사용)
+	// [2017:4:10]-[WEZASW] : 
 	pReviewResult->strOrignalImgFileName = strFileName + _T(".bmp");
 
 	strFileName += _T(".jpg");
@@ -3158,7 +3209,6 @@
 	int nStartResultIdx	= pReviewResult->GetStartSReviewResultIndex();
 	int nEndResultIdx	= pReviewResult->GetEndSReviewResultIndex();
 
-	// 인덱스가 현재 마지막 인덱스 보다 클시..
 	if (nCurResultIdx > nEndResultIdx)  
 	{
 		LeaveCriticalSection(&m_csUserCriticalSection);
@@ -3166,7 +3216,6 @@
 		g_pLog->DisplayMessage(_T("[ReviewProcessor]SetWsiResultData module[%d] point[%d] result[%d]"), nModuleIndex, measureResut.nResultIndex, nCurResultIdx);
 	}
 
-	// 현재 결과데이터 저장
 	wsiResult.nWsi_ResultCode		= measureResut.nResultCode;
 	wsiResult.dWsi_DamDistance		= measureResut.dDamDistance;
 
@@ -3176,7 +3225,6 @@
 	}
 	//memcpy(wsiResult.nWsi_pReflowResultData, measureResut.pReflowResultData, sizeof(wsiResult.nWsi_pReflowResultData));
 	
-	// 결과 데이터 추가
 	SReviewResult *pProcessResult = NULL;
 	if (pGlassResult->SetWsiReflowResultData(nModuleIndex, nCurResultIdx, wsiResult, nGlassPosX, nGlassPosY, nMotorPosX, nMotorPosY, dTime))
 	{
@@ -3185,10 +3233,8 @@
 		pProcessResult = pReviewResult->GetSReviewResult(nCurResultIdx);
 	}
 
-	// 저장 성공시, 리뷰 프로세서에 포인터 전달
 	if (pProcessResult)
 	{
-		// 처리 쓰레드 수행
 		if (AddReviewProcessData(pProcessResult)==1)
 		{
 			g_pLog->DisplayMessage(_T("[ReviewProcessor]Add Wsi Reflow Process Data module[%d] result[%d]"), nModuleIndex, nCurResultIdx);
@@ -3204,7 +3250,6 @@
 
 	LeaveCriticalSection(&m_csUserCriticalSection);
 
-	// 결과 갱신.
 	m_pRP2P->IRP2P_UpdateReviewResult(nModuleIndex, pGlassResult, 5);
 	return;
 
@@ -3212,8 +3257,7 @@
 	g_pLog->DisplayMessage(_T("[ReviewProcessor]WsiResult FAIL! module[%d] result[%d]"), nModuleIndex, measureResut.nResultIndex);
 	return;
 }
-
-//0129cmark 원점 위치별 센터 좌표를 원점 좌표로 변형 
+ 
 double CReviewProcessor_CPJT::GetCentertoOrginCoordinate(double dPosX,double dPosY,int nCornercut,int nOriginDirection){
 
 	double nResultPosX=0.0;
@@ -3222,60 +3266,60 @@
 	// CornerCutDirection	{ CLeftTop=0, CRightTop, CLeftBottom,   CRightBottom };
 	// OriginDirection	{ OLeftTop=0, ORightTop, OLeftBottom,   ORightBottom };
 
-	if(nOriginDirection==RPOLeftTop){//오리진좌상
+	if(nOriginDirection==RPOLeftTop){
 
-		if(nCornercut == RPCLeftTop)//좌상 
+		if(nCornercut == RPCLeftTop)
 		{ 
 			nResultPosX = double(GLASS_SIZE_WIDTH)/2. - dPosX;
 			nResultPosY = double(GLASS_SIZE_HEIGHT)/2. - dPosY;
 
 		}
-		else if(nCornercut == RPCRightTop)//우상
+		else if(nCornercut == RPCRightTop)
 		{
 			nResultPosX = double(GLASS_SIZE_WIDTH)/2. - dPosX;
 			nResultPosY = double(GLASS_SIZE_HEIGHT)/2. + dPosY;
 
 		}
-		else if(nCornercut == RPCLeftBottom)//좌하
+		else if(nCornercut == RPCLeftBottom)
 		{
 			nResultPosX = double(GLASS_SIZE_WIDTH)/2. + dPosX;
 			nResultPosY = double(GLASS_SIZE_HEIGHT)/2. - dPosY;
 		}
-		else if(nCornercut == RPCRightBottom)//우하
+		else if(nCornercut == RPCRightBottom)
 		{
 			nResultPosX = double(GLASS_SIZE_WIDTH)/2 + dPosX;
 			nResultPosY = double(GLASS_SIZE_HEIGHT)/2 + dPosY;
 		}
 	}
 
-	else if(nOriginDirection==RPORightTop){//오리진우상
+	else if(nOriginDirection==RPORightTop){
 
-		if(nCornercut == RPCLeftTop)//좌상 
+		if(nCornercut == RPCLeftTop)
 		{ 
 			nResultPosX = double(GLASS_SIZE_WIDTH)/2. - dPosX;
 			nResultPosY = double(GLASS_SIZE_HEIGHT)/2. + dPosY;
 
 		}
-		else if(nCornercut == RPCRightTop)//우상
+		else if(nCornercut == RPCRightTop)
 		{
 			nResultPosX = double(GLASS_SIZE_WIDTH)/2. - dPosX;
 			nResultPosY = double(GLASS_SIZE_HEIGHT)/2. - dPosY;
 
 		}
-		else if(nCornercut == RPCLeftBottom)//좌하
+		else if(nCornercut == RPCLeftBottom)
 		{
 			nResultPosX = double(GLASS_SIZE_WIDTH)/2. + dPosX;
 			nResultPosY = double(GLASS_SIZE_HEIGHT)/2. + dPosY;
 		}
-		else if(nCornercut == RPCRightBottom)//우하
+		else if(nCornercut == RPCRightBottom)
 		{
 			nResultPosX = double(GLASS_SIZE_WIDTH)/2. + dPosX;
 			nResultPosY = double(GLASS_SIZE_HEIGHT)/2. - dPosY;
 		}
 	}
-	else if(nOriginDirection==RPOLeftBottom){//오리진좌하
+	else if(nOriginDirection==RPOLeftBottom){
 
-		if(nCornercut == RPCLeftTop)//좌상 
+		if(nCornercut == RPCLeftTop)
 		{ 
 			//210402
 		/*	nResultPosX = double(GLASS_SIZE_WIDTH)/2. + dPosX;
@@ -3284,13 +3328,13 @@
 			nResultPosX = double(GLASS_SIZE_WIDTH) / 2. + dPosX;
 			nResultPosY = double(GLASS_SIZE_HEIGHT) / 2. + dPosY;
 		}
-		else if(nCornercut == RPCRightTop)//우상
+		else if(nCornercut == RPCRightTop)
 		{
 			nResultPosX = double(GLASS_SIZE_WIDTH)/2. + dPosX;
 			nResultPosY = double(GLASS_SIZE_HEIGHT)/2. + dPosY;
 
 		}
-		else if(nCornercut == RPCLeftBottom)//좌하
+		else if(nCornercut == RPCLeftBottom)
 		{
 			//210402
 			/*nResultPosX = double(GLASS_SIZE_WIDTH)/2. - dPosX;
@@ -3298,33 +3342,33 @@
 			nResultPosX = double(GLASS_SIZE_WIDTH) / 2. + dPosX;
 			nResultPosY = double(GLASS_SIZE_HEIGHT) / 2. + dPosY;
 		}
-		else if(nCornercut == RPCRightBottom)//우하
+		else if(nCornercut == RPCRightBottom)
 		{
 			nResultPosX = double(GLASS_SIZE_WIDTH) / 2. - dPosX;
 			nResultPosY = double(GLASS_SIZE_HEIGHT) / 2. + dPosY;
 		}
 	}
 	else if (nOriginDirection==RPORightBottom)
-	{//오리진우하
+	{
 
-		if(nCornercut == RPCLeftTop)//좌상 
+		if(nCornercut == RPCLeftTop) 
 		{ 
 			nResultPosX = double(GLASS_SIZE_WIDTH)/2. + dPosX;
 			nResultPosY = double(GLASS_SIZE_HEIGHT)/2. + dPosY;
 
 		}
-		else if(nCornercut == RPCRightTop)//우상
+		else if(nCornercut == RPCRightTop)
 		{
 			nResultPosX = double(GLASS_SIZE_WIDTH)/2. + dPosX;
 			nResultPosY = double(GLASS_SIZE_HEIGHT)/2. - dPosY;
 
 		}
-		else if(nCornercut == RPCLeftBottom)//좌하
+		else if(nCornercut == RPCLeftBottom)
 		{
 			nResultPosX = double(GLASS_SIZE_WIDTH)/2. - dPosX;
 			nResultPosY = double(GLASS_SIZE_HEIGHT)/2. + dPosY;
 		}
-		else if(nCornercut == RPCRightBottom)//우하
+		else if(nCornercut == RPCRightBottom)
 		{
 			nResultPosX = double(GLASS_SIZE_WIDTH)/2. - dPosX;
 			nResultPosY = double(GLASS_SIZE_HEIGHT)/2. - dPosY;
@@ -3349,7 +3393,7 @@
 	CString strFileName = _T("");
 	CString strDefectCodeTemp = _T("");
 
-	// [2017:6:5]-[WEZASW] : Review Image 파일명에 '*' 사용 금지.(예외처리)
+	// [2017:6:5]-[WEZASW] : Review Image 
 	if (pReviewResult->strDefectCode.Compare(_T("***")) == 0)
 		strDefectCodeTemp = _T("DC");	
 	else 
@@ -3413,24 +3457,30 @@
 {
 	if(pReviewResult == NULL)	return FALSE;
 
-	//결과파일 공유 메모리 리뷰 이미지 이름 및 좌표 채워주기
 	CDitGlassRawClient *pDitGlassRawCleint = CDitGlassRawClient::GetInstance();
 	if(pDitGlassRawCleint->isConnect() == TRUE)
 	{
 		
 		_grmDefectData* pSharedDefect = pDitGlassRawCleint->GetDefectData(pReviewResult->nDefectidx2);
 		_grmDefectReviewData * pSharedDefectReview = &pSharedDefect->m_ReviewDefect;
+		_grmGlassData* pSharedGlassData = pDitGlassRawCleint->GetGlassData();
 		
 		//size_t CharactersConverted;
 		//wcstombs_s(&CharactersConverted, pSharedDefectReview->m_strRevImageName, pReviewResult->strImgFileName, _TRUNCATE);
 
 		strcpy(pSharedDefectReview->m_strRevImageName,pReviewResult->strImgFileName.MakeLower());
 		
+		//taek 210624 
 
-		pSharedDefectReview->m_nPlanType =  ditRaw::RPT_Review;	//0:None, 1:Location(User, Fiexed) Review, 4:reflower, ??:Wsi, 1000:AOI(외부 로컬 리뷰 명령)			
+		strcpy(pSharedDefectReview->m_strRevImagePath,pReviewResult->strImgFilePath.MakeLower());
+
+		strcpy(pSharedGlassData->m_strAlignFirst, m_strReviewFirst.MakeLower());
+		strcpy(pSharedGlassData->m_strAlignSecond, m_strReviewSecned.MakeLower());
+
+		pSharedDefectReview->m_nPlanType =  ditRaw::RPT_Review;	//0:None, 1:Location(User, Fiexed) Review, 4:reflower, ??:Wsi, 1000:AOI(			
 		pSharedDefectReview->m_nResultCode = 1;  //0:None, 1:Success
 		pSharedDefectReview->m_nShotIndex = pReviewResult->nResultIdx; 
-		//pSharedDefectReview->m_nShotIndex = GetPlanReviewCount(); //RTMS 기준에 따라 통합 관리면 요거 아니면 나눠서 하는 걸로 taek 210128
+		//pSharedDefectReview->m_nShotIndex = GetPlanReviewCount(); //RTMS taek 210128
 		pSharedDefectReview->m_nModuleIndex = pReviewResult->nModuleIdx;
 		pSharedDefectReview->m_nMagnificIndex = 20;
 		pSharedDefectReview->m_fManification =pReviewResult->dMagnification;
@@ -3444,11 +3494,10 @@
 
 BOOL CReviewProcessor_CPJT::UpdateMemoryUserPlan( SReviewResult* pReviewResult )
 {
-	//결과파일 공유 메모리 리뷰 이미지 이름 및 좌표 채워주기
 	CDitGlassRawClient *pDitRawClient = CDitGlassRawClient::GetInstance();
 	if(pDitRawClient->isConnect() == TRUE)
 	{
-		int nDefectCount = pDitRawClient->GetGlassData()->m_nDefectNum; // user,reflow 는 검사 디펙 이후 생성되기에 디펙 카운트보다 같거나 큰값을 가지고 있다
+		int nDefectCount = pDitRawClient->GetGlassData()->m_nDefectNum; // user,reflow 
 		if(pReviewResult->nDefectIdx <nDefectCount)
 		{	
 			return FALSE;
@@ -3461,14 +3510,16 @@
 		
 		strcpy(pSharedDefectReview->m_strRevImageName,pReviewResult->strImgFileName);
 	
-		pSharedDefectReview->m_nPlanType = ditRaw::RPT_User;	//0:None, 1:Location(User, Fiexed) Review, 4:reflower, ??:Wsi, 1000:AOI(외부 로컬 리뷰 명령)			
+		pSharedDefectReview->m_nPlanType = ditRaw::RPT_User;	//0:None, 1:Location(User, Fiexed) Review, 4:reflower, ??:Wsi, 1000:AOI(			
 		pSharedDefectReview->m_nResultCode = 1;  //0:None, 1:Success
 		pSharedDefectReview->m_nShotIndex = pReviewResult->nResultIdx; 
+		pSharedDefect->m_nShotIdx = pReviewResult->nResultIdx;
 		pSharedDefectReview->m_nModuleIndex;
+		pSharedDefect->m_nModelIdx = pReviewResult->nModuleIdx;
 		pSharedDefectReview->m_nMagnificIndex = pReviewResult->dMagnification;
 		pSharedDefectReview->m_fManification = pReviewResult->dMagnification;
 		pSharedDefectReview->m_fManificResoultion = pReviewResult->dMagnification;
-			m_pRP2P->IRP2P_DisplayMessage(_T("[공유메모리접근]인덱스[%d]파일명[%s]"),pReviewResult->nDefectidx2, pReviewResult->strUploadImgFileName);
+			m_pRP2P->IRP2P_DisplayMessage(_T("[Access Shared Memory]IDX[%d]Filename[%s]"),pReviewResult->nDefectidx2, pReviewResult->strUploadImgFileName);
 	}
 
 
@@ -3478,7 +3529,6 @@
 BOOL CReviewProcessor_CPJT::UpdateMemoryReflowPlan( SReviewResult* pReviewResult )
 {
 	if(pReviewResult == NULL)	return FALSE;
-	//결과파일 공유 메모리에 결과 채워 넣기
 	CDitGlassRawClient *pDitRawClient = CDitGlassRawClient::GetInstance();
 	//int nEqpID = m_pSP2P->ISP2P_System_GetSystemInfo()->m_nMachineType;
 	CString strCellID = _T("");
@@ -3500,7 +3550,6 @@
 				nReflowjuge=1;
 			}
 
-			// 고객사 요청으로 수정함. 0,1 Position은 Pass
 			else if(nReflowjuge == 3 || nReflowjuge == 2)
 			{
 				m_pRP2P->IRP2P_DisplayMessage(_T("[ReflowResult] Reflow Judge Is No OverFlow %d"),nReflowjuge);
@@ -3519,7 +3568,6 @@
 				nReflowjuge=0;
 			}
 			
-			//0:None, // 검출한 Line의 개수. 3 미만 : DAM2 Reflow 판정, 4~5 : DAM1 Reflow 판정, 6 : no Reflow 판정 / -1 : image not loaded, -2 : roi setting error, -3 : roi length error, -5 : select wrong side
 			if(pReviewResult->nReflow_CellIndex > 7)
 			{
 				pReviewResult->nReflow_CellIndex = 0;
@@ -3536,7 +3584,7 @@
 
 	if(pDitRawClient->isConnect() == TRUE)
 	{
-		int nDefectCount = pDitRawClient->GetGlassData()->m_nDefectNum; // user,reflow 는 검사 디펙 이후 생성되기에 디펙 카운트보다 같거나 큰값을 가지고 있다
+		int nDefectCount = pDitRawClient->GetGlassData()->m_nDefectNum; 
 		if(pReviewResult->nDefectidx2 <nDefectCount)
 		{
 			return FALSE;
@@ -3551,11 +3599,10 @@
 
 		pSharedDefectReview->m_nPlanType =  ditRaw::RTP_Reflow;			
 		pSharedDefectReview->m_nReflow_ResultCode = pReviewResult->nReflow_Result;// pReviewResult->nReflow_Result;  
-		//0:None, // 검출한 Line의 개수. 3 미만 : DAM2 Reflow 판정, 4~5 : DAM1 Reflow 판정, 6 : no Reflow 판정 / -1 : image not loaded, -2 : roi setting error, -3 : roi length error, -5 : select wrong side
 		//pSharedDefectReview->m_fReflow_LinePosData;	
 		pSharedDefectReview->m_nReflow_Side = pReviewResult->nReflow_Side;
 		pSharedDefectReview->m_nReflow_InspectionMode = 0;
-		m_pRP2P->IRP2P_DisplayMessage(_T("[공유메모리접근]인덱스[%d]파일명[%s]"),pReviewResult->nDefectidx2, pReviewResult->strUploadImgFileName);
+		m_pRP2P->IRP2P_DisplayMessage(_T("[Access Shared Memory]IDX[%d]Filename[%s]"),pReviewResult->nDefectidx2, pReviewResult->strUploadImgFileName);
 	}
 	
 	return TRUE;
@@ -3565,7 +3612,6 @@
 {
 	if(pReviewResult == NULL)	return FALSE;
 
-	//결과파일 공유 메모리에 결과 채워 넣기
 	CDitGlassRawClient *pDitGlassRawClient = CDitGlassRawClient::GetInstance();
 
 	if(pDitGlassRawClient->isConnect() == TRUE)
@@ -3582,7 +3628,7 @@
 
 		pSharedDefectReview->m_nPlanType =  ditRaw::RTP_WSI;			
 		pSharedDefectReview->m_nWsi_ResultCode=pReviewResult->nWsi_ResultCode; //0:None, 1:Success
-		pSharedDefectReview->m_nWsi_Type = 2;/* nWSIType;									// 함몰 / 돌기 //wsi 진행 */
+		pSharedDefectReview->m_nWsi_Type = 2;
 		pSharedDefectReview->m_fWsi_ResultData[0]= pReviewResult->nWsi_DefectType; // 0:normal 1:metal 2:huge 3:diffuse 4:trashy
 		pSharedDefectReview->m_fWsi_ResultData[1]=(float)(nWSIheight/1000.0); 
 		pSharedDefectReview->m_fWsi_ResultData[2]=(float)(nWSIWidth/1000.0);			// 0:Type, 1:Height, 2:Width
@@ -3592,7 +3638,7 @@
 		pSharedDefectReview->m_fWsi_ResultData[6] = pReviewResult->dBZoneHeight;
 		pSharedDefectReview->m_strWsi_2DImageFilename;
 		pSharedDefectReview->m_strWsi_3DImageFilename;
-		pSharedDefectReview->m_fWsiManification = 20;//20배 고정
+		pSharedDefectReview->m_fWsiManification = 20;
 		pSharedDefectReview->m_dWsiMmMotorX=pReviewResult->dTargetMotorX;
 		pSharedDefectReview->m_dWsiMmMotorY=pReviewResult->dTargetMotorY;
 		
@@ -3607,7 +3653,6 @@
 BOOL CReviewProcessor_CPJT::UpdateMemoryWsiReflowPlan( SReviewResult* pReviewResult )
 {
 	if(pReviewResult == NULL)	return FALSE;
-	//결과파일 공유 메모리에 결과 채워 넣기
 	CDitGlassRawClient *pDitRawClient = CDitGlassRawClient::GetInstance();
 	
 
@@ -3618,17 +3663,6 @@
 
 	int nWsiReflowResult = 0;
 	int nWsiReflowJudge = -1;
-
-	/*
-	pPacket->GetInt(0)			= Index
-	pPacket->GetInt(1)			= Wsi 측정 결과
-	pPacket->GetInt(2)			= A존 판정 결과 (1 성공 0 실패)
-	pPacket->GetInt(3)          = B존 판정 결과
-	pPacket->GetInt(4)          = C존 판정 결과
-	pPacket->GetInt(5)          = D존 판정 결과
-	pPacket->GetInt(6)          = Review에서 보내줬던 PointIndex
-	pPacket->GetDouble(0)       = 댐에서 Monomo까지의 거리
-	*/
 	
 // 	int nReflowjuge=0;
 // 	for(int nZone=2; nZone<6; nZone++)
@@ -3638,7 +3672,7 @@
 	
 	nWsiReflowJudge  = pReviewResult->nWsi_ResultCode;
 
-	//nWsiReflowResult += pReviewResult->nWsi_pReflowResultData[0] //A 1차 신경안씀 
+	//nWsiReflowResult += pReviewResult->nWsi_pReflowResultData[0] //A
 	nWsiReflowResult += pReviewResult->nWsi_pReflowResultData[1];//B
 	nWsiReflowResult += pReviewResult->nWsi_pReflowResultData[2];//C
 	//nWsiReflowResult += pReviewResult->nWsi_pReflowResultData[3];//D
@@ -3698,7 +3732,6 @@
 {
 	if(pReviewResult == NULL)	return FALSE;
 
-	//결과파일 공유 메모리에 결과 채워 넣기
 	CDitGlassRawClient *pDitGlassRawClient = CDitGlassRawClient::GetInstance();
 
 	if(pDitGlassRawClient->isConnect() == TRUE)
@@ -3715,13 +3748,13 @@
 
 		pSharedDefectReview->m_nPlanType =  ditRaw::RTP_UserWsi;			
 		pSharedDefectReview->m_nWsi_ResultCode=pReviewResult->nWsi_ResultCode; //0:None, 1:Success
-		pSharedDefectReview->m_nWsi_Type=nWSIType;									// 함몰 / 돌기
+		pSharedDefectReview->m_nWsi_Type=nWSIType;						
 		pSharedDefectReview->m_fWsi_ResultData[0]= nWSIType;
 		pSharedDefectReview->m_fWsi_ResultData[1]=(float)(nWSIheight/100.0);
 		pSharedDefectReview->m_fWsi_ResultData[2]=(float)(nWSIWidth/100.0);			// 0:Type, 1:Height, 2:Width
 		pSharedDefectReview->m_strWsi_2DImageFilename;
 		pSharedDefectReview->m_strWsi_3DImageFilename;
-		pSharedDefectReview->m_fWsiManification = 20;//20배 고정
+		pSharedDefectReview->m_fWsiManification = 20;
 		pSharedDefectReview->m_dWsiMmMotorX=pReviewResult->dTargetMotorX;
 		pSharedDefectReview->m_dWsiMmMotorY=pReviewResult->dTargetMotorY;
 	}
@@ -3733,7 +3766,6 @@
 {
 	if (pReviewResult == NULL)	return FALSE;
 
-	//결과파일 공유 메모리에 결과 채워 넣기
 	CDitGlassRawClient *pDitGlassRawClient = CDitGlassRawClient::GetInstance();
 
 	if (pDitGlassRawClient->isConnect() == TRUE)
@@ -3750,13 +3782,13 @@
 
 		pSharedDefectReview->m_nPlanType = ditRaw::RTP_WSI;
 		pSharedDefectReview->m_nWsi_ResultCode = pReviewResult->nWsi_ResultCode; //0:None, 1:Success
-		pSharedDefectReview->m_nWsi_Type = nWSIType;									// 함몰 / 돌기
+		pSharedDefectReview->m_nWsi_Type = nWSIType;								
 		pSharedDefectReview->m_fWsi_ResultData[0] = nWSIType;
 		pSharedDefectReview->m_fWsi_ResultData[1] = (float)(nWSIheight / 100.0);
 		pSharedDefectReview->m_fWsi_ResultData[2] = (float)(nWSIWidth / 100.0);			// 0:Type, 1:Height, 2:Width
 		pSharedDefectReview->m_strWsi_2DImageFilename;
 		pSharedDefectReview->m_strWsi_3DImageFilename;
-		pSharedDefectReview->m_fWsiManification = 20;//20배 고정
+		pSharedDefectReview->m_fWsiManification = 20;
 		pSharedDefectReview->m_dWsiMmMotorX = pReviewResult->dTargetMotorX;
 		pSharedDefectReview->m_dWsiMmMotorY = pReviewResult->dTargetMotorY;
 
@@ -3773,50 +3805,85 @@
 	BYTE *pImageBufferByte = (BYTE*)(pImageBuffer);
 	if (pImageBuffer==NULL) return 0.;
 
+	//#3524_210902_LYW_MOD START
 	int nWidth = nImageWidth;
+	//int nWidthStep = nImageWidth;
 	int nHeight = nImageHeight;
-	int nCalWidth = nWidth/2;
-	int nCalHeight = nHeight/2;
+	// 	int nCalWidth = nWidth/2;
+	// 	int nCalHeight = nHeight/2;
+	// 
+	// 	int nStartX = nWidth/2 - nCalWidth/2;
+	// 	int nStartY = nHeight/2 - nCalHeight/2;
 
-	int nStartX = nWidth/2 - nCalWidth/2;
-	int nStartY = nHeight/2 - nCalHeight/2;
+	int nCalWidth = nWidth;
+	int nCalHeight = nHeight;
 
-	//
-	double Focusvalue = 0;
-	double SumValue = 0;
-	double TempValue = 0;
-	double m_nResultFocusValue = 0;
+	int nStartX = 0;
+	int nStartY = 0;
 
-	// 원점 XY 기준 X+1, Y+1에 대한 차영상
-	for (int y = 0; y < nHeight - 1; y++)
+	int nStep = 3;
+
+	double dXValue = 0., dYValue = 0., dCurr = 0., dSum = 0., dFocus = 0.;
+	for (int nH = nStartY; nH < nStartY + nCalHeight - nStep; nH++)
 	{
-		for (int x = 0; x < nWidth - 1; x++)
+		for (int nW = nStartX; nW < nStartX + nCalWidth - nStep; nW++)
 		{
-			TempValue = (double)(pImageBufferByte[y*nWidth + x] - pImageBufferByte[y*nWidth + x + 1]);
-			SumValue = TempValue * TempValue;
-			TempValue = (double)(pImageBufferByte[y*nWidth + x] - pImageBufferByte[(y + 1)*nWidth + x]);
-			SumValue += TempValue * TempValue;
-
-			Focusvalue += sqrt(SumValue);
-			//Focusvalue += SumValue;
-		}
-	}
-
-	m_nResultFocusValue = int(Focusvalue / (double)(nWidth*nHeight));
-
-	double dXValue=0., dYValue=0., dCurr=0., dSum=0., dFocus=0.;
-	for(int nH=nStartY ; nH<nStartY+nCalHeight-1 ; nH++)
-	{
-		for(int nW=nStartX ; nW<nStartX+nCalWidth-1 ; nW++)
-		{
-			dXValue = float((pImageBufferByte[nH*nW + nW+1] - pImageBufferByte[nH*nW + nW])*(pImageBufferByte[nH*nW + nW+1] - pImageBufferByte[nH*nW + nW]));
-			dYValue = float((pImageBufferByte[(nH+1)*nW + nW] - pImageBufferByte[nH*nW + nW])*(pImageBufferByte[(nH+1)*nW + nW] - pImageBufferByte[nH*nW + nW]));
+			dXValue = float((pImageBufferByte[nH*nWidth + nW + nStep] - pImageBufferByte[nH*nWidth + nW])*(pImageBufferByte[nH*nWidth + nW + nStep] - pImageBufferByte[nH*nWidth + nW]));
+			dYValue = float((pImageBufferByte[(nH + nStep)*nWidth + nW] - pImageBufferByte[nH*nWidth + nW])*(pImageBufferByte[(nH + nStep)*nWidth + nW] - pImageBufferByte[nH*nWidth + nW]));
 			dCurr = sqrt(dXValue + dYValue);
+			//break;
+
 			dSum += dCurr;
 		}
 	}
-	dFocus = dSum/double(nCalWidth*nCalHeight);
+	dFocus = dSum / double(nCalWidth*nCalHeight);
 
 	return dFocus;
+	//#3524_210902_LYW_MOD END
+	//Origin
+// 	int nWidth = nImageWidth;
+// 	int nHeight = nImageHeight;
+// 	int nCalWidth = nWidth/2;
+// 	int nCalHeight = nHeight/2;
+// 
+// 	int nStartX = nWidth/2 - nCalWidth/2;
+// 	int nStartY = nHeight/2 - nCalHeight/2;
+// 
+// 	//
+// 	double Focusvalue = 0;
+// 	double SumValue = 0;
+// 	double TempValue = 0;
+// 	double m_nResultFocusValue = 0;
+// 
+// 	for (int y = 0; y < nHeight - 1; y++)
+// 	{
+// 		for (int x = 0; x < nWidth - 1; x++)
+// 		{
+// 			TempValue = (double)(pImageBufferByte[y*nWidth + x] - pImageBufferByte[y*nWidth + x + 1]);
+// 			SumValue = TempValue * TempValue;
+// 			TempValue = (double)(pImageBufferByte[y*nWidth + x] - pImageBufferByte[(y + 1)*nWidth + x]);
+// 			SumValue += TempValue * TempValue;
+// 
+// 			Focusvalue += sqrt(SumValue);
+// 			//Focusvalue += SumValue;
+// 		}
+// 	}
+// 
+// 	m_nResultFocusValue = int(Focusvalue / (double)(nWidth*nHeight));
+// 
+// 	double dXValue=0., dYValue=0., dCurr=0., dSum=0., dFocus=0.;
+// 	for(int nH=nStartY ; nH<nStartY+nCalHeight-1 ; nH++)
+// 	{
+// 		for(int nW=nStartX ; nW<nStartX+nCalWidth-1 ; nW++)
+// 		{
+// 			dXValue = float((pImageBufferByte[nH*nW + nW+1] - pImageBufferByte[nH*nW + nW])*(pImageBufferByte[nH*nW + nW+1] - pImageBufferByte[nH*nW + nW]));
+// 			dYValue = float((pImageBufferByte[(nH+1)*nW + nW] - pImageBufferByte[nH*nW + nW])*(pImageBufferByte[(nH+1)*nW + nW] - pImageBufferByte[nH*nW + nW]));
+// 			dCurr = sqrt(dXValue + dYValue);
+// 			dSum += dCurr;
+// 		}
+// 	}
+// 	dFocus = dSum/double(nCalWidth*nCalHeight);
+// 
+// 	return dFocus;
 }
 

--
Gitblit v1.9.3