92 lines
2.8 KiB
C++
92 lines
2.8 KiB
C++
#pragma once
|
|
#include <nlohmannJson.hpp>
|
|
#include <sql/qSqlBase.h>
|
|
|
|
enum initStatus {
|
|
NotInit,
|
|
InitFailure,
|
|
InitOK
|
|
};
|
|
|
|
struct showImgPack {
|
|
cv::Mat img;
|
|
QString name = "";
|
|
QString type;
|
|
showImgPack() {};
|
|
showImgPack(QString name, QString type) : type(type), name(name) {}
|
|
};
|
|
|
|
enum valueType {
|
|
finsShort,
|
|
finsFloat
|
|
};
|
|
|
|
// PLC 值查看器的配置结构体
|
|
struct PlcValueViewerStruct {
|
|
QString valueName;
|
|
int valueAddr;
|
|
valueType type = finsShort;
|
|
QVariant value = -999;
|
|
};
|
|
|
|
class bSignalHub :public QObject{
|
|
Q_OBJECT
|
|
public:
|
|
explicit bSignalHub(QObject* parent = nullptr) : QObject(parent) {}
|
|
// 禁止拷贝
|
|
Q_DISABLE_COPY(bSignalHub)
|
|
signals:
|
|
// 汇总数据
|
|
void summaryData_addData(QString window, double data);
|
|
// 日志相关
|
|
void loadingWindow_appendInitLog(const QString& text, const QColor& color);
|
|
void loadingWindow_modifyLog(int col, const QString& text, const QColor& color);
|
|
void loadingWindow_clearLog();
|
|
// 登录结果
|
|
void initResult(initStatus result);
|
|
// 图像显示
|
|
void displayWidget_sendImg(showImgPack pack);
|
|
//数据到界面
|
|
void pieWidgetAddNG();
|
|
void pieWidgetAddOK();
|
|
void histogramWidgetAddData(std::vector<std::string>);
|
|
void setPlcConnectionError();
|
|
void setPlcConnectionOk();
|
|
void setCamConnectionError();
|
|
void setCamConnectionOk();
|
|
void waveFormAddData(QString windowName, double value);
|
|
//排障
|
|
void runCommand_addBtn(const QString& btnName, const QString& tip, const QString& uuid);
|
|
void runCommand_addPlcValueViewer(QString groupName, std::vector<std::pair<QString, int>> viewerNameAndAddress);
|
|
void runCommand_refeshPlcValueViewer(int address, QString value);
|
|
void saveMissionJson();
|
|
|
|
//性能监测
|
|
void sendTriggerManagerLoopData(int loopCounterPerMin, int maxInterval);
|
|
};
|
|
class IBackend :public QThread {
|
|
Q_OBJECT
|
|
public:
|
|
bSignalHub _signalHub;
|
|
virtual ~IBackend() = default;
|
|
virtual void init(SQLiteDB* ,nlohmann::ordered_json& json) = 0;
|
|
virtual void cleanup() = 0;
|
|
virtual nlohmann::ordered_json getBackendJson() = 0;
|
|
public slots:
|
|
virtual bool excuteCliCommand(const QString& command) = 0;
|
|
virtual bool excuteCliCommandPreset(const QString& uuid) = 0;
|
|
virtual void triggerAndCaptureImage(std::string cameraName, std::vector<cv::Mat>* mats) = 0;
|
|
virtual void getCameraNames(std::vector<std::string>* cameraNames) = 0;
|
|
virtual void getAllParams(std::vector<std::pair<QString, QVariant>>* params) = 0;
|
|
virtual void editParam(QString group, QString name, QVariant value) = 0;
|
|
};
|
|
|
|
extern "C" {
|
|
__declspec(dllexport) IBackend* CreateBackend();
|
|
__declspec(dllexport) void ReleaseBackend(IBackend* backend);
|
|
}
|
|
typedef IBackend* (*CreateBackendFunc)();
|
|
typedef void (*ReleaseBackendFunc)(IBackend*);
|
|
|
|
|