, ui(new Ui::MainWindow)
{
ui->setupUi(this);
- setWindowTitle("雷鸟产测工具 V1.8");
+ setWindowTitle("雷鸟产测工具 V1.9");
// 确保控制台输出使用UTF-8编码
QTextCodec *utf8Codec = QTextCodec::codecForName("UTF-8");
return result;
}
+double MainWindow::getCat1SignalThreshold() const
+{
+ const QString s = ui->cat1RSSILineEdit->text().trimmed();
+ if (s.isEmpty())
+ return 25.0;
+ bool ok = false;
+ const double v = s.toDouble(&ok);
+ return ok ? v : 25.0;
+}
+
// 解析MESSAGE_4G_NETWORK_STAT_CHANGED格式数据
void MainWindow::parseNetworkStatChanged(const QString& data)
{
}
// 判断4G测试是否通过(这段代码理论上不会执行到)
+ const double cat1Th = getCat1SignalThreshold();
bool simOk = (simValue == 1);
- bool signalOk = (signalValue > 25);
+ bool signalOk = (signalValue > cat1Th);
bool testPassed = simOk && signalOk;
qDebug() << "4G测试判断结果:";
qDebug() << " sim值:" << simValue << "(期望: 1)" << "检查结果:" << (simOk ? "通过" : "失败");
- qDebug() << " signal值:" << signalValue << "(期望: >25)" << "检查结果:" << (signalOk ? "通过" : "失败");
+ qDebug() << " signal值:" << signalValue << "(期望: >" << cat1Th << ")" << "检查结果:" << (signalOk ? "通过" : "失败");
qDebug() << " 最终测试结果:" << (testPassed ? "通过" : "失败");
qDebug() << " 警告:此代码不应该执行到,因为已启动CAT1测试";
}
if (signalValue == 99) {
failReason += QString("无效信号值(值:%1)").arg(signalValue);
- } else if (signalValue <= 25) {
- failReason += QString("信号强度不足(值:%1,期望:>25)").arg(signalValue);
+ } else if (signalValue <= cat1Th) {
+ failReason += QString("信号强度不足(值:%1,期望:>%2)").arg(signalValue).arg(cat1Th, 0, 'g', 10);
}
ui->statusbar->showMessage(QString("4G测试失败 - %1").arg(failReason), 3000);
} else {
// 累加有效信号值用于计算平均值
cat1SignalTotalValue += signalValue;
- if (signalValue > 25) {
+ if (signalValue > getCat1SignalThreshold()) {
cat1SignalGoodCount++;
}
// 计算平均信号值并判断测试结果
int validCount = cat1SignalReceivedCount - cat1Signal99Count;
double averageSignal = validCount > 0 ? (double)cat1SignalTotalValue / validCount : 0;
+ const double signalThreshold = getCat1SignalThreshold();
qDebug() << "CAT1信号测试完成,统计结果:";
qDebug() << " 发送指令次数:" << cat1SignalTestCount;
qDebug() << " 无效信号(99)次数:" << cat1Signal99Count;
qDebug() << " 信号值总和:" << cat1SignalTotalValue;
qDebug() << " 平均信号值:" << averageSignal;
+ qDebug() << " 门槛(4G Min Signal):" << signalThreshold;
if (cat1Signal99Count >= 5) {
// 连续5次都是99,判定为失败
updateTestStatus("fourg_signal", STATUS_FAILED);
updateTestStatus("ping", STATUS_UNTESTED);
}
- } else if (validCount > 0 && averageSignal >= 25.0) {
- // 平均信号值大于等于25,判定为通过
- qDebug() << "CAT1信号测试通过,平均信号值" << averageSignal << "大于等于25";
- ui->statusbar->showMessage(QString("CAT1信号测试通过 - 平均信号值:%1").arg(averageSignal, 0, 'f', 1), 3000);
+ } else if (validCount > 0 && averageSignal >= signalThreshold) {
+ // 平均信号值大于等于门槛,判定为通过
+ qDebug() << "CAT1信号测试通过,平均信号值" << averageSignal << "大于等于门槛" << signalThreshold;
+ ui->statusbar->showMessage(QString("CAT1信号测试通过 - 平均:%1 门槛:%2")
+ .arg(averageSignal, 0, 'f', 1)
+ .arg(signalThreshold, 0, 'g', 10), 3000);
updateTestStatus("fourg_signal", STATUS_SUCCESS);
updateTestStatus("ping", STATUS_UNTESTED);
}
} else {
- // 平均信号值小于25或没有有效数据,判定为失败
+ // 平均信号值低于门槛或没有有效数据,判定为失败
QString failReason;
if (validCount == 0) {
failReason = "没有有效信号数据";
} else {
- failReason = QString("平均信号值%1小于25").arg(averageSignal, 0, 'f', 1);
+ failReason = QString("平均信号值%1小于门槛%2")
+ .arg(averageSignal, 0, 'f', 1)
+ .arg(signalThreshold, 0, 'g', 10);
}
qDebug() << "CAT1信号测试失败," << failReason;
<property name="font">
<font>
<family>Arial Black</family>
+ <pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
<property name="font">
<font>
<family>Arial Black</family>
+ <pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
</widget>
</item>
+ <item>
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>4G Min RSSI</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="cat1RSSILineEdit">
+ <property name="toolTip">
+ <string/>
+ </property>
+ <property name="whatsThis">
+ <string/>
+ </property>
+ <property name="placeholderText">
+ <string>默认 25</string>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
<item>
</widget>
</item>
<item>
- <widget class="QPushButton" name="sendButton">
- <property name="text">
- <string>发送</string>
- </property>
- </widget>
+ <layout class="QVBoxLayout" name="verticalLayout_5">
+ <item>
+ <widget class="QPushButton" name="sendButton">
+ <property name="text">
+ <string>发送</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_7">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <family>Arial</family>
+ <pointsize>10</pointsize>
+ <kerning>true</kerning>
+ </font>
+ </property>
+ <property name="text">
+ <string>指令自动加回车</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
</layout>
</item>
<rect>
<x>0</x>
<y>0</y>
- <width>552</width>
- <height>630</height>
+ <width>503</width>
+ <height>592</height>
</rect>
</property>
<property name="title">
<x>0</x>
<y>0</y>
<width>1309</width>
- <height>21</height>
+ <height>36</height>
</rect>
</property>
</widget>