190 lines
6.0 KiB
C
190 lines
6.0 KiB
C
|
|
#ifndef WHEELMEASUREPRESENTER_H
|
|||
|
|
#define WHEELMEASUREPRESENTER_H
|
|||
|
|
|
|||
|
|
#include "BasePresenter.h"
|
|||
|
|
#include "IVrWheelMeasureConfig.h"
|
|||
|
|
#include "IWheelMeasureStatus.h"
|
|||
|
|
#include "CommonDialogCameraLevel.h"
|
|||
|
|
|
|||
|
|
#include <QImage>
|
|||
|
|
#include <QString>
|
|||
|
|
#include <QStringList>
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 车轮拱高测量Presenter
|
|||
|
|
* 继承BasePresenter,负责相机控制、算法调用和结果处理
|
|||
|
|
*/
|
|||
|
|
class WheelMeasurePresenter : public BasePresenter,
|
|||
|
|
public IVrWheelMeasureConfigChangeNotify,
|
|||
|
|
public ICameraLevelCalculator,
|
|||
|
|
public ICameraLevelResultSaver
|
|||
|
|
{
|
|||
|
|
Q_OBJECT
|
|||
|
|
|
|||
|
|
signals:
|
|||
|
|
void configUpdated();
|
|||
|
|
|
|||
|
|
public:
|
|||
|
|
explicit WheelMeasurePresenter(QObject* parent = nullptr);
|
|||
|
|
~WheelMeasurePresenter();
|
|||
|
|
|
|||
|
|
// ============ 实现 BasePresenter 纯虚函数 ============
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 私有初始化(实现纯虚函数)
|
|||
|
|
*/
|
|||
|
|
int InitApp() override;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 初始化算法参数(实现纯虚函数)
|
|||
|
|
*/
|
|||
|
|
int InitAlgoParams() override;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 执行算法检测(实现纯虚函数)
|
|||
|
|
*/
|
|||
|
|
int ProcessAlgoDetection(std::vector<std::pair<EVzResultDataType, SVzLaserLineData>>& detectionDataCache) override;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 获取检测数据类型(实现纯虚函数)
|
|||
|
|
*/
|
|||
|
|
EVzResultDataType GetDetectionDataType() override {
|
|||
|
|
return keResultDataType_Position;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 相机状态变化通知(实现纯虚函数)
|
|||
|
|
*/
|
|||
|
|
void OnCameraStatusChanged(int cameraIndex, bool isConnected) override;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 工作状态变化通知(重写虚函数)
|
|||
|
|
*/
|
|||
|
|
void OnWorkStatusChanged(WorkStatus status) override;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 相机数量变化通知(重写虚函数)
|
|||
|
|
*/
|
|||
|
|
void OnCameraCountChanged(int count) override;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 状态文字更新通知(重写虚函数)
|
|||
|
|
*/
|
|||
|
|
void OnStatusUpdate(const std::string& statusMessage) override;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief Modbus写寄存器回调(重写虚函数)
|
|||
|
|
*/
|
|||
|
|
void OnModbusWriteCallback(uint16_t startAddress, const uint16_t* data, uint16_t count) override;
|
|||
|
|
|
|||
|
|
// ============ 实现 ICameraLevelCalculator 接口 ============
|
|||
|
|
|
|||
|
|
bool CalculatePlaneCalibration(
|
|||
|
|
const std::vector<std::pair<EVzResultDataType, SVzLaserLineData>>& scanData,
|
|||
|
|
double planeCalib[9],
|
|||
|
|
double& planeHeight,
|
|||
|
|
double invRMatrix[9]) override;
|
|||
|
|
|
|||
|
|
// ============ 实现 ICameraLevelResultSaver 接口 ============
|
|||
|
|
|
|||
|
|
bool SaveLevelingResults(double planeCalib[9], double planeHeight, double invRMatrix[9],
|
|||
|
|
int cameraIndex, const QString& cameraName) override;
|
|||
|
|
|
|||
|
|
bool LoadLevelingResults(int cameraIndex, const QString& cameraName,
|
|||
|
|
double planeCalib[9], double& planeHeight, double invRMatrix[9]) override;
|
|||
|
|
|
|||
|
|
// ============ IVrWheelMeasureConfigChangeNotify 接口实现 ============
|
|||
|
|
|
|||
|
|
void OnConfigChanged(const WheelMeasureConfigResult& configResult) override;
|
|||
|
|
|
|||
|
|
// ============ 公共接口 ============
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 设置状态更新接口
|
|||
|
|
*/
|
|||
|
|
void setStatusUpdate(IWheelMeasureStatus* statusUpdate) { m_statusUpdate = statusUpdate; }
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 获取配置接口
|
|||
|
|
*/
|
|||
|
|
IVrWheelMeasureConfig* GetConfig() const { return m_config; }
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 获取配置结果
|
|||
|
|
*/
|
|||
|
|
WheelMeasureConfigResult* GetConfigResult() { return &m_configResult; }
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 获取相机名称列表
|
|||
|
|
*/
|
|||
|
|
QStringList getCameraNames() const;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 重新检测
|
|||
|
|
*/
|
|||
|
|
void ResetDetect(int cameraIndex = 0);
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 启动所有相机检测(依次执行)
|
|||
|
|
*/
|
|||
|
|
void StartAllDetection();
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 停止所有相机检测(完成当前设备后停止)
|
|||
|
|
*/
|
|||
|
|
void StopAllDetection();
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 检查是否正在进行顺序检测
|
|||
|
|
*/
|
|||
|
|
bool IsSequentialDetecting() const { return m_sequentialDetecting; }
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 设置默认相机索引
|
|||
|
|
*/
|
|||
|
|
void SetDefaultCameraIndex(int cameraIndex) { m_currentCameraIndex = cameraIndex; }
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 获取当前默认相机索引
|
|||
|
|
*/
|
|||
|
|
int GetDefaultCameraIndex() const { return m_currentCameraIndex; }
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 静态相机状态回调函数
|
|||
|
|
*/
|
|||
|
|
static void _StaticCameraNotify(EVzDeviceWorkStatus eStatus, void* pExtData, unsigned int nDataLength, void* pInfoParam);
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
// 初始化配置
|
|||
|
|
bool initializeConfig(const QString& configPath);
|
|||
|
|
|
|||
|
|
// 初始化相机
|
|||
|
|
bool initializeCameras();
|
|||
|
|
|
|||
|
|
// 处理扫描数据
|
|||
|
|
void processScanData(std::vector<std::pair<EVzResultDataType, SVzLaserLineData>>& detectionDataCache);
|
|||
|
|
|
|||
|
|
// 根据相机索引获取调平参数
|
|||
|
|
WheelCameraPlaneCalibParam* getPlaneCalibParam(int cameraIndex);
|
|||
|
|
|
|||
|
|
// 相机状态回调处理
|
|||
|
|
void _CameraNotify(EVzDeviceWorkStatus eStatus, void* pExtData, unsigned int nDataLength, void* pInfoParam);
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
IVrWheelMeasureConfig* m_config = nullptr;
|
|||
|
|
WheelMeasureConfigResult m_configResult;
|
|||
|
|
IWheelMeasureStatus* m_statusUpdate = nullptr;
|
|||
|
|
int m_currentCameraIndex = 1; // 默认相机索引(1-based)
|
|||
|
|
|
|||
|
|
// 顺序检测相关
|
|||
|
|
bool m_sequentialDetecting = false; // 是否正在顺序检测所有设备
|
|||
|
|
bool m_stopSequentialRequested = false; // 是否请求停止顺序检测
|
|||
|
|
int m_sequentialCurrentIndex = 0; // 当前顺序检测的设备索引(0-based)
|
|||
|
|
int m_sequentialTotalCount = 0; // 需要顺序检测的设备总数
|
|||
|
|
|
|||
|
|
// 继续检测下一个设备
|
|||
|
|
void continueSequentialDetection();
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
#endif // WHEELMEASUREPRESENTER_H
|