#ifndef BELTTEARINGPRESENTER_H #define BELTTEARINGPRESENTER_H #include #include #include #include #include #include // 假设ByteDataType枚举定义 enum class ByteDataType : quint8 { Text = 1, Image = 2 }; class BeltTearingPresenter : public QObject { Q_OBJECT public: explicit BeltTearingPresenter(QObject *parent = nullptr); ~BeltTearingPresenter(); // 初始化TCP服务器 bool startServer(quint16 port); void stopServer(); // 模拟数据发送 void startSendingSimulatedData(); void stopSendingSimulatedData(); private slots: void onNewConnection(); void onClientDisconnected(); void onSendSimulatedData(); private: QTcpServer *m_tcpServer; QMap m_clients; QTimer *m_dataTimer; quint16 m_port; // 模拟数据发送方法 void sendSimulatedImage(QTcpSocket *socket); void sendSimulatedLogRecords(QTcpSocket *socket); void sendSimulatedTearingData(QTcpSocket *socket); QString generateClientId(QTcpSocket *socket); }; #endif // BELTTEARINGPRESENTER_H