修改分包接收前板发的YUV数据,取图成功后保存YUV图和JPG图

This commit is contained in:
2024-09-03 15:58:23 +08:00
parent 15eb213578
commit c6e16094b9
18 changed files with 3799 additions and 123 deletions

View File

@@ -43,17 +43,17 @@ MainWidget::MainWidget(QWidget* parent) :
connect(server, &QTcpServer::newConnection, this, [this]() {
// 检查是否有挂起的连接
while (server->hasPendingConnections()) {
QTcpSocket* socket = server->nextPendingConnection();
int clientId = nextClientId ++;
QHostAddress clientIp = socket->peerAddress();
quint16 clientPort = socket->peerPort();
QString ipString = clientIp.toString();
QTcpSocket* socket = server->nextPendingConnection();
int clientId = nextClientId ++;
QHostAddress clientIp = socket->peerAddress();
quint16 clientPort = socket->peerPort();
QString ipString = clientIp.toString();
if (ipString.startsWith("::ffff:")) {
ipString = ipString.mid(7);
}
qDebug() << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
qDebug() << "> A client is connected. ID:" << clientId;
qDebug() << "> Client IP:" << ipString << " Port:" << clientPort;
qDebug() << "> Client IP:" << ipString << " Port:" << clientPort;
qDebug() << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
if (ipString.startsWith("10.10.10")) {
@@ -96,14 +96,11 @@ MainWidget::MainWidget(QWidget* parent) :
handler->moveToThread(thread);
// 创建 DataHandler 对象并连接信号
DataHandler* dataHandler = new DataHandler(leftLens_imageLabel, rightLens_imageLabel, videoLabel,
VideoResolutionEdit,
licenseHwInfoEdit, &devInfoLineEdits,
DataHandler* dataHandler = new DataHandler(videoLabel, VideoResolutionEdit, leftLens_imageLabel->size(), &devInfoLineEdits,
frontBoardOneClickTest, frontBoardTest, frontBoardFuncConfig,
frontBoardDevInfoJson, frontBoardLicenseJson,
backBoardOneClickTest, backBoardTest, backBoardFuncConfig, backBoardDevInfoJson,
backBoardUuidJson, getPicJson, getVideoJson, nullptr);
qDebug() << "dataHandler->moveToThread(thread)";
// 将 DataHandler 移到线程池中的线程
dataHandler->moveToThread(thread);
@@ -152,14 +149,23 @@ MainWidget::MainWidget(QWidget* parent) :
connect(thread, &QThread::finished, this, [=]() {
onThreadFinished(thread, handler, dataHandler);
});
connect(dataHandler, &DataHandler::updateLicenseHwInfoEdit, this, [this](const QString& text) {
licenseHwInfoEdit->setPlainText(text);
});
connect(dataHandler, &DataHandler::updateLeftLensImage, leftLens_imageLabel, &QLabel::setPixmap);
connect(dataHandler, &DataHandler::updateRightLensImage, rightLens_imageLabel, &QLabel::setPixmap);
connect(dataHandler, &DataHandler::updateVideoLabel, videoLabel, &QLabel::setPixmap);
connect(dataHandler, &DataHandler::updateVideoResolution, VideoResolutionEdit, &QLineEdit::setText);
// 启动新的线程
thread->start();
connect(handler, &ClientHandler::startReadTimer, this, &MainWidget::startClientReadTimer);
connect(handler, &ClientHandler::stopReadTimer, this, &MainWidget::stopClientReadTimer);
//handler->getClientId() == handler->preVideoClientId
qDebug() << "---- handler->getClientId():" << handler->getClientId();
qDebug() << "---- handler->preVideoClientId:" << handler->preVideoClientId;
//qDebug() << "---- handler->getClientId():" << handler->getClientId();
//qDebug() << "---- handler->preVideoClientId:" << handler->preVideoClientId;
connect(this, &MainWidget::openFocusWindowRequested, dataHandler, &DataHandler::handleOpenFocusWindow);
// 创建和管理定时器
@@ -295,7 +301,6 @@ void MainWidget::onClientDisconnected(ClientHandler* handler)
*/
handler->deleteLater(); // 延迟删除 ClientHandler 对象
qDebug() << "-----------dataHandlers-----------";
if (dataHandlers.contains(clientId)) {
DataHandler* dataHandler = dataHandlers[clientId];
dataHandlers.remove(clientId); // 从容器中移除
@@ -448,7 +453,7 @@ void MainWidget::setupUI()
mainLayout->addLayout(rightVerticalLayout, 3);
setLayout(mainLayout);
setWindowTitle("SL100 工厂产测工具 - V0.0.1");
setWindowTitle("SL100 工厂产测工具 - V0.0.4");
resize(1340, 900);
connect(startServerButton, &QPushButton::clicked, this, &MainWidget::onStartServerClicked);
@@ -680,7 +685,7 @@ void MainWidget::FactoryToolSendPostLicenseToHttpServer(const QString& hardware_
}
void MainWidget::startClientReadTimer(int clientId) {
qDebug() << "------ startClientReadTimer clientId:" << clientId;
//qDebug() << "------ startClientReadTimer clientId:" << clientId;
if (clientReadTimers.contains(clientId)) {
clientReadTimers[clientId]->start(10);
}
@@ -1268,6 +1273,7 @@ void MainWidget::onSendGetVideoClicked()
//QMutexLocker locker(&mutex);
for (ClientHandler* handler : clients) {
if (handler->getClientId() == handler->controlClientId) {
qDebug() << "lens number:" << lastClickedGetVideoCamIndex;
handler->sendGetVideoItem(itemIndex - 7, lastClickedGetVideoCamIndex);
break;
}