2025-08-24 23:24:33 +08:00
|
|
|
|
#ifndef ISTATUSUPDATE_H
|
|
|
|
|
|
#define ISTATUSUPDATE_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
#include <QImage>
|
|
|
|
|
|
#include <QMetaType>
|
|
|
|
|
|
#include <QDateTime>
|
2025-08-31 21:08:28 +08:00
|
|
|
|
#include <QVariant>
|
|
|
|
|
|
#include <QJsonObject>
|
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
#include <QStringList>
|
2025-09-29 00:56:53 +08:00
|
|
|
|
#include "IVrBeltTearingConfig.h"
|
|
|
|
|
|
|
2025-08-24 23:24:33 +08:00
|
|
|
|
|
|
|
|
|
|
// 皮带撕裂检测工作状态枚举
|
|
|
|
|
|
class BeltTearingWorkStatus {
|
|
|
|
|
|
public:
|
|
|
|
|
|
enum Type {
|
|
|
|
|
|
InitIng, // 初始化中
|
|
|
|
|
|
Ready, // 准备就绪
|
|
|
|
|
|
Working, // 正在检测
|
|
|
|
|
|
Completed, // 检测完成
|
|
|
|
|
|
Error, // 设备异常
|
|
|
|
|
|
Disconnected // 连接断开
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
BeltTearingWorkStatus() : value(InitIng) {}
|
|
|
|
|
|
BeltTearingWorkStatus(Type v) : value(v) {}
|
|
|
|
|
|
operator Type() const { return value; }
|
|
|
|
|
|
Type operator()() const { return value; }
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
Type value;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 工作状态转换为字符串的工具函数
|
|
|
|
|
|
inline std::string BeltTearingWorkStatusToString(BeltTearingWorkStatus status) {
|
|
|
|
|
|
switch (status) {
|
|
|
|
|
|
case BeltTearingWorkStatus::InitIng: return "初始化中";
|
|
|
|
|
|
case BeltTearingWorkStatus::Ready: return "准备就绪";
|
|
|
|
|
|
case BeltTearingWorkStatus::Working: return "正在检测";
|
|
|
|
|
|
case BeltTearingWorkStatus::Completed: return "检测完成";
|
|
|
|
|
|
case BeltTearingWorkStatus::Error: return "设备异常";
|
|
|
|
|
|
case BeltTearingWorkStatus::Disconnected: return "连接断开";
|
|
|
|
|
|
default: return "未知状态";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-31 21:08:28 +08:00
|
|
|
|
// 撕裂数据结构体
|
|
|
|
|
|
struct TearingData
|
|
|
|
|
|
{
|
|
|
|
|
|
QString level;
|
|
|
|
|
|
QString id;
|
|
|
|
|
|
QString tearStatus;
|
|
|
|
|
|
QString tearType;
|
|
|
|
|
|
QString statLineIdx;
|
|
|
|
|
|
QString endLineIdx;
|
|
|
|
|
|
QString tearDepth;
|
|
|
|
|
|
QString tearWidth;
|
|
|
|
|
|
QString tearLength;
|
|
|
|
|
|
QString older;
|
|
|
|
|
|
|
|
|
|
|
|
static TearingData fromJsonObject(const QJsonObject &json) {
|
|
|
|
|
|
TearingData data;
|
2025-09-24 22:36:13 +08:00
|
|
|
|
data.level = json["level"].toString();
|
|
|
|
|
|
data.id = json["id"].toString();
|
2025-08-31 21:08:28 +08:00
|
|
|
|
data.tearStatus = json["tearStatus"].toString();
|
2025-09-24 22:36:13 +08:00
|
|
|
|
data.tearType = json["tearType"].toString();
|
|
|
|
|
|
data.statLineIdx = json["statLineIdx"].toString();
|
|
|
|
|
|
data.endLineIdx = json["endLineIdx"].toString();
|
|
|
|
|
|
data.tearDepth = json["tearDepth"].toString();
|
|
|
|
|
|
data.tearWidth = json["tearWidth"].toString();
|
|
|
|
|
|
data.tearLength = json["tearLength"].toString();
|
|
|
|
|
|
data.older = json["older"].toString();
|
2025-08-31 21:08:28 +08:00
|
|
|
|
return data;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 重载相等运算符,便于在vector中查找和比较
|
|
|
|
|
|
bool operator==(const TearingData &other) const {
|
|
|
|
|
|
return level == other.level &&
|
|
|
|
|
|
id == other.id &&
|
|
|
|
|
|
tearStatus == other.tearStatus &&
|
|
|
|
|
|
tearType == other.tearType &&
|
|
|
|
|
|
statLineIdx == other.statLineIdx &&
|
|
|
|
|
|
endLineIdx == other.endLineIdx &&
|
|
|
|
|
|
tearDepth == other.tearDepth &&
|
|
|
|
|
|
tearWidth == other.tearWidth &&
|
|
|
|
|
|
tearLength == other.tearLength &&
|
|
|
|
|
|
older == other.older;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-08-24 23:24:33 +08:00
|
|
|
|
// 皮带撕裂检测结果结构体
|
|
|
|
|
|
struct BeltTearingResult {
|
2025-08-31 21:08:28 +08:00
|
|
|
|
QImage image; // 检测图像
|
|
|
|
|
|
bool bImageValid = false;
|
|
|
|
|
|
std::vector<TearingData> result; // 检测结果描述
|
|
|
|
|
|
bool bResultVaild = false;
|
|
|
|
|
|
double confidence = 0.0; // 置信度
|
2025-10-08 21:45:37 +08:00
|
|
|
|
QString serverName; // 服务器名称
|
|
|
|
|
|
QString aliasName; // 服务器别名
|
|
|
|
|
|
QDateTime timestamp; // 时间戳
|
2025-08-24 23:24:33 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 皮带撕裂检测状态更新接口
|
|
|
|
|
|
class IStatusUpdate {
|
|
|
|
|
|
public:
|
|
|
|
|
|
virtual ~IStatusUpdate() = default;
|
|
|
|
|
|
|
|
|
|
|
|
// 状态文字回调
|
|
|
|
|
|
virtual void OnStatusUpdate(const QString& statusMessage) = 0;
|
2025-08-27 23:10:36 +08:00
|
|
|
|
|
2025-08-31 21:08:28 +08:00
|
|
|
|
// 回调需要显示几个图像,参数为设备别名列表
|
|
|
|
|
|
virtual void OnNeedShowImageCount(const QStringList& deviceAliases) = 0;
|
2025-09-21 22:20:24 +08:00
|
|
|
|
|
|
|
|
|
|
// 设备状态更新回调
|
|
|
|
|
|
virtual void OnDeviceStatusChanged(const QString& deviceName, int deviceStatus) = 0;
|
2025-08-24 23:24:33 +08:00
|
|
|
|
|
|
|
|
|
|
// 撕裂检测结果回调
|
|
|
|
|
|
virtual void OnTearingResult(const BeltTearingResult& result) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 服务器连接状态回调
|
|
|
|
|
|
virtual void OnServerConnected(const QString& serverName) = 0;
|
|
|
|
|
|
virtual void OnServerDisconnected(const QString& serverName) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 工作状态回调
|
|
|
|
|
|
virtual void OnWorkStatusChanged(BeltTearingWorkStatus status) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 错误信息回调
|
|
|
|
|
|
virtual void OnErrorOccurred(const QString& errorMessage) = 0;
|
2025-10-08 21:45:37 +08:00
|
|
|
|
|
|
|
|
|
|
// 清空撕裂数据回调
|
|
|
|
|
|
virtual void OnClearTearingData() = 0;
|
2025-11-26 22:44:38 +08:00
|
|
|
|
|
|
|
|
|
|
// 温度数据更新回调
|
|
|
|
|
|
virtual void OnTemperatureUpdate(const QString& deviceName, float temperature) = 0;
|
2025-08-24 23:24:33 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 声明Qt元类型,使这些结构体能够在信号槽中传递
|
2025-09-29 00:56:53 +08:00
|
|
|
|
Q_DECLARE_METATYPE(TearingData)
|
2025-08-24 23:24:33 +08:00
|
|
|
|
Q_DECLARE_METATYPE(BeltTearingWorkStatus)
|
|
|
|
|
|
Q_DECLARE_METATYPE(BeltTearingResult)
|
|
|
|
|
|
|
|
|
|
|
|
#endif // ISTATUSUPDATE_H
|