From 5fe38f3aa84459690a59667bff205f3f350c086c Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 28 四月 2025 18:03:39 +0800
Subject: [PATCH] 1.把LoadPort相关的step移到CLoadPort下,交它们当前efem的子设备来处理,逻辑上比较顺。

---
 SourceCode/Bond/Servo/CLoadPort.cpp |  102 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 98 insertions(+), 4 deletions(-)

diff --git a/SourceCode/Bond/Servo/CLoadPort.cpp b/SourceCode/Bond/Servo/CLoadPort.cpp
index 9aab4ad..a51e99c 100644
--- a/SourceCode/Bond/Servo/CLoadPort.cpp
+++ b/SourceCode/Bond/Servo/CLoadPort.cpp
@@ -2,13 +2,22 @@
 #include "CLoadPort.h"
 
 
+#define CHECK_READ_STEP_SIGNAL2(addr, data, size) {							\
+	BOOL bFlag = isBitOn(data, size, addr);									\
+	SERVO::CStep* pStep = getStep(addr);									\
+	if (pStep != nullptr) {													\
+		((CReadStep*)pStep)->onReadSignal(bFlag ? addr : 0);				\
+	}																		\
+}
+
 namespace SERVO {
 	CLoadPort::CLoadPort() : CEquipment()
 	{
-		m_nType = 0;
-		m_nMode = 0;
-		m_nCassetteType = 0;
-		m_nTransferMode = 4;
+		m_nIndex = 0;
+		m_nType = 1;
+		m_nMode = 1;
+		m_nCassetteType = 1;
+		m_nTransferMode = 1;
 		m_bEnable = FALSE;
 		m_bAutoChangeEnable = FALSE;
 	}
@@ -57,6 +66,22 @@
 	void CLoadPort::getAttributeVector(CAttributeVector& attrubutes)
 	{
 		__super::getAttributeVector(attrubutes);
+
+		std::string strTemp;
+		attrubutes.addAttribute(new CAttribute("Index",
+			std::to_string(m_nIndex).c_str(), ""));
+		attrubutes.addAttribute(new CAttribute("Type",
+			getPortTypeDescription(m_nType, strTemp).c_str(), ""));
+		attrubutes.addAttribute(new CAttribute("Mode",
+			getPortModeDescription(m_nMode, strTemp).c_str(), ""));
+		attrubutes.addAttribute(new CAttribute("CassetteType",
+			getPortCassetteTypeDescription(m_nCassetteType, strTemp).c_str(), ""));
+		attrubutes.addAttribute(new CAttribute("TransferMode",
+			getPortTransferModeDescription(m_nTransferMode, strTemp).c_str(), ""));
+		attrubutes.addAttribute(new CAttribute("Enable",
+			m_bEnable ? "Eanble" : "Disable", ""));
+		attrubutes.addAttribute(new CAttribute("Auto Change",
+			m_bAutoChangeEnable ? "Eanble" : "Disable", ""));
 	}
 
 	int CLoadPort::recvIntent(CPin* pPin, CIntent* pIntent)
@@ -125,6 +150,16 @@
 		Unlock();
 
 		return pStep;
+	}
+
+	void CLoadPort::setIndex(unsigned int index)
+	{
+		m_nIndex = index;
+	}
+
+	unsigned int CLoadPort::getIndex()
+	{
+		return m_nIndex;
 	}
 
 	BOOL CLoadPort::isEnable()
@@ -306,4 +341,63 @@
 
 		return strDescription;
 	}
+
+	void CLoadPort::onReceiveLBData(const char* pszData, size_t size)
+	{
+		static int type[] = { STEP_ID_PORT1_TYPE_CHANGE, STEP_ID_PORT2_TYPE_CHANGE,
+			STEP_ID_PORT3_TYPE_CHANGE, STEP_ID_PORT4_TYPE_CHANGE };
+		static int mode[] = { STEP_ID_PORT1_MODE_CHANGE, STEP_ID_PORT2_MODE_CHANGE,
+			STEP_ID_PORT3_MODE_CHANGE, STEP_ID_PORT4_MODE_CHANGE };
+		static int cassetteType[] = { STEP_ID_PORT1_CASSETTE_TYPE_CHANGE, STEP_ID_PORT2_CASSETTE_TYPE_CHANGE,
+			STEP_ID_PORT3_CASSETTE_TYPE_CHANGE, STEP_ID_PORT4_CASSETTE_TYPE_CHANGE };
+		static int transferMode[] = { STEP_ID_PORT1_TRANSFER_MODE_CHANGE, STEP_ID_PORT2_TRANSFER_MODE_CHANGE,
+			STEP_ID_PORT3_TRANSFER_MODE_CHANGE, STEP_ID_PORT4_TRANSFER_MODE_CHANGE };
+		static int enable[] = { STEP_ID_PORT1_ENABLE_MODE_CHANGE, STEP_ID_PORT2_ENABLE_MODE_CHANGE,
+			STEP_ID_PORT3_ENABLE_MODE_CHANGE, STEP_ID_PORT4_ENABLE_MODE_CHANGE };
+		static int autoType[] = { STEP_ID_PORT1_TYPE_AUTO_CHANGE, STEP_ID_PORT2_TYPE_AUTO_CHANGE,
+			STEP_ID_PORT3_TYPE_AUTO_CHANGE, STEP_ID_PORT4_TYPE_AUTO_CHANGE };
+
+		CHECK_READ_STEP_SIGNAL2(type[m_nIndex], pszData, size);
+		CHECK_READ_STEP_SIGNAL2(mode[m_nIndex], pszData, size);
+		CHECK_READ_STEP_SIGNAL2(cassetteType[m_nIndex], pszData, size);
+		CHECK_READ_STEP_SIGNAL2(transferMode[m_nIndex], pszData, size);
+		CHECK_READ_STEP_SIGNAL2(enable[m_nIndex], pszData, size);
+		CHECK_READ_STEP_SIGNAL2(autoType[m_nIndex], pszData, size);
+	}
+
+	int CLoadPort::onStepEvent(CStep* pStep, int code)
+	{
+		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;
+			}
+		}
+
+
+		return 0;
+	}
 }

--
Gitblit v1.9.3