2025-06-08 12:48:04 +08:00
|
|
|
|
#ifndef GRABBAGPRESENTER_H
|
|
|
|
|
|
#define GRABBAGPRESENTER_H
|
|
|
|
|
|
|
|
|
|
|
|
#include "IVrConfig.h"
|
|
|
|
|
|
#include "IVrEyeDevice.h"
|
|
|
|
|
|
#include "IYGrabBagStatus.h"
|
|
|
|
|
|
#include "RobotProtocol.h"
|
2025-06-08 23:51:48 +08:00
|
|
|
|
#include "VZNL_Types.h"
|
2025-06-08 12:48:04 +08:00
|
|
|
|
|
|
|
|
|
|
class GrabBagPresenter
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
GrabBagPresenter();
|
|
|
|
|
|
~GrabBagPresenter();
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化
|
|
|
|
|
|
int Init();
|
|
|
|
|
|
|
|
|
|
|
|
// 设置状态回调
|
|
|
|
|
|
void SetStatusCallback(IYGrabBagStatus* status);
|
|
|
|
|
|
|
|
|
|
|
|
// 开始检测
|
|
|
|
|
|
int StartDetection();
|
|
|
|
|
|
|
|
|
|
|
|
// 停止检测
|
|
|
|
|
|
int StopDetection();
|
|
|
|
|
|
|
2025-06-08 23:51:48 +08:00
|
|
|
|
IVrEyeDevice* GetEyeDevice(int index);
|
|
|
|
|
|
|
2025-06-08 12:48:04 +08:00
|
|
|
|
private:
|
|
|
|
|
|
// 机械臂协议相关方法
|
|
|
|
|
|
int InitRobotProtocol();
|
|
|
|
|
|
|
|
|
|
|
|
// 机械臂协议回调函数
|
|
|
|
|
|
void OnRobotConnectionChanged(bool connected);
|
|
|
|
|
|
void OnRobotWorkSignal(bool startWork);
|
|
|
|
|
|
|
2025-06-08 23:51:48 +08:00
|
|
|
|
// 连接状态检查和更新
|
|
|
|
|
|
void CheckAndUpdateWorkStatus();
|
|
|
|
|
|
|
2025-06-08 12:48:04 +08:00
|
|
|
|
// 静态回调函数,用于传递给SDK
|
|
|
|
|
|
static void _StaticCameraNotify(EVzDeviceWorkStatus eStatus, void* pExtData, unsigned int nDataLength, void* pInfoParam);
|
|
|
|
|
|
|
|
|
|
|
|
// 实例方法,处理回调
|
|
|
|
|
|
void _CameraNotify(EVzDeviceWorkStatus eStatus, void* pExtData, unsigned int nDataLength, void* pInfoParam);
|
|
|
|
|
|
|
2025-06-08 23:51:48 +08:00
|
|
|
|
// 检测数据回调函数
|
|
|
|
|
|
static void _StaticDetectionCallback(EVzResultDataType eDataType, SVzLaserLineData* pLaserLinePoint, void* pParam);
|
|
|
|
|
|
void _DetectionCallback(EVzResultDataType eDataType, SVzLaserLineData* pLaserLinePoint);
|
|
|
|
|
|
|
|
|
|
|
|
// 算法检测线程
|
|
|
|
|
|
void _AlgoDetectThread();
|
|
|
|
|
|
|
|
|
|
|
|
int _DetectTask();
|
2025-06-08 12:48:04 +08:00
|
|
|
|
|
|
|
|
|
|
private:
|
2025-06-08 23:51:48 +08:00
|
|
|
|
IVrConfig* m_vrConfig = nullptr;
|
|
|
|
|
|
std::vector<IVrEyeDevice*> m_vrEyeDeviceList;
|
|
|
|
|
|
IYGrabBagStatus* m_pStatus = nullptr;
|
2025-06-08 12:48:04 +08:00
|
|
|
|
|
2025-06-08 23:51:48 +08:00
|
|
|
|
RobotProtocol* m_pRobotProtocol = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
// 连接状态标志
|
|
|
|
|
|
bool m_bCameraConnected = false; // 相机连接状态
|
|
|
|
|
|
bool m_bRobotConnected = false; // 机械臂连接状态
|
|
|
|
|
|
WorkStatus m_currentWorkStatus = WorkStatus::Error; // 当前工作状态
|
|
|
|
|
|
|
|
|
|
|
|
std::atomic<bool> m_bAlgoDetectThreadRunning = false;
|
|
|
|
|
|
std::mutex m_algoDetectMutex;
|
|
|
|
|
|
std::condition_variable m_algoDetectCondition;
|
|
|
|
|
|
|
|
|
|
|
|
// 检测数据缓存
|
|
|
|
|
|
std::vector<SVzLaserLineData*> m_detectionDataCache;
|
|
|
|
|
|
std::mutex m_detectionDataMutex;
|
2025-06-08 12:48:04 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // GRABBAGPRESENTER_H
|