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.

99 lines
2.8 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"
Product::Product(/* args */)
{
productBaseResult = std::make_shared<ProductBaseResult>();
productBaseResult->detlog = std::make_shared<DetLog>();
}
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;
}
}
// 不存在,创建新的 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", "add new Camera %s ", strcameraName.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)
{
ptr->setImgPushComplate();
}
std::string strTimg = CheckUtil::getCurTimeHMS();
strEndTime = strTimg;
time_pushImg_end = CheckUtil::getcurTime();
productBaseResult->detlog->AddCheckstr(PrintLevel_0, "PushInImg", "%s Add ALL img end %s ", productBaseResult->strproductName.c_str(), strTimg.c_str());
}
}
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;
}
void Product::SetCheckEnd() {
time_CheckImg_end = CheckUtil::getcurTime();
product_UseAllTime = time_CheckImg_end - time_pushImg_end;
std::string strTimg = CheckUtil::getCurTimeHMS();
productBaseResult->detlog->AddCheckstr(PrintLevel_0, "Product", "Product Usetime %ld ms,start %s end %s",\
product_UseAllTime, strEndTime.c_str(), strTimg.c_str());
}