init files
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
# 获取获取当前目录名
|
||||
get_filename_component(CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||
string(TIMESTAMP RUN_TIME)
|
||||
message( " model start : " ${CURRENT_FOLDER}:${RUN_TIME})
|
||||
|
||||
set(DLL_NAMES "opencv" "qt5") #对应的总cmakeList.txt的target
|
||||
foreach(child ${DLL_NAMES})
|
||||
LIST(APPEND ENV_INCLUDE ${${child}_include})
|
||||
LIST(APPEND ENV_LIB ${${child}_lib})
|
||||
LIST(APPEND ENV_TARGET ${${child}_target_link})
|
||||
endforeach()
|
||||
message(" ENV_INCLUDE : " ${ENV_INCLUDE} )
|
||||
message(" ENV_LIB : " ${ENV_LIB} )
|
||||
message(" ENV_TARGET : " ${ENV_TARGET} )
|
||||
include_directories(
|
||||
${ENV_INCLUDE}
|
||||
)
|
||||
|
||||
link_directories (
|
||||
${ENV_LIB}
|
||||
)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
SET(CMAKE_CXX_STANDARD 11)
|
||||
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
SET(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
FILE(GLOB HEAD_FILES "./*.h" )
|
||||
FILE(GLOB SRC_FILES "./*.cpp")
|
||||
FILE(GLOB UI_FILES "./*.ui")
|
||||
|
||||
#find_package(Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Network REQUIRED)
|
||||
|
||||
add_library(${CURRENT_FOLDER} SHARED
|
||||
${HEAD_FILES}
|
||||
${SRC_FILES}
|
||||
${UI_FILES}
|
||||
)
|
||||
|
||||
set_target_properties(${CURRENT_FOLDER} PROPERTIES LINKER_LANGUAGE C
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
|
||||
)
|
||||
|
||||
target_link_libraries(${CURRENT_FOLDER} PRIVATE
|
||||
|
||||
${ENV_TARGET}
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Network
|
||||
)
|
||||
|
||||
string(TIMESTAMP RUN_TIME)
|
||||
message( " model end : " ${CURRENT_FOLDER}:${RUN_TIME})
|
||||
@@ -0,0 +1,59 @@
|
||||
#include"Hd_SocketModule_All.h"
|
||||
//
|
||||
//typedef Base* (*CreateFunction)();
|
||||
//typedef void (*ReleaseFunction)(Base* animal);
|
||||
Hd_SocketModule_All* create(int type)
|
||||
{
|
||||
qDebug() << __FUNCTION__ << " line:" << __LINE__ << "Hd_SocketModule_All create success!";
|
||||
return new Hd_SocketModule_All(type);
|
||||
}
|
||||
|
||||
void destory(Hd_SocketModule_All* ptr)
|
||||
{
|
||||
if (ptr != nullptr)
|
||||
{
|
||||
delete ptr;
|
||||
ptr = nullptr;
|
||||
}
|
||||
qDebug() << __FUNCTION__ << " line:" << __LINE__ << "Hd_SocketModule_All destory success!";
|
||||
|
||||
}
|
||||
|
||||
Hd_SocketModule_All::Hd_SocketModule_All(int settype, QObject* parent) : PbGlobalObject(settype, parent)
|
||||
{
|
||||
}
|
||||
|
||||
Hd_SocketModule_All::~Hd_SocketModule_All()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool Hd_SocketModule_All::setParameter(const QMap<QString, QString>&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QMap<QString, QString> Hd_SocketModule_All::parameters()
|
||||
{
|
||||
return QMap<QString, QString>();
|
||||
}
|
||||
|
||||
bool Hd_SocketModule_All::init()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Hd_SocketModule_All::setData(const vector<cv::Mat>&, const QStringList&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Hd_SocketModule_All::data(std::vector<cv::Mat>&, QStringList&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString Hd_SocketModule_All::getmoduleName()
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
#ifndef Hd_SocketModule_All_H
|
||||
#define Hd_SocketModule_All_H
|
||||
|
||||
#include <QMap>
|
||||
#include "pbglobalobject.h"
|
||||
#include "base.h"
|
||||
#include "qobject.h"
|
||||
#include "qjsonobject.h"
|
||||
#include "qjsonarray.h"
|
||||
#include "qjsondocument.h"
|
||||
#include "QLibrary.h"
|
||||
#include "QMetaType.h"
|
||||
#include "QDateTime.h"
|
||||
#include "QThread.h"
|
||||
#include "QMutex.h"
|
||||
#include "QDebug.h"
|
||||
#include "QQueue.h"
|
||||
#include "QMap.h"
|
||||
#include "QDir.h"
|
||||
#include <QJsonParseError>
|
||||
//#include "qimage.h"
|
||||
#include "qtimer.h"
|
||||
#include <Windows.h>
|
||||
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
class Hd_SocketModule_All : public PbGlobalObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Hd_SocketModule_All(int settype = -1, QObject* parent = nullptr);
|
||||
~Hd_SocketModule_All();
|
||||
|
||||
//#######################通用函数#######################
|
||||
//初始化参数;通信/相机的初始化参数
|
||||
virtual bool setParameter(const QMap<QString, QString>&);
|
||||
|
||||
//setParameter之后再调用,返回当前参数
|
||||
//相机:获取默认参数;
|
||||
//通信:获取初始化示例参数
|
||||
virtual QMap<QString, QString> parameters();
|
||||
//初始化(加载模块到内存)
|
||||
virtual bool init();
|
||||
|
||||
//设置数据
|
||||
//相机:第一张图的参数,QStringList:00 曝光值 增益值;
|
||||
//相机:第N张图的参数,QStringList:非00 曝光值 增益值;
|
||||
//完成后发送信号trigged(bool);
|
||||
virtual bool setData(const vector<cv::Mat>&, const QStringList&);
|
||||
//获取数据
|
||||
virtual bool data(std::vector<cv::Mat>&, QStringList&);
|
||||
|
||||
private:
|
||||
QString getmoduleName();
|
||||
|
||||
private:
|
||||
bool ifFirst = true;
|
||||
//参数设置的数据
|
||||
QMap<QString, QString> ParasValueMap;
|
||||
};
|
||||
|
||||
extern "C"
|
||||
{
|
||||
Q_DECL_EXPORT Hd_SocketModule_All* create(int type = -1);
|
||||
Q_DECL_EXPORT void destory(Hd_SocketModule_All* ptr);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef __BASECLASS_H__
|
||||
#define __BASECLASS_H__
|
||||
|
||||
#include <iostream>
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <opencv2/core.hpp>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
class Base :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
bool init_flag; //是否初始化,false,true
|
||||
bool status = true; //相机状态(判断相机是否断开连接)
|
||||
std::string paras; //传输数据
|
||||
std::vector<cv::Mat> m_mat; //传输图片
|
||||
std::string moduleName=""; //模块名称
|
||||
public:
|
||||
Base(){}
|
||||
virtual ~Base(){}
|
||||
virtual bool readData(std::vector<cv::Mat>&,QByteArray&){return true;}
|
||||
virtual bool writeData(std::vector<cv::Mat>&,QByteArray&){return true;}
|
||||
virtual bool initParas(QByteArray&){return true;}
|
||||
virtual bool run() {return true;}
|
||||
virtual bool checkStatus() { return true; }
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,61 @@
|
||||
#ifndef PBGLOBALOBJECT_H
|
||||
#define PBGLOBALOBJECT_H
|
||||
|
||||
#include <QObject>
|
||||
#include<opencv2/opencv.hpp>
|
||||
#include <opencv.hpp>
|
||||
using namespace std;
|
||||
|
||||
//type对应的相机、触发方式
|
||||
#define HIK_Hard 0 //海康
|
||||
#define HIK_Soft 1
|
||||
#define Basler_Hard 2
|
||||
#define Basler_Soft 3
|
||||
#define DaHua_Hard 4
|
||||
#define DaHua_Soft 5
|
||||
#define DaHeng_Hard 6
|
||||
#define DaHeng_Soft 7
|
||||
#define Dalsa 8
|
||||
#define DalsaDAQ_Hard 9
|
||||
#define DalsaDAQ_Soft 10
|
||||
#define ITEK_Hard 11
|
||||
#define ITEK_Soft 12
|
||||
#define OPT_Hard 13
|
||||
#define OPT_Soft 14
|
||||
#define Keyence_25D 15
|
||||
#define Keyence_3D 16
|
||||
#define LMI_3D 17
|
||||
#define Sszn_3D 18
|
||||
#define ReadImage 1000
|
||||
|
||||
class PbGlobalObject : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PbGlobalObject(int settype, QObject* parent = nullptr) : QObject(parent), type1(settype) {}
|
||||
virtual ~PbGlobalObject() {}
|
||||
virtual bool setParameter(const QMap<QString, QString> &) { return true; }
|
||||
|
||||
virtual QMap<QString,QString> parameters() = 0;
|
||||
virtual bool init() { return true; }
|
||||
virtual bool setData(const vector<cv::Mat> &, const QStringList &) { return true; }
|
||||
virtual bool data(std::vector<cv::Mat> &, QStringList &) { return true; }
|
||||
public:
|
||||
//大类
|
||||
enum PGOFAMLIY { GLOBALVARIABLE = 0, CAMERA2D, CAMERA2_5D, CAMERA3D, PLC, COM }famliy;
|
||||
//小类
|
||||
int type1 = -1; //对应哪个品牌相机(触发方式)/通信
|
||||
int type2 = -1;
|
||||
int type3 = -1;
|
||||
QString name = "";
|
||||
|
||||
int id;
|
||||
|
||||
signals:
|
||||
void trigged(bool);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif // PBGLOBALOBJECT_H
|
||||
Reference in New Issue
Block a user