// DlgSelfDiagnosis_Flatness.cpp: 구현 파일
|
//
|
|
#include "stdafx.h"
|
#include "ReviewSystem.h"
|
#include "DlgSelfDiagnosis_Flatness.h"
|
#include "afxdialogex.h"
|
|
// CDlgSelfDiagnosis_Flatness 대화 상자
|
|
IMPLEMENT_DYNAMIC(CDlgSelfDiagnosis_Flatness, CDialogEx)
|
|
CDlgSelfDiagnosis_Flatness::CDlgSelfDiagnosis_Flatness(CDiagnosisManager* pDiagnosisManager, CWnd* pParent /*=nullptr*/)
|
: CDialogEx(IDD_DLG_SELF_DIAGNOSIS_FLATNESS, pParent)
|
{
|
m_bState = FALSE;
|
m_prBtn = NULL;
|
m_bUseRadioBtn = FALSE;
|
m_pDiagnosisManager = pDiagnosisManager;
|
}
|
|
CDlgSelfDiagnosis_Flatness::~CDlgSelfDiagnosis_Flatness()
|
{
|
KillProcess("wgnuplot.exe");
|
}
|
|
BOOL CDlgSelfDiagnosis_Flatness::ChangeRadioButton(int nIndex)
|
{
|
|
const CDiagnosisInfo* pSettingInfo = m_pDiagnosisManager->GetDiagnosisInfo();
|
if (pSettingInfo == NULL) return FALSE;
|
|
int nRangeCount = pSettingInfo->GetRangeCount_Flatness();
|
|
if (nIndex < nRangeCount)
|
{
|
m_prBtn[nIndex]->EnableWindow(TRUE);
|
m_prBtn[nIndex]->SetCheck(TRUE);
|
|
CDlgSelfDiagnosis_Flatness* pDlg = (CDlgSelfDiagnosis_Flatness*)AfxGetApp()->m_pMainWnd;
|
pDlg->PostMessage(CUSTOM_UPDATEDATA, 0, 0);
|
}
|
|
return TRUE;
|
}
|
|
BOOL CDlgSelfDiagnosis_Flatness::ChangeGridResultData()
|
{
|
CDiagnosisInfo* pSettingInfo = m_pDiagnosisManager->GetDiagnosisInfo();
|
if (pSettingInfo == NULL) return FALSE;
|
|
CDiagnosisResult * pProcessResult = m_pDiagnosisManager->GetDiagnosisResult_Flatness();
|
if (pProcessResult == NULL) return FALSE;
|
|
SPositionData* pPositionData = pProcessResult->GetPositionData_Flatness(0);
|
if (pPositionData == NULL) return FALSE;
|
|
int nMode = pSettingInfo->GetFlatnessMode();
|
|
SetGridResultData(nMode, pPositionData);
|
|
CDlgSelfDiagnosis_Flatness* pDlg = (CDlgSelfDiagnosis_Flatness*)AfxGetApp()->m_pMainWnd;
|
pDlg->PostMessage(CUSTOM_UPDATEDATA, 0, 0);
|
|
return TRUE;
|
}
|
|
void CDlgSelfDiagnosis_Flatness::DoDataExchange(CDataExchange* pDX)
|
{
|
CDialogEx::DoDataExchange(pDX);
|
DDX_Control(pDX, IDC_GRID_RESULT_DATA, m_ctrlResultData);
|
DDX_Control(pDX, IDC_PICTURE_CONTROL, m_Plot);
|
DDX_Control(pDX, IDC_LIST, m_ListBox);
|
DDX_Control(pDX, IDC_BUTTON_SIMULATION, m_btnSimul);
|
DDX_Control(pDX, IDC_COMBO_MODE, m_ComboMode);
|
DDX_Control(pDX, IDC_STATIC_GLASSVIEW, m_staticGlassView);
|
DDX_Control(pDX, IDC_EDIT_JUDGE_MOTOR_Z, m_EditJudgeRange);
|
DDX_Control(pDX, IDC_EDIT_COUNT, m_EditRangeCount);
|
}
|
|
BEGIN_MESSAGE_MAP(CDlgSelfDiagnosis_Flatness, CDialogEx)
|
ON_LBN_SELCHANGE(IDC_LIST, &CDlgSelfDiagnosis_Flatness::OnLbnSelchangeList)
|
ON_BN_CLICKED(IDC_BUTTON_SIMULATION, &CDlgSelfDiagnosis_Flatness::OnBnClickedButtonSimulation)
|
ON_WM_DESTROY()
|
ON_CBN_SELCHANGE(IDC_COMBO_MODE, &CDlgSelfDiagnosis_Flatness::OnCbnSelchangeComboMode)
|
ON_MESSAGE(CUSTOM_UPDATEDATA, OnUpdateDialog)
|
ON_BN_CLICKED(IDC_BUTTON_MANUAL, &CDlgSelfDiagnosis_Flatness::OnBnClickedButtonManual)
|
END_MESSAGE_MAP()
|
void CDlgSelfDiagnosis_Flatness::InitGnuPlot()
|
{
|
/*
|
const char* text_char = "C:\\gnuplot426\\bin\\wgnuplot.exe";
|
size_t length = strlen(text_char);
|
wchar_t text_wchar[30];
|
mbstowcs_s(&length, text_wchar, text_char, length);
|
*/
|
m_Plot.init(_T("wgnuplot.exe"));
|
//m_Plot1.cmd("plot sin(x)");
|
//m_Plot1.cmd("replot cos(x)");
|
//m_Plot1.cmd("replot tan(x)");
|
|
//reset # set 초기화
|
|
|
m_Plot.cmd("set object 1 rectangle from screen 0,0 to screen 1,1 fillcolor rgb '#282d32' behind"); // # 바탕화면 색 지정
|
|
m_Plot.cmd("set pm3d");
|
m_Plot.cmd("set xtics textcolor rgb '#d5d5d5'"); // # x 축 색 지정
|
|
m_Plot.cmd("set ytics textcolor rgb '#d5d5d5'"); // # y 축 색 지정
|
|
m_Plot.cmd("set ztics textcolor rgb '#d5d5d5'"); // # z 축 색 지정
|
|
m_Plot.cmd("set key textcolor rgb '#d5d5d5'"); // # 범례 텍스트 색지정
|
m_Plot.cmd("set border lc rgb '#555555'"); // # 범례 색 지정
|
|
m_Plot.cmd("set palette rgbformulae 33,13,10");
|
//m_Plot.cmd("set dgrid3d 10,10"); // # Smooth 처리
|
m_Plot.cmd("set dgrid3d 8,8"); // # Smooth 처리
|
m_Plot.cmd("splot 'c:\\temp\\image.txt' with lines"); // # 그래프 출력
|
//m_Plot.cmd("splot 'c:\\temp\\data3.txt' matrix w lines lc rgb '#FAED7D'"); // # 그래프 출력
|
//m_Plot.cmd("splot 'test.csv' using 1:2:3 '%lf,%lf,%lf,%lf' with linespoints pt 6 ps 2 lw 3 matrix w lines lc rgb '#FAED7D'");
|
|
|
|
//m_Plot.cmd("splot -x*x with pm3d");
|
|
}
|
|
void CDlgSelfDiagnosis_Flatness::InitListCtrl()
|
{
|
CString strExt = _T("\\*txt");
|
CString strFilePath = REVIEW_AUTO_DIAGNOSIS_RESULT_FLATNESS_PATH + strExt;
|
|
//검색 클래스
|
CFileFind finder;
|
|
//CFileFind는 파일, 디렉터리가 존재하면 TRUE 를 반환함
|
BOOL bWorking = finder.FindFile(strFilePath); //
|
|
CString fileName;
|
CString DirName;
|
|
|
m_ListBox.ResetContent();
|
while (bWorking)
|
{
|
//다음 파일 / 폴더 가 존재하면다면 TRUE 반환
|
bWorking = finder.FindNextFile();
|
//파일 일때
|
if (finder.IsArchived())
|
{
|
//파일의 경로
|
CString _fileName = finder.GetFilePath();
|
|
// 현재폴더 상위폴더 썸네일파일은 제외
|
if (_fileName == _T(".") ||
|
_fileName == _T("..") ||
|
_fileName == _T("Thumbs.db")) continue;
|
|
//읽어온 파일 경로를 리스트박스에 넣음
|
m_ListBox.AddString(_fileName);
|
}
|
//// 디렉터리 일때
|
//if (finder.IsDirectory())
|
//{
|
// // 필요하면 여기서 처리
|
// DirName = finder.GetFileName();
|
//}
|
}
|
}
|
|
|
|
void CDlgSelfDiagnosis_Flatness::InitModeComboBox()
|
{
|
//enum FlatnessMode { Mode_2x2, Mode_3x3, Mode_3x4, Mode_4x5, Mode_10x10, ModeCount };
|
m_ComboMode.AddString("Mode_2x2");
|
m_ComboMode.AddString("Mode_3x3");
|
m_ComboMode.AddString("Mode_3x4");
|
m_ComboMode.AddString("Mode_4x5");
|
m_ComboMode.AddString("Mode_10x10");
|
}
|
|
void CDlgSelfDiagnosis_Flatness::InitRadioButton(int nMode)
|
{
|
|
//enum FlatnessMode { Mode_2x2, Mode_3x3, Mode_3x4, Mode_4x5, Mode_10x10, ModeCount };
|
//Mode_2x2 0 = 4ea
|
//Mode_3x3 1 = 9ea
|
//Mode_3x4 2 = 12ea
|
//Mode_4x5 3 = 20ea
|
//Mode_10x10 4 = 100ea
|
int nbtncnt = 0;
|
int nWidth, nHeight, nViewWidth, nViewHeight, nSx, nSy, nRows, nCols;
|
int nbtnsize = 15;
|
int nBtnidx = 0;
|
|
CRect rt;
|
m_staticGlassView.GetClientRect(rt);
|
|
nSx = rt.Width();
|
nSy = rt.Height() + 3;
|
nViewWidth = rt.Width() - 20;
|
nViewHeight = rt.Height() - 30;
|
DeleteRadioButton();
|
switch (nMode)
|
{
|
case Mode_2x2:
|
nRows = 2;
|
nCols = 2;
|
break;
|
|
case Mode_3x3:
|
nRows = 3;
|
nCols = 3;
|
break;
|
|
case Mode_3x4:
|
nRows = 3;
|
nCols = 4;
|
break;
|
|
case Mode_4x5:
|
nRows = 4;
|
nCols = 5;
|
break;
|
|
case Mode_10x10:
|
nRows = 10;
|
nCols = 10;
|
break;
|
|
}
|
nbtncnt = nRows * nCols;
|
|
nWidth = nViewWidth / (nRows - 1);
|
nHeight = nViewHeight / (nCols - 1);
|
|
|
m_prBtn = new CButton*[nbtncnt];
|
for (int i = 0; i < nRows; i++)
|
{
|
if (i % 2 == 0)
|
{
|
for (int j = nCols - 1; j >= 0; j--)
|
{
|
m_prBtn[nBtnidx] = new CButton();
|
m_prBtn[nBtnidx]->Create(_T(""), WS_CHILD | WS_VISIBLE |
|
BS_AUTORADIOBUTTON, CRect(nSx + nWidth * i, nSy + nHeight * j, nSx + nWidth * i + nbtnsize, nSy + nHeight * j + nbtnsize), this, BTN_ID_001);
|
|
m_prBtn[nBtnidx]->EnableWindow(FALSE);
|
m_prBtn[nBtnidx]->SetCheck(FALSE);
|
nBtnidx++;
|
}
|
}
|
else
|
{
|
for (int j = 0; j < nCols; j++)
|
{
|
m_prBtn[nBtnidx] = new CButton();
|
m_prBtn[nBtnidx]->Create(_T(""), WS_CHILD | WS_VISIBLE |
|
BS_AUTORADIOBUTTON, CRect(nSx + nWidth * i, nSy + nHeight * j, nSx + nWidth * i + nbtnsize, nSy + nHeight * j + nbtnsize), this, BTN_ID_001);
|
|
m_prBtn[nBtnidx]->EnableWindow(FALSE);
|
m_prBtn[nBtnidx]->SetCheck(FALSE);
|
nBtnidx++;
|
}
|
}
|
}
|
|
m_bUseRadioBtn = TRUE;
|
m_nPrerbtnCnt = nbtncnt;
|
}
|
|
BOOL CDlgSelfDiagnosis_Flatness::InitDiagnosisSetiing()
|
{
|
const CDiagnosisInfo* pSettingInfo = m_pDiagnosisManager->GetDiagnosisInfo();
|
if (pSettingInfo == NULL) return 0;
|
|
CString strTemp = _T("");
|
|
strTemp.Format(_T("%d"), pSettingInfo->GetJudgeData_ZRange());
|
m_EditJudgeRange.SetWindowTextA(strTemp);
|
|
int nMode = pSettingInfo->GetFlatnessMode();
|
int nRangeCount = pSettingInfo->GetRangeCount_Flatness();
|
m_ComboMode.SetCurSel(nMode);
|
|
if(nMode==0)
|
strTemp = _T("Mode_2x2");
|
else if (nMode == 1)
|
strTemp = _T("Mode_3x3");
|
else if (nMode == 2)
|
strTemp = _T("Mode_3x4");
|
else if (nMode == 3)
|
strTemp = _T("Mode_4x5");
|
else if (nMode == 4)
|
strTemp = _T("Mode_10x10");
|
m_ComboMode.SetWindowTextA(strTemp);
|
|
strTemp.Format("%d", nRangeCount);
|
m_EditRangeCount.SetWindowTextA(strTemp);
|
SetRadioButton(nMode);
|
InitRadioButton(nMode);
|
|
return TRUE;
|
|
}
|
|
BOOL CDlgSelfDiagnosis_Flatness::SetGridResultData(int nMode, SPositionData* pPositionData)
|
{
|
int nRowIdx, nColIdx, nRows, nCols, nFixRows, nFixCols;
|
CString strTemp;
|
|
int nGridWidth, nGridHeight;
|
nGridWidth = 380;
|
nGridHeight = 80;
|
|
m_ctrlResultData.DeleteAllItems();
|
|
switch (nMode)
|
{
|
case Mode_2x2:
|
nCols = 2;
|
nRows = 2;
|
m_ctrlResultData.SetRowCount(nRows+1);
|
m_ctrlResultData.SetColumnCount(nCols+1);
|
m_ctrlResultData.SetColumnWidth(0, 130);
|
//tmp_grid.SetItemBkColour(row, col, clr);
|
//tmp_grid.SetItemFgColour(row, col, RGB(255, 0, 0));
|
for (int i = 0; i < nRows +1; i++)
|
{
|
//m_ctrlResultData.SetRowHeight(i, nGridHeight/2);
|
}
|
|
for (int i = 0; i < nCols +1; i++)
|
{
|
//m_ctrlResultData.SetColumnWidth(i, nGridWidth/2);
|
}
|
break;
|
case Mode_3x3:
|
nCols = 3;
|
nRows = 3;
|
m_ctrlResultData.SetRowCount(nRows+1);
|
m_ctrlResultData.SetColumnCount(nCols+1);
|
for (int i = 0; i < nRows; i++)
|
{
|
//m_ctrlResultData.SetRowHeight(i, 31);
|
}
|
|
for (int i = 0; i < nCols; i++)
|
{
|
//m_ctrlResultData.SetColumnWidth(i, 171);
|
}
|
break;
|
case Mode_3x4:
|
nCols = 3;
|
nRows = 4;
|
m_ctrlResultData.SetRowCount(nRows+1);
|
m_ctrlResultData.SetColumnCount(nCols+1);
|
for (int i = 0; i < nRows; i++)
|
{
|
//m_ctrlResultData.SetRowHeight(i, 31);
|
}
|
|
for (int i = 0; i < nCols; i++)
|
{
|
//m_ctrlResultData.SetColumnWidth(i, 171);
|
}
|
break;
|
case Mode_4x5:
|
|
nCols = 4;
|
nRows = 5;
|
m_ctrlResultData.SetRowCount(nRows+1);
|
m_ctrlResultData.SetColumnCount(nCols+1);
|
for (int i = 0; i < nRows; i++)
|
{
|
//m_ctrlResultData.SetRowHeight(i, 31);
|
}
|
|
for (int i = 0; i < nCols; i++)
|
{
|
//m_ctrlResultData.SetColumnWidth(i, 171);
|
}
|
break;
|
case Mode_10x10:
|
|
nCols = 10;
|
nRows = 10;
|
m_ctrlResultData.SetRowCount(nRows+1);
|
m_ctrlResultData.SetColumnCount(nCols+1);
|
for (int i = 0; i < nRows; i++)
|
{
|
//m_ctrlResultData.SetRowHeight(i, 31);
|
}
|
|
for (int i = 0; i < nCols; i++)
|
{
|
//m_ctrlResultData.SetColumnWidth(i, 171);
|
}
|
break;
|
|
}
|
|
int nIndex = 0;
|
|
nCols++;
|
nRows++;
|
|
|
// 글라스 좌표 영역 색상
|
for (int i = 0; i < nRows; i++)
|
{
|
m_ctrlResultData.SetItemBkColour(i, 0, RGB(128, 143, 175));
|
}
|
|
for (int i = 0; i < nCols; i++)
|
{
|
m_ctrlResultData.SetItemBkColour(0, i, RGB(128, 143, 175));
|
}
|
|
|
// 0,0 영역 색상 및 텍스트
|
|
GV_ITEM Item;
|
Item.mask = GVIF_TEXT | GVIF_FORMAT;
|
Item.nFormat = DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX;
|
strTemp.Format(_T("GlassPosY\GlassPosX(mm)"));
|
m_ctrlResultData.SetColumnWidth(0, 171);
|
Item.col = 0;
|
Item.row = 0;
|
Item.strText = strTemp;
|
m_ctrlResultData.SetItem(&Item);
|
|
|
|
// 값 입력
|
for (int i = 1; i < nCols; i++)
|
{
|
if (i % 2 == 0)
|
{
|
for (int j = 1; j < nRows; j++)
|
{
|
Item.col = i;
|
Item.row = j;
|
strTemp.Format(_T("%lf"), pPositionData[nIndex].dPosZ);
|
Item.strText = strTemp;
|
m_ctrlResultData.SetItem(&Item);
|
|
Item.col = i;
|
Item.row = 0;
|
strTemp.Format(_T("%.2lf"), pPositionData[nIndex].dPosX);
|
Item.strText = _T("글라스좌표X");
|
Item.strText = strTemp;
|
m_ctrlResultData.SetItem(&Item);
|
|
Item.col = 0;
|
Item.row = j;
|
strTemp.Format(_T("%.2lf"), pPositionData[nIndex].dPosY);
|
Item.strText = _T("글라스좌표Y");
|
Item.strText = strTemp;
|
m_ctrlResultData.SetItem(&Item);
|
|
nIndex++;
|
|
}
|
}
|
else
|
{
|
for (int j = nRows - 1; j > 0; j--)
|
{
|
Item.col = i;
|
Item.row = j;
|
strTemp.Format(_T("%lf"), pPositionData[nIndex].dPosZ);
|
Item.strText = strTemp;
|
m_ctrlResultData.SetItem(&Item);
|
|
Item.col = i;
|
Item.row = 0;
|
strTemp.Format(_T("%.2lf"), pPositionData[nIndex].dPosX);
|
Item.strText = _T("글라스좌표X");
|
Item.strText = strTemp;
|
m_ctrlResultData.SetItem(&Item);
|
|
Item.col = 0;
|
Item.row = j;
|
strTemp.Format(_T("%.2lf"), pPositionData[nIndex].dPosY);
|
Item.strText = _T("글라스좌표Y");
|
Item.strText = strTemp;
|
m_ctrlResultData.SetItem(&Item);
|
nIndex++;
|
}
|
}
|
}
|
|
m_ctrlResultData.SetEditable(FALSE);
|
|
return TRUE;
|
}
|
|
void CDlgSelfDiagnosis_Flatness::SetListCtrl()
|
{
|
|
}
|
|
void CDlgSelfDiagnosis_Flatness::SetGnuPlot(CString strFilePath)
|
{
|
CString strsplot, strtemp, strCmdMakeGraph;
|
|
strsplot = _T("splot ");
|
strtemp = _T(" with lines");
|
strCmdMakeGraph = strsplot + _T("'") + strFilePath + _T("'") + strtemp;
|
|
m_Plot.cmd("set dgrid3d 2,2"); // # Smooth 처리
|
m_Plot.cmd(strCmdMakeGraph); // # 그래프 출력
|
}
|
|
void CDlgSelfDiagnosis_Flatness::SetRadioButton(int nMode)
|
{
|
//enum FlatnessMode { Mode_2x2, Mode_3x3, Mode_3x4, Mode_4x5, Mode_10x10, ModeCount };
|
//Mode_2x2 0 = 4ea
|
//Mode_3x3 1 = 9ea
|
//Mode_3x4 2 = 12ea
|
//Mode_4x5 3 = 20ea
|
//Mode_10x10 4 = 100ea
|
int nbtncnt = 0;
|
int nWidth, nHeight, nViewWidth, nViewHeight, nSx, nSy, nRows, nCols;
|
int nbtnsize = 15;
|
int nBtnidx = 0;
|
|
CRect rt;
|
m_staticGlassView.GetClientRect(rt);
|
|
nSx = rt.Width();
|
nSy = rt.Height()+3;
|
nViewWidth = rt.Width()-20;
|
nViewHeight = rt.Height()-30;
|
DeleteRadioButton();
|
switch (nMode)
|
{
|
case Mode_2x2:
|
nRows = 2;
|
nCols = 2;
|
|
nbtncnt = nRows * nCols;
|
|
nWidth = nViewWidth / (nRows - 1);
|
nHeight = nViewHeight / (nCols - 1);
|
|
|
m_prBtn = new CButton*[nbtncnt];
|
for (int i = 0; i < nRows; i++)
|
{
|
if (i % 2 == 0)
|
{
|
for (int j = 0; j < nCols; j++)
|
{
|
m_prBtn[nBtnidx] = new CButton();
|
m_prBtn[nBtnidx]->Create(_T(""), WS_CHILD | WS_VISIBLE |
|
BS_AUTORADIOBUTTON, CRect(nSx + nWidth * i, nSy + nHeight * j, nSx + nWidth * i + nbtnsize, nSy + nHeight * j + nbtnsize), this, BTN_ID_001);
|
|
//m_prBtn[nBtnidx]->EnableWindow(FALSE);
|
m_prBtn[nBtnidx]->SetCheck(TRUE);
|
nBtnidx++;
|
}
|
}
|
else
|
{
|
for (int j = nCols - 1; j >= 0; j--)
|
{
|
m_prBtn[nBtnidx] = new CButton();
|
m_prBtn[nBtnidx]->Create(_T(""), WS_CHILD | WS_VISIBLE |
|
BS_AUTORADIOBUTTON, CRect(nSx + nWidth * i, nSy + nHeight * j, nSx + nWidth * i + nbtnsize, nSy + nHeight * j + nbtnsize), this, BTN_ID_001);
|
|
//m_prBtn[nBtnidx]->EnableWindow(FALSE);
|
m_prBtn[nBtnidx]->SetCheck(TRUE);
|
nBtnidx++;
|
}
|
}
|
}
|
break;
|
|
case Mode_3x3:
|
nRows = 3;
|
nCols = 3;
|
|
nbtncnt = nRows * nCols;
|
|
nWidth = nViewWidth / (nRows - 1);
|
nHeight = nViewHeight / (nCols - 1);
|
|
|
m_prBtn = new CButton*[nbtncnt];
|
for (int i = 0; i < nRows; i++)
|
{
|
if (i % 2 == 0)
|
{
|
for (int j = 0; j < nCols; j++)
|
{
|
m_prBtn[nBtnidx] = new CButton();
|
m_prBtn[nBtnidx]->Create(_T(""), WS_CHILD | WS_VISIBLE |
|
BS_AUTORADIOBUTTON, CRect(nSx + nWidth * i, nSy + nHeight * j, nSx + nWidth * i + nbtnsize, nSy + nHeight * j + nbtnsize), this, BTN_ID_001);
|
|
//m_prBtn[nBtnidx]->EnableWindow(FALSE);
|
m_prBtn[nBtnidx]->SetCheck(TRUE);
|
nBtnidx++;
|
}
|
}
|
else
|
{
|
for (int j = nCols - 1; j >= 0; j--)
|
{
|
m_prBtn[nBtnidx] = new CButton();
|
m_prBtn[nBtnidx]->Create(_T(""), WS_CHILD | WS_VISIBLE |
|
BS_AUTORADIOBUTTON, CRect(nSx + nWidth * i, nSy + nHeight * j, nSx + nWidth * i + nbtnsize, nSy + nHeight * j + nbtnsize), this, BTN_ID_001);
|
|
//m_prBtn[nBtnidx]->EnableWindow(FALSE);
|
m_prBtn[nBtnidx]->SetCheck(TRUE);
|
nBtnidx++;
|
}
|
}
|
}
|
break;
|
|
case Mode_3x4:
|
nRows = 3;
|
nCols = 4;
|
|
nbtncnt = nRows * nCols;
|
|
nWidth = nViewWidth / (nRows - 1);
|
nHeight = nViewHeight / (nCols - 1);
|
|
|
m_prBtn = new CButton*[nbtncnt];
|
for (int i = 0; i < nRows; i++)
|
{
|
|
if (i % 2 == 0)
|
{
|
for (int j = 0; j < nCols; j++)
|
{
|
m_prBtn[nBtnidx] = new CButton();
|
m_prBtn[nBtnidx]->Create(_T(""), WS_CHILD | WS_VISIBLE |
|
BS_AUTORADIOBUTTON, CRect(nSx + nWidth * i, nSy + nHeight * j, nSx + nWidth * i + nbtnsize, nSy + nHeight * j + nbtnsize), this, BTN_ID_001);
|
|
//m_prBtn[nBtnidx]->EnableWindow(FALSE);
|
m_prBtn[nBtnidx]->SetCheck(TRUE);
|
nBtnidx++;
|
}
|
}
|
else
|
{
|
for (int j = nCols-1; j >= 0; j--)
|
{
|
m_prBtn[nBtnidx] = new CButton();
|
m_prBtn[nBtnidx]->Create(_T(""), WS_CHILD | WS_VISIBLE |
|
BS_AUTORADIOBUTTON, CRect(nSx + nWidth * i, nSy + nHeight * j, nSx + nWidth * i + nbtnsize, nSy + nHeight * j + nbtnsize), this, BTN_ID_001);
|
|
//m_prBtn[nBtnidx]->EnableWindow(FALSE);
|
m_prBtn[nBtnidx]->SetCheck(TRUE);
|
nBtnidx++;
|
}
|
}
|
}
|
break;
|
|
case Mode_4x5:
|
nRows = 4;
|
nCols = 5;
|
|
nbtncnt = nRows * nCols;
|
|
nWidth = nViewWidth / (nRows - 1);
|
nHeight = nViewHeight / (nCols - 1);
|
|
|
m_prBtn = new CButton*[nbtncnt];
|
for (int i = 0; i < nRows; i++)
|
{
|
if (i % 2 == 0)
|
{
|
for (int j = 0; j < nCols; j++)
|
{
|
m_prBtn[nBtnidx] = new CButton();
|
m_prBtn[nBtnidx]->Create(_T(""), WS_CHILD | WS_VISIBLE |
|
BS_AUTORADIOBUTTON, CRect(nSx + nWidth * i, nSy + nHeight * j, nSx + nWidth * i + nbtnsize, nSy + nHeight * j + nbtnsize), this, BTN_ID_001);
|
|
//m_prBtn[nBtnidx]->EnableWindow(FALSE);
|
m_prBtn[nBtnidx]->SetCheck(TRUE);
|
nBtnidx++;
|
}
|
}
|
else
|
{
|
for (int j = nCols - 1; j >= 0; j--)
|
{
|
m_prBtn[nBtnidx] = new CButton();
|
m_prBtn[nBtnidx]->Create(_T(""), WS_CHILD | WS_VISIBLE |
|
BS_AUTORADIOBUTTON, CRect(nSx + nWidth * i, nSy + nHeight * j, nSx + nWidth * i + nbtnsize, nSy + nHeight * j + nbtnsize), this, BTN_ID_001);
|
|
//m_prBtn[nBtnidx]->EnableWindow(FALSE);
|
m_prBtn[nBtnidx]->SetCheck(TRUE);
|
nBtnidx++;
|
}
|
}
|
}
|
break;
|
|
case Mode_10x10:
|
nRows = 10;
|
nCols = 10;
|
|
nbtncnt = nRows * nCols;
|
|
nWidth = nViewWidth / (nRows - 1);
|
nHeight = nViewHeight / (nCols - 1);
|
|
|
m_prBtn = new CButton*[nbtncnt];
|
for (int i = 0; i < nRows; i++)
|
{
|
if (i % 2 == 0)
|
{
|
for (int j = 0; j < nCols; j++)
|
{
|
m_prBtn[nBtnidx] = new CButton();
|
m_prBtn[nBtnidx]->Create(_T(""), WS_CHILD | WS_VISIBLE |
|
BS_AUTORADIOBUTTON, CRect(nSx + nWidth * i, nSy + nHeight * j, nSx + nWidth * i + nbtnsize, nSy + nHeight * j + nbtnsize), this, BTN_ID_001);
|
|
//m_prBtn[nBtnidx]->EnableWindow(FALSE);
|
m_prBtn[nBtnidx]->SetCheck(TRUE);
|
nBtnidx++;
|
}
|
}
|
else
|
{
|
for (int j = nCols - 1; j >= 0; j--)
|
{
|
m_prBtn[nBtnidx] = new CButton();
|
m_prBtn[nBtnidx]->Create(_T(""), WS_CHILD | WS_VISIBLE |
|
BS_AUTORADIOBUTTON, CRect(nSx + nWidth * i, nSy + nHeight * j, nSx + nWidth * i + nbtnsize, nSy + nHeight * j + nbtnsize), this, BTN_ID_001);
|
|
//m_prBtn[nBtnidx]->EnableWindow(FALSE);
|
m_prBtn[nBtnidx]->SetCheck(TRUE);
|
nBtnidx++;
|
}
|
}
|
}
|
break;
|
|
}
|
|
m_bUseRadioBtn = TRUE;
|
m_nPrerbtnCnt = nbtncnt;
|
|
}
|
BOOL CDlgSelfDiagnosis_Flatness::OnInitDialog()
|
{
|
CDialogEx::OnInitDialog();
|
|
InitDiagnosisSetiing();
|
InitListCtrl();
|
InitGnuPlot();
|
InitModeComboBox();
|
|
// TODO: 여기에 추가 초기화 작업을 추가합니다.
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
// 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
|
}
|
|
|
void CDlgSelfDiagnosis_Flatness::OnLbnSelchangeList()
|
{
|
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
|
int nCurrentSel;
|
CString strFilePath = _T("");
|
|
|
nCurrentSel = m_ListBox.GetCurSel();
|
m_ListBox.GetText(nCurrentSel, strFilePath);
|
|
//"c:\\temp\\2020-12-01_1_Flatness.txt" // 1_Flatness = Mode 1 = Mode_3x3;
|
int nMode, nTemp;
|
CString strMode;
|
nTemp = strFilePath.Find(_T("."));
|
nTemp -= 10; // "c:\\temp\\2020-12-01_1 <-1의 위치 찾기
|
|
strMode = strFilePath.Mid(nTemp,1);
|
nMode = _ttoi(strMode);
|
|
// Mode로 RangeCount 찾아내기
|
int nRangeCount;
|
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; }
|
|
// RangeCount만큼 SPositionData 생성
|
SPositionData* pPositionData = new SPositionData[nRangeCount];
|
|
|
|
SetGnuPlot(strFilePath);
|
m_pDiagnosisManager->GetDiagnosis3DImageData_Flatness(strFilePath, pPositionData);
|
SetGridResultData(nMode, pPositionData);
|
SetRadioButton(nMode);
|
m_ComboMode.SetCurSel(nMode);
|
|
|
// 메모리 해제
|
delete [] pPositionData;
|
}
|
|
|
void CDlgSelfDiagnosis_Flatness::MakeSimulationData()
|
{
|
for (int i = 1; i <= 5; i++)
|
{
|
SPositionData data;
|
data.dPosX = i * 1000;
|
data.dPosY = i * 1000;
|
data.dPosZ = i * 1000;
|
data.nIndex = i;
|
}
|
}
|
|
int CDlgSelfDiagnosis_Flatness::LoadResultData()
|
{
|
CString strFilepath = _T("C:\\temp\\2018-12-01_0_Flatness.txt");
|
|
|
CFile file;
|
// 파일의 내용을 담는다.
|
CString strFile;
|
// 파일의 크기
|
int nFileSize = 0;
|
// 단어를 담을 스트링 배열
|
// CString의 배열 보다 CStirng을 담을 수 있는 배열을 쓰는게 효율적이다.
|
CStringArray strWordArray;
|
// 하나의 단어를 담을 임시 변수
|
CString strWord;
|
|
float fGlassPosX, fGlassPosY, fMotorZ;
|
enum { GlassPosX, GlassPosY, MotorZ };
|
CString str = _T("\r\n");
|
if (file.Open(strFilepath, CFile::modeRead))
|
{
|
// 파일의 크기를 구한다.
|
nFileSize = (int)file.GetLength();
|
// 파일의 크기 만큼 읽어 CString 변수에 담는다.
|
file.Read(strFile.GetBuffer(nFileSize), nFileSize);
|
strFile.ReleaseBuffer(nFileSize);
|
|
|
int nIndex = -1;
|
|
// 공백을 찾을 때 까지 루프를 돈다.
|
while (strFile.Find(" ") != -1)
|
{
|
|
// 공백까지의 스트링을 가져온다.
|
strWord = strFile.Left(strFile.Find(" "));
|
|
// 단어를 담는다.
|
if (strWord.Mid(0, 2) == str)
|
{
|
//strWordArray.Add(strWord.Mid(2, strWord.GetLength() - 2));
|
strWord = strWord.Mid(2, strWord.GetLength() - 2);
|
nIndex = 0;
|
}
|
else
|
{
|
nIndex++;
|
//strWordArray.Add(strWord);
|
}
|
|
switch (nIndex)
|
{
|
case GlassPosX:
|
fGlassPosX = _tstof(strWord);
|
TRACE(_T("fGlassPosX = %f\r\n"), fGlassPosX);
|
break;
|
case GlassPosY:
|
fGlassPosY = _tstof(strWord);
|
TRACE(_T("fGlassPosY = %f\r\n"), fGlassPosY);
|
break;
|
case MotorZ:
|
fMotorZ = _tstof(strWord);
|
TRACE(_T("fMotorZ = %f\r\n"), fMotorZ);
|
break;
|
}
|
|
|
|
// 단어 길이만큼 파일의 내용을 삭제한다.
|
if(strFile.Mid(0,2)== str)
|
strFile.Delete(0, strWord.GetLength()+3);
|
else
|
strFile.Delete(0, strWord.GetLength() + 1);
|
|
|
}
|
// 파일의 끝은 공백이 없으므로 마지막 단어가 하나 남는다.
|
// 마지막 단어 하나를 추가해 준다.
|
//strWordArray.Add(strFile);
|
//if (strWord.Mid(0, 2) == str)
|
// strWordArray.Add(strWord.Mid(2, strWord.GetLength() - 2));
|
//else
|
// strWordArray.Add(strWord);
|
|
file.Close();
|
}
|
|
|
return TRUE;
|
}
|
|
|
int CDlgSelfDiagnosis_Flatness::SaveResultData(int nMode)
|
{
|
/*
|
CTime cTime = CTime::GetCurrentTime(); // 현재 시스템으로부터 날짜 및 시간을 얻어 온다.
|
CString strFilename,strFilePath;
|
|
|
//strFilename.Format(_T("c:\\temp\\2018_12_01_12_24_0_Flatness.txt"));
|
strFilename.Format("%d-%2d-%2d-%2d-%2d-%d-Flatness.txt", cTime.GetYear(),cTime.GetMonth(),cTime.GetDay(), cTime.GetHour(), cTime.GetMinute(),nMode);
|
strFilePath = _T("C:\\temp\\tempimage\\") + strFilename;
|
|
FILE *fp = NULL;
|
_tfopen_s(&fp, strFilePath, _T("w"));
|
if (fp == NULL) return 0;
|
|
|
|
|
_ftprintf_s(fp, _T("%d %d %.3lf \n"), 10, 10, 1.01);
|
_ftprintf_s(fp, _T("%d %d %.3lf \n"), 10, 2290, 1.015);
|
_ftprintf_s(fp, _T("%d %d %.3lf \n"), 2690, 2290, 1.07);
|
_ftprintf_s(fp, _T("%d %d %.3lf \n"), 2690, 10, 1.031);
|
|
int nIndex = 0;
|
|
for (int i =0; i<5; i++)
|
{
|
//pDefectResult = static_cast<CDefectResult*>(*it);
|
//
|
//if (pDefectResult == NULL) continue;
|
|
_ftprintf_s(fp, _T("%d %d %.3lf \n"), 10, 10, 1.01);
|
_ftprintf_s(fp, _T("%d %d %.3lf \n"), 10, 2290, 1.015);
|
_ftprintf_s(fp, _T("%d %d %.3lf \n"), 2690, 2290, 1.07);
|
_ftprintf_s(fp, _T("%d %d %.3lf \n"), 2690, 10, 1.031);
|
}
|
|
fclose(fp);
|
*/
|
return 1;
|
}
|
|
void CDlgSelfDiagnosis_Flatness::DeleteRadioButton()
|
{
|
if (m_bUseRadioBtn == TRUE)
|
{
|
if (m_prBtn != NULL)
|
{
|
for (int i = 0; i < m_nPrerbtnCnt; i++)
|
{
|
delete m_prBtn[i];
|
m_prBtn[i] = NULL;
|
}
|
delete[] m_prBtn;
|
}
|
}
|
}
|
|
void CDlgSelfDiagnosis_Flatness::OnBnClickedButtonSimulation()
|
{
|
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
|
|
//#3514_LYW_CF AOI Review 자가진단 기능 개선_START
|
if (m_pDiagnosisManager->CheckManualMode() == FALSE)
|
{
|
CString strMessage;
|
strMessage.Format(_T("Change Manual Mode!!"));
|
if (IDOK == AfxMessageBox(strMessage, MB_OK | MB_ICONERROR))
|
{
|
g_pLog->DisplayMessage(_T("Manual Diagnosis Fail! Not Manual Mode"));
|
return;
|
}
|
}
|
//#3514_LYW_CF AOI Review 자가진단 기능 개선_END
|
|
if (m_bState == FALSE)
|
{
|
m_bState = TRUE;
|
m_btnSimul.SetWindowTextA("동작 중");
|
m_pDiagnosisManager->RecvSignalToSignalControl(DiagnosisSignal_Auto, DiagnosisMode_Flatness,TRUE);
|
}
|
else
|
{
|
m_bState = FALSE;
|
m_btnSimul.SetWindowTextA("종료 됨");
|
m_pDiagnosisManager->RecvSignalToSignalControl(DiagnosisSignal_Auto, DiagnosisMode_Flatness,FALSE);
|
}
|
}
|
|
|
void CDlgSelfDiagnosis_Flatness::OnBnClickedButtonManual()
|
{
|
//#3514_LYW_CF AOI Review 자가진단 기능 개선_START
|
if (m_pDiagnosisManager->CheckManualMode() == FALSE)
|
{
|
CString strMessage;
|
strMessage.Format(_T("Change Manual Mode!!"));
|
if (IDOK == AfxMessageBox(strMessage, MB_OK | MB_ICONERROR))
|
{
|
g_pLog->DisplayMessage(_T("Manual Diagnosis Fail! Not Manual Mode"));
|
return;
|
}
|
}
|
//#3514_LYW_CF AOI Review 자가진단 기능 개선_END
|
|
m_pDiagnosisManager->ManualMeasure_Flatness();
|
}
|
|
|
void CDlgSelfDiagnosis_Flatness::OnDestroy()
|
{
|
CDialogEx::OnDestroy();
|
|
// TODO: 여기에 메시지 처리기 코드를 추가합니다.
|
}
|
|
|
void CDlgSelfDiagnosis_Flatness::OnCbnSelchangeComboMode()
|
{
|
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
|
int nMode = m_ComboMode.GetCurSel();
|
SetRadioButton(nMode);
|
}
|
|
LRESULT CDlgSelfDiagnosis_Flatness::OnUpdateDialog(WPARAM wParam, LPARAM lParam)
|
{
|
UpdateData(FALSE);
|
return 0;
|
}
|