升级到c++11,在存图文件夹不存在时自动创建,修复大量以byte为变量名的问题
This commit is contained in:
@@ -153,7 +153,7 @@ bool Logic_taskthread::processTask()
|
||||
//汇总:保存路径,拍照面描述,触发信号_序号列表0,,SN_时间戳
|
||||
//m_data.byte
|
||||
//std::cout << "camera_name_index[0]::" << camera_name_index[0].toStdString() << std::endl;
|
||||
AlgorithmModuleProcessData(m_module.module_key, camera_name_index, m_data.dstImageMat, m_data.byte);
|
||||
AlgorithmModuleProcessData(m_module.module_key, camera_name_index, m_data.dstImageMat, m_data.byteArray);
|
||||
m_ptr->deleteDetectData();
|
||||
/*stop = clock();
|
||||
qDebug() << "m_module.module_key::" << m_module.module_key << " Logic_taskthread cut Time ::" << stop - start ;
|
||||
@@ -322,14 +322,14 @@ bool Logic_taskthread::sendDataToModule(QVector<QString> camera_name_index, std:
|
||||
return true;
|
||||
}
|
||||
|
||||
QString Logic_taskthread::getSnDataInfo ( QByteArray byte )
|
||||
QString Logic_taskthread::getSnDataInfo ( QByteArray byteArray )
|
||||
{
|
||||
if ( byte.isEmpty() )
|
||||
if ( byteArray.isEmpty() )
|
||||
return nullptr;
|
||||
else
|
||||
{
|
||||
QByteArrayList vec_ret;
|
||||
if ( decodeAiValue( byte, vec_ret ) )
|
||||
if ( decodeAiValue( byteArray, vec_ret ) )
|
||||
{
|
||||
if ( !vec_ret.isEmpty() )
|
||||
{
|
||||
@@ -342,7 +342,7 @@ QString Logic_taskthread::getSnDataInfo ( QByteArray byte )
|
||||
|
||||
|
||||
//添加数据到最前面
|
||||
bool Logic_taskthread::encodeAppendData(QVector<QString> append_value, QByteArray &byte)
|
||||
bool Logic_taskthread::encodeAppendData(QVector<QString> append_value, QByteArray &byteArray)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -370,13 +370,13 @@ bool Logic_taskthread::encodeAppendData(QVector<QString> append_value, QByteArra
|
||||
}
|
||||
resultByte = QByteArray::fromStdString(sendMsg);
|
||||
|
||||
if (byte.isEmpty())
|
||||
if (byteArray.isEmpty())
|
||||
{
|
||||
byte = resultByte;
|
||||
byteArray = resultByte;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte = resultByte.append(byte);
|
||||
byteArray = resultByte.append(byteArray);
|
||||
}
|
||||
}
|
||||
catch (QString ev)
|
||||
@@ -387,30 +387,30 @@ bool Logic_taskthread::encodeAppendData(QVector<QString> append_value, QByteArra
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Logic_taskthread::decodereciveValue(QByteArray byte, QVector<QByteArray>& vec_ret)
|
||||
bool Logic_taskthread::decodereciveValue(QByteArray byteArray, QVector<QByteArray>& vec_ret)
|
||||
{
|
||||
while (!byte.isEmpty())
|
||||
while (!byteArray.isEmpty())
|
||||
{
|
||||
int type = 0;
|
||||
QByteArray m_type = byte.mid(0, 4);
|
||||
QByteArray m_type = byteArray.mid(0, 4);
|
||||
memcpy((void*)&type, (void*)m_type.data(), 4);
|
||||
byte.remove(0, 4);
|
||||
byteArray.remove(0, 4);
|
||||
|
||||
int len = 0;
|
||||
QByteArray m_len = byte.mid(0, 4);
|
||||
QByteArray m_len = byteArray.mid(0, 4);
|
||||
memcpy((void*)&len, (void*)m_len.data(), 4);
|
||||
byte.remove(0, 4);
|
||||
byteArray.remove(0, 4);
|
||||
|
||||
QByteArray mm_data = byte.mid(0, len);
|
||||
QByteArray mm_data = byteArray.mid(0, len);
|
||||
vec_ret.append(mm_data);
|
||||
byte.remove(0, len);
|
||||
byteArray.remove(0, len);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//保存算法结果数据到容器
|
||||
bool Logic_taskthread::saveAlgorithmData(testData m_testdata, int index, QByteArray byte)
|
||||
bool Logic_taskthread::saveAlgorithmData(testData m_testdata, int index, QByteArray byteArray)
|
||||
{
|
||||
//for (int i = 0; i < m_testdata.cameraName.size(); i++)
|
||||
{
|
||||
@@ -418,7 +418,7 @@ bool Logic_taskthread::saveAlgorithmData(testData m_testdata, int index, QByteAr
|
||||
QString task_index = m_testdata.task_index[index];
|
||||
|
||||
Algorithm_Result_Data result_data;
|
||||
result_data.byte = byte;
|
||||
result_data.byteArray = byteArray;
|
||||
if (m_testdata.SN_dataTime.size())
|
||||
result_data.SN_dataTime = m_testdata.SN_dataTime[0]; //这里暂时只取了第一个SN;即一张图对应一个SN;一张图里有2个产品的情况,应该在回调函数放两次图
|
||||
|
||||
@@ -482,14 +482,14 @@ bool Logic_taskthread::sendCatchCommond(QVector<QString> camera_name_index)
|
||||
}
|
||||
|
||||
|
||||
bool Logic_taskthread::decodeAiValue(QByteArray byte, QByteArrayList &vec_ret)
|
||||
bool Logic_taskthread::decodeAiValue(QByteArray byteArray, QByteArrayList &vec_ret)
|
||||
{
|
||||
if(byte.isEmpty())
|
||||
if(byteArray.isEmpty())
|
||||
{
|
||||
qCritical() << __FUNCTION__ << "line:" << __LINE__ << " byte is null!";
|
||||
return false;
|
||||
}
|
||||
vec_ret = byte.split('#');
|
||||
vec_ret = byteArray.split('#');
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -566,7 +566,7 @@ bool Logic_taskthread::writeTcpData(QMap<QString,QString> key_value)
|
||||
|
||||
QByteArray Logic_taskthread::writeFormat(QString startPos, QVector<QString> vector_value)
|
||||
{
|
||||
QByteArray byte;
|
||||
QByteArray byteArray;
|
||||
QString write_format;
|
||||
|
||||
// 其他格式 按照 长度+数据写入 进行编码
|
||||
@@ -584,11 +584,11 @@ QByteArray Logic_taskthread::writeFormat(QString startPos, QVector<QString> vect
|
||||
write_format = startPos + "_" + sendData;
|
||||
else write_format = sendData;
|
||||
|
||||
byte = write_format.toLocal8Bit();
|
||||
return byte;
|
||||
byteArray = write_format.toLocal8Bit();
|
||||
return byteArray;
|
||||
}
|
||||
//保存结果图到容器并UI显示;发送结果数据给PLC
|
||||
bool Logic_taskthread::sendDataCommond( QString m_type, QVector<QString> camera_name_index, std::vector<cv::Mat> mat,QByteArray byte )
|
||||
bool Logic_taskthread::sendDataCommond( QString m_type, QVector<QString> camera_name_index, std::vector<cv::Mat> mat,QByteArray byteArray)
|
||||
{
|
||||
// 界面显示包
|
||||
QMutexLocker locker(m_image_lock);
|
||||
@@ -625,7 +625,7 @@ bool Logic_taskthread::sendDataCommond( QString m_type, QVector<QString> camera_
|
||||
}
|
||||
}
|
||||
|
||||
if (!byte.contains("null"))
|
||||
if (!byteArray.contains("null"))
|
||||
{
|
||||
foreach(QString send_usual_result, m_send_usual_result.vector_algorithm_usual_feedback_plcpos)
|
||||
{
|
||||
@@ -644,15 +644,15 @@ bool Logic_taskthread::sendDataCommond( QString m_type, QVector<QString> camera_
|
||||
if (save_data_flag == "true")
|
||||
{
|
||||
//保存算法结果数据到容器
|
||||
saveAlgorithmData(m_exec_testData, ci, byte);
|
||||
saveAlgorithmData(m_exec_testData, ci, byteArray);
|
||||
}
|
||||
|
||||
// 发送检测模块的结果到PLC
|
||||
if (send_data_flag == "true")
|
||||
{
|
||||
QString sbyte = byte;
|
||||
QString sbyte = byteArray;
|
||||
//发送数据给PLC
|
||||
if (!writeAiCommond(m_name, camera_name_index[ci], byte))
|
||||
if (!writeAiCommond(m_name, camera_name_index[ci], byteArray))
|
||||
{
|
||||
qCritical() << __FUNCTION__ << " line:" << __LINE__ << " ---- writeAiCommond is failed!"<<" byte,"<< sbyte;
|
||||
}
|
||||
@@ -663,7 +663,7 @@ bool Logic_taskthread::sendDataCommond( QString m_type, QVector<QString> camera_
|
||||
send_ng_info.clear();
|
||||
//汇总算法删除,检测算法不删。
|
||||
//获取第一组sn;//获取次数是sn容器长度的倍数时,删一个数据
|
||||
bool ifdeleSn = deleteSnData(byte, sndata, send_ng_info);
|
||||
bool ifdeleSn = deleteSnData(byteArray, sndata, send_ng_info);
|
||||
|
||||
//汇总算法
|
||||
// 传递给界面用来显示产品的sn码
|
||||
@@ -694,7 +694,7 @@ bool Logic_taskthread::sendDataCommond( QString m_type, QVector<QString> camera_
|
||||
// cv::resize(mat[ci], mat[ci], cv::Size(), 0.5, 0.5); //图像大时(内存、cpu占用大),耗时长。
|
||||
m_pack.mat = mat[ci].clone();
|
||||
}
|
||||
m_pack.byte = byte;
|
||||
m_pack.byteArray = byteArray;
|
||||
m_pack.retFlag = m_type;
|
||||
|
||||
if (!queue_exec_cameraName.isEmpty())
|
||||
@@ -752,7 +752,7 @@ bool Logic_taskthread::getdataPack(dataPack& myDataPack)
|
||||
else return false;
|
||||
}
|
||||
//汇总算法,删除SN,所有相机线程的snIndex减一
|
||||
bool Logic_taskthread::deleteSnData ( QByteArray byte, QVector<QString>& sndata,QString &send_ng_info)
|
||||
bool Logic_taskthread::deleteSnData ( QByteArray byteArray, QVector<QString>& sndata,QString &send_ng_info)
|
||||
{
|
||||
// 读取sn区域的位置下标;只在汇总算法有,检测算法无
|
||||
QString read_sn_area_index = m_sn_set_object.value("汇总-读哪个上料通道的SN").toString();
|
||||
@@ -808,9 +808,9 @@ bool Logic_taskthread::deleteSnData ( QByteArray byte, QVector<QString>& sndata,
|
||||
}
|
||||
|
||||
// 算法结果 写入plc
|
||||
bool Logic_taskthread::writeAiCommond ( QString cameraName,QString camera_name_index,QByteArray byte )
|
||||
bool Logic_taskthread::writeAiCommond ( QString cameraName,QString camera_name_index,QByteArray byteArray )
|
||||
{
|
||||
QByteArrayList PLCvec_ret= byte.split('*'); // 存储结果的
|
||||
QByteArrayList PLCvec_ret= byteArray.split('*'); // 存储结果的
|
||||
|
||||
if (PLCvec_ret.isEmpty() )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user