// ViewHWSetting.cpp : 备泅 颇老涝聪促. // #include "stdafx.h" #include "EdgeInspector_App.h" #include "ViewMain_HWSetting.h" #include "afxdialogex.h" #include "Global_Define.h" #include "NewCellTypes\GridCellCombo.h" // CViewHWSetting 措拳 惑磊涝聪促. extern BOOL g_bUse_SaveAllDMP; const int LIGHT_COLUMN_COUNT = 4; const TCHAR* LIGHT_COLUMN_ITEM[LIGHT_COLUMN_COUNT] = {_T("ID"),_T("Type"),_T("Port&IP"),_T("Maker")}; const int LIGHT_COLUMN_WIDHT[LIGHT_COLUMN_COUNT] = {70,104,104,104}; const int CAMERA_COLUMN_COUNT = 19; const TCHAR* CAMERA_COLUMN_ITEM[CAMERA_COLUMN_COUNT] = {_T("Cam Idx"),_T("Scan"),_T("Cam Dir."),_T("Scan Size"),_T("Dimension"),_T("Margin(L)"),_T("Margin(R)"),_T("0 Hand Resolution(H)") ,_T("0 Hand Resolution(V)"),_T("1 Hand Resolution(H)"),_T("1 Hand Resolution(V)"),_T("Frame(H)"),_T("Frame(V)"),_T("Grab Count"),_T("Light R"),_T("Light R Channel"),_T("Light T"),_T("Light T Channel") ,_T("Image Flip X")}; const int CAMERA_COLUMN_WIDHT[CAMERA_COLUMN_COUNT] = {60,50,80,80,80,80,80,120 ,120,120,120,80,80,100,80,140,70,140 ,140}; #define GRID_FIX_COLOR RGB(144,200,246) #define GRID_COLOR RGB(242,242,242) #define GRID_TEXT_COLOR RGB(255,255,255) #define GRID_LINE_COLOR GRID_FIX_COLOR IMPLEMENT_DYNAMIC(CViewMain_HWSetting, CDialogEx) CViewMain_HWSetting::CViewMain_HWSetting(CWnd* pParent /*=NULL*/) : CDialogEx(CViewMain_HWSetting::IDD, pParent) { m_pDlgHDSettingParm = new CHardwareSettings; m_pHDSetting = NULL; m_pDlgLicenseInfo = NULL; } CViewMain_HWSetting::~CViewMain_HWSetting() { delete m_pDlgHDSettingParm; m_pDlgHDSettingParm = NULL; } void CViewMain_HWSetting::DoDataExchange(CDataExchange* pDX) { DDX_Control(pDX, IDC_LIGHT_LIST, m_LightGrid); DDX_Control(pDX, IDC_CAMERA_LIST, m_CameraGrid); CPLCSettings *pPLC = m_pDlgHDSettingParm->GetPLCSettings(); if(pPLC != NULL) { DDX_Text(pDX, IDC_EDIT_PLC_DELAY, pPLC->m_nPLCLoopTime); } DDX_Text(pDX, IDC_EDIT_LIGHT_TRANS_COUNT, m_pDlgHDSettingParm->m_nLightCount_Trans); DDX_Text(pDX, IDC_EDIT_LIGHT_REFLECT_COUNT, m_pDlgHDSettingParm->m_nLightCount_Reflect); DDX_Text(pDX, IDC_EDIT_CAMERA_COUNT, m_pDlgHDSettingParm->m_nCameraCount); DDX_Text(pDX, IDC_EDIT_SCAN_COUNT, m_pDlgHDSettingParm->m_nScanCount); DDX_Text(pDX, IDC_EDIT_MACHINE_NAME, m_pDlgHDSettingParm->m_strMachineName); DDX_Text(pDX, IDC_EDIT_LINE_ID, m_pDlgHDSettingParm->m_strLineID); DDX_Check(pDX,IDC_CHK_INS_REVERSE,m_pDlgHDSettingParm->m_bInsDirReverse); DDX_Text(pDX, IDC_EDIT_PLC_SIGNAL_RETRY_COUNT, m_pDlgHDSettingParm->m_nPLCSignalRetry); DDX_Text(pDX, IDC_EDIT_SAVEIMAGE_QUALITY, m_pDlgHDSettingParm->m_nSaveImageQuality); DDX_Text(pDX,IDC_EDIT_FOLDER_REMOVE_DAY,m_pDlgHDSettingParm->m_nFolderRemoveDay); DDX_Check(pDX,IDC_CHK_USECOLORVISUAL,m_pDlgHDSettingParm->m_bUseColorVisual); DDX_Check(pDX,IDC_CHECK_USE_FREERUN_INSPECT,m_pDlgHDSettingParm->m_bUseFreerun); DDX_Text(pDX,IDC_EDIT_FREERUN_PERIOD,m_pDlgHDSettingParm->m_nFreerunPeriod); DDX_Text(pDX,IDC_EDIT_PREERUN_EXPOSURETIME,m_pDlgHDSettingParm->m_nFreerunExposureTime); DDX_Check(pDX,IDC_CHECK_USE_MVSOL_TRIGGER_CONTROL,m_pDlgHDSettingParm->m_bUse_MvsolTriggerControl); DDX_Text(pDX,IDC_EDIT_MVSOL_TRIGGER_CONTROL_PORT,m_pDlgHDSettingParm->m_nPort_MvsolTriggerControl); DDX_Check(pDX,IDC_CHECK_USE_SAVE_DEBUG_IMAGE,m_pDlgHDSettingParm->m_bUse_SaveDebugImage); DDX_Check(pDX, IDC_CHECK_USE_SAVE_ALL_DMP, g_bUse_SaveAllDMP); DDX_Check(pDX, IDC_CHECK_USE_SAVE_DL_IMAGE, m_pDlgHDSettingParm->m_bUse_SaveDLDefectImage); DDX_Check(pDX, IDC_CHECK_SAVE_RESULT_BY_HOUR, m_pDlgHDSettingParm->m_bSaveResultByHour); // ly,2025.07.10 DDX_Check(pDX, IDC_CHECK_ENABLE_AUTO_COPY, m_pDlgHDSettingParm->m_bEnableAutoCopy); // ly,2025.07.07 DDX_Text(pDX, IDC_EDIT_COPY_TOOL_EXE_PATH, m_pDlgHDSettingParm->m_strCopyToolExePath); DDX_Text(pDX, IDC_EDIT_COPY_TOOL_CONFIG_PATH, m_pDlgHDSettingParm->m_strCopyToolConfigPath); DDX_Check(pDX, IDC_CHECK_ENABLE_AUTO_DELETE, m_pDlgHDSettingParm->m_bEnableAutoDelete); DDX_Text(pDX, IDC_EDIT_DELETE_TOOL_EXE_PATH, m_pDlgHDSettingParm->m_strDeleteToolExePath); DDX_Text(pDX, IDC_EDIT_DELETE_TOOL_CONFIG_PATH, m_pDlgHDSettingParm->m_strDeleteToolConfigPath); CDialogEx::DoDataExchange(pDX); } BOOL CViewMain_HWSetting::PreTranslateMessage(MSG* pMsg) { if( pMsg->message == WM_KEYDOWN ) { if(pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE ) { ::TranslateMessage(pMsg); ::DispatchMessage(pMsg); return TRUE; // DO NOT process further } } return CDialog::PreTranslateMessage(pMsg); } BEGIN_EVENTSINK_MAP(CViewMain_HWSetting, CDialogEx) ON_EVENT(CViewMain_HWSetting, IDC_BTN_HW_SAVE, DISPID_CLICK, CViewMain_HWSetting::ClickHWSaveButton, VTS_NONE) ON_EVENT(CViewMain_HWSetting, IDC_BUT_LIGHTCNT_APPLY, DISPID_CLICK, CViewMain_HWSetting::OnClickLightApply, VTS_NONE) ON_EVENT(CViewMain_HWSetting, IDC_BUT_CAMCNT_APPLY, DISPID_CLICK, CViewMain_HWSetting::OnBnClickedButCamcntApply, VTS_NONE) ON_EVENT(CViewMain_HWSetting, IDC_BUT_LICENSE_INFO, DISPID_CLICK, CViewMain_HWSetting::ClickButLicenseInfo, VTS_NONE) ON_EVENT(CViewMain_HWSetting, IDC_BUT_BROWSE_COPY_TOOL_EXE, DISPID_CLICK, CViewMain_HWSetting::OnClickBrowseCopyToolExe, VTS_NONE) ON_EVENT(CViewMain_HWSetting, IDC_BUT_BROWSE_COPY_TOOL_CONFIG, DISPID_CLICK, CViewMain_HWSetting::OnClickBrowseCopyToolConfig, VTS_NONE) ON_EVENT(CViewMain_HWSetting, IDC_BUT_BROWSE_DELETE_TOOL_EXE, DISPID_CLICK, CViewMain_HWSetting::OnClickBrowseDeleteToolExe, VTS_NONE) ON_EVENT(CViewMain_HWSetting, IDC_BUT_BROWSE_DELETE_TOOL_CONFIG, DISPID_CLICK, CViewMain_HWSetting::OnClickBrowseDeleteToolConfig, VTS_NONE) END_EVENTSINK_MAP() BEGIN_MESSAGE_MAP(CViewMain_HWSetting, CDialogEx) ON_BN_CLICKED(IDC_BUTTON_CAL_FREERUN, &CViewMain_HWSetting::OnBnClickedButtonCalFreerun) ON_WM_DESTROY() END_MESSAGE_MAP() BOOL CViewMain_HWSetting::OnInitDialog() { ((CComboBox*)(GetDlgItem(IDC_COMBO_BORAD_TYPE)))->AddString(L"GrabLink"); ((CComboBox*)(GetDlgItem(IDC_COMBO_BORAD_TYPE)))->AddString(L"Radient"); ((CComboBox*)(GetDlgItem(IDC_COMBO_BORAD_TYPE)))->AddString(L"Solios"); ((CComboBox*)(GetDlgItem(IDC_COMBO_BORAD_TYPE)))->AddString(L"Sapera"); UpdateControlValue(TRUE); Init_LightGrid(); Init_CameraGrid(); m_pDlgLicenseInfo = new CDlgLicenseInfo; m_pDlgLicenseInfo->Create(CDlgLicenseInfo::IDD,this); m_pDlgLicenseInfo->ShowWindow(SW_HIDE); return TRUE; } // CViewHWSetting 皋矫瘤 贸府扁涝聪促. void CViewMain_HWSetting::Init_LightGrid() { if(m_LightGrid.GetSafeHwnd() == NULL) return; m_LightGrid.GetDefaultCell(TRUE, FALSE)->SetBackClr(GRID_FIX_COLOR); m_LightGrid.GetDefaultCell(FALSE, TRUE)->SetBackClr(GRID_FIX_COLOR); m_LightGrid.GetDefaultCell(FALSE, FALSE)->SetBackClr(GRID_COLOR); m_LightGrid.SetFixedBkColor(GRID_FIX_COLOR); m_LightGrid.SetGridLines(GVL_BOTH); m_LightGrid.SetColumnCount(LIGHT_COLUMN_COUNT); m_LightGrid.SetRowCount(10); m_LightGrid.SetFixedRowCount(1); m_LightGrid.SetFixedColumnCount(0); m_LightGrid.ExpandColumnsToFit(); CFont *pFont = m_LightGrid.GetFont(); if (!pFont) return; LOGFONT lf; pFont->GetLogFont(&lf); lf.lfItalic = 0; lf.lfHeight = 14; lf.lfWeight = FW_BOLD; _tcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Arial")); m_LightGrid.GetDefaultCell(TRUE, FALSE)->SetFont(&lf); m_LightGrid.GetDefaultCell(FALSE, TRUE)->SetFont(&lf); m_LightGrid.GetDefaultCell(TRUE, TRUE)->SetFont(&lf); m_LightGrid.SetEditable(TRUE); m_LightGrid.EnableSelection(TRUE); Init_LightGridHeader(); } void CViewMain_HWSetting::Init_LightGridHeader() { CString str; GV_ITEM Item; int nCol = 0; int iLoop; Item.mask = GVIF_TEXT; Item.row = 0; for(iLoop=0;iLoopSetBackClr(GRID_FIX_COLOR); m_CameraGrid.GetDefaultCell(FALSE, TRUE)->SetBackClr(GRID_FIX_COLOR); m_CameraGrid.GetDefaultCell(FALSE, FALSE)->SetBackClr(GRID_COLOR); m_CameraGrid.SetFixedBkColor(GRID_FIX_COLOR); m_CameraGrid.SetGridLines(GVL_BOTH); m_CameraGrid.SetColumnCount(CAMERA_COLUMN_COUNT); m_CameraGrid.SetRowCount(10); m_CameraGrid.SetFixedRowCount(1); m_CameraGrid.SetFixedColumnCount(0); m_CameraGrid.ExpandColumnsToFit(); CFont *pFont = m_CameraGrid.GetFont(); if (!pFont) return; LOGFONT lf; pFont->GetLogFont(&lf); lf.lfItalic = 0; lf.lfHeight = 14; lf.lfWeight = FW_BOLD; _tcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Arial")); m_CameraGrid.GetDefaultCell(TRUE, FALSE)->SetFont(&lf); m_CameraGrid.GetDefaultCell(FALSE, TRUE)->SetFont(&lf); m_CameraGrid.GetDefaultCell(TRUE, TRUE)->SetFont(&lf); m_CameraGrid.SetEditable(TRUE); m_CameraGrid.EnableSelection(TRUE); Init_CameraGridHeader(); } void CViewMain_HWSetting::Init_CameraGridHeader() { CString str; GV_ITEM Item; int nCol = 0; int iLoop; Item.mask = GVIF_TEXT; Item.row = 0; for(iLoop=0;iLoopGetLightSettings(); if(pLight == NULL) return; CString str; int nCol = 0, nRow; int iLoop; const TCHAR* SET_LIGHT_TYPE[] = {_T("Transfer"),_T("Reflect")}; const TCHAR* SET_LIGHT_MAKER[] = {_T("LCP"),_T("AKP"),_T("No")}; CGridCellCombo *pCell; CStringArray optType,optMaker; for(iLoop=0;iLoop<2;iLoop++) optType.Add(SET_LIGHT_TYPE[iLoop]); for(iLoop=0;iLoop<3;iLoop++) optMaker.Add(SET_LIGHT_MAKER[iLoop]); if(bWrite == TRUE) { m_LightGrid.SetRowCount(m_pDlgHDSettingParm->m_nLightCount_Trans+m_pDlgHDSettingParm->m_nLightCount_Reflect+1); for(iLoop=0;iLoopm_nLightCount_Trans+m_pDlgHDSettingParm->m_nLightCount_Reflect;iLoop++) { nCol = 0; nRow = iLoop+1; str.Format(_T("%d"),pLight[iLoop].m_nIndex); m_LightGrid.SetItemText(nRow,nCol,str); nCol++; if (!m_LightGrid.SetCellType(nRow,nCol, RUNTIME_CLASS(CGridCellCombo))) continue; switch(pLight[iLoop].m_emType) { case LIGHT_TYPE_TRANS: str.Format(_T("%s"),SET_LIGHT_TYPE[0]); break; case LIGHT_TYPE_REF: str.Format(_T("%s"),SET_LIGHT_TYPE[1]); break; default: str.Format(_T("%s"),_T("No")); break; } m_LightGrid.SetItemText(nRow,nCol,str); pCell = (CGridCellCombo*) m_LightGrid.GetCell(nRow,nCol); pCell->SetOptions(optType); pCell->SetStyle(CBS_DROPDOWN); nCol++; str.Format(_T("%d"),pLight[iLoop].m_nPort); m_LightGrid.SetItemText(nRow,nCol,str); nCol++; if (!m_LightGrid.SetCellType(nRow,nCol, RUNTIME_CLASS(CGridCellCombo))) continue; switch(pLight[iLoop].m_emMaker) { case MAKER_LCP: str.Format(_T("%s"),SET_LIGHT_MAKER[0]); break; case MAKER_AKP: str.Format(_T("%s"),SET_LIGHT_MAKER[1]); break; default: str.Format(_T("%s"),_T("No")); break; } m_LightGrid.SetItemText(nRow,nCol,str); pCell = (CGridCellCombo*) m_LightGrid.GetCell(nRow,nCol); pCell->SetOptions(optMaker); pCell->SetStyle(CBS_DROPDOWN); nCol++; } m_LightGrid.Invalidate(); } else { for(iLoop=0;iLoopm_nLightCount_Trans+m_pDlgHDSettingParm->m_nLightCount_Reflect;iLoop++) { nCol = 0; nRow = iLoop+1; str = m_LightGrid.GetItemText(nRow,nCol); pLight[iLoop].m_nIndex = _ttoi(str); nCol++; str = m_LightGrid.GetItemText(nRow,nCol); int i; for(i=0;im_nCameraCount*m_pDlgHDSettingParm->m_nScanCount+1); iRow = 1; for(iCam=0;iCamm_nCameraCount;iCam++) { for(iScan=0;iScanm_nScanCount;iScan++) { iCol = 0; pCamera = m_pDlgHDSettingParm->GetCameraSettings(iCam,iScan); if(pCamera == NULL) continue; str.Format(_T("%d"),pCamera->m_iCamera); m_CameraGrid.SetItemText(iRow,iCol,str); iCol++; str.Format(_T("%d"),pCamera->m_iScan); m_CameraGrid.SetItemText(iRow,iCol,str); iCol++; if (!m_CameraGrid.SetCellType(iRow,iCol, RUNTIME_CLASS(CGridCellCombo))) continue; switch(pCamera->m_enCamDir) { case CAMDIR_TOP: str.Format(_T("%s"),SET_CAMERA_DIR[0]); break; case CAMDIR_BOTTOM: str.Format(_T("%s"),SET_CAMERA_DIR[1]); break; default: str.Format(_T("%s"),_T("No")); break; } m_CameraGrid.SetItemText(iRow,iCol,str); pCell = (CGridCellCombo*) m_CameraGrid.GetCell(iRow,iCol); pCell->SetOptions(arrDir); pCell->SetStyle(CBS_DROPDOWN); iCol++; if (!m_CameraGrid.SetCellType(iRow,iCol, RUNTIME_CLASS(CGridCellCombo))) continue; switch(pCamera->m_eScanDir) { case SCANGLASS_X: str.Format(_T("%s"),SET_INS_DIR[0]); break; case SCANGLASS_Y: str.Format(_T("%s"),SET_INS_DIR[1]); break; default: str.Format(_T("%s"),_T("No")); break; } m_CameraGrid.SetItemText(iRow,iCol,str); pCell = (CGridCellCombo*) m_CameraGrid.GetCell(iRow,iCol); pCell->SetOptions(arrInsDir); pCell->SetStyle(CBS_DROPDOWN); iCol++; if (!m_CameraGrid.SetCellType(iRow,iCol, RUNTIME_CLASS(CGridCellCombo))) continue; switch(pCamera->m_eDimension) { case DIMENSION_A: str.Format(_T("%s"),SET_INS_DIMENSION[0]); break; case DIMENSION_B: str.Format(_T("%s"),SET_INS_DIMENSION[1]); break; case DIMENSION_C: str.Format(_T("%s"),SET_INS_DIMENSION[2]); break; case DIMENSION_D: str.Format(_T("%s"),SET_INS_DIMENSION[3]); break; case DIMENSION_A_DN: str.Format(_T("%s"),SET_INS_DIMENSION[4]); break; case DIMENSION_B_DN: str.Format(_T("%s"),SET_INS_DIMENSION[5]); break; case DIMENSION_C_DN: str.Format(_T("%s"),SET_INS_DIMENSION[6]); break; case DIMENSION_D_DN: str.Format(_T("%s"),SET_INS_DIMENSION[7]); break; default: str.Format(_T("%s"),_T("No")); break; } m_CameraGrid.SetItemText(iRow,iCol,str); pCell = (CGridCellCombo*) m_CameraGrid.GetCell(iRow,iCol); pCell->SetOptions(arrDimension); pCell->SetStyle(CBS_DROPDOWN); iCol++; str.Format(_T("%d"),pCamera->m_nMarginLeft); m_CameraGrid.SetItemText(iRow,iCol,str); iCol++; str.Format(_T("%d"),pCamera->m_nMarginRight); m_CameraGrid.SetItemText(iRow,iCol,str); iCol++; str.Format(_T("%.10f"),pCamera->m_dConvResolution[0]); m_CameraGrid.SetItemText(iRow,iCol,str); iCol++; str.Format(_T("%.10f"),pCamera->m_dScanResolution[0]); m_CameraGrid.SetItemText(iRow,iCol,str); iCol++; str.Format(_T("%.10f"),pCamera->m_dConvResolution[1]); m_CameraGrid.SetItemText(iRow,iCol,str); iCol++; str.Format(_T("%.10f"),pCamera->m_dScanResolution[1]); m_CameraGrid.SetItemText(iRow,iCol,str); iCol++; str.Format(_T("%d"),pCamera->m_FrameSize.cx); m_CameraGrid.SetItemText(iRow,iCol,str); iCol++; str.Format(_T("%d"),pCamera->m_FrameSize.cy); m_CameraGrid.SetItemText(iRow,iCol,str); iCol++; str.Format(_T("%d"),pCamera->m_nGrabFrameCount); m_CameraGrid.SetItemText(iRow,iCol,str); iCol++; str.Format(_T("%d"),pCamera->m_nLightIdx_R); m_CameraGrid.SetItemText(iRow,iCol,str); iCol++; str.Format(_T("%d"),pCamera->m_nLightIdx_R_Ch); m_CameraGrid.SetItemText(iRow,iCol,str); iCol++; str.Format(_T("%d"),pCamera->m_nLightIdx_T); m_CameraGrid.SetItemText(iRow,iCol,str); iCol++; str.Format(_T("%d"),pCamera->m_nLightIdx_T_Ch); m_CameraGrid.SetItemText(iRow,iCol,str); iCol++; str.Format(_T("%d"),pCamera->m_nImgFlipx); m_CameraGrid.SetItemText(iRow,iCol,str); iCol++; iRow++; } m_CameraGrid.Invalidate(); } } else { iRow = 1; for(iCam=0;iCamm_nCameraCount;iCam++) { for(iScan=0;iScanm_nScanCount;iScan++) { iCol = 0; pCamera = m_pDlgHDSettingParm->GetCameraSettings(iCam,iScan); if(pCamera == NULL) continue; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_iCamera = _ttoi(str); iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_iScan = _ttoi(str); iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_enCamDir = CAMDIR_NONE; for(i=0;im_enCamDir = (CAMERA_DIR)i; break; } } iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_eScanDir = SCANGLASS_NONE; for(i=0;im_eScanDir = (CAMERA_SCANDIR)i; break; } } iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_eDimension = DIMENSION_NONE; for(i=0;im_eDimension = (DimensionDir)i; break; } } iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_nMarginLeft = _ttoi(str); iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_nMarginRight = _ttoi(str); iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_dConvResolution[0] = _ttof(str); iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_dScanResolution[0] = _ttof(str); iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_dConvResolution[1] = _ttof(str); iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_dScanResolution[1] = _ttof(str); iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_FrameSize.cx = _ttoi(str); iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_FrameSize.cy = _ttoi(str); iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_nGrabFrameCount = _ttoi(str); iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_nLightIdx_R = _ttoi(str); iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_nLightIdx_R_Ch = _ttoi(str); iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_nLightIdx_T = _ttoi(str); iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_nLightIdx_T_Ch = _ttoi(str); iCol++; str = m_CameraGrid.GetItemText(iRow,iCol); pCamera->m_nImgFlipx = _ttoi(str); iCol++; iRow++; } } } } void CViewMain_HWSetting::SetSettingParm(CHardwareSettings *pParm) { m_pDlgHDSettingParm->Reset(); m_pHDSetting = NULL; if(pParm != NULL) { m_pHDSetting = pParm; *m_pDlgHDSettingParm = *pParm; } UpdateControlValue(TRUE); } void CViewMain_HWSetting::UpdateControlValue(BOOL bWrite) { if(bWrite == TRUE) { UpdateData(FALSE); FillLightGrid(TRUE); FillCameraGrid(TRUE); ((CComboBox*)(GetDlgItem(IDC_COMBO_BORAD_TYPE)))->SetCurSel((int)m_pDlgHDSettingParm->m_nBoardType); } else { UpdateData(TRUE); FillLightGrid(FALSE); FillCameraGrid(FALSE); if(m_pHDSetting != NULL) { m_pDlgHDSettingParm->m_nBoardType = (BOARD_TYPE)((CComboBox*)(GetDlgItem(IDC_COMBO_BORAD_TYPE)))->GetCurSel(); *m_pHDSetting = *m_pDlgHDSettingParm; } } } void CViewMain_HWSetting::View_LicenseInfo() { if(m_pDlgLicenseInfo == NULL) return; m_pDlgLicenseInfo->UpdateLicenseInfo(); m_pDlgLicenseInfo->ShowWindow(SW_SHOW); } void CViewMain_HWSetting::OnClickLightApply() { UpdateData(TRUE); m_pDlgHDSettingParm->SetLightCount(m_pDlgHDSettingParm->m_nLightCount_Trans,m_pDlgHDSettingParm->m_nLightCount_Reflect); FillLightGrid(TRUE); } void CViewMain_HWSetting::OnBnClickedButCamcntApply() { UpdateData(TRUE); m_pDlgHDSettingParm->SetCameraCount(m_pDlgHDSettingParm->m_nCameraCount,m_pDlgHDSettingParm->m_nScanCount); FillCameraGrid(TRUE); } void CViewMain_HWSetting::SaveHardwareFileBackup() { CreateDirectory(_T("C:\\EdgeInspector_App"),NULL); CreateDirectory(_T("C:\\EdgeInspector_App\\Config"),NULL); CreateDirectory(_T("C:\\EdgeInspector_App\\Config\\Backup"),NULL); CTime currentTime = CTime::GetCurrentTime(); CString str; str.Format(_T("%s\\HardwareSetting_%02d%02d%02d_%02d%02d%02d.cfg"), HARDWARE_SETTING_BACKUP_DIR_PATH , currentTime.GetYear() , currentTime.GetMonth() , currentTime.GetDay() , currentTime.GetHour() , currentTime.GetMinute() , currentTime.GetSecond()); UpdateControlValue(FALSE); if(m_pHDSetting->WriteHardwareSettingsFile(str) == FALSE) { AfxMessageBox(_T("Save Fail!")); } } void CViewMain_HWSetting::ClickHWSaveButton() { if(m_pHDSetting == NULL) return; if (IDYES == AfxMessageBox(_T("Do you want to save? \n Restarting is required to change settings."), MB_YESNO | MB_ICONQUESTION)) { UpdateControlValue(FALSE); if(m_pHDSetting->WriteHardwareSettingsFile(HARDWARE_SETTING_PATH) == FALSE)// if(m_pHDSetting->WriteHardwareSettingsRegistry() == FALSE) { AfxMessageBox(_T("Save Fail!")); return; } SaveHardwareFileBackup(); } } void CViewMain_HWSetting::OnBnClickedButtonCalFreerun() { CString strFreerunMotorSpeed = _T(""); CString strFreerunTargetResolution = _T(""); GetDlgItemText(IDC_EDIT_FREERUN_MOTOR_SPEED, strFreerunMotorSpeed); GetDlgItemText(IDC_EDIT_FREERUN_TARGET_RESOLUTION, strFreerunTargetResolution); double dFreerunMotorSpeed = _wtof(strFreerunMotorSpeed); double dFreerunTargetResolution = _wtof(strFreerunTargetResolution); dFreerunMotorSpeed = (dFreerunMotorSpeed * 1000.0) / 60.0; double dLineRate = dFreerunMotorSpeed/dFreerunTargetResolution; double dPulseSize = 1000000.0/dLineRate; CString strPulseSize; CString strExposureTime; strPulseSize.Format(_T("%d"), (int) dPulseSize); strExposureTime.Format(_T("%d"), (int) (dPulseSize/2.0)); SetDlgItemText(IDC_EDIT_FREERUN_PERIOD, strPulseSize); SetDlgItemText(IDC_EDIT_PREERUN_EXPOSURETIME, strExposureTime); } void CViewMain_HWSetting::OnDestroy() { CDialogEx::OnDestroy(); if(m_pDlgLicenseInfo != NULL) { m_pDlgLicenseInfo->DestroyWindow(); delete m_pDlgLicenseInfo; m_pDlgLicenseInfo = NULL; } } void CViewMain_HWSetting::ClickButLicenseInfo() { View_LicenseInfo(); } void CViewMain_HWSetting::OnClickBrowseCopyToolExe() { CString strFilePath; CFileDialog dlg(TRUE, _T("exe"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("Executable Files (*.exe)|*.exe||")); if (dlg.DoModal() == IDOK) { strFilePath = dlg.GetPathName(); m_pDlgHDSettingParm->m_strCopyToolExePath = strFilePath; UpdateData(FALSE); } } void CViewMain_HWSetting::OnClickBrowseCopyToolConfig() { CString strFilePath; CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("Config Files (*.ffs_real;*.json;*.xml;*.ini;*.cfg)|*.ffs_real;*.json;*.xml;*.ini;*.cfg||"), this); if (dlg.DoModal() == IDOK) { strFilePath = dlg.GetPathName(); m_pDlgHDSettingParm->m_strCopyToolConfigPath = strFilePath; UpdateData(FALSE); } } void CViewMain_HWSetting::OnClickBrowseDeleteToolExe() { CString strFilePath; CFileDialog dlg(TRUE, _T("exe"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("Executable Files (*.exe)|*.exe||")); if (dlg.DoModal() == IDOK) { strFilePath = dlg.GetPathName(); m_pDlgHDSettingParm->m_strDeleteToolExePath = strFilePath; UpdateData(FALSE); } } void CViewMain_HWSetting::OnClickBrowseDeleteToolConfig() { CString strFilePath; CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("Config Files (*.ffs_real;*.json;*.xml;*.ini;*.cfg)|*.ffs_real;*.json;*.xml;*.ini;*.cfg||"), this); if (dlg.DoModal() == IDOK) { strFilePath = dlg.GetPathName(); m_pDlgHDSettingParm->m_strDeleteToolConfigPath = strFilePath; UpdateData(FALSE); } }