From 4a102d22d449d0230f01a77f661ab667c36a648e Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 11 七月 2025 11:33:37 +0800
Subject: [PATCH] 1.EAP模拟器之警告信息模拟

---
 SourceCode/Bond/EAPSimulator/CHsmsActive.cpp |   26 ++++++++++++++++++++++++++
 SourceCode/Bond/EAPSimulator/CHsmsActive.h   |    6 ++++++
 SourceCode/Bond/Servo/CBonder.cpp            |   15 ++++++++-------
 3 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp b/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
index c5a6a1c..94f5bb7 100644
--- a/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
+++ b/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
@@ -60,9 +60,16 @@
 
 	auto onRecvDataMessage = [&](void* pFrom, IMessage* pMessage) -> void {
 		HEADER* pHeader = pMessage->getHeader();
+		int nStream = (pHeader->stream & 0x7F);
+
 		TRACE("收到消息 S%dF%d================\n", pHeader->stream & 0x7F, pHeader->function);
 		TRACE("Body:%s\n", pMessage->toString());
 		LOGI("onRecvDataMessage(%s).", pMessage->toString());
+
+		if (nStream == 5 && pHeader->function == 1) {
+			// S1F1
+			replyAck(5, 2, pMessage->getHeader()->systemBytes, 0, _T("ACK0"));
+		}
 	};
 
 	ActiveListener listener;
@@ -162,3 +169,22 @@
 
 	return 0;
 }
+
+int CHsmsActive::replyAck0(IMessage* pMessage)
+{
+	return 0;
+}
+
+// 通用的reply ack函数
+void CHsmsActive::replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName)
+{
+	IMessage* pMessage = NULL;
+	HSMS_Create1Message(pMessage, m_nSessionId, s, f, systemBytes);
+	ASSERT(pMessage);
+	ISECS2Item* pItem = pMessage->getBody();
+	pItem->setBinary((const char*)&ack, 1, pszAckName);
+	m_pActive->sendMessage(pMessage);
+	LOGI("<HSMS>[SECS Msg SEND]S%dF%d (SysByte=%u)", s, f, systemBytes);
+	HSMS_Destroy1Message(pMessage);
+}
+
diff --git a/SourceCode/Bond/EAPSimulator/CHsmsActive.h b/SourceCode/Bond/EAPSimulator/CHsmsActive.h
index 664193a..9b839cd 100644
--- a/SourceCode/Bond/EAPSimulator/CHsmsActive.h
+++ b/SourceCode/Bond/EAPSimulator/CHsmsActive.h
@@ -37,6 +37,12 @@
 	// terminal display
 	int hsmsTerminalDisplay(BYTE tid, const char* pszText);
 
+	// 通过的reply函数
+	void replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName);
+
+	// reply ack0
+	int replyAck0(IMessage* pMessage);
+
 private:
 	ACTIVEListener m_listener;
 	IActive* m_pActive;
diff --git a/SourceCode/Bond/Servo/CBonder.cpp b/SourceCode/Bond/Servo/CBonder.cpp
index 3c42d87..afe3cdf 100644
--- a/SourceCode/Bond/Servo/CBonder.cpp
+++ b/SourceCode/Bond/Servo/CBonder.cpp
@@ -419,16 +419,17 @@
 	{
 		CEquipment::onTimer(nTimerid);
 
-		// test
-		/*
+		// test	 
 		static int i[2] = { 0, 0 };
 		i[m_nIndex]++;
-
-		if (i[m_nIndex] == 15) {
-			char szBuffer[26];
-			decodeJobProcessStartReport(getStep(STEP_ID_JOB_PROCESS_START_REPORT), szBuffer, 26);
+		if (m_nIndex == 0 && i[m_nIndex] == 100) {
+			if (m_listener.onAlarm != nullptr) {
+				m_listener.onAlarm(this, 1,
+					100,
+					getID(),
+					1);
+			}
 		}
-		*/
 	}
 
 	void CBonder::serialize(CArchive& ar)

--
Gitblit v1.9.3