SDC C-Project CF Review 프로그램
LYW
2021-07-01 4acd943c6f0beecd3ee573f77d8d6c7524fd5045
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
// DlgSelfDiagnosis_Squareness.cpp: 구현 파일
//
 
#include "stdafx.h"
#include "ReviewSystem.h"
#include "DlgSelfDiagnosis_Squareness.h"
#include "DlgSelfDiagnosis.h"
#include "afxdialogex.h"
 
 
// CDlgSelfDiagnosis_Squareness 대화 상자
 
IMPLEMENT_DYNAMIC(CDlgSelfDiagnosis_Squareness, CDialogEx)
 
CDlgSelfDiagnosis_Squareness::CDlgSelfDiagnosis_Squareness(CDiagnosisManager* pDiagnosisManager, CWnd* pParent /*=nullptr*/)
    : CDialogEx(IDD_DLG_SELF_DIAGNOSIS_SQUARENESS, pParent)
    , m_nSelModuleIndex(0)
    , m_dEditTheta(0)
    , m_dEditMotorX_1(0)
    , m_dEditMotorY_1(0)
    , m_dEditPixelX_1(0)
    , m_dEditPixelY_1(0)
    , m_dEditMotorX_2(0)
    , m_dEditMotorY_2(0)
    , m_dEditPixelX_2(0)
    , m_dEditPixelY_2(0)
    , m_dEditMotorX_3(0)
    , m_dEditMotorY_3(0)
    , m_dEditPixelX_3(0)
    , m_dEditPixelY_3(0)
{
    m_pDiagnosisManager = pDiagnosisManager;
}
 
CDlgSelfDiagnosis_Squareness::~CDlgSelfDiagnosis_Squareness()
{
}
 
void CDlgSelfDiagnosis_Squareness::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_GRID_GANTRY_DATA_HISTORY, m_ctrlGridGantryDataHistory);
    DDX_Control(pDX, IDC_LIST, m_ctrlListFileHistory);
    DDX_Text(pDX, IDC_EDIT_GANTRY_THETA, m_dEditTheta);
    DDX_Text(pDX, IDC_EDIT_GANTRY_MOTOR_X, m_dEditMotorX_1);
    DDX_Text(pDX, IDC_EDIT_GANTRY_MOTOR_Y, m_dEditMotorY_1);
    DDX_Text(pDX, IDC_EDIT_GANTRY_PIXEL_X, m_dEditPixelX_1);
    DDX_Text(pDX, IDC_EDIT_GANTRY_PIXEL_Y, m_dEditPixelY_1);
    DDX_Text(pDX, IDC_EDIT_GANTRY_MOTOR_X2, m_dEditMotorX_2);
    DDX_Text(pDX, IDC_EDIT_GANTRY_MOTOR_Y2, m_dEditMotorY_2);
    DDX_Text(pDX, IDC_EDIT_GANTRY_PIXEL_X2, m_dEditPixelX_2);
    DDX_Text(pDX, IDC_EDIT_GANTRY_PIXEL_Y2, m_dEditPixelY_2);
    DDX_Control(pDX, IDC_COMBO_MODULE_INDEX, m_ctrlComboModuleIndex);
    DDX_Text(pDX, IDC_EDIT_GANTRY_MOTOR_X3, m_dEditMotorX_3);
    DDX_Text(pDX, IDC_EDIT_GANTRY_MOTOR_Y3, m_dEditMotorY_3);
    DDX_Text(pDX, IDC_EDIT_GANTRY_PIXEL_X3, m_dEditPixelX_3);
    DDX_Text(pDX, IDC_EDIT_GANTRY_PIXEL_Y3, m_dEditPixelY_3);
    //DDX_Control(pDX, IDC_BUTTON_SIMULATION, m_BtSumulation);
    //DDX_Control(pDX, IDC_BUTTON_SIMULATION, m_BtSumulation);
    DDX_Control(pDX, IDC_BUTTON_SIMULATION2, m_BtSumulation);
}
 
 
BEGIN_MESSAGE_MAP(CDlgSelfDiagnosis_Squareness, CDialogEx)
    ON_LBN_SELCHANGE(IDC_LIST, &CDlgSelfDiagnosis_Squareness::OnLbnSelchangeList)
    ON_CBN_SELCHANGE(IDC_COMBO_MODULE_INDEX, &CDlgSelfDiagnosis_Squareness::OnCbnSelchangeComboModuleIndex)
    ON_BN_CLICKED(IDC_BUTTON_SIMULATION, &CDlgSelfDiagnosis_Squareness::OnBnClickedButtonSimulation)
    ON_MESSAGE(UM_UPDATE_DIALOG, &CDlgSelfDiagnosis_Squareness::OnUpdateDialog)
    ON_BN_CLICKED(IDC_BUTTON_SIMULATION2, &CDlgSelfDiagnosis_Squareness::OnBnClickedButtonSimulation2)
END_MESSAGE_MAP()
 
 
// CDlgSelfDiagnosis_Squareness 메시지 처리기
 
 
 
BOOL CDlgSelfDiagnosis_Squareness::OnInitDialog()
{
    CDialogEx::OnInitDialog();
 
    // TODO:  여기에 추가 초기화 작업을 추가합니다.
    for (int nIdx = 0; nIdx < MODULE_COUNT; nIdx++)
    {
        CString strData = _T("");
        strData.Format(_T("%02d"), nIdx);
        m_ctrlComboModuleIndex.AddString(strData);
    }
    m_ctrlComboModuleIndex.SetCurSel(0);
    
    UpdateDialogControls();
    InitListControl(); //taek 210105
 
    UpdateData(FALSE);
 
    return TRUE;  // return TRUE unless you set the focus to a control
                  // 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
}
 
void CDlgSelfDiagnosis_Squareness::InitGridControl()
{
 
}
 
void CDlgSelfDiagnosis_Squareness::FillGridControl()
{
 
}
 
 
void CDlgSelfDiagnosis_Squareness::InitListControl()
{
    CString strExt = _T("\\*txt"); //taek 210105
    CString strFilePath = REVIEW_AUTO_DIAGNOSIS_RESULT_SQUARENESS_PATH + strExt;
    //검색 클래스
    CFileFind finder;
 
    //CFileFind는 파일, 디렉터리가 존재하면 TRUE 를 반환함
    BOOL bWorking = finder.FindFile(strFilePath); //
 
    CString fileName;
    CString DirName;
 
 
    m_ctrlListFileHistory.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_ctrlListFileHistory.AddString(_fileName);
        }
        //// 디렉터리 일때
        //if (finder.IsDirectory())
        //{
        //    // 필요하면 여기서 처리
        //        DirName = finder.GetFileName();
        //}
    }
}
 
void CDlgSelfDiagnosis_Squareness::UpdateDialogControls(BOOL bLoadResult/* = FALSE*/)
{
    if (m_pDiagnosisManager == NULL/* || m_pDiagnosisManager->ExistStandardData() == FALSE*/) return;
    
        const CDiagnosisInfo* pSettingInfo = m_pDiagnosisManager->GetDiagnosisInfo();
        if (pSettingInfo == NULL) return;
 
        const CDiagnosisResult* pStandardResult = pSettingInfo->GetSettingResult_Squareness(m_nSelModuleIndex);
        if (pStandardResult == NULL) return;
 
        if (bLoadResult) // update load file data
        {
            const CDiagnosisResult* pResult = m_pDiagnosisManager->GetDiagnosisResult_Squareness(m_nSelModuleIndex);
            if (pResult == NULL) return;
 
            // result : theta, pixel position
            m_dEditTheta = pResult->GetGantryDegree();
            for (int nPIdx = 0; nPIdx < pSettingInfo->GetPanelCount_Squareness(); nPIdx++)
            {
                const SPositionData* pPosData = pResult->GetPositionData_Squareness(nPIdx);
                if (pPosData == NULL) continue;
 
                if (pPosData->nIndex == PanelPosition_Base)
                {
                    m_dEditPixelX_1 = pPosData->dPixelX;
                    m_dEditPixelY_1 = pPosData->dPixelY;
                }
                else if (pPosData->nIndex == PanelPosition_Sub)
                {
                    m_dEditPixelX_2 = pPosData->dPixelX;
                    m_dEditPixelY_2 = pPosData->dPixelY;
                }
                else if (pPosData->nIndex == PanelPosition_Addition)
                {
                    m_dEditPixelX_3 = pPosData->dPixelX;
                    m_dEditPixelY_3 = pPosData->dPixelY;
                }
            }
        }
        else if (bLoadResult == FALSE && m_pDiagnosisManager->ExistStandardData() == FALSE)// update setting data
        {
            const CDiagnosisResult* pResult = m_pDiagnosisManager->GetDiagnosisResult_Squareness(m_nSelModuleIndex);
            if (pResult == NULL) return;
 
            // result : theta, pixel position
            m_dEditTheta = pResult->GetGantryDegree();
 
            for (int nPIdx = 0; nPIdx < pSettingInfo->GetPanelCount_Squareness(); nPIdx++)
            {
                const SPositionData* pPosData = pResult->GetPositionData_Squareness(nPIdx);
                if (pPosData == NULL) continue;
 
                if (pPosData->nIndex == PanelPosition_Base)
                {
                    m_dEditPixelX_1 = pPosData->dPixelX;
                    m_dEditPixelY_1 = pPosData->dPixelY;
                }
                else if (pPosData->nIndex == PanelPosition_Sub)
                {
                    m_dEditPixelX_2 = pPosData->dPixelX;
                    m_dEditPixelY_2 = pPosData->dPixelY;
                }
                else if (pPosData->nIndex == PanelPosition_Addition)
                {
                    m_dEditPixelX_3 = pPosData->dPixelX;
                    m_dEditPixelY_3 = pPosData->dPixelY;
                }
            }
        }
        else
        {
            int nPlanindex = 0;
 
            // result : theta, pixel position
            const CDiagnosisResult* pResult = m_pDiagnosisManager->GetDiagnosisResult_Squareness(m_nSelModuleIndex);
            if (pResult == NULL) return;
 
            BOOL bProcess = FALSE;
            for (int nPIdx = 0; nPIdx < pSettingInfo->GetPanelCount_Squareness(); nPIdx++)
            {
                if (m_nSelModuleIndex == 1)
                {
                    nPlanindex = nPIdx + 3;
                }
                else
                {
                    nPlanindex = nPIdx;
                }
                const SPositionData* pPosData = pResult->GetPositionData_Squareness(nPlanindex);
                if (pPosData == NULL) continue;
 
                if (pPosData->nPosMode == PanelPosition_Base)
                {
                    m_dEditPixelX_1 = pPosData->dPixelX;
                    m_dEditPixelY_1 = pPosData->dPixelY;
                    bProcess = pPosData->bProcsss;
                }
                else if (pPosData->nIndex == PanelPosition_Sub)
                {
                    m_dEditPixelX_2 = pPosData->dPixelX;
                    m_dEditPixelY_2 = pPosData->dPixelY;
                    bProcess &= pPosData->bProcsss;
                }
                else if (pPosData->nIndex == PanelPosition_Addition)
                {
                    m_dEditPixelX_3 = pPosData->dPixelX;
                    m_dEditPixelY_3 = pPosData->dPixelY;
                    bProcess &= pPosData->bProcsss;
                }
            }
 
            m_dEditTheta = bProcess ? pResult->GetGantryDegree() : 0.;
        }
 
        // info : motor position
        for (int nPIdx = 0; nPIdx < pSettingInfo->GetPanelCount_Squareness(); nPIdx++)
        {
            const SPositionData* pPosData = pStandardResult->GetPositionData_Squareness(nPIdx);
            if (pPosData == NULL) continue;
 
            if (pPosData->nIndex == PanelPosition_Base)
            {
                m_dEditMotorX_1 = pPosData->dPosX;
                m_dEditMotorY_1 = pPosData->dPosY;
            }
            else if (pPosData->nIndex == PanelPosition_Sub)
            {
                m_dEditMotorX_2 = pPosData->dPosX;
                m_dEditMotorY_2 = pPosData->dPosY;
            }
            else if (pPosData->nIndex == PanelPosition_Addition)
            {
                m_dEditMotorX_3 = pPosData->dPosX;
                m_dEditMotorY_3 = pPosData->dPosY;
            }
        }
    
    this->PostMessage(UM_UPDATE_DIALOG);
}
 
void CDlgSelfDiagnosis_Squareness::GetDialogControls()
{
    if (m_pDiagnosisManager == NULL) return;
 
    UpdateData(TRUE);
 
    CDiagnosisInfo* pSettingInfo = m_pDiagnosisManager->GetDiagnosisInfo();
    if (pSettingInfo == NULL) return;
 
    if (m_pDiagnosisManager->ExistStandardData() == FALSE) // set standard data
    {
        CDiagnosisResult* pStandardResult = pSettingInfo->GetSettingResult_Squareness(m_nSelModuleIndex);
        if (pStandardResult == NULL)
        {
            pSettingInfo->SetSettingResultCount_Squareness(MODULE_COUNT);
            pStandardResult = pSettingInfo->GetSettingResult_Squareness(m_nSelModuleIndex);
        }
 
        pStandardResult->SetModuleIndex(m_nSelModuleIndex);
        for (int nPIdx = 0; nPIdx < pStandardResult->GetPanelCount_Squareness(); nPIdx++)
        {
            SPositionData* pPosData = pStandardResult->GetPositionData_Squareness(nPIdx);
            if (pPosData == NULL) continue;
 
            pPosData->nIndex = nPIdx;
 
            if (nPIdx == 0)
            {
                pPosData->dPosX = m_dEditMotorX_1;
                pPosData->dPosY = m_dEditMotorY_1;
            }
            else if (nPIdx == 1)
            {
                pPosData->dPosX = m_dEditMotorX_2;
                pPosData->dPosY = m_dEditMotorY_2;
            }
        }
    }
    else // set setting data
    {
 
    }
}
void CDlgSelfDiagnosis_Squareness::ChangeResultData()
{
    //     CDiagnosisResult * pProcessResult = m_pDiagnosisManager->GetDiagnosisResultCount_Squareness();
    //     if (pProcessResult == NULL) return FALSE;
    // 
    //     SPositionData* pPositionData = pProcessResult->GetPositionData_Squareness(0);
    //     if (pPositionData == NULL) return FALSE;
    // 
    //     SetGridResultData(pPositionData);
    // 
    //     CDlgSelfDiagnosis_Squareness* pDlg = (CDlgSelfDiagnosis_Squareness*)AfxGetApp()->m_pMainWnd;
    //     pDlg->PostMessage(CUSTOM_UPDATEDATA, 0, 0);
 
//    return TRUE; //taek 210105
}
 
 
void CDlgSelfDiagnosis_Squareness::DisableBtSIMULATION(BOOL bUse)
{
    if (bUse)
    {
        m_BtSumulation.EnableWindow(FALSE);
 
    }
    else
    {
        m_BtSumulation.EnableWindow(TRUE);
    }
 
    
}
 
void CDlgSelfDiagnosis_Squareness::OnLbnSelchangeList()
{
    // TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
    if (m_pDiagnosisManager == NULL) return;
 
    UpdateData(TRUE);
 
    CString strFilePath = _T("");
 
    int nCurrentSel = m_ctrlListFileHistory.GetCurSel();
    m_ctrlListFileHistory.GetText(nCurrentSel, strFilePath);
 
    m_pDiagnosisManager->LoadDiagnosisFile(strFilePath);
 
    UpdateDialogControls(TRUE);
}
 
void CDlgSelfDiagnosis_Squareness::OnCbnSelchangeComboModuleIndex()
{
    // TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
 
    UpdateData(TRUE);
 
    m_nSelModuleIndex = m_ctrlComboModuleIndex.GetCurSel();
    UpdateDialogControls();
 
}
 
LRESULT CDlgSelfDiagnosis_Squareness::OnUpdateDialog(WPARAM wParam, LPARAM lParam)
{
    UpdateData(FALSE);
    
    return 1;
}
 
void CDlgSelfDiagnosis_Squareness::OnBnClickedButtonSimulation()
{
    // TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
    if (m_pDiagnosisManager == NULL) return;
 
    GetDialogControls();
 
    m_pDiagnosisManager->RecvSignalToSignalControl(DiagnosisSignal_Manual, DiagnosisMode_Squareness, TRUE);
}
 
 
void CDlgSelfDiagnosis_Squareness::OnBnClickedButtonSimulation2()
{
    // TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
    if (m_pDiagnosisManager == NULL) return;
 
    GetDialogControls();
 
    m_pDiagnosisManager->RecvSignalToSignalControl(DiagnosisSignal_Manual, DiagnosisMode_Squareness, TRUE);
 
}