2025-06-08 12:48:04 +08:00
|
|
|
|
#ifndef IYGRABBAGSTATUS_H
|
|
|
|
|
|
#define IYGRABBAGSTATUS_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
#include <QImage>
|
2025-06-22 14:08:15 +08:00
|
|
|
|
#include <QMetaType>
|
2025-06-08 12:48:04 +08:00
|
|
|
|
|
|
|
|
|
|
// 工作状态枚举
|
|
|
|
|
|
enum class WorkStatus {
|
2025-06-22 14:08:15 +08:00
|
|
|
|
InitIng, // 初始化中
|
2025-06-08 12:48:04 +08:00
|
|
|
|
Ready, // 准备就绪
|
|
|
|
|
|
Working, // 正在工作
|
|
|
|
|
|
Completed, // 监测完成
|
|
|
|
|
|
Error // 设备异常
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 工作状态转换为字符串的工具函数
|
|
|
|
|
|
inline std::string WorkStatusToString(WorkStatus status) {
|
|
|
|
|
|
switch (status) {
|
2025-06-22 14:08:15 +08:00
|
|
|
|
case WorkStatus::InitIng: return "初始化中";
|
2025-06-08 12:48:04 +08:00
|
|
|
|
case WorkStatus::Ready: return "准备就绪";
|
|
|
|
|
|
case WorkStatus::Working: return "正在工作";
|
2025-06-08 23:51:48 +08:00
|
|
|
|
case WorkStatus::Completed: return "检测完成";
|
2025-06-08 12:48:04 +08:00
|
|
|
|
case WorkStatus::Error: return "设备异常";
|
|
|
|
|
|
default: return "未知状态";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 坐标结构体
|
|
|
|
|
|
struct GrabBagPosition {
|
|
|
|
|
|
double x;
|
|
|
|
|
|
double y;
|
|
|
|
|
|
double z;
|
|
|
|
|
|
double roll;
|
|
|
|
|
|
double pitch;
|
|
|
|
|
|
double yaw;
|
2025-06-22 14:08:15 +08:00
|
|
|
|
|
|
|
|
|
|
// 默认构造函数
|
|
|
|
|
|
GrabBagPosition() : x(0), y(0), z(0), roll(0), pitch(0), yaw(0) {}
|
|
|
|
|
|
|
|
|
|
|
|
// 拷贝构造函数(编译器会自动生成,但为了明确可以保留)
|
|
|
|
|
|
GrabBagPosition(const GrabBagPosition&) = default;
|
|
|
|
|
|
GrabBagPosition& operator=(const GrabBagPosition&) = default;
|
2025-06-08 12:48:04 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct GrabBagPositionLayout {
|
|
|
|
|
|
int layerIndex;
|
|
|
|
|
|
std::vector<GrabBagPosition> position;
|
2025-06-22 14:08:15 +08:00
|
|
|
|
|
|
|
|
|
|
// 默认构造函数
|
|
|
|
|
|
GrabBagPositionLayout() : layerIndex(0) {}
|
|
|
|
|
|
|
|
|
|
|
|
// 拷贝构造函数(编译器会自动生成,但为了明确可以保留)
|
|
|
|
|
|
GrabBagPositionLayout(const GrabBagPositionLayout&) = default;
|
|
|
|
|
|
GrabBagPositionLayout& operator=(const GrabBagPositionLayout&) = default;
|
2025-06-08 12:48:04 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 检测结果结构体
|
|
|
|
|
|
struct DetectionResult {
|
|
|
|
|
|
QImage image;
|
|
|
|
|
|
std::vector<GrabBagPositionLayout> positionLayout;
|
2025-06-22 14:08:15 +08:00
|
|
|
|
|
|
|
|
|
|
// 默认构造函数
|
|
|
|
|
|
DetectionResult() = default;
|
|
|
|
|
|
|
|
|
|
|
|
// 拷贝构造函数(编译器会自动生成,但为了明确可以保留)
|
|
|
|
|
|
DetectionResult(const DetectionResult&) = default;
|
|
|
|
|
|
DetectionResult& operator=(const DetectionResult&) = default;
|
|
|
|
|
|
|
|
|
|
|
|
// 移动构造函数(为了优化性能)
|
|
|
|
|
|
DetectionResult(DetectionResult&&) = default;
|
|
|
|
|
|
DetectionResult& operator=(DetectionResult&&) = default;
|
2025-06-08 12:48:04 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 状态回调接口
|
|
|
|
|
|
class IYGrabBagStatus {
|
|
|
|
|
|
public:
|
|
|
|
|
|
virtual ~IYGrabBagStatus() = default;
|
|
|
|
|
|
|
|
|
|
|
|
// 状态文字回调
|
|
|
|
|
|
virtual void OnStatusUpdate(const std::string& statusMessage) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 算法监测结果回调
|
|
|
|
|
|
virtual void OnDetectionResult(const DetectionResult& result) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 相机状态回调
|
|
|
|
|
|
virtual void OnCamera1StatusChanged(bool isConnected) = 0;
|
|
|
|
|
|
virtual void OnCamera2StatusChanged(bool isConnected) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 机械臂连接状态回调
|
|
|
|
|
|
virtual void OnRobotConnectionChanged(bool isConnected) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 相机个数回调
|
|
|
|
|
|
virtual void OnCameraCountChanged(int cameraCount) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 工作状态回调
|
|
|
|
|
|
virtual void OnWorkStatusChanged(WorkStatus status) = 0;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-06-22 14:08:15 +08:00
|
|
|
|
// 声明Qt元类型,使这些结构体能够在信号槽中传递
|
|
|
|
|
|
Q_DECLARE_METATYPE(WorkStatus)
|
|
|
|
|
|
Q_DECLARE_METATYPE(GrabBagPosition)
|
|
|
|
|
|
Q_DECLARE_METATYPE(GrabBagPositionLayout)
|
|
|
|
|
|
Q_DECLARE_METATYPE(DetectionResult)
|
|
|
|
|
|
|
2025-06-08 12:48:04 +08:00
|
|
|
|
#endif // IYGRABBAGSTATUS_H
|