From 437d3d047183eed3bbd8eb79e4b40c4a1e0427c9 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期四, 15 一月 2026 10:39:31 +0800
Subject: [PATCH] 1.修复: CEID 校验恒通过:ceidDefined 返回 true,PauseEvent ID 不做有效性检查。Host 若下发无效 CEID,将被接受但运行时无法触发暂停,风险难以察觉。 指定事件发生时暂停;
---
SourceCode/Bond/Servo/CMaster.cpp | 77 ++++++++++++++++++++++++++++++++++++--
1 files changed, 72 insertions(+), 5 deletions(-)
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index 0ab057f..d9a0e67 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -3,6 +3,7 @@
#include "CMaster.h"
#include <future>
#include <vector>
+#include <algorithm>
#include "RecipeManager.h"
#include <fstream>
#include "SerializeUtil.h"
@@ -1540,7 +1541,7 @@
unlock();
}
};
- listener.onProcessStateChanged = [&](void* pEquipment, int slotNo, PROCESS_STATE state) -> void {
+ listener.onProcessStateChanged = [&](void* pEquipment, int slotNo, PROCESS_STATE prevState, PROCESS_STATE state) -> void {
ASSERT(1 <= slotNo && slotNo <= 8);
int eqid = ((CEquipment*)pEquipment)->getID();
CGlass* pGlass = ((CEquipment*)pEquipment)->getGlassFromSlot(slotNo);
@@ -1558,7 +1559,12 @@
}
if (m_listener.onProcessStateChanged != nullptr) {
- m_listener.onProcessStateChanged(this, (CEquipment*)pEquipment, slotNo, state);
+ m_listener.onProcessStateChanged(this, (CEquipment*)pEquipment, slotNo, prevState, state);
+ }
+ };
+ listener.onProcessDataReport = [&](void* pEquipment, const std::vector<CParam>& params) {
+ if (m_listener.onProcessDataReport != nullptr) {
+ m_listener.onProcessDataReport(this, (CEquipment*)pEquipment, params);
}
};
listener.onMapMismatch = [&](void* pEquipment, short scanMap, short downMap) {
@@ -1781,6 +1787,10 @@
strOut.append(szBuffer);
}
LOGD("<CMaster-%s>SVDataReport:%s", ((CEquipment*)pEquipment)->getName().c_str(), strOut.c_str());
+
+ if (m_listener.onSVDataReport != nullptr) {
+ m_listener.onSVDataReport(this, (CEquipment*)pEquipment, params);
+ }
};
listener.onPanelDataReport = [&](void* pEquipment, void* pContext) {
LOGD("<CMaster-%s>onPanelDataReport", ((CEquipment*)pEquipment)->getName().c_str());
@@ -1800,6 +1810,11 @@
}
}
+ };
+ listener.onReceivedJob = [&](void* pEquipment, int port, CJobDataS* pJobDataS) {
+ if (m_listener.onJobReceived != nullptr) {
+ m_listener.onJobReceived(this, (CEquipment*)pEquipment, port, pJobDataS);
+ }
};
pEquipment->setListener(listener);
pEquipment->setCcLink(&m_cclink);
@@ -2115,8 +2130,9 @@
}
};
auto fireProcessState = [&](SERVO::CEquipment* pEq, int slotNo, SERVO::PROCESS_STATE st) {
- if (m_listener.onProcessStateChanged != nullptr && pEq != nullptr) {
- m_listener.onProcessStateChanged(this, pEq, slotNo, st);
+ // Drive equipment state so listeners receive prev/current states consistently.
+ if (pEq != nullptr) {
+ pEq->fireSetProcessState(slotNo, st);
}
};
@@ -2199,6 +2215,34 @@
fireLoadPortStatus(PORT_LOAD_READY);
fireLoadPortStatus(PORT_EMPTY); // will also raise LoadPortNotAssoc via Model
break;
+ case 24: { // 妯℃嫙 SV Data锛堢ず渚嬶細Bonder1锛�
+ SERVO::CEquipment* pEq = getEquipment(EQ_ID_Bonder1);
+ if (pEq != nullptr && m_listener.onSVDataReport != nullptr) {
+ static int counter = 0;
+ ++counter;
+ std::vector<CParam> params;
+ params.emplace_back("MockSV_Temp", "1", "C", 25 + (counter % 5));
+ params.emplace_back("MockSV_Pressure", "2", "kPa", 100 + (counter % 3));
+ params.emplace_back("MockSV_Speed", "3", "mm/s", 50 + (counter % 7));
+ m_listener.onSVDataReport(this, pEq, params);
+ LOGI("<Master>SIM_EAP step24: mock SVData (Bonder1), params=%zu", params.size());
+ }
+ break;
+ }
+ case 25: { // 妯℃嫙 Process Data锛堢ず渚嬶細Bonder1锛�
+ SERVO::CEquipment* pEq = getEquipment(EQ_ID_Bonder1);
+ if (pEq != nullptr && m_listener.onProcessDataReport != nullptr) {
+ static int counter = 0;
+ ++counter;
+ std::vector<CParam> params;
+ params.emplace_back("MockProc_CycleTime", "1", "s", 30 + (counter % 4));
+ params.emplace_back("MockProc_MaxTemp", "2", "C", 200 + (counter % 6));
+ params.emplace_back("MockProc_Result", "3", "", (counter % 2) ? 1 : 0);
+ m_listener.onProcessDataReport(this, pEq, params);
+ LOGI("<Master>SIM_EAP step25: mock ProcessData (Bonder1), params=%zu", params.size());
+ }
+ break;
+ }
default:
break;
}
@@ -2929,7 +2973,30 @@
bool CMaster::ceidDefined(uint32_t ceid) const
{
- return true;
+ if (m_allowedCeids.empty()) return true; // backward compatible: treat as all allowed when not configured
+ return m_allowedCeids.find(ceid) != m_allowedCeids.end();
+ }
+
+ void CMaster::handleCollectionEvent(uint32_t ceid)
+ {
+ // 閬嶅巻褰撳墠 PJ锛屽懡涓� pauseEvents 鏃跺彲鍦ㄦ鎵╁睍鏆傚仠鍔ㄤ綔
+ for (auto pj : m_processJobs) {
+ if (pj == nullptr) continue;
+ const auto& pauseList = pj->pauseEvents();
+ if (std::find(pauseList.begin(), pauseList.end(), ceid) != pauseList.end()) {
+ LOGW("<Master>PauseEvent hit: CEID=%u, PJ=%s, state=%d", ceid, pj->id().c_str(), (int)pj->state());
+ // TODO: 琛旀帴鍏蜂綋鏆傚仠绛栫暐锛堝鏆傚仠 PJ/CJ銆佸仠姝㈣皟搴�/鎼�侊級锛屾澶勪粎鐣欐々浣�
+ }
+ }
+ }
+
+ void CMaster::setAllowedCeids(const std::vector<unsigned int>& ceids)
+ {
+ m_allowedCeids.clear();
+ m_allowedCeids.reserve(ceids.size());
+ for (auto id : ceids) {
+ m_allowedCeids.insert(id);
+ }
}
bool CMaster::saveState() const
--
Gitblit v1.9.3