// DlgSelfDiagnosis_Setting.cpp: 구현 파일 // #include "stdafx.h" #include "ReviewSystem.h" #include "DlgSelfDiagnosis_Setting.h" #include "afxdialogex.h" #include "CHCommonClasses/MacroFile.h" // CDlgSelfDiagnosis_Setting 대화 상자 IMPLEMENT_DYNAMIC(CDlgSelfDiagnosis_Setting, CDialogEx) CDlgSelfDiagnosis_Setting::CDlgSelfDiagnosis_Setting(CDiagnosisManager* pDiagnosisManager, CWnd* pParent /*=nullptr*/) : CDialogEx(IDD_DLG_SELF_DIAGNOSIS_SETTING, pParent) , m_dEditReviewPanelPosX(0) , m_dEditReviewPanelPosY(0) , m_dEditReviewPanelPosX2(0) , m_dEditReviewPanelPosY2(0) , m_dEditReviewPanelPosX3(0) , m_dEditReviewPanelPosY3(0) , m_dEditReviewPanelPosX4(0) , m_dEditReviewPanelPosY4(0) , m_dEditReviewPanelPosX5(0) , m_dEditReviewPanelPosY5(0) , m_dEditReviewPanelPosX6(0) , m_dEditReviewPanelPosY6(0) { m_pDiagnosisManager = pDiagnosisManager; } CDlgSelfDiagnosis_Setting::~CDlgSelfDiagnosis_Setting() { } void CDlgSelfDiagnosis_Setting::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_EDIT_FILE_PATH, m_editFilePath); DDX_Control(pDX, IDC_EDIT_PANEL_COUNT_SQUARENESS, m_editPanelCount_Squareness); DDX_Control(pDX, IDC_EDIT_JUDGE_DATA_DEGREE, m_editJudgeData_Degree); DDX_Control(pDX, IDC_EDIT_AF_DELAY, m_editAFDelay); DDX_Control(pDX, IDC_EDIT_JUDGE_DATA_Z_RANGE, m_editJudgeDataZRange); DDX_Control(pDX, IDC_COMBO_FLANTESS_MODE, m_ComboFlatnessMode); DDX_Control(pDX, IDC_EDIT_RANGE_COUNT_FLATNESS, m_editRangeCount_Flatness); DDX_Control(pDX, IDC_EDIT_GLASS_SIZE_X, m_editGlassSizeX); DDX_Control(pDX, IDC_EDIT_GLASS_SIZE_Y, m_editGlassSizeY); DDX_Control(pDX, IDC_EDIT_PANEL_COUNT_WSI, m_editPanelCount_Wsi); DDX_Control(pDX, IDC_EDIT_JUDGE_DATA_3SIGMA, m_editJudgeData_3Sigma); DDX_Control(pDX, IDC_STATIC_FILE, m_staticFile); DDX_Control(pDX, IDC_EDIT_CAMERA_RESOLUTION, m_editCameraResolution); DDX_Control(pDX, IDC_EDIT_CAMERA_FRAME_WIDTH, m_editFrameWidth); DDX_Control(pDX, IDC_EDIT_CAMERA_FRAME_HEIGHT, m_editFrameHeight); DDX_Control(pDX, IDC_EDIT_MODULE_COUNT, m_editModuleCount); DDX_Control(pDX, IDC_EDIT_WSI_PANEL_POS_X, m_editPanelPosX); DDX_Control(pDX, IDC_EDIT_WSI_PANEL_POS_Y, m_editPanelPosY); DDX_Control(pDX, IDC_EDIT_WSI_PANEL_POS_X2, m_editPanelPosX2); DDX_Control(pDX, IDC_EDIT_WSI_PANEL_POS_Y2, m_editPanelPosY2); /*< LYW 20210719 : #3517 ADD Start >*/ DDX_Control(pDX, IDC_CHECK_SELF_DIAGNOSIS_FLATNESS_SKIP, m_CheckFlatnessSkip); DDX_Control(pDX, IDC_EDIT_SQUARENESS_STANDARD, m_editSquarenessStandard); DDX_Control(pDX, IDC_EDIT_SQUARENESS_STANDARD2, m_editSquarenessStandard2); DDX_Control(pDX, IDC_EDIT_WSI_STANDARD, m_editWSIStandard); /*< LYW 20210719 : #3517 ADD End >*/ DDX_Text(pDX, IDC_EDIT_REVIEW_PANEL_POS_X, m_dEditReviewPanelPosX); DDX_Text(pDX, IDC_EDIT_REVIEW_PANEL_POS_Y, m_dEditReviewPanelPosY); DDX_Text(pDX, IDC_EDIT_REVIEW_PANEL_POS_X2, m_dEditReviewPanelPosX2); DDX_Text(pDX, IDC_EDIT_REVIEW_PANEL_POS_Y2, m_dEditReviewPanelPosY2); DDX_Text(pDX, IDC_EDIT_REVIEW_PANEL_POS_X3, m_dEditReviewPanelPosX3); DDX_Text(pDX, IDC_EDIT_REVIEW_PANEL_POS_Y3, m_dEditReviewPanelPosY3); DDX_Text(pDX, IDC_EDIT_REVIEW_PANEL_POS_X4, m_dEditReviewPanelPosX4); DDX_Text(pDX, IDC_EDIT_REVIEW_PANEL_POS_Y4, m_dEditReviewPanelPosY4); DDX_Text(pDX, IDC_EDIT_REVIEW_PANEL_POS_X5, m_dEditReviewPanelPosX5); DDX_Text(pDX, IDC_EDIT_REVIEW_PANEL_POS_Y5, m_dEditReviewPanelPosY5); DDX_Text(pDX, IDC_EDIT_REVIEW_PANEL_POS_X6, m_dEditReviewPanelPosX6); DDX_Text(pDX, IDC_EDIT_REVIEW_PANEL_POS_Y6, m_dEditReviewPanelPosY6); } CString CDlgSelfDiagnosis_Setting::GetFileSaveLastTime() { CString strFilePath = REVIEW_AUTO_DIAGNOSIS_SETTING_FILE_PATH; CString strFileName = _T("AutoDiagnosisSetting.cfg"); strFilePath = strFilePath + _T('\\') + strFileName; HANDLE h_File = CreateFile(strFilePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); CString strDate, strYear, strMonth, strDay, strHour, strMinute; if (h_File != INVALID_HANDLE_VALUE) { //** create_time : 생성 날짜, access_time : 마지막 접근날짜, write_time : 마지막 수정 날짜 FILETIME create_time, access_time, write_time; //** System Time 취득 GetFileTime(h_File, &create_time, &access_time, &write_time); //** SystemTime은 UTC형식(Universal Time Coordinated)이기 때문에 그냥 사용 불가능 //** 지역시간으로 변경(일반적인 시간 계산법 2015/11/09 21:18:35) SYSTEMTIME write_system_time, write_local_time; FileTimeToSystemTime(&write_time, &write_system_time); //** write_local_time변수에 변환되어 저장됨 //** 저장된 형태는 WORD형(short) //** wYear, wMonth, wDay, wHour, wMinute, wSecond를 활용하여 사용하면 됨 SystemTimeToTzSpecificLocalTime(NULL, &write_system_time, &write_local_time); strYear.Format("%d", write_local_time.wYear); strMonth.Format("%02d", write_local_time.wMonth); strDay.Format("%02d", write_local_time.wDay); //strHour.Format("%02d", write_local_time.wHour); //strMinute.Format("%02d", write_local_time.wMinute); strDate = _T("마지막으로 파일을 수정한 날짜 : ")+ strYear +_T("-") + strMonth+ _T("-") + strDay; CloseHandle(h_File); } return strDate; } BOOL CDlgSelfDiagnosis_Setting::ReadAutoDiagnosisConfigFile() { /*< LYW 20210719 : #3517 ADD Start >*/ CString strConfigFilePath = _T(""); strConfigFilePath.Format(_T("%s\\%s"), REVIEW_AUTO_DIAGNOSIS_SETTING_FILE_PATH, REVIEW_AUTO_DIAGNOSIS_SETTING_FILE_NAME); m_pDiagnosisManager->LoadSettingConfigFile(strConfigFilePath); /*< LYW 20210719 : #3517 ADD End >*/ CDiagnosisInfo* pSettingInfo = m_pDiagnosisManager->GetDiagnosisInfo(); if (pSettingInfo == NULL) return FALSE; CString strTemp = _T(""); m_editFilePath.SetWindowTextA(strConfigFilePath); strTemp.Format("%d", pSettingInfo->GetModuleCount()); m_editModuleCount.SetWindowTextA(strTemp); strTemp.Format("%f", pSettingInfo->GetCameraResolution()); m_editCameraResolution.SetWindowTextA(strTemp); strTemp.Format("%d", pSettingInfo->GetPanelCount_Squareness()); m_editPanelCount_Squareness.SetWindowTextA(strTemp); strTemp.Format("%f", pSettingInfo->GetJudgeData_Degree()); m_editJudgeData_Degree.SetWindowTextA(strTemp); /*< LYW 20210719 : #3517 ADD Start >*/ strTemp.Format("%f", pSettingInfo->GetSquarenessStandard()); m_editSquarenessStandard.SetWindowTextA(strTemp); strTemp.Format("%f", pSettingInfo->GetSquarenessStandard2()); m_editSquarenessStandard2.SetWindowTextA(strTemp); /*< LYW 20210719 : #3517 ADD End >*/ strTemp.Format("%d", pSettingInfo->GetCameraFrameWidth()); m_editFrameWidth.SetWindowTextA(strTemp); strTemp.Format("%d", pSettingInfo->GetCameraFrameHeight()); m_editFrameHeight.SetWindowTextA(strTemp); strTemp.Format("%d", pSettingInfo->GetAFDelay()); m_editAFDelay.SetWindowTextA(strTemp); strTemp.Format("%f", pSettingInfo->GetJudgeData_ZRange()); m_editJudgeDataZRange.SetWindowTextA(strTemp); int nFlatnessMode = pSettingInfo->GetFlatnessMode(); int nRangeCount_Flatness = pSettingInfo->GetRangeCount_Flatness(); m_ComboFlatnessMode.AddString("Mode_2x2"); m_ComboFlatnessMode.AddString("Mode_3x3"); m_ComboFlatnessMode.AddString("Mode_3x4"); m_ComboFlatnessMode.AddString("Mode_4x5"); m_ComboFlatnessMode.AddString("Mode_10x10"); m_ComboFlatnessMode.SetCurSel(nFlatnessMode); strTemp.Format("%d",nRangeCount_Flatness); m_editRangeCount_Flatness.SetWindowTextA(strTemp); strTemp.Format("%d", pSettingInfo->GetGlassSizeX_Flatness()); m_editGlassSizeX.SetWindowTextA(strTemp); strTemp.Format("%d", pSettingInfo->GetGlassSizeY_Flatness()); m_editGlassSizeY.SetWindowTextA(strTemp); /*< LYW 20210719 : #3517 ADD Start >*/ m_CheckFlatnessSkip.SetCheck(pSettingInfo->GetFlastnessSkipMode()); /*< LYW 20210719 : #3517 ADD End >*/ strTemp.Format("%d", pSettingInfo->GetPanelCount_Wsi()); m_editPanelCount_Wsi.SetWindowTextA(strTemp); strTemp.Format("%f", pSettingInfo->GetJudgeData_3Sigma()); m_editJudgeData_3Sigma.SetWindowTextA(strTemp); /*< LYW 20210719 : #3517 ADD Start >*/ strTemp.Format("%f", pSettingInfo->GetWSIStandard()); m_editWSIStandard.SetWindowTextA(strTemp); /*< LYW 20210719 : #3517 ADD End >*/ strTemp.Format("%f", pSettingInfo->GetPanelPosX_Wsi()); m_editPanelPosX.SetWindowTextA(strTemp); strTemp.Format("%f", pSettingInfo->GetPanelPosY_Wsi()); m_editPanelPosY.SetWindowTextA(strTemp); strTemp.Format("%f", pSettingInfo->GetPanelPosX2_Wsi()); m_editPanelPosX2.SetWindowTextA(strTemp); strTemp.Format("%f", pSettingInfo->GetPanelPosY2_Wsi()); m_editPanelPosY2.SetWindowTextA(strTemp); //review m_dEditReviewPanelPosX = pSettingInfo->GetReviewPanelPosX(); m_dEditReviewPanelPosY = pSettingInfo->GetReviewPanelPosY(); m_dEditReviewPanelPosX3 = pSettingInfo->GetReviewPanelPosX3(); m_dEditReviewPanelPosY3 = pSettingInfo->GetReviewPanelPosY3(); m_dEditReviewPanelPosX5 = pSettingInfo->GetReviewPanelPosX5(); m_dEditReviewPanelPosY5 = pSettingInfo->GetReviewPanelPosY5(); m_dEditReviewPanelPosX2 = pSettingInfo->GetReviewPanelPosX2(); m_dEditReviewPanelPosY2 = pSettingInfo->GetReviewPanelPosY2(); m_dEditReviewPanelPosX4 = pSettingInfo->GetReviewPanelPosX4(); m_dEditReviewPanelPosY4 = pSettingInfo->GetReviewPanelPosY4(); m_dEditReviewPanelPosX6 = pSettingInfo->GetReviewPanelPosX6(); m_dEditReviewPanelPosY6 = pSettingInfo->GetReviewPanelPosY6(); UpdateData(FALSE); return TRUE; } BOOL CDlgSelfDiagnosis_Setting::WriteAutoDiagnosisConfigFile() { UpdateData(TRUE); BOOL bReturn = FALSE; CString strTemp; int nTemp; double dTemp; CMacroFile macroFile; macroFile.Clear(); CString strItem = _T(""); strItem.Format(_T("MODULE_COUNT")); m_editModuleCount.GetWindowTextA(strTemp); nTemp = atoi(strTemp); macroFile.SetItem(strItem, nTemp); strItem.Format(_T("SQUARENESS_PANEL_COUNT")); m_editPanelCount_Squareness.GetWindowTextA(strTemp); nTemp = atoi(strTemp); macroFile.SetItem(strItem, nTemp); strItem.Format(_T("SQUARENESS_CAMERA_RESOLUTION")); m_editCameraResolution.GetWindowTextA(strTemp); dTemp = atof(strTemp); macroFile.SetItem(strItem, dTemp); strItem.Format(_T("SQUARENESS_JUDGE_DATA_DEGREE")); m_editJudgeData_Degree.GetWindowTextA(strTemp); dTemp = atof(strTemp); macroFile.SetItem(strItem, dTemp); strItem.Format(_T("SQUARENESS_CAMERA_FRAME_WIDTH")); m_editFrameWidth.GetWindowTextA(strTemp); nTemp = atoi(strTemp); macroFile.SetItem(strItem, nTemp); strItem.Format(_T("SQUARENESS_CAMERA_FRAME_HEIGHT")); m_editFrameHeight.GetWindowTextA(strTemp); nTemp = atoi(strTemp); macroFile.SetItem(strItem, nTemp); strItem.Format(_T("FLATNESS_AF_DELAY")); m_editAFDelay.GetWindowTextA(strTemp); nTemp = atoi(strTemp); macroFile.SetItem(strItem, nTemp); strItem.Format(_T("FLATNESS_JUDGE_DATA_Z_RANGE")); m_editJudgeDataZRange.GetWindowTextA(strTemp); dTemp = atof(strTemp); macroFile.SetItem(strItem, dTemp); strItem.Format(_T("FLATNESS_MODE")); nTemp = m_ComboFlatnessMode.GetCurSel(); macroFile.SetItem(strItem, nTemp); strItem.Format(_T("FLATNESS_RANGECOUNT")); m_editRangeCount_Flatness.GetWindowTextA(strTemp); nTemp = atoi(strTemp); macroFile.SetItem(strItem, nTemp); strItem.Format(_T("FLATNESS_GLASS_X")); m_editGlassSizeX.GetWindowTextA(strTemp); nTemp = atoi(strTemp); macroFile.SetItem(strItem, nTemp); strItem.Format(_T("FLATNESS_GLASS_Y")); m_editGlassSizeY.GetWindowTextA(strTemp); nTemp = atoi(strTemp); macroFile.SetItem(strItem, nTemp); /*< LYW 20210719 : #3517 ADD Start >*/ strItem.Format(_T("FLATNESS_SKIPMODE")); nTemp = m_CheckFlatnessSkip.GetCheck(); macroFile.SetItem(strItem, nTemp); strItem.Format(_T("SQUARENESS_STANDARD")); m_editSquarenessStandard.GetWindowTextA(strTemp); dTemp = atof(strTemp); macroFile.SetItem(strItem, dTemp); strItem.Format(_T("SQUARENESS_STANDARD2")); m_editSquarenessStandard2.GetWindowTextA(strTemp); dTemp = atof(strTemp); macroFile.SetItem(strItem, dTemp); strItem.Format(_T("WSI_STANDARD")); m_editWSIStandard.GetWindowTextA(strTemp); dTemp = atof(strTemp); macroFile.SetItem(strItem, dTemp); /*< LYW 20210719 : #3517 ADD End >*/ strItem.Format(_T("WSI_PANEL_COUNT")); m_editPanelCount_Wsi.GetWindowTextA(strTemp); nTemp = atoi(strTemp); macroFile.SetItem(strItem, nTemp); strItem.Format(_T("WSI_JUDGE_DATA_3SIGMA")); m_editJudgeData_3Sigma.GetWindowTextA(strTemp); dTemp = atof(strTemp); macroFile.SetItem(strItem, dTemp); strItem.Format(_T("WSI_PANEL_POSX")); m_editPanelPosX.GetWindowTextA(strTemp); dTemp = atof(strTemp); macroFile.SetItem(strItem, dTemp); strItem.Format(_T("WSI_PANEL_POSY")); m_editPanelPosY.GetWindowTextA(strTemp); dTemp = atof(strTemp); macroFile.SetItem(strItem, dTemp); strItem.Format(_T("WSI_PANEL_POSX2")); m_editPanelPosX2.GetWindowTextA(strTemp); dTemp = atof(strTemp); macroFile.SetItem(strItem, dTemp); strItem.Format(_T("WSI_PANEL_POSY2")); m_editPanelPosY2.GetWindowTextA(strTemp); dTemp = atof(strTemp); macroFile.SetItem(strItem, dTemp); //Review strItem.Format(_T("REVIEW_PANEL_POSX")); macroFile.SetItem(strItem, m_dEditReviewPanelPosX); strItem.Format(_T("REVIEW_PANEL_POSY")); macroFile.SetItem(strItem, m_dEditReviewPanelPosY); strItem.Format(_T("REVIEW_PANEL_POSX3")); macroFile.SetItem(strItem, m_dEditReviewPanelPosX3); strItem.Format(_T("REVIEW_PANEL_POSY3")); macroFile.SetItem(strItem, m_dEditReviewPanelPosY3); strItem.Format(_T("REVIEW_PANEL_POSX5")); macroFile.SetItem(strItem, m_dEditReviewPanelPosX5); strItem.Format(_T("REVIEW_PANEL_POSY5")); macroFile.SetItem(strItem, m_dEditReviewPanelPosY5); strItem.Format(_T("REVIEW_PANEL_POSX2")); macroFile.SetItem(strItem, m_dEditReviewPanelPosX2); strItem.Format(_T("REVIEW_PANEL_POSY2")); macroFile.SetItem(strItem, m_dEditReviewPanelPosY2); strItem.Format(_T("REVIEW_PANEL_POSX4")); macroFile.SetItem(strItem, m_dEditReviewPanelPosX4); strItem.Format(_T("REVIEW_PANEL_POSY4")); macroFile.SetItem(strItem, m_dEditReviewPanelPosY4); strItem.Format(_T("REVIEW_PANEL_POSX6")); macroFile.SetItem(strItem, m_dEditReviewPanelPosX6); strItem.Format(_T("REVIEW_PANEL_POSY6")); macroFile.SetItem(strItem, m_dEditReviewPanelPosY6); CString strFilePath; m_editFilePath.GetWindowTextA(strFilePath); bReturn = macroFile.Write(strFilePath); return bReturn; } BEGIN_MESSAGE_MAP(CDlgSelfDiagnosis_Setting, CDialogEx) ON_BN_CLICKED(IDC_BUTTON_SAVE, &CDlgSelfDiagnosis_Setting::OnBnClickedButtonSave) ON_CBN_SELCHANGE(IDC_COMBO_FLANTESS_MODE, &CDlgSelfDiagnosis_Setting::OnCbnSelchangeComboFlantessMode) ON_BN_CLICKED(IDC_BUTTON_LOAD, &CDlgSelfDiagnosis_Setting::OnBnClickedButtonLoad) END_MESSAGE_MAP() // CDlgSelfDiagnosis_Setting 메시지 처리기 void CDlgSelfDiagnosis_Setting::OnBnClickedButtonSave() { LPCTSTR pAppNameTemp = AfxGetApp()->m_pszAppName; AfxGetApp()->m_pszAppName = _T("자가진단"); if (WriteAutoDiagnosisConfigFile()) { AfxMessageBox(_T("저장 완료!")); m_staticFile.SetWindowTextA(GetFileSaveLastTime()); } else AfxMessageBox(_T("저장 실패!")); AfxGetApp()->m_pszAppName = pAppNameTemp; } BOOL CDlgSelfDiagnosis_Setting::OnInitDialog() { CDialogEx::OnInitDialog(); // TODO: 여기에 추가 초기화 작업을 추가합니다. m_staticFile.SetWindowTextA(GetFileSaveLastTime()); ReadAutoDiagnosisConfigFile(); return TRUE; // return TRUE unless you set the focus to a control // 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다. } void CDlgSelfDiagnosis_Setting::OnCbnSelchangeComboFlantessMode() { int nMode = m_ComboFlatnessMode.GetCurSel(); int nRangeCount = 0; CString strMode = _T(""); if (nMode == Mode_2x2) nRangeCount = 4; else if (nMode == Mode_3x3) nRangeCount = 9; else if (nMode == Mode_3x4) nRangeCount = 12; else if (nMode == Mode_4x5) nRangeCount = 20; else if (nMode == Mode_10x10) nRangeCount = 100; strMode.Format("%d", nRangeCount); m_editRangeCount_Flatness.SetWindowTextA(strMode); } void CDlgSelfDiagnosis_Setting::OnBnClickedButtonLoad() { // TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다. ReadAutoDiagnosisConfigFile(); }