119 lines
3.3 KiB
C++
119 lines
3.3 KiB
C++
#pragma once
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
#include <qobject.h>
|
|
#include <qmetatype.h>
|
|
#include <qstring.h>
|
|
#include <qcolor.h>
|
|
#include <qpixmap.h>
|
|
|
|
#include <opencv.hpp>
|
|
#include <qvariant.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 qtFuncBridge : public QObject {
|
|
Q_OBJECT
|
|
public:
|
|
// 获取单例实例(线程不安全的延迟初始化,适用于主线程初始化)
|
|
static qtFuncBridge* getInstance() {
|
|
static qtFuncBridge* s_instance = nullptr;
|
|
if (!s_instance) {
|
|
// intentionally leaked: lives for application lifetime
|
|
s_instance = new qtFuncBridge(nullptr);
|
|
}
|
|
return s_instance;
|
|
}
|
|
|
|
// 禁止拷贝
|
|
Q_DISABLE_COPY(qtFuncBridge)
|
|
|
|
signals:
|
|
// 日志相关
|
|
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 summaryData_addData(QString window, double data);
|
|
|
|
//数据到界面
|
|
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 switchMainStakedWidget(int index);
|
|
|
|
// UI 效果
|
|
void passWordEditShake();
|
|
|
|
// 加载窗口状态图标
|
|
void loadingWindow_SetLoadingIcon();
|
|
void loadingWindow_SetErrorIcon();
|
|
void loadingWindow_SetErrorText(QString text);
|
|
|
|
// 警告日志
|
|
void loadingWindow_appendWarningLog(QString text);
|
|
void loadingWindow_clearWarningLog();
|
|
//////////////////////////////////////////////////////////////
|
|
void restartInit();
|
|
|
|
//排障
|
|
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 sendTriggerManagerLoopData(int loopCounterPerMin,int maxInterval);
|
|
|
|
void triggerAndCaptureImage(std::string cameraName, std::vector<cv::Mat>* mats);
|
|
void getCameraNames(std::vector<std::string>* cameraNames);
|
|
void getAllParams(std::vector<std::pair<QString, QVariant>>* params);
|
|
void editParam(QString name, QVariant value);
|
|
private:
|
|
explicit qtFuncBridge(QObject* parent = nullptr) : QObject(parent) {}
|
|
~qtFuncBridge() = default;
|
|
};
|
|
|