From 83c4b402947892eafe9ec9d732d3159d07d6228a Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期三, 21 五月 2025 11:07:09 +0800
Subject: [PATCH] 1.LoadPort状态获取; 2.LoadPort Event 由原CReadIntStep修改为CReadStep

---
 SourceCode/Bond/Servo/Servo.vcxproj         |    2 
 SourceCode/Bond/Servo/Servo.vcxproj.filters |    2 
 SourceCode/Bond/Servo/CLoadPort.h           |    5 +
 SourceCode/Bond/Servo/CEFEM.cpp             |   62 ---------------
 SourceCode/Bond/Servo/CEquipment.h          |    1 
 SourceCode/Bond/Servo/CLoadPort.cpp         |  140 +++++++++++++++++++++++++---------
 SourceCode/Bond/Servo/Common.h              |    1 
 7 files changed, 113 insertions(+), 100 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEFEM.cpp b/SourceCode/Bond/Servo/CEFEM.cpp
index 82ab452..f94b373 100644
--- a/SourceCode/Bond/Servo/CEFEM.cpp
+++ b/SourceCode/Bond/Servo/CEFEM.cpp
@@ -234,18 +234,6 @@
 		}
 
 		{
-			// VCR1 Event Report
-			/*
-			CEqVcrEventStep* pStep = new CEqVcrEventStep();
-			pStep->setName(STEP_EQ_VCR1_EVENT_REPORT);
-			pStep->setWriteSignalDev(0x4a);
-			pStep->setReturnDev(0x91e);
-			pStep->setVcrEventReportDev(0x5fef);
-			if (addStep(STEP_ID_VCR1_EVENT_REPORT, pStep) != 0) {
-				delete pStep;
-			}
-			*/
-
 			// VCR Event Report
 			// 机器上报扫码结果,扫码器预计安装在巡边检机器上
 			CEqReadStep* pStep = new CEqReadStep(0x5fef, 15 * 2,
@@ -328,56 +316,6 @@
 				delete pStep;
 			}
 		}
-
-		// CEqCassetteTranserStateStep
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT1_EMPTY, 0xd8,
-			STEP_ID_PORT1_EMPTY, 0x6050);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT1_LOAD_EADY, 0xe0,
-			STEP_ID_PORT1_LOAD_READY, 0x6050);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT1_LOADED, 0xe8,
-			STEP_ID_PORT1_LOADED, 0x6050);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT1_INUSE, 0xf0,
-			STEP_ID_PORT1_INUSE, 0x6050);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT1_UNLOAD_EADY, 0xf8,
-			STEP_ID_PORT1_UNLOAD_READY, 0x60f50);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT1_BLOCKED, 0x100,
-			STEP_ID_PORT1_BLOCKED, 0x6050);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT2_EMPTY, 0xd9,
-			STEP_ID_PORT2_EMPTY, 0x6070);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT2_LOAD_EADY, 0xe1,
-			STEP_ID_PORT2_LOAD_READY, 0x6070);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT2_LOADED, 0xe9,
-			STEP_ID_PORT2_LOADED, 0x6070);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT2_INUSE, 0xf1,
-			STEP_ID_PORT2_INUSE, 0x6070);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT2_UNLOAD_EADY, 0xf9,
-			STEP_ID_PORT2_UNLOAD_READY, 0x6070);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT2_BLOCKED, 0x101,
-			STEP_ID_PORT2_BLOCKED, 0x6070);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT3_EMPTY, 0xda,
-			STEP_ID_PORT3_EMPTY, 0x6090);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT3_LOAD_EADY, 0xe2,
-			STEP_ID_PORT3_LOAD_READY, 0x6090);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT3_LOADED, 0xea,
-			STEP_ID_PORT3_INUSE, 0x6090);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT3_INUSE, 0xf2,
-			STEP_ID_PORT3_INUSE, 0x6090);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT3_UNLOAD_EADY, 0xfa,
-			STEP_ID_PORT3_UNLOAD_READY, 0x6090);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT3_BLOCKED, 0x102,
-			STEP_ID_PORT3_BLOCKED, 0x6090);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT4_EMPTY, 0xdb,
-			STEP_ID_PORT4_EMPTY, 0x60b0);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT4_LOAD_EADY, 0xe3,
-			STEP_ID_PORT4_LOAD_READY, 0x60b0);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT4_LOADED, 0xeb,
-			STEP_ID_PORT4_LOADED, 0x60b0);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT4_INUSE, 0xf3,
-			STEP_ID_PORT4_INUSE, 0x60b0);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT4_UNLOAD_EADY, 0xfb,
-			STEP_ID_PORT4_UNLOAD_READY, 0x60b0);
-		ADD_EQ_PORT_STATUS_STEP(STEP_EQ_PORT4_BLOCKED, 0x103,
-			STEP_ID_PORT4_BLOCKED, 0x60b0);
 
 		{
 			// Received Job Report Upstream#1~9
diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index 81b7bc0..d1d3288 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -32,6 +32,7 @@
 #include "CJobDataC.h"
 #include "CJobDataS.h"
 #include "CProcessData.h"
+#include "CPortStatusReport.h"
 
 
 namespace SERVO {
diff --git a/SourceCode/Bond/Servo/CLoadPort.cpp b/SourceCode/Bond/Servo/CLoadPort.cpp
index d3879c3..0771f18 100644
--- a/SourceCode/Bond/Servo/CLoadPort.cpp
+++ b/SourceCode/Bond/Servo/CLoadPort.cpp
@@ -85,7 +85,13 @@
 			static int writeSignalDev[] = { 0xa0, 0xa1, 0xa2, 0xa3 };
 			static int addr[] = { STEP_ID_PORT1_TYPE_CHANGE, STEP_ID_PORT2_TYPE_CHANGE, STEP_ID_PORT3_TYPE_CHANGE, STEP_ID_PORT4_TYPE_CHANGE };
 
-			CEqReadIntStep* pStep = new CEqReadIntStep(__INT16, dev[m_nIndex]);
+			CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], sizeof(short),
+				[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
+					if (code == ROK && pszData != nullptr && size > 0) {
+						m_nType = (unsigned int)CToolUnits::toInt16(pszData);
+					}
+					return 0;
+				});
 			pStep->setName(pszName[m_nIndex]);
 			pStep->setWriteSignalDev(writeSignalDev[m_nIndex]);
 			if (addStep(addr[m_nIndex], pStep) != 0) {
@@ -100,7 +106,13 @@
 			static int writeSignalDev[] = { 0xa8, 0xa9, 0xaa, 0xab };
 			static int addr[] = { STEP_ID_PORT1_MODE_CHANGE, STEP_ID_PORT2_MODE_CHANGE, STEP_ID_PORT3_MODE_CHANGE, STEP_ID_PORT4_MODE_CHANGE };
 
-			CEqReadIntStep* pStep = new CEqReadIntStep(__INT16, dev[m_nIndex]);
+			CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], sizeof(short),
+				[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
+					if (code == ROK && pszData != nullptr && size > 0) {
+						m_nMode = (unsigned int)CToolUnits::toInt16(pszData);
+					}
+					return 0;
+				});
 			pStep->setName(pszName[m_nIndex]);
 			pStep->setWriteSignalDev(writeSignalDev[m_nIndex]);
 			if (addStep(addr[m_nIndex], pStep) != 0) {
@@ -115,7 +127,13 @@
 			static int writeSignalDev[] = { 0xb0, 0xb1, 0xb2, 0xb3 };
 			static int addr[] = { STEP_ID_PORT1_CASSETTE_TYPE_CHANGE, STEP_ID_PORT2_CASSETTE_TYPE_CHANGE, STEP_ID_PORT3_CASSETTE_TYPE_CHANGE, STEP_ID_PORT4_CASSETTE_TYPE_CHANGE };
 
-			CEqReadIntStep* pStep = new CEqReadIntStep(__INT16, dev[m_nIndex]);
+			CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], sizeof(short),
+				[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
+					if (code == ROK && pszData != nullptr && size > 0) {
+						m_nCassetteType = (unsigned int)CToolUnits::toInt16(pszData);
+					}
+					return 0;
+				});
 			pStep->setName(pszName[m_nIndex]);
 			pStep->setWriteSignalDev(writeSignalDev[m_nIndex]);
 			if (addStep(addr[m_nIndex], pStep) != 0) {
@@ -130,7 +148,13 @@
 			static int writeSignalDev[] = { 0xb8, 0xb9, 0xba, 0xbb };
 			static int addr[] = { STEP_ID_PORT1_TRANSFER_MODE_CHANGE, STEP_ID_PORT2_TRANSFER_MODE_CHANGE, STEP_ID_PORT3_TRANSFER_MODE_CHANGE, STEP_ID_PORT4_TRANSFER_MODE_CHANGE };
 
-			CEqReadIntStep* pStep = new CEqReadIntStep(__INT16, dev[m_nIndex]);
+			CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], sizeof(short),
+				[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
+					if (code == ROK && pszData != nullptr && size > 0) {
+						m_nTransferMode = (unsigned int)CToolUnits::toInt16(pszData);
+					}
+					return 0;
+				});
 			pStep->setName(pszName[m_nIndex]);
 			pStep->setWriteSignalDev(writeSignalDev[m_nIndex]);
 			if (addStep(addr[m_nIndex], pStep) != 0) {
@@ -145,7 +169,13 @@
 			static int writeSignalDev[] = { 0xc0, 0xc1, 0xc2, 0xc3 };
 			static int addr[] = { STEP_ID_PORT1_ENABLE_MODE_CHANGE, STEP_ID_PORT2_ENABLE_MODE_CHANGE, STEP_ID_PORT3_ENABLE_MODE_CHANGE, STEP_ID_PORT4_ENABLE_MODE_CHANGE };
 
-			CEqReadIntStep* pStep = new CEqReadIntStep(__INT16, dev[m_nIndex]);
+			CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], sizeof(short),
+				[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
+					if (code == ROK && pszData != nullptr && size > 0) {
+						m_bEnable = (unsigned int)CToolUnits::toInt16(pszData) == 1;
+					}
+					return 0;
+				});
 			pStep->setName(pszName[m_nIndex]);
 			pStep->setWriteSignalDev(writeSignalDev[m_nIndex]);
 			if (addStep(addr[m_nIndex], pStep) != 0) {
@@ -160,11 +190,61 @@
 			static int writeSignalDev[] = { 0xc8, 0xc9, 0xca, 0xcb };
 			static int addr[] = { STEP_ID_PORT1_TYPE_AUTO_CHANGE, STEP_ID_PORT2_TYPE_AUTO_CHANGE, STEP_ID_PORT3_TYPE_AUTO_CHANGE, STEP_ID_PORT4_TYPE_AUTO_CHANGE };
 
-			CEqReadIntStep* pStep = new CEqReadIntStep(__INT16, dev[m_nIndex]);
+			CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], sizeof(short),
+				[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
+					if (code == ROK && pszData != nullptr && size > 0) {
+						m_bAutoChangeEnable = (unsigned int)CToolUnits::toInt16(pszData) == 1;
+					}
+					return 0;
+				});
 			pStep->setName(pszName[m_nIndex]);
 			pStep->setWriteSignalDev(writeSignalDev[m_nIndex]);
 			if (addStep(addr[m_nIndex], pStep) != 0) {
 				delete pStep;
+			}
+		}
+
+		{
+			char* pszName[6][4] = { 
+				{STEP_EQ_PORT1_EMPTY, STEP_EQ_PORT2_EMPTY, STEP_EQ_PORT3_EMPTY, STEP_EQ_PORT4_EMPTY},
+				{STEP_EQ_PORT1_LOAD_EADY, STEP_EQ_PORT2_LOAD_EADY, STEP_EQ_PORT3_LOAD_EADY, STEP_EQ_PORT4_LOAD_EADY},
+				{STEP_EQ_PORT1_LOADED, STEP_EQ_PORT2_LOADED, STEP_EQ_PORT3_LOADED, STEP_EQ_PORT4_LOADED},
+				{STEP_EQ_PORT1_INUSE, STEP_EQ_PORT2_INUSE, STEP_EQ_PORT3_INUSE, STEP_EQ_PORT4_INUSE},
+				{STEP_EQ_PORT1_UNLOAD_EADY, STEP_EQ_PORT2_UNLOAD_EADY, STEP_EQ_PORT3_UNLOAD_EADY, STEP_EQ_PORT4_UNLOAD_EADY},
+				{STEP_EQ_PORT1_BLOCKED, STEP_EQ_PORT2_BLOCKED, STEP_EQ_PORT3_BLOCKED, STEP_EQ_PORT4_BLOCKED}
+			};
+			static int dev[] = { 0x6050, 0x6070, 0x6090, 0x60b0 };
+			static int writeSignalDev[6][4] = {
+				{0xd8, 0xd9, 0xda, 0xdb},
+				{0xe0, 0xe1, 0xe2, 0xe3},
+				{0xe8, 0xe9, 0xea, 0xeb},
+				{0xf0, 0xf1, 0xf2, 0xf3},
+				{0xf8, 0xf9, 0xfa, 0xfb},
+				{0x100, 0x101, 0x102, 0x103}
+			};
+			static int addr[6][4] = {
+				{ STEP_ID_PORT1_EMPTY, STEP_ID_PORT2_EMPTY, STEP_ID_PORT3_EMPTY, STEP_ID_PORT4_EMPTY },
+				{ STEP_ID_PORT1_LOAD_READY, STEP_ID_PORT2_LOAD_READY, STEP_ID_PORT3_LOAD_READY, STEP_ID_PORT4_LOAD_READY },
+				{ STEP_ID_PORT1_LOADED, STEP_ID_PORT2_LOADED, STEP_ID_PORT3_LOADED, STEP_ID_PORT4_LOADED },
+				{ STEP_ID_PORT1_INUSE, STEP_ID_PORT2_INUSE, STEP_ID_PORT3_INUSE, STEP_ID_PORT4_INUSE },
+				{ STEP_ID_PORT1_UNLOAD_READY, STEP_ID_PORT2_UNLOAD_READY, STEP_ID_PORT3_UNLOAD_READY, STEP_ID_PORT4_UNLOAD_READY },
+				{ STEP_ID_PORT1_BLOCKED, STEP_ID_PORT2_BLOCKED, STEP_ID_PORT3_BLOCKED, STEP_ID_PORT4_BLOCKED },
+			};
+
+			for (int i = 0; i < 6; i++) {
+				CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], 32 * 2,
+					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
+						if (code == ROK && pszData != nullptr && size > 0) {
+							decodePortStatusReport((CStep*)pFrom, pszData, size);
+						}
+						return -1;
+					});
+				pStep->setName(pszName[i][m_nIndex]);
+				pStep->setProp("Port", (void*)(__int64)(m_nIndex + 1));
+				pStep->setWriteSignalDev(writeSignalDev[i][m_nIndex]);
+				if (addStep(addr[i][m_nIndex], pStep) != 0) {
+					delete pStep;
+				}
 			}
 		}
 	}
@@ -469,40 +549,26 @@
 		CHECK_READ_STEP_SIGNAL2(autoType[m_nIndex], pszData, size);
 	}
 
-	int CLoadPort::onStepEvent(CStep* pStep, int code)
+	int CLoadPort::decodePortStatusReport(CStep* pStep, const char* pszData, size_t size)
 	{
-		int nRet = CEquipment::onStepEvent(pStep, code);
-		if (nRet > 0) return nRet;
-
-		if (code == STEP_EVENT_READDATA) {
-			if (isPortTypeStep(pStep)) {
-				SERVO::CEqReadIntStep* pReadIntStep = (SERVO::CEqReadIntStep*)pStep;
-				m_nType = pReadIntStep->getValue();
-			}
-			else if(isPortModeStep(pStep)) {
-				SERVO::CEqReadIntStep* pReadIntStep = (SERVO::CEqReadIntStep*)pStep;
-				m_nMode = pReadIntStep->getValue();
-			}
-			else if (isPortCassetteTypeStep(pStep)) {
-				SERVO::CEqReadIntStep* pReadIntStep = (SERVO::CEqReadIntStep*)pStep;
-				m_nCassetteType = pReadIntStep->getValue();
-			}
-			else if (isPortTransferModeStep(pStep)) {
-				SERVO::CEqReadIntStep* pReadIntStep = (SERVO::CEqReadIntStep*)pStep;
-				m_nTransferMode = pReadIntStep->getValue();
-			}
-			else if (isPortEnableStep(pStep)) {
-				SERVO::CEqReadIntStep* pReadIntStep = (SERVO::CEqReadIntStep*)pStep;
-				m_bEnable = pReadIntStep->getValue() == 1;
-			}
-			else if (isPortTypeAutoChangeEnableStep(pStep)) {
-				SERVO::CEqReadIntStep* pReadIntStep = (SERVO::CEqReadIntStep*)pStep;
-				m_bAutoChangeEnable = pReadIntStep->getValue() == 1;
-			}
-		}
+		CPortStatusReport portStatusReport;
+		int nRet = portStatusReport.unserialize(&pszData[0], (int)size);
+		if (nRet < 0) return nRet;
+		m_portStatusReport.copyEx(portStatusReport);
 
 
-		return 0;
+		// 缓存Attribute,用于调试时显示信息
+		unsigned int weight = 201;
+		CAttributeVector attrubutes;
+		m_portStatusReport.getAttributeVector(attrubutes, weight);
+		pStep->addAttributeVector(attrubutes);
+
+
+		LOGI("<CCassetteTranserStateStep>decodePortStatusReport<Status:%d, CassetteSequenceNo:%d>",
+			m_portStatusReport.getPortStatus(), m_portStatusReport.getCassetteSequenceNo());
+
+
+		return nRet;
 	}
 
 	/*
diff --git a/SourceCode/Bond/Servo/CLoadPort.h b/SourceCode/Bond/Servo/CLoadPort.h
index 0b28400..17d8eef 100644
--- a/SourceCode/Bond/Servo/CLoadPort.h
+++ b/SourceCode/Bond/Servo/CLoadPort.h
@@ -22,7 +22,6 @@
 		virtual int recvIntent(CPin* pPin, CIntent* pIntent);
 		virtual BOOL glassWillArrive(CGlass* pGlass);
 		virtual void onReceiveLBData(const char* pszData, size_t size);
-		virtual int onStepEvent(CStep* pStep, int code);
 
 	public:
 		void setIndex(unsigned int index);
@@ -53,6 +52,9 @@
 		CStep* getCassetteCtrlCmdStep();
 
 	private:
+		int decodePortStatusReport(CStep* pStep, const char* pszData, size_t size);
+
+	private:
 		unsigned int m_nIndex;
 		int m_nType;
 		int m_nMode;
@@ -60,6 +62,7 @@
 		int m_nTransferMode;
 		BOOL m_bEnable;
 		BOOL m_bAutoChangeEnable;
+		CPortStatusReport m_portStatusReport;
 	};
 }
 
diff --git a/SourceCode/Bond/Servo/Common.h b/SourceCode/Bond/Servo/Common.h
index aa287e8..3ddf79a 100644
--- a/SourceCode/Bond/Servo/Common.h
+++ b/SourceCode/Bond/Servo/Common.h
@@ -365,6 +365,7 @@
 
 /* Port Status */
 #define PORT_LOAD_READY				1
+#define PORT_LOAD_REQUEST			PORT_LOAD_READY
 #define PORT_LOADED					2
 #define PORT_INUSE					3
 #define PORT_LOAD_COMPLETE			PORT_INUSE
diff --git a/SourceCode/Bond/Servo/Servo.vcxproj b/SourceCode/Bond/Servo/Servo.vcxproj
index 5db43c3..e158b1d 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj
+++ b/SourceCode/Bond/Servo/Servo.vcxproj
@@ -200,6 +200,7 @@
   <ItemGroup>
     <ClInclude Include="CEquipmentPage3.h" />
     <ClInclude Include="CGlassPool.h" />
+    <ClInclude Include="CPortStatusReport.h" />
     <ClInclude Include="PageRecipe.h" />
     <ClInclude Include="CDoubleGlass.h" />
     <ClInclude Include="CProcessData.h" />
@@ -299,6 +300,7 @@
   <ItemGroup>
     <ClCompile Include="CEquipmentPage3.cpp" />
     <ClCompile Include="CGlassPool.cpp" />
+    <ClCompile Include="CPortStatusReport.cpp" />
     <ClCompile Include="PageRecipe.cpp" />
     <ClCompile Include="CDoubleGlass.cpp" />
     <ClCompile Include="CProcessData.cpp" />
diff --git a/SourceCode/Bond/Servo/Servo.vcxproj.filters b/SourceCode/Bond/Servo/Servo.vcxproj.filters
index d3871d4..4f377c4 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj.filters
+++ b/SourceCode/Bond/Servo/Servo.vcxproj.filters
@@ -105,6 +105,7 @@
     <ClCompile Include="CProcessData.cpp" />
     <ClCompile Include="CGlassPool.cpp" />
     <ClCompile Include="CEquipmentPage3.cpp" />
+    <ClCompile Include="CPortStatusReport.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="AlarmManager.h" />
@@ -208,6 +209,7 @@
     <ClInclude Include="CProcessData.h" />
     <ClInclude Include="CGlassPool.h" />
     <ClInclude Include="CEquipmentPage3.h" />
+    <ClInclude Include="CPortStatusReport.h" />
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="Servo.rc" />

--
Gitblit v1.9.3