// 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); }