mrDarker
2025-07-16 1dbe46cd9d0f181d08d5a69f72d8548628a13b9d
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
// ViewMainStatus.cpp : 备泅 颇老涝聪促.
//
 
#include "stdafx.h"
#include "EdgeInspector_App.h"
#include "ViewMain_Status.h"
#include "afxdialogex.h"
 
 
// CViewMainStatus 措拳 惑磊涝聪促.
 
IMPLEMENT_DYNAMIC(CViewMain_Status, CDialogEx)
 
    CViewMain_Status::CViewMain_Status(CWnd* pParent /*=NULL*/)
    : CDialogEx(CViewMain_Status::IDD, pParent)
{
 
}
 
CViewMain_Status::~CViewMain_Status()
{
}
 
void CViewMain_Status::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
}
 
BEGIN_MESSAGE_MAP(CViewMain_Status, CDialogEx)
    ON_WM_TIMER()
END_MESSAGE_MAP()
 
 
// CViewMainStatus 皋矫瘤 贸府扁涝聪促.
 
BOOL CViewMain_Status::OnInitDialog(void)
{
    CDialogEx::OnInitDialog();
 
    UpdateVersionInfo();
 
    SetTimer(ID_TIMER_UPDATE, 500, NULL);
 
    return TRUE;
}
 
BOOL CViewMain_Status::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 CDialogEx::PreTranslateMessage(pMsg);
}
 
void CViewMain_Status::UpDateMachineName()
{
    CHardwareSettings* pHWSetting = g_pStatus->m_pHWSettings;
 
    if(pHWSetting != NULL)
    {
        CString strMachineName_Title;
 
        CString strMachineName = pHWSetting->GetMachineName();
        CString strLineID = pHWSetting->GetLineID();
 
        if(strMachineName.IsEmpty() || strMachineName.GetLength() == 0)
            strMachineName = _T("Edge Inspector");
 
        if(strLineID.IsEmpty() || strLineID.GetLength() == 0)
            strMachineName_Title = strMachineName;
        else
            strMachineName_Title.Format(_T("%s - #%s"), strMachineName, strLineID);
 
        CString strUI;
        GetDlgItemText(IDC_STATIC_MACHINE_NAME, strUI);
 
        if(strUI != strMachineName_Title)
            SetDlgItemText(IDC_STATIC_MACHINE_NAME, strMachineName_Title);
    }
}
 
void CViewMain_Status::UpDateCurrentRecipe()
{
    CTransfer_Data* pTransData    = g_pStatus->m_pTransData;
    if(pTransData != NULL)
    {
        CString strPLCRecipeNo;
        strPLCRecipeNo.Format(_T("%d"), pTransData->m_nRecipeNo);
 
        CString strUI;
        GetDlgItemText(IDC_STATIC_PLC_RECIPE, strUI);
 
        if(strUI != strPLCRecipeNo)
            SetDlgItemText(IDC_STATIC_PLC_RECIPE, strPLCRecipeNo);
    }
 
    CGlassRecipe* pRecipe = g_pStatus->m_pRecipe;
    if(pRecipe != NULL)
    {
        CString strCurrentRecipeName = pRecipe->m_RecieParm.m_strRecipeName;
 
        CString strOldRecipeName;
        GetDlgItemText(IDC_STATIC_RECIPE_NAME, strOldRecipeName);
 
        if (strOldRecipeName != strCurrentRecipeName)
        {
            SetDlgItemText(IDC_STATIC_RECIPE_NAME, strCurrentRecipeName);
 
#if HALCON_VISION_KEY
            USES_CONVERSION;
            BlVision_GetVisionRecipe()->setVisionName(T2A(strCurrentRecipeName));
            BlVision_GetVisionRecipe()->open();
 
            int nGlassSizeX = g_pStatus->m_pRecipe->m_SideParam[0].m_nSidePanelSize_um;
            int nGlassSizeY = g_pStatus->m_pRecipe->m_SideParam[1].m_nSidePanelSize_um;
            BlVision_GetVisionRecipe()->setGlassSize(nGlassSizeX, nGlassSizeY);
#endif // HALCON_VISION_KEY
        }
    }
}
 
void CViewMain_Status::UpdateCurrentGlass()
{
    CTransfer_Data* pTransData    = g_pStatus->m_pTransData;
 
    if(pTransData != NULL)
    {
        CString strGlassID = pTransData->m_strHPANELID;
 
        CString strUI;
        GetDlgItemText(IDC_STATIC_GLASS_ID, strUI);
 
        if(strUI != strGlassID)
            SetDlgItemText(IDC_STATIC_GLASS_ID, strGlassID);
 
        CString strGrindingdata;
        strGrindingdata.Format(_T("Unit NO:%d"), pTransData->m_nUnitNo);
        SetDlgItemText(IDC_STATIC_PLC_UNITNO, strGrindingdata);
 
        strGrindingdata.Format(_T("Table NO:%d"), pTransData->m_nEqpNo);
        SetDlgItemText(IDC_STATIC_PLC_TABLENO, strGrindingdata);
 
        strGrindingdata.Format(_T("Slot NO:%d"), pTransData->m_nisGrind);
        SetDlgItemText(IDC_STATIC_PLC_SLOTNO, strGrindingdata);
 
        strGrindingdata.Format(_T("Panel Count:%d"), pTransData->m_nRoughPadLayer);
        SetDlgItemText(IDC_STATIC_PLC_PANELCOUNT, strGrindingdata);
    }
    
 
    CGlass_Data* pGlassData        = g_pStatus->m_pGlassData;
 
    if(pGlassData != NULL)
    {
        CString strJudge;
 
        if(pGlassData->GetInspectComplete() == FALSE)    
            strJudge = _T("OK / NG"); 
        else
            strJudge = (pGlassData->GetGlassJudge() == TRUE) ? _T("NG") : _T("OK"); 
 
        CString strUI;
        GetDlgItemText(IDC_STATIC_JUDGE, strUI);
 
        if(strUI != strJudge)
            SetDlgItemText(IDC_STATIC_JUDGE, strJudge);
    }
 
 
}
 
void CViewMain_Status::UpdateVersionInfo()
{
    TCHAR szFile[ MAX_PATH ] = { 0 };
    ::GetModuleFileName( NULL, szFile, MAX_PATH );
    HANDLE hFile = CreateFile (szFile ,GENERIC_READ    ,FILE_SHARE_READ,NULL,OPEN_EXISTING ,0    ,NULL) ; 
 
    if (hFile != INVALID_HANDLE_VALUE)       
    {    
        SYSTEMTIME st;
        FILETIME fileTime_Create;
        FILETIME fileTime_LastAccess;
        FILETIME fileTime_LastWrite;
 
        if (!GetFileTime(hFile, &fileTime_Create, &fileTime_LastAccess, &fileTime_LastWrite))
        {
            CloseHandle(hFile);
            return;
        }
 
        FILETIME fileTime_Local;
        FileTimeToLocalFileTime(&fileTime_LastWrite, &fileTime_Local);
        FileTimeToSystemTime(&fileTime_Local, &st);
 
        CString strValue = L"";
        strValue.Format(L"Ver : %04d / %02d / %02d \r\n(Build : %02d:%02d:%02d)", st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
 
        SetDlgItemText(IDC_STATIC_VER_INFO, strValue);
 
        CloseHandle(hFile);
    }
}
 
void CViewMain_Status::UpdateCurrentTime()
{
    if (IsWindowVisible() == FALSE)
        return;
 
    SYSTEMTIME st;
    GetLocalTime(&st);
 
    CString strValue = L"";
    strValue.Format(L"%02d/%02d/%02d (%s) %02d:%02d:%02d", st.wYear, st.wMonth, st.wDay, g_strDayOfWeek[st.wDayOfWeek], st.wHour, st.wMinute, st.wSecond);
    SetDlgItemText(IDC_STATIC_CURRENT_TIME, strValue);
}
 
void CViewMain_Status::OnTimer(UINT_PTR nIDEvent)
{
    switch(nIDEvent)
    {
    case ID_TIMER_UPDATE:
 
        UpDateMachineName();
 
        UpdateCurrentGlass();
 
        UpDateCurrentRecipe();
 
        UpdateCurrentTime();
        break;            
    }
 
    CDialogEx::OnTimer(nIDEvent);
}