SDC C-Project CF Review 프로그램
ReviewSystem/ReviewSystem/ReviewProcessor_CPJT.cpp
@@ -5,16 +5,44 @@
#include "CameraControlReview.h"
#include "CHImageControls/CHImageProcess.h"
#include "CHMotorControls/MotorControl.h"
#include "CHSignalControls/SignalControl.h"
#include "CHEdgeTriangle/EdgeTriangle.h"
#include "CHEdgeTriangle/RecipeManager.h"
#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;
@@ -43,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)
@@ -88,7 +122,6 @@
   int nEndResultIdx   = pReviewResult->GetEndSReviewResultIndex();
                  
   
   // �ε����� ���� ������ �ε��� ���� Ŭ��..
   if (nCurResultIdx > nEndResultIdx)  
   {
      LeaveCriticalSection(&m_csUserCriticalSection);
@@ -96,8 +129,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 +169,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 +176,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 +190,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 +199,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 +216,6 @@
   
   LeaveCriticalSection(&m_csUserCriticalSection);
   // 占쏙옙占?占쏙옙占쏙옙.
   m_pRP2P->IRP2P_UpdateReviewResult(nModuleIndex, pGlassResult);
   return;
@@ -238,7 +261,6 @@
   int nEndResultIdx   = pReviewResult->GetEndSReviewResultIndex();
   // �ε����� ���� ������ �ε��� ���� Ŭ��..
   if (nCurResultIdx > nEndResultIdx)  
   {
      LeaveCriticalSection(&m_csUserCriticalSection);
@@ -246,14 +268,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 +283,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 +300,6 @@
   LeaveCriticalSection(&m_csUserCriticalSection);
   // 占쏙옙占?占쏙옙占쏙옙.
   m_pRP2P->IRP2P_UpdateReviewResult(nModuleIndex, pGlassResult);
   return;
@@ -337,7 +354,6 @@
   int nEndResultIdx = pReviewResult->GetEndSReviewResultIndex();
   // �ε����� ���� ������ �ε��� ���� Ŭ��..
   if (nCurResultIdx > nEndResultIdx)
   {
      LeaveCriticalSection(&m_csUserCriticalSection);
@@ -345,7 +361,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 +368,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 +377,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 +393,6 @@
   }
   LeaveCriticalSection(&m_csUserCriticalSection);
   // 占쏙옙占?占쏙옙占쏙옙.
   m_pRP2P->IRP2P_UpdateReviewResult(nModuleIndex, pGlassResult);
   return;
@@ -457,7 +467,6 @@
   int nStartResultIdx   = pReviewResult->GetStartSReviewResultIndex();
   int nEndResultIdx   = pReviewResult->GetEndSReviewResultIndex();
   
   // �ε����� ���� ������ �ε��� ���� Ŭ��..
   if (nCurResultIdx > nEndResultIdx)  
   {
      LeaveCriticalSection(&m_csUserCriticalSection);
@@ -465,7 +474,6 @@
      g_pLog->DisplayMessage(_T("[ReviewProcessor]SetReviewResultData module[%d] point[%d] result[%d]"), nModuleIndex, nResultIndex, nCurResultIdx);
   }
   // 占쏙옙占쏙옙 占쏙옙占쏙옙譴占쏙옙占?占쏙옙占쏙옙
   SReviewResult *pProcessResult = NULL;
   switch(GetReviewProcessStatus())
   {
@@ -509,10 +517,8 @@
      break;
   }
   // ���� ������, ���� ���μ����� ������ ����
   if (pProcessResult)
   {
      // ó�� ������ ����
      if (AddReviewProcessData(pProcessResult)==1)
      {
         g_pLog->DisplayMessage(_T("[ReviewProcessor]Add Process Data module[%d] result[%d]"), nModuleIndex, nCurResultIdx); 
@@ -526,9 +532,7 @@
      pReviewResult->SetLastSReviewResultIndex(nCurResultIdx);
   }
      LeaveCriticalSection(&m_csUserCriticalSection);
      //占쏙옙占쏙옙 占쏙옙占?占쏙옙占쏙옙占쏙옙占쏙옙占쏙옙트 占쏙옙占쏙옙占쏙옙 占쏙옙占쌔뱄옙占쏙옙占쏙옙 占싣뤄옙 占쏙옙占쏙옙占쏙옙 占쏙옙타占쏙옙 占쌕쏙옙 占쏙옙占쏙옙占쏙옙표 占싫쏙옙占쏙옙
      // ��ȣó�� �ʿ��� �̰� ����
      if (nCurResultIdx + 1== pReviewResult->GetSReviewResultCount())
      {
         if (nModuleIndex == 0)
@@ -542,7 +546,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 +571,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 +602,6 @@
      }
      
      // 占쏙옙占쏙옙占쏙옙 占쏙옙占쏙옙트占쏙옙占쏙옙 占쌉곤옙, 占쏙옙占쏙옙占쏙옙 占쏙옙占쏙옙占?占쏙옙占쏙옙 占쏙옙占쏙옙占쏙옙...
      if(nCurResultIdx==nEndResultIdx && nCurResultIdx+1 < pReviewResult->GetSReviewResultCount())
       {
@@ -624,8 +624,7 @@
      pReviewResult->SetStartSReviewResultIndex(nStartResultIdx);
      pReviewResult->SetEndSReviewResultIndex(nEndResultIdx);
      // ������ ����Ʈ ���� ��������.
      ::Sleep(3000); // 占쏙옙占쏙옙甄占?占십쇽옙占쏙옙. 占쏙옙占쏙옙占쏙옙 占쏙옙占쏙옙 占쏙옙占쏙옙.
      ::Sleep(3000);
         if (bLeftGantryReviewDone&&bRightGantryReviewDone)
         {
         
@@ -685,7 +684,6 @@
      }
   }
   // 占쏙옙占?占쏙옙占쏙옙.
   m_pRP2P->IRP2P_UpdateReviewResult(nModuleIndex, pGlassResult, m_nReviewPlanIndex);
   return;
@@ -729,7 +727,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 +734,6 @@
      return 1;
   }
   // ����Ȯ��
   if (pGlassResult->CheckReviewComplete())
   {
      // check motor ready!
@@ -763,7 +759,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 +766,6 @@
      return 1;
   }
   // ����Ȯ��
   if (pGlassResult->CheckUserComplete())
   {
      m_pRP2P->IRP2P_DisplayMessage(_T("User Last Point Complete! "));
@@ -796,7 +790,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 +797,6 @@
      return 1;
   }
   // ����Ȯ��
   if (pGlassResult->CheckReflowComplete())
   {
      m_pRP2P->IRP2P_DisplayMessage(_T("Reflow Last Point Complete! "));
@@ -829,7 +821,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 +828,6 @@
      return 1;
   }
   // ����Ȯ��
   if (pGlassResult->CheckWsiComplete())
   {
      m_pRP2P->IRP2P_DisplayMessage(_T("Wsi Last Point Complete! "));
@@ -863,7 +853,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 +860,6 @@
      return 1;
   }
   // ����Ȯ��
   if (pGlassResult->CheckMeasureComplete())
   {
      m_pRP2P->IRP2P_DisplayMessage(_T("Measure Last Point Complete! "));
@@ -900,7 +888,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 +895,6 @@
      return 1;
   }
   // ����Ȯ��
   if (pGlassResult->CheckWsiReflowComplete())
   {
      m_pRP2P->IRP2P_DisplayMessage(_T("Wsi Reflow Last Point Complete! "));
@@ -932,7 +918,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 +925,6 @@
      return 1;
   }
   // ����Ȯ��
   if (pGlassResult->CheckWsiUserComplete())
   {
      m_pRP2P->IRP2P_DisplayMessage(_T("Wsi Last Point Complete! "));
@@ -965,7 +949,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 +956,6 @@
      return 1;
   }
   // ����Ȯ��
   if (pGlassResult->CheckWsiMultiShotComplete())
   {
      m_pRP2P->IRP2P_DisplayMessage(_T("WsiMultiShot Last Point Complete! "));
@@ -1138,23 +1120,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,7 +1156,6 @@
      //   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);
@@ -1193,7 +1170,7 @@
               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); //taek 210128 �ӵ� ������ �ӽ÷� �α� ������ ����
            else m_pRP2P->IRP2P_DisplayMessage(_T("RTMS Review Image Save Success! Size: %d byte [%s] index[%d]"), nSize, strRTMSPath, pReviewResult->nDefectIdx);
         }
         if (nSize > 0)
@@ -1237,7 +1214,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)
     {
@@ -1278,22 +1255,41 @@
           }
        }
        if (pReviewResult->nModuleIdx == 0)
        if (pReviewResult->nModuleIdx == 0 && m_pRP2P->IRP2P_GetFirstReviewLeft())
        {
           m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview00ImageContrast = dFocusValue;
           /* double dAverageGray = 0.0;
            if (CCHImageProcess::ImageAverage(pImageData, dAverageGray) == 1)
            {
               m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview00ImageContrast = dAverageGray;
            }*/
     }
        else
           const CSignalControlInfo* pSignalInfo = m_pRP2P->IRP2P_GetReviewSignalinfo();
           int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
           int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
           //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);
           if (dFocusValue < nDefocusValueMin || dFocusValue > nDefocusValueMax)
           {
              m_pRP2P->IRP2P_GetSequenceProcessor()->SendSignalToSignalControl(0, 3, 1000);
           }
        }
        else if(pReviewResult->nModuleIdx == 1 && m_pRP2P->IRP2P_GetFirstReviewRight())
        {
           m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview01ImageContrast = dFocusValue;
           const CSignalControlInfo* pSignalInfo = m_pRP2P->IRP2P_GetReviewSignalinfo();
           int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
           int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
           //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);
           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.;
@@ -1311,15 +1307,42 @@
         dFocusValue = CalcFocusValue(imageConvert.GetImageBuffer(), imageConvert.GetWidth(), imageConvert.GetHeight());
      }
      if (pReviewResult->nModuleIdx == 0)
      if (pReviewResult->nModuleIdx == 0 && m_pRP2P->IRP2P_GetFirstReviewLeft())
      {
         m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview00ImageContrast = dFocusValue;
         const CSignalControlInfo* pSignalInfo = m_pRP2P->IRP2P_GetReviewSignalinfo();
         int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
         int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
         //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);
         if (dFocusValue < nDefocusValueMin || dFocusValue > nDefocusValueMax)
         {
            m_pRP2P->IRP2P_GetSequenceProcessor()->SendSignalToSignalControl(0, 3, 1000);
         }
      }
      else
      else if (pReviewResult->nModuleIdx == 1 && m_pRP2P->IRP2P_GetFirstReviewRight())
      {
         m_pRP2P->IRP2P_GetCurrentGlassResult()->nReview01ImageContrast = dFocusValue;
         const CSignalControlInfo* pSignalInfo = m_pRP2P->IRP2P_GetReviewSignalinfo();
         int nDefocusValueMin = pSignalInfo->GetDefocusValueMin();
         int nDefocusValueMax = pSignalInfo->GetDefocusValueMax();
         //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);
         if (dFocusValue < nDefocusValueMin || dFocusValue > nDefocusValueMax)
         {
            m_pRP2P->IRP2P_GetSequenceProcessor()->SendSignalToSignalControl(0, 3, 1000);
         }
      }
   }
   //#3524_210723_LYW_CF AOI Review 디포커스 알람 추가 및 FDC 보고 방식 개선 MOD End
   
   
@@ -1339,12 +1362,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)
   {
@@ -1356,8 +1377,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;
@@ -1376,10 +1395,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);
@@ -1401,7 +1419,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)
      {
@@ -1424,9 +1442,43 @@
         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_SetReview00ImageContrast(round(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_SetReview01ImageContrast(round(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)
@@ -1446,6 +1498,59 @@
      }
   }
   //#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_SetReview00ImageContrast(round(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_SetReview01ImageContrast(round(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;
}
@@ -1459,7 +1564,6 @@
   int nTestMode = FALSE;
   
   //�ù� �������� �̹��� ���� ���� 20190827 chm
   if(nTestMode){
      Sleep(500);
      CString strPathName;
@@ -1481,12 +1585,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)
   {
@@ -1502,8 +1604,8 @@
   }
   reflowParam reParam; //Reflow ���� ����
   reflowResult reResult;//Reflow 占쏙옙占?占쏙옙占쏙옙
   reflowParam reParam;
   reflowResult reResult;
   //////////////////////////////////////////////////////////////////////////////////////////////
   BOOL btFlag =0;
@@ -1515,10 +1617,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;
@@ -1628,9 +1730,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"));
   }
@@ -1655,17 +1757,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;
@@ -1685,7 +1785,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);
@@ -1897,8 +1996,6 @@
}
//���ϸ� 181227 cmark
BOOL CReviewProcessor_CPJT::MakeReviewImageFileName(SReviewResult* pReviewResult)
{
   if (m_pRP2P==NULL || pReviewResult==NULL) return FALSE;
@@ -1911,7 +2008,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 
@@ -2002,7 +2099,7 @@
      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");
@@ -2015,11 +2112,10 @@
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;
}
@@ -2063,7 +2159,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 
@@ -2157,7 +2253,7 @@
   //       strFileName += pReviewResult->strSnapTime;
   //    }
   // [2017:4:10]-[WEZASW] : 占쏙옙占쏙옙占?占쏙옙청占쏙옙 占쏙옙占쏙옙 bmp 占쏙옙占쏙옙 占쌩곤옙 占쏙옙占쏙옙. (占쌈시삼옙占?
   // [2017:4:10]-[WEZASW] :
   pReviewResult->strOrignalImgFileName = strFileName + _T(".bmp");
   strFileName += _T(".jpg");
@@ -2234,13 +2330,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)
   {
@@ -2285,7 +2379,6 @@
   CFileFind finder;
   CString strSearchPath = _T("");
   // Dark, Bright 占쏙옙占?찾占쏙옙 占쏙옙占쏙옙 占쌍쇽옙처占쏙옙 [2017.7.1 bhs]
   //if (nOpticType & DEFECT_OPTIC_DARK)
   {
      // Dark field
@@ -2359,7 +2452,6 @@
         processTimer.End();
      }
      // 4-3. 占쏙옙占쏙옙占쏙옙占?占쏙옙占?
      double dAverageGray = 0.0;
      if (CCHImageProcess::ImageAverage(&bandImage, dAverageGray)==1)
      {
@@ -2396,14 +2488,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)
@@ -2440,7 +2530,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);
@@ -2466,14 +2555,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);
@@ -2501,7 +2589,7 @@
   nWidthDark = nHeightDark = nWidthBright = nHeightBright = 0;
   // 20170817 smok Dark, Bright �̹����� ���� �̹��� �Ʒ��� �ٵ��� ����
   // 20170817 smok Dark, Bright
   // dark
   CCHImageData subImage;
   if(pAoiDark!=NULL && pAoiDark->GetImageExist())
@@ -2582,11 +2670,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);
@@ -2594,7 +2680,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
@@ -2615,7 +2700,7 @@
   CFont *pOldFont = pDC->SelectObject(&Font);
   pDC->SetTextColor(RGB(255,0,0));
   CString strArrow = _T("��");
   CString strArrow = _T("↗");
   CSize size = pDC->GetTextExtent(strArrow);
   int nCenterX = nX + (nWidth / 2) - size.cx;
   int nCenterY = nY + (nHeight / 2)/* + (size.cy / 2)*/;
@@ -2818,7 +2903,6 @@
   else {
      wchar_t  pstrPrefix[128] ={};
      //Zone �ѹ� 210127
      int nValue = 0;
      for (int i = 15; i >= 0; i--)
      {
@@ -2829,8 +2913,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(),
@@ -3045,7 +3127,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 
@@ -3122,7 +3204,7 @@
   //       strFileName += pReviewResult->strSnapTime;
   //    }
   // [2017:4:10]-[WEZASW] : 占쏙옙占쏙옙占?占쏙옙청占쏙옙 占쏙옙占쏙옙 bmp 占쏙옙占쏙옙 占쌩곤옙 占쏙옙占쏙옙. (占쌈시삼옙占?
   // [2017:4:10]-[WEZASW] :
   pReviewResult->strOrignalImgFileName = strFileName + _T(".bmp");
   strFileName += _T(".jpg");
@@ -3168,7 +3250,6 @@
   int nStartResultIdx   = pReviewResult->GetStartSReviewResultIndex();
   int nEndResultIdx   = pReviewResult->GetEndSReviewResultIndex();
   // �ε����� ���� ������ �ε��� ���� Ŭ��..
   if (nCurResultIdx > nEndResultIdx)  
   {
      LeaveCriticalSection(&m_csUserCriticalSection);
@@ -3176,7 +3257,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;
@@ -3186,7 +3266,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))
   {
@@ -3195,10 +3274,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);
@@ -3214,7 +3291,6 @@
   LeaveCriticalSection(&m_csUserCriticalSection);
   // 占쏙옙占?占쏙옙占쏙옙.
   m_pRP2P->IRP2P_UpdateReviewResult(nModuleIndex, pGlassResult, 5);
   return;
@@ -3222,8 +3298,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;
@@ -3232,60 +3307,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;
@@ -3294,13 +3369,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;
@@ -3308,33 +3383,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;
@@ -3359,7 +3434,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 
@@ -3423,7 +3498,6 @@
{
   if(pReviewResult == NULL)   return FALSE;
   //占쏙옙占쏙옙占쏙옙占?占쏙옙占쏙옙 占쌨몌옙 占쏙옙占쏙옙 占싱뱄옙占쏙옙 占싱몌옙 占쏙옙 占쏙옙표 채占쏙옙占쌍깍옙
   CDitGlassRawClient *pDitGlassRawCleint = CDitGlassRawClient::GetInstance();
   if(pDitGlassRawCleint->isConnect() == TRUE)
   {
@@ -3437,17 +3511,17 @@
      strcpy(pSharedDefectReview->m_strRevImageName,pReviewResult->strImgFileName.MakeLower());
      
      //taek 210624 ���� ���� �� ���ش�.
      //taek 210624
      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_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;
@@ -3461,11 +3535,10 @@
BOOL CReviewProcessor_CPJT::UpdateMemoryUserPlan( SReviewResult* pReviewResult )
{
   //占쏙옙占쏙옙占쏙옙占?占쏙옙占쏙옙 占쌨몌옙 占쏙옙占쏙옙 占싱뱄옙占쏙옙 占싱몌옙 占쏙옙 占쏙옙표 채占쏙옙占쌍깍옙
   CDitGlassRawClient *pDitRawClient = CDitGlassRawClient::GetInstance();
   if(pDitRawClient->isConnect() == TRUE)
   {
      int nDefectCount = pDitRawClient->GetGlassData()->m_nDefectNum; // user,reflow �� �˻� ���� ���� �����DZ⿡ ���� ī��Ʈ���� ���ų� ū���� ������ �ִ�
      int nDefectCount = pDitRawClient->GetGlassData()->m_nDefectNum; // user,reflow
      if(pReviewResult->nDefectIdx <nDefectCount)
      {   
         return FALSE;
@@ -3478,7 +3551,7 @@
      
      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;
@@ -3487,7 +3560,7 @@
      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);
   }
@@ -3497,7 +3570,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("");
@@ -3519,7 +3591,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);
@@ -3538,7 +3609,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;
@@ -3555,7 +3625,7 @@
   if(pDitRawClient->isConnect() == TRUE)
   {
      int nDefectCount = pDitRawClient->GetGlassData()->m_nDefectNum; // user,reflow �� �˻� ���� ���� �����DZ⿡ ���� ī��Ʈ���� ���ų� ū���� ������ �ִ�
      int nDefectCount = pDitRawClient->GetGlassData()->m_nDefectNum;
      if(pReviewResult->nDefectidx2 <nDefectCount)
      {
         return FALSE;
@@ -3570,11 +3640,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;
@@ -3584,7 +3653,6 @@
{
   if(pReviewResult == NULL)   return FALSE;
   //占쏙옙占쏙옙占쏙옙占?占쏙옙占쏙옙 占쌨모리울옙 占쏙옙占?채占쏙옙 占쌍깍옙
   CDitGlassRawClient *pDitGlassRawClient = CDitGlassRawClient::GetInstance();
   if(pDitGlassRawClient->isConnect() == TRUE)
@@ -3601,7 +3669,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
@@ -3611,7 +3679,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;
      
@@ -3626,7 +3694,6 @@
BOOL CReviewProcessor_CPJT::UpdateMemoryWsiReflowPlan( SReviewResult* pReviewResult )
{
   if(pReviewResult == NULL)   return FALSE;
   //占쏙옙占쏙옙占쏙옙占?占쏙옙占쏙옙 占쌨모리울옙 占쏙옙占?채占쏙옙 占쌍깍옙
   CDitGlassRawClient *pDitRawClient = CDitGlassRawClient::GetInstance();
   
@@ -3637,17 +3704,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++)
@@ -3657,7 +3713,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
@@ -3717,7 +3773,6 @@
{
   if(pReviewResult == NULL)   return FALSE;
   //占쏙옙占쏙옙占쏙옙占?占쏙옙占쏙옙 占쌨모리울옙 占쏙옙占?채占쏙옙 占쌍깍옙
   CDitGlassRawClient *pDitGlassRawClient = CDitGlassRawClient::GetInstance();
   if(pDitGlassRawClient->isConnect() == TRUE)
@@ -3734,13 +3789,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;
   }
@@ -3752,7 +3807,6 @@
{
   if (pReviewResult == NULL)   return FALSE;
   //占쏙옙占쏙옙占쏙옙占?占쏙옙占쏙옙 占쌨모리울옙 占쏙옙占?채占쏙옙 占쌍깍옙
   CDitGlassRawClient *pDitGlassRawClient = CDitGlassRawClient::GetInstance();
   if (pDitGlassRawClient->isConnect() == TRUE)
@@ -3769,13 +3823,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;
@@ -3792,50 +3846,121 @@
   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);
   if (dFocus >= 10.0) dFocus = 10.0;
   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;
}
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;
}