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

210 lines
5.1 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef SMOKE_IDENTIFICATION_H
#define SMOKE_IDENTIFICATION_H
#include <fstream>
#include <QtWidgets/QMainWindow>
#include <QtConcurrent/QtConcurrent>
#include".\Qt5Xlsx\xlsxdocument.h"
#include".\Qt5Xlsx\xlsxworkbook.h"
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include "CameraControl.h"
#include "NetControl.h"
#include "ADModule.h"
#include "CategoryMatcher.h"
#include "lpSerialStation.h"
#include "CodeScanStation.h"
#include "dataPreprocessing.h"
#include "QNumTemplateBuild.h"
#include "ui_SmokeBoxIdentification.h"
//#define IMAGEDRAWING OPENCV
#define IMAGEDRAWING LPV
enum MsgType
{
EmptyCheckResult = 0,
DataCollectionEndSC,
StockCheckResult,
IntoStockResult
};
enum WorkMode
{
Idle = 0,
EmptyCheck,
StockCheck,
IntoStock
};
enum StockCheckMode
{
NoVirtual = 0,
TypeVirtual, //品规模拟盘点
NumVirtual, //数量模拟盘点
TypeNumVirtual //品规数量模拟盘点
};
struct IntoStockInfo
{
QString streetName;
QString taskNum;
QString stockNum;
QStringList imagesPathList;
};
struct EmptyCheckInfo
{
QString streetName;
QString taskNum;
};
struct StockCheckInfo
{
// "SC&6&UL062015020111&6335&37010106&30&N>"
// 新规则GP&111&6&2121&1&S001&25>
// 111:ID号
// 6:巷道号
// 2121:任务号-工单号
// 1方向1左2右
// S001:品规号-上位机发送的品规号
//
QString streetName; // 巷道6
QString taskNum; // 工单号6335
QString stockNum; // 货架位置UL062015020111 6号堆垛机2右边
QString id = 0;
QString stockLocation = 0; // 方向1左2右0保留为之前规则
QString smokeTypeNum; //上位机发送的品规号37010106
QString smokeQuantity; //上位机发送的数量30
QString smokeTypeNumRlt; //盘点识别的品规号
QString smokeQuantityRlt; //盘点识别的数量
bool correctness; //盘点结果是否与上位机一致
//void clear()
//{
// streetName.clear();
// taskNum.clear();
// stockNum.clear();
// smokeTypeNum.clear();
// smokeQuantity.clear();
// smokeTypeNumRlt.clear();
// smokeQuantityRlt.clear();
// correctness = false;
//}
//StockCheckInfo &operator = (const StockCheckInfo& obj)
//{
// this->streetName = obj.streetName;
// this->taskNum = obj.taskNum;
// this->stockNum = obj.stockNum;
// this->smokeTypeNum = obj.smokeTypeNum;
// this->smokeQuantity = obj.smokeQuantity;
// this->smokeTypeNumRlt = obj.smokeTypeNumRlt;
// this->smokeQuantityRlt = obj.smokeQuantityRlt;
// this->correctness = obj.correctness;
// return *this;
//}
};
struct ModuleParam
{
int CodeScan; // 扫码器数量0为不安装扫码器
int Sensor; // 传感器数量0为不安装传感器
int Camera2D; // 2D相机数量
int Camera3D; // 3D相机数量
ModuleParam()
{
CodeScan = 1;
Sensor = 1;
Camera2D = 2;
Camera3D = 2;
}
};
class SmokeBoxIdentification : public QMainWindow
{
Q_OBJECT
public:
SmokeBoxIdentification(QWidget *parent = Q_NULLPTR);
~SmokeBoxIdentification();
signals:
void sgCapture(int cameraLocation);
void sgCategoryMatchFinished(QString smokeNum);
void sgShowImage(QLabel* labelPtr, const QImage& qImage);
//void sgSendData2AndAlgo();
//void sgSaveSensorData2Local(QString filePath);
void sgNumDataCollectStart(int sideId);
void sgNumDataCollectStop();
//void sgSendResults(int mode);
void sgStartEmptyPlaceCheck(QString streetName);
void sgStopEmptyPlaceCheck();
void sgControlSideLight(int);
void sgSendMsg(QString msg);
private:
Q_SLOT void onDecodeMsg(const QString& msg);
Q_SLOT void onCapturedImage(const QVector<ImageInfo>& vecImageInfo, int camearLocation);
Q_SLOT void onNumStatistic(QString typeNum);
Q_SLOT void onShowImage(QLabel* labelPtr, const QImage& qImage);
Q_SLOT void onMonitorSensorTriggerStart(int);
Q_SLOT void onMonitorSensorTriggerStop(int);
Q_SLOT void onActionClicked();
Q_SLOT void onSendEmptyCheckResults(const QMap<QString, int>&);
Q_SLOT void onNewNumData(const QVector<QVector<double>>& vec, const QVector<QString>& strVec, int side);
void sendResults(int mode);
void saveData2File(const QVector<QString>& strVec, QString folderPath, int side);
void captureTop();
void captureSide();
void saveImage(const QVector<ImageInfo>& vecImageInfo, int workMode);
void saveImage(const cv::Mat& imgMat, const QString& filePath);
bool decodeSmokeInfoCsv(const QString& filePath);
bool matchSmokeNameAndTemplateFolderName(const QString& folderPath);
bool m_bEmptyCheckStart{ false };
//bool m_bStockCheckStart{ false };
bool m_bCaptureFinish{ false };
bool m_bDataCollection{ false };
//bool m_bCamerasInit{ false };
void moduleLoading();
ModuleParam m_moduleParam;
QMap<QString, QString> m_mapSmokeCode2Name;
QMap<QString, QString> m_mapSmokeName2TemplateFolderName;
QString m_currLeftRightJudge;
QVector<QString> m_vecStrHeightLeft;
QVector<QString> m_vecStrHeightRight;
std::shared_ptr<dataPreProcessing> m_pDataProcess;
WorkMode m_workMode;
NetControl* m_pNetControl;
CategoryMatcher* m_pCategoryMatcher;
IntoStockInfo m_currtIntoStockInfo;
StockCheckInfo m_currtStockCheckInfo;
EmptyCheckInfo m_currtEmptyCheckInfo;
QNumTemplateBuild* m_pNumTemplateBuild{ nullptr };
StockCheckMode m_stockCheckMode;
QThread* m_pTcpClientThread;
//QLabel* m_pShowRltImgLabel;
Ui::SmokeBoxIdentificationClass ui;
};
#endif // !SMOKE_IDENTIFICATION_H