2025-12-10 00:01:32 +08:00
|
|
|
|
#ifndef WORKPIECESPLICEPRESENTER_H
|
|
|
|
|
|
#define WORKPIECESPLICEPRESENTER_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
#include <mutex>
|
2025-12-27 09:34:02 +08:00
|
|
|
|
#include "BasePresenter.h"
|
2025-12-10 00:01:32 +08:00
|
|
|
|
#include "IYWorkpieceSpliceStatus.h"
|
|
|
|
|
|
#include "IBinocularMarkReceiver.h"
|
|
|
|
|
|
#include "IVrConfig.h"
|
|
|
|
|
|
|
2025-12-27 09:34:02 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 工件拼接Presenter
|
|
|
|
|
|
*
|
|
|
|
|
|
* 继承自BasePresenter,使用BinocularMark设备进行工件拼接检测
|
|
|
|
|
|
* 不使用BasePresenter的激光相机功能,而是使用自己的BinocularMark设备管理
|
|
|
|
|
|
*/
|
|
|
|
|
|
class WorkpieceSplicePresenter : public BasePresenter
|
2025-12-10 00:01:32 +08:00
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
explicit WorkpieceSplicePresenter(QObject *parent = nullptr);
|
|
|
|
|
|
~WorkpieceSplicePresenter();
|
|
|
|
|
|
|
2025-12-27 09:34:02 +08:00
|
|
|
|
// 获取配置管理器
|
|
|
|
|
|
IVrConfig* GetConfigManager() { return m_pConfig; }
|
|
|
|
|
|
|
|
|
|
|
|
// ============ 重写 BasePresenter 的检测方法 ============
|
|
|
|
|
|
int StartDetection(int cameraIndex = -1, bool isAuto = true) override;
|
|
|
|
|
|
int StopDetection() override;
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
// ============ 实现 BasePresenter 纯虚函数 ============
|
|
|
|
|
|
int InitApp() override;
|
|
|
|
|
|
int InitAlgoParams() override;
|
|
|
|
|
|
int ProcessAlgoDetection(std::vector<std::pair<EVzResultDataType, SVzLaserLineData>>& detectionDataCache) override;
|
|
|
|
|
|
EVzResultDataType GetDetectionDataType() override;
|
|
|
|
|
|
void OnCameraStatusChanged(int cameraIndex, bool isConnected) override;
|
|
|
|
|
|
|
|
|
|
|
|
// ============ 重写 BasePresenter 虚函数 ============
|
|
|
|
|
|
void OnWorkStatusChanged(WorkStatus status) override;
|
|
|
|
|
|
void OnStatusUpdate(const std::string& statusMessage) override;
|
2025-12-10 00:01:32 +08:00
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
void onMarkReconnectTimeout();
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2025-12-27 09:34:02 +08:00
|
|
|
|
// 初始化方法
|
2025-12-10 00:01:32 +08:00
|
|
|
|
int InitConfig();
|
|
|
|
|
|
int InitBinocularMarkReceiver();
|
2025-12-27 09:34:02 +08:00
|
|
|
|
|
|
|
|
|
|
// 回调处理
|
2025-12-10 00:01:32 +08:00
|
|
|
|
void OnMarkResult(const std::vector<VrMark3D>& marks, qint64 timestamp, int errorCode);
|
|
|
|
|
|
void OnMarkConnectionChanged(bool connected);
|
2025-12-27 09:34:02 +08:00
|
|
|
|
|
|
|
|
|
|
// 连接方法
|
2025-12-10 00:01:32 +08:00
|
|
|
|
int ConnectToBinocularMark();
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2025-12-27 09:34:02 +08:00
|
|
|
|
// 配置相关
|
|
|
|
|
|
IVrConfig* m_pConfig = nullptr;
|
|
|
|
|
|
ConfigResult m_configResult;
|
|
|
|
|
|
|
|
|
|
|
|
// BinocularMark 设备
|
|
|
|
|
|
IBinocularMarkReceiver* m_pMarkReceiver = nullptr;
|
|
|
|
|
|
std::string m_binocularMarkIp;
|
|
|
|
|
|
quint16 m_binocularMarkPort = 0;
|
|
|
|
|
|
bool m_bMarkConnected = false;
|
|
|
|
|
|
QTimer* m_pMarkReconnectTimer = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
// 检测相关
|
|
|
|
|
|
std::mutex m_mutex;
|
2025-12-10 00:01:32 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // WORKPIECESPLICEPRESENTER_H
|