From d5c8d6545efe0ab2026a4127fde0fa2bad659ccd Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期三, 06 八月 2025 14:45:52 +0800
Subject: [PATCH] 1.实现EAP中ProceedWithCarrier和CarrierRelease的功能模拟及测试;

---
 SourceCode/Bond/Servo/HsmsPassive.h                    |   19 ++++
 SourceCode/Bond/EAPSimulator/CHsmsActive.h             |   14 +++
 SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h         |    2 
 SourceCode/Bond/Servo/HsmsPassive.cpp                  |   54 +++++++++++++
 SourceCode/Bond/EAPSimulator/EAPSimulator.rc           |    0 
 SourceCode/Bond/Servo/CMaster.h                        |    2 
 SourceCode/Bond/Servo/Model.cpp                        |   24 ++++++
 SourceCode/Bond/EAPSimulator/CHsmsActive.cpp           |   32 ++++++++
 SourceCode/Bond/EAPSimulator/Resource.h                |    6 +
 SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp       |   15 +++
 SourceCode/Bond/Servo/Servo.rc                         |    0 
 SourceCode/Bond/Servo/CMaster.cpp                      |   20 +++++
 Document/Panel Bonder八零联合 SecsTest CheckList_v3.0.xlsx |    0 
 13 files changed, 186 insertions(+), 2 deletions(-)

diff --git "a/Document/Panel Bonder\345\205\253\351\233\266\350\201\224\345\220\210 SecsTest CheckList_v3.0.xlsx" "b/Document/Panel Bonder\345\205\253\351\233\266\350\201\224\345\220\210 SecsTest CheckList_v3.0.xlsx"
index 48e2a37..ec6ca66 100644
--- "a/Document/Panel Bonder\345\205\253\351\233\266\350\201\224\345\220\210 SecsTest CheckList_v3.0.xlsx"
+++ "b/Document/Panel Bonder\345\205\253\351\233\266\350\201\224\345\220\210 SecsTest CheckList_v3.0.xlsx"
Binary files differ
diff --git a/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp b/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
index 1605306..2dc424f 100644
--- a/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
+++ b/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
@@ -299,6 +299,38 @@
 	return 0;
 }
 
+int CHsmsActive::hsmsCarrierActionRequest(unsigned int DATAID, 
+	const char* pszCarrierAction, 
+	const char* pszCarrierId,
+	unsigned char PTN)
+{
+	IMessage* pMessage = nullptr;
+	int nRet = HSMS_Create1Message(pMessage, m_nSessionId, 3 | REPLY, 17, ++m_nSystemByte);
+	pMessage->getBody()->addU4Item(DATAID, "DATAID");
+	pMessage->getBody()->addItem(pszCarrierAction, "CARRIERACTION");
+	pMessage->getBody()->addItem(pszCarrierId, "CARRIERID");
+	pMessage->getBody()->addU1Item(PTN, "PTN");
+	pMessage->getBody()->addItem();
+	m_pActive->sendMessage(pMessage);
+	HSMS_Destroy1Message(pMessage);
+
+	return 0;
+}
+
+int CHsmsActive::hsmsProceedWithCarrier(unsigned int DATAID,
+	const char* pszCarrierId,
+	unsigned char PTN)
+{
+	return hsmsCarrierActionRequest(DATAID, "ProceedWithCarrier", pszCarrierId, PTN);
+}
+
+int CHsmsActive::hsmsCarrierRelease(unsigned int DATAID,
+	const char* pszCarrierId,
+	unsigned char PTN)
+{
+	return hsmsCarrierActionRequest(DATAID, "CarrierRelease", pszCarrierId, PTN);
+}
+
 int CHsmsActive::replyAck0(IMessage* pMessage)
 {
 	return 0;
diff --git a/SourceCode/Bond/EAPSimulator/CHsmsActive.h b/SourceCode/Bond/EAPSimulator/CHsmsActive.h
index d6ff5b6..b814d4b 100644
--- a/SourceCode/Bond/EAPSimulator/CHsmsActive.h
+++ b/SourceCode/Bond/EAPSimulator/CHsmsActive.h
@@ -64,6 +64,20 @@
 	// 查询PPID List
 	int hsmsQueryPPIDList();
 
+	// S3F17
+	// 卡匣动作请求
+	int hsmsCarrierActionRequest(unsigned int DATAID, 
+		const char* pszCarrierAction,
+		const char* pszCarrierId,
+		unsigned char PTN);
+	int hsmsProceedWithCarrier(unsigned int DATAID,
+		const char* pszCarrierId,
+		unsigned char PTN);
+	int CHsmsActive::hsmsCarrierRelease(unsigned int DATAID,
+		const char* pszCarrierId,
+		unsigned char PTN);
+
+
 	// 通过的reply函数
 	void replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName);
 
diff --git a/SourceCode/Bond/EAPSimulator/EAPSimulator.rc b/SourceCode/Bond/EAPSimulator/EAPSimulator.rc
index a7c343f..f489bd8 100644
--- a/SourceCode/Bond/EAPSimulator/EAPSimulator.rc
+++ b/SourceCode/Bond/EAPSimulator/EAPSimulator.rc
Binary files differ
diff --git a/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp b/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp
index f95c6ee..3af62af 100644
--- a/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp
+++ b/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp
@@ -88,6 +88,8 @@
 	ON_BN_CLICKED(IDC_BUTTON_TRANSMIT_SPOOLED_DATA, &CEAPSimulatorDlg::OnBnClickedButtonTransmitSpooledData)
 	ON_BN_CLICKED(IDC_BUTTON_PURGE_SPOOLED_DATA, &CEAPSimulatorDlg::OnBnClickedButtonPurgeSpooledData)
 	ON_BN_CLICKED(IDC_BUTTON_QUERY_PPID_LIST, &CEAPSimulatorDlg::OnBnClickedButtonQueryPpidList)
+	ON_BN_CLICKED(IDC_BUTTON_PROCEED_WITH_CARRIER, &CEAPSimulatorDlg::OnBnClickedButtonProceedWithCarrier)
+	ON_BN_CLICKED(IDC_BUTTON_CARRIER_RELEASE, &CEAPSimulatorDlg::OnBnClickedButtonCarrierRelease)
 END_MESSAGE_MAP()
 
 
@@ -275,6 +277,8 @@
 	GetDlgItem(IDC_BUTTON_TRANSMIT_SPOOLED_DATA)->EnableWindow(enabled);
 	GetDlgItem(IDC_BUTTON_PURGE_SPOOLED_DATA)->EnableWindow(enabled);
 	GetDlgItem(IDC_BUTTON_QUERY_PPID_LIST)->EnableWindow(enabled);	
+	GetDlgItem(IDC_BUTTON_PROCEED_WITH_CARRIER)->EnableWindow(enabled);	
+	GetDlgItem(IDC_BUTTON_CARRIER_RELEASE)->EnableWindow(enabled);
 }
 
 void CEAPSimulatorDlg::OnBnClickedButtonConnect()
@@ -376,3 +380,14 @@
 {
 	theApp.m_model.m_pHsmsActive->hsmsQueryPPIDList();
 }
+
+static int DATAID = 1;
+void CEAPSimulatorDlg::OnBnClickedButtonProceedWithCarrier()
+{
+	theApp.m_model.m_pHsmsActive->hsmsProceedWithCarrier(DATAID++, "CSX 52078", 1);
+}
+
+void CEAPSimulatorDlg::OnBnClickedButtonCarrierRelease()
+{
+	theApp.m_model.m_pHsmsActive->hsmsCarrierRelease(DATAID++, "CSX 52078", 2);
+}
diff --git a/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h b/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h
index c243873..c19a88e 100644
--- a/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h
+++ b/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h
@@ -57,4 +57,6 @@
 	afx_msg void OnBnClickedButtonTransmitSpooledData();
 	afx_msg void OnBnClickedButtonPurgeSpooledData();
 	afx_msg void OnBnClickedButtonQueryPpidList();
+	afx_msg void OnBnClickedButtonProceedWithCarrier();
+	afx_msg void OnBnClickedButtonCarrierRelease();
 };
diff --git a/SourceCode/Bond/EAPSimulator/Resource.h b/SourceCode/Bond/EAPSimulator/Resource.h
index f3daccf..b39967c 100644
--- a/SourceCode/Bond/EAPSimulator/Resource.h
+++ b/SourceCode/Bond/EAPSimulator/Resource.h
@@ -44,10 +44,12 @@
 #define IDC_BUTTON_CONFIGURE_SPOOLING   1029
 #define IDC_BUTTON_PURGE_SPOOLED_DATA   1030
 #define IDC_EDIT_CE_NAME                1031
-#define IDC_BUTTON_QUERY_PPID_LIST		1032
+#define IDC_BUTTON_QUERY_PPID_LIST      1032
 #define IDC_EDIT_CE_RPTID               1033
+#define IDC_BUTTON_PROCEED_WITH_CARRIER 1033
 #define IDC_BUTTON_TRANSMIT_SPOOLED_DATA 1034
-
+#define IDC_BUTTON_PROCEED_WITH_CARRIER2 1035
+#define IDC_BUTTON_CARRIER_RELEASE      1035
 
 // Next default values for new objects
 // 
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index 6714999..856a750 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -1703,4 +1703,24 @@
 	{
 		return m_bEnableAlarmReport;
 	}
+
+	int CMaster::proceedWithCarrier(unsigned int port)
+	{
+		if (port >= 4) return -1;
+
+		static int pid[] = { EQ_ID_LOADPORT1, EQ_ID_LOADPORT2, EQ_ID_LOADPORT3, EQ_ID_LOADPORT4};
+		CLoadPort* pPort = (CLoadPort*)getEquipment(pid[port]);
+		pPort->sendCassetteCtrlCmd(CCC_PROCESS_START, nullptr, 0, 0, 0, nullptr, nullptr);
+		return 0;
+	}
+
+	int CMaster::carrierRelease(unsigned int port)
+	{
+		if (port >= 4) return -1;
+
+		static int pid[] = { EQ_ID_LOADPORT1, EQ_ID_LOADPORT2, EQ_ID_LOADPORT3, EQ_ID_LOADPORT4 };
+		CLoadPort* pPort = (CLoadPort*)getEquipment(pid[port]);
+		pPort->sendCassetteCtrlCmd(CCC_PROCESS_CANCEL, nullptr, 0, 0, 0, nullptr, nullptr);
+		return 0;
+	}
 }
diff --git a/SourceCode/Bond/Servo/CMaster.h b/SourceCode/Bond/Servo/CMaster.h
index 7b16db8..27d0973 100644
--- a/SourceCode/Bond/Servo/CMaster.h
+++ b/SourceCode/Bond/Servo/CMaster.h
@@ -81,6 +81,8 @@
         void enableEventReport(bool bEnable);
         void enableAlarmReport(bool bEnable);
         bool isAlarmReportEnable();
+        int proceedWithCarrier(unsigned int port);
+        int carrierRelease(unsigned int port);
 
     private:
         inline void lock() { EnterCriticalSection(&m_criticalSection); }
diff --git a/SourceCode/Bond/Servo/HsmsPassive.cpp b/SourceCode/Bond/Servo/HsmsPassive.cpp
index 9dca68a..76bb93a 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.cpp
+++ b/SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -542,6 +542,9 @@
 		else if (nStream == 2 && pHeader->function == 43) {
 			replyConfigureSpooling(pMessage);
 		}
+		else if (nStream == 3 && pHeader->function == 17) {
+			replyCarrierAction(pMessage);
+		}
 		else if (nStream == 5 && pHeader->function == 3) {
 			replyEanbleDisableAlarmReport(pMessage);
 		}
@@ -1234,6 +1237,57 @@
 	return 0;
 }
 
+// S3F17
+int CHsmsPassive::replyCarrierAction(IMessage* pRecv)
+{
+	if (m_pPassive == NULL || STATE::SELECTED != m_pPassive->getState()) {
+		return ER_NOTSELECT;
+	}
+
+	unsigned char CAACK = CAACK_0;
+	unsigned int ERRCODE = 0;
+	std::string strError = "no error";
+	if (m_listener.onCarrierAction == nullptr) {
+		CAACK = 5;
+		ERRCODE = CAACK_5;
+		strError = "Not supported";
+		goto MYREPLY;
+	}
+
+
+	ISECS2Item* pBody = pRecv->getBody();
+	if (pBody == nullptr || pBody->getType() != SITYPE::L) ER_PARAM_ERROR;
+
+	unsigned int DATAID;
+	unsigned char PTN;
+	const char* pszCarrierAction, *pszCarrierId;
+	pBody->getSubItemU4(0, DATAID);
+	pBody->getSubItemString(1, pszCarrierAction);
+	pBody->getSubItemString(2, pszCarrierId);
+	pBody->getSubItemU1(3, PTN);
+	ERRCODE = m_listener.onCarrierAction(this,
+		DATAID, 
+		pszCarrierAction,
+		pszCarrierId, 
+		PTN,
+		strError);
+	CAACK = ERRCODE;
+
+	// 鍥炲
+MYREPLY:
+	IMessage* pMessage = NULL;
+	HSMS_Create1Message(pMessage, m_nSessionId, 3, 18, pRecv->getHeader()->systemBytes);
+	pMessage->getBody()->addU1Item(CAACK, "CAACK");
+	ISECS2Item* pErrItem = pMessage->getBody()->addItem();
+	pErrItem->addU4Item(ERRCODE, "ERRCODE");
+	pErrItem->addItem(strError.c_str(), "ERRTEXT");
+	m_pPassive->sendMessage(pMessage);
+	LOGI("<HSMS>[SECS Msg SEND]S3F18 (SysByte=%u)", pMessage->getHeader()->systemBytes);
+	HSMS_Destroy1Message(pMessage);
+	
+	return 0;
+}
+
 // S5F3
 int CHsmsPassive::replyEanbleDisableAlarmReport(IMessage* pRecv)
 {
diff --git a/SourceCode/Bond/Servo/HsmsPassive.h b/SourceCode/Bond/Servo/HsmsPassive.h
index 64bccc0..a08350e 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.h
+++ b/SourceCode/Bond/Servo/HsmsPassive.h
@@ -23,7 +23,18 @@
 #define ER_NO_EVENT				-4
 #define ER_UNLINK_EVENT_REPORT	-5
 #define ER_NO_PPID_LIST			-6
+#define ER_NOT_SUPPORTED		-7
 
+
+/* CAACK */
+
+#define CAACK_0					0		/* ok */
+#define CAACK_1					1		/* invalid command */
+#define CAACK_2					2		/* cannot perform now */
+#define CAACK_3					3		/* invalid data or argument */
+#define CAACK_4					4		/* initiated for asynchronous completion */
+#define CAACK_5					5		/* rejected - invalid state */
+#define CAACK_6					6		/* command performed with errors */
 
 /*
  * 常量数据结构
@@ -69,6 +80,12 @@
 typedef std::function<void(void* pFrom, bool bEnable, std::vector<unsigned int>& ids)> EDEVENTREPORT;
 typedef std::function<void(void* pFrom, bool bEnable, unsigned int id)> EDALARMREPORT;
 typedef std::function<std::vector<std::string> (void* pFrom)> QUERYPPIDLIST;
+typedef std::function<unsigned int (void* pFrom,
+	unsigned int DATAID,
+	const char* pszCarrierAction,
+	const char* pszCarrierId,
+	unsigned char PTN, 
+	std::string& strErrorTxt)> CARRIERACTION;
 typedef struct _SECSListener
 {
 	SECSEQOFFLINE				onEQOffLine;
@@ -80,6 +97,7 @@
 	EDEVENTREPORT				onEnableDisableEventReport;
 	EDALARMREPORT				onEnableDisableAlarmReport;
 	QUERYPPIDLIST				onQueryPPIDList;
+	CARRIERACTION				onCarrierAction;
 } SECSListener;
 
 
@@ -173,6 +191,7 @@
 	int replyEanbleDisableEventReport(IMessage* pRecv);
 	int replyCommand(IMessage* pRecv);
 	int replyConfigureSpooling(IMessage* pRecv);
+	int replyCarrierAction(IMessage* pRecv);
 	int replyEanbleDisableAlarmReport(IMessage* pRecv);
 	int replyPurgeSpooledData(IMessage* pRecv);
 	int replyQueryPPIDList(IMessage* pRecv);
diff --git a/SourceCode/Bond/Servo/Model.cpp b/SourceCode/Bond/Servo/Model.cpp
index 70685aa..6cc7531 100644
--- a/SourceCode/Bond/Servo/Model.cpp
+++ b/SourceCode/Bond/Servo/Model.cpp
@@ -151,6 +151,30 @@
 		}
 		return ppids;
 	};
+	listener.onCarrierAction = [&](void* pFrom, 
+		unsigned int DATAID, 
+		const char* pszCarrierAction,
+		const char* pszCarrierId,
+		unsigned char PTN,
+		std::string& strErrorTxt) -> unsigned int {
+			if (PTN < 1 || 4 < PTN) {
+				strErrorTxt = "invalid data or argument";
+				return CAACK_3;
+			}
+
+			if (_strcmpi(pszCarrierAction, "ProceedWithCarrier") == 0) {
+				m_master.proceedWithCarrier(PTN);
+				return CAACK_0;
+			}
+			else if (_strcmpi(pszCarrierAction, "CarrierRelease") == 0) {
+				m_master.carrierRelease(PTN);
+				return CAACK_0;
+			}
+
+			strErrorTxt = "rejected - invalid state";
+			return CAACK_5;
+			LOGI("<Model>onCarrierAction %d, %s, %d, %d", DATAID, pszCarrierAction, pszCarrierId, PTN);
+	};
 	m_hsmsPassive.setListener(listener);
 	m_hsmsPassive.setEquipmentModelType((LPTSTR)(LPCTSTR)strModeType);
 	m_hsmsPassive.setSoftRev((LPTSTR)(LPCTSTR)strSoftRev);
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index 552795b..c1df135 100644
--- a/SourceCode/Bond/Servo/Servo.rc
+++ b/SourceCode/Bond/Servo/Servo.rc
Binary files differ

--
Gitblit v1.9.3