You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
3.2 KiB

/*
* @Author: xiewenji 527774126@qq.com
* @Date: 2025-09-13 19:26:19
* @LastEditors: xiewenji 527774126@qq.com
* @LastEditTime: 2025-09-17 18:10:38
* @FilePath: /BOE_CELL_AOI_Detect/AlgorithmModule/src/Product.cpp
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*
*/
#include "Product.h"
#include "QX_Merge_Analysis.h"
Product::Product(/* args */)
{
productBaseResult = std::make_shared<ProductBaseResult>();
productBaseResult->detlog = std::make_shared<DetLog>();
productBaseResult->pQX_Merge_Analysis = QX_Merge_Analysis::GetInstance();
productBaseResult->pQX_Merge_Analysis->InitData();
productBaseResult->detlog->AddCheckstr(PrintLevel_0, "PushInImg", "Product create %s productBaseResult ", CheckUtil::getCurTimeHMS().c_str());
}
Product::~Product()
{
}
std::shared_ptr<CameraResult> Product::GetCameraResult(std::string strcameraName)
{
// 加锁保证多线程安全
std::lock_guard<std::mutex> lock(mtx_CameraResultList);
for (auto &ptr : m_pCameraResultList)
{
if (ptr->cameraBaseResult->strCameraName == strcameraName)
{
return ptr;
}
}
productBaseResult->detlog->bPrintStr = true;
// 不存在,创建新的 CameraResult 并插入 map
std::shared_ptr<CameraResult> newResult = std::make_shared<CameraResult>();
newResult->productBaseResult = productBaseResult;
newResult->cameraBaseResult->strCameraName = strcameraName;
m_pCameraResultList.push_back(newResult);
productBaseResult->detlog->AddCheckstr(PrintLevel_0, "PushInImg", "11111 Camera %s %s", strcameraName.c_str(), CheckUtil::getCurTimeHMS().c_str());
productBaseResult->pQX_Merge_Analysis->AddCamer(strcameraName);
productBaseResult->detlog->AddCheckstr(PrintLevel_0, "PushInImg", "22222 Camera %s %s", strcameraName.c_str(), CheckUtil::getCurTimeHMS().c_str());
productBaseResult->nCamera_Num = m_pCameraResultList.size();
productBaseResult->detlog->AddCheckstr(PrintLevel_0, "PushInImg", "add new Camera %s %s", strcameraName.c_str(), CheckUtil::getCurTimeHMS().c_str());
return newResult;
}
void Product::AddLog(std::string str)
{
LogList.push_back(str);
}
void Product::UpdatePushStatus(int status)
{
if (IN_IMG_Status_End == status ||
IN_IMG_Status_OneImg == status ||
-1 == status)
{
bIsImgComplete = true;
std::lock_guard<std::mutex> lock(mtx_CameraResultList); // 加锁保护 map
for (auto &ptr : m_pCameraResultList)
{
// printf("===========1112\n");
ptr->setImgPushComplate();
}
std::string strTimg = CheckUtil::getCurTimeHMS();
productBaseResult->detlog->AddCheckstr(PrintLevel_0, "PushInImg", "%s Add ALL img end %s m_pCameraResultList %ld ",
productBaseResult->strproductName.c_str(), strTimg.c_str(), m_pCameraResultList.size());
}
}
bool Product::bCheckCamplate()
{
// 所有的图都送完了。
if (bIsImgComplete)
{
bool ballcomplate = true;
std::lock_guard<std::mutex> lock(mtx_CameraResultList); // 加锁保护 map
for (auto &ptr : m_pCameraResultList)
{
if (!ptr->bCheckCamplate())
{
ballcomplate = false;
break;
}
}
if (ballcomplate)
{
return true;
}
}
return false;
}