SDC C-Project CF Review 프로그램
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
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
// ReviewProcessor.cpp : 구현 파일입니다.
//
 
#include "stdafx.h"
#include "ReviewProcessor.h"
#include "CHCommonClasses/ProcessTimer.h"
#include "CHImageControls/CHImageProcess.h"
#include "CHReviewRecipe/RsRcpReviewInfo.h"
#include "CHReviewRecipe/RcpLightInfo.h"
#include "CHReviewRecipe/RsRcpDefectFindInfo.h"
#include "CameraControlReview.h"
#include "CHSignalControls/SignalControl.h"
#include "CHWsiControls/WsiControl.h"
#include "CHEdgeTriangle/RecipeManager.h"
#include "CHEdgeTriangle/EdgeTriangle.h"
 
using namespace CHReviewResult;
using namespace CHImageControls;
 
// CReviewProcessor
CReviewProcessor::CReviewProcessor(int nThreadCount) : CWorkThreadPools(nThreadCount)
{
    // gdiplus startup
    if (gpGdiplusToken==NULL)
    {
        GdiplusStartupInput gdiplusStartupInput;
        GdiplusStartup(&gpGdiplusToken, &gdiplusStartupInput, NULL);
        gpGdiplusTokenCount++;
    }
 
 
    InitializeCriticalSection(&m_csUseThreadIndex);
 
    m_pView                    = NULL;
    m_pRP2P                    = NULL;
    
    m_pReviewDefectFinder    = new CReviewDefectFinder[nThreadCount];
    m_pEdgeTriangle            = new CEdgeTriangle[nThreadCount];
    m_pUseThreadIndex        = new bool [nThreadCount];
    for (int i=0; i<m_nThreadCount; i++) 
    {
        m_pUseThreadIndex[i] = false;
    }
 
 
//     m_pManageResultFileCD    = NULL;
//     m_pManageResultFileSD    = NULL;
 
    m_strSaveImageBasePath    = _T("D:\\ResultData\\Image");
    m_strSaveImageUploadPath = _T("D:\\ResultData\\UploadImage");
    // [2017:6:6]-[WEZASW] : 
    m_strInspectImagePath    = _T("D:\\Image\\Defect");
 
    m_strRTMSImagePath = _T("");
    m_nLineType                = -1;
    m_nMachineType            = -1;
    m_strEqpID                = _T("");
    m_strJobID            = _T("");
    m_strOperID                = _T("");
    m_nReviewCount            = 0;
 
    m_nReviewResizeWidth    = 1224;
    m_nReviewResizeHeight    = 1024;
    m_nReviewImageSize        = 150000; //byte
    m_nReviewImageQuality    = 50;
    m_nReviewImageStep        = 5;
    m_dReviewImageScale        = 1.0;
    m_bReviewOriginalImage    = false;
 
    m_bDefectFindProcess    = FALSE;
 
    m_nReviewProcessStatus    = ReviewProcessStatus_None;
    m_nReviewPlanIndex        = 0;
 
    m_vecCellIndex.clear();
    m_vecCellId.clear();
}
 
CReviewProcessor::~CReviewProcessor(void)
{
    if (m_pReviewDefectFinder)
    {
        delete [] m_pReviewDefectFinder;
    }
    m_pReviewDefectFinder = NULL;
 
    if (m_pEdgeTriangle)
    {
        delete [] m_pEdgeTriangle;
    }
    m_pEdgeTriangle = NULL;
 
    if (m_pUseThreadIndex)
    {
        delete [] m_pUseThreadIndex;
    }
    m_pUseThreadIndex = NULL;
 
    DeleteCriticalSection(&m_csUseThreadIndex);
 
    // gdiplus shutdown
    gpGdiplusTokenCount--;
    if (gpGdiplusToken && gpGdiplusTokenCount==0)
    {
        GdiplusShutdown(gpGdiplusToken);
        gpGdiplusToken = NULL;
    }
}
 
void CReviewProcessor::UpdateReviewProcessStatus(int nReviewStatus, int nPlanIndex)
{
    m_nReviewProcessStatus    = nReviewStatus;
    m_nReviewPlanIndex        = nPlanIndex;
}
 
 
int    CReviewProcessor::LockThreadIndex()
{
    if (m_pUseThreadIndex==NULL) return -1;
 
    EnterCriticalSection(&m_csUseThreadIndex);
 
    int nThreadIdx = -1;
    for (int i=0; i<m_nThreadCount; i++)
    {
        if (!m_pUseThreadIndex[i])
        {
            m_pUseThreadIndex[i] = true;
 
            nThreadIdx = i;
            break;
        }
    }
 
    LeaveCriticalSection(&m_csUseThreadIndex);
 
    return nThreadIdx;
}
 
void CReviewProcessor::UnlockThreadIndex(int nIndex)
{
    if (m_pUseThreadIndex==NULL) return;
 
    EnterCriticalSection(&m_csUseThreadIndex);
 
    if (nIndex>-1 && nIndex<m_nThreadCount) 
    {
        m_pUseThreadIndex[nIndex] = false;
    }
 
    LeaveCriticalSection(&m_csUseThreadIndex);
}
 
void CReviewProcessor::SetView(CView *pView)                                
    m_pView = pView;
}
 
void CReviewProcessor::SetRP2P(IReviewProcessor2Parent *pRP2P)                    
    m_pRP2P = pRP2P; 
}
 
void CReviewProcessor::SetLineMachineType(int nLineType, int nMachineType, CString strEqpID)                            
    m_nLineType = nLineType; 
    m_nMachineType = nMachineType;
    m_strEqpID = strEqpID;
}
 
void CReviewProcessor::SetJobID(const CString& strJobID)
{
    m_strJobID = strJobID;
}
 
void CReviewProcessor::SetOperID(const CString& strOperID)
{
    m_strOperID = strOperID;
}
 
void CReviewProcessor::SetReviewCount(int nCount)
{
    m_nReviewCount = nCount;
}
 
void CReviewProcessor::SetSaveImageBasePath(const CString& strPath)        
    m_strSaveImageBasePath = strPath; 
}
 
BOOL CReviewProcessor::SetReviewImageInfo(int nWidth, int nHeight, int nSize, int nQuality, int nStep, double dScale)
{
    if (nQuality>100 || nStep<1 || nStep>10) return FALSE;
 
    m_nReviewResizeWidth    = nWidth;
    m_nReviewResizeHeight    = nHeight;
    m_nReviewImageSize        = nSize; //byte
    m_nReviewImageQuality    = nQuality;
    m_nReviewImageStep        = nStep;
    m_dReviewImageScale        = dScale;
 
    return TRUE;
}
 
BOOL CReviewProcessor::SetReviewImageInfo(int nWidth, int nHeight, int nSize, int nQuality, int nStep, double dScale, BOOL bOriginImg, int nImageRotate, int nImageFlip)
{
    if (nQuality>100 || nStep<1 || nStep>10) return FALSE;
 
    if (nImageRotate == 1 || nImageRotate == 3)
    {
        m_nReviewResizeWidth    = nHeight;
        m_nReviewResizeHeight    = nWidth;
    }
    else
    {
        m_nReviewResizeWidth    = nWidth;
        m_nReviewResizeHeight    = nHeight;
    }
    m_nReviewImageSize        = nSize; //byte
    m_nReviewImageQuality    = nQuality;
    m_nReviewImageStep        = nStep;
    m_dReviewImageScale        = dScale;
    
    m_bReviewOriginalImage    = bOriginImg;
    m_nImageRotate            = nImageRotate;
    m_nimageFlip            = nImageFlip;
 
    return TRUE;
}
 
void CReviewProcessor::SetUploadImagePath(const CString& strImagePath)
{    
    m_strSaveImageUploadPath = strImagePath;
}
 
void CReviewProcessor::SetReviewImagePath(const CString& strImagePath)
{
    m_strSaveImageReviewPath = strImagePath;
}
 
void CReviewProcessor::GetSaveImageBasePath( CString& strPath )
{
    strPath = m_strSaveImageBasePath; 
}
 
CString CReviewProcessor::GetUploadImagePath()
{
 return m_strSaveImageUploadPath; 
}
 
CString CReviewProcessor::GetReviewUploadImagePath()
{
    return m_strSaveImageReviewPath;
}
 
void CReviewProcessor::SetRTMSUploadImagePath(const CString& strImagePath)
{
    m_strRTMSImagePath = strImagePath;
}
 
CString CReviewProcessor::GetRTMSUploadImagePath()
{
    return m_strRTMSImagePath;
}
 
void CReviewProcessor::SetDefectFindInfo(const CRsRcpDefectFindInfo* pDefectFindInfo)
{
    if (pDefectFindInfo==NULL) return;
 
    m_bDefectFindProcess                    = pDefectFindInfo->m_bDefectFind;
 
    m_ReviewDefectFindParam.nDirection        = pDefectFindInfo->m_nDirection;
    m_ReviewDefectFindParam.dPitchX            = pDefectFindInfo->m_nDFPitchX;
    m_ReviewDefectFindParam.dPitchY            = pDefectFindInfo->m_nDFPitchY;
    m_ReviewDefectFindParam.nAutoPitchRange = pDefectFindInfo->m_nDFAutoPitchRange;
    m_ReviewDefectFindParam.nThreshold        = pDefectFindInfo->m_nDFThreshold;
}
 
UINT64 CReviewProcessor::SaveReviewImage(CCHImageData* pImageData, const CString& strFilename, UINT64 nMaxSize, int nQuality, int nStep)
{
    if (pImageData==NULL) return 0;
 
    UINT64 nSize = 0;
    BOOL bFind = FALSE;
    CFileFind finder;
    do 
    {
        if (pImageData->SaveImage(strFilename, nQuality)==FALSE) 
        {
            
            return 0;
        }
 
        bFind = finder.FindFile(strFilename);
        if (bFind==FALSE) return 0;
 
        bFind = finder.FindNextFile();
 
        nSize = finder.GetLength();
 
        nQuality -= nStep;
 
        if (nQuality<1 || nQuality>100) 
        {
            return 0;
        }
    } while (nSize > nMaxSize);
 
    return nSize;
}
 
BOOL CReviewProcessor::SaveReviewImage(CCHImageData* pImageData, const CString& strFilename)
{
    if (pImageData==NULL) return 0;
 
    BOOL bFind = FALSE;
    CFileFind finder;
    if (pImageData->SaveImage(strFilename)==FALSE)     {    return 0;    }
 
    bFind = finder.FindFile(strFilename);
    
    return bFind;
}
 
void CReviewProcessor::DrawText(CDC *pDC, int nStartX, int nStartY, const VectorPoint& vectorPoint, const VectorString& vectorString)
{
    if (pDC==NULL) return;
 
    pDC->SelectStockObject(WHITE_PEN);
 
    CFont font;
    VERIFY(font.CreateFont(
        17,                        // nHeight
        9,                         // nWidth
        0,                         // nEscapement
        0,                         // nOrientation
        FW_NORMAL,                 // nWeight
        FALSE,                     // bItalic
        FALSE,                     // bUnderline
        0,                         // cStrikeOut
        ANSI_CHARSET,              // nCharSet
        OUT_DEFAULT_PRECIS,        // nOutPrecision
        CLIP_DEFAULT_PRECIS,       // nClipPrecision
        DEFAULT_QUALITY,           // nQuality
        DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
        _T("Arial")));                 // lpszFacename
 
    // Do something with the font just created...
    CFont* def_font = pDC->SelectObject(&font);
    //     pDC->SetTextColor(RGB(255,255,255));
    //     pDC->SetBkMode(TRANSPARENT);
    pDC->SetTextColor(RGB(255,255,0));
    pDC->SetBkColor(RGB(0, 0, 0));
    pDC->SetBkMode(OPAQUE);
 
    // text out
    for (int i=0; i<(int)vectorPoint.size(); i++)
    {
        pDC->TextOut(vectorPoint[i].x + nStartX, vectorPoint[i].y + nStartY, vectorString[i]);
    }
}
 
void CReviewProcessor::DrawRuler(CDC *pDC, int nWidth, int nHeight, double dResolution, double dRulerGab)
{
    if (pDC==NULL || dRulerGab==0.0 || dResolution==0.0) return;
    if (nWidth==0 || nHeight==0) return;
 
    pDC->SelectStockObject(WHITE_PEN);
 
    CFont font;
    VERIFY(font.CreateFont(
        10,                        // nHeight
        5,                         // nWidth
        0,                         // nEscapement
        0,                         // nOrientation
        FW_NORMAL,                 // nWeight
        FALSE,                     // bItalic
        FALSE,                     // bUnderline
        0,                         // cStrikeOut
        ANSI_CHARSET,              // nCharSet
        OUT_DEFAULT_PRECIS,        // nOutPrecision
        CLIP_DEFAULT_PRECIS,       // nClipPrecision
        DEFAULT_QUALITY,           // nQuality
        DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
        _T("Arial")));                 // lpszFacename
 
    // Do something with the font just created...
    CFont* def_font = pDC->SelectObject(&font);
    pDC->SetTextColor(RGB(255,255,255));
    pDC->SetBkMode(TRANSPARENT);
 
    // ruler 
    double dResX = dResolution;
    double dResY = dResolution;
    double dGabX = dRulerGab / dResX; // um
    double dGabY = dRulerGab / dResY; // um
 
    if (dGabX<=0.0 || dGabY<=0.0) return;
 
    double dWidth = nWidth;
    double dHeight = nHeight;
    double dCenterX = dWidth/2.0;
    double dCenterY = dHeight/2.0;
 
    // x direction
    CString strValue = _T("");
    strValue.Format(_T("%.1lf um"), dRulerGab);
    pDC->TextOut(5, nHeight/2+5, strValue);
    for (double dPos=dCenterX; dPos>=0.0; dPos-=dGabX)
    {
        pDC->MoveTo((int)(dPos+0.5), 0);
        pDC->LineTo((int)(dPos+0.5), 6);
    }
    for (double dPos=dCenterX+dGabX; dPos<dWidth; dPos+=dGabX)
    {
        pDC->MoveTo((int)(dPos+0.5), 0);
        pDC->LineTo((int)(dPos+0.5), 6);
    }
 
    // y direction
    strValue.Format(_T("%.1lf um"), dRulerGab);
    pDC->TextOut(nWidth/2+5, 5, strValue);
    for (double dPos=dCenterY; dPos>0.0; dPos-=dGabY)
    {
        pDC->MoveTo(0, (int)(dPos+0.5));
        pDC->LineTo(6, (int)(dPos+0.5));
    }
    for (double dPos=dCenterY+dGabY; dPos<dHeight; dPos+=dGabY)
    {
        pDC->MoveTo(0, (int)(dPos+0.5));
        pDC->LineTo(6, (int)(dPos+0.5));
    }
}
 
void CReviewProcessor::DrawDefectPosCursor(CDC* pDC, int nDefectPosX, int nDefectPosY)
{
    if (pDC==NULL) return;
 
    POINT ptTemp;
    CPen pen, *pOldPen;
    pen.CreatePen(PS_SOLID, 2, RGB(0,255,0));
    pOldPen = (CPen*) pDC->SelectObject(&pen);
 
    ptTemp.x = nDefectPosX;
    ptTemp.y = nDefectPosY;
    pDC->MoveTo(ptTemp.x, ptTemp.y);
    ptTemp.x = ptTemp.x + 14;
    pDC->LineTo(ptTemp.x, ptTemp.y);
 
    pDC->MoveTo(ptTemp.x, ptTemp.y);
    ptTemp.x = ptTemp.x - 4;
    ptTemp.y = ptTemp.y - 4;
    pDC->LineTo(ptTemp.x, ptTemp.y);
 
    pDC->MoveTo(ptTemp.x, ptTemp.y);
    ptTemp.x = ptTemp.x + 10;
    ptTemp.y = ptTemp.y - 10;
    pDC->LineTo(ptTemp.x, ptTemp.y);
 
    pDC->MoveTo(ptTemp.x, ptTemp.y);
    ptTemp.x = ptTemp.x - 6;
    ptTemp.y = ptTemp.y - 6;
    pDC->LineTo(ptTemp.x, ptTemp.y);
 
    pDC->MoveTo(ptTemp.x, ptTemp.y);
    ptTemp.x = ptTemp.x - 10;
    ptTemp.y = ptTemp.y + 10;
    pDC->LineTo(ptTemp.x, ptTemp.y);
 
    pDC->MoveTo(ptTemp.x, ptTemp.y);
    ptTemp.x = ptTemp.x - 4;
    ptTemp.y = ptTemp.y - 4;
    pDC->LineTo(ptTemp.x, ptTemp.y);
 
    pDC->MoveTo(ptTemp.x, ptTemp.y);
    ptTemp.y = ptTemp.y + 14;
    pDC->LineTo(ptTemp.x, ptTemp.y);
 
    pDC->SelectObject(pOldPen);
}
 
void CReviewProcessor::DrawDefectRect(CDC* pDC, const CRect& rtRect)
{
    if (pDC==NULL) return;
 
    CPen pen, *pOldPen;
    pen.CreatePen(PS_SOLID, 2, RGB(0,255,0));
    pOldPen = (CPen*) pDC->SelectObject(&pen);
    pDC->SelectStockObject(NULL_BRUSH);
 
    pDC->Rectangle(rtRect);
 
/*    ptTemp.x = nDefectPosX;
    ptTemp.y = nDefectPosY;
    pDC->MoveTo(ptTemp.x, ptTemp.y);
    ptTemp.x = ptTemp.x + 14;
    pDC->LineTo(ptTemp.x, ptTemp.y);
 
    pDC->MoveTo(ptTemp.x, ptTemp.y);
    ptTemp.x = ptTemp.x - 4;
    ptTemp.y = ptTemp.y - 4;
    pDC->LineTo(ptTemp.x, ptTemp.y);
 
    pDC->MoveTo(ptTemp.x, ptTemp.y);
    ptTemp.x = ptTemp.x + 10;
    ptTemp.y = ptTemp.y - 10;
    pDC->LineTo(ptTemp.x, ptTemp.y);
 
    pDC->MoveTo(ptTemp.x, ptTemp.y);
    ptTemp.x = ptTemp.x - 6;
    ptTemp.y = ptTemp.y - 6;
    pDC->LineTo(ptTemp.x, ptTemp.y);
 
    pDC->MoveTo(ptTemp.x, ptTemp.y);
    ptTemp.x = ptTemp.x - 10;
    ptTemp.y = ptTemp.y + 10;
    pDC->LineTo(ptTemp.x, ptTemp.y);
 
    pDC->MoveTo(ptTemp.x, ptTemp.y);
    ptTemp.x = ptTemp.x - 4;
    ptTemp.y = ptTemp.y - 4;
    pDC->LineTo(ptTemp.x, ptTemp.y);
 
    pDC->MoveTo(ptTemp.x, ptTemp.y);
    ptTemp.y = ptTemp.y + 14;
    pDC->LineTo(ptTemp.x, ptTemp.y);
    */
 
    pDC->SelectObject(pOldPen);
}
 
// PCControl Control command
BOOL CReviewProcessor::Signal_SendSignal(int nSignalIndex)
{
    CSignalControl *pSignalControl = m_pRP2P->IRP2P_GetSignalControl();
 
    if (pSignalControl==NULL) return FALSE;
 
    int nAddrIdx = 0;
    if (pSignalControl->Write_SendSignal(nAddrIdx, nSignalIndex, 1, 2000))
    {
        m_pRP2P->IRP2P_DisplayMessage(_T("[PCControl_Send] Send Fail! "));
        return FALSE;
    }
 
    return TRUE;
}
 
// Review Camera Control Command
void CReviewProcessor::ReviewCamera_CameraControl(int nControlCmd)
{
    int nModuleCount = Module_GetModuleStatusCount();
 
    for (int nModuleIdx=0; nModuleIdx<nModuleCount; nModuleIdx++)
    {
        SCameraControl *pCameraControl = Module_GetCameraControl(nModuleIdx);
        CCameraControlReview *pReviewCameraControl = ReviewCamera_GetReviewCameraControl(nModuleIdx);
 
        if  (pCameraControl==NULL || pReviewCameraControl==NULL) continue;
 
        if (pCameraControl->nCameraControl != nControlCmd)
        {
            pReviewCameraControl->Camera_Control(nControlCmd);
 
            pCameraControl->nCameraControl = nControlCmd;
 
            m_pRP2P->IRP2P_UpdateCameraControl(nModuleIdx, pCameraControl, NULL);
        }
    }
}
 
BOOL CReviewProcessor::ReviewCamera_CameraControl(int nModuleIndex, int nControlCmd)
{
    SCameraControl *pCameraControl = Module_GetCameraControl(nModuleIndex);
    CCameraControlReview *pReviewCameraControl = ReviewCamera_GetReviewCameraControl(nModuleIndex);
    if (pCameraControl==NULL || pReviewCameraControl==NULL)
    {
        return FALSE;
    }
 
    if (nControlCmd!=CameraControlStop)
    {
        pReviewCameraControl->Camera_Control(CameraControlStop);
    }
 
    if(pReviewCameraControl->Camera_Control(nControlCmd))
    {
        pCameraControl->nCameraControl = nControlCmd;
        m_pRP2P->IRP2P_UpdateCameraControl(nModuleIndex, pCameraControl, NULL);
        return TRUE;
    }
 
    return FALSE;
}
 
 
int    CReviewProcessor::ReviewCamera_GetReviewCameraControlCount() const
{
    return m_pRP2P->IRP2P_GetReviewCameraControlCount();
}
 
CCameraControlReview* CReviewProcessor::ReviewCamera_GetReviewCameraControl(int nModuleIndex)
{
    return m_pRP2P->IRP2P_GetReviewCameraControl(nModuleIndex);
}
 
// getter module status
int    CReviewProcessor::Module_GetModuleStatusCount(int nModuleType) const
{
    return m_pRP2P->IRP2P_GetModuleStatusCount(nModuleType);
}
 
CModuleStatus* CReviewProcessor::Module_GetModuleStatus(int nModuleIdx)
{
    return m_pRP2P->IRP2P_GetModuleStatus(nModuleIdx);
}
 
SCameraControl*    CReviewProcessor::Module_GetCameraControl(int nModuleIdx)
{
    CModuleStatus *pModuleStatus = Module_GetModuleStatus(nModuleIdx);
    if (pModuleStatus==NULL) return NULL;
    return pModuleStatus->GetCameraControl();
}
 
SMotorPosition*    CReviewProcessor::Module_GetMotorPosition(int nModuleIdx)
{
    CModuleStatus *pModuleStatus = Module_GetModuleStatus(nModuleIdx);
    if (pModuleStatus==NULL) return NULL;
    return pModuleStatus->GetMotorPosition();
}
 
SMotorStatus* CReviewProcessor::Module_GetMotorStatus(int nModuleIdx)
{
    CModuleStatus *pModuleStatus = Module_GetModuleStatus(nModuleIdx);
    if (pModuleStatus==NULL) return NULL;
    return pModuleStatus->GetMotorStatus();
}
 
SAxisIndex*    CReviewProcessor::Module_GetAxisIndex(int nModuleIdx)
{
    CModuleStatus *pModuleStatus = Module_GetModuleStatus(nModuleIdx);
    if (pModuleStatus==NULL) return NULL;
    return pModuleStatus->GetAxisIndex();
}
 
SCoordInfo*    CReviewProcessor::Module_GetCoordInfo(int nModuleIdx)
{
    CModuleStatus *pModuleStatus = Module_GetModuleStatus(nModuleIdx);
    if (pModuleStatus==NULL) return NULL;
    return pModuleStatus->GetCoordInfo();
}
 
SCameraInfo* CReviewProcessor::Module_GetCurrentCameraInfo(int nModuleIdx)
{
    CModuleStatus *pModuleStatus = Module_GetModuleStatus(nModuleIdx);
    if (pModuleStatus==NULL) return NULL;
    return pModuleStatus->GetCurrentCameraInfo();
}
 
SCameraInfo* CReviewProcessor::Module_GetCameraInfo(int nModuleIdx, int nZoomIdx)
{
    CModuleStatus *pModuleStatus = Module_GetModuleStatus(nModuleIdx);
    if (pModuleStatus==NULL) return NULL;
    return pModuleStatus->GetCameraInfo(nZoomIdx);
}
 
BOOL CReviewProcessor::WSI_SetWSIEnd()
{
    BOOL bReturn = TRUE;
    for (int i=0; i<Module_GetModuleStatusCount(); i++)
    {
        bReturn = bReturn & WSI_SetWSIEnd(i);
    }
    return bReturn;
}
 
BOOL CReviewProcessor::WSI_SetWSITimeOver()
{
    BOOL bReturn = TRUE;
    for (int i=0; i<Module_GetModuleStatusCount(); i++)
    {
        bReturn = bReturn & WSI_SetWSITimeOver(i);
    }
    return bReturn;
}
 
BOOL CReviewProcessor::WSI_SetWSIEnd(int nModuleIndex)
{
    if (nModuleIndex<0 || nModuleIndex>=Module_GetModuleStatusCount())
    {
        return FALSE;
    }
 
    CWsiControl *pWSIControl = m_pRP2P->IRP2P_GetWSIControl(nModuleIndex);
    if (pWSIControl==NULL) return FALSE;
 
    return pWSIControl->SetWsiEnd();
}
 
BOOL CReviewProcessor::WSI_SetWSITimeOver(int nModuleIndex)
{
    if (nModuleIndex<0 || nModuleIndex>=Module_GetModuleStatusCount())
    {
        return FALSE;
    }
 
    CWsiControl *pWSIControl = m_pRP2P->IRP2P_GetWSIControl(nModuleIndex);
    if (pWSIControl==NULL) return FALSE;
 
    return pWSIControl->SetWsiTimeOver();
}
 
void CReviewProcessor::SetCellData(CGlassResult* pGlassResult)
{
    m_vecCellId.clear();
    m_vecCellIndex.clear();
 
    int nVectorCellCount = pGlassResult->GetCellResultCount();
    VectorCellResult* pVectorCellResult = pGlassResult->GetVectorCellResult();
 
    for(int nVectorCellIdx = 0; nVectorCellIdx < nVectorCellCount; nVectorCellIdx++)
    {
        m_vecCellId.push_back(pVectorCellResult->at(nVectorCellIdx).strCellID);
        m_vecCellIndex.push_back(0);
    }
}
 
int    CReviewProcessor::GetCellIdIdx(const CString& strCellID)
{
    int nCellIDCount = (int)m_vecCellId.size();
 
    for(int nCellIDIdx = 0; nCellIDIdx < nCellIDCount; nCellIDIdx++)
    {
        if(!strCellID.Compare(m_vecCellId.at(nCellIDIdx)))
        {
            return nCellIDIdx;
        }
    }
    return -1;
}
 
void CReviewProcessor::DrawCenterLine( CDC *pDC, int nWidth, int nHeight )
{
 
    if (pDC==NULL) return;
    if (nWidth==0 || nHeight==0) return;
 
    CPen CenterPen(PS_SOLID, 2, RGB(255,255,255));
    pDC->SelectObject(&CenterPen);
 
    double dWidth = nWidth;
    double dHeight = nHeight;
    double dCenterX = dWidth/2.0;
    double dCenterY = dHeight/2.0;
 
    // horizontal line
    pDC->MoveTo(0, nHeight/2);
    pDC->LineTo(nWidth, nHeight/2);
 
    // vertical line
    pDC->MoveTo(nWidth/2, 0);
    pDC->LineTo(nWidth/2, nHeight);
}
 
void CReviewProcessor::DrawCenterRect( CDC *pDC, int nWidth, int nHeight, int nDrawWidth, int nDrawHeight, double dResolution )
{
    if (pDC==NULL) return;
    if (nWidth==0 || nHeight==0 || nDrawWidth==0 || nDrawHeight==0) return;
 
    CPen CenterPen(PS_SOLID, 3, RGB(255,0,0));
    pDC->SelectObject(&CenterPen);
 
    int nPixelWidth = int(nDrawWidth/dResolution);
    int nPixelHeight = int(nDrawHeight/dResolution);
    int nCenterPixelX = nWidth/2;
    int nCenterPixelY = nHeight/2;
 
    // top line
    pDC->MoveTo(nCenterPixelX-nPixelWidth/2, nCenterPixelY-nPixelHeight/2);
    pDC->LineTo(nCenterPixelX+nPixelWidth/2, nCenterPixelY-nPixelHeight/2);
 
    // left line
    pDC->MoveTo(nCenterPixelX-nPixelWidth/2, nCenterPixelY-nPixelHeight/2);
    pDC->LineTo(nCenterPixelX-nPixelWidth/2, nCenterPixelY+nPixelHeight/2);
 
    // right line
    pDC->MoveTo(nCenterPixelX+nPixelWidth/2, nCenterPixelY-nPixelHeight/2);
    pDC->LineTo(nCenterPixelX+nPixelWidth/2, nCenterPixelY+nPixelHeight/2);
 
    // bottom line
    pDC->MoveTo(nCenterPixelX-nPixelWidth/2, nCenterPixelY+nPixelHeight/2);
    pDC->LineTo(nCenterPixelX+nPixelWidth/2, nCenterPixelY+nPixelHeight/2);
}
 
void IReviewProcessor2Parent::IRP2P_UpdateWSISelfDiagnosisResult()
{
    
}