LWQ
2025-07-14 52d230fd0eb38adc5c6f4c6d6ed3786a3c19354d
EdgeInspector_App/Data/PostProcess.cpp
@@ -180,6 +180,9 @@
   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;
@@ -241,42 +244,19 @@
      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;
@@ -434,31 +414,13 @@
   }
   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);
@@ -481,32 +443,15 @@
   }
   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;
@@ -642,14 +587,22 @@
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) {
      return FALSE;
   }
   // 标题文本
   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();
   // 成功标志
@@ -1052,47 +1005,28 @@
   // 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);