1.调通所有与服务器HTTP连接的接口 2.更新图语License从服务器查询和U盘获取后上报,前板可直接使用产测工具写入License 3.优化接收到前板的H264解码后出现视频卡的问题 4.更新从前板取图后旋转 5.增加ffmpeg解码的视频分辨率获取
This commit is contained in:
@@ -3,13 +3,24 @@
|
||||
#include "../Network/ClientHandler.h"
|
||||
|
||||
DataHandler::DataHandler(QLabel* leftLens_imageLabel, QLabel* rightLens_imageLabel, QLabel* videoLabel,
|
||||
QTextEdit* licenseHwInfoEdit, QMap<QString, QLineEdit*>* devInfoLineEdits, QObject* parent)
|
||||
QTextEdit* licenseHwInfoEdit, QMap<QString, QLineEdit*>* devInfoLineEdits,
|
||||
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)
|
||||
: QObject(parent),
|
||||
leftLens_m_imageLabel(leftLens_imageLabel),
|
||||
rightLens_m_imageLabel(rightLens_imageLabel),
|
||||
videoLabel(videoLabel),
|
||||
licenseHwInfoEdit(licenseHwInfoEdit),
|
||||
devInfoLineEdits(devInfoLineEdits),
|
||||
frontBoardOneClickTest(frontBoardOneClickTest), frontBoardTest(frontBoardTest),
|
||||
frontBoardFuncConfig(frontBoardFuncConfig), frontBoardDevInfoJson(frontBoardDevInfoJson),
|
||||
frontBoardLicenseJson(frontBoardLicenseJson),
|
||||
backBoardOneClickTest(backBoardOneClickTest), backBoardTest(backBoardTest),
|
||||
backBoardFuncConfig(backBoardFuncConfig), backBoardDevInfoJson(backBoardDevInfoJson),
|
||||
backBoardUuidJson(backBoardUuidJson), getPicJson(getPicJson), getVideoJson(getVideoJson),
|
||||
ffmpegDecoder(new FFmpegDecoder()), // 初始化FFmpeg解码器
|
||||
buffer(new QByteArray())
|
||||
{
|
||||
@@ -90,12 +101,12 @@ void DataHandler::clearAllRecvData() {
|
||||
// 处理接收到的数据
|
||||
void DataHandler::handleData(const QString& client, const QByteArray& recvData, int msg_id,
|
||||
int currentRecvItemIndex, int currentRecvFuncItemIndex,
|
||||
const QString& itemData, const QString& funcItemData)
|
||||
const QString& itemData, const QString& funcItemData, const QJsonArray& jsonArray, int itemJsonIndex)
|
||||
{
|
||||
//qDebug() << "Data received from" << client << ":" << recvData;
|
||||
#if 0
|
||||
从文件中读取YUV数据
|
||||
QFile file("output_2.txt");
|
||||
从文件中读取YUV数据
|
||||
QFile file("output_2.txt");
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qWarning() << "Failed to open file:";
|
||||
file.close();
|
||||
@@ -120,29 +131,43 @@ void DataHandler::handleData(const QString& client, const QByteArray& recvData,
|
||||
(static_cast<unsigned char>(buffer->at(8)) << 16) |
|
||||
(static_cast<unsigned char>(buffer->at(7)) << 8) |
|
||||
(static_cast<unsigned char>(buffer->at(6)));
|
||||
//qDebug() << "---Received dataSize:" << dataSize;
|
||||
//qDebug() << "---msg_id:" << QString::number(msg_id, 16).toUpper();
|
||||
//qDebug() << "---(static_cast<unsigned char>(buffer->at(10)):" << static_cast<unsigned char>(buffer->at(10));
|
||||
//qDebug() << "---(static_cast<unsigned char>(buffer->at(11)):" << static_cast<unsigned char>(buffer->at(11));
|
||||
//qDebug() << "---(static_cast<unsigned char>(buffer->at(12)):" << static_cast<unsigned char>(buffer->at(12));
|
||||
//qDebug() << "---(static_cast<unsigned char>(buffer->at(13)):" << static_cast<unsigned char>(buffer->at(13));
|
||||
//qDebug() << "---(static_cast<unsigned char>(buffer->at(14)):" << static_cast<unsigned char>(buffer->at(14));
|
||||
//qDebug() << "---(static_cast<unsigned char>(buffer->at(15)):" << static_cast<unsigned char>(buffer->at(15));
|
||||
// 第11字节为返回 OK/NG
|
||||
bool success = (static_cast<unsigned char>(buffer->at(10)) == 0x00);
|
||||
//int totalSize = 10 + dataSize + 1; // 数据头大小(10字节) + success + 实际数据
|
||||
int totalSize = 10 + dataSize; // 数据头大小(10字节) + 实际数据大小
|
||||
bool success = (static_cast<unsigned char>(buffer->at(10)) == 0x00);
|
||||
int totalSize = 10 + dataSize; // 数据头大小(10字节) + 实际数据大小
|
||||
|
||||
if (buffer->size() >= totalSize) {
|
||||
// 去掉前面 11 字节
|
||||
QByteArray data = buffer->mid(11, dataSize);
|
||||
QByteArray data = buffer->mid(11, dataSize);
|
||||
//QByteArray data = buffer->mid(10, dataSize);
|
||||
QString hexString = QString::fromUtf8(data.toHex().data());
|
||||
QString hexString = QString::fromUtf8(data.toHex().data());
|
||||
QByteArray actual_data = hexStringToByteArray(hexString);
|
||||
//qDebug() << "---Received hexString:" << hexString;
|
||||
buffer->remove(0, totalSize); // 移除已处理的数据
|
||||
// 暂时设置 NG
|
||||
// 同一个client仅当 msg_id 不连续为 0x11/0x21 或第一次处理时才执行 emit statusUpdated
|
||||
if ((msg_id != 0x0011 || clientLastMsgId.value(client, 0) != 0x0011) &&
|
||||
(msg_id != 0x0021 || clientLastMsgId.value(client, 0) != 0x0021)){
|
||||
qDebug() << "Emitting statusUpdated for client:" << client << "with msg_id:" << QString::number(msg_id, 16).toUpper();
|
||||
emit statusUpdated(client, currentRecvItemIndex + 1, currentRecvFuncItemIndex + 1,
|
||||
true, itemData, funcItemData);
|
||||
}
|
||||
clientLastMsgId[client] = msg_id;
|
||||
handleCmd(msg_id, client, actual_data);
|
||||
if(msg_id != 0x0040 && msg_id != START_VIDEO) {
|
||||
//if (msg_id != 0x0040) {
|
||||
qDebug() << "--- msg_id:" << msg_id;
|
||||
qDebug() << "--- clientLastMsgId.value(client, 0):" << clientLastMsgId.value(client, 0);
|
||||
// 同一个client仅当 msg_id 不连续为 0x11/0x21 或第一次处理时才执行 emit statusUpdated
|
||||
if ((msg_id != 0x0011 || clientLastMsgId.value(client, 0) != 0x0011) &&
|
||||
(msg_id != 0x0021 || clientLastMsgId.value(client, 0) != 0x0021) &&
|
||||
(msg_id != START_VIDEO || clientLastMsgId.value(client, 0) != START_VIDEO)) {
|
||||
//qDebug() << "Emitting statusUpdated for client:" << client << "with msg_id:" << QString::number(msg_id, 16).toUpper();
|
||||
emit statusUpdated(client, currentRecvItemIndex + 1, currentRecvFuncItemIndex + 1,
|
||||
true, itemData, funcItemData, jsonArray, itemJsonIndex);
|
||||
}
|
||||
clientLastMsgId[client] = msg_id;
|
||||
qDebug() << "--- client:" << client;
|
||||
qDebug() << "--- clientLastMsgId[client]:" << clientLastMsgId[client];
|
||||
}
|
||||
handleCmd(msg_id, client, actual_data);
|
||||
}
|
||||
else {
|
||||
break; // 数据还不完整,等待下一次接收
|
||||
@@ -154,6 +179,7 @@ void DataHandler::handleData(const QString& client, const QByteArray& recvData,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DataHandler::initializeMsgIdToCmdMap() {
|
||||
msgIdToCmdMap[GET_FRONT_V851_VERSION] = "GET_FRONT_V851_VERSION";
|
||||
msgIdToCmdMap[GET_FRONT_MCU_VERSION] = "GET_FRONT_MCU_VERSION";
|
||||
@@ -256,12 +282,12 @@ void DataHandler::handleFrontCmd(int msg_id, const QString& client, QByteArray a
|
||||
break;
|
||||
case GET_IMG:
|
||||
{
|
||||
|
||||
showPic(leftLens_m_imageLabel, rightLens_m_imageLabel, client, actual_data);
|
||||
}
|
||||
break;
|
||||
case START_VIDEO:
|
||||
{
|
||||
|
||||
showVideo(client, actual_data);
|
||||
}
|
||||
break;
|
||||
case STOP_VIDEO:
|
||||
|
||||
@@ -34,18 +34,38 @@ class DataHandler : public QObject
|
||||
|
||||
public:
|
||||
explicit DataHandler(QLabel* leftLens_imageLabel, QLabel* rightLens_imageLabel, QLabel* videoLabel,
|
||||
QTextEdit* licenseHwInfoEdit, QMap<QString, QLineEdit*>* devInfoLineEdits, QObject* parent = nullptr);
|
||||
QTextEdit* licenseHwInfoEdit, QMap<QString, QLineEdit*>* devInfoLineEdits,
|
||||
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);
|
||||
~DataHandler();
|
||||
|
||||
public slots:
|
||||
void handleData(const QString& client, const QByteArray& data, int msg_id, int currentRecvItemIndex,
|
||||
int currentRecvFuncItemIndex, const QString& itemData, const QString& funcItemData);
|
||||
int currentRecvFuncItemIndex, const QString& itemData, const QString& funcItemData,
|
||||
const QJsonArray& jsonArray, int itemJsonIndex);
|
||||
|
||||
signals:
|
||||
void statusUpdated(const QString& clientAddress, int currentItemIndex, int currentFuncItemIndex,
|
||||
bool success, const QString& currentItemLabel, const QString& currentFuncItemLabel);
|
||||
bool success, const QString& currentItemLabel, const QString& currentFuncItemLabel,
|
||||
const QJsonArray& jsonArray, int itemJsonIndex);
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user