From 3afd6812c6bcb156297a9000db44caf23ede568c Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期日, 04 一月 2026 17:44:42 +0800
Subject: [PATCH] 1.EV_SubEqpStart和EV_SubEqpEnd事件上报

---
 SourceCode/Bond/Servo/HsmsPassive.h               |    2 +
 SourceCode/Bond/x64/Debug/CollectionEventList.txt |    2 +
 SourceCode/Bond/Servo/HsmsPassive.cpp             |   32 ++++++++++-----
 SourceCode/Bond/Servo/CMaster.cpp                 |    4 ++
 SourceCode/Bond/Servo/CMaster.h                   |    3 +
 SourceCode/Bond/Servo/Model.cpp                   |   14 +++++++
 SourceCode/Bond/x64/Debug/ReportList.txt          |    2 +
 SourceCode/Bond/x64/Debug/VariableList.txt        |    2 +
 8 files changed, 49 insertions(+), 12 deletions(-)

diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index 348c561..95caa52 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -1553,6 +1553,10 @@
 					m_pCollector->batchStop(SlotToMid(eqid, slotNo));
 				}
 			}
+
+			if (m_listener.onProcessStateChanged != nullptr) {
+				m_listener.onProcessStateChanged(this, (CEquipment*)pEquipment, slotNo, state);
+			}
 		};
 		listener.onMapMismatch = [&](void* pEquipment, short scanMap, short downMap) {
 			LOGE("<Master-%s>Port InUse, map(%d!=%d)涓嶄竴鑷达紝璇锋鏌ャ��",
diff --git a/SourceCode/Bond/Servo/CMaster.h b/SourceCode/Bond/Servo/CMaster.h
index 29d413c..be5c434 100644
--- a/SourceCode/Bond/Servo/CMaster.h
+++ b/SourceCode/Bond/Servo/CMaster.h
@@ -58,6 +58,7 @@
     typedef std::function<void(void* pMaster, CEquipment* pEquipment, int code)> ONEQDATACHANGED;
     typedef std::function<void(void* pMaster, CRobotTask* pTask, int code)> ONROBOTTASKEVENT;
     typedef std::function<void(void* pMaster, CEquipment* pEquipment, short status, __int64 data)> ONLOADPORTSTATUSCHANGED;
+    typedef std::function<void(void* pMaster, CEquipment* pEquipment, int slotNo, PROCESS_STATE state)> ONPROCESSSTATECHANGED;
     typedef std::function<void(void* pMaster, int round)> ONCTROUNDEND;
     typedef std::function<void(void* pMaster, void* pj)> ONPJSTART;
     typedef struct _MasterListener
@@ -70,6 +71,7 @@
         ONEQDATACHANGED         onEqDataChanged;
         ONROBOTTASKEVENT        onRobotTaskEvent;
         ONLOADPORTSTATUSCHANGED	onLoadPortStatusChanged;
+        ONPROCESSSTATECHANGED   onProcessStateChanged;
         ONCTROUNDEND            onCTRoundEnd;
         ONPJSTART               onCjStart;
         ONPJSTART               onCjEnd;
@@ -272,4 +274,3 @@
         void CreateDAQBridgeServer();
     };
 }
-
diff --git a/SourceCode/Bond/Servo/HsmsPassive.cpp b/SourceCode/Bond/Servo/HsmsPassive.cpp
index cb736bb..8b56b52 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.cpp
+++ b/SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -950,7 +950,8 @@
 		return -1;
 	}
 
-	std::wregex pattern(L"^\\d+,[^,]*,[^,]*,\\(\\d+(,\\d+)*\\).*");  // 鍖归厤浠ユ暟瀛�+閫楀彿寮�澶寸殑瀛楃涓�
+	// 鍏佽 Attached RPTID 涓虹┖锛�()
+	std::wregex pattern(L"^\\d+,[^,]*,[^,]*,\\(\\d*(,\\d+)*\\).*");  // 鍖归厤浠ユ暟瀛�+閫楀彿寮�澶寸殑瀛楃涓�
 	std::vector<SERVO::CCollectionEvent*> events;
 	int index, last;
 	CStringW strLine, strRPTIDs;
@@ -2468,9 +2469,6 @@
 	}
 
 	SERVO::CReport* pReport = pEvent->getFirstReport();
-	if (pReport == nullptr) {
-		return ER_UNLINK_EVENT_REPORT;
-	}
 
 
 	Lock();
@@ -2482,14 +2480,16 @@
 	// pItem->addU2Item(++DATAID, "DATAID");		// 鏍规嵁鍒殑鏃ュ織鏄剧ずDATAID鎭掍负0锛屾墍浠ユ垜浠厛鐓т娇鐢�0
 	pItem->addU2Item(0, "DATAID");
 	pItem->addU4Item(CEID, "CEID");
-	ISECS2Item* pItemList1 = pItem->addItem();
-	ISECS2Item* pItemList2 = pItemList1->addItem();
-	pItemList2->addU4Item(pReport->getReportId(), "RPTID");
-	ISECS2Item* pItemList3 = pItemList2->addItem();
+	ISECS2Item* pItemList1 = pItem->addItem(); // L[n] reports
+	if (pReport != nullptr) {
+		ISECS2Item* pItemList2 = pItemList1->addItem();
+		pItemList2->addU4Item(pReport->getReportId(), "RPTID");
+		ISECS2Item* pItemList3 = pItemList2->addItem();
 
-	auto vars = pReport->getVariables();
-	for (auto var : vars) {
-		addVariableValueToItem(pItemList3, var);
+		auto vars = pReport->getVariables();
+		for (auto var : vars) {
+			addVariableValueToItem(pItemList3, var);
+		}
 	}
 	pAction->setSendMessage(pMessage);
 	if (m_pPassive == NULL || STATE::SELECTED != m_pPassive->getState()) {
@@ -2609,4 +2609,14 @@
 	return requestEventReportSend("ProcessDataReport");
 }
 
+int CHsmsPassive::requestEventReportSend_SubEqpStart()
+{
+	return requestEventReportSend("SubEqpStart");
+}
+
+int CHsmsPassive::requestEventReportSend_SubEqpEnd()
+{
+	return requestEventReportSend("SubEqpEnd");
+}
+
 
diff --git a/SourceCode/Bond/Servo/HsmsPassive.h b/SourceCode/Bond/Servo/HsmsPassive.h
index 314b008..3be6125 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.h
+++ b/SourceCode/Bond/Servo/HsmsPassive.h
@@ -220,6 +220,8 @@
 	int requestEventReportSend_OCR_PanelID_Read_OK();
 	int requestEventReportSend_LoadPortNotAssoc();
 	int requestEventReportSend_ProcessDataReport();
+	int requestEventReportSend_SubEqpStart();
+	int requestEventReportSend_SubEqpEnd();
 
 private:
 	void replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName);
diff --git a/SourceCode/Bond/Servo/Model.cpp b/SourceCode/Bond/Servo/Model.cpp
index c39f86b..9918b56 100644
--- a/SourceCode/Bond/Servo/Model.cpp
+++ b/SourceCode/Bond/Servo/Model.cpp
@@ -480,6 +480,20 @@
 		}
 		notifyPtr(RX_CODE_LOADPORT_STATUS_CHANGED, pEquipment);
 	};
+	masterListener.onProcessStateChanged = [&](void* pMaster, SERVO::CEquipment* pEquipment, int slotNo, SERVO::PROCESS_STATE state) {
+		// SubEqpStart/SubEqpEnd: align to log's EV_SubEqpStart/EV_SubEqpEnd stage (no report payload required).
+		(void)pMaster;
+		if (pEquipment != nullptr) {
+			m_hsmsPassive.setVariableValue("SubEqpName", pEquipment->getName().c_str());
+		}
+		m_hsmsPassive.setVariableValue("SubEqpSlot", slotNo);
+		if (state == SERVO::PROCESS_STATE::Processing) {
+			m_hsmsPassive.requestEventReportSend_SubEqpStart();
+		}
+		else if (state == SERVO::PROCESS_STATE::Complete) {
+			m_hsmsPassive.requestEventReportSend_SubEqpEnd();
+		}
+	};
 	masterListener.onCTRoundEnd = [&](void* pMaster, int round) {
 		m_configuration.setContinuousTransferCount(round);
 	};
diff --git a/SourceCode/Bond/x64/Debug/CollectionEventList.txt b/SourceCode/Bond/x64/Debug/CollectionEventList.txt
index 607bdff..edf6943 100644
--- a/SourceCode/Bond/x64/Debug/CollectionEventList.txt
+++ b/SourceCode/Bond/x64/Debug/CollectionEventList.txt
@@ -4,6 +4,8 @@
 600,ControlStateChanged,,(600)
 700,ProcessStateChanged,,(700)
 10018,ProcessDataReport,,(33)
+10015,SubEqpStart,,(10015)
+10016,SubEqpEnd,,(10016)
 10000,RecipeChanged,,(10000)
 10030,CarrierArrived,,(10300)
 10031,CarrierRemoved,,(10300)
diff --git a/SourceCode/Bond/x64/Debug/ReportList.txt b/SourceCode/Bond/x64/Debug/ReportList.txt
index 28e3639..71fd33b 100644
--- a/SourceCode/Bond/x64/Debug/ReportList.txt
+++ b/SourceCode/Bond/x64/Debug/ReportList.txt
@@ -31,3 +31,5 @@
 50012,(5014)
 50013,(5015)
 50014,(5016)
+10015,(5018,5019)
+10016,(5018,5019)
diff --git a/SourceCode/Bond/x64/Debug/VariableList.txt b/SourceCode/Bond/x64/Debug/VariableList.txt
index 6160adf..2381563 100644
--- a/SourceCode/Bond/x64/Debug/VariableList.txt
+++ b/SourceCode/Bond/x64/Debug/VariableList.txt
@@ -52,6 +52,8 @@
 5015,ReadyToReleasePortId,U1,"Port ID"
 5016,LoadPortNotAssocPortId,U1,"Port ID"
 5017,ProcessDataReportText,A50,EV_PROCESS_DATA_REPORT payload string (placeholder)
+5018,SubEqpName,A20,Equipment name for EV_SubEqpStart/EV_SubEqpEnd
+5019,SubEqpSlot,U1,Slot number for EV_SubEqpStart/EV_SubEqpEnd
 10200,SlotMap,U2,SlotMap(Scan)
 10201,SlotMapScan,U2,SlotMap(Scan)
 10202,SlotMapDownload,U2,SlotMap(Download)

--
Gitblit v1.9.3