53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
#pragma once
|
||
|
||
#include <QObject>
|
||
#include <QString>
|
||
#include <functional>
|
||
#include <memory>
|
||
#include "IVrConfig.h"
|
||
#include "RobotPose6D.h"
|
||
|
||
using DetectionTriggerCallback = std::function<void(int cameraIndex, DetectionType type, const RobotPose6D& robotPose)>;
|
||
|
||
/**
|
||
* @brief DiscHolePose TCP 文本协议(PIMPL 模式)
|
||
*
|
||
* 协议格式:
|
||
* - 请求: D1_X_Y_Z_A_B_C 表示 disc hole 检测
|
||
* - 请求: R1_X_Y_Z_A_B_C 表示 disc rack 检测
|
||
* - 响应: count_AX_AY_AZ_A_B_C_X_Y_Z_A_B_C
|
||
* (12 个浮点:先接近点,后目标点,姿态相同)
|
||
*
|
||
* 内部持有 IYTCPServer 生命周期与行缓冲,通过回调驱动 QObject 信号。
|
||
*/
|
||
class DiscHolePoseTCPProtocol : public QObject
|
||
{
|
||
Q_OBJECT
|
||
|
||
public:
|
||
explicit DiscHolePoseTCPProtocol(QObject* parent = nullptr);
|
||
~DiscHolePoseTCPProtocol();
|
||
|
||
bool StartServer(uint16_t port);
|
||
void StopServer();
|
||
bool IsConnected() const;
|
||
|
||
void SetDetectionTriggerCallback(DetectionTriggerCallback callback);
|
||
void SendResult(const QString& resultText);
|
||
|
||
signals:
|
||
void ConnectionChanged(bool connected);
|
||
void DataReceived(const QString& data);
|
||
void DetectionTriggered(int cameraIndex, DetectionType type, const RobotPose6D& robotPose);
|
||
|
||
private slots:
|
||
void OnNewConnection();
|
||
void OnDisconnected();
|
||
void OnReadyRead(const QByteArray& data);
|
||
|
||
private:
|
||
void ProcessCommand(const QString& command);
|
||
class Impl;
|
||
std::unique_ptr<Impl> m_pImpl;
|
||
};
|