Bläddra i källkod

Sync Qt client, web firmware-controls & field manuals (v0.8.1.29+)

XJKJ STL 1 vecka sedan
förälder
incheckning
7a5532f1fb

BIN
docs/6400高温罩快速使用说明书.docx


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 124 - 0
docs/6400高温罩快速使用说明书.md


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 24 - 0
docs/QT_CLIENT_API_ZH.md


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2222 - 0
docs/XJKJ-STL-Architecture-Map.html


+ 9 - 0
docs/port.example.json

@@ -0,0 +1,9 @@
+{
+  "_comment": "工位串口配置模板:复制并重命名为 port.json 放到与 config.json 同级目录。数组第 1 个对应 SLT-HT-001,依次到 SLT-HT-004。Windows 填 COMx(如 COM18)或 USB serialNumber;Linux 填 /dev/ttyUSBx 或 serialNumber(禁止占用 /dev/ttyUSB0)。波特率固定 115200。",
+  "serialPorts": [
+    { "port": "", "serialNumber": "", "baud": 115200 },
+    { "port": "", "serialNumber": "", "baud": 115200 },
+    { "port": "", "serialNumber": "", "baud": 115200 },
+    { "port": "", "serialNumber": "", "baud": 115200 }
+  ]
+}

+ 43 - 10
src/backendlink.cpp

@@ -399,6 +399,13 @@ void BackendLink::onDisconnected()
         m_stageIntentPending[i].clear();
         m_stageIntentPending[i].clear();
         m_stageIntentReady[i].clear();
         m_stageIntentReady[i].clear();
         m_startRpcInFlight[i] = false;
         m_startRpcInFlight[i] = false;
+        if (!m_fileQueryCmd[i].isEmpty()) {
+            const QString failedCmd = m_fileQueryCmd[i];
+            m_fileQueryCmd[i].clear();
+            forgetCommand(failedCmd);
+            emit uefiFilesArrived(i, false, m_fileQueryPath[i], QStringList(),
+                                  QStringLiteral("后端连接已断开,请重试"));
+        }
     }
     }
 
 
     if (m_reportedConnected && !m_disconnectDebounce.isActive())
     if (m_reportedConnected && !m_disconnectDebounce.isActive())
@@ -673,6 +680,8 @@ void BackendLink::confirmDimmReplacement(int station)
             return;
             return;
         }
         }
         emit logLine(station, QStringLiteral("[qt] 已确认更换异常内存条,后端换条停机挂起已解除"));
         emit logLine(station, QStringLiteral("[qt] 已确认更换异常内存条,后端换条停机挂起已解除"));
+        m_stageErrorsJson[station].clear();
+        m_lastVerdict[station].clear();
         emit dimmConfirmed(station, true, QString());
         emit dimmConfirmed(station, true, QString());
     }, [this, station](const QString &code, const QString &message) {
     }, [this, station](const QString &code, const QString &message) {
         const QString msg = QStringLiteral("%1 %2").arg(code, message).trimmed();
         const QString msg = QStringLiteral("%1 %2").arg(code, message).trimmed();
@@ -685,10 +694,8 @@ void BackendLink::applyState(const QJsonObject &result)
 {
 {
     const QString serverId = result.value(QStringLiteral("server_id")).toString();
     const QString serverId = result.value(QStringLiteral("server_id")).toString();
     if (!m_serverId.isEmpty() && serverId != m_serverId) {
     if (!m_serverId.isEmpty() && serverId != m_serverId) {
-        // 后端重启:清掉旧输入节点与自动运行归属,不重放任何动作
-        qInfo().noquote() << "[backend] server_id 变化,清理旧输入节点与自动运行状态";
-        // 后端实例变化后,旧命令、输入节点与阶段意图均不可继续使用。
-        // 暂停自动动作,要求用户明确重新开始,避免对新后端会话误发旧计划。
+        // 后端重启:清掉旧输入节点与在途/自动运行归属,不重放任何动作,防止 canSubmitStart 永久锁死
+        qInfo().noquote() << "[backend] server_id 变化,清理旧输入节点与在途/自动运行状态";
         m_autoPaused = true;
         m_autoPaused = true;
         for (int i = 0; i < kStationCount; ++i) {
         for (int i = 0; i < kStationCount; ++i) {
             m_handledInput[i].clear();
             m_handledInput[i].clear();
@@ -696,13 +703,35 @@ void BackendLink::applyState(const QJsonObject &result)
             m_bootId[i].clear();
             m_bootId[i].clear();
             m_lastTaskCompleteBoot[i].clear();
             m_lastTaskCompleteBoot[i].clear();
             m_lastTaskCompleteEventBoot[i].clear();
             m_lastTaskCompleteEventBoot[i].clear();
+            m_stageDoneKeys[i].clear();
+            m_stagePendingCmd[i].clear();
+            m_stagePendingKey[i].clear();
             m_stageIntentPending[i].clear();
             m_stageIntentPending[i].clear();
             m_stageIntentReady[i].clear();
             m_stageIntentReady[i].clear();
             m_waitingNewBoot[i] = false;
             m_waitingNewBoot[i] = false;
+            m_stationPaused[i] = false;
+            m_blockedWarned[i] = false;
+            m_lastCompleteCmd[i].clear();
+            m_lastTaskStatus[i].clear();
+            m_stageErrorsJson[i].clear();
+            m_lastVerdict[i].clear();
+            m_lastCanStart[i] = true;
+            m_startRpcInFlight[i] = false;
+            const bool hadStartPending = m_startPending[i];
+            m_startPending[i] = false;
+            m_startCmd[i].clear();
+            if (!m_fileQueryCmd[i].isEmpty()) {
+                m_fileQueryCmd[i].clear();
+                emit uefiFilesArrived(i, false, m_fileQueryPath[i], QStringList(),
+                                      QStringLiteral("后端已重启,请重试"));
+            }
+            if (hadStartPending)
+                emit startTestReplied(i, false, QStringLiteral("后端实例已重启"));
         }
         }
         m_pending.clear();
         m_pending.clear();
         m_pollCount.clear();
         m_pollCount.clear();
         m_pendingSince.clear();
         m_pendingSince.clear();
+        emit serverRestarted();
     }
     }
     m_serverId = serverId;
     m_serverId = serverId;
 
 
@@ -828,10 +857,15 @@ void BackendLink::applyStation(int station, const QJsonObject &st)
                            QStringLiteral("换条停机:等待更换异常内存条并重新开始测试"));
                            QStringLiteral("换条停机:等待更换异常内存条并重新开始测试"));
     }
     }
 
 
-    // FAIL 之后该工位停止自动动作,等人工处理(其他工位不受影响)
-    if (runState == QStringLiteral("failed")) {
+    // FAIL / STOPPED / ABORTED 之后该工位停止自动动作,等人工处理(其他工位不受影响)
+    if (runState == QStringLiteral("failed")
+        || runState == QStringLiteral("stopped")
+        || runState == QStringLiteral("interrupted")
+        || runState == QStringLiteral("aborted")
+        || runState == QStringLiteral("error")
+        || runState == QStringLiteral("timeout")) {
         if (!m_stationPaused[station]) {
         if (!m_stationPaused[station]) {
-            qInfo().noquote() << "[backend] 工位" << stationId(station) << "进入 failed,暂停该工位自动下发";
+            qInfo().noquote() << "[backend] 工位" << stationId(station) << "进入" << runState << ",暂停该工位自动下发";
             m_stationPaused[station] = true;
             m_stationPaused[station] = true;
         }
         }
     }
     }
@@ -892,14 +926,13 @@ void BackendLink::stageStationIntents(int station)
         });
         });
     };
     };
 
 
-    // ICT1:完整透传本地 memory_params(包含快捷参数及扩展目录参数)与 rmt(含 selected/enabled),并单独指定 RMT 开关。
+    // ICT1:完整透传本地 memory_params(即使为空对象也透传以清掉上一轮残留覆写)与 rmt(含 selected/enabled),并单独指定 RMT 开关。
     QJsonObject ict1;
     QJsonObject ict1;
     const bool runRmt = m_rmtParams[station].value(QStringLiteral("enabled")).toBool(true);
     const bool runRmt = m_rmtParams[station].value(QStringLiteral("enabled")).toBool(true);
     ict1.insert(QStringLiteral("run_rmt"), runRmt);
     ict1.insert(QStringLiteral("run_rmt"), runRmt);
     if (!m_rmtParams[station].isEmpty())
     if (!m_rmtParams[station].isEmpty())
         ict1.insert(QStringLiteral("rmt"), m_rmtParams[station]);
         ict1.insert(QStringLiteral("rmt"), m_rmtParams[station]);
-    if (!m_memoryParams[station].isEmpty())
-        ict1.insert(QStringLiteral("memory_params"), m_memoryParams[station]);
+    ict1.insert(QStringLiteral("memory_params"), m_memoryParams[station]);
     sendIntent(QStringLiteral("uip1"), QStringLiteral("continue_uip"), ict1);
     sendIntent(QStringLiteral("uip1"), QStringLiteral("continue_uip"), ict1);
 
 
     // AMT:按启用开关预置 start_amt / skip_amt;selected、only_tests、skip_tests 均透传。
     // AMT:按启用开关预置 start_amt / skip_amt;selected、only_tests、skip_tests 均透传。

+ 2 - 0
src/backendlink.h

@@ -90,6 +90,8 @@ public:
 
 
 signals:
 signals:
     void connectionChanged(bool connected);
     void connectionChanged(bool connected);
+    /** 后端 server_id 发生变化(后端实例重启):上层据此复位在途/执行中状态 */
+    void serverRestarted();
     /** 后端 state 推送里某个工位的快照(含 channels 24 项),交由 StationStore 落库 */
     /** 后端 state 推送里某个工位的快照(含 channels 24 项),交由 StationStore 落库 */
     void stateArrived(int station, const QJsonObject &stationState);
     void stateArrived(int station, const QJsonObject &stationState);
     /** BIOS UART 原文的一行(已切行、已按 session/offset 去重) */
     /** BIOS UART 原文的一行(已切行、已按 session/offset 去重) */

+ 38 - 9
src/comworker.cpp

@@ -118,13 +118,14 @@ void ComWorker::poll()
     // 只有真正打开了的串口才轮询:轮询 disabled 的端口没有意义,还会刷一堆写失败日志
     // 只有真正打开了的串口才轮询:轮询 disabled 的端口没有意义,还会刷一堆写失败日志
     for (int index = 0; index < m_slots.size(); ++index) {
     for (int index = 0; index < m_slots.size(); ++index) {
         Slot &slot = m_slots[index];
         Slot &slot = m_slots[index];
-        if (!slot.sp || !slot.sp->isOpen())
+        if (!slot.sp || slot.closeQueued || !slot.sp->isOpen())
             continue;
             continue;
 
 
-        // 每 1000ms 只请求本板 CT7428 八路温度(0x0D)。
-        // 24 路内存温度改由后端 channels[i].temperature_c 推送,不再向 MCU 发送 0x02 请求。
+        // 每 1000ms 请求本板 CT7428 八路温度(0x0D)与 24 路 BMC 温度(0x02),
+        // 与后端 channels[i].temperature_c 协同仲裁(后端缺失/未报时可由 0x82 实时兜底)。
         // 应答是异步回来的,由 readyRead 里的 handleReply() 处理,不等在这里。
         // 应答是异步回来的,由 readyRead 里的 handleReply() 处理,不等在这里。
         slot.sp->write(slt::frameRequestCt7428());
         slot.sp->write(slt::frameRequestCt7428());
+        slot.sp->write(slt::frameRequestChannels());
     }
     }
 }
 }
 
 
@@ -134,7 +135,7 @@ void ComWorker::setTargetTemp(int index, int celsius)
         return;
         return;
 
 
     Slot &slot = m_slots[index];
     Slot &slot = m_slots[index];
-    if (!slot.sp || !slot.sp->isOpen()) {
+    if (!slot.sp || slot.closeQueued || !slot.sp->isOpen()) {
         qInfo().noquote() << "[com]" << index << "串口未打开,目标温度" << celsius << "℃ 未下发";
         qInfo().noquote() << "[com]" << index << "串口未打开,目标温度" << celsius << "℃ 未下发";
         emit targetTempSent(index, celsius, false);
         emit targetTempSent(index, celsius, false);
         return;
         return;
@@ -154,7 +155,7 @@ void ComWorker::sendTestEnd(int index, bool dissipate)
         return;
         return;
 
 
     Slot &slot = m_slots[index];
     Slot &slot = m_slots[index];
-    if (!slot.sp || !slot.sp->isOpen()) {
+    if (!slot.sp || slot.closeQueued || !slot.sp->isOpen()) {
         qInfo().noquote() << "[com]" << index << "串口未打开,测试结束命令未下发";
         qInfo().noquote() << "[com]" << index << "串口未打开,测试结束命令未下发";
         emit testEndSent(index, false, dissipate);
         emit testEndSent(index, false, dissipate);
         return;
         return;
@@ -277,11 +278,29 @@ void ComWorker::tick()
                     || err == QSerialPort::PermissionError) {
                     || err == QSerialPort::PermissionError) {
                     qInfo().noquote() << "[com] 串口设备错误" << shortName(s.port) << err
                     qInfo().noquote() << "[com] 串口设备错误" << shortName(s.port) << err
                                       << (s.sp ? s.sp->errorString() : QString());
                                       << (s.sp ? s.sp->errorString() : QString());
-                    closeSlot(s);
+                    if (s.closeQueued || !s.sp)
+                        return;
+                    s.closeQueued = true;
+                    // 注意:open()/read()/write() 期间会同步触发 errorOccurred,
+                    // 绝对不能在这里直接 delete slot.sp(否则 open() 返回前即 UAF 段错误)。
+                    // opening 期间交由 open() 返回后关闭;其余场景排进事件队列异步释放。
+                    if (!s.opening) {
+                        QSerialPort *badSp = s.sp;
+                        QTimer::singleShot(0, this, [this, index, badSp]() {
+                            if (index >= m_slots.size())
+                                return;
+                            Slot &cur = m_slots[index];
+                            if (cur.sp == badSp) {
+                                closeSlot(cur);
+                                tick();
+                            }
+                        });
+                    }
                 }
                 }
             });
             });
         }
         }
 
 
+        slot.closeQueued = false;
         slot.sp->setPortName(target);
         slot.sp->setPortName(target);
         slot.sp->setBaudRate(slot.baud);
         slot.sp->setBaudRate(slot.baud);
         slot.sp->setDataBits(QSerialPort::Data8);
         slot.sp->setDataBits(QSerialPort::Data8);
@@ -289,23 +308,33 @@ void ComWorker::tick()
         slot.sp->setStopBits(QSerialPort::OneStop);
         slot.sp->setStopBits(QSerialPort::OneStop);
         slot.sp->setFlowControl(QSerialPort::NoFlowControl);
         slot.sp->setFlowControl(QSerialPort::NoFlowControl);
 
 
-        if (slot.sp->open(QIODevice::ReadWrite)) {
+        slot.opening = true;
+        const bool opened = slot.sp->open(QIODevice::ReadWrite);
+        slot.opening = false;
+        if (opened) {
+            slot.closeQueued = false;
             report(index, slot, Online, shown,
             report(index, slot, Online, shown,
                    QStringLiteral("已打开 %1 @%2").arg(shortName(target)).arg(slot.baud));
                    QStringLiteral("已打开 %1 @%2").arg(shortName(target)).arg(slot.baud));
         } else {
         } else {
+            const QString errStr = slot.sp ? slot.sp->errorString() : QString();
             report(index, slot, Offline, shown,
             report(index, slot, Offline, shown,
-                   QStringLiteral("打开 %1 失败:%2").arg(shortName(target), slot.sp->errorString()));
+                   QStringLiteral("打开 %1 失败:%2").arg(shortName(target), errStr));
+            if (slot.closeQueued)
+                closeSlot(slot);
         }
         }
     }
     }
 }
 }
 
 
 void ComWorker::closeSlot(Slot &slot)
 void ComWorker::closeSlot(Slot &slot)
 {
 {
+    slot.closeQueued = false;
+    slot.opening = false;
     if (slot.sp) {
     if (slot.sp) {
+        slot.sp->disconnect(this);
         if (slot.sp->isOpen())
         if (slot.sp->isOpen())
             slot.sp->close();
             slot.sp->close();
         slot.parser.reset();    // 端口重开时清掉半帧残数据,别把新会话的头一帧拼错
         slot.parser.reset();    // 端口重开时清掉半帧残数据,别把新会话的头一帧拼错
-        delete slot.sp;         // 和本对象同一个线程,直接删
+        slot.sp->deleteLater(); // 使用 deleteLater 防止任何在途栈帧残余悬垂指针
         slot.sp = nullptr;
         slot.sp = nullptr;
     }
     }
 }
 }

+ 11 - 2
src/comworker.h

@@ -90,8 +90,17 @@ private:
         // 连续几次热插拔扫描没枚举到端口。枚举偶尔会漏一拍(USB 重新枚举、
         // 连续几次热插拔扫描没枚举到端口。枚举偶尔会漏一拍(USB 重新枚举、
         // 驱动扫描中),此时端口其实还能读,先忍两拍再关,别让界面闪「未连接」
         // 驱动扫描中),此时端口其实还能读,先忍两拍再关,别让界面闪「未连接」
         int missCount;
         int missCount;
-
-        Slot() : baud(115200), sp(nullptr), lastState(-1), missCount(0) {}
+        bool opening;     // 正在 open() 调用栈内,禁止 errorOccurred 回调同步 delete sp
+        bool closeQueued; // 已登记异步关闭清理,避免重复 close / UAF
+
+        Slot()
+            : baud(115200)
+            , sp(nullptr)
+            , lastState(-1)
+            , missCount(0)
+            , opening(false)
+            , closeQueued(false)
+        {}
     };
     };
 
 
     void closeSlot(Slot &slot);
     void closeSlot(Slot &slot);

+ 68 - 7
src/createtaskdialog.cpp

@@ -72,13 +72,21 @@ QList<QCheckBox *> algoChecks(QListWidget *list)
     return out;
     return out;
 }
 }
 
 
+QString algoNameOf(const QCheckBox *cb)
+{
+    if (!cb)
+        return QString();
+    const QString stored = cb->property("algoName").toString();
+    return stored.isEmpty() ? cb->text() : stored;
+}
+
 QStringList checkedItems(const QListWidget *list)
 QStringList checkedItems(const QListWidget *list)
 {
 {
     QStringList out;
     QStringList out;
     for (int i = 0; i < list->count(); ++i)
     for (int i = 0; i < list->count(); ++i)
         if (QCheckBox *cb = qobject_cast<QCheckBox *>(list->itemWidget(list->item(i))))
         if (QCheckBox *cb = qobject_cast<QCheckBox *>(list->itemWidget(list->item(i))))
             if (cb->isChecked())
             if (cb->isChecked())
-                out << cb->text();
+                out << algoNameOf(cb);
     return out;
     return out;
 }
 }
 
 
@@ -115,7 +123,7 @@ QStringList allItems(QListWidget *list)
 {
 {
     QStringList out;
     QStringList out;
     for (QCheckBox *cb : algoChecks(list))
     for (QCheckBox *cb : algoChecks(list))
-        out << cb->text();
+        out << algoNameOf(cb);
     return out;
     return out;
 }
 }
 
 
@@ -241,26 +249,41 @@ bool confirmRemove(QWidget *parent, const QString &title, const QString &detail,
 {
 {
     QDialog dlg(parent);
     QDialog dlg(parent);
     dlg.setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
     dlg.setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
+#ifndef Q_OS_LINUX
     dlg.setAttribute(Qt::WA_TranslucentBackground);   // 圆角外透出底下的界面,不留一圈灰底
     dlg.setAttribute(Qt::WA_TranslucentBackground);   // 圆角外透出底下的界面,不留一圈灰底
+#endif
     dlg.setWindowTitle(title);
     dlg.setWindowTitle(title);
     dlg.setFixedWidth(420);
     dlg.setFixedWidth(420);
 
 
     QVBoxLayout *outer = new QVBoxLayout(&dlg);
     QVBoxLayout *outer = new QVBoxLayout(&dlg);
+#ifdef Q_OS_LINUX
+    outer->setContentsMargins(0, 0, 0, 0);
+#else
     outer->setContentsMargins(20, 20, 20, 20);        // 给阴影留绘制空间
     outer->setContentsMargins(20, 20, 20, 20);        // 给阴影留绘制空间
+#endif
     QFrame *card = new QFrame(&dlg);
     QFrame *card = new QFrame(&dlg);
     card->setObjectName(QStringLiteral("confirmCard"));
     card->setObjectName(QStringLiteral("confirmCard"));
+#ifdef Q_OS_LINUX
+    card->setStyleSheet(QStringLiteral(
+        "QFrame#confirmCard { background:#ffffff; border:1px solid #b9cae0; border-radius:0px; }"
+        "QLabel#confirmTitle { color:#20323f; font-size:19px; font-weight:600; }"
+        "QLabel#confirmDetail { color:#5b7183; font-size:15px; }"));
+#else
     card->setStyleSheet(QStringLiteral(
     card->setStyleSheet(QStringLiteral(
         "QFrame#confirmCard { background:#ffffff; border:1px solid #d3dde9; border-radius:10px; }"
         "QFrame#confirmCard { background:#ffffff; border:1px solid #d3dde9; border-radius:10px; }"
         "QLabel#confirmTitle { color:#20323f; font-size:19px; font-weight:600; }"
         "QLabel#confirmTitle { color:#20323f; font-size:19px; font-weight:600; }"
         "QLabel#confirmDetail { color:#5b7183; font-size:15px; }"));
         "QLabel#confirmDetail { color:#5b7183; font-size:15px; }"));
+#endif
     outer->addWidget(card);
     outer->addWidget(card);
 
 
+#ifndef Q_OS_LINUX
     // 和 ResultToast 一样的柔和投影,让卡片从背景里浮起来
     // 和 ResultToast 一样的柔和投影,让卡片从背景里浮起来
     QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(card);
     QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(card);
     shadow->setBlurRadius(32);
     shadow->setBlurRadius(32);
     shadow->setOffset(0, 8);
     shadow->setOffset(0, 8);
     shadow->setColor(QColor(31, 56, 82, 95));
     shadow->setColor(QColor(31, 56, 82, 95));
     card->setGraphicsEffect(shadow);
     card->setGraphicsEffect(shadow);
+#endif
 
 
     QVBoxLayout *body = new QVBoxLayout(card);
     QVBoxLayout *body = new QVBoxLayout(card);
     body->setContentsMargins(24, 22, 24, 18);
     body->setContentsMargins(24, 22, 24, 18);
@@ -316,25 +339,40 @@ bool promptTaskName(QWidget *parent, const QString &defaultName,
 {
 {
     QDialog dlg(parent);
     QDialog dlg(parent);
     dlg.setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
     dlg.setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
+#ifndef Q_OS_LINUX
     dlg.setAttribute(Qt::WA_TranslucentBackground);
     dlg.setAttribute(Qt::WA_TranslucentBackground);
+#endif
     dlg.setWindowTitle(QStringLiteral("创建任务"));
     dlg.setWindowTitle(QStringLiteral("创建任务"));
     dlg.setFixedWidth(420);
     dlg.setFixedWidth(420);
 
 
     QVBoxLayout *outer = new QVBoxLayout(&dlg);
     QVBoxLayout *outer = new QVBoxLayout(&dlg);
+#ifdef Q_OS_LINUX
+    outer->setContentsMargins(0, 0, 0, 0);
+#else
     outer->setContentsMargins(20, 20, 20, 20);
     outer->setContentsMargins(20, 20, 20, 20);
+#endif
     QFrame *card = new QFrame(&dlg);
     QFrame *card = new QFrame(&dlg);
     card->setObjectName(QStringLiteral("nameCard"));
     card->setObjectName(QStringLiteral("nameCard"));
+#ifdef Q_OS_LINUX
+    card->setStyleSheet(QStringLiteral(
+        "QFrame#nameCard { background:#ffffff; border:1px solid #b9cae0; border-radius:0px; }"
+        "QLabel#nameTitle { color:#20323f; font-size:19px; font-weight:600; }"
+        "QLabel#nameLabel { color:#5b7183; font-size:15px; }"));
+#else
     card->setStyleSheet(QStringLiteral(
     card->setStyleSheet(QStringLiteral(
         "QFrame#nameCard { background:#ffffff; border:1px solid #d3dde9; border-radius:10px; }"
         "QFrame#nameCard { background:#ffffff; border:1px solid #d3dde9; border-radius:10px; }"
         "QLabel#nameTitle { color:#20323f; font-size:19px; font-weight:600; }"
         "QLabel#nameTitle { color:#20323f; font-size:19px; font-weight:600; }"
         "QLabel#nameLabel { color:#5b7183; font-size:15px; }"));
         "QLabel#nameLabel { color:#5b7183; font-size:15px; }"));
+#endif
     outer->addWidget(card);
     outer->addWidget(card);
 
 
+#ifndef Q_OS_LINUX
     QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(card);
     QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(card);
     shadow->setBlurRadius(32);
     shadow->setBlurRadius(32);
     shadow->setOffset(0, 8);
     shadow->setOffset(0, 8);
     shadow->setColor(QColor(31, 56, 82, 95));
     shadow->setColor(QColor(31, 56, 82, 95));
     card->setGraphicsEffect(shadow);
     card->setGraphicsEffect(shadow);
+#endif
 
 
     QVBoxLayout *body = new QVBoxLayout(card);
     QVBoxLayout *body = new QVBoxLayout(card);
     body->setContentsMargins(24, 22, 24, 18);
     body->setContentsMargins(24, 22, 24, 18);
@@ -448,7 +486,10 @@ CreateTaskDialog::CreateTaskDialog(QWidget *parent)
             const QString text = it->text();
             const QString text = it->text();
             it->setText(QString());
             it->setText(QString());
             it->setFlags(Qt::ItemIsEnabled);
             it->setFlags(Qt::ItemIsEnabled);
-            QCheckBox *cb = new QCheckBox(text, list);
+            QString displayText = text;
+            displayText.replace(QLatin1Char('&'), QLatin1String("&&")); // 避免 '&' 被当成快捷键前缀变成下划线
+            QCheckBox *cb = new QCheckBox(displayText, list);
+            cb->setProperty("algoName", text);
             cb->setProperty("role", "algoCheck");
             cb->setProperty("role", "algoCheck");
             cb->setFocusPolicy(Qt::NoFocus);
             cb->setFocusPolicy(Qt::NoFocus);
             cb->setChecked(true);
             cb->setChecked(true);
@@ -1096,9 +1137,29 @@ void CreateTaskDialog::loadUiFrom(const QJsonObject &cfg)
         if (!sec.contains(QStringLiteral("selected")))
         if (!sec.contains(QStringLiteral("selected")))
             return;
             return;
         QStringList sel = fromArray(sec.value(QStringLiteral("selected")));
         QStringList sel = fromArray(sec.value(QStringLiteral("selected")));
+        // 兼容正式发布版的 MT 文案差异与历史拼写(Adress / DMA Test / March C / Galloping Pattern - xxx)
+        static const struct { const char *from; const char *to; } kMtNormalize[] = {
+            {"Adress test, walking ones, 1 CPU", "Address test, walking ones, 1 CPU"},
+            {"DMA Test", "DMA test (experimental)"},
+            {"March C", "March C algorithm"},
+            {"Galloping Pattern - galpat", "Galloping Pattern (GALPAT)"},
+            {"Galloping Pattern - linear", "Galloping Pattern (LINEAR)"},
+            {"Galloping Pattern - randaddr", "Galloping Pattern (RANDOMADDRESS)"},
+            {"Galloping Pattern - bankjump", "Galloping Pattern (BANKJUMP)"},
+            {"Galloping Pattern - victim", "Galloping Pattern (VICTIM)"},
+            {"Galloping Pattern - marchic", "Galloping Pattern (MARCHIC)"},
+            {"Galloping Pattern - marchsse", "Galloping Pattern (MARCHSSE)"},
+            {"Galloping Pattern - butterfly", "Galloping Pattern (BUTTERFLY)"},
+            {"March SS+", "March SS+ algorithm"},
+            {"StressApp", "Stressapp memory stress test"},
+        };
         for (QString &s : sel) {
         for (QString &s : sel) {
-            if (s == QLatin1String("Adress test, walking ones, 1 CPU"))
-                s = QStringLiteral("Address test, walking ones, 1 CPU");
+            for (const auto &rule : kMtNormalize) {
+                if (s.compare(QLatin1String(rule.from), Qt::CaseInsensitive) == 0) {
+                    s = QString::fromLatin1(rule.to);
+                    break;
+                }
+            }
         }
         }
         const QList<QCheckBox *> cbs = algoChecks(list);
         const QList<QCheckBox *> cbs = algoChecks(list);
         // 存档里的名字一个都对不上当前清单 = 清单换过版,按全选处理,
         // 存档里的名字一个都对不上当前清单 = 清单换过版,按全选处理,
@@ -1106,7 +1167,7 @@ void CreateTaskDialog::loadUiFrom(const QJsonObject &cfg)
         if (!sel.isEmpty()) {
         if (!sel.isEmpty()) {
             bool matched = false;
             bool matched = false;
             for (QCheckBox *cb : cbs) {
             for (QCheckBox *cb : cbs) {
-                if (sel.contains(cb->text())) {
+                if (sel.contains(algoNameOf(cb))) {
                     matched = true;
                     matched = true;
                     break;
                     break;
                 }
                 }
@@ -1118,7 +1179,7 @@ void CreateTaskDialog::loadUiFrom(const QJsonObject &cfg)
             }
             }
         }
         }
         for (QCheckBox *cb : cbs)
         for (QCheckBox *cb : cbs)
-            cb->setChecked(sel.contains(cb->text()));
+            cb->setChecked(sel.contains(algoNameOf(cb)));
     };
     };
     const QJsonObject mtCfg = cfg.value(QStringLiteral("mt")).toObject();
     const QJsonObject mtCfg = cfg.value(QStringLiteral("mt")).toObject();
     apply(ui->algoList, mtCfg);
     apply(ui->algoList, mtCfg);

+ 4 - 6
src/detailview.cpp

@@ -585,7 +585,7 @@ void DetailView::renderCurve()
     p->yAxis->setRange(yLo, yHi);
     p->yAxis->setRange(yLo, yHi);
 
 
     // 最新点标记 + 数值标签:贴在最后一个采样点下方
     // 最新点标记 + 数值标签:贴在最后一个采样点下方
-    if (m_lastDot && m_lastLabel && n > 0) {
+    if (m_lastDot && m_lastLabel && n > 0 && values.last() >= 0.0) {
         const double k = keys.last();
         const double k = keys.last();
         const double v = values.last();
         const double v = values.last();
 
 
@@ -593,10 +593,9 @@ void DetailView::renderCurve()
         m_lastDot->setGraphKey(k);
         m_lastDot->setGraphKey(k);
         m_lastDot->setVisible(true);
         m_lastDot->setVisible(true);
 
 
-        // 读不到温度(<0 是占位值)时不贴数值标签,免得曲线末端挂一个 -1.0°C
-        m_lastLabel->setText(v >= 0.0 ? ui::formatTemp(v) : QString());
+        m_lastLabel->setText(ui::formatTemp(v));
         m_lastLabel->position->setCoords(k, v);
         m_lastLabel->position->setCoords(k, v);
-        m_lastLabel->setVisible(v >= 0.0);
+        m_lastLabel->setVisible(true);
 
 
         // 点贴近轴的右边缘时改成右对齐,否则标签会甩到图外
         // 点贴近轴的右边缘时改成右对齐,否则标签会甩到图外
         const double px = p->xAxis->coordToPixel(k);
         const double px = p->xAxis->coordToPixel(k);
@@ -739,8 +738,7 @@ void DetailView::updateStatusIndicators()
         const bool isFail = (d.verdict == QLatin1String("fail")
         const bool isFail = (d.verdict == QLatin1String("fail")
                              || d.taskStatus == QLatin1String("failed")
                              || d.taskStatus == QLatin1String("failed")
                              || d.awaitingDimmReplacement
                              || d.awaitingDimmReplacement
-                             || failSlots > 0
-                             || nAlarms > 0);
+                             || failSlots > 0);
         if (!isFail) {
         if (!isFail) {
             m_failBanner->setVisible(false);
             m_failBanner->setVisible(false);
         } else {
         } else {

+ 29 - 0
src/localplans.cpp

@@ -63,6 +63,35 @@ int parseMtTestValue(const QJsonValue &v)
         if (lower == QLatin1String(kMtCanonicalNames[i]))
         if (lower == QLatin1String(kMtCanonicalNames[i]))
             return i;
             return i;
     }
     }
+    // 兼容正式发布版 / 简化名称写法(如 "DMA Test", "March C", "Galloping Pattern - galpat")
+    static const struct { const char *alias; int idx; } kMtAliases[] = {
+        {"dma test", 14},
+        {"march c", 15},
+        {"galloping pattern - galpat", 16},
+        {"galpat", 16},
+        {"galloping pattern - linear", 17},
+        {"galpat linear", 17},
+        {"galloping pattern - randaddr", 18},
+        {"galloping pattern - randomaddress", 18},
+        {"galloping pattern (randaddr)", 18},
+        {"galpat randaddr", 18},
+        {"galloping pattern - bankjump", 19},
+        {"galpat bankjump", 19},
+        {"galloping pattern - victim", 20},
+        {"galpat victim", 20},
+        {"galloping pattern - marchic", 21},
+        {"galpat marchic", 21},
+        {"galloping pattern - marchsse", 22},
+        {"galpat marchsse", 22},
+        {"galloping pattern - butterfly", 23},
+        {"galpat butterfly", 23},
+        {"march ss+", 24},
+        {"stressapp", 25},
+    };
+    for (const auto &entry : kMtAliases) {
+        if (lower == QLatin1String(entry.alias))
+            return entry.idx;
+    }
     if (lower.startsWith(QLatin1String("test "))) {
     if (lower.startsWith(QLatin1String("test "))) {
         bool ok = false;
         bool ok = false;
         const int n = lower.mid(5).trimmed().toInt(&ok);
         const int n = lower.mid(5).trimmed().toInt(&ok);

+ 136 - 28
src/mainwindow.cpp

@@ -183,27 +183,42 @@ public:
         : QDialog(parent)
         : QDialog(parent)
     {
     {
         setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
         setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
-        setAttribute(Qt::WA_TranslucentBackground); // 圆角外留白要透出底下的界面
+#ifndef Q_OS_LINUX
+        setAttribute(Qt::WA_TranslucentBackground); // 圆角外留白要透出底下的界面(Windows DWM 始终合成)
+#endif
         setWindowTitle(title.isEmpty() ? (ok ? QStringLiteral("设置成功") : QStringLiteral("设置失败"))
         setWindowTitle(title.isEmpty() ? (ok ? QStringLiteral("设置成功") : QStringLiteral("设置失败"))
                                        : title);
                                        : title);
         setFixedWidth(detail.isEmpty() ? 360 : 420);
         setFixedWidth(detail.isEmpty() ? 360 : 420);
 
 
         QVBoxLayout *outer = new QVBoxLayout(this);
         QVBoxLayout *outer = new QVBoxLayout(this);
+#ifdef Q_OS_LINUX
+        outer->setContentsMargins(0, 0, 0, 0); // Linux VNC/Xvfb 无窗口合成器时 WA_TranslucentBackground 会发黑
+#else
         outer->setContentsMargins(24, 24, 24, 24); // 给阴影留出绘制空间
         outer->setContentsMargins(24, 24, 24, 24); // 给阴影留出绘制空间
+#endif
 
 
         QFrame *card = new QFrame(this);
         QFrame *card = new QFrame(this);
         card->setObjectName(QStringLiteral("toastCard"));
         card->setObjectName(QStringLiteral("toastCard"));
+#ifdef Q_OS_LINUX
+        card->setStyleSheet(QStringLiteral(
+            "QFrame#toastCard { background: #ffffff; border: 1px solid #b9cae0; border-radius: 0px; }"
+            "QLabel#toastTitle { color: #20323f; font-size: 19px; font-weight: 600; }"
+            "QLabel#toastDetail { color: #5b7183; font-size: 15px; }"));
+#else
         card->setStyleSheet(QStringLiteral(
         card->setStyleSheet(QStringLiteral(
             "QFrame#toastCard { background: #ffffff; border: 1px solid #d3dde9; border-radius: 10px; }"
             "QFrame#toastCard { background: #ffffff; border: 1px solid #d3dde9; border-radius: 10px; }"
             "QLabel#toastTitle { color: #20323f; font-size: 19px; font-weight: 600; }"
             "QLabel#toastTitle { color: #20323f; font-size: 19px; font-weight: 600; }"
             "QLabel#toastDetail { color: #5b7183; font-size: 15px; }"));
             "QLabel#toastDetail { color: #5b7183; font-size: 15px; }"));
+#endif
         outer->addWidget(card);
         outer->addWidget(card);
 
 
+#ifndef Q_OS_LINUX
         QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(card);
         QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(card);
         shadow->setBlurRadius(32);
         shadow->setBlurRadius(32);
         shadow->setOffset(0, 8);
         shadow->setOffset(0, 8);
         shadow->setColor(QColor(31, 56, 82, 95));
         shadow->setColor(QColor(31, 56, 82, 95));
         card->setGraphicsEffect(shadow);
         card->setGraphicsEffect(shadow);
+#endif
 
 
         QVBoxLayout *body = new QVBoxLayout(card);
         QVBoxLayout *body = new QVBoxLayout(card);
         body->setContentsMargins(24, 22, 24, 18);
         body->setContentsMargins(24, 22, 24, 18);
@@ -432,24 +447,42 @@ MainWindow::MainWindow(QWidget *parent)
     connect(m_backend, &BackendLink::stateArrived, this, [this](int station, const QJsonObject &st) {
     connect(m_backend, &BackendLink::stateArrived, this, [this](int station, const QJsonObject &st) {
         m_store->applyBackendState(station, st);
         m_store->applyBackendState(station, st);
 
 
-        // 按钮状态只由本地点击决定,不从后端同步:开屏一律「开始测试」,
-        // 点了才变「重新开始」并下发 StartTest(运行过程中允许再次点击直接重跑)。
-        // 现场口径:后端收到 StartTest 会立刻复位主机重跑本轮,界面不需要替它判断能不能跑。
-        // 万一后端真的拒了,startTestReplied 会把按钮退回「开始测试」并写明原因。
-        // 下面这段只负责把跑完的工位复位——且必须分清是「本轮跑完」还是「还没起跑的旧 idle」。
         const QString runState = st.value(QStringLiteral("run_state")).toString();
         const QString runState = st.value(QStringLiteral("run_state")).toString();
+        const QString bootId = st.value(QStringLiteral("boot_id")).toString();
+        const QString phase = st.value(QStringLiteral("phase")).toString();
+        const qint64 startedMs = m_store->station(station).backendStartedMs;
+        if (m_awaitingNewStart[station]) {
+            const bool earlyStage = (phase == QLatin1String("boot")
+                                     || phase == QLatin1String("uip")
+                                     || phase == QLatin1String("uip1")
+                                     || phase == QLatin1String("training")
+                                     || phase == QLatin1String("powered_off"));
+            const bool bootChanged = (!bootId.isEmpty() && bootId != m_waitOldBootId[station]);
+            const bool startChanged = (startedMs > 0 && startedMs != m_waitOldStartedMs[station]);
+            const bool graceElapsed = (!m_clickTimer[station].isValid()
+                                       || m_clickTimer[station].elapsed() > 5000);
+            if (bootChanged || startChanged || earlyStage || graceElapsed) {
+                m_awaitingNewStart[station] = false;
+            } else {
+                m_overview->setStartRunning(station, m_startClicked[station] || m_backendRunning[station]);
+                return;
+            }
+        }
+
         const bool running = (runState == QStringLiteral("starting")
         const bool running = (runState == QStringLiteral("starting")
                               || runState == QStringLiteral("running")
                               || runState == QStringLiteral("running")
                               || runState == QStringLiteral("waiting_input"));
                               || runState == QStringLiteral("waiting_input"));
 
 
-        // 后端运行态:见到 starting/running/waiting_input 就记住,completed/failed 才清。
-        // 这样网页端 / 其他客户端发起的测试,本机也显示「执行中」;
+        // 后端运行态:见到 starting/running/waiting_input 就记住,终态(completed/failed/stopped/interrupted/aborted/error/timeout/blocked)才清。
+        // 这样网页端 / 其他客户端发起的测试或重开软件时,本机按钮也能正确同步为运行态;
         // 主机复位过程中短暂回到 idle 也不会让按钮闪回「开始测试」。
         // 主机复位过程中短暂回到 idle 也不会让按钮闪回「开始测试」。
-        // 手册 9.2:run_state 新增 blocked(阶段 FAIL 后的换条停机挂起),
-        // 同样算本轮终态,要停表 / 复位按钮,但队列由 finishCurrentTask 决定是否中止。
         const bool terminal = (runState == QStringLiteral("completed")
         const bool terminal = (runState == QStringLiteral("completed")
                                || runState == QStringLiteral("failed")
                                || runState == QStringLiteral("failed")
                                || runState == QStringLiteral("interrupted")
                                || runState == QStringLiteral("interrupted")
+                               || runState == QStringLiteral("stopped")
+                               || runState == QStringLiteral("aborted")
+                               || runState == QStringLiteral("error")
+                               || runState == QStringLiteral("timeout")
                                || runState == QStringLiteral("blocked"));
                                || runState == QStringLiteral("blocked"));
         if (running) {
         if (running) {
             if (!m_backendRunning[station]) {
             if (!m_backendRunning[station]) {
@@ -518,8 +551,32 @@ MainWindow::MainWindow(QWidget *parent)
                           .arg(taskName).arg(targetTemp));
                           .arg(taskName).arg(targetTemp));
         }
         }
 
 
-        if (terminal && !waitingInitialRun)
+        const StationData stNow = m_store->station(station);
+        const bool hostPhaseActive =
+            (stNow.phase == QLatin1String("boot")
+             || stNow.phase == QLatin1String("booting")
+             || stNow.phase == QLatin1String("uip")
+             || stNow.phase == QLatin1String("uip1")
+             || stNow.phase == QLatin1String("uip2")
+             || stNow.phase == QLatin1String("training")
+             || stNow.phase == QLatin1String("rmt")
+             || stNow.phase == QLatin1String("amt")
+             || stNow.phase == QLatin1String("post")
+             || stNow.phase == QLatin1String("uefi")
+             || stNow.phase == QLatin1String("mt"));
+        const bool hostStillActive =
+            hostPhaseActive
+            && (stNow.connection == QLatin1String("online") || stNow.consoleOnline == 1)
+            && st.value(QStringLiteral("power")).toString() != QLatin1String("off");
+        const bool restartClick = m_backend->lastStartWasRestart(station);
+        const bool idleSettled = !restartClick || m_clickTimer[station].elapsed() > 60000;
+
+        if ((terminal
+             || (runState == QLatin1String("idle") && !hostStillActive
+                 && (!m_startClicked[station] || idleSettled)))
+            && !waitingInitialRun) {
             m_backendRunning[station] = false;
             m_backendRunning[station] = false;
+        }
 
 
         // 终态冻结已由后端 ended_unix_ms / elapsed_ms 权威控制,前端不再私自停表或重置。
         // 终态冻结已由后端 ended_unix_ms / elapsed_ms 权威控制,前端不再私自停表或重置。
 
 
@@ -531,16 +588,18 @@ MainWindow::MainWindow(QWidget *parent)
             //
             //
             // 「跑着的时候点重新开始」还有一层坑:主机复位过程中后端会短暂回到 idle,
             // 「跑着的时候点重新开始」还有一层坑:主机复位过程中后端会短暂回到 idle,
             // 那并不代表本轮结束。所以这种情况下的 idle 要等一分钟再认,
             // 那并不代表本轮结束。所以这种情况下的 idle 要等一分钟再认,
-            // 否则按钮会在新一轮刚开始时闪回「开始测试」,用户以为没起来又点一次。
-            const bool restartClick = m_backend->lastStartWasRestart(station);
-            const bool idleSettled = !restartClick || m_clickTimer[station].elapsed() > 60000;
+            // 且当主机在线并仍处于测试阶段(boot/training/amt/mt 等)时,禁止将 idle 误判为测试结束。
             bool finished = (!waitingInitialRun
             bool finished = (!waitingInitialRun
                              && (runState == QStringLiteral("completed")
                              && (runState == QStringLiteral("completed")
                                  || runState == QStringLiteral("failed")
                                  || runState == QStringLiteral("failed")
                                  || runState == QStringLiteral("interrupted")
                                  || runState == QStringLiteral("interrupted")
+                                 || runState == QStringLiteral("stopped")
+                                 || runState == QStringLiteral("aborted")
+                                 || runState == QStringLiteral("error")
+                                 || runState == QStringLiteral("timeout")
                                  || runState == QStringLiteral("blocked")))
                                  || runState == QStringLiteral("blocked")))
                             || (runState == QStringLiteral("idle") && m_sawRunning[station]
                             || (runState == QStringLiteral("idle") && m_sawRunning[station]
-                                && idleSettled);
+                                && idleSettled && !hostStillActive);
             // 多任务队列还没跑完(后面还有任务在等着发):按钮保持「执行中」,不要复位
             // 多任务队列还没跑完(后面还有任务在等着发):按钮保持「执行中」,不要复位
             if (m_taskIndex[station] >= 0 && m_taskIndex[station] < m_taskQueue[station].size())
             if (m_taskIndex[station] >= 0 && m_taskIndex[station] < m_taskQueue[station].size())
                 finished = false;
                 finished = false;
@@ -572,10 +631,8 @@ MainWindow::MainWindow(QWidget *parent)
             }
             }
         }
         }
 
 
-        // 按钮只由「本机点过开始测试」决定:每次打开软件一律显示「开始测试」,
-        // 不继承后端推来的上一轮运行态(开屏不能残留上次的「执行中」)。
-        // 后端在跑、网页端发起的测试都不改本机按钮,现场口径由本地点击驱动。
-        m_overview->setStartRunning(station, m_startClicked[station]);
+        // 按钮状态同步本地点击与后端实际运行态:重开软件、网页端启动或后端停机都能一致反映。
+        m_overview->setStartRunning(station, m_startClicked[station] || m_backendRunning[station]);
     });
     });
     // StartTest 被后端拒掉 / 命令失败:立刻把「执行中」退回「开始测试」并写明原因。
     // StartTest 被后端拒掉 / 命令失败:立刻把「执行中」退回「开始测试」并写明原因。
     // 少了这一步,按钮只能等 20 s 兜底才复位,现场看起来就是「点了没反应、
     // 少了这一步,按钮只能等 20 s 兜底才复位,现场看起来就是「点了没反应、
@@ -612,7 +669,11 @@ MainWindow::MainWindow(QWidget *parent)
             return;
             return;
         const bool terminalTask = (taskStatus == QStringLiteral("completed")
         const bool terminalTask = (taskStatus == QStringLiteral("completed")
                                    || taskStatus == QStringLiteral("failed")
                                    || taskStatus == QStringLiteral("failed")
-                                   || taskStatus == QStringLiteral("interrupted"));
+                                   || taskStatus == QStringLiteral("interrupted")
+                                   || taskStatus == QStringLiteral("stopped")
+                                   || taskStatus == QStringLiteral("aborted")
+                                   || taskStatus == QStringLiteral("error")
+                                   || taskStatus == QStringLiteral("timeout"));
         if (complete && terminalTask) {
         if (complete && terminalTask) {
             // completed 命令回执可能先于 task_complete(其中才带 verdict / stage_completions)。
             // completed 命令回执可能先于 task_complete(其中才带 verdict / stage_completions)。
             // 若当前还没有任何 verdict,先等权威事件;旧后端没有该事件时仍由 state 终态兜底。
             // 若当前还没有任何 verdict,先等权威事件;旧后端没有该事件时仍由 state 终态兜底。
@@ -644,6 +705,33 @@ MainWindow::MainWindow(QWidget *parent)
         if (m_overview)
         if (m_overview)
             m_overview->setBackendOnline(connected);
             m_overview->setBackendOnline(connected);
     });
     });
+    connect(m_backend, &BackendLink::serverRestarted, this, [this]() {
+        for (int i = 0; i < m_store->count(); ++i) {
+            if (m_nextTaskTimer[i] && m_nextTaskTimer[i]->isActive())
+                m_nextTaskTimer[i]->stop();
+            const bool wasActive = m_startClicked[i] || m_backendRunning[i];
+            m_startClicked[i] = false;
+            m_sawRunning[i] = false;
+            m_backendRunning[i] = false;
+            m_endCmdSent[i] = false;
+            m_endSignalReceived[i] = false;
+            m_terminalSince[i].invalidate();
+            m_taskCompleteVerdict[i].clear();
+            m_tempSent[i] = false;
+            m_awaitingNewStart[i] = false;
+            m_taskAdvanceGuard[i] = false;
+            if (m_taskIndex[i] >= 0) {
+                m_taskFailed[i] = m_taskIndex[i];
+                m_store->setTaskProgress(i, m_taskIndex[i], -1, m_taskFailed[i]);
+                m_taskIndex[i] = -1;
+                m_taskQueue[i] = QJsonArray();
+            }
+            if (m_overview)
+                m_overview->setStartRunning(i, false);
+            if (wasActive)
+                m_store->appendLog(i, QStringLiteral("[qt] 后端实例已重启,本机运行态与任务队列已复位"));
+        }
+    });
 
 
     setupDetail();
     setupDetail();
     setupCom();
     setupCom();
@@ -787,6 +875,9 @@ void MainWindow::startTest(int index)
 
 
     // 新一轮点击「开始测试」时先清显示为 00:00:00,等待后端下发新起点 started_unix_ms / elapsed_ms。
     // 新一轮点击「开始测试」时先清显示为 00:00:00,等待后端下发新起点 started_unix_ms / elapsed_ms。
     m_store->resetBackendTiming(index);
     m_store->resetBackendTiming(index);
+    m_waitOldBootId[index] = m_store->station(index).bootId;
+    m_waitOldStartedMs[index] = m_store->station(index).backendStartedMs;
+    m_awaitingNewStart[index] = true;
     m_backendRunning[index] = false;  // 本次 StartTest 是新一轮,等待后端重新进入运行态
     m_backendRunning[index] = false;  // 本次 StartTest 是新一轮,等待后端重新进入运行态
     m_endCmdSent[index] = false;
     m_endCmdSent[index] = false;
     m_endSignalReceived[index] = false;
     m_endSignalReceived[index] = false;
@@ -905,7 +996,11 @@ bool MainWindow::backendRoundFailed(int station, const QString &stateOrStatus) c
     if (station < 0 || station >= m_store->count())
     if (station < 0 || station >= m_store->count())
         return false;
         return false;
     if (stateOrStatus == QStringLiteral("failed")
     if (stateOrStatus == QStringLiteral("failed")
-        || stateOrStatus == QStringLiteral("interrupted"))
+        || stateOrStatus == QStringLiteral("interrupted")
+        || stateOrStatus == QStringLiteral("stopped")
+        || stateOrStatus == QStringLiteral("aborted")
+        || stateOrStatus == QStringLiteral("error")
+        || stateOrStatus == QStringLiteral("timeout"))
         return true;
         return true;
     // 0.8.1.19:training / rmt / amt / mt 任一阶段 FAIL 时,后端可能把本轮
     // 0.8.1.19:training / rmt / amt / mt 任一阶段 FAIL 时,后端可能把本轮
     // task_status 报成 completed(阶段完整跑完、但结论是 fail)。这种情况同样
     // task_status 报成 completed(阶段完整跑完、但结论是 fail)。这种情况同样
@@ -1059,6 +1154,9 @@ void MainWindow::startNextTask(int station)
     // 多任务同一批次延续后端总计时,不清空计时显示,也不重算 started_unix_ms;只清本任务日志与异常记录
     // 多任务同一批次延续后端总计时,不清空计时显示,也不重算 started_unix_ms;只清本任务日志与异常记录
     m_store->clearLogs(station);
     m_store->clearLogs(station);
     m_store->clearAlarms(station);
     m_store->clearAlarms(station);
+    m_waitOldBootId[station] = m_store->station(station).bootId;
+    m_waitOldStartedMs[station] = m_store->station(station).backendStartedMs;
+    m_awaitingNewStart[station] = true;
     m_backendRunning[station] = false; // 新任务开始,重新识别运行态切换
     m_backendRunning[station] = false; // 新任务开始,重新识别运行态切换
     m_tempSent[station] = false;
     m_tempSent[station] = false;
     m_endCmdSent[station] = false;
     m_endCmdSent[station] = false;
@@ -1313,6 +1411,9 @@ void MainWindow::showCreateTask()
         if (!m_backend->isConnected())
         if (!m_backend->isConnected())
             return false;
             return false;
         const StationData &d = m_store->station(station);
         const StationData &d = m_store->station(station);
+        if (d.connection == QLatin1String("online")
+            && d.phase == QLatin1String("powered_off"))
+            return true;
         if (d.consoleOnline == 0)
         if (d.consoleOnline == 0)
             return false;
             return false;
         if (d.consoleOnline == 1)
         if (d.consoleOnline == 1)
@@ -1392,13 +1493,20 @@ void MainWindow::setupCom()
     connect(m_com, &ComManager::ctRawArrived, this, [this](int index, const QByteArray &raw) {
     connect(m_com, &ComManager::ctRawArrived, this, [this](int index, const QByteArray &raw) {
         m_store->applyCtTemperatures(index, raw);
         m_store->applyCtTemperatures(index, raw);
     });
     });
-    // 24 通道内存条温度已改为从后端 state 推送的 channels[i].temperature_c 获取
-    // (见 StationStore::applyBackendState),本地 MCU 串口 0x82 的 24 路温度不再写进 UI。
-    // MCU 温控框架与高温罩目标温度下发(setTargetTemp / targetTempSent / targetTempReplied)全部保留。
-    // 如需回退到 MCU 串口来源:取消下面这段注释即可恢复连接。
-    // connect(m_com, &ComManager::channelRawArrived, this, [this](int index, const QByteArray &raw) {
-    //     m_store->applyChannelTemperatures(index, raw);
-    // });
+    // 24 路内存条温度双源接入:有后端 channels[i].temperature_c 时按后端精确浮点和在位状态显示,
+    // 后端未上送有效值且 MCU 0x82 有新鲜有效字节(3 秒内 != 0xFF)时自动补位(并支持 DDR5_DEBUG_TEMP 排查)。
+    connect(m_com, &ComManager::channelRawArrived, this, [this](int index, const QByteArray &raw) {
+        m_store->applyChannelTemperatures(index, raw);
+        if (qEnvironmentVariableIsSet("DDR5_DEBUG_TEMP")) {
+            QStringList vals;
+            vals.reserve(raw.size());
+            for (int i = 0; i < raw.size(); ++i) {
+                const quint8 b = static_cast<quint8>(raw.at(i));
+                vals << (b == 0xFF ? QStringLiteral("--") : QString::number(b));
+            }
+            qInfo().noquote() << "[temp]" << index << vals.join(QLatin1Char(' '));
+        }
+    });
 
 
     // 目标温度下发:帧发没发出去、设备收没收,都写进该工位的日志,现场能直接看到
     // 目标温度下发:帧发没发出去、设备收没收,都写进该工位的日志,现场能直接看到
     connect(m_com, &ComManager::targetTempSent, this, [this](int index, int celsius, bool ok) {
     connect(m_com, &ComManager::targetTempSent, this, [this](int index, int celsius, bool ok) {

+ 5 - 0
src/mainwindow.h

@@ -129,6 +129,11 @@ private:
     bool m_endSignalReceived[4] = {false, false, false, false};
     bool m_endSignalReceived[4] = {false, false, false, false};
     QElapsedTimer m_terminalSince[4];
     QElapsedTimer m_terminalSince[4];
     QString m_taskCompleteVerdict[4];   // 本轮 task_complete 的 verdict(pass/fail)
     QString m_taskCompleteVerdict[4];   // 本轮 task_complete 的 verdict(pass/fail)
+    // 点击开始/重启时的旧轮次锚点:在看到新 boot_id / started_unix_ms 或重新回到早期阶段前,
+    // 忽略旧轮次的 running / terminal state,避免重启瞬间提前触发 0x01 或误置 m_sawRunning。
+    bool m_awaitingNewStart[4] = {false, false, false, false};
+    QString m_waitOldBootId[4];
+    qint64 m_waitOldStartedMs[4] = {0, 0, 0, 0};
 
 
 
 
     // ---- 多任务串行执行 ----
     // ---- 多任务串行执行 ----

+ 9 - 8
src/overviewview.cpp

@@ -199,12 +199,17 @@ void OverviewView::renderInfo(int index)
         const bool linkLost = (d.connection == QLatin1String("offline")
         const bool linkLost = (d.connection == QLatin1String("offline")
                                || d.connection == QLatin1String("error"));
                                || d.connection == QLatin1String("error"));
         const bool consoleConfirmed = (d.consoleOnline == 1);
         const bool consoleConfirmed = (d.consoleOnline == 1);
+        // BMC 在线且主机显式关机(powered_off)时,SOL 串口必然无输出,不应误判「控制台离线」
+        const bool bmcPoweredOff = (d.connection == QLatin1String("online")
+                                    && d.phase == QLatin1String("powered_off"));
         const bool offline = !m_backendOnline
         const bool offline = !m_backendOnline
-                             || (d.consoleOnline == 0)
+                             || (!bmcPoweredOff && (d.consoleOnline == 0))
                              || (!consoleConfirmed && (linkLost || text.isEmpty()));
                              || (!consoleConfirmed && (linkLost || text.isEmpty()));
         const bool isFail = (d.verdict == QLatin1String("fail")
         const bool isFail = (d.verdict == QLatin1String("fail")
                              || d.taskStatus == QLatin1String("failed"));
                              || d.taskStatus == QLatin1String("failed"));
-        const bool hasErr = isFail || d.awaitingDimmReplacement || !d.alarms.isEmpty();
+        // 已 ConfirmDimmReplacement 后后端清空 stage_errors 并置 idle/not_started;
+        // 旧轮次保留在详情页供查看,但总览卡片状态胶囊与标题恢复正常,不永久挂红
+        const bool hasErr = isFail || d.awaitingDimmReplacement;
         QString scopeLabel = d.verdictScope.isEmpty() ? text : d.verdictScope.toUpper();
         QString scopeLabel = d.verdictScope.isEmpty() ? text : d.verdictScope.toUpper();
         if (scopeLabel.isEmpty())
         if (scopeLabel.isEmpty())
             scopeLabel = QStringLiteral("本轮");
             scopeLabel = QStringLiteral("本轮");
@@ -217,10 +222,6 @@ void OverviewView::renderInfo(int index)
             text = d.alarms.isEmpty()
             text = d.alarms.isEmpty()
                        ? QStringLiteral("%1 FAIL").arg(scopeLabel)
                        ? QStringLiteral("%1 FAIL").arg(scopeLabel)
                        : QStringLiteral("%1 FAIL · 异常 %2").arg(scopeLabel).arg(d.alarms.size());
                        : QStringLiteral("%1 FAIL · 异常 %2").arg(scopeLabel).arg(d.alarms.size());
-        } else if (!d.alarms.isEmpty()) {
-            text = QStringLiteral("%1 · 异常 %2")
-                       .arg(text.isEmpty() ? QStringLiteral("在线") : text)
-                       .arg(d.alarms.size());
         } else if (text.isEmpty()) {
         } else if (text.isEmpty()) {
             text = QStringLiteral("在线");   // 控制台确认在线但阶段未知:标题右边不留空白
             text = QStringLiteral("在线");   // 控制台确认在线但阶段未知:标题右边不留空白
         }
         }
@@ -243,11 +244,11 @@ void OverviewView::renderInfo(int index)
             }
             }
             if ((isFail || d.awaitingDimmReplacement) && failSlots == 0) {
             if ((isFail || d.awaitingDimmReplacement) && failSlots == 0) {
                 m_chTitles[index]->setText(
                 m_chTitles[index]->setText(
-                    QStringLiteral("内存通道状态 · 测试 FAIL(%1 条异常未映射具体通道,点查看详情)")
+                    QStringLiteral("24 通道内存测试状态 · FAIL(%1 条未映射通道,点查看详情)")
                         .arg(d.alarms.size()));
                         .arg(d.alarms.size()));
                 m_chTitles[index]->setStyleSheet(QStringLiteral("color:#c92f2f;"));
                 m_chTitles[index]->setStyleSheet(QStringLiteral("color:#c92f2f;"));
             } else {
             } else {
-                m_chTitles[index]->setText(QStringLiteral("内存通道状态"));
+                m_chTitles[index]->setText(QStringLiteral("24 通道内存测试状态"));
                 m_chTitles[index]->setStyleSheet(QString());
                 m_chTitles[index]->setStyleSheet(QString());
             }
             }
         }
         }

+ 5 - 0
src/sltproto.cpp

@@ -32,6 +32,11 @@ QByteArray buildFrame(quint8 cmd, const QByteArray &payload)
     return f;
     return f;
 }
 }
 
 
+QByteArray frameRequestChannels()
+{
+    return buildFrame(kCmdReqChannels);
+}
+
 QByteArray frameRequestCt7428()
 QByteArray frameRequestCt7428()
 {
 {
     return buildFrame(kCmdReqCt7428);
     return buildFrame(kCmdReqCt7428);

+ 4 - 0
src/sltproto.h

@@ -25,6 +25,7 @@ const quint8 kHdr1 = 0x55;
 
 
 // PC → MCU
 // PC → MCU
 const quint8 kCmdSetTargetTemp = 0x01; // 设置目标温度(会连带启动预加热)→ 0x81
 const quint8 kCmdSetTargetTemp = 0x01; // 设置目标温度(会连带启动预加热)→ 0x81
+const quint8 kCmdReqChannels   = 0x02; // 请求 24 路内存通道温度 → 0x82
 const quint8 kCmdReqCt7428   = 0x0D;   // 请求 CT7428 八路温度 → 0x8D
 const quint8 kCmdReqCt7428   = 0x0D;   // 请求 CT7428 八路温度 → 0x8D
 const quint8 kCmdTestEnd     = 0x08;   // 测试结束通知(0x08 + 1B 模式载荷,见 frameTestEnd)
 const quint8 kCmdTestEnd     = 0x08;   // 测试结束通知(0x08 + 1B 模式载荷,见 frameTestEnd)
 
 
@@ -46,6 +47,9 @@ quint8 crc8(const QByteArray &data);
 // 组帧:AA 55 CMD LEN [Payload] CRC8
 // 组帧:AA 55 CMD LEN [Payload] CRC8
 QByteArray buildFrame(quint8 cmd, const QByteArray &payload = QByteArray());
 QByteArray buildFrame(quint8 cmd, const QByteArray &payload = QByteArray());
 
 
+// 请求 24 路 BMC 温度
+QByteArray frameRequestChannels();     // AA 55 02 00 AD
+
 // 请求 CT7428 八路温度(CRC 运行时实时计算)
 // 请求 CT7428 八路温度(CRC 运行时实时计算)
 QByteArray frameRequestCt7428();       // AA 55 0D 00 6E
 QByteArray frameRequestCt7428();       // AA 55 0D 00 6E
 
 

+ 86 - 24
src/stationdata.cpp

@@ -139,24 +139,31 @@ void StationStore::clearTemperatures(int index)
         return;
         return;
 
 
     StationData &d = m_stations[index];
     StationData &d = m_stations[index];
-    bool changed = false;
+    bool tempChanged = false;
+    bool chChanged = false;
 
 
     if (d.currentTemp >= 0.0) {
     if (d.currentTemp >= 0.0) {
         d.currentTemp = -1.0;
         d.currentTemp = -1.0;
-        changed = true;
+        tempChanged = true;
     }
     }
 
 
     for (ChannelInfo &ch : d.channels) {
     for (ChannelInfo &ch : d.channels) {
-        if (ch.temperature >= 0.0) {
-            ch.temperature = -1.0;
-            changed = true;
+        ch.mcuTempMs = 0;
+        ch.mcuTempC = -1;
+        if (ch.tempFromMcu) {
+            ch.tempFromMcu = false;
+            const double fallback = (ch.backendPresent && ch.hasBackendTemp) ? ch.backendTemp : -1.0;
+            if (qAbs(ch.temperature - fallback) > 0.05 || (ch.temperature < 0.0) != (fallback < 0.0)) {
+                ch.temperature = fallback;
+                chChanged = true;
+            }
         }
         }
     }
     }
 
 
-    if (changed) {
+    if (tempChanged)
         emit temperatureChanged(index);
         emit temperatureChanged(index);
+    if (chChanged)
         emit channelsChanged(index);
         emit channelsChanged(index);
-    }
 }
 }
 
 
 void StationStore::setCurrentTemp(int index, double temperature)
 void StationStore::setCurrentTemp(int index, double temperature)
@@ -286,6 +293,11 @@ void StationStore::resetChannelResults(int index)
     for (ChannelInfo &ch : channels) {
     for (ChannelInfo &ch : channels) {
         ch.state = ChannelInfo::Idle;
         ch.state = ChannelInfo::Idle;
         ch.temperature = -1.0;
         ch.temperature = -1.0;
+        ch.hasBackendTemp = false;
+        ch.backendTemp = -1.0;
+        ch.mcuTempMs = 0;
+        ch.mcuTempC = -1;
+        ch.tempFromMcu = false;
         ch.history.clear();
         ch.history.clear();
         ch.historyStart = 0;
         ch.historyStart = 0;
     }
     }
@@ -357,10 +369,12 @@ void StationStore::applyChannelTemperatures(int index, const QByteArray &raw24)
     if (index < 0 || index >= m_stations.size())
     if (index < 0 || index >= m_stations.size())
         return;
         return;
 
 
-    QVector<ChannelInfo> &channels = m_stations[index].channels;
+    StationData &d = m_stations[index];
+    QVector<ChannelInfo> &channels = d.channels;
     if (raw24.size() != channels.size())
     if (raw24.size() != channels.size())
         return;                       // 应答长度不对(比如还夹着别的 CMD)就整帧丢
         return;                       // 应答长度不对(比如还夹着别的 CMD)就整帧丢
 
 
+    const qint64 now = QDateTime::currentMSecsSinceEpoch();
     bool changed = false;
     bool changed = false;
     bool curveChanged = false;
     bool curveChanged = false;
 
 
@@ -369,7 +383,25 @@ void StationStore::applyChannelTemperatures(int index, const QByteArray &raw24)
         ChannelInfo &ch = channels[i];
         ChannelInfo &ch = channels[i];
 
 
         if (b == 0xFF) {
         if (b == 0xFF) {
-            // 无读数:温度退回 -1(界面 --℃),状态保持后端给的那个字不动
+            // MCU 该路无读数(0xFF):清除新鲜 MCU 标记,优先回落到后端 temperature_c(如有)
+            ch.mcuTempMs = 0;
+            ch.mcuTempC = -1;
+            if (ch.tempFromMcu) {
+                ch.tempFromMcu = false;
+                const double fallback = (ch.backendPresent && ch.hasBackendTemp) ? ch.backendTemp : -1.0;
+                if (qAbs(ch.temperature - fallback) > 0.05 || (ch.temperature < 0.0) != (fallback < 0.0)) {
+                    ch.temperature = fallback;
+                    changed = true;
+                }
+            }
+            continue;
+        }
+
+        // 后端明确判定该槽位为空槽(present=false)时,即使 MCU 有读数也显示 --℃
+        if (d.backendHasChannels && !ch.backendPresent) {
+            ch.mcuTempMs = 0;
+            ch.mcuTempC = -1;
+            ch.tempFromMcu = false;
             if (ch.temperature >= 0.0) {
             if (ch.temperature >= 0.0) {
                 ch.temperature = -1.0;
                 ch.temperature = -1.0;
                 changed = true;
                 changed = true;
@@ -377,8 +409,12 @@ void StationStore::applyChannelTemperatures(int index, const QByteArray &raw24)
             continue;
             continue;
         }
         }
 
 
+        ch.mcuTempC = static_cast<int>(b);
+        ch.mcuTempMs = now;
+        ch.tempFromMcu = true;
+
         const double t = static_cast<double>(b);
         const double t = static_cast<double>(b);
-        if (qAbs(ch.temperature - t) > 0.05) {
+        if (qAbs(ch.temperature - t) > 0.05 || ch.temperature < 0.0) {
             ch.temperature = t;
             ch.temperature = t;
             changed = true;
             changed = true;
         }
         }
@@ -421,6 +457,11 @@ void StationStore::applyBackendState(int index, const QJsonObject &station)
         for (ChannelInfo &ch : d.channels) {
         for (ChannelInfo &ch : d.channels) {
             ch.state = ChannelInfo::Idle;
             ch.state = ChannelInfo::Idle;
             ch.temperature = -1.0;
             ch.temperature = -1.0;
+            ch.hasBackendTemp = false;
+            ch.backendTemp = -1.0;
+            ch.mcuTempMs = 0;
+            ch.mcuTempC = -1;
+            ch.tempFromMcu = false;
             ch.history.clear();
             ch.history.clear();
             ch.historyStart = 0;
             ch.historyStart = 0;
         }
         }
@@ -519,7 +560,10 @@ void StationStore::applyBackendState(int index, const QJsonObject &station)
     // 不在前端按阶段切换重置,也不以本机墙钟计算。
     // 不在前端按阶段切换重置,也不以本机墙钟计算。
     applyBackendTiming(index, station);
     applyBackendTiming(index, station);
 
 
+    const qint64 now = QDateTime::currentMSecsSinceEpoch();
     const QJsonArray channels = station.value(QStringLiteral("channels")).toArray();
     const QJsonArray channels = station.value(QStringLiteral("channels")).toArray();
+    if (!channels.isEmpty())
+        d.backendHasChannels = true;
     for (const QJsonValue &v : channels) {
     for (const QJsonValue &v : channels) {
         const QJsonObject ch = v.toObject();
         const QJsonObject ch = v.toObject();
 
 
@@ -548,16 +592,14 @@ void StationStore::applyBackendState(int index, const QJsonObject &station)
         const bool isPresent = presentVal.isBool() && presentVal.toBool();
         const bool isPresent = presentVal.isBool() && presentVal.toBool();
 
 
         const QString chVerdict = ch.value(QStringLiteral("state")).toString();
         const QString chVerdict = ch.value(QStringLiteral("state")).toString();
-        const ChannelInfo::State state = !isPresent
-                                             ? ChannelInfo::Idle
-                                             : ((chVerdict == QStringLiteral("pass"))
-                                                    ? ChannelInfo::Pass
-                                                    : (chVerdict == QStringLiteral("fail")
-                                                           ? ChannelInfo::Fail
+        const ChannelInfo::State state = (chVerdict == QStringLiteral("fail"))
+                                             ? ChannelInfo::Fail
+                                             : (!isPresent
+                                                    ? ChannelInfo::Idle
+                                                    : ((chVerdict == QStringLiteral("pass"))
+                                                           ? ChannelInfo::Pass
                                                            : ChannelInfo::Idle));
                                                            : ChannelInfo::Idle));
 
 
-        // 24 通道内存条温度:改从后端 channels[i].temperature_c 获取(float,单位 ℃),
-        // 取代原 MCU 串口 0x82 的来源。空槽或无效值统一显示 --℃。
         const QJsonValue tempVal = ch.value(QStringLiteral("temperature_c"));
         const QJsonValue tempVal = ch.value(QStringLiteral("temperature_c"));
         double temp = -1.0;
         double temp = -1.0;
         bool tempValid = false;
         bool tempValid = false;
@@ -567,6 +609,9 @@ void StationStore::applyBackendState(int index, const QJsonObject &station)
         }
         }
 
 
         ChannelInfo &info = d.channels[slot];
         ChannelInfo &info = d.channels[slot];
+        info.backendPresent = isPresent;
+        info.hasBackendTemp = tempValid;
+        info.backendTemp = tempValid ? temp : -1.0;
         if (info.state != state) {
         if (info.state != state) {
             info.state = state;
             info.state = state;
             channelsChangedFlag = true;
             channelsChangedFlag = true;
@@ -574,32 +619,44 @@ void StationStore::applyBackendState(int index, const QJsonObject &station)
 
 
         if (!isPresent) {
         if (!isPresent) {
             // 空槽不保留上一轮温度和曲线,避免插拔内存后仍显示旧数据。
             // 空槽不保留上一轮温度和曲线,避免插拔内存后仍显示旧数据。
+            info.mcuTempMs = 0;
+            info.mcuTempC = -1;
+            info.tempFromMcu = false;
             if (info.temperature >= 0.0 || !info.history.isEmpty() || info.historyStart != 0) {
             if (info.temperature >= 0.0 || !info.history.isEmpty() || info.historyStart != 0) {
                 info.temperature = -1.0;
                 info.temperature = -1.0;
                 info.history.clear();
                 info.history.clear();
                 info.historyStart = 0;
                 info.historyStart = 0;
                 channelsChangedFlag = true;
                 channelsChangedFlag = true;
             }
             }
+            continue;
         }
         }
 
 
-        if (tempValid) {
+        const bool mcuFresh = (info.mcuTempMs > 0 && info.mcuTempC >= 0
+                               && (now - info.mcuTempMs) < 3000);
+        if (mcuFresh) {
+            // 3 秒内有有效 MCU 0x82 数据时由 MCU 驱动温度显示与 1Hz 曲线,不与后端重复落点或清零
+            info.tempFromMcu = true;
+        } else if (tempValid) {
+            info.tempFromMcu = false;
             // 值变化(或上一轮是 --℃)才改写,避免无谓刷新
             // 值变化(或上一轮是 --℃)才改写,避免无谓刷新
             if (qAbs(info.temperature - temp) > 0.05 || info.temperature < 0.0) {
             if (qAbs(info.temperature - temp) > 0.05 || info.temperature < 0.0) {
                 info.temperature = temp;
                 info.temperature = temp;
                 channelsChangedFlag = true;
                 channelsChangedFlag = true;
             }
             }
             // 每个推送周期落一个点,详情页曲线靠这个 history 撑起来
             // 每个推送周期落一个点,详情页曲线靠这个 history 撑起来
-            // (与原来 MCU 0x82 分支逻辑一致,仅来源换成后端)
             info.history.append(temp);
             info.history.append(temp);
             while (info.history.size() > kTempHistorySize) {
             while (info.history.size() > kTempHistorySize) {
                 info.history.removeFirst();
                 info.history.removeFirst();
                 ++info.historyStart;
                 ++info.historyStart;
             }
             }
             channelsChangedFlag = true;
             channelsChangedFlag = true;
-        } else if (info.temperature >= 0.0) {
-            // 后端没给有效温度:退回 -1(显示 --℃),但不清历史曲线点
-            info.temperature = -1.0;
-            channelsChangedFlag = true;
+        } else {
+            info.tempFromMcu = false;
+            if (info.temperature >= 0.0) {
+                // 两路均无有效温度:退回 -1(显示 --℃),但不清历史曲线点
+                info.temperature = -1.0;
+                channelsChangedFlag = true;
+            }
         }
         }
     }
     }
 
 
@@ -623,6 +680,11 @@ void StationStore::applyTaskComplete(int index, const QJsonObject &result)
         for (ChannelInfo &ch : d.channels) {
         for (ChannelInfo &ch : d.channels) {
             ch.state = ChannelInfo::Idle;
             ch.state = ChannelInfo::Idle;
             ch.temperature = -1.0;
             ch.temperature = -1.0;
+            ch.hasBackendTemp = false;
+            ch.backendTemp = -1.0;
+            ch.mcuTempMs = 0;
+            ch.mcuTempC = -1;
+            ch.tempFromMcu = false;
             ch.history.clear();
             ch.history.clear();
             ch.historyStart = 0;
             ch.historyStart = 0;
         }
         }

+ 13 - 0
src/stationdata.h

@@ -32,6 +32,18 @@ struct ChannelInfo {
     double temperature;     // °C;Idle(未装载)为 -1
     double temperature;     // °C;Idle(未装载)为 -1
     State state;
     State state;
 
 
+    // 24 路温度双源仲裁(后端 channels[i].temperature_c 与 MCU 串口 0x82):
+    //   1) present=false(确认空槽)统一显示 --℃;
+    //   2) 在位时有新鲜 MCU 0x82(3 秒内有效值 != 0xFF)则优先用 MCU,
+    //      否则回落到后端 channels[i].temperature_c;
+    //   3) 串口断开或 0x82 返回 0xFF 时不抹掉后端 temperature_c。
+    bool backendPresent = false;
+    bool hasBackendTemp = false;
+    double backendTemp = -1.0;
+    qint64 mcuTempMs = 0;
+    int mcuTempC = -1;
+    bool tempFromMcu = false;
+
     // 该通道自己的温度历史(点详情页上方的通道格子,曲线就切到它)
     // 该通道自己的温度历史(点详情页上方的通道格子,曲线就切到它)
     QVector<double> history;
     QVector<double> history;
     int historyStart = 0;   // history[0] 对应的全局采样序号
     int historyStart = 0;   // history[0] 对应的全局采样序号
@@ -86,6 +98,7 @@ struct StationData {
     QJsonObject taskBatch;                 // 后端托管批次队列快照(前端自维护队列时仅留档)
     QJsonObject taskBatch;                 // 后端托管批次队列快照(前端自维护队列时仅留档)
     QJsonArray taskHistory;                // 已完成轮次归档摘要
     QJsonArray taskHistory;                // 已完成轮次归档摘要
     QJsonObject mtResult;                  // MT 执行摘要(report_file / errors / tests_passed / ecc_*)
     QJsonObject mtResult;                  // MT 执行摘要(report_file / errors / tests_passed / ecc_*)
+    bool backendHasChannels = false;       // 是否已收到过后端 channels[] 权威在位信息
 
 
     QVector<double> tempHistory;   // 最近 kTempHistorySize 个腔体温度,最老的在前
     QVector<double> tempHistory;   // 最近 kTempHistorySize 个腔体温度,最老的在前
 
 

+ 30 - 10
web/firmware-controls.js

@@ -202,9 +202,8 @@
     $('mt-command-preview').textContent = previewMt(d.mt).text;
     $('mt-command-preview').textContent = previewMt(d.mt).text;
     renderAvailability();
     renderAvailability();
   }
   }
-  function fillForms() {
-    const control = snapshot(), d = draft();
-    if (!d) return;
+  function fillConnectionForm(control = snapshot()) {
+    if (!control || !control.connections) return;
     const connection = control.connections || {}, console = connection.console || {}, bmc = connection.bmc || {}, n540 = connection.n540 || {};
     const connection = control.connections || {}, console = connection.console || {}, bmc = connection.bmc || {}, n540 = connection.n540 || {};
     const rawTr = console.transport || 'ssh_console';
     const rawTr = console.transport || 'ssh_console';
     const normTr = ['serial','tty','tty_serial','usb_serial','local_serial'].includes(rawTr)
     const normTr = ['serial','tty','tty_serial','usb_serial','local_serial'].includes(rawTr)
@@ -231,6 +230,18 @@
     if ($('n540-mode')) $('n540-mode').value = n540.mode || 'TCPS';
     if ($('n540-mode')) $('n540-mode').value = n540.mode || 'TCPS';
     $('connection-edit-status').textContent = '已读取后端配置';
     $('connection-edit-status').textContent = '已读取后端配置';
     connectionDirty = false;
     connectionDirty = false;
+    connectionFields();
+  }
+  function fillForms() {
+    if (!controls.has(currentId())) {
+      const groups = [...new Set(catalog().map(x => x.group).filter(Boolean))];
+      $('uip-group').innerHTML = '<option value="">全部分组</option>' + groups.map(group => `<option value="${esc(group)}">${esc(groupNames[group] || group)}</option>`).join('');
+      connectionFields();
+      return;
+    }
+    const control = snapshot(), d = draft();
+    if (!d) return;
+    fillConnectionForm(control);
     for (const [key,field] of Object.entries({efi_path:'mt-efi-path',config_path:'mt-config-path',arguments:'mt-arguments',command_template:'mt-command-template'})) $(field).value = d.mt[key] || '';
     for (const [key,field] of Object.entries({efi_path:'mt-efi-path',config_path:'mt-config-path',arguments:'mt-arguments',command_template:'mt-command-template'})) $(field).value = d.mt[key] || '';
     if ($('mt-memory-range')) $('mt-memory-range').value = d.mt.memory_range || 'all';
     if ($('mt-memory-range')) $('mt-memory-range').value = d.mt.memory_range || 'all';
     if ($('mt-addr-lo')) { $('mt-addr-lo').value = d.mt.addr_lim_lo || ''; $('mt-addr-lo').disabled = ($('mt-memory-range')?.value || 'all') !== 'custom'; }
     if ($('mt-addr-lo')) { $('mt-addr-lo').value = d.mt.addr_lim_lo || ''; $('mt-addr-lo').disabled = ($('mt-memory-range')?.value || 'all') !== 'custom'; }
@@ -476,7 +487,7 @@
 
 
   function render() {
   function render() {
     if (!api) return;
     if (!api) return;
-    if (formStation !== currentId() && drafts.has(currentId())) { formStation = currentId(); fillForms(); }
+    if (formStation !== currentId() && controls.has(currentId()) && drafts.has(currentId())) { formStation = currentId(); fillForms(); }
     renderCapabilities(); renderRmt(); renderTraining(); renderCpuStages(); renderFiles(); renderResponses(); renderAvailability(); renderPhaseActions(); renderPxeAndNative();
     renderCapabilities(); renderRmt(); renderTraining(); renderCpuStages(); renderFiles(); renderResponses(); renderAvailability(); renderPhaseActions(); renderPxeAndNative();
     window.stlBootPlan?.render(); window.stlAmt?.render(); window.stlStages?.render();
     window.stlBootPlan?.render(); window.stlAmt?.render(); window.stlStages?.render();
   }
   }
@@ -488,13 +499,20 @@
       const needsCatalog = forceCatalog || !catalogs.has(station);
       const needsCatalog = forceCatalog || !catalogs.has(station);
       if (needsCatalog) reads.push(api.callApi('GetFirmwareCatalog',{station_id:station}));
       if (needsCatalog) reads.push(api.callApi('GetFirmwareCatalog',{station_id:station}));
       const [control, schema] = await Promise.all(reads);
       const [control, schema] = await Promise.all(reads);
+      const hadControl = controls.has(station);
       controls.set(station,control); if (schema) catalogs.set(station,schema);
       controls.set(station,control); if (schema) catalogs.set(station,schema);
-      if (!drafts.has(station)) drafts.set(station,createDraft(control));
+      if (!hadControl || !drafts.has(station)) drafts.set(station,createDraft(control));
       if (station !== currentId()) return;
       if (station !== currentId()) return;
-      if (schema && formStation === station) {
-        const group = $('uip-group').value;
-        $('uip-group').innerHTML = '<option value="">全部分组</option>' + [...new Set(catalog().map(x => x.group).filter(Boolean))].map(x => `<option value="${esc(x)}">${esc(groupNames[x] || x)}</option>`).join('');
-        $('uip-group').value = group; renderCatalog(); renderStepDirectories();
+      if (!hadControl || formStation !== station) {
+        formStation = station;
+        fillForms();
+      } else {
+        if (!connectionDirty) fillConnectionForm(control);
+        if (schema) {
+          const group = $('uip-group').value;
+          $('uip-group').innerHTML = '<option value="">全部分组</option>' + [...new Set(catalog().map(x => x.group).filter(Boolean))].map(x => `<option value="${esc(x)}">${esc(groupNames[x] || x)}</option>`).join('');
+          $('uip-group').value = group; renderCatalog(); renderStepDirectories();
+        }
       }
       }
       render();
       render();
     } catch (error) {
     } catch (error) {
@@ -513,7 +531,9 @@
     api = services;
     api = services;
     api.bind('btn-reload-catalog',() => refresh(true));
     api.bind('btn-reload-catalog',() => refresh(true));
     api.bind('btn-reload-connections',async () => { await refresh(); fillForms(); });
     api.bind('btn-reload-connections',async () => { await refresh(); fillForms(); });
-    for (const key of ['connection-console-enabled','connection-transport','connection-console-host','connection-console-port','connection-write-chunk-bytes','connection-write-gap-ms','connection-bmc-enabled','connection-bmc-host','connection-bmc-user','connection-bmc-password']) $(key).addEventListener('input',() => {connectionDirty = true; $('connection-edit-status').textContent = '有未保存的连接修改'; connectionFields();});
+    for (const key of ['connection-console-enabled','connection-transport','connection-console-host','connection-console-port','connection-write-chunk-bytes','connection-write-gap-ms','connection-bmc-enabled','connection-bmc-host','connection-bmc-user','connection-bmc-password']) {
+      for (const evt of ['input','change']) $(key).addEventListener(evt,() => {connectionDirty = true; $('connection-edit-status').textContent = '有未保存的连接修改'; connectionFields();});
+    }
     $('connection-bmc-host').addEventListener('input',() => {
     $('connection-bmc-host').addEventListener('input',() => {
       if (!['tcp_serial','tcp_serial_server','local_serial'].includes($('connection-transport').value)) {
       if (!['tcp_serial','tcp_serial_server','local_serial'].includes($('connection-transport').value)) {
         $('connection-console-host').value = $('connection-bmc-host').value.trim();
         $('connection-console-host').value = $('connection-bmc-host').value.trim();