105 lines
2.7 KiB
C++
105 lines
2.7 KiB
C++
#include <iostream>
|
|
#include <qthread.h>
|
|
#include <qqueue.h>
|
|
#include <qmutex.h>
|
|
#include <iomanip>
|
|
#include <sstream>
|
|
#include <filesystem>
|
|
#include <opencv.hpp>
|
|
#include <string>
|
|
#include <handleAi/handleAiModel.h>
|
|
#include <sqlManager/sqlManager.h>
|
|
#include <QtConcurrent/qtconcurrent>
|
|
#include <QMetaType>
|
|
#include <fileManager.h>
|
|
#include <qtcpserver.h>
|
|
#include <qtcpsocket.h>
|
|
#include <mutex>
|
|
#include <backStruct.h>
|
|
#include <memory>
|
|
#include <detData.h>
|
|
class threadManager;
|
|
class algoThread;
|
|
class subThread;
|
|
class detDataManager;
|
|
class triggerManager;
|
|
|
|
class backEndManager;
|
|
|
|
class sncodeCls
|
|
{
|
|
public:
|
|
struct snPack
|
|
{
|
|
unsigned long long timecode;
|
|
std::string sn;
|
|
int startpos;
|
|
};
|
|
QList<snPack>snWaittingVec;
|
|
QList<snPack>snResList;
|
|
std::string snErrorsnError = "snErrNoSn";
|
|
int tcpStartPos=0;
|
|
bool clearSameSnRequestData();
|
|
void checkSnFromWaittingVec(QByteArray byte);
|
|
std::string readSnFromQByteArray(QByteArray byte, int dmPos,
|
|
bool highLowConversion, bool clearAfterRead, long long timeCode, int Size = -1);
|
|
QString snHex(QString sn);
|
|
std::string getData(unsigned long long timeCode);
|
|
std::string waitForSn(unsigned long long timeCode, int timeOut=1000);
|
|
sncodeCls();
|
|
};
|
|
|
|
class threadManager : public QThread
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
bool initFlag = false;
|
|
threadManager();
|
|
|
|
sqlManager* sql;
|
|
imgSaveThreadManager* _imgSaveThreadManager;
|
|
triggerManager* _triggerManager;
|
|
handleAiModelManager* _handleAiModelManager;
|
|
|
|
QQueue<std::shared_ptr <detData>> detDataQueue;
|
|
autoDelete* autoDeleteThread;
|
|
void initialization(backEndManager* _backEndManagerIn);
|
|
void run();
|
|
void stop()
|
|
{
|
|
runFlag = false;
|
|
this->terminate();
|
|
}
|
|
void resultHandle(std::shared_ptr <detData>);
|
|
|
|
void addTask(std::shared_ptr <detData>);
|
|
sncodeCls snDatas;
|
|
~threadManager();
|
|
|
|
QMutex queueMutex;
|
|
|
|
QMutex insertQueueMutex;
|
|
QQueue<std::shared_ptr <detData>>insertQueue;
|
|
void process();
|
|
private:
|
|
backEndManager* _backEndManager;
|
|
std::list<std::shared_ptr <detData>> waitImgData;//等待图片
|
|
std::list<std::shared_ptr <detData>> processData;//处理中
|
|
std::list<std::shared_ptr <detData>> resultData;//等待结果
|
|
|
|
std::unordered_map<unsigned long long, std::future<bool>> algoFutures;
|
|
std::unordered_map<unsigned long long, std::future<void>> resultFutures;
|
|
|
|
std::chrono::seconds zeroSec = std::chrono::seconds(0);
|
|
std::unordered_map<unsigned long long, std::future<bool>>::iterator futrueIte;
|
|
|
|
bool runFlag = true;
|
|
QList<std::shared_ptr <detData>>imgWaitList;
|
|
std::vector<std::shared_ptr <detData>>deleteVec;
|
|
signals:
|
|
|
|
};
|
|
|
|
#pragma once
|