117 lines
4.0 KiB
C++
117 lines
4.0 KiB
C++
#ifndef Logic_camera_thread_H
|
|
#define Logic_camera_thread_H
|
|
|
|
#include <QObject>
|
|
#include <QApplication>
|
|
#include <QJsonObject>
|
|
#include <QJsonArray>
|
|
#include <QJsonDocument>
|
|
#include <QJsonParseError>
|
|
#include <QLibrary>
|
|
#include <QMetaType>
|
|
#include <QDateTime>
|
|
#include <QThread>
|
|
#include <QMutex>
|
|
#include <QDebug>
|
|
#include <QImage>
|
|
#include <QQueue>
|
|
#include <QMap>
|
|
#include <QDir>
|
|
|
|
#include "struct.h"
|
|
#include "Logic_hdataintegration.h"
|
|
|
|
// 模块线程
|
|
class Logic_camera_thread : public QThread
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit Logic_camera_thread(QObject *parent = nullptr):m_obj(parent){}
|
|
~Logic_camera_thread();
|
|
void run();
|
|
void setRunFlag(bool flag){ m_stoprun = flag; }
|
|
void setMutex( QMutex *mutex);
|
|
void setSaveImage( QString save){ m_saveImage = save;}
|
|
bool sendDataCommond(QString m_type,cv::Mat mat,QByteArray byteArray);
|
|
bool runCameraModule();
|
|
bool saveImage(std::vector<cv::Mat> mat);
|
|
//设置相机key、取图超时、模块、拍照面描述、触发方式
|
|
bool setModule( QString station_name,MyModule module,QJsonObject obj);
|
|
QString getName(){ return m_name; }
|
|
QString getType() { return m_type;}
|
|
QString getTriggerModel(){ return m_triggermodel; }
|
|
QVector<QString> getSnData(int index); // 获取sn码
|
|
void incrementSnIndex() { m_sn_index++; } // 先做预留
|
|
void degressSnIndex();
|
|
void setReadSnModel( QString model ) { m_sn_model = model; }
|
|
void adddataIntegrationThread(Logic_hdataintegration* mythread);// { mydataIntegrationThread = mythread; }
|
|
bool ifshowSoureImg = false;
|
|
//相机关键字(SN或userName)
|
|
QString m_name;
|
|
MyModule m_Module;
|
|
QString m_stationName = nullptr;
|
|
bool ifsaveImage = false;
|
|
QString trigger_signal;
|
|
QString SN_signal;
|
|
QStringList SN_signalList;
|
|
//获取几次图
|
|
int getImgNums = 0;
|
|
//获取图失败次数
|
|
int getImg_faileNums = 0;
|
|
int dataPack_size();
|
|
dataPack getdataPack();
|
|
int cu_runNum = 0;
|
|
bool ifRun = true;
|
|
bool ifMissImage = false;//缺图标志
|
|
QString m_missImgae_add;//缺图补图数据
|
|
void missImgae_addImage(std::vector<cv::Mat> & camera_mat);//缺图补图
|
|
//qstype转matType
|
|
int matType(QString qstype);
|
|
void set_ifMissImage(bool flage);
|
|
//项目通信流程,1简单流程,2标准流程;
|
|
int CommunicationProcessLevel = 0;
|
|
//发送的数据是否自动拼接PLC指令头
|
|
bool ifAddCmdHead = true;
|
|
QString CmdHeadShort = "write_short_";
|
|
QString CmdHeadString = "write_string_";
|
|
int getImgTimeout = 0;
|
|
bool m_stoprun = true;
|
|
void set_m_stoprun(bool val);
|
|
|
|
//相机取图完成后,"拍照信号-完成写入PLC-列表"回复PLC;避免取图时间长,阻塞其它相机的取图流程
|
|
QMutex* m_iomutex = nullptr;
|
|
Base* finstcp_ptr = nullptr;
|
|
QByteArray send_byte;
|
|
int maxCheckTime = 3000;
|
|
int waitenum = 0;
|
|
private:
|
|
QQueue<Logic_hdataintegration*> mydataIntegrationThread ;
|
|
QObject *m_obj;
|
|
QString m_type;
|
|
QString m_saveImage = nullptr;
|
|
QString m_summaryflag = nullptr; // 结果汇总标志,默认不汇总
|
|
QJsonObject m_moduleobj; // 模块的object
|
|
QString m_triggermodel = nullptr; // 设置相机触发模式
|
|
int m_sn_index = 0; // 获取当前sn码容器中sn的位置
|
|
QString m_sn_model = nullptr; // sn码的提取模式 -3 和其他工位做区分
|
|
|
|
//硬触发取图耗时累计
|
|
int myTime = 0;
|
|
//拍照面描述列表
|
|
QQueue<QString> cameraProductSurface;
|
|
|
|
int addImageNums = 0;
|
|
int runCameraModuleNums = 0;
|
|
QMutex* m_mutex = nullptr;
|
|
QMutex* ifMissImage_mutex = nullptr;
|
|
//相机数据包
|
|
QQueue<dataPack> camera_ImageDataPack;
|
|
int hardNum = 0;
|
|
clock_t maxTime_start, maxTime_stop;
|
|
signals:
|
|
|
|
};
|
|
extern QList<Logic_camera_thread*> camerathreadlist;
|
|
|
|
#endif // Logic_camera_thread_H
|