#include "StdAfx.h" #include "DitGlassRawClient.h" CDitGlassRawClient::CDitGlassRawClient(void) : m_mxCommandProcess(FALSE, MUTEX_RAWMESSENGER) { m_hMapBasicInfo = NULL; m_hMapGlassData = NULL; m_pDitGlassClient =NULL; m_pGlassRawInfo = NULL; m_pGlassRawData = NULL; m_nLastCommandIdx = -1; m_pGlassData = NULL; m_pBlockData = NULL; m_pCellData = NULL; m_pDefectData = NULL; } CDitGlassRawClient::~CDitGlassRawClient(void) { if (m_hMapBasicInfo!=NULL) { ::UnmapViewOfFile(m_hMapBasicInfo); m_pGlassRawInfo = NULL; } if (m_hMapGlassData!=NULL) { ::UnmapViewOfFile(m_hMapGlassData); m_pGlassRawData = NULL; } } BOOL CDitGlassRawClient::ConnectServer() { if(isConnect()) return TRUE; if(ConnectGlassRawInfo() == FALSE) { return FALSE; } if(ConnectGlassRawData() == FALSE) { return FALSE; } return TRUE; } BOOL CDitGlassRawClient::ConnectGlassRawInfo() { if(m_hMapBasicInfo == NULL) { m_hMapBasicInfo = ::OpenFileMapping(FILE_MAP_ALL_ACCESS,FALSE,SHAREDMEMNAME_BASICINFO); if (m_hMapBasicInfo) { m_pGlassRawInfo = (_grmDitGlassRawInfo*)::MapViewOfFile(m_hMapBasicInfo, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(_grmDitGlassRawInfo)); } if(m_hMapBasicInfo == NULL || m_pGlassRawInfo == NULL) { if (m_hMapBasicInfo!=NULL) { ::UnmapViewOfFile(m_hMapBasicInfo); m_pGlassRawInfo = NULL; } m_pGlassRawInfo = NULL; return FALSE; } } return TRUE; } BOOL CDitGlassRawClient::ConnectGlassRawData() { SIZE_T nGlassRawSharedSize = m_pGlassRawInfo->m_nGlassRawDataSize; if(m_hMapGlassData == NULL) { m_hMapGlassData = ::OpenFileMapping(FILE_MAP_ALL_ACCESS,FALSE,SHAREDMEMNAME_GLASSDATA); if (m_hMapGlassData) { m_pGlassRawData = (char*)::MapViewOfFile(m_hMapGlassData, FILE_MAP_ALL_ACCESS, 0, 0, nGlassRawSharedSize); } if(m_hMapGlassData == NULL || m_pGlassRawData == NULL) { if (m_hMapGlassData != NULL) { ::UnmapViewOfFile(m_hMapGlassData); m_pGlassRawData = NULL; } m_pGlassRawData = NULL; return FALSE; } } m_pGlassData = (_grmGlassData*)&m_pGlassRawData[m_pGlassRawInfo->m_nGlassDataPoint]; m_pBlockData = (_grmBlockData*)&m_pGlassRawData[m_pGlassRawInfo->m_nBlockDataPoint]; m_pCellData = (_grmCellData*)&m_pGlassRawData[m_pGlassRawInfo->m_nCellDataPoint]; m_pDefectData = (_grmDefectData*)&m_pGlassRawData[m_pGlassRawInfo->m_nDefectDataPoint]; m_pStackData = (_grmDefectData*)&m_pGlassRawData[m_pGlassRawInfo->m_nStackDataPoint]; /*< KJG 20211024 - #3487 ADD Start >*/ m_pRawMergeData = (_grmDefectData*)&m_pGlassRawData[m_pGlassRawInfo->m_nRawMergeDataPoint]; /*< KJG 20211024 - #3487 ADD End >*/ return TRUE; } BOOL CDitGlassRawClient::WriteAOIRawFile() { return SetCommand(grcWriteRaw); } BOOL CDitGlassRawClient::WriteAOIRawBinFile() { return SetCommand(grcWriteBin); } BOOL CDitGlassRawClient::ReadAOIRawBinFile() { return SetCommand(grcReadBin); } BOOL CDitGlassRawClient::WriteReviewRawBinFile() { return SetCommand(grcReviewWriteBIn); } BOOL CDitGlassRawClient::SetCommand( emGlassRawCommand nCmd ) { if(m_pGlassRawInfo == NULL) return FALSE; m_mxCommandProcess.Lock(); int nCmdId = (m_pGlassRawInfo->m_nCommandIdxWrite+1) % COMMAND_MAXCOUNT; if(m_pGlassRawInfo->m_nCommandIdxRead == nCmdId)//µÑÀÌ °°´Ù´Â°ÍÀº ¼­Å§·¯ ¹öÆÛ°¡ ÇѹÙÄû µ¹¾Ò´Ù´Â°Í!! [±èÅÂÇö 2018/11/12] { m_pGlassRawInfo->m_nCommandIdxRead++;//°¡Àå ¿À·¡µÈ ¸í·É Çϳª¸¦ »èÁ¦ÇÑ´Ù. [±èÅÂÇö 2018/11/12] } m_pGlassRawInfo->m_nCommandBuffer[nCmdId].nCommand = (short)nCmd; m_pGlassRawInfo->m_nCommandBuffer[nCmdId].strParam; m_pGlassRawInfo->m_nCommandBuffer[nCmdId].nResult = -1; //-1¼öÇàÀü, 0½ÇÆÐ, 1¼º°ø [±èÅÂÇö 2018/11/13] m_nLastCommandIdx = m_pGlassRawInfo->m_nCommandIdxWrite = nCmdId; m_mxCommandProcess.Unlock(); return TRUE; } /* < KJG 20240620 - #4942 ADD Start >*/ void CDitGlassRawClient::ResetClientResultStep() { if (isConnect() == FALSE) return; if (m_pGlassRawInfo) { m_pGlassRawInfo->m_ClientResultStep = APS_RES_None; } } emClientResult CDitGlassRawClient::GetClientResultStep() { if (isConnect() == FALSE) return APS_RES_None; if (m_pGlassRawInfo) { return m_pGlassRawInfo->m_ClientResultStep; } return APS_RES_None; } /* < KJG 20240620 - #4942 ADD End >*/ emAOIProcStep CDitGlassRawClient::GetProcessStep() { if(isConnect() == FALSE) return APS_None; if(m_pGlassRawInfo) { return m_pGlassRawInfo->m_ClientProcStep; } return APS_None; } BOOL CDitGlassRawClient::SetGlassLoading() { if(isConnect() == FALSE) return FALSE; m_pGlassRawInfo->m_ClientProcStep = APS_GlassLoading; m_pGlassData->m_bStackRead = FALSE; /*< KJG 20211024 - #3487 ADD Start >*/ m_pGlassData->m_bRawMergeRead = FALSE; /*< KJG 20211024 - #3487 ADD End >*/ return SetCommand(grcSequenceGlassLoading); } BOOL CDitGlassRawClient::SetInspectEnd() { if(isConnect() == FALSE) return FALSE; m_pGlassRawInfo->m_ClientProcStep = APS_InspectEnd; return SetCommand(grcSequenceInspectEnd); } BOOL CDitGlassRawClient::SetReviewStart() { if(isConnect() == FALSE) return FALSE; m_pGlassRawInfo->m_ClientProcStep = APS_ReviewStart; return SetCommand(grcSequenceReviewStart); } BOOL CDitGlassRawClient::SetReviewEnd() { if(isConnect() == FALSE) return FALSE; m_pGlassRawInfo->m_ClientProcStep = APS_ReviewEnd; return SetCommand(grcSequenceReviewEnd); } BOOL CDitGlassRawClient::SetReviewComtomize() { if(isConnect() == FALSE) return FALSE; m_pGlassRawInfo->m_ClientProcStep = APS_CustomReviewRead; return SetCommand(grcSequenceCustomReviewDataRead); } CDitGlassRawClient* CDitGlassRawClient::GetInstance() { if(m_pDitGlassClient == NULL) { m_pDitGlassClient = new CDitGlassRawClient; } return m_pDitGlassClient; } void CDitGlassRawClient::RemoveReviewDefects() { int nDefectNum = m_pGlassData->m_nDefectNum; int nRightDefectNum = 0;//±âÁØÁ¡ ¿À¸¥ÂÊ¿¡ À§Ä¡ÇÑ °áÇÔ °¹¼ö int nDefectDeleteNum = 0; for(int i=nDefectNum-1; i>=0; i--) { if(m_pDefectData[i].m_ReviewDefect.m_nPlanType > 0 && m_pDefectData[i].m_ReviewDefect.m_nPlanType != 1000 ) { nDefectDeleteNum++; if(nRightDefectNum) { memcpy(&m_pDefectData[i], &m_pDefectData[i+1], sizeof(_grmDefectData)*nRightDefectNum); } } else { nRightDefectNum++; } } m_pGlassData->m_nDefectNum = nDefectNum-nDefectDeleteNum; } CDitGlassRawClient* CDitGlassRawClient::m_pDitGlassClient;