From d179e328a058dba6782074c560b0853482dcc658 Mon Sep 17 00:00:00 2001 From: LYW <leeyeanwoo@diteam.co.kr> Date: 목, 11 11월 2021 17:53:57 +0900 Subject: [PATCH] Ongoing70 #3766 CF AOI Review 전설비 설정한 기준치 이상 Offset 적용시 경고 기능 추가 --- ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.cpp | 697 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 692 insertions(+), 5 deletions(-) diff --git a/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.cpp b/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.cpp index 81b16e1..0b307fc 100644 --- a/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.cpp +++ b/ReviewHistory/ReveiwHistory/ReveiwHistoryDlg.cpp @@ -12,6 +12,7 @@ #include "akGridCtrl/GridCellCheck.h" #include "akImageView.h" #include <algorithm> +#include "MacroFile.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -54,6 +55,12 @@ CReveiwHistoryDlg::CReveiwHistoryDlg(CWnd* pParent /*=nullptr*/) : CDialogEx(IDD_DLG_REVIEWHISTORY, pParent) , m_nFileCount(0) + , m_nEditCamIdx(0) + , m_nEditScanIdx(0) + , m_dEditOffsetX(0) + , m_dEditOffsetY(0) + , m_strGantryIdx(_T("")) + , m_TextLastSaveOffsetTime(_T("")) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); @@ -73,6 +80,16 @@ m_nImageCount = 0; m_nCellCount = 0; m_bAsending = FALSE; + /*< LYW 20211018 - #3684 ADD Start >*/ + m_dCurDefectIdx = 0; + m_dCurDefectID = 0; + /*< LYW 20211018 - #3684 ADD End >*/ + /*< LYW 20211029 - #3684 ADD Start >*/ + DWORD dwThreadId = 0; + HANDLE hThread = CreateThread(NULL, 0, RunThreadReviewHistory, this, 0, &dwThreadId); + m_ThreadId = dwThreadId; + /*< LYW 20211029 - #3684 ADD End >*/ + m_CheckInsViewCenterLine.SetCheck(FALSE); for (int i = 0; i < 105; i++) { @@ -83,6 +100,13 @@ m_nImageSize[i] = 0; } } + +/*< LYW 20211029 - #3684 ADD Start >*/ +CReveiwHistoryDlg::~CReveiwHistoryDlg(void) +{ + PostThreadMessage(m_ThreadId, WM_QUIT, 0, 0); +} +/*< LYW 20211029 - #3684 ADD End >*/ void CReveiwHistoryDlg::DoDataExchange(CDataExchange* pDX) { @@ -97,6 +121,13 @@ DDX_Text(pDX, IDC_EDIT_FILE_COUNT, m_nFileCount); DDX_Control(pDX, IDC_EDIT_FILE_COUNT, m_ctlFileCount); DDX_Control(pDX, IDC_PROGRESS_LOAD, m_ctlProgress); + DDX_Text(pDX, IDC_EDIT_OFFSET_CAM_IDX, m_nEditCamIdx); + DDX_Text(pDX, IDC_EDIT_OFFSET_SCAN_IDX, m_nEditScanIdx); + DDX_Text(pDX, IDC_EDIT_OFFSET_X, m_dEditOffsetX); + DDX_Text(pDX, IDC_EDIT_OFFSET_Y, m_dEditOffsetY); + DDX_Text(pDX, IDC_EDIT_DFFSET_GANTRY_IDX, m_strGantryIdx); + DDX_Text(pDX, IDC_STATIC_LAST_SAVE_OFFSET_TIME, m_TextLastSaveOffsetTime); + DDX_Control(pDX, IDC_CHECK_INS_VIEW_CENTER_LINE, m_CheckInsViewCenterLine); } BEGIN_MESSAGE_MAP(CReveiwHistoryDlg, CDialogEx) @@ -109,6 +140,8 @@ ON_BN_CLICKED(IDC_BUTTON_MAPVIEW_FIT, &CReveiwHistoryDlg::OnBnClickedButtonMapviewFit) ON_MESSAGE(UM_FORMMAP_DEFECTSELECT, OnMapDefectSelected) ON_MESSAGE(UM_FORMMAP_DEFECTMOUSEOVER, OnMapDefectMouseOver) + ON_MESSAGE(UM_WARNING_OFFSET, OnDisplayWarning) + ON_MESSAGE(UM_FORMMAP_IMAGEMOUSECLICK, OnImageClick) ON_COMMAND(ID_OPTION_PATHSETTING, &CReveiwHistoryDlg::OnOptionPathsetting) ON_COMMAND(ID_VIEW_ALLDEFECT, &CReveiwHistoryDlg::OnViewAlldefect) ON_COMMAND(ID_VIEW_REVIEWDEFECT, &CReveiwHistoryDlg::OnViewReviewdefect) @@ -121,6 +154,10 @@ ON_BN_CLICKED(IDC_CHK_REVIEW_DEFECT, &CReveiwHistoryDlg::OnClickedChkReviewDefect) ON_BN_CLICKED(IDC_CHK_SINGLE, &CReveiwHistoryDlg::OnClickedChkSingle) ON_EN_CHANGE(IDC_EDIT_FILE_COUNT, &CReveiwHistoryDlg::OnChangeEditFileCount) + ON_WM_KEYDOWN() + ON_BN_CLICKED(IDC_BUTTON_OFFSET_APPLY, &CReveiwHistoryDlg::OnBnClickedButtonOffsetApply) + ON_BN_CLICKED(IDC_BUTTON_OFFSET_SAVE, &CReveiwHistoryDlg::OnBnClickedButtonOffsetSave) + ON_BN_CLICKED(IDC_CHECK_INS_VIEW_CENTER_LINE, &CReveiwHistoryDlg::OnBnClickedCheckInsViewCenterLine) END_MESSAGE_MAP() // CReveiwHistoryDlg 硫붿떆吏� 泥섎━湲� @@ -193,6 +230,13 @@ InitGridReviewLIst(&m_gridReviewList, IDC_STATIC_GRID_GLASS); InitGridDefectLIst(&m_gridDefectInfo, IDC_STATIC_GRID_DEFECT); InitGridGlassLIst(&m_gridGlassInfo, IDC_STATIC_GRID_GLASS_INFO); + + /*< LYW 20211025 - #3684 ADD Start >*/ + CString strPath = _T(""); + InitDataInfo(); + strPath.Format(_T("%s%s"), REVIEW_OFFSET_CONFIGFILE_PATH, REVIEW_OFFSET_CONFIGFILE_NAME); + LoadOffset(strPath); + /*< LYW 20211025 - #3684 ADD End >*/ OnViewReviewdefect(); @@ -279,7 +323,15 @@ // // 洹몃┝�쓣 Picture Control �겕湲곕줈 �솕硫댁뿉 異쒕젰�븳�떎. // m_ReviewImage.Draw(dc, m_picture_rect); // } - if (!m_DefectImage.IsNull()) + //LYW 20210825 #3486 ADD START + if (!m_DefectRotateImage.IsNull()) + { + dc.SetStretchBltMode(COLORONCOLOR); + // 洹몃┝�쓣 Picture Control �겕湲곕줈 �솕硫댁뿉 異쒕젰�븳�떎. + m_DefectRotateImage.Draw(dc, m_picture_rect2); + } + //LYW 20210825 #3486 ADD END + else if (!m_DefectImage.IsNull()) { dc.SetStretchBltMode(COLORONCOLOR); // 洹몃┝�쓣 Picture Control �겕湲곕줈 �솕硫댁뿉 異쒕젰�븳�떎. @@ -295,6 +347,10 @@ { dc.SetStretchBltMode(COLORONCOLOR); m_AlignSecend.Draw(dc, m_Align_rect2); + } + if (m_CheckInsViewCenterLine.GetCheck() == TRUE) + { + DrawInsViewCenterLine(&dc); } CDialogEx::OnPaint(); } @@ -730,7 +786,7 @@ return TRUE; } - else if (NM_CLICK == pDispInfo->hdr.code) + else if (NM_CLICK == pDispInfo->hdr.code || LVN_ITEMCHANGING == pDispInfo->hdr.code) { if (pDispInfo->item.row == 0) { @@ -856,7 +912,7 @@ return TRUE; } - else if (NM_CLICK == pDispInfo->hdr.code) + else if (NM_CLICK == pDispInfo->hdr.code || LVN_ITEMCHANGING == pDispInfo->hdr.code) { if (pDispInfo->item.row == 0) { @@ -870,6 +926,7 @@ _akDefect* pDefectInfo = &m_Formation.m_vecDefects[pDispInfo->item.row - 1]; m_FormationMap.setSelectDefect(pDefectInfo->m_nDefectID); + //ImageShow(pDefectInfo->m_nDefectID); if (!m_bDefectAll) { @@ -1201,6 +1258,12 @@ return 0; } +LRESULT CReveiwHistoryDlg::OnDisplayWarning(WPARAM wParam, LPARAM lParam) +{ + AfxMessageBox(_T("�꽑�깮�븯�떊 由щ럭 �뜲�씠�꽣�뒗 吏�湲� �쟻�슜�맂 OFFSET �뜲�씠�꽣 �씠�쟾�쓽 �뜲�씠�꽣 �엯�땲�떎. �솗�떎�븳 寃쎌슦媛� �븘�땲�씪硫� OFFSET �뀑�똿�쓣 湲덊빐二쇱떗�떆�삤."), MB_OK | MB_ICONWARNING); + return 0; +} + LRESULT CReveiwHistoryDlg::OnListDefectSelected(WPARAM wParam, LPARAM lParam) { int nSelectDefect = static_cast<int>(wParam); @@ -1210,6 +1273,62 @@ return 0; } + +/*< LYW 20211018 - #3684 ADD Start >*/ +LRESULT CReveiwHistoryDlg::OnImageClick(WPARAM wParam, LPARAM lParam) +{ + CPathSettingDlg* lpDlg = CPathSettingDlg::GetMgr(); + if (lpDlg == NULL) return 0; + + _akDefect *pDefect; + pDefect = &m_Formation.m_vecDefects[m_dCurDefectIdx]; + if (pDefect == NULL) return 0; + + CPoint Point; + Point.x = GET_X_LPARAM(lParam); + Point.y = GET_Y_LPARAM(lParam); + + int dOffsetDrectionX; + int dOffsetDrectionY; + + if (lpDlg->m_comboDirectionX.GetCurSel() == 1) dOffsetDrectionX = -1; + else dOffsetDrectionX = 1; + + if (lpDlg->m_comboDirectionY.GetCurSel() == 1) dOffsetDrectionY = -1; + else dOffsetDrectionY = 1; + + if (pDefect->m_nDefectID == m_dCurDefectID) + { + m_nEditCamIdx = pDefect->m_nCameraID; + m_nEditScanIdx = pDefect->m_nScanIdx; + m_nCurModelIdx = pDefect->m_nModelIdx; + if (m_nCurModelIdx == 0) + { + m_strGantryIdx = _T("Left"); + m_dEditOffsetX = (double)(dOffsetDrectionX * (Point.x / 5)) / 1000; + m_dEditOffsetY = (double)-(dOffsetDrectionY * (Point.y / 5)) / 1000; + } + else if (m_nCurModelIdx == 1) + { + m_strGantryIdx = _T("Right"); + m_dEditOffsetX = (double)-(dOffsetDrectionX * (Point.x / 5)) / 1000; + m_dEditOffsetY = (double)-(dOffsetDrectionY * (Point.y / 5)) / 1000; + } + else AfxMessageBox(_T("寃먰듃由� �씤�뜳�뒪媛� 鍮꾩젙�긽 �엯�땲�떎."), MB_OK | MB_ICONWARNING); + } + + else + { + if (IDOK == AfxMessageBox(_T("�씠誘몄� �씤�뜳�뒪媛� �씪移섑븯吏� �븡�뒿�땲�떎."), MB_OK | MB_ICONWARNING)) + { + return 0; + } + } + + UpdateData(FALSE); + return 0; +} +/*< LYW 20211018 - #3684 ADD End >*/ LRESULT CReveiwHistoryDlg::OnMapDefectMouseOver(WPARAM wParam, LPARAM lParam) { @@ -1349,6 +1468,8 @@ nSecond = write_local_time.wSecond; CString strTime; strTime.Format("%04d-%02d-%02d-%02d-%02d-%02d", nYear, nMonth, nDay, nHour, nMinute, nSecond); + + CloseHandle(h_File); m_vecStrGridTimeList.push_back(strTime); } @@ -1466,6 +1587,12 @@ Imagenoload(); return; } + + /*< LYW 20211028 - #3684 ADD Start >*/ + CString strBinFileName; + strBinFileName.Format("%s\\%s", strBinPath, strFileName); + m_CurrentResultFileTime = GetCurrentResultFileTime(strBinFileName); + /*< LYW 20211028 - #3684 ADD End >*/ if (bNewFile && m_chkSingle.GetCheck()) { @@ -1692,6 +1819,12 @@ { SetScrollSetting(); } + /*< LYW 20211028 - #3684 ADD Start >*/ + if (m_LastSaveOffsetTime >= m_CurrentResultFileTime) + { + PostThreadMessage(m_ThreadId, UM_THREAD_WARNING_OFFSET, 0, 0); + } + /*< LYW 20211028 - #3684 ADD End >*/ } void CReveiwHistoryDlg::OnCbnSelchangeComboRawtype() @@ -1706,6 +1839,25 @@ m_ConfigOption.m_nSelectRawType = 3; +} + +void CReveiwHistoryDlg::DrawInsViewCenterLine(CPaintDC * pDC) +{ + if (m_picture_rect2.Width() == 0 || m_picture_rect2.Height() == 0) return; + + CRect rtDraw = m_picture_rect2; + + CPen pen, *pPen = NULL; + pen.CreatePen(PS_DOT, 1, RGB(255, 0, 0)); + pDC->SelectObject(&pen); + + //pDC->SelectStockObject(WHITE_PEN); + + // center line + pDC->MoveTo((rtDraw.Width() / 2) + rtDraw.left, 0 + rtDraw.top); + pDC->LineTo((rtDraw.Width() / 2) + rtDraw.left, rtDraw.Height() + rtDraw.top); + pDC->MoveTo(0 + rtDraw.left, (rtDraw.Height() / 2) + rtDraw.top); + pDC->LineTo(rtDraw.Width() + rtDraw.left, (rtDraw.Height() / 2) + rtDraw.top); } void CReveiwHistoryDlg::OnBnClickedBtnFindBin() @@ -1968,6 +2120,9 @@ m_DefectImage.Destroy(); m_ReviewImage.Destroy(); + //LYW 20210825 #3486 ADD START + m_DefectRotateImage.Destroy(); + //LYW 20210825 #3486 ADD END m_AlignFirst.Destroy(); m_AlignSecend.Destroy(); @@ -2010,6 +2165,13 @@ } } _akReviewList* pImageInfo = &m_Formation.m_vecImage[nIndex]; + m_dCurDefectID = pImageInfo->m_nDefectID; + m_dCurDefectIdx = nIndex; +// _akDefect *pDefect; +// pDefect = &m_Formation.m_vecDefects[nIndex]; +// m_dCurDefectCam = pDefect->m_nCameraID; +// m_dCurDefectModuleIdx = pDefect->m_nModelIdx; +// m_dCurDefectScan = pDefect->m_nScanIdx; //紐� 踰덉㎏ �씤吏� �뜕吏꾨떎. CString wekfjlwe = pImageInfo->m_strReviewImageName; @@ -2055,7 +2217,7 @@ DeftectPath.Format(_T("%s\\%s\\%s"), strReviewPath, strReviewImagePath, strReviewImageName); //DeftectPath2.Format(_T("%s\\%s"), strInspectorPath, strInspectorName); if (strInspectorName == "*" || strInspectorName == "**" || strInspectorName == "***") strInspectorName = ""; - DeftectPath2.Format(_T("%s\\%s\\%s"), strInspectorPath, pImageInfo->m_strGlassID, strReviewImageName); + DeftectPath2.Format(_T("%s\\%s\\%s"), strInspectorPath, pImageInfo->m_strGlassID, strInspectorName); AlignPath.Format(_T("%s\\%s\\%s"), strAlignPath, pImageInfo->m_strGlassID, strAlignName); AlignPath2.Format(_T("%s\\%s\\%s"), strAlignPath, pImageInfo->m_strGlassID, strAlignName2); @@ -2096,13 +2258,21 @@ if (CFile::GetStatus(DeftectPath2, FileOn) && strInspectorName != "") //�뙆�씪�씠 �엳�쓣 �븣 { m_DefectImage.Load(DeftectPath2); + //LYW 20210825 #3486 ADD START + m_DefectRotateImage.Create(m_DefectImage.GetWidth(), m_DefectImage.GetHeight(), m_DefectImage.GetBPP(), 0); + ImageRotate(m_DefectImage, m_DefectRotateImage); + //LYW 20210825 #3486 ADD END HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), DeftectPath2, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); InvalidateRect(m_picture_rect2, FALSE); dc.SetStretchBltMode(COLORONCOLOR); - m_DefectImage.Draw(dc, m_picture_rect2); + //LYW 20210825 #3486 MOD START + m_DefectRotateImage.Draw(dc, m_picture_rect2); + //LYW 20210825 #3486 MOD END + //original + //m_DefectImage.Draw(dc, m_picture_rect2); } else { @@ -2490,6 +2660,9 @@ // m_ReviewImage.Destroy(); m_DefectImage.Destroy(); + //LYW 20210825 #3486 ADD START + m_DefectRotateImage.Destroy(); + //LYW 20210825 #3486 ADD END m_AlignFirst.Destroy(); m_AlignSecend.Destroy(); @@ -2527,6 +2700,48 @@ m_AlignSecend.Draw(dc, m_Align_rect2); } +//LYW 20210825 #3486 ADD START +void CReveiwHistoryDlg::ImageRotate(CImage & SrcImage, CImage & DstImage, double degree/* = 180.0 */) +{ + int Height = SrcImage.GetHeight(); // �꽭濡� 湲몄씠 ���옣 + int Width = SrcImage.GetWidth(); // 媛�濡� 湲몄씠 ���옣 + int new_x, new_y; + int R, G, B; + int center_x = (SrcImage.GetWidth() / 2); // �쉶�쟾 以묒떖�젏 + int center_y = (SrcImage.GetHeight() / 2); // �쉶�쟾 以묒떖�젏 + + double seta = 3.14 / (180.0 / degree); // �씪�뵒�븞 + double CosSeta = cos(seta); + double SinSeta = sin(seta); + + for (int y = 0; y < Height; y++) + { + for (int x = 0; x < Width; x++) + { + new_x = (int)((x - center_x) * CosSeta - (y - center_y) * SinSeta + center_x); + new_y = (int)((x - center_x) * SinSeta + (y - center_y) * CosSeta + center_y); + + if ((new_x < 0) || (new_x > Width) || (new_y < 0) || (new_y > Height)) + //�씠誘몄� 踰붿쐞瑜� 踰쀬뼱�굹硫� 0 媛� + { + R = 0; + G = 0; + B = 0; + } + else + { + R = GetRValue(SrcImage.GetPixel(new_x, new_y)); + G = GetGValue(SrcImage.GetPixel(new_x, new_y)); + B = GetBValue(SrcImage.GetPixel(new_x, new_y)); + } + DstImage.SetPixel((int)x, (int)y, RGB(R, G, B)); + new_x = 0; new_y = 0; + } + } + +} +//LYW 20210825 #3486 ADD END + void CReveiwHistoryDlg::OnChangeEditFileCount() { // TODO: RICHEDIT 而⑦듃濡ㅼ씤 寃쎌슦, �씠 而⑦듃濡ㅼ� @@ -2539,6 +2754,63 @@ m_ctlFileCount.GetWindowText(strCount); m_nFileCount = _ttoi(strCount); } + +/*< LYW 20211028 - #3684 ADD Start >*/ +void CReveiwHistoryDlg::UpdateLastSaveOffsetTime(CString FileName) +{ + + HANDLE h_file = CreateFile(FileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + + FILETIME create_time, access_time, write_time; + GetFileTime(h_file, &create_time, &access_time, &write_time); + + SYSTEMTIME access_system_time; + FileTimeToSystemTime(&access_time, &access_system_time); + + SYSTEMTIME access_system_Local_time; + SystemTimeToTzSpecificLocalTime(NULL, &access_system_time, &access_system_Local_time); + + CTime FIleTime(access_system_Local_time); + m_LastSaveOffsetTime = FIleTime; + + CloseHandle(h_file); + + m_TextLastSaveOffsetTime.Format(_T("%04d/%02d/%02d/%02d:%02d:%02d"), m_LastSaveOffsetTime.GetYear(), m_LastSaveOffsetTime.GetMonth(), + m_LastSaveOffsetTime.GetDay(), m_LastSaveOffsetTime.GetHour(), m_LastSaveOffsetTime.GetMinute(), m_LastSaveOffsetTime.GetSecond()); + + UpdateData(FALSE); +} +CTime CReveiwHistoryDlg::GetCurrentResultFileTime(CString FileName) +{ + HANDLE h_file = CreateFile(FileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + + if (h_file != INVALID_HANDLE_VALUE) + { + FILETIME create_time, access_time, write_time; + GetFileTime(h_file, &create_time, &access_time, &write_time); + + SYSTEMTIME access_system_time; + FileTimeToSystemTime(&access_time, &access_system_time); + + SYSTEMTIME access_system_Local_time; + SystemTimeToTzSpecificLocalTime(NULL, &access_system_time, &access_system_Local_time); + + CloseHandle(h_file); + + CTime FIleTime(access_system_Local_time); + m_CurrentResultFileTime = FIleTime; + + return m_CurrentResultFileTime; + } + + else + { + return CTime::GetCurrentTime(); + } + + +} +/*< LYW 20211028 - #3684 ADD End >*/ BOOL CReveiwHistoryDlg::GetCheckFileLoad(int nCount) { @@ -3764,3 +4036,418 @@ } m_Formation.m_vecHeaderTemp.clear(); } + + +void CReveiwHistoryDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + // TODO: �뿬湲곗뿉 硫붿떆吏� 泥섎━湲� 肄붾뱶瑜� 異붽� 諛�/�삉�뒗 湲곕낯媛믪쓣 �샇異쒗빀�땲�떎. + + CDialogEx::OnKeyDown(nChar, nRepCnt, nFlags); +} + +/*< LYW 20211025 - #3684 ADD Start >*/ +void CReveiwHistoryDlg::OnBnClickedButtonOffsetApply() +{ + // TODO: �뿬湲곗뿉 而⑦듃濡� �븣由� 泥섎━湲� 肄붾뱶瑜� 異붽��빀�땲�떎. + ApplyOffset(m_nCurModelIdx, m_nEditCamIdx, m_nEditScanIdx, m_dEditOffsetX, m_dEditOffsetY); +} + + +void CReveiwHistoryDlg::OnBnClickedButtonOffsetSave() +{ + // TODO: �뿬湲곗뿉 而⑦듃濡� �븣由� 泥섎━湲� 肄붾뱶瑜� 異붽��빀�땲�떎. + SaveOffset(); + SendMsg2ReviewSystem(); +} + +BOOL CReveiwHistoryDlg::LoadOffset(CString strFilePath) +{ + //dBarValue = 0; + CMacroFile macroFile; + + if (!macroFile.Read(strFilePath)) + return FALSE; + + UpdateLastSaveOffsetTime(strFilePath); + + macroFile.GetItem(_T("CAMERA_COUNT"), m_nCameraCount, 0); + macroFile.GetItem(_T("SCAN_COUNT"), m_nScanCount, 0); + macroFile.GetItem(_T("XPOS_COUNT"), m_XposCount, 0); + /*< LYW 20211111 - #3766 ADD Start >*/ + macroFile.GetItem(_T("WARN_STANDARD"), m_dWarnStandard, 0); + macroFile.GetItem(_T("HARD_STANDARD"), m_dHardStandard, 0); + /*< LYW 20211111 - #3766 ADD End >*/ + CString strItem = _T(""); + double dXoffset = 0; + double dYoffset = 0; + double dXMin = 0; + double dXMAX = 0; + + double dValue = 0; + dValue = 2 * CAM_MAX_COUNT*SCAN_MAX_COUNT; + dValue = 1600 / dValue; + + for (int nModuleidx = 0; nModuleidx < 2; nModuleidx++) + { + for (int nCamidx = 0; nCamidx < CAM_MAX_COUNT; nCamidx++) + { + for (int nScanidx = 0; nScanidx < SCAN_MAX_COUNT; nScanidx++) + { + + for (int nXposIndex = 0; nXposIndex < XPOS_MAX_COUNT; nXposIndex++) + { + + strItem.Format(_T("MODULE[%d]_CAM[%d]_SCAN[%d]_IDX[%d]_OFFSET_X"), nModuleidx, nCamidx, nScanidx, nXposIndex); + macroFile.GetItem(strItem, dXoffset); + + + strItem.Format(_T("MODULE[%d]_CAM[%d]_SCAN[%d]_IDX[%d]_OFFSET_Y"), nModuleidx, nCamidx, nScanidx, nXposIndex); + macroFile.GetItem(strItem, dYoffset); + + strItem.Format(_T("MODULE[%d]_CAM[%d]_SCAN[%d]_IDX[%d]_XPOS_X_MIN"), nModuleidx, nCamidx, nScanidx, nXposIndex); + macroFile.GetItem(strItem, dXMin); + + strItem.Format(_T("MODULE[%d]_CAM[%d]_SCAN[%d]_IDX[%d]_XPOS_X_MAN"), nModuleidx, nCamidx, nScanidx, nXposIndex); + macroFile.GetItem(strItem, dXMAX); + + SetInputOffSet(nModuleidx, nCamidx, nScanidx, nXposIndex, dXoffset, dYoffset, dXMin, dXMAX); + + } + //IncressProcessBar(dValue); + } + } + } + + return TRUE; + +} + +BOOL CReveiwHistoryDlg::SaveOffset() +{ + //dBarValue = 0; + + CString strForderPath; + CString strFileName; + CTime time = CTime::GetCurrentTime(); + /*< LYW 20211028 - #3684 ADD Start >*/ + m_LastSaveOffsetTime = time; + /*< LYW 20211028 - #3684 ADD End >*/ + strFileName.Format(_T("ReviewOffSet_%04d%02d%02d%02d%02d%02d.cfg"), time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond()); + strForderPath.Format(_T("%s%s"), REVIEW_OFFSET_BACKUP_FORDER_PATH, strFileName); + + CopyFile(REVIEW_OFFSET_CONFIGFILE_FULL_PATHNAME, strForderPath, FALSE); + + BOOL bReturn = FALSE; + CString strTemp; + int nTemp; + double dTemp; + + CMacroFile macroFile; + macroFile.Clear(); + + CString strItem = _T(""); + + + strItem.Format(_T("CAMERA_COUNT")); + macroFile.SetItem(strItem, m_nCameraCount); + + strItem.Format(_T("SCAN_COUNT")); + macroFile.SetItem(strItem, m_nScanCount); + + strItem.Format(_T("XPOS_COUNT")); + macroFile.SetItem(strItem, m_XposCount); + + /*< LYW 20211111 - #3766 ADD Start >*/ + strItem.Format(_T("WARN_STANDARD")); + macroFile.SetItem(strItem, m_dWarnStandard); + + strItem.Format(_T("HARD_STANDARD")); + macroFile.SetItem(strItem, m_dHardStandard); + /*< LYW 20211111 - #3766 ADD End >*/ + + + CString strData; + double dData = 0; + for (int nModuleidx = 0; nModuleidx < 2; nModuleidx++) + { + for (int nCamidx = 0; nCamidx < CAM_MAX_COUNT; nCamidx++) + { + for (int nScanidx = 0; nScanidx < SCAN_MAX_COUNT; nScanidx++) + { + + for (int nXposIndex = 0; nXposIndex < XPOS_MAX_COUNT; nXposIndex++) + { + + OffSetInfo pOffSet = GetOffSetInfo(nModuleidx, nCamidx, nScanidx, nXposIndex); + + strItem.Format(_T("MODULE[%d]_CAM[%d]_SCAN[%d]_IDX[%d]_OFFSET_X"), nModuleidx, nCamidx, nScanidx); + dData = pOffSet.dXoffSetValue; + macroFile.SetItem(strItem, dData); + + strItem.Format(_T("MODULE[%d]_CAM[%d]_SCAN[%d]_IDX[%d]_OFFSET_Y"), nModuleidx, nCamidx, nScanidx); + dData = pOffSet.dYoffSetValue; + macroFile.SetItem(strItem, dData); + + strItem.Format(_T("MODULE[%d]_CAM[%d]_SCAN[%d]_IDX[%d]_XPOS_X_MIN"), nModuleidx, nCamidx, nScanidx); + dData = pOffSet.dXposMin; + macroFile.SetItem(strItem, dData); + + strItem.Format(_T("MODULE[%d]_CAM[%d]_SCAN[%d]_IDX[%d]_XPOS_X_MAN"), nModuleidx, nCamidx, nScanidx); + dData = pOffSet.dXposMax; + macroFile.SetItem(strItem, dData); + } + //IncressProcessBar(5); + } + } + } + + CString strFilePath; + strFilePath.Format(_T("%s%s"), REVIEW_OFFSET_CONFIGFILE_PATH, REVIEW_OFFSET_CONFIGFILE_NAME); + + bReturn = macroFile.Write(strFilePath); + + if (bReturn) + { + /*< LYW 20211028 - #3684 ADD Start >*/ + UpdateLastSaveOffsetTime(strFilePath); + AfxMessageBox(_T("OFFSET SAVE SUCCESS"), MB_OK | MB_ICONASTERISK); + /*< LYW 20211028 - #3684 ADD End >*/ + } + else AfxMessageBox(_T("OFFSET SAVE FAIL"), MB_OK | MB_ICONHAND); + + return bReturn; +} + +BOOL CReveiwHistoryDlg::SendMsg2ReviewSystem() +{ + HWND hWnd = ::FindWindow(NULL, _T("ReviewSystem")); + + if (hWnd) + { + COPYDATASTRUCT cds; + cds.dwData = COPYDATA_REVIEWHISTORYOR2REVIEWSYSTEM; + cds.cbData = 0; + cds.lpData = 0; + + ::SendMessage(hWnd, WM_COPYDATA, 0, (LPARAM)(LPVOID)&cds); + + return TRUE; + } + + return FALSE; +} + +BOOL CReveiwHistoryDlg::ApplyOffset(int nModuleidx, int nCamIndex, int ScanIndex, double dXOffsetValue, double dYOffsetValue) +{ + if (nCamIndex > CAM_MAX_COUNT || nCamIndex < 0) + { + return FALSE; + } + + if (ScanIndex > SCAN_MAX_COUNT || ScanIndex < 0) + { + return FALSE; + } + + + if (nModuleidx == 0) + { + VecOffSetScanData* pScandata = &m_vecOffSetCameraInfo[nCamIndex]; + VecOffSetData* pData = &pScandata->at(ScanIndex); + OffSetInfo* pOffSetData = &pData->at(0); + if (pOffSetData->bCheckSave == TRUE) + { + AfxMessageBox(_T("�씠誘� ���옣�븳 OFFSET �엯�땲�떎. �떎�떆 �뀑�똿�쓣 �썝�븯�떆硫� �봽濡쒓렇�옩�쓣 �옱�떆�옉 �빐二쇱꽭�슂"), MB_OK | MB_ICONWARNING); + return FALSE; + } + else + { + pOffSetData->dXoffSetValue += dXOffsetValue; + pOffSetData->dYoffSetValue += dYOffsetValue; + pOffSetData->bCheckSave = TRUE; + } + } + else if (nModuleidx == 1) + { + VecOffSetScanData* pScandata = &m_vecOffSetCameraInfo2[nCamIndex]; + VecOffSetData* pData = &pScandata->at(ScanIndex); + OffSetInfo* pOffSetData = &pData->at(0); + if (pOffSetData->bCheckSave == TRUE) + { + AfxMessageBox(_T("�씠誘� ���옣�븳 OFFSET �엯�땲�떎. �떎�떆 �뀑�똿�쓣 �썝�븯�떆硫� �봽濡쒓렇�옩�쓣 �옱�떆�옉 �빐二쇱꽭�슂"), MB_OK | MB_ICONWARNING); + return FALSE; + } + else + { + pOffSetData->dXoffSetValue += dXOffsetValue; + pOffSetData->dYoffSetValue += dYOffsetValue; + pOffSetData->bCheckSave = TRUE; + } + } + else + { + return FALSE; + } +} + +BOOL CReveiwHistoryDlg::SetInputOffSet(int nModuleidx, int nCamIndex, int ScanIndex, int nXposIndex, double dXOffsetValue, double dYOffsetValue, double dXposMin, double dXposMax, BOOL bCheckSave/* = 0*/) +{ + if (nCamIndex > CAM_MAX_COUNT || nCamIndex < 0) + { + return FALSE; + } + + if (ScanIndex > SCAN_MAX_COUNT || ScanIndex < 0) + { + return FALSE; + } + + + if (nModuleidx == 0) + { + VecOffSetScanData* pScandata = &m_vecOffSetCameraInfo[nCamIndex]; + VecOffSetData* pData = &pScandata->at(ScanIndex); + OffSetInfo* pOffSetData = &pData->at(nXposIndex); + pOffSetData->dXoffSetValue = dXOffsetValue; + pOffSetData->dYoffSetValue = dYOffsetValue; + pOffSetData->dXposMin = dXposMin; + pOffSetData->dXposMax = dXposMax; + pOffSetData->bCheckSave = bCheckSave; + + } + else if (nModuleidx == 1) + { + VecOffSetScanData* pScandata = &m_vecOffSetCameraInfo2[nCamIndex]; + VecOffSetData* pData = &pScandata->at(ScanIndex); + OffSetInfo* pOffSetData = &pData->at(nXposIndex); + pOffSetData->dXoffSetValue = dXOffsetValue; + pOffSetData->dYoffSetValue = dYOffsetValue; + pOffSetData->dXposMin = dXposMin; + pOffSetData->dXposMax = dXposMax; + pOffSetData->bCheckSave = bCheckSave; + } + else + { + return FALSE; + } +} + +void CReveiwHistoryDlg::InitDataInfo() +{ + //誘몃━ 怨듦컙 �븷�떦 + for (int nCamidx = 0; nCamidx < CAM_MAX_COUNT; nCamidx++) + { + + VecOffSetScanData pVecScanData; + for (int nScanidx = 0; nScanidx < SCAN_MAX_COUNT; nScanidx++) + { + VecOffSetData pVecData; + for (int nXposIndex = 0; nXposIndex < XPOS_MAX_COUNT; nXposIndex++) + { + + OffSetInfo pInfo; + pInfo.nXposIndex = nXposIndex; + pInfo.nScanIndex = nScanidx; + pInfo.nCamIndex = nCamidx; + pVecData.push_back(pInfo); + + } + pVecScanData.push_back(pVecData); + + } + + m_vecOffSetCameraInfo.push_back(pVecScanData); + } + + for (int nCamidx = 0; nCamidx < CAM_MAX_COUNT; nCamidx++) + { + + VecOffSetScanData pVecScanData; + for (int nScanidx = 0; nScanidx < SCAN_MAX_COUNT; nScanidx++) + { + VecOffSetData pVecData; + for (int nXposIndex = 0; nXposIndex < XPOS_MAX_COUNT; nXposIndex++) + { + + OffSetInfo pInfo; + pInfo.nXposIndex = nXposIndex; + pInfo.nScanIndex = nScanidx; + pInfo.nCamIndex = nCamidx; + pVecData.push_back(pInfo); + + } + pVecScanData.push_back(pVecData); + + } + + m_vecOffSetCameraInfo2.push_back(pVecScanData); + } + +} + +OffSetInfo CReveiwHistoryDlg::GetOffSetInfo(int nModuleidx, int nCamIndex, int ScanIndex, int nXposIndex) +{ + OffSetInfo pOFF; + if (nCamIndex > CAM_MAX_COUNT || nCamIndex < 0) + { + return pOFF; + } + + if (ScanIndex > SCAN_MAX_COUNT || ScanIndex < 0) + { + return pOFF; + } + + + if (nModuleidx == 0) + { + VecOffSetScanData* pScandata = &m_vecOffSetCameraInfo[nCamIndex]; + VecOffSetData* pData = &pScandata->at(ScanIndex); + OffSetInfo* pOffSetData = &pData->at(nXposIndex); + + return *pOffSetData; + } + else if (nModuleidx == 1) + { + VecOffSetScanData* pScandata = &m_vecOffSetCameraInfo2[nCamIndex]; + VecOffSetData* pData = &pScandata->at(ScanIndex); + OffSetInfo* pOffSetData = &pData->at(nXposIndex); + return *pOffSetData; + } + else + { + return pOFF; + } +} +/*< LYW 20211025 - #3684 ADD End >*/ + +/*< LYW 20211029 - #3684 ADD Start >*/ +DWORD RunThreadReviewHistory(LPVOID param) +{ + MSG msg; + CReveiwHistoryDlg* pDlg = (CReveiwHistoryDlg*)param; + while (GetMessage(&msg, NULL, 0, 0)) + { + //CString* pstrLog = reinterpret_cast<CString*>(msg.wParam); + switch (msg.message) + { + case UM_THREAD_WARNING_OFFSET: + + Sleep(100); + pDlg->PostMessage(UM_WARNING_OFFSET); + break; + + default: + break; + } + } + return 0; +} +/*< LYW 20211029 - #3684 ADD End >*/ + +void CReveiwHistoryDlg::OnBnClickedCheckInsViewCenterLine() +{ + // TODO: �뿬湲곗뿉 而⑦듃濡� �븣由� 泥섎━湲� 肄붾뱶瑜� 異붽��빀�땲�떎. + Invalidate(TRUE); + +} -- Gitblit v1.9.3