1.增加整机测试工厂信息输入; 2. 增加前后板连接后自动发送获取设备版本信息指令; 3. 优化UI布局代码
This commit is contained in:
@@ -75,7 +75,7 @@ void ClientHandler::resetCurrentItemIndex()
|
||||
void ClientHandler::start()
|
||||
{
|
||||
resetCurrentItemIndex(); // 初始化计数器和索引
|
||||
sendNextItem();
|
||||
//sendNextItem();
|
||||
}
|
||||
|
||||
// 处理客户端断开连接
|
||||
@@ -91,7 +91,7 @@ void ClientHandler::startReadVideoDataTimer(int client_Id)
|
||||
{
|
||||
//emit startReadTimer(clientId);
|
||||
emit startReadTimer(client_Id);
|
||||
//qDebug() << "------ startClientReadTimer clientId:" << clientId;
|
||||
qDebug() << "------ startClientReadTimer clientId:" << clientId;
|
||||
}
|
||||
|
||||
void ClientHandler::stopReadVideoDataTimer(int client_Id)
|
||||
@@ -175,21 +175,40 @@ void ClientHandler::sendDataToClient(const QByteArray& data)
|
||||
emit sendData(data, isBackBoardOrAllBoard);
|
||||
}
|
||||
|
||||
void ClientHandler::sendJsonItem(const QJsonArray& jsonArray, int itemIndex, const QString text, const QString& itemType)
|
||||
void ClientHandler::sendJsonItem(const QJsonArray& jsonArray, int itemIndex, const QString text, const QString backBoardSn, const QString& itemType)
|
||||
{
|
||||
startReadVideoDataTimer(preVideoClientId);
|
||||
currentJson = jsonArray;
|
||||
currentJsonItem = itemIndex;
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
if (itemType == "License") {
|
||||
|
||||
}
|
||||
isSingleSend = true;
|
||||
isClickedSend = true;
|
||||
isRecvImgData = false;
|
||||
if (jsonArray == backBoardTest) {
|
||||
QJsonObject tempItem = jsonArray[itemIndex].toObject();
|
||||
if (tempItem["cmd"] == "VIDEO_TEST") {
|
||||
if (tempItem["val"] == 0) {
|
||||
isSingleSend = false;
|
||||
isClickedSend = false;
|
||||
isRecvVideoData = true;
|
||||
isStartVideo = true;
|
||||
startReadVideoDataTimer(isBackBoardOrAllBoard);
|
||||
}
|
||||
else if (tempItem["val"] == 1) {
|
||||
isRecvVideoData = false;
|
||||
isStartVideo = false;
|
||||
stopReadVideoDataTimer(isBackBoardOrAllBoard);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (itemType == "handleVideo") {
|
||||
if (itemIndex == 0) {
|
||||
isSingleSend = false;
|
||||
isClickedSend = false;
|
||||
isClickedSend = false;
|
||||
}
|
||||
else {
|
||||
stopReadVideoDataTimer(preVideoClientId);
|
||||
@@ -200,12 +219,15 @@ void ClientHandler::sendJsonItem(const QJsonArray& jsonArray, int itemIndex, con
|
||||
isClickedSend = false;
|
||||
isRecvImgData = true;
|
||||
}
|
||||
//qDebug() << "itemIndex:" << itemIndex;
|
||||
//qDebug() << "jsonArray.size():" << jsonArray.size();
|
||||
if (itemType == "Uuid") {
|
||||
|
||||
}
|
||||
qDebug() << "itemIndex:" << itemIndex;
|
||||
qDebug() << "jsonArray.size():" << jsonArray.size();
|
||||
if (itemIndex >= 0 && itemIndex < jsonArray.size()) {
|
||||
currentItemIndex = (itemType == "test") ? itemIndex : 0;
|
||||
currentFuncItemIndex = (itemType == "func") ? itemIndex : 0;
|
||||
QJsonObject currentItem = jsonArray[itemIndex].toObject();
|
||||
currentItem = jsonArray[itemIndex].toObject();
|
||||
if (!text.isEmpty() && currentItem.contains("val")) {
|
||||
QJsonValue originalValue = currentItem["val"];
|
||||
qDebug() << "text:" << text;
|
||||
@@ -223,12 +245,47 @@ void ClientHandler::sendJsonItem(const QJsonArray& jsonArray, int itemIndex, con
|
||||
currentItem["val"] = text;
|
||||
}
|
||||
}
|
||||
else if (!text.isEmpty() && currentItem.contains("UUID") && currentItem.contains("SN")) {
|
||||
QJsonValue originalUUID = currentItem["UUID"];
|
||||
QJsonValue originalSN = currentItem["SN"];
|
||||
qDebug() << "UUID:" << text;
|
||||
qDebug() << "SN:" << backBoardSn;
|
||||
if (originalUUID.isDouble()) {
|
||||
bool ok;
|
||||
double doubleValue = text.toDouble(&ok);
|
||||
if (ok) {
|
||||
currentItem["UUID"] = doubleValue;
|
||||
}
|
||||
else {
|
||||
qWarning() << "Text conversion to double failed, original value is kept.";
|
||||
}
|
||||
}
|
||||
else if (originalUUID.isString()) {
|
||||
currentItem["UUID"] = text;
|
||||
}
|
||||
if (originalSN.isDouble()) {
|
||||
bool ok;
|
||||
double doubleValue = backBoardSn.toDouble(&ok);
|
||||
if (ok) {
|
||||
currentItem["SN"] = doubleValue;
|
||||
}
|
||||
else {
|
||||
qWarning() << "backBoardSn conversion to double failed, original value is kept.";
|
||||
}
|
||||
}
|
||||
else if (originalSN.isString()) {
|
||||
currentItem["SN"] = backBoardSn;
|
||||
}
|
||||
}
|
||||
QString itemData = QJsonDocument(currentItem).toJson();
|
||||
//emit sendData(itemData.toUtf8());
|
||||
emit sendDataToSomeClient(controlClientId, itemData.toUtf8());
|
||||
|
||||
// 设置超时处理
|
||||
if (isBackBoardOrAllBoard) {
|
||||
emit sendDataToSomeClient(isBackBoardOrAllBoard, itemData.toUtf8());
|
||||
}
|
||||
else {
|
||||
emit sendDataToSomeClient(controlClientId, itemData.toUtf8());
|
||||
}
|
||||
if (currentItem.contains("timeout")) {
|
||||
qDebug() << "sendJsonItem currentItem.contains(\"timeout\")";
|
||||
int timeout = currentItem.value("timeout").toInt();
|
||||
if (timeout > 0) {
|
||||
emit startTimeout(timeout);
|
||||
@@ -240,13 +297,13 @@ void ClientHandler::sendJsonItem(const QJsonArray& jsonArray, int itemIndex, con
|
||||
// 发送获取设备信息按键
|
||||
void ClientHandler::sendGetDevInfoItem(int itemIndex)
|
||||
{
|
||||
sendJsonItem(getDevInfoJson, itemIndex, "", "devInfo");
|
||||
sendJsonItem(getDevInfoJson, itemIndex, "", "", "devInfo");
|
||||
}
|
||||
|
||||
// 发送取图按键
|
||||
void ClientHandler::sendGetPicItem(int itemIndex, int GetPicCamIndex)
|
||||
{
|
||||
sendJsonItem(getPicJson, itemIndex, QString::number(GetPicCamIndex), "getPic");
|
||||
sendJsonItem(getPicJson, itemIndex, QString::number(GetPicCamIndex), "", "getPic");
|
||||
}
|
||||
|
||||
// 发送拉视频按键
|
||||
@@ -254,122 +311,162 @@ void ClientHandler::sendGetVideoItem(int itemIndex, int GetVideoCamIndex)
|
||||
{
|
||||
qDebug() << "sendGetVideoItem itemIndex:" << itemIndex;
|
||||
if(isBackBoardOrAllBoard) {
|
||||
sendJsonItem(getVideoJson, itemIndex, QString::number(GetVideoCamIndex), "handleVideo");
|
||||
sendJsonItem(getVideoJson, itemIndex, QString::number(GetVideoCamIndex), "", "handleVideo");
|
||||
}
|
||||
else {
|
||||
sendJsonItem(getVideoJson, itemIndex, QString::number(GetVideoCamIndex), "handleVideo");
|
||||
sendJsonItem(getVideoJson, itemIndex, QString::number(GetVideoCamIndex), "", "handleVideo");
|
||||
}
|
||||
}
|
||||
|
||||
// 发送License处理按键
|
||||
void ClientHandler::sendLicenseItem(int itemIndex, const QString text)
|
||||
{
|
||||
if (itemIndex < 0 || itemIndex >= frontBoardLicenseJson.size()) {
|
||||
qDebug() << "Invalid itemIndex";
|
||||
if (isBackBoardOrAllBoard != 0) {
|
||||
emit HandleInvalidOperate("当前连接的是后板或整机,请勿操作前板页面的按键!!!");
|
||||
return;
|
||||
}
|
||||
sendJsonItem(frontBoardLicenseJson, itemIndex, text, "License");
|
||||
else {
|
||||
if (itemIndex < 0 || itemIndex >= frontBoardLicenseJson.size()) {
|
||||
qDebug() << "Invalid itemIndex";
|
||||
return;
|
||||
}
|
||||
sendJsonItem(frontBoardLicenseJson, itemIndex, text, "", "License");
|
||||
}
|
||||
}
|
||||
|
||||
void ClientHandler::sendUuidItem(int itemIndex, const QString text)
|
||||
void ClientHandler::sendUuidItem(int itemIndex, const QString backBoardUuid, const QString backBoardSn)
|
||||
{
|
||||
|
||||
qDebug() << "ClientHandler::sendUuidItem itemIndex:" << itemIndex;
|
||||
if (isBackBoardOrAllBoard == 0) {
|
||||
emit HandleInvalidOperate("当前连接的是前板,请勿操作后板或整机页面的按键!!!");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (itemIndex < 0 || itemIndex >= backBoardUuidJson.size()) {
|
||||
qDebug() << "Invalid itemIndex";
|
||||
return;
|
||||
}
|
||||
sendJsonItem(backBoardUuidJson, itemIndex, backBoardUuid, backBoardSn, "Uuid");
|
||||
}
|
||||
}
|
||||
|
||||
// 发送单独一个功能配置 JSON 项目
|
||||
void ClientHandler::sendFrontFuncItem(int itemIndex, const QString text)
|
||||
{
|
||||
//qDebug() << "sendFuncItem Text:" << text;
|
||||
sendJsonItem(frontBoardFuncConfig, itemIndex, text, "func");
|
||||
if (isBackBoardOrAllBoard != 0) {
|
||||
emit HandleInvalidOperate("当前连接的是后板或整机,请勿操作前板页面的按键!!!");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
//qDebug() << "sendFuncItem Text:" << text;
|
||||
sendJsonItem(frontBoardFuncConfig, itemIndex, text, "", "func");
|
||||
}
|
||||
}
|
||||
|
||||
void ClientHandler::sendBackFuncItem(int itemIndex, const QString text)
|
||||
{
|
||||
//qDebug() << "sendFuncItem Text:" << text;
|
||||
sendJsonItem(backBoardFuncConfig, itemIndex, text, "func");
|
||||
if (isBackBoardOrAllBoard == 0) {
|
||||
emit HandleInvalidOperate("当前连接的是前板,请勿操作后板或整机页面的按键!!!");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
//qDebug() << "sendFuncItem Text:" << text;
|
||||
sendJsonItem(backBoardFuncConfig, itemIndex, text, "", "func");
|
||||
}
|
||||
}
|
||||
|
||||
// 发送单独一个测试配置 JSON 项目
|
||||
void ClientHandler::sendFrontItem(int itemIndex)
|
||||
{
|
||||
QString text = "";
|
||||
QJsonObject currentItem = frontBoardTest[itemIndex].toObject();
|
||||
if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "IMG_ENROLL") {
|
||||
ImageEnrollWindow dialog;
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
text = dialog.getFilePath();
|
||||
QByteArray imageData = dialog.getImageData();
|
||||
if (!imageData.isEmpty()) {
|
||||
text = QString::fromUtf8(imageData);
|
||||
if (isBackBoardOrAllBoard != 0) {
|
||||
emit HandleInvalidOperate("当前连接的是后板或整机,请勿操作前板页面的按键!!!");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
QString text = "";
|
||||
QJsonObject currentItem = frontBoardTest[itemIndex].toObject();
|
||||
if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "IMG_ENROLL") {
|
||||
ImageEnrollWindow dialog;
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
text = dialog.getFilePath();
|
||||
QByteArray imageData = dialog.getImageData();
|
||||
if (!imageData.isEmpty()) {
|
||||
text = QString::fromUtf8(imageData);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "DEL_USER") {
|
||||
DelUserWindow dialog;
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
QString userInput = dialog.getUserInput();
|
||||
if (!userInput.isEmpty() && currentItem.contains("val")) {
|
||||
text = userInput;
|
||||
else if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "DEL_USER") {
|
||||
DelUserWindow dialog;
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
QString userInput = dialog.getUserInput();
|
||||
if (!userInput.isEmpty() && currentItem.contains("val")) {
|
||||
text = userInput;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return;
|
||||
else if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "PASSWD_ENROLL") {
|
||||
PasswordEnrollWindow dialog;
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
text = dialog.getPassword();
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
sendJsonItem(frontBoardTest, itemIndex, text, "", "test");
|
||||
}
|
||||
else if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "PASSWD_ENROLL") {
|
||||
PasswordEnrollWindow dialog;
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
text = dialog.getPassword();
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
sendJsonItem(frontBoardTest, itemIndex, text, "test");
|
||||
}
|
||||
|
||||
void ClientHandler::sendBackItem(int itemIndex)
|
||||
{
|
||||
QString text = "";
|
||||
QJsonObject currentItem = backBoardTest[itemIndex].toObject();
|
||||
if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "IMG_ENROLL") {
|
||||
ImageEnrollWindow dialog;
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
text = dialog.getFilePath();
|
||||
QByteArray imageData = dialog.getImageData();
|
||||
if (!imageData.isEmpty()) {
|
||||
text = QString::fromUtf8(imageData);
|
||||
if (isBackBoardOrAllBoard == 0) {
|
||||
emit HandleInvalidOperate("当前连接的是前板,请勿操作后板或整机页面的按键!!!");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
QString text = "";
|
||||
QJsonObject currentItem = backBoardTest[itemIndex].toObject();
|
||||
if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "IMG_ENROLL") {
|
||||
ImageEnrollWindow dialog;
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
text = dialog.getFilePath();
|
||||
QByteArray imageData = dialog.getImageData();
|
||||
if (!imageData.isEmpty()) {
|
||||
text = QString::fromUtf8(imageData);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "DEL_USER") {
|
||||
DelUserWindow dialog;
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
QString userInput = dialog.getUserInput();
|
||||
if (!userInput.isEmpty() && currentItem.contains("val")) {
|
||||
text = userInput;
|
||||
else if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "DEL_USER") {
|
||||
DelUserWindow dialog;
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
QString userInput = dialog.getUserInput();
|
||||
if (!userInput.isEmpty() && currentItem.contains("val")) {
|
||||
text = userInput;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return;
|
||||
else if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "PASSWD_ENROLL") {
|
||||
PasswordEnrollWindow dialog;
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
text = dialog.getPassword();
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
isRecvVideoData = false;
|
||||
sendJsonItem(backBoardTest, itemIndex, text, "", "test");
|
||||
}
|
||||
else if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "PASSWD_ENROLL") {
|
||||
PasswordEnrollWindow dialog;
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
text = dialog.getPassword();
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
sendJsonItem(backBoardTest, itemIndex, text, "test");
|
||||
}
|
||||
|
||||
void ClientHandler::sendDevInfoJsonItem(const QJsonObject& jsonItem, int itemIndex)
|
||||
@@ -381,7 +478,13 @@ void ClientHandler::sendDevInfoJsonItem(const QJsonObject& jsonItem, int itemInd
|
||||
|
||||
QString itemData = QJsonDocument(jsonItem).toJson();
|
||||
//emit sendData(itemData.toUtf8());
|
||||
emit sendDataToSomeClient(controlClientId, itemData.toUtf8());
|
||||
if (isBackBoardOrAllBoard) {
|
||||
emit sendDataToSomeClient(isBackBoardOrAllBoard, itemData.toUtf8());
|
||||
}
|
||||
else {
|
||||
emit sendDataToSomeClient(controlClientId, itemData.toUtf8());
|
||||
}
|
||||
|
||||
|
||||
if (jsonItem.contains("timeout")) {
|
||||
int timeout = jsonItem.value("timeout").toInt();
|
||||
@@ -396,58 +499,60 @@ void ClientHandler::sendDevInfoJsonItem(const QJsonObject& jsonItem, int itemInd
|
||||
|
||||
void ClientHandler::sendDevInfoItem()
|
||||
{
|
||||
// 前板
|
||||
if (1) {
|
||||
qDebug() << "frontBoardDevInfoJson.size():" << frontBoardDevInfoJson.size();
|
||||
if (currentFrontBoardIndex < frontBoardDevInfoJson.size()) {
|
||||
sendDevInfoJsonItem(frontBoardDevInfoJson[currentFrontBoardIndex].toObject(), 1);
|
||||
currentFrontBoardIndex ++;
|
||||
if (isBackBoardOrAllBoard) {
|
||||
currentJson = backBoardDevInfoJson;
|
||||
currentJsonItem = currentBackBoardIndex;
|
||||
if (currentBackBoardIndex < backBoardDevInfoJson.size()) {
|
||||
sendDevInfoJsonItem(backBoardDevInfoJson[currentBackBoardIndex++].toObject(), 1);
|
||||
}
|
||||
else
|
||||
isPowerOnSend = false;
|
||||
|
||||
}
|
||||
// 后板
|
||||
else {
|
||||
if (currentBackBoardIndex < backBoardDevInfoJson.size()) {
|
||||
sendDevInfoJsonItem(backBoardDevInfoJson[currentBackBoardIndex ++].toObject(), 1);
|
||||
currentJson = frontBoardDevInfoJson;
|
||||
currentJsonItem = currentFrontBoardIndex;
|
||||
if (currentFrontBoardIndex < frontBoardDevInfoJson.size()) {
|
||||
sendDevInfoJsonItem(frontBoardDevInfoJson[currentFrontBoardIndex].toObject(), 1);
|
||||
currentFrontBoardIndex++;
|
||||
}
|
||||
else
|
||||
isPowerOnSend = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 发送下一个 JSON 项目
|
||||
void ClientHandler::sendNextItem()
|
||||
void ClientHandler::sendNextItem(QJsonArray& currentOneClickedItem)
|
||||
{
|
||||
//qDebug() << "------> start mutex :" << __FUNCTION__;
|
||||
QMutexLocker locker(&mutex);
|
||||
QMutexLocker locker(&mutex);
|
||||
isClickedSend = true;
|
||||
qDebug() << "------> locker(&mutex) :" << itemsProcessedCount;
|
||||
if (currentItemIndex < frontBoardOneClickTest.size()) {
|
||||
currentJson = frontBoardOneClickTest;
|
||||
//qDebug() << "------> locker(&mutex) :" << itemsProcessedCount;
|
||||
//qDebug() << "------> currentItemIndex :" << currentItemIndex;
|
||||
//qDebug() << "------> currentOneClickedItem.size() :" << currentOneClickedItem.size();
|
||||
if (currentItemIndex < currentOneClickedItem.size()) {
|
||||
currentJson = currentOneClickedItem;
|
||||
currentJsonItem = currentItemIndex;
|
||||
|
||||
currentItem = frontBoardOneClickTest[currentItemIndex].toObject();
|
||||
currentItem = currentOneClickedItem[currentItemIndex].toObject();
|
||||
QString itemData = QJsonDocument(currentItem).toJson();
|
||||
//qDebug() << "Sending item index:" << currentItemIndex << "data:" << itemData;
|
||||
if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "DEL_USER") {
|
||||
if (currentItem.contains("cmd") && currentItem["cmd"].toString() == "DEL_USER") {
|
||||
DelUserWindow dialog;
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
//qDebug() << "用户确认删除,关闭窗口";
|
||||
QString userInput = dialog.getUserInput();
|
||||
if (!userInput.isEmpty() && currentItem.contains("val")) {
|
||||
currentItem["val"] = userInput;
|
||||
itemData = QJsonDocument(currentItem).toJson();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//emit sendData(itemData.toUtf8());
|
||||
emit sendDataToSomeClient(controlClientId, itemData.toUtf8());
|
||||
|
||||
if (isBackBoardOrAllBoard) {
|
||||
emit sendDataToSomeClient(isBackBoardOrAllBoard, itemData.toUtf8());
|
||||
}
|
||||
else {
|
||||
emit sendDataToSomeClient(controlClientId, itemData.toUtf8());
|
||||
}
|
||||
if (currentItem.contains("timeout")) {
|
||||
int timeout = currentItem.value("timeout").toInt();
|
||||
if (timeout > 0) {
|
||||
qDebug() << "------> sendNextItem :" << itemsProcessedCount;
|
||||
emit startTimeout(timeout);
|
||||
}
|
||||
}
|
||||
@@ -458,12 +563,11 @@ void ClientHandler::sendNextItem()
|
||||
else if (isManualSend) {
|
||||
emit allItemsProcessed(getClientAddress(), itemsProcessedCount);
|
||||
// 处理完毕后重置标记
|
||||
isManualSend = false;
|
||||
isManualSend = false;
|
||||
isClickedSend = false;
|
||||
// 重置索引,可以再次一键功能测试
|
||||
// 重置索引
|
||||
resetCurrentItemIndex();
|
||||
}
|
||||
//qDebug() << "------> end mutex :" << __FUNCTION__;
|
||||
}
|
||||
|
||||
void ClientHandler::RNDISClient1Data(QByteArray& data) {
|
||||
@@ -570,7 +674,16 @@ void ClientHandler::setThreadPriority(QThread::Priority priority) {
|
||||
}
|
||||
}
|
||||
|
||||
// 处理数据接收
|
||||
void ClientHandler::onPicRecvFinished()
|
||||
{
|
||||
if (currentJson != getPicJson && currentJson != frontBoardTest) {
|
||||
currentItemIndex ++;
|
||||
itemsProcessedCount ++;
|
||||
qDebug() << "------> onPicRecvFinished :" << __FUNCTION__;
|
||||
sendNextItem(currentJson);
|
||||
}
|
||||
}
|
||||
|
||||
void ClientHandler::onDataReceived()
|
||||
{
|
||||
//qDebug() << "isRecvVideoData:" << isRecvVideoData;
|
||||
@@ -578,8 +691,10 @@ void ClientHandler::onDataReceived()
|
||||
//qDebug() << "isClickedSend:" << isClickedSend;
|
||||
//qDebug() << "isSingleSend:" << isSingleSend;
|
||||
//qDebug() << "isRecvImgData:" << isRecvImgData;
|
||||
/*if (!isRecvVideoData &&
|
||||
(isRecvImgData || isPowerOnSend || isClickedSend || (isSingleSend && (currentItemIndex < frontBoardTest.size())))) {*/
|
||||
if (!isRecvVideoData &&
|
||||
(isRecvImgData || isPowerOnSend || isClickedSend || (isSingleSend && (currentItemIndex < frontBoardTest.size())))) {
|
||||
(isRecvImgData || isPowerOnSend || isClickedSend || (isSingleSend && (currentItemIndex < currentJson.size())))) {
|
||||
QByteArray allData;
|
||||
while (socket->bytesAvailable() > 0) {
|
||||
qint64 bytesAvailableBefore = socket->bytesAvailable();
|
||||
@@ -593,59 +708,72 @@ void ClientHandler::onDataReceived()
|
||||
qint64 bytesAvailableAfter = socket->bytesAvailable();
|
||||
}
|
||||
}
|
||||
getCurrentItemLable();
|
||||
if ((currentItem.contains("timeout")) || (currentFuncItem.contains("timeout"))) {
|
||||
emit startTimeout(0);
|
||||
}
|
||||
QJsonObject currentTempItem = currentJson[currentItemIndex].toObject();
|
||||
if (!allData.isEmpty()) {
|
||||
emit dataReceived(getClientAddress(), allData, 0xFF, currentItemIndex, currentFuncItemIndex, getCurrentItemLable(), "", currentJson, currentJsonItem);
|
||||
if (!isSingleSend && !isPowerOnSend) {
|
||||
if (!isSingleSend && !isPowerOnSend && (currentTempItem["cmd"] != "GET_IMG")) {
|
||||
currentItemIndex ++;
|
||||
itemsProcessedCount ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isSingleSend) {
|
||||
isSingleSend = false;
|
||||
if (currentTempItem["cmd"] != "GET_IMG") {
|
||||
isSingleSend = false;
|
||||
}
|
||||
isClickedSend = false;
|
||||
}
|
||||
else if (isPowerOnSend && currentFrontBoardIndex < frontBoardDevInfoJson.size()) {
|
||||
sendDevInfoItem();
|
||||
else if (isPowerOnSend) {
|
||||
if (isBackBoardOrAllBoard) {
|
||||
if (currentBackBoardIndex < backBoardDevInfoJson.size()) {
|
||||
sendDevInfoItem();
|
||||
}
|
||||
else {
|
||||
qDebug() << "All items processed in onDataReceived.";
|
||||
emit allItemsProcessed(getClientAddress(), currentBackBoardIndex);
|
||||
isPowerOnSend = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (currentFrontBoardIndex < frontBoardDevInfoJson.size()) {
|
||||
sendDevInfoItem();
|
||||
}
|
||||
else {
|
||||
qDebug() << "All items processed in onDataReceived.";
|
||||
emit allItemsProcessed(getClientAddress(), currentFrontBoardIndex);
|
||||
isPowerOnSend = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isPowerOnSend && currentBackBoardIndex < backBoardDevInfoJson.size()) {
|
||||
sendDevInfoItem();
|
||||
}
|
||||
/*else if (isPowerOnSend) {
|
||||
qDebug() << "All items processed in onDataReceived.";
|
||||
emit allItemsProcessed(getClientAddress(), currentFrontBoardIndex);
|
||||
isPowerOnSend = false;
|
||||
}*/
|
||||
else if (isClickedSend && (currentItemIndex < frontBoardOneClickTest.size())) {
|
||||
//qDebug() << "-------- start sendNextItem";
|
||||
sendNextItem();
|
||||
else if (isClickedSend && (currentItemIndex < currentJson.size())) {
|
||||
// 判断是否是取图或者其他会接收很多数据的指令
|
||||
if (currentTempItem["cmd"] != "GET_IMG") {
|
||||
sendNextItem(currentJson);
|
||||
}
|
||||
}
|
||||
else if(isClickedSend) {
|
||||
//qDebug() << "All items processed in onDataReceived.";
|
||||
emit allItemsProcessed(getClientAddress(), itemsProcessedCount);
|
||||
isClickedSend = false;
|
||||
//resetCurrentItemIndex();
|
||||
}
|
||||
//qDebug() << "" << __FUNCTION__ << "------> itemsProcessedCount :" << itemsProcessedCount;
|
||||
}
|
||||
// 接收视频流数据 isRecvVideoData 置 0
|
||||
else if (isRecvVideoData && (!dataProcessingActive)) {
|
||||
dataProcessingActive = true;
|
||||
if (!isStartVideo) {
|
||||
isRecvVideoData = false;
|
||||
if ((isBackBoardOrAllBoard == 0) && !isStartVideo) {
|
||||
isRecvVideoData = false;
|
||||
}
|
||||
QTimer::singleShot(0, this, &ClientHandler::processPendingData);
|
||||
}
|
||||
else if(!isRecvVideoData && !isRecvImgData){
|
||||
if (preVideoClientId == clientId) {
|
||||
qDebug() << "-----------------" << preVideoClientId << "isRecvVideoData:" << isRecvVideoData;
|
||||
}
|
||||
|
||||
}
|
||||
socket->readAll();
|
||||
//QByteArray data = socket->readAll();
|
||||
//qDebug() << "Received data:" << data;
|
||||
//qDebug() << "--------- socket->readAll()" ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -673,7 +801,7 @@ void ClientHandler::processPendingData()
|
||||
<< "at" << QDateTime::currentDateTime().toString(Qt::ISODate)
|
||||
<< "bytesAvailable after read:" << bytesAvailableAfter; */
|
||||
|
||||
if (isFirstDataReceived) {
|
||||
if ((isBackBoardOrAllBoard == 0) && isFirstDataReceived) {
|
||||
RNDISFirstData(buffer);
|
||||
isFirstDataReceived = false;
|
||||
}
|
||||
@@ -725,17 +853,12 @@ void ClientHandler::processPendingData()
|
||||
}
|
||||
}
|
||||
|
||||
// 处理超时
|
||||
void ClientHandler::onTimeout()
|
||||
{
|
||||
//qDebug() << "------> start mutex :" << __FUNCTION__;
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
// 获取当前项的 "data" 字段
|
||||
//QString itemData = currentItem.value("data").toString();
|
||||
//emit statusUpdated(socket->peerAddress().toString(), currentItemIndex, false, itemData);
|
||||
emit statusUpdated(getClientAddress(), currentItemIndex + 1, currentFuncItemIndex + 1,
|
||||
false, getCurrentItemLable(), getCurrentFuncItemLable(), currentJson, currentJsonItem);
|
||||
emit statusUpdated(getClientAddress(), false, currentJson, currentJsonItem);
|
||||
qDebug() << "isSingleSend:" << isSingleSend << "isPowerOnSend:" << isPowerOnSend;
|
||||
if (!isSingleSend && !isPowerOnSend) {
|
||||
currentItemIndex ++;
|
||||
itemsProcessedCount ++;
|
||||
@@ -744,23 +867,51 @@ void ClientHandler::onTimeout()
|
||||
if (isSingleSend) {
|
||||
isSingleSend = false;
|
||||
}
|
||||
else if (isPowerOnSend && currentFrontBoardIndex < frontBoardDevInfoJson.size()) {
|
||||
sendDevInfoItem();
|
||||
}
|
||||
else if (isClickedSend && (currentItemIndex < frontBoardOneClickTest.size())) {
|
||||
//qDebug() << "------> onTimeout";
|
||||
sendNextItem();
|
||||
}
|
||||
else if(isClickedSend) {
|
||||
qDebug() << "All items processed in onTimeout.";
|
||||
emit allItemsProcessed(getClientAddress(), itemsProcessedCount);
|
||||
//resetCurrentItemIndex();
|
||||
else if (isClickedSend) {
|
||||
if (isBackBoardOrAllBoard) {
|
||||
if (currentItemIndex < backBoardOneClickTest.size()) {
|
||||
sendNextItem(currentJson);
|
||||
}
|
||||
else if (currentItemIndex >= backBoardOneClickTest.size()) {
|
||||
qDebug() << "All backBoardOneClickTest items processed in onTimeout().";
|
||||
emit allItemsProcessed(getClientAddress(), itemsProcessedCount);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (currentItemIndex < frontBoardOneClickTest.size()) {
|
||||
sendNextItem(currentJson);
|
||||
}
|
||||
else if (currentItemIndex >= frontBoardOneClickTest.size()) {
|
||||
qDebug() << "All frontBoardOneClickTest items processed in onTimeout().";
|
||||
emit allItemsProcessed(getClientAddress(), itemsProcessedCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isPowerOnSend) {
|
||||
qDebug() << "All items processed in onTimeout.";
|
||||
emit allItemsProcessed(getClientAddress(), currentFrontBoardIndex);
|
||||
//resetCurrentItemIndex();
|
||||
if (isBackBoardOrAllBoard) {
|
||||
if (currentBackBoardIndex < backBoardDevInfoJson.size()) {
|
||||
sendDevInfoItem();
|
||||
}
|
||||
else {
|
||||
qDebug() << "All items processed in onTimeout.";
|
||||
emit allItemsProcessed(getClientAddress(), currentBackBoardIndex);
|
||||
currentFrontBoardIndex = 0;
|
||||
currentBackBoardIndex = 0;
|
||||
isPowerOnSend = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (currentFrontBoardIndex < frontBoardDevInfoJson.size()) {
|
||||
sendDevInfoItem();
|
||||
}
|
||||
else {
|
||||
qDebug() << "All items processed in onTimeout.";
|
||||
emit allItemsProcessed(getClientAddress(), currentFrontBoardIndex);
|
||||
currentFrontBoardIndex = 0;
|
||||
currentBackBoardIndex = 0;
|
||||
isPowerOnSend = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
//qDebug() << "------> end mutex :" << __FUNCTION__;
|
||||
qDebug() << "" << __FUNCTION__ << "------> itemsProcessedCount :" << itemsProcessedCount;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "DelUserWindows.h"
|
||||
|
||||
#define TEST_TCP_MOVE_TO_MAIN 0
|
||||
#define GET_PIC_DATA_SIZE (480 * 640 * 1.5)
|
||||
|
||||
class ClientHandler : public QObject, public QRunnable
|
||||
{
|
||||
@@ -59,7 +60,7 @@ public:
|
||||
void run() override;
|
||||
// 开始处理客户端
|
||||
void start();
|
||||
void sendJsonItem(const QJsonArray& jsonArray, int itemIndex, const QString text, const QString& itemType);
|
||||
void sendJsonItem(const QJsonArray& jsonArray, int itemIndex, const QString text, const QString backBoardSn, const QString& itemType);
|
||||
// 发送获取设备信息按键
|
||||
void sendGetDevInfoItem(int itemIndex);
|
||||
// 发送取图按键
|
||||
@@ -68,12 +69,12 @@ public:
|
||||
void sendGetVideoItem(int itemIndex, int GetVideoCamIndex);
|
||||
// 发送License处理按键
|
||||
void sendLicenseItem(int itemIndex, const QString text);
|
||||
void sendUuidItem(int itemIndex, const QString text);
|
||||
void sendUuidItem(int itemIndex, const QString uuid, const QString sn);
|
||||
// 发送下一个功能配置 JSON 项目
|
||||
void sendFrontFuncItem(int itemIndex, QString text);
|
||||
void sendBackFuncItem(int itemIndex, QString text);
|
||||
// 发送下一个 JSON 项目
|
||||
void sendNextItem();
|
||||
void sendNextItem(QJsonArray& currentOneClickedItem);
|
||||
// 处理发送单独指令
|
||||
void sendFrontItem(int itemIndex);
|
||||
void sendBackItem(int itemIndex);
|
||||
@@ -105,9 +106,8 @@ signals:
|
||||
// 数据发送信号
|
||||
void sendData(const QByteArray& data, int isBoardType);
|
||||
// 状态更新信号
|
||||
void statusUpdated(const QString& client, int itemIndex, int funcItemIndex,
|
||||
bool success, const QString& itemData, const QString& funcItemData,
|
||||
const QJsonArray& jsonArray, int itemJsonIndex);
|
||||
void statusUpdated(const QString& client, bool success, const QJsonArray& jsonArray, int itemJsonIndex);
|
||||
void HandleInvalidOperate(const QString& text);
|
||||
// 客户端断开连接信号
|
||||
void clientDisconnected(ClientHandler* handler);
|
||||
// json文件配置项发送完毕
|
||||
@@ -132,6 +132,7 @@ public slots:
|
||||
void onDisconnected();
|
||||
//void onSocketError(QAbstractSocket::SocketError socketError);
|
||||
void onTimeoutRead();
|
||||
void onPicRecvFinished();
|
||||
void checkConnectionStatus(); // 定期检查连接状态
|
||||
void processPendingData();
|
||||
void startReadVideoDataTimer(int client_Id);
|
||||
|
||||
Reference in New Issue
Block a user