From c70166f3e86ffd0528884911483c067a6b21ebdd Mon Sep 17 00:00:00 2001
From: kojingeun <diteam.co.kr>
Date: 금, 30 6월 2023 15:48:59 +0900
Subject: [PATCH] Ongoing60 #4517 CF AOI Review 결과 파일 찾기 실패 개선 1. AOIServer RawBin 폴더 연결 TimerThread 추가  - file_dummy 생성 후 Open/Close 반복(10초) 2. 프로젝트 누락 경로 및 설정 추가  - FTPUploader Include Path, Debug모드 psapi.lib

---
 ReviewSystem/ReviewSystem/ReviewProcessor_CPJT.cpp |   97 +++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 87 insertions(+), 10 deletions(-)

diff --git a/ReviewSystem/ReviewSystem/ReviewProcessor_CPJT.cpp b/ReviewSystem/ReviewSystem/ReviewProcessor_CPJT.cpp
index e5c5bcf..9c8d564 100644
--- a/ReviewSystem/ReviewSystem/ReviewProcessor_CPJT.cpp
+++ b/ReviewSystem/ReviewSystem/ReviewProcessor_CPJT.cpp
@@ -12,10 +12,37 @@
 #include "CHReviewRecipe/RsRcpReviewInfo.h"
 #include "DitGlassRawClient.h"
 #include "LineChecker/LineChecker.h"
+
+#include <fstream> /* < KJG 20230630 - #4517 ADD >*/
 enum StackInfo { Stack_Unknown = 0, Stack_TD, Stack_SD, Stack_PD, Stack_SP, Stack_CD };
 using namespace CHImageControls;
 
-CReviewProcessor_CPJT::CReviewProcessor_CPJT(int nThreadCount) : CReviewProcessor(nThreadCount)
+const CString AOIRAWBIN_PATH = _T("\\\\126.100.100.1\\d\\DIT_ResultData\\RawBin");
+
+CString GetFormatMessageString(DWORD dwError) /* < KJG 20230630 - #4517 ADD >*/
+{
+	LPVOID lpMsgBuf;
+
+	FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
+		| FORMAT_MESSAGE_FROM_SYSTEM
+		| FORMAT_MESSAGE_IGNORE_INSERTS
+		, NULL
+		, dwError
+		, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)
+		, (LPTSTR)&lpMsgBuf
+		, 0
+		, NULL
+	);
+
+	CString str;
+	str.Format(_T("%s"), lpMsgBuf);
+
+	LocalFree(lpMsgBuf);
+	return str;
+}
+
+CReviewProcessor_CPJT::CReviewProcessor_CPJT(int nThreadCount) 
+	: CReviewProcessor(nThreadCount)
 {
 	bProcessSuccess[CPJT_REVIEW_SUCCESS] = FALSE;
 	bProcessSuccess[CPJT_MEASURE_SUCCESS] = FALSE;
@@ -44,6 +71,12 @@
 	ErrorStringCode[17].Insert(17,_T("CircleCoefficientFail"));
 	ErrorStringCode[18].Insert(18,_T("ProcessSuccess"));
 	ErrorStringCode[19].Insert(19,_T("ProcessNone"));
+	
+	/* < KJG 20230630 - #4517 ADD Start >*/
+	CString strDummyFilePath;
+	strDummyFilePath.Format(_T("%s\\file_dummy"), AOIRAWBIN_PATH);
+	m_threadFileMonitor.StartThread();
+	/* < KJG 20230630 - #4517 ADD End >*/
 }
 
 CReviewProcessor_CPJT::~CReviewProcessor_CPJT(void)
@@ -1228,7 +1261,8 @@
 			  int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
 			  int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
 
-			  m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview00ImageContrast = dFocusValue;
+			  //m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview00ImageContrast = dFocusValue;
+			  m_pRP2P->IRP2P_SetReview00ImageContrast(round(dFocusValue));
 			  m_pRP2P->IRP2P_SetFirstReviewLeft(FALSE);
 			  m_pRP2P->IRP2P_DisplayMessage(_T("FirstReviewLeft FDC FocusValue = %.2f "), dFocusValue);
 
@@ -1243,7 +1277,8 @@
 			  int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
 			  int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
 
-			  m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview01ImageContrast = dFocusValue;
+			  //m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview01ImageContrast = dFocusValue;
+			  m_pRP2P->IRP2P_SetReview01ImageContrast(round(dFocusValue));
 			  m_pRP2P->IRP2P_SetFirstReviewRight(FALSE);
 			  m_pRP2P->IRP2P_DisplayMessage(_T("FirstReviewRight FDC FocusValue = %.2f "), dFocusValue);
 
@@ -1278,7 +1313,8 @@
 			int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
 			int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
 
-			m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview00ImageContrast = dFocusValue;
+			//m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview00ImageContrast = dFocusValue;
+			m_pRP2P->IRP2P_SetReview00ImageContrast(round(dFocusValue));
 			m_pRP2P->IRP2P_SetFirstReviewLeft(FALSE);
 			m_pRP2P->IRP2P_DisplayMessage(_T("FirstReviewLeft FDC FocusValue = %.2f "), dFocusValue);
 			
@@ -1294,7 +1330,8 @@
 			int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
 			int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
 
-			m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview01ImageContrast = dFocusValue;
+			//m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview01ImageContrast = dFocusValue;
+			m_pRP2P->IRP2P_SetReview01ImageContrast(round(dFocusValue));
 			m_pRP2P->IRP2P_SetFirstReviewRight(FALSE);
 			m_pRP2P->IRP2P_DisplayMessage(_T("FirstReviewRight FDC FocusValue = %.2f "), dFocusValue);
 
@@ -1412,7 +1449,8 @@
 					int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
 					int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
 
-					m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview00ImageContrast = dFocusValue;
+					//m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview00ImageContrast = dFocusValue;
+					m_pRP2P->IRP2P_SetReview00ImageContrast(round(dFocusValue));
 					m_pRP2P->IRP2P_SetFirstReviewLeft(FALSE);
 					m_pRP2P->IRP2P_DisplayMessage(_T("FirstReviewLeft FDC FocusValue = %.2f "), dFocusValue);
 
@@ -1427,7 +1465,8 @@
 					int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
 					int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
 
-					m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview01ImageContrast = dFocusValue;
+					//m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview01ImageContrast = dFocusValue;
+					m_pRP2P->IRP2P_SetReview01ImageContrast(round(dFocusValue));
 					m_pRP2P->IRP2P_SetFirstReviewRight(FALSE);
 					m_pRP2P->IRP2P_DisplayMessage(_T("FirstReviewRight FDC FocusValue = %.2f "), dFocusValue);
 
@@ -1483,7 +1522,8 @@
 			int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
 			int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
 
-			m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview00ImageContrast = dFocusValue;
+			//m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview00ImageContrast = dFocusValue;
+			m_pRP2P->IRP2P_SetReview00ImageContrast(round(dFocusValue));
 			m_pRP2P->IRP2P_SetFirstReviewLeft(FALSE);
 			m_pRP2P->IRP2P_DisplayMessage(_T("FirstReviewLeft FDC FocusValue = %.2f "), dFocusValue);
 
@@ -1498,7 +1538,8 @@
 			int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
 			int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
 
-			m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview01ImageContrast = dFocusValue;
+			//m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview01ImageContrast = dFocusValue;
+			m_pRP2P->IRP2P_SetReview01ImageContrast(round(dFocusValue));
 			m_pRP2P->IRP2P_SetFirstReviewRight(FALSE);
 			m_pRP2P->IRP2P_DisplayMessage(_T("FirstReviewRight FDC FocusValue = %.2f "), dFocusValue);
 
@@ -3831,12 +3872,14 @@
 			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;
+			//break;
 
 			dSum += dCurr;
 		}
 	}
 	dFocus = dSum / double(nCalWidth*nCalHeight);
+
+	if (dFocus >= 10.0) dFocus = 10.0;
 
 	return dFocus;
 	//#3524_210902_LYW_MOD END
@@ -3887,3 +3930,37 @@
 // 	return dFocus;
 }
 
+CTimerThreadFileMonitor::CTimerThreadFileMonitor(DWORD dwPeriod /*=10000*/, int nThreadCount /*=1*/)
+	: CTimerThreadPools(dwPeriod, nThreadCount), m_pLog(nullptr)
+{
+
+}
+
+void CTimerThreadFileMonitor::TimerThreadProcess(PVOID pParameter)
+{
+	if (m_strFilePath.IsEmpty())
+		return;
+
+	std::ofstream file(m_strFilePath);
+
+	if (file.is_open())
+	{
+
+	}
+	else
+	{
+		DWORD dwError = GetLastError();
+
+		if(m_pLog)
+			m_pLog->DisplayMessage(_T("[FileMonitor Thread] Abort! Error Code[%d][%s] File Path[%s]"), dwError, GetFormatMessageString(dwError), m_strFilePath);
+
+		AfxBeginThread([](LPVOID pParam)->UINT {
+			CTimerThreadFileMonitor *pMain = static_cast<CTimerThreadFileMonitor*>(pParam);
+			pMain->StopThread();
+
+			return 0;
+		}, this);
+	}
+
+	return;
+}
\ No newline at end of file

--
Gitblit v1.9.3