100 lines
2.8 KiB
C++
100 lines
2.8 KiB
C++
#ifndef BELTTEARINGPRESENTER_H
|
|
#define BELTTEARINGPRESENTER_H
|
|
|
|
#include <QObject>
|
|
#include <QTcpServer>
|
|
#include <QTcpSocket>
|
|
#include <QTimer>
|
|
#include <QMap>
|
|
#include <opencv2/opencv.hpp>
|
|
#include "IVrEyeDevice.h"
|
|
#include "BeltTearingAlgo.h"
|
|
#include "beltTearingDetection_Export.h"
|
|
#include "IVrBeltTearingConfig.h"
|
|
#include "VZNL_Common.h"
|
|
#include "VZNL_Types.h"
|
|
#include "VrLog.h"
|
|
|
|
// 假设ByteDataType枚举定义
|
|
enum class ByteDataType : quint8 {
|
|
Text = 1,
|
|
Image = 2
|
|
};
|
|
|
|
class BeltTearingPresenter : public QObject, public IVrBeltTearingConfigChangeNotify
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit BeltTearingPresenter(QObject *parent = nullptr);
|
|
~BeltTearingPresenter();
|
|
|
|
// 配置相关方法
|
|
bool loadConfiguration(const QString& configFilePath);
|
|
void applyAlgorithmParameters(const BeltTearingAlgorithmParams& params);
|
|
|
|
// 初始化TCP服务器
|
|
bool startServer(quint16 port = 0); // port = 0 表示使用配置文件中的端口
|
|
void stopServer();
|
|
|
|
// 相机相关方法
|
|
bool initializeCamera();
|
|
void startCamera();
|
|
void stopCamera();
|
|
|
|
// 获取配置信息
|
|
quint16 getServerPort() const { return m_configResult.serverPort; }
|
|
const BeltTearingConfigResult& getConfig() const { return m_configResult; }
|
|
|
|
// 获取版本信息
|
|
static QString getVersionString();
|
|
static QString getProductName();
|
|
static QString getBuildInfo();
|
|
|
|
// IVrBeltTearingConfigChangeNotify接口实现
|
|
void OnConfigChanged(const BeltTearingConfigResult& configResult) override;
|
|
|
|
private slots:
|
|
void onNewConnection();
|
|
void onClientDisconnected();
|
|
void onCameraInitTimer();
|
|
|
|
private:
|
|
// TCP服务器相关
|
|
QTcpServer *m_tcpServer;
|
|
QMap<QString, QTcpSocket*> m_clients;
|
|
quint16 m_port;
|
|
|
|
// 配置相关
|
|
IVrBeltTearingConfig *m_config;
|
|
BeltTearingConfigResult m_configResult;
|
|
QString m_configFilePath;
|
|
|
|
// 相机相关
|
|
IVrEyeDevice *m_eyeDevice;
|
|
QTimer *m_cameraInitTimer;
|
|
QString m_cameraIP;
|
|
bool m_cameraInitialized;
|
|
bool m_cameraDetecting;
|
|
|
|
// 算法相关
|
|
BeltTearingAlgo *m_beltTearingAlgo;
|
|
|
|
// 相机状态回调函数
|
|
static void OnStatusCallback(EVzDeviceWorkStatus eStatus, void* pExtData, unsigned int nDataLength, void* pInfoParam);
|
|
|
|
// 点云数据回调函数
|
|
static void OnPointCloudCallback(EVzResultDataType eDataType, SVzLaserLineData* pLaserLinePoint, void* pParam);
|
|
|
|
// 处理点云数据
|
|
void processPointCloudData(const SVzLaserLineData* pLaserLine);
|
|
|
|
// 发送算法结果
|
|
void sendTearingResults(const std::vector<SSG_beltTearingInfo>& results);
|
|
|
|
// 工具方法
|
|
QString generateClientId(QTcpSocket *socket);
|
|
};
|
|
|
|
#endif // BELTTEARINGPRESENTER_H
|