From 9aa3a8ff940e89bb0b5c75bc8abd0864e4c85874 Mon Sep 17 00:00:00 2001
From: LYW <leeyeanwoo@diteam.co.kr>
Date: 화, 17 8월 2021 10:00:15 +0900
Subject: [PATCH] 이전 머지간 누락된 코드 삽입

---
 ReviewHistory/ReveiwHistory/GlassRawCSOT.cpp | 1696 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1,696 insertions(+), 0 deletions(-)

diff --git a/ReviewHistory/ReveiwHistory/GlassRawCSOT.cpp b/ReviewHistory/ReveiwHistory/GlassRawCSOT.cpp
new file mode 100644
index 0000000..c10d4fe
--- /dev/null
+++ b/ReviewHistory/ReveiwHistory/GlassRawCSOT.cpp
@@ -0,0 +1,1696 @@
+#include "StdAfx.h"
+#include "GlassRawCSOT.h"
+#include "akLoggerExt.h"
+#include "MacroResultFile.h"
+#include "akCore/akFileUtil.h"
+#include "akGridData.h"
+
+//#include "AOIDefinitionType.h"
+//#include "AOIDefinition.h"
+ 
+#define	FTPCopyDataCmd_RawDownload		1
+#define	FTPCopyDataCmd_RawUpload			2
+#define	FTPCopyDataCmd_LotUpload			3
+#define	FTPCopyDataCmd_ImageUpload		4
+
+#define MAX_PATH_NUM				255
+#define MAX_FILE_NUM				100
+
+#define LOCAL_INDEX_PATH			"D:\\DIT_ResultData\\Index\\"	  
+#define LOCAL_REV_IMAGE_PATH		"D:\\ResultData\\Upload\\Image\\" 
+#define LOCAL_AOI_IMAGE_PATH		"D:\\Image\\Defect\\" 
+#define LOCAL_MURA_IMAGE_PATH		"D:\\DIT_ResultData\\Mura\\IMG\\" 
+#define LOCAL_DEEP_PATH				"D:\\DIT_ResultData\\Deeplearning\\"
+
+enum FTPProcessType { FTPProcessType_DownFile=0, FTPProcessType_UpFile, FTPProcessType_Count };
+class CFTPCopyDataParam
+{
+public:
+	CFTPCopyDataParam()				{ Reset(); }
+	virtual ~CFTPCopyDataParam()	{ Reset(); }
+	void Reset()
+	{
+		memset(this, 0, sizeof(CFTPCopyDataParam));
+		m_hSenderWnd = GetCurrentProcessWndHandle();
+	}
+
+	const HWND	GetSenderWnd() const						{ return m_hSenderWnd; }
+	void		SetSenderWnd(HWND hWnd)						{ m_hSenderWnd = hWnd; }
+
+public:
+	int		m_nProcessType;								// 프로세스 타입
+	int 	m_nCreateSignalFile;						// 시그널 파일 생성유무
+	int		m_bFirstPriority;							// 최상위 우선순위유무
+	int		m_nSendResultCode;							// 보낸 결과 코드
+
+	TCHAR	m_strServer_FolderName[MAX_PATH_NUM];		// 서버 경로명
+	TCHAR	m_strServer_FileName[MAX_FILE_NUM];			// 서버 파일명
+
+	TCHAR	m_strLocal_FolderName[MAX_PATH_NUM];		// 로컬 경로명
+	TCHAR	m_strLocal_FileName[MAX_FILE_NUM];			// 로컬 파일명
+
+	TCHAR	m_strServer_SignalFolderName[MAX_PATH_NUM];	// 서버 시그널 경로명
+	TCHAR	m_strServer_SignalFileName[MAX_FILE_NUM];	// 서버 시그널 파일명
+
+protected:
+	HWND	m_hSenderWnd;								// 보낸 프로그램 윈도우
+
+	static HWND GetCurrentProcessWndHandle()
+	{
+		DWORD dwPID = GetCurrentProcessId();
+		HWND hWnd = FindWindow(NULL, NULL);
+		while (hWnd != NULL)
+		{
+			if (GetParent(hWnd) == NULL){
+				DWORD dwProcId;
+				GetWindowThreadProcessId(hWnd, &dwProcId);
+				if (dwPID == dwProcId){
+					return hWnd;
+				}
+			}
+			hWnd = GetWindow(hWnd, GW_HWNDNEXT);
+		}
+		return NULL;
+	}
+};
+
+
+CGlassRawCSOT::CGlassRawCSOT(void)
+{
+	m_GlassRawRTMS.SetMuraResult(&m_MuraResultFile);
+}
+
+CGlassRawCSOT::~CGlassRawCSOT(void)
+{
+}
+
+BOOL CGlassRawCSOT::SequenceGlassLoading( CgrmGlassRawData* pData )
+{
+	if(m_StackResult.getStackUse())
+	{
+		SendMessageFTPDownloadStack(pData->GetGlassData()); //스택파일 다운 요청 [김태현 2019/1/12]
+		m_StackResult.StackFileReadStart(pData->GetGlassData()->m_strGlassID);
+	}
+
+	SendMessageFTPDownloadDataFile(pData->GetGlassData());
+	return TRUE;
+}
+
+BOOL CGlassRawCSOT::SequenceInspectEnd( CgrmGlassRawData* pData )
+{
+	m_tmReviewEnd = m_tmReviewStart = CTime::GetCurrentTime();
+
+
+	if(m_StackResult.getStackUse())
+	{
+		m_StackResult.StackFileReadStop();
+	}
+
+	ReadMuraFile(pData);
+	
+	if(0) //이제 end시점에 파일 생성하지 않음(파일시간때문에 두번 올라갈수잇음) [김태현 2019/1/15]
+	{
+		if(!WriteAOIFile(pData))
+			return FALSE;
+
+		SendMessageFTPUploadRaw(pData->GetGlassData());
+	}
+	
+	return TRUE;
+}
+
+BOOL CGlassRawCSOT::SequenceReviewStart( CgrmGlassRawData* pData )
+{
+	m_tmReviewStart = m_tmReviewEnd = CTime::GetCurrentTime();
+
+	SequenceCustomizeReview(pData);
+	
+
+	return TRUE;
+}
+
+
+BOOL CGlassRawCSOT::SequenceCustomizeReview( CgrmGlassRawData* pData )
+{
+	_grmGlassData* pGlass = pData->GetGlassData();
+	/*
+	//이전 생성된 커스터 마이징 데이터 삭제
+	{
+		pGlass->m_nDefectNum;
+		for(int i=pGlass->m_nDefectNum-1; i>=0; i--)
+		{
+			if(pData->GetDefectData(i)->m_nCustomizeDefectType == 0
+				|| pData->GetDefectData(i)->m_nCustomizeDefectType == 1000)
+			{
+				pGlass->m_nDefectNum = i+1;
+				break;
+			}
+		}
+	}
+
+	//커스터마이즈 데이터 로드
+	{
+		if(m_CustomizeReview.openFile(pGlass->m_strRecipeName))
+		{
+			pGlass->m_nCustomizePlanType = m_CustomizeReview.GetCustomizeType();
+			int nCustomReviewNum = m_CustomizeReview.GetCustomizeReviewNum();
+
+			int nDefectStpoint = pGlass->m_nDefectNum;
+			if(pGlass->m_nCustomizePlanType == 2) nDefectStpoint = 0;
+			int nRealDefectIndex;
+			_grmDefectData* pGrmDefect;
+			_CustomizeReview* pCustomizeReview;
+			for(int i=0; i<nCustomReviewNum; i++)
+			{
+				nRealDefectIndex = nDefectStpoint+i;
+				pGrmDefect = pData->GetDefectData(nRealDefectIndex);
+				pCustomizeReview = m_CustomizeReview.GetCustomizeReivew(i);
+
+				pGrmDefect->m_nCustomizeDefectType	 = pCustomizeReview->m_nCustomizeDefectType;
+				pGrmDefect->m_dCustomizeDefectPosXmm = pCustomizeReview->m_dCustomizeDefectPosXmm;
+				pGrmDefect->m_dCustomizeDefectPosYmm = pCustomizeReview->m_dCustomizeDefectPosYmm;
+				pGrmDefect->m_nCustomizeParam1 = pCustomizeReview->m_nCustomizeParam1;
+				pGrmDefect->m_nCustomizeParam2 = pCustomizeReview->m_nCustomizeParam2;
+			}
+			pGlass->m_nDefectNum = nDefectStpoint+nCustomReviewNum;
+
+			pGlass->m_nCustomizeDataReadResult = 1;
+		}
+		else
+		{
+			pGlass->m_nCustomizeDataReadResult = 2;
+		}
+	}
+
+	if(pGlass->m_nCustomizeDataReadResult == 1) return TRUE;
+	*/
+
+	return FALSE;
+}
+
+
+BOOL CGlassRawCSOT::SequenceReviewEnd( CgrmGlassRawData* pData )
+{ 
+	m_tmReviewEnd = CTime::GetCurrentTime();
+
+	if(WriteAOIFile(pData) == FALSE)
+		return FALSE;
+
+	_grmGlassData* pGlassData = pData->GetGlassData();
+	SendMessageFTPUploadRaw(pGlassData);
+	SendMessageFTPUploadImage(pGlassData, FTPCMD_REVIEW_IMAGE);
+	SendMessageFTPUploadImage(pGlassData, FTPCMD_AOI_IMAGE); 
+	if(m_MuraResultFile.IsRead()) SendMessageFTPUploadImage(pGlassData, FTPCMD_MURA_IMAGE);
+	SendMessageFTPUploadLinkFile(pGlassData);
+
+	if(WriteIndexFile(pGlassData))
+	{
+		SendMessageFTPUploadIndexFile(pGlassData);
+	}
+	
+	return TRUE;
+}
+
+BOOL CGlassRawCSOT::SequenceFtpUpload( char* pRawFilePathName )
+{
+
+	CTime tmFileCreate; 
+	_grmGlassData GlassData;
+	_grmGlassData* pGlassData = &GlassData;
+
+	//정보 얻어오기 [김태현 2019/1/25]
+	{
+		//"D:\\DIT_ResultData\\Raw\\";
+		//6CCF01P7_HPANELID_20190125_002545.csv
+
+		char* pFileName = CakFileUtil::getFileName(pRawFilePathName);
+		char* pext = CakFileUtil::getFileExt(pRawFilePathName);
+
+		if(!strcmp(pext, "csv") == FALSE) return FALSE;
+
+		CakParser parser;
+		parser.process(pFileName, "_.");
+		if(parser.getTokNum() < 5) return FALSE;
+
+		strcpy(pGlassData->m_strOperID, parser.getTokStr(0));
+		strcpy(pGlassData->m_strGlassID, parser.getTokStr(1));
+		char* pDate = &pFileName[parser.getTokPos(2)];
+		char* pTime = &pFileName[parser.getTokPos(3)];
+		int nData[8]={};
+		nData[0] = (pDate[0]-'0')*1000 + (pDate[1]-'0')*100 + (pDate[2]-'0')*10+ (pDate[3]-'0')*1;
+		nData[1] = (pDate[4]-'0')*10+ (pDate[5]-'0')*1;
+		nData[2] = (pDate[6]-'0')*10+ (pDate[7]-'0')*1;
+		nData[3] = (pTime[0]-'0')*10+ (pTime[1]-'0')*1;
+		nData[4] = (pTime[2]-'0')*10+ (pTime[3]-'0')*1;
+		nData[5] = (pTime[4]-'0')*10+ (pTime[5]-'0')*1;
+
+		CTime tmTemp(nData[0], nData[1], nData[2], nData[3], nData[4], nData[5] );
+		tmFileCreate = tmTemp;
+
+		FILE* pf = fopen(pRawFilePathName, "r");
+		if(pf)
+		{
+			char buffer[512];
+			fgets(buffer, 512, pf);
+			if(buffer[0] != 'H') return FALSE;
+			fgets(buffer, 512, pf);
+			fgets(buffer, 512, pf);
+
+			fgets(buffer, 512, pf);buffer[strlen(buffer)-1] = 0;
+			strcpy(pGlassData->m_strEquipID, &buffer[strlen("EQUIP_TYPE:")]);
+
+			fgets(buffer, 512, pf);buffer[strlen(buffer)-1] = 0;
+			strcpy(pGlassData->m_strStepID, &buffer[strlen("EQUIP_ID:")]);
+		}
+		else
+		{
+			return FALSE;
+		}
+
+
+		CakFileUtil::getPath(pGlassData->m_strPath, 256, pRawFilePathName);
+
+	}
+
+
+
+	m_tmReviewEnd = m_tmReviewStart = tmFileCreate;
+
+ 
+	SendMessageFTPUploadRaw(pGlassData);
+	SendMessageFTPUploadImage(pGlassData, FTPCMD_REVIEW_IMAGE);
+	SendMessageFTPUploadImage(pGlassData, FTPCMD_AOI_IMAGE); 
+	SendMessageFTPUploadImage(pGlassData, FTPCMD_MURA_IMAGE);//없으면 실패 하겠지
+	SendMessageFTPUploadLinkFile(pGlassData);
+
+	if(WriteIndexFile(pGlassData))
+	{
+		SendMessageFTPUploadIndexFile(pGlassData);
+	}
+
+	return TRUE;
+}
+
+
+BOOL CGlassRawCSOT::WriteAOIFile( CgrmGlassRawData* pData )
+{
+	BOOL bResult = TRUE;
+	
+	bResult &= MakeAOIFile(pData);
+	bResult &= MakeAnaFile(pData);
+
+	m_GlassRawRTMS.WriteAOIFile(pData);
+
+	AKLOG("WriteAOIFile Complete");
+	return bResult;
+}
+
+BOOL CGlassRawCSOT::MakeAOIFile( CgrmGlassRawData* pData )
+{
+	_grmGlassData* pGlass = pData->GetGlassData();
+	CString strFilePathName;
+	CString strFileName;//파일생성 시간 때문에 여기서 정확하게 파일명 다시 정정
+	{
+		//Glass 정보
+		CTime CurrTime = m_tmReviewEnd;
+		CString strTime;
+		strTime.Format(_T("%04d%02d%02d_%02d%02d%02d"),
+			CurrTime.GetYear(), CurrTime.GetMonth(), CurrTime.GetDay(), CurrTime.GetHour(), CurrTime.GetMinute(), CurrTime.GetSecond());
+		strFileName.Format("%s_%s_%s.csv", pGlass->m_strOperID, pGlass->m_strGlassID, strTime.GetBuffer(0));
+	}
+	
+	strFilePathName.Format("%s\\%s", pGlass->m_strPath, strFileName);//pGlass->m_strFileName);
+	//strFilePathName.Format("C:\\AOIServer\\NFS\\RAW\\%s", pData->GetGlassData()->m_strFileName);
+	
+	
+	//FILE* pf = fopen(strFilePathName.GetBuffer(0), "w");
+	FILE* pf = fopen(strFilePathName.GetBuffer(0), "w");
+	if(pf == NULL)
+	{
+		AKLOG("MakeAOIFile Fail : [%s]", strFilePathName.GetBuffer(0));
+		return FALSE;
+	}
+	
+	
+	
+	CString strBuffer;
+	CString strLine;
+
+	//////////////////////////////////////////////////////////////////////////
+	//HEDER
+	fprintf(pf, "HEADER_BEGIN\n");
+	{
+		makeDataHeader(strLine, pGlass);
+		fprintf(pf, "%s", strLine);
+	}
+	fprintf(pf, "HEADER_END\n\n");
+
+	//////////////////////////////////////////////////////////////////////////
+	//GLASS_DATA
+	fprintf(pf, "GLASS_DATA_BEGIN\n");
+	{
+		fprintf(pf, "GLASS_ID,OWNER_CODE,OWNER_TYPE,PRODUCT_ID,PROCESS_ID,PRODUCT_GROUP,LOT_ID,CST_ID,SLOT_ID,PRE_PROCESS_ID,PRE_EQP_ID,PRE_CHAMBER_ID,PRE_RECIPE_ID,GROUP_ID,AUTOSAMPLEFLAG\n");
+		
+		makeDataGlass(strLine, pGlass);
+		fprintf(pf, "%s\n", strLine);
+	}
+	fprintf(pf, "GLASS_DATA_END\n\n");
+
+	//////////////////////////////////////////////////////////////////////////
+	//EQP_GLASS_DATA
+	fprintf(pf, "EQP_GLASS_DATA_BEGIN\n");
+	{
+		fprintf(pf, "RECIPE_NO,RECIPE_NAME,START_TIME,END_TIME,TACT_TIME,GLASS_YIELD,TOTAL_PANEL_CNT,OK_PANEL,NG_PANEL,X1_PANEL,X2_PANEL,X3_PANEL,X4_PANEL,X5_PANEL,X6_PANEL,X7_PANEL,X8_PANEL,X9_PANEL,TT_DEFECT_CNT,S_SIZE_DEFECT_CNT,M_SIZE_DEFECT_CNT,L_SIZE_DEFECT_CNT,GLASS_ID_DCR,TT_MURA_CNT,POINT_MURA_CNT,LINE_MURA_CNT,AREA_MURA_CNT,POINT_1,POINT_2,POINT_3,POINT_4,POINT_5,GLASS_JUDGE,GLASS_GRADE\n");
+
+		makeDataEQPGlass(strLine, pData);
+		fprintf(pf, "%s\n", strLine);
+	}
+	fprintf(pf, "EQP_GLASS_DATA_END\n\n");
+
+	//////////////////////////////////////////////////////////////////////////
+	//BLOCK_SUMMARY
+	fprintf(pf, "BLOCK_SUMMARY_BEGIN\n");
+	{
+		fprintf(pf, "BLOCK_ID,BLOCK_JUDGE_AOI,BLOCK_JUDGE_MURA,BLOCK_JUDGE_ATS,BLOCK_JUDGE_TEG,TT_PANEL,OK_PANEL,NG_PANEL,X1_PANEL,X2_PANEL,X3_PANEL,X4_PANEL,X5_PANEL,X6_PANEL,X7_PANEL,X8_PANEL,X9_PANEL,TT_DEFECT_CNT,S_SIZE_DEFECT_CNT,M_SIZE_DEFECT_CNT,L_SIZE_DEFECT_CNT,TT_MURA_CNT,POINT_MURA_CNT,LINE_MURA_CNT,AREA_MURA_CNT,GLASS_ID_DCR,POINT_1,POINT_2,POINT_3,POINT_4,POINT_5\n");
+		
+		int nBlockNum = 1;
+		for(int i=0; i<nBlockNum; i++)
+		{
+			makeDataBlock(strLine, pData->GetBlockData(i));
+			fprintf(pf, "%s\n", strLine);
+		}
+	}
+	fprintf(pf, "BLOCK_SUMMARY_END\n\n");
+	
+	//////////////////////////////////////////////////////////////////////////
+	//PANEL_SUMMARY
+	fprintf(pf, "PANEL_SUMMARY_BEGIN\n");
+	{
+		fprintf(pf, "PANEL_ID,PANEL_JUDGE_AOI,PANEL_JUDGE_MURA,PANEL_JUDGE,TT_DEFECT,TT_MURA,PANEL_ID_2D,PANEL_FLAG,PANEL_GRADE,X_D,Y_D,X_A,Y_A,DELTA_X,DELTA_Y,OK_DEFECT,NG_DEFECT,X1_DEFECT,X2_DEFECT,X3_DEFECT,X4_DEFECT,X5_DEFECT,X6_DEFECT,X7_DEFECT,X8_DEFECT,X9_DEFECT,IJP1,IJP2,IJP3,IJP4,IJP5,IJP6,IJP7,IJP8,Mark1,Mark2,Mark3,Mark4,Mark5,Mark6,Mark7,Mark8\n");
+
+		for(int iCell = 0; iCell < pData->GetGlassData()->m_nCellNum; iCell++)
+		{
+			_grmCellData* pCell = pData->GetCellData(iCell);
+			makeDataCell(strLine, pData, pCell);	
+			fprintf(pf, "%s\n", strLine);
+		}
+	}
+	fprintf(pf, "PANEL_SUMMARY_END\n\n");
+	
+	//////////////////////////////////////////////////////////////////////////
+	//DEFECT_DATA
+	fprintf(pf, "DEFECT_DATA_BEGIN\n");
+	{
+		fprintf(pf, "PANEL_ID,DEFECT_NO1,DEFECT_NO2,UPDATE_TIME,STEP_1ST,RECIPE_1ST,STEP_CURRENT,RECIPE_CURRENT,GATE1,DATA1,");
+		fprintf(pf, "GATE2,DATA2,X1,Y1,X2,Y2,AOI_DEFECT_TYPE,AOI_GRAY_H,AOI_GRAY_L,AOI_GRAY_AVE,");
+		fprintf(pf, "AOI_DEFECT_AREA,AOI_DEFECT_LGT,AOI_DEFECT_WID,AOI_DEFECT_HGT,AOI_DEFECT_WIH,AOI_DEFECT_SIZE,DEFECT_PIX,MASK_DEFECT,REPEAT_DEFECT,DEFECT_IMAGE_DATA,");
+		fprintf(pf, "AOI_CCD_NO,AOI_REVIEW_NO,OP_ID_1ST,OP_ID_2ND,OP_ID_CURRENT,DEFECT_JUGDE_1ST,DEFECT_JUGDE_2ND,DEFECT_JUGDE_CURRENT,DEFECT_REASON1,DEFECT_REASON2,");
+		fprintf(pf, "DEFECT_REASON3,WSI_JUDGE,MURA_GRAY_H,MURA_GRAY_L,MURA_GRAY_AVE,MURA_AREA,MURA_LGT,MURA_WID,MURA_HGT,MURA_SIZE,");
+		fprintf(pf, "MURA_PIX,MURA_TYPE,MURA_JUDGE,MURA_GRADE,MURA_IMAGE_DATA,RSRV1,RSRV2,RSRV3,RSRV4,RSRV5,");
+		fprintf(pf, "RSRV6,RSRV7,RSRV8,RSRV9,FILE_NAME\n");
+
+		for(int iDefect = 0; iDefect < pData->GetGlassData()->m_nDefectNum; iDefect++)
+		{
+			_grmDefectData* pDefect = pData->GetDefectData(iDefect);
+			if(makeDataDefect(strLine, pData, pDefect))
+			{
+				fprintf(pf, "%s\n", strLine);
+			}
+		}
+		fprintf(pf, "DEFECT_DATA_END\n\n");
+	}
+	
+	
+	AKLOG("MakeAOIFile Complete : [%s]", strFilePathName.GetBuffer(0));
+	fclose(pf);
+	return TRUE;
+}
+
+BOOL CGlassRawCSOT::MakeAnaFile( CgrmGlassRawData* pData )
+{
+	return TRUE;
+
+	CString strFilePathName;
+	strFilePathName.Format("%s\\%sana", pData->GetGlassData()->m_strPath, pData->GetGlassData()->m_strFileName);
+
+	FILE* pf = fopen(strFilePathName.GetBuffer(0), "w");
+	if(pf == NULL)
+	{
+		AKLOG("MakeAOIFile Fail : [%s]", strFilePathName.GetBuffer(0));
+		return FALSE;
+	}
+
+	fprintf(pf, "%s\n", pData->GetGlassData()->m_strGlassID);
+	fprintf(pf, "m_strImageName, m_strDefectCode, UMCenterAlignX, UMCenterAlignY, m_nLevelSrcMin, m_nLevelSrcMax, m_nLevelSrcAvg, m_nLevelRefMin, m_nLevelRefMax, m_nLevelRefAvg, m_nLevelDiffMin, m_nLevelDiffMax, m_nLevelDiffAvg");
+	for(int i=0; i<MAX_ZONE_NUM; i++) fprintf(pf, ",Zone%02d", i);
+	fprintf(pf, ", m_sDefectPeak, m_nPixelSize, DefectType, UMSize, Density, ScrtRatio, MergeState");
+	fprintf(pf, "\n");
+
+	for(int iDefect = 0; iDefect < pData->GetGlassData()->m_nDefectNum; iDefect++)
+	{
+		_grmDefectData* pDefect = pData->GetDefectData(iDefect);
+		if(pData->GetGlassData()->m_nScanCoordinateY == 1) //분판설비의 경우 XY반전
+		{
+			fprintf(pf, "%s, %s, %.3lf, %.3lf, %d, %d, %d, %d, %d, %d, %d, %d, %d", 
+				pDefect->m_strAoiImageName, pDefect->m_strDefectCode, (double)pDefect->m_nUMCenterAlignY / 1000.0, (double)pDefect->m_nUMCenterAlignX / 1000.0,
+				pDefect->m_nLevelSrcMin, pDefect->m_nLevelSrcMax, pDefect->m_nLevelSrcAvg,
+				pDefect->m_nLevelRefMin, pDefect->m_nLevelRefMax, pDefect->m_nLevelRefAvg,
+				pDefect->m_nLevelDiffMin, pDefect->m_nLevelDiffMax, pDefect->m_nLevelDiffAvg);
+			for(int iz=0; iz<MAX_ZONE_NUM; iz++)
+			{
+				fprintf(pf, ",%d", pDefect->m_sZonePixelCount[iz]);
+			}
+			fprintf(pf, ",%d, %d, %d, %d, %d, %d, %d", 
+				pDefect->m_sDefectPeak, pDefect->m_nPixelSize, pDefect->m_DefectType, pDefect->m_nUMSize, pDefect->m_nDensity, pDefect->m_nScratchRatio, pDefect->m_bMergeState);
+
+			fprintf(pf, ", %d, %d, %d, %d, %d", pDefect->m_nAngle, pDefect->m_nMajor, pDefect->m_nMinor, pDefect->m_nCompact, pDefect->m_nThickness);
+
+			fprintf(pf, "\n");
+		}
+		else
+		{
+			fprintf(pf, "%s, %s, %.3lf, %.3lf, %d, %d, %d, %d, %d, %d, %d, %d, %d", 
+				pDefect->m_strAoiImageName, pDefect->m_strDefectCode, (double)pDefect->m_nUMCenterAlignX / 1000.0, (double)pDefect->m_nUMCenterAlignY / 1000.0,
+				pDefect->m_nLevelSrcMin, pDefect->m_nLevelSrcMax, pDefect->m_nLevelSrcAvg,
+				pDefect->m_nLevelRefMin, pDefect->m_nLevelRefMax, pDefect->m_nLevelRefAvg,
+				pDefect->m_nLevelDiffMin, pDefect->m_nLevelDiffMax, pDefect->m_nLevelDiffAvg);
+			for(int iz=0; iz<MAX_ZONE_NUM; iz++)
+			{
+				fprintf(pf, ",%d", pDefect->m_sZonePixelCount[iz]);
+			}
+			fprintf(pf, ",%d, %d, %d, %d, %d, %d, %d", 
+				pDefect->m_sDefectPeak, pDefect->m_nPixelSize, pDefect->m_DefectType, pDefect->m_nUMSize, pDefect->m_nDensity, pDefect->m_nScratchRatio, pDefect->m_bMergeState);
+
+			fprintf(pf, ", %d, %d, %d, %d, %d", pDefect->m_nAngle, pDefect->m_nMajor, pDefect->m_nMinor, pDefect->m_nCompact, pDefect->m_nThickness);
+
+			fprintf(pf, "\n");
+		}
+	}
+	AKLOG("MakeAnaFile Complete %s", strFilePathName);
+	fclose(pf);
+
+	return TRUE;
+}
+
+void CGlassRawCSOT::makeDataHeader( CString& strLine, _grmGlassData* pGlassData )
+{
+	strLine.Empty();
+	CString strValue;
+	CString strDiv = ",";
+
+	CString strCurDateTime;
+	{
+		CTime Time = m_tmReviewEnd;
+		strCurDateTime.Format("%04d/%02d/%02d_%d:%02d:%02d", 
+			Time.GetYear(), Time.GetMonth(), Time.GetDay(),
+			Time.GetHour(), Time.GetMinute(), Time.GetSecond());
+	} 
+	strValue.Format("FILE_VERSION:%.1lf\n", 1.0);
+	strLine += strValue;
+	strValue.Format("FILE_CREATED_TIME:%s\n", strCurDateTime);
+	strLine += strValue;
+	strValue.Format("EQUIP_TYPE:%s\n", pGlassData->m_strEquipID);
+	strLine += strValue;
+	strValue.Format("EQUIP_ID:%s\n", pGlassData->m_strStepID);
+	strLine += strValue;
+	strValue.Format("CONTENT:%s\n", _T("GLASS_DATA/EQP_GLASS_DATA/BLOCK_SUMMARY/PANEL_SUMMARY/DEFECT_DATA"));
+	strLine += strValue;
+}
+void CGlassRawCSOT::makeDataGlass( CString& strLine, _grmGlassData* pGlassData )
+{
+	strLine.Empty();
+	CString strValue;
+	CString strDiv = ","; 
+	
+	//물류정보 파싱해서 가지고 오기 CString strProcessID, strProductID, strLotID, strSlotID;
+	{ 
+		std::map<CString, CString> mapTransData;
+
+		CString strTemp;
+		strTemp.Format("D:\\DIT_ResultData\\DownloadData\\%s.dat", pGlassData->m_strGlassID); 
+
+		FILE *pFile = fopen(strTemp.GetBuffer(0), "r");  
+		if(pFile)
+		{     
+			const int MAX_BUFFER	= 1024;
+			char buffer[MAX_BUFFER];   
+			CString strKey;
+			CString strValue;
+			char* pFlagPos;
+			char* pEndFlagPos;
+			char* pTest = "』";
+			while (fgets(buffer, MAX_BUFFER, pFile) != '\0')
+			{   
+				pFlagPos = strchr(buffer, '=');
+				
+				if(pFlagPos == NULL) continue;
+
+				if(pEndFlagPos = strchr(pFlagPos, -29)) //"』"끝에 있는 end문자열 제거
+					pEndFlagPos[0] = 0;
+
+				pFlagPos[0] = 0; // = 이걸 0으로 만들어서 Key, Value 분리
+
+				strKey = buffer;
+				strValue = &pFlagPos[1];
+
+				strValue.Remove(' ');//혹시 모를 공백 제거 [김태현 2019/1/31]
+
+				mapTransData.insert(std::make_pair(strKey, strValue));
+			}
+			fclose(pFile);
+		} 
+		
+
+		//GlassData에 값을 넣어줌 [김태현 2019/1/31]
+		strcpy(pGlassData->m_strSLotID, mapTransData["Slot_ID"].GetBuffer(0));
+		strcpy(pGlassData->m_strProductID, mapTransData["Product_ID"].GetBuffer(0));
+		strcpy(pGlassData->m_strProcessID, mapTransData["Process_ID"].GetBuffer(0));
+		strcpy(pGlassData->m_strLotID, mapTransData["Lot_ID"].GetBuffer(0));
+	}
+ 
+ 
+	strValue.Format("%s", pGlassData->m_strGlassID);	 	//1. Glass ID
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strOwnerCode);  	//2. OWNER_CODE
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strOwnerType);  	//3. OWNER_TYPE
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strProductID);  	//4. PRODUCT_ID
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strProcessID);  	//5. PROCESS_ID
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strProductGroup);  //6. PRODUCT_GROUP
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strLotID);  		//7. LOT_ID
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strCSTID);  		//8. CST_ID
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strSLotID); 		//9.SLOT_ID
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strProcessID);  //10.PRE_PROCESS_ID
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strEquipID);		//11.PRE_EQP_ID
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strPreChamerID);	//12.PRE_CHAMBER_ID
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strPreRecipeID);	//13.PRE_RECIPE_ID
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strGroupID);		//14.GROUP_ID
+	strLine += strValue+strDiv;
+	strValue.Format("%c", pGlassData->m_cAutoSampleFlag);  //15.AUTOSAMPLEFLAG
+	strLine += strValue;
+
+
+}
+
+void CGlassRawCSOT::makeDataEQPGlass( CString& strLine, CgrmGlassRawData* pData )
+{
+	strLine.Empty();
+	CString strValue;
+	CString strDiv = ",";
+
+	_grmGlassData *pGlassData = pData->GetGlassData();
+	CString strStartTime, strEndTime;
+	{
+		CTime Time;
+		Time = pGlassData->m_tmGlassLoading;
+		strStartTime.Format("%04d/%02d/%02d_%d:%02d:%02d", 
+			Time.GetYear(), Time.GetMonth(), Time.GetDay(),
+			Time.GetHour(), Time.GetMinute(), Time.GetSecond());
+		Time = pGlassData->m_tmInspectionEND;
+		strEndTime.Format("%04d/%02d/%02d_%d:%02d:%02d", 
+			Time.GetYear(), Time.GetMonth(), Time.GetDay(),
+			Time.GetHour(), Time.GetMinute(), Time.GetSecond());
+	}
+
+	strValue.Format("%s", pGlassData->m_strPPID);														//1. RECIPE_NO
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strRecipeName);													//2. RECIPE_NAME
+	strLine += strValue+strDiv;
+	strValue.Format("%s", strStartTime);																//3. START_TIME
+	strLine += strValue+strDiv;
+	strValue.Format("%s", strEndTime);																	//4. END_TIME
+	strLine += strValue+strDiv;
+	strValue.Format("%d", strEndTime - strStartTime);													//5. TACT_TIME
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "0000");																		//6. GLASS_YIELD
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pGlassData->m_nCellNum);														//7. TOTAL_PANEL_CNT(CELL COUNT)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pGlassData->m_nDefectNumJudgeOKBlack+pGlassData->m_nDefectNumJudgeOKWhite);	//8. OK_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pGlassData->m_nDefectNumJudgeNG);												//9. NG_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																	//10. X1_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																	//11. X2_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																	//12. X3_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																	//13. X4_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																	//14. X5_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																	//15. X6_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																	//16. X7_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																	//17. X8_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pGlassData->m_nDefectNumSizeHuge);										//18. X9_PANEL(Count)	//190116 고객사가 키큰여자 여기에다가 ol갯수 적어 달라고 요청
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pGlassData->m_nDefectNum);													//19. TT_DEFECT_CNT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pGlassData->m_nDefectNumSizeSmall);											//20. S_SIZE_DFECT_CNT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pGlassData->m_nDefectNumSizeMid);												//21. M_SIZE_DFECT_CNT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pGlassData->m_nDefectNumSizeLarge);											//22. L_SIZE_DFECT_CNT
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "AAAA");																		//23. GLASS_ID_DCR
+	strLine += strValue+strDiv;
+	strValue.Format("%d", m_MuraResultFile.GetDefectNum());												//24. TT_MURA_CNT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//25. POINT_MURA_CNT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//26. LINE_MURA_CNT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//27. AREA_MURA_CNT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//28. POINT_1
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//29. POINT_2
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//30. POINT_3
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//31. POINT_4
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 1);																			//32. POINT_5		
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strGlassJudge);													//33. GLASS_JUDGE
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strGlassCode);													//34. GLASS_GRADE
+	strLine += strValue;
+	
+}
+
+void CGlassRawCSOT::makeDataBlock( CString& strLine, _grmBlockData* pBlockData )
+{
+	strLine.Empty();
+	CString strValue;
+	CString strDiv = ",";
+
+	strValue.Format("%s", pBlockData->m_strBlockID);				//1. BLOCK_ID
+	strLine += strValue+strDiv;
+	strValue.Format("%c", pBlockData->m_cBlockJudgeAOI);			//2. BLOCK_JUDGE_AOI		
+	strLine += strValue+strDiv;
+	strValue.Format("%c", 'G');									//3. BLOCK_JUDGE_MURA
+	strLine += strValue+strDiv;
+	strValue.Format("%c", pBlockData->m_cBlockJudgeATS);			//4. BLOCK_JUDGE_ATS		
+	strLine += strValue+strDiv;
+	strValue.Format("%c", pBlockData->m_cBlockJudgeTEG);			//5. BLOCK_JUDGE_TEG		
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//6. TT_PANEL
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//7. OK_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//8. NG_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//9. X1_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//10. X2_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//11. X3_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//12. X4_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//13. X5_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//14. X6_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//15. X7_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//16. X8_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//17. X9_PANEL(Count)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//18. TT_DEFECT_CNT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//19. S_SIZE_DFECT_CNT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//20. M_SIZE_DFECT_CNT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//21. L_SIZE_DFECT_CNT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//22. GLASS_ID_DCR
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//23. TT_MURA_CNT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//24. POINT_MURA_CNT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//25. LINE_MURA_CNT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//26. AREA_MURA_CNT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//27. POINT_1
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//28. POINT_2
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//29. POINT_3
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//30. POINT_4
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);										//31. POINT_5
+	strLine += strValue;
+}
+
+
+void CGlassRawCSOT::makeDataCell( CString& strLine, CgrmGlassRawData* pData, _grmCellData* pCellData )
+{
+	strLine.Empty();
+	CString strValue;
+	CString strDiv = ",";
+
+	CString strJudgeCode = "O";
+	CString strLastCode = "O";
+	{
+		switch (pCellData->m_nJudgement)
+		{
+		case 0:		strJudgeCode = "G"; break;
+		case 2:		strJudgeCode = "N"; break;
+		case 10:	strJudgeCode = "O"; break;
+		case 1:		strJudgeCode = "O"; break;
+		case 6:		strJudgeCode = "O"; break;
+		case 7:		strJudgeCode = "O"; break;
+		}
+	}
+	strLastCode = strJudgeCode;
+
+	strValue.Format("%s%s", pData->GetGlassData()->m_strGlassID, pCellData->m_strCellName);													//1. PANEL_ID
+	strLine += strValue+strDiv;
+	strValue.Format("%s", strJudgeCode);																//2. PANEL_JUDGE_AOI
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "O");																			//3. PANEL_JUDGE_MURA
+	strLine += strValue+strDiv;
+	strValue.Format("%s", strLastCode);																	//4. PANEL_JUDGE
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pCellData->getTotalDefectNum());												//5. tt_DEFECT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", m_MuraResultFile.GetDefectNum(pCellData->m_nCellID));												//6. tt_MURA
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "A*");																		//7. PANEL_ID_2D
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pCellData->m_nJudgeFlag);														//8. PANEL_FLAG
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pCellData->m_nJudgeGlade);													//9. PANEL_GRADE
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pCellData->m_rectCellLeft);													//10. X_D
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pCellData->m_rectCellTop);													//11. Y_D
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pCellData->m_rectCellRight-pCellData->m_rectCellLeft);						//12. X_A
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pCellData->m_rectCellBottom-pCellData->m_rectCellTop);						//13. Y_A
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//14. DELTA_X
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//15. DELTA_Y
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pCellData->m_nDefectNumJudgeOKWhite + pCellData->m_nDefectNumJudgeOKBlack);	//16. OK_DEFECT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pCellData->m_nDefectNumJudgeNG);												//17. NG_DEFECT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//18. X1_DEFECT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//19. X2_DEFECT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//20. X3_DEFECT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//21. X4_DEFECT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//22. X5_DEFECT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//23. X6_DEFECT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//24. X7_DEFECT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//25. X8_DEFECT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//26. X9_DEFECT
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "0");																			//27. IJP1
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "0");																			//28. IJP2
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "0");																			//29. IJP3
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "0");																			//30. IJP4
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "0");																			//31. IJP5
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "0");																			//32. IJP6
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "0");																			//33. IJP7
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "0");																			//34. IJP8
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//35. Mark1
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//36. Mark2
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//37. Mark3
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//38. Mark4
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//39. Mark5
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//40. Mark6
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//41. Mark7
+	strLine += strValue+strDiv;
+	strValue.Format("%d", 0);																			//42. Mark8
+	strLine += strValue;
+
+}
+
+BOOL CGlassRawCSOT::makeDataDefect( CString& strLine, CgrmGlassRawData* pData, _grmDefectData* pDefectData )
+{
+	strLine.Empty();
+	CString strValue;
+	CString strDiv = ",";
+
+	_grmGlassData* pGlassData = pData->GetGlassData();
+	_grmCellData* pCellData = pData->GetCellData(pDefectData->m_nCellIdx);
+
+	if(pDefectData->m_ReviewDefect.m_nPlanType == 1000 //aoi결함
+		//pDefectData->m_ReviewDefect.m_nPlanType == 999 
+		) return FALSE;
+
+	CString strUpdateTime;
+	{
+		CTime Time = pGlassData->m_tmInspectionEND;
+		strUpdateTime.Format("%04d/%02d/%02d_%d:%02d:%02d", 
+			Time.GetYear(), Time.GetMonth(), Time.GetDay(),
+			Time.GetHour(), Time.GetMinute(), Time.GetSecond());
+
+// 		CTime Time = pGlassData->m_tmInspectionEND;
+// 		strUpdateTime.Format("%04d%02d%02d%02d%02d",
+// 			Time.GetYear(), Time.GetMonth(), Time.GetDay(),
+// 			Time.GetHour(), Time.GetMinute());
+	}
+	
+	CString strStepFirst;//첫번째 스택 [김태현 2018/12/5]
+	{
+		if(pDefectData->m_strStackFirst[0])
+		{
+			strStepFirst =pDefectData->m_strStackFirst;
+		}	
+		else
+		{
+			strStepFirst = pGlassData->m_strStepID;
+		}
+	}
+
+	strValue.Format("%s%s", pData->GetGlassData()->m_strGlassID, pCellData->m_strCellName);					//1. CELL ID
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pDefectData->m_nDefectID);				//2. DEFECT_NO1
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pDefectData->m_nDefectID);				//3. DEFECT_NO2
+	strLine += strValue+strDiv;
+	strValue.Format("%s", strUpdateTime);							//4. UPDATE_TIME
+	strLine += strValue+strDiv;
+	strValue.Format("%s", strStepFirst);							//5. STEP_1ST
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strRecipeName);				//6. RECIPE_1ST
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strStepID);					//7. STEP_CURRENT
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pGlassData->m_strRecipeName);				//8. RECIPE_CURRENT
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pDefectData->m_nCellGate);				//9. GATE1, 셀별 Gate라인(얼라인 보정 전)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pDefectData->m_nCellData);				//10. DATA1, 셀별 Data라인(얼라인 보정 전)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pDefectData->m_nCellGateAlign);			//11. GATE2, 셀별 Gate라인(얼라인 보정 후)
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pDefectData->m_nCellDataAlign);			//12. DATA2, 셀별 Data라인(얼라인 보정 후)
+	strLine += strValue+strDiv;
+
+
+
+	//_grmGlassData* pGlass = pData->GetGlassData(); 
+
+	
+
+	// x,y좌표 mm단위 소수점 세자리까지 표현 (고객사 요청) - 2019-01-30 HJH
+	if(pGlassData->m_nScanCoordinateY == 1) //분판설비의 경우 XY반전
+	{
+		strValue.Format("%.3lf", pDefectData->m_nUMCenterAlignY / 1000.0);			//13. X1, um단위 X좌표 (Glass Center 기준, 얼라인보정 후)
+		strLine += strValue+strDiv;
+		strValue.Format("%.3lf", pDefectData->m_nUMCenterAlignX / 1000.0);			//14. Y1, um단위 Y좌표 (Glass Center 기준, 얼라인보정 후)
+		strLine += strValue+strDiv;
+		strValue.Format("%.3lf", pDefectData->m_nUMCellY / 1000.0);					//15. X2, 셀 원점 기준 x 좌표
+		strLine += strValue+strDiv;
+		strValue.Format("%.3lf", pDefectData->m_nUMCellX / 1000.0);					//16. Y2, 셀 원점 기준 y 좌표
+		strLine += strValue+strDiv;
+		strValue.Format("%d", pDefectData->m_DefectType);				//17. AOI_DEFECT_TYPE, SERVER_DefectType
+		strLine += strValue+strDiv;
+		strValue.Format("%d", pDefectData->m_nLevelSrcMax);				//18. AOI_GRAY_H, 결함 밝기 Max			
+		strLine += strValue+strDiv;
+		strValue.Format("%d", pDefectData->m_nLevelSrcMin);				//19. AOI_GRAY_L, 결함 밝기 Min			
+		strLine += strValue+strDiv;
+		strValue.Format("%d", pDefectData->m_nLevelSrcAvg);				//20. AOI_GRAY_AVE, 결함 밝기 Avg			
+		strLine += strValue+strDiv;
+		strValue.Format("%d", pDefectData->m_nPixelSize);				//21. AOI_DEFECT_AREA 			
+		strLine += strValue+strDiv;
+		strValue.Format("%d", pDefectData->m_nDefectRScale);			//22. AOI_DEFECT_LGT, 결함 길이				
+		strLine += strValue+strDiv;
+		strValue.Format("%s", GetDefectInfoToString(DMT_DefectSizeType, pDefectData->m_DefectSizeType));				//23. AOI_DEFECT_WID , <- 190106 고객 담당자 요청 키큰여자	사이즈타입으로로 변경		
+		strLine += strValue+strDiv;
+		strValue.Format("%d", pDefectData->m_sPixelWidth);				//24. AOI_DEFECT_HGT		
+	}
+	else
+	{
+		strValue.Format("%.3lf", pDefectData->m_nUMCenterAlignX / 1000.0);			//13. X1, um단위 X좌표 (Glass Center 기준, 얼라인보정 후)
+		strLine += strValue+strDiv;
+		strValue.Format("%.3lf", pDefectData->m_nUMCenterAlignY / 1000.0);			//14. Y1, um단위 Y좌표 (Glass Center 기준, 얼라인보정 후)
+		strLine += strValue+strDiv;
+		strValue.Format("%.3lf", pDefectData->m_nUMCellX / 1000.0);					//15. X2, 셀 원점 기준 x 좌표
+		strLine += strValue+strDiv;
+		strValue.Format("%.3lf", pDefectData->m_nUMCellY / 1000.0);					//16. Y2, 셀 원점 기준 y 좌표
+		strLine += strValue+strDiv;
+		strValue.Format("%d", pDefectData->m_DefectType);				//17. AOI_DEFECT_TYPE, SERVER_DefectType
+		strLine += strValue+strDiv;
+		strValue.Format("%d", pDefectData->m_nLevelSrcMax);				//18. AOI_GRAY_H, 결함 밝기 Max			
+		strLine += strValue+strDiv;
+		strValue.Format("%d", pDefectData->m_nLevelSrcMin);				//19. AOI_GRAY_L, 결함 밝기 Min			
+		strLine += strValue+strDiv;
+		strValue.Format("%d", pDefectData->m_nLevelSrcAvg);				//20. AOI_GRAY_AVE, 결함 밝기 Avg			
+		strLine += strValue+strDiv;
+		strValue.Format("%d", pDefectData->m_nPixelSize);				//21. AOI_DEFECT_AREA 			
+		strLine += strValue+strDiv;
+		strValue.Format("%d", pDefectData->m_nDefectRScale);			//22. AOI_DEFECT_LGT, 결함 길이				
+		strLine += strValue+strDiv;
+		strValue.Format("%s", GetDefectInfoToString(DMT_DefectSizeType, pDefectData->m_DefectSizeType));				//23. AOI_DEFECT_WID, <- 190106 고객 담당자 요청 키큰여자	사이즈타입으로로 변경					
+		strLine += strValue+strDiv;
+		strValue.Format("%d", pDefectData->m_sPixelHeight);				//24. AOI_DEFECT_HGT		
+	}
+	
+	
+		
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pDefectData->m_DefectSizeType);			//25. AOI_DEFECT_WIH, SERVER_DefectSizeType			
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pDefectData->m_nUMSize);					//26. AOI_DEFECT_SIZE 			
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pDefectData->m_nPixelSize);				//27. DEFECT_PIX 			
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pDefectData->m_DefectSubType == 2 ? 1:0);	//28. MASK_DEFECT, 한 Glass에서 발견된 마스크결함 묶음의 			
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pDefectData->m_DefectSubType == 3 ? 1:0);		//29. REPEAT_DEFECT, 연속결함발견위한 동일좌표 반복수			
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pDefectData->m_ReviewDefect.m_strRevImageName);			//30. DEFECT_IMAGE_DATA		
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pDefectData->m_nDefectIdx);				//31. AOI_CCD_NO  			
+	strLine += strValue+strDiv;
+	strValue.Format("%d", pDefectData->m_ReviewDefect.m_nShotIndex);			//32. AOI_REVIEW_NO  				
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "A*");									//33. OP_ID_1ST  
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "A*");									//34. OP_ID_2ND  
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "A*");									//35. OP_ID_CURRENT  
+	strLine += strValue+strDiv;
+	strValue.Format("%s", GetDefectInfoToString(DMT_DefectSizeType, pDefectData->m_DefectJudgement));			//36. DEFECT_JUGDE_1ST  			
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "O");										//37. DEFECT_JUGDE_2ND  
+	strLine += strValue+strDiv;
+	strValue.Format("%s", GetDefectInfoToString(DMT_DefectSizeType, pDefectData->m_DefectJudgement));			//38. DEFECT_JUGDE_CURRENT
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "A");										//39. DEFECT_REASON1  
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "A");										//40. DEFECT_REASON2 
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "A");										//41. DEFECT_REASON3 
+	strLine += strValue+strDiv;
+	strValue.Format("%.2lf", pDefectData->m_ReviewDefect.m_fWsi_ResultData[1]);//42. WSI_JUDGE 
+	strLine += strValue+strDiv;
+	//KMS - 20190128 MuraDefect 내용 추가
+	_MacroDefect* pMuraDefect = m_MuraResultFile.FindDefect(pDefectData->m_nUMCenterAlignX, pDefectData->m_nUMCenterAlignY);
+	_MacroDefect MuraDefect;
+	if(pMuraDefect) MuraDefect = *pMuraDefect;
+	strValue.Format("%d", MuraDefect.G_MAX);										//43. MURA_GRAY_H 
+	strLine += strValue+strDiv;
+	strValue.Format("%d", MuraDefect.G_MIN);										//44. MURA_GRAY_L 
+	strLine += strValue+strDiv;
+	strValue.Format("%d", MuraDefect.G_AVG);										//45. MURA_GRAY_AVE 
+	strLine += strValue+strDiv;
+	strValue.Format("%d", MuraDefect.SIZE_S);										//46. MURA_AREA 
+	strLine += strValue+strDiv;
+	strValue.Format("%d", MuraDefect.SIZE_L);										//47. MURA_LGT 
+	strLine += strValue+strDiv;
+	strValue.Format("%d", MuraDefect.SIZE_W);										//48. MURA_WID  
+	strLine += strValue+strDiv;
+	strValue.Format("%d", MuraDefect.COORD_Y1);										//49. MURA_HGT 
+	strLine += strValue+strDiv;
+	strValue.Format("%d", MuraDefect.SIZE_S);										//50. MURA_SIZE 
+	strLine += strValue+strDiv;
+	strValue.Format("%d", MuraDefect.COORD_PX1);											//51. MURA_PIX 
+	strLine += strValue+strDiv;
+	strValue.Format("%s", MuraDefect.MAIN_TYPE.GetBuffer(0));									//52. MURA_TYPE 
+	strLine += strValue+strDiv;
+	strValue.Format("%s", MuraDefect.JUDGE.GetBuffer(0));										//53. MURA_JUDGE 
+	strLine += strValue+strDiv;
+	strValue.Format("%s", MuraDefect.SUB_TYPE.GetBuffer(0));										//54. MURA_GRADE 
+	strLine += strValue+strDiv;
+	strValue.Format("%s", MuraDefect.IMG_FILE_NAME.GetBuffer(0));								//55. MURA_IMAGE_DATA 
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "*");									//56. RSRV1 
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "*");									//57. RSRV2 
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "*");									//58. RSRV3 
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "*");									//59. RSRV4 
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "*");									//60. RSRV5 
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "*");									//61. RSRV6 
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "*");									//62. RSRV7 
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "*");									//63. RSRV8 
+	strLine += strValue+strDiv;
+	strValue.Format("%s", "*");									//64. RSRV9 
+	strLine += strValue+strDiv;
+	strValue.Format("%s", pDefectData->m_strAoiImageName);				//65. FILE_NAME 			
+	strLine += strValue;
+
+	return TRUE;
+}
+
+BOOL CGlassRawCSOT::ReadMuraFile( CgrmGlassRawData* pData )
+{
+ 	if(m_MuraResultFile.m_strServerResultRawPath.IsEmpty() == FALSE)//읽은 결과 파일 복사,삭제 태현[2017/3/29]
+ 	{
+		CString strMacroFilePath;
+		{
+			strMacroFilePath.Format("%s\\%s_*.dat", m_MuraResultFile.m_strMacroResultRawPath, pData->GetGlassData()->m_strGlassID);
+
+			CFileFind FF;
+
+			if (FF.FindFile(strMacroFilePath))
+			{
+				FF.FindNextFile();
+				strMacroFilePath = FF.GetFilePath();
+				FF.Close();
+			}
+			else
+			{
+				AKLOG("Find Macro File Fail. [%s]", strMacroFilePath);
+				return FALSE;
+			}
+		}
+		
+
+ 		CString strMacroResultTargetPath;
+ 		strMacroResultTargetPath.Format("%s\\%s.dat", m_MuraResultFile.m_strServerResultRawPath, pData->GetGlassData()->m_strGlassID);
+ 
+ 		if(TRUE == CopyFile(strMacroFilePath,strMacroResultTargetPath,FALSE))
+ 		{
+ 			if(m_MuraResultFile.openFile(strMacroResultTargetPath.GetBuffer(0)) == TRUE)
+ 			{
+ 				AKLOG("Macro File Read Success : %dItem", m_MuraResultFile.GetDefectNum());
+ 				//DeleteFile(strMacroResultTargetPath); //삭제는 hddspacectrl이 하는 것으로 통일
+ 			}
+ 			else
+ 			{
+ 				AKLOG("Macro File Read Fail[%s]", strMacroFilePath);
+ 				//DeleteFile(strMacroResultTargetPath); //삭제는 hddspacectrl이 하는 것으로 통일
+ 				return FALSE;
+ 			}
+ 		}
+ 	}
+ 
+	//무라 이미지 복사(ftp업로드를 위함) [김태현 2018/12/5]
+ 	if(m_MuraResultFile.m_strMacroResultImagePath.IsEmpty() == FALSE && m_MuraResultFile.m_strServerResultImagePath.IsEmpty() == FALSE)//이미지 파일 복사 태현[2017/3/29]
+ 	{
+ 		CString strMacroImageSrcPath;
+ 		CString strMacroImageTarPath;
+ 
+ 		strMacroImageSrcPath.Format("%s\\%s", m_MuraResultFile.m_strMacroResultImagePath, pData->GetGlassData()->m_strGlassID);
+ 		strMacroImageTarPath.Format("%s\\%s", m_MuraResultFile.m_strServerResultImagePath, pData->GetGlassData()->m_strGlassID);
+ 
+		AKLOG("Macro Image File Copy Start[%s]", strMacroImageTarPath);
+ 		CakFileUtil::CopyFolder(strMacroImageSrcPath.GetBuffer(0), strMacroImageTarPath.GetBuffer(0), FALSE);
+		AKLOG("Macro Image File Copy End");
+ 	}
+
+	return TRUE;
+}
+
+
+void CGlassRawCSOT::SendMessageFTPUploadLinkFile( _grmGlassData* pGlassData )
+{
+	if(pGlassData == NULL) return;
+	HWND hWnd = ::FindWindow(NULL, "FTPUploader");
+	if(hWnd == NULL) return;
+
+	char strServerFolder[256] = {};
+	char strServerFile[256] = {};
+	char strLocalFolder[256] = {};
+	char pLocalFile[256] = {}; 
+	GetFormatDescription(FTPCMD_LINK, strServerFolder, strServerFile, strLocalFolder, pLocalFile, pGlassData);
+
+	CFTPCopyDataParam upParam;
+	strcpy(upParam.m_strServer_FolderName,			strServerFolder);
+	strcpy(upParam.m_strServer_FileName,			strServerFile);
+	strcpy(upParam.m_strLocal_FolderName,			strLocalFolder);
+	strcpy(upParam.m_strLocal_FileName,				pLocalFile);
+	strcpy(upParam.m_strServer_SignalFolderName,	"");
+	strcpy(upParam.m_strServer_SignalFileName,		"");
+	upParam.m_nCreateSignalFile							= FALSE;//m_ctrlCreateSignal.GetCheck();
+	upParam.m_nSendResultCode							= FALSE;//m_ctrlResultAck.GetCheck();
+	upParam.m_nProcessType								= FTPProcessType_UpFile;
+
+	COPYDATASTRUCT cds;
+	cds.dwData = FTPCopyDataCmd_RawUpload;
+	cds.cbData = sizeof(CFTPCopyDataParam);
+	cds.lpData = &upParam;
+
+	DWORD dwReturn = 0;
+	if(SendMessageTimeout(hWnd, WM_COPYDATA, NULL, (LPARAM)&cds, SMTO_NORMAL, 20000, (PDWORD_PTR)(dwReturn)) == FALSE)
+	{
+	}
+
+}
+ 
+void CGlassRawCSOT::SendMessageFTPUploadRaw( _grmGlassData* pGlassData )
+{
+	if(pGlassData == NULL) return;
+	HWND hWnd = ::FindWindow(NULL, "FTPUploader");
+	if(hWnd == NULL) return;
+
+	char strServerFolder[256] = {};
+	char strServerFile[256] = {};
+	char strLocalFolder[256] = {};
+	char pLocalFile[256] = {}; 
+	GetFormatDescription(FTPCMD_RAW, strServerFolder, strServerFile, strLocalFolder, pLocalFile, pGlassData);
+  
+	CFTPCopyDataParam upParam;
+	strcpy(upParam.m_strServer_FolderName,			strServerFolder);
+	strcpy(upParam.m_strServer_FileName,			strServerFile);
+	strcpy(upParam.m_strLocal_FolderName,			strLocalFolder);
+	strcpy(upParam.m_strLocal_FileName,				pLocalFile);
+	strcpy(upParam.m_strServer_SignalFolderName,	"");
+	strcpy(upParam.m_strServer_SignalFileName,		"");
+	upParam.m_nCreateSignalFile							= FALSE;//m_ctrlCreateSignal.GetCheck();
+	upParam.m_nSendResultCode							= FALSE;//m_ctrlResultAck.GetCheck();
+	upParam.m_nProcessType								= FTPProcessType_UpFile;
+
+	COPYDATASTRUCT cds;
+	cds.dwData = FTPCopyDataCmd_RawUpload;
+	cds.cbData = sizeof(CFTPCopyDataParam);
+	cds.lpData = &upParam;
+
+	DWORD dwReturn = 0;
+	if(SendMessageTimeout(hWnd, WM_COPYDATA, NULL, (LPARAM)&cds, SMTO_NORMAL, 20000, (PDWORD_PTR)(dwReturn)) == FALSE)
+	{
+	}
+
+}
+
+void CGlassRawCSOT::SendMessageFTPDownloadStack( _grmGlassData* pGlassData )
+{
+	if(pGlassData == NULL) return;
+	HWND hWnd = ::FindWindow(NULL, "FTPUploader");
+	if(hWnd == NULL) return;
+
+	char strServerFolder[256] = {};
+	char strServerFile[256] = {};
+	char strLocalFolder[256] = {};
+	char pLocalFile[256] = {}; 
+	GetFormatDescription(FTPCMD_STACK, strServerFolder, strServerFile, strLocalFolder, pLocalFile, pGlassData);
+
+	CFTPCopyDataParam upParam;
+	strcpy(upParam.m_strServer_FolderName,			strServerFolder);
+	strcpy(upParam.m_strServer_FileName,			strServerFile);
+	strcpy(upParam.m_strLocal_FolderName,			strLocalFolder);
+	strcpy(upParam.m_strLocal_FileName,				pLocalFile);
+	strcpy(upParam.m_strServer_SignalFolderName,	"");
+	strcpy(upParam.m_strServer_SignalFileName,		"");
+	upParam.m_nCreateSignalFile							= FALSE;//m_ctrlCreateSignal.GetCheck();
+	upParam.m_nSendResultCode							= FALSE;//m_ctrlResultAck.GetCheck();
+	upParam.m_nProcessType								= FTPProcessType_DownFile;
+
+	COPYDATASTRUCT cds;
+	cds.dwData = FTPCopyDataCmd_RawDownload;
+	cds.cbData = sizeof(CFTPCopyDataParam);
+	cds.lpData = &upParam;
+
+	DWORD dwReturn = 0;
+	if(SendMessageTimeout(hWnd, WM_COPYDATA, NULL, (LPARAM)&cds, SMTO_NORMAL, 20000, (PDWORD_PTR)(dwReturn)) == FALSE)
+	{
+	}
+}
+
+void CGlassRawCSOT::SendMessageFTPDownloadDataFile( _grmGlassData* pGlassData )
+{
+	if(pGlassData == NULL) return;
+	HWND hWnd = ::FindWindow(NULL, "FTPDownloader");
+	if(hWnd == NULL) return;
+
+	char strServerFolder[256] = {};
+	char strServerFile[256] = {};
+	char strLocalFolder[256] = {};
+	char pLocalFile[256] = {}; 
+
+	//GetFormatDescription(FTPCMD_DATAFILE, strServerFolder, strServerFile, strLocalFolder, pLocalFile, pGlassData);
+	{
+		CString strGlassIDOrg = pGlassData->m_strGlassID; 
+		CString strGlassID = strGlassIDOrg.Left(12);
+		sprintf(strServerFolder, "%s", pGlassData->m_strCassetteSequenceNo);
+		sprintf(strServerFile, "%s.dat", strGlassID.GetBuffer(0));  
+		sprintf(strLocalFolder,  "D:\\DIT_ResultData\\DownloadData"); 
+		sprintf(pLocalFile,  "%s.dat", strGlassID.GetBuffer(0)); 
+	}
+
+	CFTPCopyDataParam upParam;
+	strcpy(upParam.m_strServer_FolderName,			strServerFolder);
+	strcpy(upParam.m_strServer_FileName,			strServerFile);
+	strcpy(upParam.m_strLocal_FolderName,			strLocalFolder);
+	strcpy(upParam.m_strLocal_FileName,				pLocalFile);
+	strcpy(upParam.m_strServer_SignalFolderName,	"");
+	strcpy(upParam.m_strServer_SignalFileName,		"");
+	upParam.m_nCreateSignalFile							= FALSE;//m_ctrlCreateSignal.GetCheck();
+	upParam.m_nSendResultCode							= FALSE;//m_ctrlResultAck.GetCheck();
+	upParam.m_nProcessType								= FTPProcessType_DownFile;
+
+	COPYDATASTRUCT cds;
+	cds.dwData = FTPCopyDataCmd_RawDownload;
+	cds.cbData = sizeof(CFTPCopyDataParam);
+	cds.lpData = &upParam;
+
+	DWORD dwReturn = 0;
+	if(SendMessageTimeout(hWnd, WM_COPYDATA, NULL, (LPARAM)&cds, SMTO_NORMAL, 20000, (PDWORD_PTR)(dwReturn)) == FALSE)
+	{
+	}
+}
+
+void CGlassRawCSOT::SendMessageFTPUploadImage( _grmGlassData* pGlassData, emFTPCommand sort)
+{  
+	if(pGlassData == NULL) return;
+	HWND hWnd = ::FindWindow(NULL, "FTPUploader");
+	if(hWnd == NULL) return;
+ 
+	char strServerFolder[256] = {};
+	char strServerFile[32];// = "*.*";
+	char strLocalFolder[256] = {};
+	char strLocalFile[32];// = "*.*"; 
+
+	GetFormatDescription(sort, strServerFolder, strServerFile, strLocalFolder, strLocalFile, pGlassData);
+   
+// 	if(0)//test 
+// 	{
+// 		sprintf(strServerFolder, "HDD1/DIT/TestC");
+// 	}
+ 
+	CFTPCopyDataParam upParam;
+	strcpy(upParam.m_strServer_FolderName,			strServerFolder);
+	strcpy(upParam.m_strServer_FileName,			strServerFile);
+	strcpy(upParam.m_strLocal_FolderName,			strLocalFolder);
+	strcpy(upParam.m_strLocal_FileName,				strLocalFile);
+	strcpy(upParam.m_strServer_SignalFolderName,	"");
+	strcpy(upParam.m_strServer_SignalFileName,		"");
+	upParam.m_nCreateSignalFile							= FALSE;
+	upParam.m_nSendResultCode							= FALSE;
+	upParam.m_nProcessType								= FTPProcessType_UpFile;
+
+	COPYDATASTRUCT cds;
+	cds.dwData = FTPCopyDataCmd_RawUpload; //<--요건 나중에 구분
+	cds.cbData = sizeof(CFTPCopyDataParam);
+	cds.lpData = &upParam;
+
+	DWORD dwReturn = 0;
+	if(SendMessageTimeout(hWnd, WM_COPYDATA, NULL, (LPARAM)&cds, SMTO_NORMAL, 20000, (PDWORD_PTR)(dwReturn)) == FALSE)
+	{
+	}
+}
+  
+
+BOOL CGlassRawCSOT::SendMessageFTPUploadIndexFile( _grmGlassData* pGlassData )
+{  
+	if(pGlassData == NULL) 
+		return FALSE;
+
+	HWND hWnd = ::FindWindow(NULL, "FTPUploader");
+	if(hWnd == NULL) return FALSE;
+
+
+	char strServerFolder[256] = {};
+	char strServerFile[256] = {};
+	char strLocalFolder[256] = {};
+	char pLocalFile[256] = {}; 
+
+	GetFormatDescription(FTPCMD_INDEX, strServerFolder, strServerFile, strLocalFolder, pLocalFile, pGlassData);
+
+
+	// 	if(0)//test 
+	// 	{
+	// 		sprintf(strServerFolder, "HDD1/DIT/TestC");
+	// 		ServerFile = "ftptestfile.txt";
+	// 
+	// 		sprintf(strLocalFolder, "D:");
+	// 		pLocalFile = "ftptestfile.txt";
+	// 	}
+
+
+	CFTPCopyDataParam upParam;
+	strcpy(upParam.m_strServer_FolderName,			strServerFolder);
+	strcpy(upParam.m_strServer_FileName,			strServerFile);
+	strcpy(upParam.m_strLocal_FolderName,			strLocalFolder);
+	strcpy(upParam.m_strLocal_FileName,				pLocalFile);
+	strcpy(upParam.m_strServer_SignalFolderName,	"");
+	strcpy(upParam.m_strServer_SignalFileName,		"");
+	upParam.m_nCreateSignalFile							= FALSE;//m_ctrlCreateSignal.GetCheck();
+	upParam.m_nSendResultCode							= FALSE;//m_ctrlResultAck.GetCheck();
+	upParam.m_nProcessType								= FTPProcessType_UpFile;
+
+	COPYDATASTRUCT cds;
+	cds.dwData = FTPCopyDataCmd_RawUpload;
+	cds.cbData = sizeof(CFTPCopyDataParam);
+	cds.lpData = &upParam;
+
+	DWORD dwReturn = 0;
+	if(SendMessageTimeout(hWnd, WM_COPYDATA, NULL, (LPARAM)&cds, SMTO_NORMAL, 20000, (PDWORD_PTR)(dwReturn)) == FALSE)
+	{
+	}
+	return TRUE;
+}
+
+void CGlassRawCSOT::GetFormatDescription(emFTPCommand sort, char* pServerPath, char* pServerFile, char* pLocalPath, char* pLocalFile, _grmGlassData* pGlassData)
+{ 
+	
+	CString strGlassIDOrg = pGlassData->m_strGlassID; 
+	CString strGlassID = strGlassIDOrg.Left(12);
+	CString strGlassIDLevel5th = strGlassID.Left(5);
+	CString strGlassIDLevel8th = strGlassID.Left(8);
+ 
+	switch(sort)
+	{ 
+	case FTPCMD_AOI_IMAGE:
+		{
+			CTime time = m_tmReviewEnd;
+
+			sprintf(pServerPath, "%s\\%04d%02d%02d\\%s\\%s\\%s\\Image", pGlassData->m_strEquipID, time.GetYear(), time.GetMonth(), time.GetDay(), 
+				strGlassIDLevel5th.GetBuffer(0), 
+				strGlassIDLevel8th.GetBuffer(0),
+				strGlassID.GetBuffer(0));  
+			
+			sprintf(pLocalPath, "%s%s", LOCAL_AOI_IMAGE_PATH, strGlassID.GetBuffer(0));  
+			strcpy(pServerFile, "*.*");
+			strcpy(pLocalFile, "*.*");
+		}
+		break;
+	case FTPCMD_REVIEW_IMAGE: 
+		{
+			CTime time = m_tmReviewEnd;
+
+			sprintf(pServerPath, "%s\\%04d%02d%02d\\%s\\%s\\%s\\Image", pGlassData->m_strEquipID, time.GetYear(), time.GetMonth(), time.GetDay(), 
+				strGlassIDLevel5th.GetBuffer(0), 
+				strGlassIDLevel8th.GetBuffer(0),
+				strGlassID.GetBuffer(0)); 
+
+			sprintf(pLocalPath, "%s%s", LOCAL_REV_IMAGE_PATH, strGlassID.GetBuffer(0));  
+			strcpy(pServerFile, "*.*");
+			strcpy(pLocalFile, "*.*");
+		}
+		break;
+	case FTPCMD_RAW:   
+		{
+			CTime time = m_tmReviewEnd;
+			CString strFileName;//파일생성 시간 때문에 여기서 정확하게 파일명 다시 정정
+			{
+				//Glass 정보
+				CTime CurrTime = m_tmReviewEnd;
+				CString strTime;
+				strTime.Format(_T("%04d%02d%02d_%02d%02d%02d"),
+					CurrTime.GetYear(), CurrTime.GetMonth(), CurrTime.GetDay(), CurrTime.GetHour(), CurrTime.GetMinute(), CurrTime.GetSecond());
+				strFileName.Format("%s_%s_%s.csv", pGlassData->m_strOperID, pGlassData->m_strGlassID, strTime.GetBuffer(0));
+			}
+			sprintf(pServerPath, "%s\\%04d%02d%02d\\%s\\%s\\%s\\Data", pGlassData->m_strEquipID, time.GetYear(), time.GetMonth(), time.GetDay(), 
+				strGlassIDLevel5th.GetBuffer(0), 
+				strGlassIDLevel8th.GetBuffer(0),
+				strGlassID.GetBuffer(0)); 
+			
+			sprintf(pLocalPath, "%s", pGlassData->m_strPath);
+
+			sprintf(pServerFile, "%s", strFileName.GetBuffer(0)); 
+			sprintf(pLocalFile, "%s", strFileName.GetBuffer(0)); 
+		}
+		break;
+	case FTPCMD_STACK:
+		{
+			CTime time = pGlassData->m_tmGlassLoading;
+			sprintf(pServerPath, "%s\\%04d%02d%02d\\%s\\%s\\%s\\Data", m_StackResult.getStackEquipID(), time.GetYear(), time.GetMonth(), time.GetDay(), 
+				strGlassIDLevel5th.GetBuffer(0), 
+				strGlassIDLevel8th.GetBuffer(0),
+				strGlassID.GetBuffer(0)); 
+
+			//가장 최근걸 찾아야 하나? [김태현 2019/1/12]
+			sprintf(pServerFile, "%s_%s_*.csv", 
+				m_StackResult.getStackOperID(), 
+				pGlassData->m_strGlassID); 
+
+			sprintf(pLocalPath, "%s", m_StackResult.getStackLocalPath()); 
+			sprintf(pLocalFile, "%s.txt", strGlassID.GetBuffer(0)); 
+		}
+		break;
+	case FTPCMD_MURA_IMAGE: 
+		{
+			CTime time = m_tmReviewEnd;
+			sprintf(pServerPath, "%s\\%04d%02d%02d\\%s\\%s\\%s\\Image", pGlassData->m_strEquipID, time.GetYear(), time.GetMonth(), time.GetDay(), 
+				strGlassIDLevel5th.GetBuffer(0), 
+				strGlassIDLevel8th.GetBuffer(0),
+				strGlassID.GetBuffer(0)); 
+
+			sprintf(pLocalPath, "%s%s", LOCAL_MURA_IMAGE_PATH, strGlassID.GetBuffer(0)); 
+			strcpy(pServerFile, "*.*");
+			strcpy(pLocalFile, "*.*"); 
+		}
+		break;
+	case FTPCMD_INDEX:
+		{
+			CTime time = m_tmReviewEnd;
+			sprintf(pServerPath, "INDEX\\%s", pGlassData->m_strEquipID);
+			sprintf(pServerFile, "%04d%02d%02d_%s.csv", time.GetYear(), time.GetMonth(), time.GetDay(),	pGlassData->m_strStepID); 
+
+			sprintf(pLocalPath, "%s", LOCAL_INDEX_PATH); 
+			sprintf(pLocalFile, "%s", pServerFile); 
+		}
+		break;
+
+	case FTPCMD_LINK:   
+		{ 
+			CTime time = m_tmReviewEnd;
+			CString strFileName;//파일생성 시간 때문에 여기서 정확하게 파일명 다시 정정
+			{
+				//Glass 정보
+				CTime CurrTime = m_tmReviewEnd;
+				CString strTime;
+				strTime.Format(_T("%04d%02d%02d_%02d%02d%02d"),
+					CurrTime.GetYear(), CurrTime.GetMonth(), CurrTime.GetDay(), CurrTime.GetHour(), CurrTime.GetMinute(), CurrTime.GetSecond());
+				strFileName.Format("%s_%s_%s.csv", pGlassData->m_strOperID, pGlassData->m_strGlassID, strTime.GetBuffer(0));
+			}
+			sprintf(pServerPath, "%s\\%s\\%s\\%s\\%s", "LINK", pGlassData->m_strEquipID, 
+				strGlassIDLevel5th.GetBuffer(0), 
+				strGlassIDLevel8th.GetBuffer(0),
+				strGlassID.GetBuffer(0)); 
+
+			sprintf(pLocalPath, "%s", pGlassData->m_strPath);
+
+			sprintf(pServerFile, "%s", strFileName.GetBuffer(0)); 
+			sprintf(pLocalFile, "%s", strFileName.GetBuffer(0)); 
+		}
+		break;
+	} 
+
+
+}
+ 
+
+BOOL CGlassRawCSOT::WriteIndexFile( _grmGlassData* pGlassData)
+{   
+	CTime time = CTime::GetCurrentTime();//m_tmReviewEnd;
+
+	CString strLocalIndexFileName;
+	strLocalIndexFileName.Format("%s\\%04d%02d%02d_%s.csv", LOCAL_INDEX_PATH,
+		time.GetYear(), time.GetMonth(), time.GetDay(),
+		pGlassData->m_strStepID);
+
+
+	if(!PathFileExists(strLocalIndexFileName))//처음생성되는 파일인지 체크 해서 헤더 라인 넣어줌
+	{
+		FILE* pFile = fopen(strLocalIndexFileName.GetBuffer(0), "w");
+		if(pFile)
+		{
+			fprintf(pFile, "Date_Time, Path\n");
+			fclose(pFile);
+		}
+	}
+
+
+	FILE* fp = fopen(strLocalIndexFileName.GetBuffer(0), "a");  
+	if(fp == NULL) 
+		return FALSE; 
+
+
+	char strServerFolder[256] = {};
+	char strServerFile[256] = {};
+	char strLocalFolder[256] = {};
+	char pLocalFile[256] = {}; 
+
+	CString strDate;
+	strDate.Format("%04d/%02d/%02d %02d:%02d:%02d", time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond());
+
+	char* pHomePath = "/EL";
+	//Review Image File
+	{
+		GetFormatDescription(FTPCMD_REVIEW_IMAGE, strServerFolder, strServerFile, strLocalFolder, pLocalFile, pGlassData); 
+		CString strLocal_FindPath;
+		CString strServer_Path;
+		 
+		strLocal_FindPath.Format("%s\\*.*", strLocalFolder);
+		strServer_Path.Format("\\%s\\",strServerFolder);
+
+		CFileFind finder;
+		BOOL bFind = finder.FindFile(strLocal_FindPath);
+		strServer_Path.Replace('\\', '/');
+		while(bFind)
+		{ 
+			bFind = finder.FindNextFile();
+
+			if (finder.IsDots()) continue;
+			if (finder.IsDirectory()) continue;
+
+
+			fprintf(fp, "%s,%s%s%s\n", strDate, pHomePath, strServer_Path.GetBuffer(0), finder.GetFileName().GetBuffer(0));
+		}
+		finder.Close(); 
+	}
+	// Inspector Image
+	{
+		GetFormatDescription(FTPCMD_AOI_IMAGE, strServerFolder, strServerFile, strLocalFolder, pLocalFile, pGlassData); 
+		CString strLocal_FindPath;
+		CString strServer_Path;
+
+		strLocal_FindPath.Format("%s\\*.*", strLocalFolder);
+		strServer_Path.Format("\\%s\\",strServerFolder);
+		
+		CFileFind finder;
+		BOOL bFind = finder.FindFile(strLocal_FindPath);
+		strServer_Path.Replace('\\', '/');
+		while(bFind)
+		{ 
+			bFind = finder.FindNextFile();
+
+			if (finder.IsDots()) continue;
+			if (finder.IsDirectory()) continue;
+
+
+			fprintf(fp, "%s,%s%s%s\n", strDate, pHomePath, strServer_Path.GetBuffer(0), finder.GetFileName().GetBuffer(0));
+		}
+		finder.Close(); 
+	}
+	// RAW
+	{
+ 		GetFormatDescription(FTPCMD_RAW, strServerFolder, strServerFile, strLocalFolder, pLocalFile, pGlassData);
+		CString strServerPath = strServerFolder;
+		strServerPath.Replace('\\', '/');
+		fprintf(fp, "%s,%s/%s/%s\n", strDate, pHomePath, strServerPath.GetBuffer(0), strServerFile);
+	}
+	if(m_MuraResultFile.IsRead())// MURA [김태현 2019/1/10]
+	{
+		GetFormatDescription(FTPCMD_MURA_IMAGE, strServerFolder, strServerFile, strLocalFolder, pLocalFile, pGlassData); 
+		CString strLocal_FindPath;
+		CString strServer_Path;
+
+		strLocal_FindPath.Format("%s\\*.*", strLocalFolder);
+		strServer_Path.Format("\\%s\\",strServerFolder);
+
+		CFileFind finder;
+		BOOL bFind = finder.FindFile(strLocal_FindPath);
+		strServer_Path.Replace('\\', '/');
+		while(bFind)
+		{ 
+			bFind = finder.FindNextFile();
+
+			if (finder.IsDots()) continue;
+			if (finder.IsDirectory()) continue;
+
+
+			fprintf(fp, "%s,%s/%s%s\n", strDate, pHomePath, strServer_Path.GetBuffer(0), finder.GetFileName().GetBuffer(0));
+		}
+		finder.Close(); 
+	}
+
+	// Link File
+	{
+		GetFormatDescription(FTPCMD_LINK, strServerFolder, strServerFile, strLocalFolder, pLocalFile, pGlassData);
+		CString strServerPath = strServerFolder;
+		strServerPath.Replace('\\', '/');
+		fprintf(fp, "%s,%s/%s/%s\n", strDate, pHomePath, strServerPath.GetBuffer(0), strServerFile);
+	}
+
+	// Index
+	{
+		GetFormatDescription(FTPCMD_INDEX, strServerFolder, strServerFile, strLocalFolder, pLocalFile, pGlassData);  
+		CString strServerPath = strServerFolder;
+		strServerPath.Replace('\\', '/');
+		fprintf(fp, "%s,%s/%s/%s\n", strDate, pHomePath, strServerPath.GetBuffer(0), strServerFile);
+	}
+
+
+	fclose(fp);
+	return TRUE;
+
+}
+
+CString CGlassRawCSOT::GetDefectInfoToString(emDefectMemberType nDefectInfoType, int nParam)
+{  
+	CString sStr;
+	switch(nDefectInfoType)
+	{
+	case DMT_DefectJudge:// Judge
+		{
+			sStr = "O";
+			switch(nParam)
+			{
+			case 0:			sStr.Format("O");		
+				break;
+			}
+		}
+		break;
+
+	case DMT_DefectSizeType: 
+		{
+			sStr = "S";
+			switch(nParam)
+			{
+				//case SizeType_Unknown:	 sStr.Format("U");	break; 
+			case 1:	 sStr.Format("S");
+				break; 
+			case 2:		 sStr.Format("M");
+				break; 
+			case 3:	 sStr.Format("L");
+				break; 
+			case 4:		 sStr.Format("O");
+				break;
+			}
+		}
+		break;
+
+
+	}
+	return sStr;
+}

--
Gitblit v1.9.3