通讯支持算法处理多条信号同步发送

master
zhou.mengjia 2 years ago
parent 6ae5aba12f
commit fc64f8873d

File diff suppressed because it is too large Load Diff

@ -29,7 +29,7 @@
"rotation_angle": 0, "rotation_angle": 0,
"calib_file": ".\\config\\1.calib", "calib_file": ".\\config\\1.calib",
"save": 1, "save": 1,
"save_img_suffix": ".BMP", "save_img_suffix": ".PNG",
"savefile_rgb_swapped": false, "savefile_rgb_swapped": false,
"showname": "相机一", "showname": "相机一",
"trigger_source": "Line0", "trigger_source": "Line0",
@ -66,7 +66,7 @@
"rotation_angle": 0, "rotation_angle": 0,
"calib_file": ".\\config\\1.calib", "calib_file": ".\\config\\1.calib",
"save": 1, "save": 1,
"save_img_suffix": ".BMP", "save_img_suffix": ".PNG",
"savefile_rgb_swapped": false, "savefile_rgb_swapped": false,
"showname": "相机一", "showname": "相机一",
"trigger_source": "Line0", "trigger_source": "Line0",
@ -78,7 +78,7 @@
"id": 3, "id": 3,
"exposure": 10000, "exposure": 10000,
"location": 1, "location": 1,
"save_img_suffix": ".BMP", "save_img_suffix": ".PNG",
"height": 3072, "height": 3072,
"width": 2048, "width": 2048,
"type": 210 "type": 210
@ -88,7 +88,7 @@
"id": 4, "id": 4,
"exposure": 10000, "exposure": 10000,
"location": 2, "location": 2,
"save_img_suffix": ".BMP", "save_img_suffix": ".PNG",
"height": 3072, "height": 3072,
"width": 2048, "width": 2048,
"type": 210 "type": 210

Binary file not shown.

@ -7,12 +7,12 @@ HeightCalculate::HeightCalculate(QObject *parent)
HeightCalculate::~HeightCalculate() HeightCalculate::~HeightCalculate()
{} {}
void HeightCalculate::LoadBasicFile() void HeightCalculate::LoadBasicFile(QString path)
{ {
} }
void HeightCalculate::LoadPointCould() void HeightCalculate::LoadPointCould(QString path)
{ {
} }

@ -10,8 +10,8 @@ public:
HeightCalculate(QObject *parent = nullptr); HeightCalculate(QObject *parent = nullptr);
~HeightCalculate(); ~HeightCalculate();
void LoadBasicFile(); void LoadBasicFile(QString path);
void LoadPointCould(); void LoadPointCould(QString path);
int SmokeHeight(); int SmokeHeight();
}; };

@ -298,109 +298,135 @@ Q_SLOT void SmokeBoxIdentification::onDecodeMsg(const QString& msg)
msgContent.chop(1); msgContent.chop(1);
} }
qDebug() << "msg: " << msg << " content: " << msgContent; qDebug() << "msg: " << msg << " content: " << msgContent;
QStringList strList = msgContent.split(SPLIT_RULE);
qDebug() << "strlist length: " << strList.length() << " head: " << strList.at(0); switch (m_moduleParam.COMMRules)
if (strList[0] == EMPTY_CHECK_HEAD) {
case eCommunicationRules::emNJ:
{ {
if (strList.length() == 4) QStringList strList = msgContent.split(SPLIT_RULE);
qDebug() << "strlist length: " << strList.length() << " head: " << strList.at(0);
if (strList[0] == EMPTY_CHECK_HEAD)
{ {
EmptyCheckInfo emptyCheckInfo; if (strList.length() == 4)
emptyCheckInfo.streetName = strList[1];
emptyCheckInfo.taskNum = strList[2];
m_currtEmptyCheckInfo = emptyCheckInfo;
if (strList[3] == "START")
{
m_workMode = WorkMode::EmptyCheck;
emit sgStartEmptyPlaceCheck(m_currtEmptyCheckInfo.streetName);
}
else if (strList[3] == "END")
{ {
if (m_workMode == WorkMode::EmptyCheck) EmptyCheckInfo emptyCheckInfo;
emptyCheckInfo.streetName = strList[1];
emptyCheckInfo.taskNum = strList[2];
m_currtEmptyCheckInfo = emptyCheckInfo;
if (strList[3] == "START")
{ {
emit sgStopEmptyPlaceCheck(); m_workMode = WorkMode::EmptyCheck;
m_workMode = WorkMode::Idle; emit sgStartEmptyPlaceCheck(m_currtEmptyCheckInfo.streetName);
}
else if (strList[3] == "END")
{
if (m_workMode == WorkMode::EmptyCheck)
{
emit sgStopEmptyPlaceCheck();
m_workMode = WorkMode::Idle;
}
} }
} }
} }
} if (strList.at(0) == STOCK_CHECK_HEAD)
if (strList.at(0) == STOCK_CHECK_HEAD)
{
if (strList.length() == 7)
{ {
qDebug() << "开始货位盘点"; if (strList.length() == 7)
m_workMode = WorkMode::StockCheck; {
StockCheckInfo stockCheckInfo; qDebug() << "开始货位盘点";
stockCheckInfo.streetName = strList.at(1); m_workMode = WorkMode::StockCheck;
stockCheckInfo.stockNum = strList.at(2); StockCheckInfo stockCheckInfo;
stockCheckInfo.taskNum = strList.at(3); stockCheckInfo.streetName = strList.at(1);
stockCheckInfo.smokeTypeNum = strList.at(4); stockCheckInfo.stockNum = strList.at(2);
stockCheckInfo.smokeQuantity = strList.at(5); stockCheckInfo.taskNum = strList.at(3);
m_currtStockCheckInfo = stockCheckInfo; stockCheckInfo.smokeTypeNum = strList.at(4);
stockCheckInfo.smokeQuantity = strList.at(5);
m_currtStockCheckInfo = stockCheckInfo;
}
else if (strList.length() == 3)
{
qDebug() << "取货到位";
QString taskNum = strList.at(2);
QString currentTaskNum = m_currtStockCheckInfo.taskNum;
if (m_workMode == WorkMode::StockCheck)
{
captureSide(1);
captureTop(1);
}
}
} }
else if (strList.length() == 3) else if (strList.at(0) == INTO_STOCK_HEAD)
{ {
qDebug() << "取货到位"; if (strList.length() == 4)
QString taskNum = strList.at(2);
QString currentTaskNum = m_currtStockCheckInfo.taskNum;
if (m_workMode == WorkMode::StockCheck)
{ {
captureSide(1); qDebug() << "入库顶部拍照";
m_workMode = WorkMode::IntoStock;
IntoStockInfo intoStockInfo;
intoStockInfo.streetName = strList.at(1);
intoStockInfo.taskNum = strList.at(2);
intoStockInfo.stockNum = strList.at(3);
m_currtIntoStockInfo = intoStockInfo;
captureTop(1); captureTop(1);
} }
} }
} else if (strList.at(0) == LIGHT_CONTROL_HEAD)
else if (strList.at(0) == INTO_STOCK_HEAD)
{
if (strList.length() == 4)
{ {
qDebug() << "入库顶部拍照"; if (strList.length() == 3)
m_workMode = WorkMode::IntoStock; {
IntoStockInfo intoStockInfo; qDebug() << "开关灯";
intoStockInfo.streetName = strList.at(1); if (strList.at(2) == "0")
intoStockInfo.taskNum = strList.at(2); {
intoStockInfo.stockNum = strList.at(3); emit sgControlSideLight(lightCtrl::emTurnOffLight);
m_currtIntoStockInfo = intoStockInfo; }
captureTop(1); else if (strList.at(2) == "1")
{
emit sgControlSideLight(lightCtrl::emTurnOnLight);
}
}
} }
} }
else if (strList.at(0) == LIGHT_CONTROL_HEAD) break;
case eCommunicationRules::emSJZ:
{ {
if (strList.length() == 3) QStringList msgList = msgContent.split(END_SYMBOL);
for (int i = 0; i < msgList.length(); i++)
{ {
qDebug() << "开关灯"; QStringList strList = msgList[i].split(SPLIT_RULE);
if (strList.at(2) == "0") qDebug() << "strlist length: " << strList.length() << " head: " << strList.at(0);
if (strList.at(0) == START_CAPTURE && strList.length() == 7)
{ {
emit sgControlSideLight(lightCtrl::emTurnOffLight); qDebug() << "到位取图开始";
//m_workMode = WorkMode::Capture;
m_currtIntoStockInfo.streetName = strList.at(1);
m_currtIntoStockInfo.id = strList.at(2);
m_currtIntoStockInfo.taskNum = strList.at(3);
m_currtIntoStockInfo.stockLocation = strList.at(4);
m_currtIntoStockInfo.smokeTypeNum = strList.at(5);
m_currtIntoStockInfo.smokeQuantity = strList.at(6);
captureSide(m_currtIntoStockInfo.stockLocation.toInt());
} }
else if (strList.at(2) == "1") else if (strList.at(0) == START_CALCULATE && strList.length() == 7)
{ {
emit sgControlSideLight(lightCtrl::emTurnOnLight); qDebug() << "品规计数开始";
//m_workMode = WorkMode::StockCheck;
m_currtStockCheckInfo.streetName = strList.at(1);
m_currtStockCheckInfo.id = strList.at(2);
m_currtStockCheckInfo.taskNum = strList.at(3);
m_currtStockCheckInfo.stockLocation = strList.at(4);
m_currtStockCheckInfo.smokeTypeNum = strList.at(5);
m_currtStockCheckInfo.smokeQuantity = strList.at(6);
m_stocketList.insert(m_currtStockCheckInfo.id.toInt(), m_currtStockCheckInfo);
calculate(m_currtStockCheckInfo.id.toInt());
} }
} }
} }
else if (strList.at(0) == START_CAPTURE) break;
{ default:
qDebug() << "到位取图开始"; break;
//m_workMode = WorkMode::Capture;
m_currtIntoStockInfo.streetName = strList.at(1);
m_currtIntoStockInfo.id = strList.at(2);
m_currtIntoStockInfo.taskNum = strList.at(3);
m_currtIntoStockInfo.stockLocation = strList.at(4);
captureSide(m_currtIntoStockInfo.stockLocation.toInt());
}
else if (strList.at(0) == START_CALCULATE)
{
qDebug() << "品规计数开始";
//m_workMode = WorkMode::StockCheck;
m_currtStockCheckInfo.streetName = strList.at(1);
m_currtStockCheckInfo.id = strList.at(2);
m_currtStockCheckInfo.taskNum = strList.at(3);
m_currtStockCheckInfo.stockLocation = strList.at(4);
m_currtStockCheckInfo.smokeTypeNum = strList.at(5);
m_currtStockCheckInfo.smokeQuantity = strList.at(6);
m_stocketList.insert(m_currtStockCheckInfo.id.toInt(),m_currtStockCheckInfo);
calculate(m_currtStockCheckInfo.id.toInt());
} }
} }
void SmokeBoxIdentification::calculate(int stocketID) void SmokeBoxIdentification::calculate(int stocketID)
@ -444,6 +470,8 @@ void SmokeBoxIdentification::calculate(int stocketID)
m_pCategoryMatcher->saveResultsImage(filePath); m_pCategoryMatcher->saveResultsImage(filePath);
m_stocketList[stocketID].imagesPathList.append(filePath.right(filePath.length()-1));
//根据相机编号对应找到3D基准文件去计算层高 //根据相机编号对应找到3D基准文件去计算层高
QString pclPath = dataSaveFolder; QString pclPath = dataSaveFolder;
@ -454,7 +482,16 @@ void SmokeBoxIdentification::calculate(int stocketID)
if (fileList.length() > 0) if (fileList.length() > 0)
{ {
m_pHeightCalculate->LoadPointCould(); pclPath = fileList[0].absolutePath();
m_pHeightCalculate->LoadPointCould(fileList[0].absolutePath());
str = QString("[%1]:Camera %2 -- PointCould = %3").arg(stocket.id)
.arg(imgInfo.cameraSn).arg(pclPath);
qInfo() << str;
int lastPos = pclPath.lastIndexOf('.');
QString depthImagePath = pclPath.left(lastPos);
depthImagePath.append(".PNG");
m_stocketList[stocketID].imagesPathList.append(depthImagePath.right(depthImagePath.length() - 1));
} }
else else
{ {
@ -470,9 +507,13 @@ void SmokeBoxIdentification::calculate(int stocketID)
.arg(imgInfo.cameraSn).arg(basicFile); .arg(imgInfo.cameraSn).arg(basicFile);
qWarning() << str; qWarning() << str;
} }
m_pHeightCalculate->LoadBasicFile(); m_pHeightCalculate->LoadBasicFile(QString{});
//数量计算
m_stocketList[stocketID].smokeQuantityRlt = QString::number(m_pHeightCalculate->SmokeHeight()); m_stocketList[stocketID].smokeQuantityRlt = QString::number(m_pHeightCalculate->SmokeHeight());
//QFile::copy("C:\\Users\\LENOVO\\Downloads\\30t.pcd",pclPath);
QFile::rename(".\\Cache\\1.pcd", pclPath);
break; break;
} }
@ -483,6 +524,7 @@ void SmokeBoxIdentification::calculate(int stocketID)
QString filePath = dataSaveFolder + QString("\\%1_error.PNG") QString filePath = dataSaveFolder + QString("\\%1_error.PNG")
.arg(stocket.smokeTypeNum); .arg(stocket.smokeTypeNum);
m_pCategoryMatcher->saveResultsImage(filePath); m_pCategoryMatcher->saveResultsImage(filePath);
m_stocketList[stocketID].imagesPathList.append(filePath);
} }
} }
else else
@ -619,7 +661,8 @@ void SmokeBoxIdentification::sendResults(int mode, int id)
.append(m_stocketList.value(id).stockLocation).append(SPLIT_RULE) .append(m_stocketList.value(id).stockLocation).append(SPLIT_RULE)
.append(m_stocketList.value(id).smokeTypeNumRlt).append(SPLIT_RULE) .append(m_stocketList.value(id).smokeTypeNumRlt).append(SPLIT_RULE)
.append(m_stocketList.value(id).smokeQuantityRlt).append(SPLIT_RULE) .append(m_stocketList.value(id).smokeQuantityRlt).append(SPLIT_RULE)
.append(QString::number(m_stocketList.value(id).correctness)).append(END_SYMBOL); .append(QString::number(m_stocketList.value(id).correctness)).append(SPLIT_RULE)
.append(m_stocketList.value(id).imagesPathList.join(";")).append(END_SYMBOL);
m_stocketList.remove(id); m_stocketList.remove(id);
qInfo() << "m_stocketList.remove(id) = " << id <<"; Next ="<<m_stocketList.size(); qInfo() << "m_stocketList.remove(id) = " << id <<"; Next ="<<m_stocketList.size();
@ -652,7 +695,9 @@ void SmokeBoxIdentification::sendResults(int mode, int id)
.append(m_currtIntoStockInfo.streetName).append(SPLIT_RULE) .append(m_currtIntoStockInfo.streetName).append(SPLIT_RULE)
.append(m_currtIntoStockInfo.id).append(SPLIT_RULE) .append(m_currtIntoStockInfo.id).append(SPLIT_RULE)
.append(m_currtIntoStockInfo.taskNum).append(SPLIT_RULE) .append(m_currtIntoStockInfo.taskNum).append(SPLIT_RULE)
.append(m_currtIntoStockInfo.stockLocation).append(END_SYMBOL); .append(m_currtIntoStockInfo.stockLocation).append(SPLIT_RULE)
.append(m_currtIntoStockInfo.smokeTypeNum).append(SPLIT_RULE)
.append(m_currtIntoStockInfo.smokeQuantity).append(END_SYMBOL);
break; break;
} }
default: default:

@ -150,6 +150,8 @@ struct IntoStockInfo
QString stockNum; //货架位置UL062015020111 6号堆垛机2右边 QString stockNum; //货架位置UL062015020111 6号堆垛机2右边
QString id = 0; QString id = 0;
QString stockLocation = 0; // 方向1左2右0保留为之前规则 QString stockLocation = 0; // 方向1左2右0保留为之前规则
QString smokeTypeNum; //上位机发送的品规号37010106
QString smokeQuantity; //上位机发送的数量30
QStringList imagesPathList; QStringList imagesPathList;
}; };
@ -179,6 +181,7 @@ struct StockCheckInfo
QString smokeTypeNumRlt; //盘点识别的品规号 QString smokeTypeNumRlt; //盘点识别的品规号
QString smokeQuantityRlt; //盘点识别的数量 QString smokeQuantityRlt; //盘点识别的数量
bool correctness; //盘点结果是否与上位机一致 bool correctness; //盘点结果是否与上位机一致
QStringList imagesPathList;
//void clear() //void clear()
//{ //{
// streetName.clear(); // streetName.clear();

Loading…
Cancel
Save