| | |
| | | #include "StdAfx.h" |
| | | #include "StdAfx.h" |
| | | #include "PostProcess.h" |
| | | #include "Config.h" |
| | | #include "FreeImage.h" |
| | |
| | | if (glass_id.IsEmpty() == TRUE) |
| | | glass_id.Format(_T("MANUAL_ID")); |
| | | |
| | | // 获取当前产品加载时间 |
| | | CTime tGlassLoading = m_pGlassData->GetLoadingTime(); |
| | | |
| | | CString measure_data; |
| | | CString chip_data; |
| | | CString defect_data; |
| | |
| | | m_pGlassData->GetSideData(DIMENSION_C)->m_nTopCornerHeight, |
| | | m_pGlassData->GetSideData(DIMENSION_C)->m_nBottomCornerWidth, |
| | | m_pGlassData->GetSideData(DIMENSION_C)->m_nBottomCornerHeight |
| | | ); |
| | | ); |
| | | measure_data.Append(_T("\r\n")); |
| | | |
| | | CString measure_file_path; |
| | | if (m_pHardware->m_bSaveResultByHour) { |
| | | // 按小时保存结果 |
| | | measure_file_path.Format(_T("%s\\%s_%02d_MeasureData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, tGlassLoading.GetHour()); |
| | | } |
| | | else { |
| | | // 不按小时保存结果 |
| | | measure_file_path.Format(_T("%s\\%s_MeasureData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay); |
| | | } |
| | | |
| | | // 获取当前时间 |
| | | std::time_t m_now = std::time(nullptr); |
| | | // 使用localtime_s代替localtime |
| | | std::tm m_nowTm; |
| | | localtime_s(&m_nowTm, &m_now); |
| | | if (m_nowTm.tm_hour < 4) |
| | | { |
| | | measure_file_path.Format(_T("%s\\%s_%02d_MeasureData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay,24); |
| | | } |
| | | else if(m_nowTm.tm_hour > 3 && m_nowTm.tm_hour < 9) |
| | | { |
| | | measure_file_path.Format(_T("%s\\%s_%02d_MeasureData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, 4); |
| | | } |
| | | else if (m_nowTm.tm_hour > 7 && m_nowTm.tm_hour < 13) |
| | | { |
| | | measure_file_path.Format(_T("%s\\%s_%02d_MeasureData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, 8); |
| | | } |
| | | else if (m_nowTm.tm_hour > 11 && m_nowTm.tm_hour < 17) |
| | | { |
| | | measure_file_path.Format(_T("%s\\%s_%02d_MeasureData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, 12); |
| | | } |
| | | else if (m_nowTm.tm_hour > 15 && m_nowTm.tm_hour < 21) |
| | | { |
| | | measure_file_path.Format(_T("%s\\%s_%02d_MeasureData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, 16); |
| | | } |
| | | else if (m_nowTm.tm_hour > 19) |
| | | { |
| | | measure_file_path.Format(_T("%s\\%s_%02d_MeasureData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, 20); |
| | | } |
| | | |
| | | |
| | | CheckDirectory(measure_file_path); |
| | | |
| | | CFile measure_module; |
| | |
| | | CString strDefectType = g_strDefectType[pDefect->m_DefectInfo.m_DefectLoc]; |
| | | if ((strDefectType.Compare(_T("Chip")) == 0 || strDefectType.Compare(_T("In_Chip")) == 0)) |
| | | { |
| | | // 获取当前时间 |
| | | // 获取当前时间 |
| | | std::time_t now = std::time(nullptr); |
| | | // 使用localtime_s代替localtime |
| | | // 使用localtime_s代替localtime |
| | | std::tm nowTm; |
| | | localtime_s(&nowTm, &now); |
| | | |
| | |
| | | #else |
| | | CPoint pos2I = m_pGlassData->TransformToGlobal((DimensionDir)pDefect->m_DefectInfo.m_nSideIdx, pDefect->m_DefectInfo.m_ptDefectPos_pxl); |
| | | #endif // HALCON_VISION_KEY |
| | | |
| | | |
| | | |
| | | |
| | | int nMinSize_X = m_pRecipe->m_SideParam[pDefect->m_DefectInfo.m_nSideIdx].m_InspectPrm[(int)pDefect->m_DefectInfo.m_DefectLoc].m_nMinSize_Filter_X_um; |
| | | int nMinSize_Y = m_pRecipe->m_SideParam[pDefect->m_DefectInfo.m_nSideIdx].m_InspectPrm[(int)pDefect->m_DefectInfo.m_DefectLoc].m_nMinSize_Filter_Y_um;; |
| | |
| | | |
| | | if ((strDefectType.Compare(_T("Chip")) == 0 || strDefectType.Compare(_T("In_Chip")) == 0)) |
| | | { |
| | | // 获取当前时间 |
| | | // 获取当前时间 |
| | | std::time_t now = std::time(nullptr); |
| | | // 使用localtime_s代替localtime |
| | | // 使用localtime_s代替localtime |
| | | std::tm nowTm; |
| | | localtime_s(&nowTm, &now); |
| | | |
| | |
| | | } |
| | | |
| | | CString Chip_file_path; |
| | | |
| | | localtime_s(&m_nowTm, &m_now); |
| | | if (m_nowTm.tm_hour < 4) |
| | | { |
| | | Chip_file_path.Format(_T("%s\\%s_%02d_ChipData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay,24); |
| | | if (m_pHardware->m_bSaveResultByHour) { |
| | | // 按小时保存结果 |
| | | Chip_file_path.Format(_T("%s\\%s_%02d_ChipData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, tGlassLoading.GetHour()); |
| | | } |
| | | else if (m_nowTm.tm_hour > 3 && m_nowTm.tm_hour < 9) |
| | | { |
| | | Chip_file_path.Format(_T("%s\\%s_%02d_ChipData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, 4); |
| | | } |
| | | else if (m_nowTm.tm_hour > 7 && m_nowTm.tm_hour < 13) |
| | | { |
| | | Chip_file_path.Format(_T("%s\\%s_%02d_ChipData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, 8); |
| | | } |
| | | else if (m_nowTm.tm_hour > 11 && m_nowTm.tm_hour < 17) |
| | | { |
| | | Chip_file_path.Format(_T("%s\\%s_%02d_ChipData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, 12); |
| | | } |
| | | else if (m_nowTm.tm_hour > 15 && m_nowTm.tm_hour < 21) |
| | | { |
| | | Chip_file_path.Format(_T("%s\\%s_%02d_ChipData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, 16); |
| | | } |
| | | else if (m_nowTm.tm_hour > 19) |
| | | { |
| | | Chip_file_path.Format(_T("%s\\%s_%02d_ChipData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, 20); |
| | | else { |
| | | // 不按小时保存结果 |
| | | Chip_file_path.Format(_T("%s\\%s_ChipData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay); |
| | | } |
| | | |
| | | CheckDirectory(Chip_file_path); |
| | |
| | | } |
| | | |
| | | CString Defect_file_path; |
| | | if (m_pHardware->m_bSaveResultByHour) { |
| | | // 按小时保存结果 |
| | | Defect_file_path.Format(_T("%s\\%s_%02d_DefectData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, tGlassLoading.GetHour()); |
| | | } |
| | | else { |
| | | // 不按小时保存结果 |
| | | Defect_file_path.Format(_T("%s\\%s_DefectData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay); |
| | | } |
| | | |
| | | |
| | | if (m_nowTm.tm_hour < 4) |
| | | { |
| | | Defect_file_path.Format(_T("%s\\%s_%02d_DefectData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, 24); |
| | | } |
| | | else if (m_nowTm.tm_hour > 3 && m_nowTm.tm_hour < 9) |
| | | { |
| | | Defect_file_path.Format(_T("%s\\%s_%02d_DefectData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, 4); |
| | | } |
| | | else if (m_nowTm.tm_hour > 7 && m_nowTm.tm_hour < 13) |
| | | { |
| | | Defect_file_path.Format(_T("%s\\%s_%02d_DefectData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, 8); |
| | | } |
| | | else if (m_nowTm.tm_hour > 11 && m_nowTm.tm_hour < 17) |
| | | { |
| | | Defect_file_path.Format(_T("%s\\%s_%02d_DefectData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, 12); |
| | | } |
| | | else if (m_nowTm.tm_hour > 15 && m_nowTm.tm_hour < 21) |
| | | { |
| | | Defect_file_path.Format(_T("%s\\%s_%02d_DefectData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, 16); |
| | | } |
| | | else if (m_nowTm.tm_hour > 19) |
| | | { |
| | | Defect_file_path.Format(_T("%s\\%s_%02d_DefectData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, 20); |
| | | } |
| | | CheckDirectory(Defect_file_path); |
| | | |
| | | CFile defect_module; |
| | |
| | | |
| | | BOOL CPostProcess::SaveDefectImage(LPBYTE pImage,CSize szImage,CRect rectDefect,CString strFile,DimensionDir emDir) |
| | | { |
| | | FIBITMAP *bitmap = NULL; |
| | | BYTE *pBitBuffer; |
| | | if (pImage == NULL || szImage.cx <= 0 || szImage.cy <= 0) { |
| | | g_pLog->DisplayMessage(_T("Invalid image data or size")); |
| | | return FALSE; |
| | | } |
| | | |
| | | bitmap = FreeImage_Allocate(szImage.cx, szImage.cy,8); |
| | | Lock(); |
| | | FIBITMAP* bitmap = FreeImage_Allocate(szImage.cx, szImage.cy, 8); |
| | | if (bitmap == NULL) { |
| | | g_pLog->DisplayMessage(_T("FreeImage_Allocate failed")); |
| | | Unlock(); |
| | | return FALSE; |
| | | } |
| | | |
| | | pBitBuffer = FreeImage_GetBits(bitmap); |
| | | if(pBitBuffer == NULL) |
| | | { |
| | | FreeImage_Unload(bitmap); |
| | | BYTE* pBitBuffer = FreeImage_GetBits(bitmap); |
| | | if(pBitBuffer == NULL) { |
| | | FreeImage_Unload(bitmap); |
| | | Unlock(); |
| | | return FALSE; |
| | | } |
| | | |
| | | CopyMemory(pBitBuffer,pImage,szImage.cx*szImage.cy); |
| | | CopyMemory(pBitBuffer, pImage, szImage.cx * szImage.cy); |
| | | |
| | | FIBITMAP *pBit24 = FreeImage_ConvertTo24Bits(bitmap); |
| | | if(pBit24 == NULL) |
| | | if (pBit24 == NULL) { |
| | | Unlock(); |
| | | return FALSE; |
| | | } |
| | | |
| | | char cFilePath[255]; |
| | | |
| | | #ifdef _UNICODE |
| | | int nSize = WideCharToMultiByte(CP_ACP, 0, strFile.GetBuffer(), -1, NULL, 0, NULL,NULL); |
| | | int nSize = WideCharToMultiByte(CP_ACP, 0, strFile.GetBuffer(), -1, NULL, 0, NULL,NULL); |
| | | WideCharToMultiByte(CP_ACP, 0, strFile.GetBuffer(), -1, cFilePath, nSize, NULL, NULL); |
| | | #else |
| | | sprintf_s(cFilePath,sizeof(char)*255,_T("%s"),(LPSTR)(LPCTSTR)strFile); |
| | | #endif |
| | | |
| | | FreeImage_FlipVertical(pBit24); |
| | | |
| | | FreeImage_Save(FIF_JPEG, pBit24, cFilePath,JPEG_RATE); |
| | | |
| | | FreeImage_Unload(bitmap); |
| | | FreeImage_Unload(pBit24); |
| | | |
| | | Unlock(); |
| | | |
| | | return TRUE; |
| | | } |
| | | |
| | | BOOL CPostProcess::SaveDefectImage2(LPBYTE pImage,CSize szImage,CRect rectDefect,CString strFile) |
| | | BOOL CPostProcess::SaveDefectImageModern(LPBYTE pImage,CSize szImage,CRect rectDefect,CString strFile) |
| | | { |
| | | IplImage *pImageTmp = cvCreateImage(cvSize(szImage.cx, szImage.cy), 8,1); |
| | | if (!pImage || szImage.cx <= 0 || szImage.cy <= 0) { |
| | | return FALSE; |
| | | } |
| | | |
| | | #if 0 |
| | | IplImage* pImageTmp = cvCreateImage(cvSize(szImage.cx, szImage.cy), 8, 1); |
| | | cvZero(pImageTmp); |
| | | |
| | | |
| | | // add point to the image |
| | | for (int i = 0; i<szImage.cy; i++) |
| | | { |
| | | for (int j = 0; j<szImage.cx; j++) |
| | | { |
| | | pImageTmp->imageData[i*pImageTmp->widthStep+j] = pImage[i*szImage.cx+j]; |
| | | for (int i = 0; i < szImage.cy; i++) { |
| | | for (int j = 0; j < szImage.cx; j++) { |
| | | pImageTmp->imageData[i * pImageTmp->widthStep + j] = pImage[i * szImage.cx + j]; |
| | | } |
| | | } |
| | | |
| | | IplImage *pColorImg = cvCreateImage(cvSize(szImage.cx, szImage.cy), 8, 3); |
| | | IplImage* pColorImg = cvCreateImage(cvSize(szImage.cx, szImage.cy), 8, 3); |
| | | cvZero(pColorImg); |
| | | |
| | | cvCvtColor(pImageTmp, pColorImg, CV_GRAY2BGR); |
| | | cvRectangle(pColorImg, CvPoint(rectDefect.left, rectDefect.top), CvPoint(rectDefect.left + rectDefect.Width(), rectDefect.top + rectDefect.Height()), cvScalar(0, 0, 255), 1); |
| | | |
| | | cvRectangle(pColorImg,CvPoint(rectDefect.left,rectDefect.top), CvPoint(rectDefect.left+rectDefect.Width(),rectDefect.top+rectDefect.Height()), cvScalar(0,0,255), 1); |
| | | |
| | | USES_CONVERSION; |
| | | USES_CONVERSION; |
| | | char str_filename[1024]; |
| | | sprintf_s(str_filename, "%s", W2A(strFile)); |
| | | cvSaveImage(str_filename, pColorImg); |
| | | |
| | | cvReleaseImage(&pColorImg); |
| | | cvReleaseImage(&pImageTmp); |
| | | #else |
| | | Lock(); |
| | | cv::Mat grayImg(szImage.cy, szImage.cx, CV_8UC1, pImage); |
| | | cv::Mat colorImg; |
| | | cv::cvtColor(grayImg, colorImg, cv::COLOR_GRAY2BGR); |
| | | |
| | | cv::rectangle( |
| | | colorImg, |
| | | cv::Rect(rectDefect.left, rectDefect.top, rectDefect.Width(), rectDefect.Height()), |
| | | cv::Scalar(0, 0, 255), |
| | | 1 |
| | | ); |
| | | |
| | | USES_CONVERSION; |
| | | std::string strFilename = W2A(strFile); |
| | | |
| | | if (!cv::imwrite(strFilename, colorImg)) { |
| | | Unlock(); |
| | | g_pLog->DisplayMessage(_T("Failed to save image to %s"), strFile); |
| | | return FALSE; |
| | | } |
| | | Unlock(); |
| | | #endif // 0 |
| | | |
| | | return TRUE; |
| | | } |
| | | |
| | | BOOL CPostProcess::SaveDefectImage_with_Title(CDefect* pDefect, CSize szImage,CRect rectDefect,CString strFile, CvScalar color) |
| | | { |
| | | Lock(); |
| | | if(pDefect == NULL || pDefect->m_Image == NULL) |
| | | if (pDefect == NULL || pDefect->m_Image == NULL) { |
| | | g_pLog->DisplayMessage(_T("Invalid defect data or image")); |
| | | return FALSE; |
| | | } |
| | | |
| | | // 标题文本 |
| | | if (szImage.cx <= 0 || szImage.cy <= 0) { |
| | | g_pLog->DisplayMessage(_T("Invalid image size: %d x %d"), szImage.cx, szImage.cy); |
| | | return FALSE; |
| | | } |
| | | |
| | | BOOL bSuccess = TRUE; |
| | | |
| | | Lock(); |
| | | // 标题文本 |
| | | CString strTitle; |
| | | int nSideIdx = (0 <= pDefect->m_DefectInfo.m_nSideIdx && pDefect->m_DefectInfo.m_nSideIdx < MAX_SIDE_COUNT) ? pDefect->m_DefectInfo.m_nSideIdx : MAX_SIDE_COUNT; |
| | | int nCategoryIdx = (0 <= pDefect->m_DefectInfo.m_DefectLoc && pDefect->m_DefectInfo.m_DefectLoc < DefectLoc_None) ? pDefect->m_DefectInfo.m_DefectLoc : DefectLoc_Unknown; |
| | | strTitle.Format(_T("SIDE[%s] CAT[%s] SIZE[%d,%d]"), g_SideName[nSideIdx], g_strDefectType[nCategoryIdx], (int)pDefect->m_dSizeX_um, (int)pDefect->m_dSizeY_um); |
| | | |
| | | DefectLocation eCategory = pDefect->m_DefectInfo.m_DefectLoc; |
| | | if (eCategory == DefectLoc_Notch_Dimension || eCategory == DefectLoc_Notch_Chamfer) { |
| | | strTitle.Format(_T("SIDE[%s] CAT[%s] SIZE[%d,%d] distance[%d,%d] "), g_SideName[nSideIdx], g_strDefectType[nCategoryIdx], (int)pDefect->m_dSizeX_um, (int)pDefect->m_dSizeY_um, (int)pDefect->m_dChamfer_um, (int)pDefect->m_dChamferOff_um); |
| | | } |
| | | else { |
| | | strTitle.Format(_T("SIDE[%s] CAT[%s] SIZE[%d,%d]"), g_SideName[nSideIdx], g_strDefectType[nCategoryIdx], (int)pDefect->m_dSizeX_um, (int)pDefect->m_dSizeY_um); |
| | | } |
| | | Unlock(); |
| | | |
| | | // 成功标志 |
| | | BOOL bSuccess = TRUE; |
| | | |
| | | try { |
| | | // 将 CDefect 的 m_Image 缓冲区复制到 cv::Mat |
| | | Lock(); |
| | | cv::Mat imgTmp(szImage.cy, szImage.cx, CV_8UC1, pDefect->m_Image); |
| | | |
| | | // 创建彩色图像 |
| | | cv::Mat colorImg(szImage.cy, szImage.cx, CV_8UC3); |
| | | cv::cvtColor(imgTmp, colorImg, cv::COLOR_GRAY2BGR); |
| | | |
| | | // 在图像上画矩形 |
| | | cv::rectangle(colorImg, cv::Point(rectDefect.left, rectDefect.top), |
| | | cv::Point(rectDefect.right, rectDefect.bottom), color, 1); |
| | | cv::rectangle(colorImg, cv::Point(rectDefect.left, rectDefect.top), cv::Point(rectDefect.right, rectDefect.bottom), color, 1); |
| | | cv::rectangle(colorImg, cv::Point(0, szImage.cy - 40), cv::Point(szImage.cx, szImage.cy), cv::Scalar(0, 0, 0), cv::FILLED); |
| | | |
| | | // 添加标题 |
| | | cv::rectangle(colorImg, cv::Point(0, szImage.cy - 40), |
| | | cv::Point(szImage.cx, szImage.cy), cv::Scalar(0, 0, 0), cv::FILLED); |
| | | |
| | | // 设置字体 |
| | | int fontFace = cv::FONT_HERSHEY_TRIPLEX; |
| | | double fontScale = 0.7; |
| | | int thickness = 1; |
| | | |
| | | // 将标题文本放到图像上 |
| | | CT2CA pszConvertedAnsiTitle(strTitle); |
| | | cv::String strCVTitle(pszConvertedAnsiTitle); |
| | | cv::putText(colorImg, strCVTitle, cv::Point(10, szImage.cy - 10), |
| | | fontFace, fontScale, CV_RGB(255, 255, 255), thickness); |
| | | cv::putText(colorImg, strCVTitle, cv::Point(10, szImage.cy - 10), fontFace, fontScale, CV_RGB(255, 255, 255), thickness); |
| | | |
| | | // 将图像保存到文件 |
| | | CT2CA pszConvertedAnsiFile(strFile); |
| | | cv::String strStdFile(pszConvertedAnsiFile); |
| | | cv::imwrite(strStdFile, colorImg); |
| | | // cv::imwrite("D:\\Inspection\\Data\\IMG_DEFECT\\20250409\\Manual\\Manual_A_TOP_Chip_0.bmp", colorImg); |
| | | Unlock(); |
| | | } |
| | | catch (cv::Exception& e) { |
| | | // OpenCV异常处理 |
| | | bSuccess = FALSE; |
| | | Unlock(); |
| | | g_pLog->DisplayMessage(_T("OpenCV Exception: %s"), e.what()); |
| | | } |
| | | return bSuccess; |
| | | |
| | |
| | | // 3. Corner |
| | | |
| | | |
| | | // A 惑何 官蹿 |
| | | // A 惑何 官蹿 |
| | | vecStrTitle.push_back(_T("CORNER_1_X")); |
| | | strTemp.Format(_T("%d"), m_pGlassData->GetSideData(DIMENSION_A)->m_nBottomCornerWidth); |
| | | vecStrResultData.push_back(strTemp); |
| | |
| | | strTemp.Format(_T("%d"), m_pGlassData->GetSideData(DIMENSION_A)->m_nBottomCornerHeight); |
| | | vecStrResultData.push_back(strTemp); |
| | | |
| | | // C 惑何 官蹿 |
| | | // C 惑何 官蹿 |
| | | vecStrTitle.push_back(_T("CORNER_2_X")); |
| | | strTemp.Format(_T("%d"), m_pGlassData->GetSideData(DIMENSION_C)->m_nBottomCornerWidth); |
| | | vecStrResultData.push_back(strTemp); |
| | |
| | | strTemp.Format(_T("%d"), m_pGlassData->GetSideData(DIMENSION_C)->m_nBottomCornerHeight); |
| | | vecStrResultData.push_back(strTemp); |
| | | |
| | | // C 惑何 啪 |
| | | // C 惑何 啪 |
| | | vecStrTitle.push_back(_T("CORNER_3_X")); |
| | | strTemp.Format(_T("%d"), m_pGlassData->GetSideData(DIMENSION_C)->m_nTopCornerWidth); |
| | | vecStrResultData.push_back(strTemp); |
| | |
| | | strTemp.Format(_T("%d"), m_pGlassData->GetSideData(DIMENSION_C)->m_nTopCornerHeight); |
| | | vecStrResultData.push_back(strTemp); |
| | | |
| | | // A 惑何 啪 |
| | | // A 惑何 啪 |
| | | vecStrTitle.push_back(_T("CORNER_4_X")); |
| | | strTemp.Format(_T("%d"), m_pGlassData->GetSideData(DIMENSION_A)->m_nTopCornerWidth); |
| | | vecStrResultData.push_back(strTemp); |
| | |
| | | CSide_Data* pSideData_UP = NULL; |
| | | CSide_Data* pSideData_DN = NULL; |
| | | |
| | | // Notch乐绰 搁 茫扁 |
| | | // Notch乐绰 搁 茫扁 |
| | | for(int nSideIdx=0; nSideIdx<MAX_PANEL_SIDE; nSideIdx++) |
| | | { |
| | | pSideData_UP = m_pGlassData->GetSideData(arryWriteOrder_UP[nSideIdx]); |
| | |
| | | |
| | | for(int nNotchIdx=0; nNotchIdx<MAX_SIDE_NOTCH_COUNT; nNotchIdx++) |
| | | { |
| | | // 4-2. Dimension, 酒阀搁栏肺 螟沥 |
| | | // 4-2. Dimension, 酒阀搁栏肺 螟沥 |
| | | for(int nMeasureIdx = 0; nMeasureIdx < MAX_SIDE_NOTCH_MEASURE_COUNT; nMeasureIdx++) |
| | | { |
| | | strTemp.Format(_T("NOTCH_%d_DIM_%d"), nNotchIdx+1, nMeasureIdx+1); |
| | |
| | | |
| | | // Save Path |
| | | CString strFilePath; |
| | | // 获取当前时间 |
| | | std::time_t m_now = std::time(nullptr); |
| | | // 使用localtime_s代替localtime |
| | | std::tm m_nowTm; |
| | | localtime_s(&m_nowTm, &m_now); |
| | | if (m_nowTm.tm_hour < 4) |
| | | { |
| | | |
| | | strFilePath.Format(_T("D:\\Data\\%s\\%s\\%d\\%02d\\%02d\\%s_%s_%02d.csv"), m_pHardware->GetMachineName(), m_pHardware->GetLineID() |
| | | , tLoadingTime.GetYear(), tLoadingTime.GetMonth(), tLoadingTime.GetDay() |
| | | , m_pGlassData->GetGlassRecipe()->GetRecipeName(), tLoadingTime.Format(_T("%Y%m%d")),24 ); |
| | | if (m_pHardware->m_bSaveResultByHour) { |
| | | // 按小时保存,绑定玻璃 Loading Time |
| | | strFilePath.Format(_T("D:\\Data\\%s\\%s\\%d\\%02d\\%02d\\%s_%s_%02d.csv"), |
| | | m_pHardware->GetMachineName(), |
| | | m_pHardware->GetLineID(), |
| | | tLoadingTime.GetYear(), |
| | | tLoadingTime.GetMonth(), |
| | | tLoadingTime.GetDay(), |
| | | g_pBase->m_strRecipeName, |
| | | g_pBase->m_strLoadingDay, |
| | | tLoadingTime.GetHour()); |
| | | } |
| | | else if (m_nowTm.tm_hour > 3 && m_nowTm.tm_hour < 8) |
| | | { |
| | | strFilePath.Format(_T("D:\\Data\\%s\\%s\\%d\\%02d\\%02d\\%s_%s_%02d.csv"), m_pHardware->GetMachineName(), m_pHardware->GetLineID() |
| | | , tLoadingTime.GetYear(), tLoadingTime.GetMonth(), tLoadingTime.GetDay() |
| | | , m_pGlassData->GetGlassRecipe()->GetRecipeName(), tLoadingTime.Format(_T("%Y%m%d")), 4); |
| | | } |
| | | else if (m_nowTm.tm_hour > 7 && m_nowTm.tm_hour < 12) |
| | | { |
| | | strFilePath.Format(_T("D:\\Data\\%s\\%s\\%d\\%02d\\%02d\\%s_%s_%02d.csv"), m_pHardware->GetMachineName(), m_pHardware->GetLineID() |
| | | , tLoadingTime.GetYear(), tLoadingTime.GetMonth(), tLoadingTime.GetDay() |
| | | , m_pGlassData->GetGlassRecipe()->GetRecipeName(), tLoadingTime.Format(_T("%Y%m%d")), 8); |
| | | } |
| | | else if (m_nowTm.tm_hour > 11 && m_nowTm.tm_hour < 16) |
| | | { |
| | | strFilePath.Format(_T("D:\\Data\\%s\\%s\\%d\\%02d\\%02d\\%s_%s_%02d.csv"), m_pHardware->GetMachineName(), m_pHardware->GetLineID() |
| | | , tLoadingTime.GetYear(), tLoadingTime.GetMonth(), tLoadingTime.GetDay() |
| | | , m_pGlassData->GetGlassRecipe()->GetRecipeName(), tLoadingTime.Format(_T("%Y%m%d")), 12); |
| | | } |
| | | else if (m_nowTm.tm_hour > 15 && m_nowTm.tm_hour < 20) |
| | | { |
| | | strFilePath.Format(_T("D:\\Data\\%s\\%s\\%d\\%02d\\%02d\\%s_%s_%02d.csv"), m_pHardware->GetMachineName(), m_pHardware->GetLineID() |
| | | , tLoadingTime.GetYear(), tLoadingTime.GetMonth(), tLoadingTime.GetDay() |
| | | , m_pGlassData->GetGlassRecipe()->GetRecipeName(), tLoadingTime.Format(_T("%Y%m%d")), 16); |
| | | } |
| | | else if (m_nowTm.tm_hour > 19) |
| | | { |
| | | strFilePath.Format(_T("D:\\Data\\%s\\%s\\%d\\%02d\\%02d\\%s_%s_%02d.csv"), m_pHardware->GetMachineName(), m_pHardware->GetLineID() |
| | | , tLoadingTime.GetYear(), tLoadingTime.GetMonth(), tLoadingTime.GetDay() |
| | | , m_pGlassData->GetGlassRecipe()->GetRecipeName(), tLoadingTime.Format(_T("%Y%m%d")), 20); |
| | | else { |
| | | // 按天保存,绑定玻璃 Loading Time |
| | | strFilePath.Format(_T("D:\\Data\\%s\\%s\\%d\\%02d\\%02d\\%s_%s.csv"), |
| | | m_pHardware->GetMachineName(), |
| | | m_pHardware->GetLineID(), |
| | | tLoadingTime.GetYear(), |
| | | tLoadingTime.GetMonth(), |
| | | tLoadingTime.GetDay(), |
| | | g_pBase->m_strRecipeName, |
| | | g_pBase->m_strLoadingDay); |
| | | } |
| | | |
| | | CheckDirectory(strFilePath); |
| | |
| | | |
| | | /* |
| | | pDefect->m_nUMOriginX = (int)((double) (pDefect->m_DefectInfo.m_ptDefectPos_pxl.y - nStartLine) * dScanRes); |
| | | pDefect->m_nUMOriginY = (int)((double) (pDefect->m_DefectInfo.m_ptDefectPos_pxl.x * dConvRes)); // 荐沥 鞘夸.. |
| | | pDefect->m_nUMOriginY = (int)((double) (pDefect->m_DefectInfo.m_ptDefectPos_pxl.x * dConvRes)); // 荐沥 鞘夸.. |
| | | */ |
| | | |
| | | CSIDE_PARM* pSideParam = &pRecipe->m_SideParam[pDefect->m_DefectInfo.m_nSideIdx]; |
| | |
| | | TCHAR szTemp[MAX_PATH]; |
| | | |
| | | wcscpy_s(szTemp, MAX_PATH, strFolder); |
| | | szTemp[strFolder.GetLength() + 1] = NULL; // NULL巩磊啊 滴俺 甸绢啊具 茄促. |
| | | szTemp[strFolder.GetLength() + 1] = NULL; // NULL巩磊啊 滴俺 甸绢啊具 茄促. |
| | | |
| | | FileOp.hwnd = NULL; |
| | | FileOp.wFunc = FO_DELETE; |
| | | FileOp.pFrom = NULL; |
| | | FileOp.pTo = NULL; |
| | | FileOp.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI; // 犬牢皋矫瘤啊 救哆档废 汲沥 |
| | | FileOp.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI; // 犬牢皋矫瘤啊 救哆档废 汲沥 |
| | | FileOp.fAnyOperationsAborted = false; |
| | | FileOp.hNameMappings = NULL; |
| | | FileOp.lpszProgressTitle = NULL; |