124 lines
5.5 KiB
C++
124 lines
5.5 KiB
C++
// SerialRecvDataHandler.h
|
|
#ifndef SERIALRECVDATAHANDLER_H
|
|
#define SERIALRECVDATAHANDLER_H
|
|
|
|
#include <QObject>
|
|
#include <QByteArray>
|
|
#include <QLabel>
|
|
#include <QGroupBox>
|
|
#include <QJsonDocument>
|
|
#include <QJsonArray>
|
|
#include <QJsonObject>
|
|
#include <QPixmap>
|
|
#include <QBuffer>
|
|
#include <QImage>
|
|
#include <QVBoxLayout>
|
|
#include <QDebug>
|
|
#include <QFile>
|
|
#include <QThread>
|
|
#include <QElapsedTimer>
|
|
#include <QLineEdit>
|
|
#include <QTextEdit>
|
|
|
|
#include "../Media/Media.h"
|
|
#include "../Media/VideoDecoder/FFmpegDecoder.h"
|
|
#include "../LicenseGenerate/LicenseGenerate.h"
|
|
#include "MsgTpye.h"
|
|
|
|
#define YUV420 1
|
|
#define YUV422 2
|
|
|
|
#define BACK_MAC_ADDRESS_LEN 17
|
|
// 打开注册识别取图
|
|
#define REG_AND_VERIFY_GET_PIC 1
|
|
|
|
class SerialDataHandler : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit SerialDataHandler(QLabel* videoLabel, QLabel* video_Label_back, QLineEdit* VideoResolutionEdit, QLineEdit* VideoResolutionEdit_back,
|
|
QSize labelSize, QMap<QString, QLineEdit*>* devInfoLineEdits, int isBackBoardOrAllBoard,
|
|
QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest, QJsonArray frontBoardFuncConfig,
|
|
QJsonArray frontBoardDevInfoJson, QJsonArray frontBoardLicenseJson,
|
|
QJsonArray backBoardOneClickTest, QJsonArray backBoardTest, QJsonArray backBoardFuncConfig,
|
|
QJsonArray backBoardDevInfoJson, QJsonArray backBoardUuidJson,
|
|
QJsonArray getPicJson, QJsonArray getVideoJson, QObject* parent = nullptr);
|
|
~SerialDataHandler();
|
|
|
|
public slots:
|
|
void handleData(const QString& client, const QByteArray& data, int msg_id, int currentRecvItemIndex,
|
|
int currentRecvFuncItemIndex, const QString& itemData, const QString& funcItemData,
|
|
const QJsonArray& jsonArray, int itemJsonIndex, bool timeoutFlag);
|
|
void getCurrentSendItem(const QString& text);
|
|
|
|
void onUpdateTimeout(bool timeoutFlag);
|
|
void handleOpenFocusWindow(int itemIndex);
|
|
signals:
|
|
void statusUpdated(int boardTpye, const QString& clientAddress, bool success, const QJsonArray& jsonArray, int itemJsonIndex);
|
|
void updateLicenseHwInfoEdit(const QString& text);
|
|
void updateUuidHwInfoEdit(const QString& text);
|
|
void updateLeftLensImage(const QPixmap& pixmap);
|
|
void updateRightLensImage(const QPixmap& pixmap);
|
|
void updateVideoLabel(const QPixmap& pixmap);
|
|
void updateVideoResolution(const QString& resolutionText);
|
|
void picRecvFinished();
|
|
void commandError();
|
|
void sendHeartBeatData(const QByteArray& payload, int heartBeat);
|
|
void startTimeout(int timeout);
|
|
void recvNormalDataFlag(bool flag);
|
|
|
|
private:
|
|
QJsonArray frontBoardOneClickTest; // 前板一键功能测试 JSON
|
|
QJsonArray frontBoardTest; // 前板单项测试 JSON
|
|
QJsonArray frontBoardFuncConfig; // 前板功能配置参数 JSON
|
|
QJsonArray frontBoardDevInfoJson; // 前板设备信息参数 JSON
|
|
QJsonArray frontBoardLicenseJson; // 前板license信息 JSON
|
|
QJsonArray backBoardOneClickTest; // 后板一键功能测试 JSON
|
|
QJsonArray backBoardTest; // 后板单项测试 JSON
|
|
QJsonArray backBoardFuncConfig; // 后板功能配置参数 JSON
|
|
QJsonArray backBoardDevInfoJson; // 后板设备信息参数 JSON
|
|
QJsonArray backBoardUuidJson; // 后板UUID和SN参数 JSON
|
|
QJsonArray getDevInfoJson; // 获取设备信息 JSON 配置
|
|
QJsonArray getPicJson; // 发送取图指令 JSON 配置
|
|
QJsonArray getVideoJson; // 发送拉视频指令 JSON 配置
|
|
//QLabel* leftLens_m_imageLabel;
|
|
//QLabel* rightLens_m_imageLabel;
|
|
QLabel* videoLabel;
|
|
QLabel* video_Label_back;
|
|
QLineEdit* VideoResolutionEdit;
|
|
QLineEdit* VideoResolutionEdit_back;
|
|
//QTextEdit* licenseHwInfoEdit;
|
|
QByteArray allRecvData; // 完整的一帧数据
|
|
int remain = 0;
|
|
int start_run = 0;
|
|
long dataLen = 0;
|
|
int isBackBoardOrAllBoard = 0;
|
|
FFmpegDecoder* ffmpegDecoder;
|
|
QByteArray* buffer;
|
|
QByteArray* picBuffer;
|
|
QHash<QString, unsigned char> clientLastMsgId;
|
|
QMap<QString, QLineEdit*>* devInfoLineEdits;
|
|
QMap<int, QString> msgIdToCmdMap;
|
|
QSize labelSize;
|
|
bool isStartVideo = false;
|
|
bool isTimeout = false;
|
|
QString CurrentCommand = "";
|
|
|
|
bool getCommandNameFromValue(int receivedValue);
|
|
QByteArray hexStringToByteArray(const QString& hexString);
|
|
void showVideo(const QString& client, const QByteArray& valData);
|
|
void clearAllRecvData();
|
|
void handleCmd(int msg_id, const QString& client, QByteArray actual_data, const QJsonArray& jsonArray, int itemJsonIndex, bool success);
|
|
void handleFrontCmd(int msg_id, const QString& client, QByteArray actual_data, const QJsonArray& jsonArray, int itemJsonIndex, bool success);
|
|
void handleDevInfo(int msg_id, const QString& client, QByteArray actual_data, const QJsonArray& jsonArray, int itemJsonIndex);
|
|
void initializeMsgIdToCmdMap();
|
|
void updateLineEdit(int msg_id, const QByteArray& actual_data);
|
|
void showPic(QSize labelSize, int lens_n,
|
|
int width, int height, int format, const QByteArray* valData);
|
|
};
|
|
|
|
#endif // SERIALDATAHANDLER_H
|
|
|
|
|