1.增加整机测试工厂信息输入; 2. 增加前后板连接后自动发送获取设备版本信息指令; 3. 优化UI布局代码

This commit is contained in:
2024-09-10 11:29:44 +08:00
parent 9a49eab4af
commit 843b2058c3
377 changed files with 197841 additions and 231069 deletions

View File

@@ -0,0 +1,42 @@
// UI_Name.h
#ifndef UI_NAME_H
#define UI_NAME_H
#define SL100_FACTORY_TOOL_W 1340
#define SL100_FACTORY_TOOL_H 900
#define START_LISTENING "开始监听\n(Start Listening...)"
#define ONE_CLICKED_TEST "一键功能测试"
#define TOOL_VERSION "SL100 工厂产测工具 - V0.0.7"
#define FRONT_BOARD_NAME "前 板"
#define BACK_BOARD_NAME "后 板"
#define ALL_BOARD_NAME "整 机"
#define FRONT_BOARD_TEST "前板测试项"
#define IMAGE_DISPLAYAREA "图像显示区"
#define VIDEO_DISPLAYAREA "视频显示区"
#define RESOLUTION_EDIT "分辨率:"
#define LEFT_LENS "左边镜头"
#define RIGHT_LENS "右边镜头"
#define CAT_EYE_LENS_RGB "猫眼镜头(RGB)"
#define CAT_EYE_LENS_IR "猫眼镜头(IR)"
#define BIG_WINDOW_PRE_VIDEO "大窗口播放视频"
#define IMAGE_DISPLAY_TAB "图像显示区"
#define VIDEO_DISPLAY_TAB "视频显示区"
#define INPUT_CONFIG_PARA "请输入配置参数..."
#define FRONT_TEST_ITEM "前板测试项"
#define FRONT_CONFID_ITEM "前板配置项"
#define FRONT_DEVICE_INFO "前板设备信息"
#define FRONT_TUYU_LICENSE "算法 license"
#define BACK_TEST_ITEM "后板测试项"
#define BACK_CONFID_ITEM "后板配置项"
#define BACK_GET_UUID_SN "后板获取 UUID/SN"
#define BACK_DEVICE_INFO "后板设备信息"
#define ALL_BOARD "整机设备信息"
#define ALL_PRODUCT_INFO "工厂生产信息"
#define FRONT_BOARD_VIDEO_BUTTON_INDEX_PROPERTY "getVideoIndex"
#define BACK_BOARD_VIDEO_BUTTON_INDEX_PROPERTY "BackGetVideoIndex"
#define ALL_BOARD_VIDEO_BUTTON_INDEX_PROPERTY "AllGetVideoIndex"
#endif

View File

@@ -2,7 +2,7 @@
QGroupBox* MainWidget::createLicenseGroupBox()
{
QGroupBox* groupBox = new QGroupBox("算法 license", this);
QGroupBox* groupBox = new QGroupBox(QString(FRONT_TUYU_LICENSE), this);
QHBoxLayout* buttonRowLayout = new QHBoxLayout;
for (int i = 0; i < frontBoardLicenseJson.size(); ++i) {
@@ -29,9 +29,8 @@ QGroupBox* MainWidget::createLicenseGroupBox()
QGroupBox* MainWidget::createFrontDeviceInfoGroupBox()
{
QGroupBox* frontDeviceInfoGroupBox = new QGroupBox("前板设备信息", this);
QGroupBox* frontDeviceInfoGroupBox = new QGroupBox(QString(FRONT_DEVICE_INFO), this);
QFormLayout* formLayout = new QFormLayout(frontDeviceInfoGroupBox);
for (const QJsonValue& value : frontBoardDevInfoJson) {
QJsonObject item = value.toObject();
QString label = item["lable"].toString();
@@ -43,19 +42,17 @@ QGroupBox* MainWidget::createFrontDeviceInfoGroupBox()
formLayout->addRow(itemLabel, itemLineEdit);
devInfoLineEdits[cmd] = itemLineEdit;
}
return frontDeviceInfoGroupBox;
}
QGroupBox* MainWidget::createBackDeviceInfoGroupBox()
{
QGroupBox* backDeviceInfoGroupBox = new QGroupBox("后板设备信息", this);
QGroupBox* backDeviceInfoGroupBox = new QGroupBox(QString(BACK_DEVICE_INFO), this);
QFormLayout* formLayout = new QFormLayout(backDeviceInfoGroupBox);
for (const QJsonValue& value : backBoardDevInfoJson) {
QJsonObject item = value.toObject();
QString label = item["lable"].toString();
QString cmd = item["cmd"].toString();
QJsonObject item = value.toObject();
QString label = item["lable"].toString();
QString cmd = item["cmd"].toString();
QLabel* itemLabel = new QLabel(label, this);
QLineEdit* itemLineEdit = new QLineEdit(this);
itemLineEdit->setReadOnly(true);
@@ -63,13 +60,12 @@ QGroupBox* MainWidget::createBackDeviceInfoGroupBox()
formLayout->addRow(itemLabel, itemLineEdit);
devInfoLineEdits[cmd] = itemLineEdit;
}
return backDeviceInfoGroupBox;
}
QGroupBox* MainWidget::createBackConnectServerGroupBox()
{
QGroupBox* BackConnectServerGroupBox = new QGroupBox("后板获取UUID", this);
QGroupBox* BackConnectServerGroupBox = new QGroupBox(QString(BACK_GET_UUID_SN), this);
QHBoxLayout* frontDeviceInfoLayout = new QHBoxLayout;
for (int i = 0; i < backBoardUuidJson.size(); ++i) {
@@ -141,11 +137,11 @@ QWidget* MainWidget::createFunctionConfigTab(const QJsonArray& BoardFuncConfig,
QWidget* functionConfigTab = new QWidget(this);
QVBoxLayout* functionConfigLayout = new QVBoxLayout(functionConfigTab);
if (propertyName == "frontBoardFuncConfig") {
frontFuncConfigLineEdit->setPlaceholderText("请输入配置参数...");
frontFuncConfigLineEdit->setPlaceholderText(QString(INPUT_CONFIG_PARA));
functionConfigLayout->addWidget(frontFuncConfigLineEdit);
}
else if (propertyName == "backBoardFuncConfig") {
backFuncConfigLineEdit->setPlaceholderText("请输入配置参数...");
backFuncConfigLineEdit->setPlaceholderText(QString(INPUT_CONFIG_PARA));
functionConfigLayout->addWidget(backFuncConfigLineEdit);
}
@@ -186,7 +182,7 @@ QWidget* MainWidget::createFunctionConfigTab(const QJsonArray& BoardFuncConfig,
return functionConfigTab;
}
QWidget* MainWidget::createImageDisplayTab()
QWidget* MainWidget::createImageDisplayTab(QLabel* leftLensLabel, QLabel* rightLensLabel)
{
QWidget* imageDisplayTab = new QWidget(this);
QVBoxLayout* imageDisplayLayout = new QVBoxLayout(imageDisplayTab);
@@ -197,7 +193,7 @@ QWidget* MainWidget::createImageDisplayTab()
for (int j = 0; j < 2; ++j) {
QPushButton* button;
if (i == 0 && j == 0) {
button = new QPushButton(QString("IR"), this);
button = new QPushButton(QString(LEFT_LENS), this);
button->setFixedSize(73, 50);
imageButtonsRowLayout->addWidget(button);
button->setProperty("getPicIndex", i * 2 + j);
@@ -206,7 +202,7 @@ QWidget* MainWidget::createImageDisplayTab()
continue;
}
else if (i == 0 && j == 1) {
button = new QPushButton(QString("RGB"), this);
button = new QPushButton(QString(RIGHT_LENS), this);
button->setFixedSize(73, 50);
imageButtonsRowLayout->addWidget(button);
button->setProperty("getPicIndex", i * 2 + j);
@@ -215,7 +211,7 @@ QWidget* MainWidget::createImageDisplayTab()
continue;
}
button = new QPushButton(QString("Device %1").arg(i * 2 + j - 1), this);
button = new QPushButton(QString("Device %1\n取图").arg(i * 2 + j - 1), this);
button->setFixedSize(73, 50);
imageButtonsRowLayout->addWidget(button);
button->setProperty("getPicIndex", i * 2 + j);
@@ -226,10 +222,12 @@ QWidget* MainWidget::createImageDisplayTab()
}
QHBoxLayout* lensesLayout = new QHBoxLayout;
leftLens_imageLabel = new QLabel(this);
rightLens_imageLabel = new QLabel(this);
lensesLayout->addWidget(leftLens_imageLabel);
lensesLayout->addWidget(rightLens_imageLabel);
//leftLens_imageLabel = new QLabel(this);
//rightLens_imageLabel = new QLabel(this);
//lensesLayout->addWidget(leftLens_imageLabel);
//lensesLayout->addWidget(rightLens_imageLabel);
lensesLayout->addWidget(leftLensLabel);
lensesLayout->addWidget(rightLensLabel);
QHBoxLayout* imageAndButtonsLayout = new QHBoxLayout;
imageAndButtonsLayout->addLayout(imageButtonsColumnLayout, 1);
@@ -239,12 +237,23 @@ QWidget* MainWidget::createImageDisplayTab()
return imageDisplayTab;
}
QWidget* MainWidget::createVideoDisplayTab()
QWidget* MainWidget::createVideoDisplayTab(QLabel* video_Label, QLineEdit* VideoResolutionEdit_type, const QString& tabName)
{
QWidget* videoDisplayTab = new QWidget(this);
QWidget* videoDisplayTab = new QWidget(this);
QVBoxLayout* videoDisplayLayout = new QVBoxLayout(videoDisplayTab);
QVBoxLayout* videoButtonsColumnLayout = new QVBoxLayout;
const char* videoIndexProperty;
if (tabName == QString(FRONT_BOARD_NAME)) {
videoIndexProperty = FRONT_BOARD_VIDEO_BUTTON_INDEX_PROPERTY;
}
else if (tabName == QString(BACK_BOARD_NAME)) {
videoIndexProperty = BACK_BOARD_VIDEO_BUTTON_INDEX_PROPERTY;
}
else if(tabName == QString(ALL_BOARD_NAME)) {
videoIndexProperty = ALL_BOARD_VIDEO_BUTTON_INDEX_PROPERTY;
}
for (int i = 0; i < 6; ++i) {
QHBoxLayout* videoButtonsRowLayout = new QHBoxLayout;
@@ -252,52 +261,92 @@ QWidget* MainWidget::createVideoDisplayTab()
QPushButton* button;
if (i == 0 && j == 0) {
button = new QPushButton(QString("猫眼镜头(IR)"), this);
button = new QPushButton(QString(CAT_EYE_LENS_IR), this);
button->setFixedSize(110, 50);
videoButtonsRowLayout->addWidget(button);
button->setProperty("getVideoIndex", i * 2 + j);
button->setProperty(videoIndexProperty, i * 2 + j);
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
getVideoButtons.append(button);
if (tabName == QString(FRONT_BOARD_NAME)) {
getVideoButtons.append(button);
}
else if (tabName == QString(BACK_BOARD_NAME)) {
getBackVideoButtons.append(button);
}
else if (tabName == QString(ALL_BOARD_NAME)) {
getAllVideoButtons.append(button);
}
continue;
}
else if (i == 0 && j == 1) {
button = new QPushButton(QString("猫眼镜头(RGB)"), this);
button = new QPushButton(QString(CAT_EYE_LENS_RGB), this);
button->setFixedSize(110, 50);
videoButtonsRowLayout->addWidget(button);
button->setProperty("getVideoIndex", i * 2 + j);
button->setProperty(videoIndexProperty, i * 2 + j);
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
getVideoButtons.append(button);
if (tabName == QString(FRONT_BOARD_NAME)) {
getVideoButtons.append(button);
}
else if (tabName == QString(BACK_BOARD_NAME)) {
getBackVideoButtons.append(button);
}
else if (tabName == QString(ALL_BOARD_NAME)) {
getAllVideoButtons.append(button);
}
continue;
}
if (i == 1 && j == 0) {
button = new QPushButton(QString("左边镜头"), this);
button->setFixedSize(110, 50);
videoButtonsRowLayout->addWidget(button);
button->setProperty("getVideoIndex", i * 2 + j);
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
getVideoButtons.append(button);
continue;
if (tabName != QString(BACK_BOARD_NAME)) {
if (i == 1 && j == 0) {
button = new QPushButton(QString(LEFT_LENS), this);
button->setFixedSize(110, 50);
videoButtonsRowLayout->addWidget(button);
button->setProperty(videoIndexProperty, i * 2 + j);
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
if (tabName == QString(FRONT_BOARD_NAME)) {
getVideoButtons.append(button);
}
else if (tabName == QString(BACK_BOARD_NAME)) {
getBackVideoButtons.append(button);
}
else if (tabName == QString(ALL_BOARD_NAME)) {
getAllVideoButtons.append(button);
}
continue;
}
else if (i == 1 && j == 1) {
button = new QPushButton(QString(RIGHT_LENS), this);
button->setFixedSize(110, 50);
videoButtonsRowLayout->addWidget(button);
button->setProperty(videoIndexProperty, i * 2 + j);
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
if (tabName == QString(FRONT_BOARD_NAME)) {
getVideoButtons.append(button);
}
else if (tabName == QString(BACK_BOARD_NAME)) {
getBackVideoButtons.append(button);
}
else if (tabName == QString(ALL_BOARD_NAME)) {
getAllVideoButtons.append(button);
}
continue;
}
}
else if (i == 1 && j == 1) {
button = new QPushButton(QString("右边镜头"), this);
button->setFixedSize(110, 50);
videoButtonsRowLayout->addWidget(button);
button->setProperty("getVideoIndex", i * 2 + j);
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
getVideoButtons.append(button);
continue;
}
if (i == 2 && j == 0) {
button = new QPushButton(QString("大窗口播放视频"), this);
button = new QPushButton(QString(BIG_WINDOW_PRE_VIDEO), this);
button->setFixedSize(224, 50);
button->setEnabled(false);
videoButtonsRowLayout->addWidget(button);
button->setProperty("getVideoIndex", i * 2 + j);
button->setProperty(videoIndexProperty, i * 2 + j);
connect(button, &QPushButton::clicked, this, &MainWidget::onOpenFocusWindowClicked);
getVideoButtons.append(button);
break; // 跳出内层循环,只添加一个按键
if (tabName == QString(FRONT_BOARD_NAME)) {
getVideoButtons.append(button);
}
else if (tabName == QString(BACK_BOARD_NAME)) {
getBackVideoButtons.append(button);
}
else if (tabName == QString(ALL_BOARD_NAME)) {
getAllVideoButtons.append(button);
}
break;
}
if (i >= 3 && i <= 5) {
@@ -312,28 +361,30 @@ QWidget* MainWidget::createVideoDisplayTab()
button->setFixedSize(110, 50);
videoButtonsRowLayout->addWidget(button);
button->setProperty("getVideoIndex", i * 2 + j + 1);
button->setProperty(videoIndexProperty, i * 2 + j + 1);
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
getVideoButtons.append(button);
if (tabName == QString(FRONT_BOARD_NAME)) {
getVideoButtons.append(button);
}
else if (tabName == QString(BACK_BOARD_NAME)) {
getBackVideoButtons.append(button);
}
else if (tabName == QString(ALL_BOARD_NAME)) {
getAllVideoButtons.append(button);
}
}
videoButtonsColumnLayout->addLayout(videoButtonsRowLayout);
}
QHBoxLayout* videoAndButtonsLayout = new QHBoxLayout;
QFormLayout* formLayout = new QFormLayout;
QLabel* VideoResolution = new QLabel("分辨率:");
VideoResolutionEdit = new QLineEdit;
VideoResolutionEdit->setFixedWidth(120);
formLayout->addRow(VideoResolution, VideoResolutionEdit);
/*QLabel* frameRate = new QLabel("帧率:");
frameRateEdit = new QLineEdit;
frameRateEdit->setFixedWidth(120);
formLayout->addRow(frameRate, frameRateEdit);*/
videoLabel = new QLabel(this);
videoLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QLabel* VideoResolution = new QLabel(QString(RESOLUTION_EDIT));
VideoResolutionEdit_type->setFixedWidth(120);
formLayout->addRow(VideoResolution, VideoResolutionEdit_type);
video_Label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
videoAndButtonsLayout->addLayout(videoButtonsColumnLayout);
videoAndButtonsLayout->addLayout(formLayout);
videoAndButtonsLayout->addWidget(videoLabel);
videoAndButtonsLayout->addWidget(video_Label);
videoAndButtonsLayout->setStretch(0, 1);
videoAndButtonsLayout->setStretch(1, 1);
videoAndButtonsLayout->setStretch(2, 1);
@@ -342,4 +393,79 @@ QWidget* MainWidget::createVideoDisplayTab()
return videoDisplayTab;
}
// 创建设备区域布局(前板或后板)
void MainWidget::addDeviceAreaTab(QTabWidget* mainTabWidget, const QString& tabName,
QGroupBox* deviceInfoGroupBox, QGroupBox* licenseGroupBox,
const QJsonArray& boardTest, const QJsonArray& boardFuncConfig,
const QString& boardTestName, const QString& boardFuncConfigName,
const QString& boardTestTitle, const QString& boardConfigTitle,
QLabel* leftLensLabel, QLabel* rightLensLabel, QLabel* video_Label,
QLineEdit* VideoResolutionEdit_type)
{
QHBoxLayout* groupBoxLayout = new QHBoxLayout;
groupBoxLayout->addWidget(deviceInfoGroupBox, 1);
groupBoxLayout->addWidget(licenseGroupBox, 1);
QTabWidget* boardTabWidget = new QTabWidget(this);
boardTabWidget->setFixedSize(900, 315);
QWidget* functionTestTab = createFunctionTestTab(boardTest, boardTestName);
QWidget* functionConfigTab = createFunctionConfigTab(boardFuncConfig, boardFuncConfigName);
boardTabWidget->addTab(functionTestTab, boardTestTitle);
boardTabWidget->addTab(functionConfigTab, boardConfigTitle);
QTabWidget* mediaTabWidget = createMediaTabWidget(leftLensLabel, rightLensLabel, video_Label, VideoResolutionEdit_type, tabName);
QWidget* devAreaTab = new QWidget(this);
QVBoxLayout* devLayout = new QVBoxLayout(devAreaTab);
devLayout->addLayout(groupBoxLayout);
devLayout->addWidget(boardTabWidget, 2, Qt::AlignTop | Qt::AlignLeft);
devLayout->addWidget(mediaTabWidget, 3);
mainTabWidget->addTab(devAreaTab, tabName);
}
// 创建整机区域布局
void MainWidget::addAllDeviceAreaTab(QTabWidget* mainTabWidget, const QString& tabName,
QLabel* leftLensLabel, QLabel* rightLensLabel, QLabel* video_Label,
QLineEdit* VideoResolutionEdit_type)
{
QHBoxLayout* groupBoxLayout = new QHBoxLayout;
QGroupBox* allDeviceInfoGroupBox = new QGroupBox(QString(ALL_BOARD), this);
QGroupBox* allProductInfoGroupBox = new QGroupBox(QString(ALL_PRODUCT_INFO), this);
QFormLayout* formLayout = new QFormLayout(allProductInfoGroupBox);
for (const QJsonValue& value : factoryProductInfo) {
QJsonObject item = value.toObject();
QString label = item["lable"].toString();
QString cmd = item["cmd"].toString();
QLabel* itemLabel = new QLabel(label, this);
QLineEdit* itemLineEdit = new QLineEdit(this);
itemLineEdit->setReadOnly(false);
formLayout->addRow(itemLabel, itemLineEdit);
productInfoLineEdits[cmd] = itemLineEdit;
}
groupBoxLayout->addWidget(allProductInfoGroupBox, 1);
groupBoxLayout->addWidget(allDeviceInfoGroupBox, 1);
QTabWidget* mediaTabWidget = createMediaTabWidget(leftLensLabel, rightLensLabel, video_Label, VideoResolutionEdit_type, tabName);
QWidget* allDevAreaTab = new QWidget(this);
QVBoxLayout* allDevLayout = new QVBoxLayout(allDevAreaTab);
allDevLayout->addLayout(groupBoxLayout, 5);
allDevLayout->addWidget(mediaTabWidget, 3);
mainTabWidget->addTab(allDevAreaTab, tabName);
}
// 创建媒体显示区的 tabWidget
QTabWidget* MainWidget::createMediaTabWidget(QLabel* leftLensLabel, QLabel* rightLensLabel, QLabel* video_Label,
QLineEdit* VideoResolutionEdit_type, const QString& tabName)
{
QTabWidget* tabWidget_media = new QTabWidget(this);
if (tabName != QString(BACK_BOARD_NAME)){
QWidget* imageDisplayTab = createImageDisplayTab(leftLensLabel, rightLensLabel);
tabWidget_media->addTab(imageDisplayTab, IMAGE_DISPLAY_TAB);
}
QWidget* videoDisplayTab = createVideoDisplayTab(video_Label, VideoResolutionEdit_type, tabName);
tabWidget_media->addTab(videoDisplayTab, VIDEO_DISPLAY_TAB);
return tabWidget_media;
}