From 0393d1ff2ebc378b3c4cff9b45f72ebc8a4ea516 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期二, 03 六月 2025 15:13:42 +0800
Subject: [PATCH] Merge branch 'master' into liuyang

---
 SourceCode/Bond/Servo/CLoadPort.cpp |  305 +++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 258 insertions(+), 47 deletions(-)

diff --git a/SourceCode/Bond/Servo/CLoadPort.cpp b/SourceCode/Bond/Servo/CLoadPort.cpp
index 940dbbc..6e689a9 100644
--- a/SourceCode/Bond/Servo/CLoadPort.cpp
+++ b/SourceCode/Bond/Servo/CLoadPort.cpp
@@ -16,10 +16,10 @@
 	CLoadPort::CLoadPort() : CEquipment()
 	{
 		m_nIndex = 0;
-		m_nType = 1;
-		m_nMode = 1;
-		m_nCassetteType = 1;
-		m_nTransferMode = 1;
+		m_portType = PortType::Loading;
+		m_portMode = PortMode::InService;
+		m_cassetteType = CassetteType::G1;
+		m_transferMode = TransferMode::AGVMode;
 		m_bEnable = FALSE;
 		m_bAutoChangeEnable = FALSE;
 	}
@@ -55,6 +55,35 @@
 		addPin(SERVO::PinType::OUTPUT, _T("Out2"));
 	}
 
+	// 必须要实现的虚函数,在此初始化Slot信息
+	void CLoadPort::initSlots()
+	{
+		m_slot[0].enable();
+		m_slot[0].setPosition(m_nID);
+		m_slot[0].setNo(1);
+		m_slot[0].setName("Slot 1");
+		m_slot[1].enable();
+		m_slot[1].setPosition(m_nID);
+		m_slot[1].setNo(2);
+		m_slot[1].setName("Slot 2");
+		m_slot[2].setPosition(m_nID);
+		m_slot[2].enable();
+		m_slot[2].setNo(3);
+		m_slot[2].setName("Slot 3");
+		m_slot[3].setPosition(m_nID);
+		m_slot[3].enable();
+		m_slot[3].setNo(4);
+		m_slot[3].setName("Slot 4");
+		m_slot[4].setPosition(m_nID);
+		m_slot[4].enable();
+		m_slot[4].setNo(5);
+		m_slot[4].setName("Slot 5");
+		m_slot[5].setPosition(m_nID);
+		m_slot[5].enable();
+		m_slot[5].setNo(6);
+		m_slot[5].setName("Slot 6");
+	}
+
 	void CLoadPort::initSteps()
 	{
 		CEquipment::initSteps();
@@ -88,7 +117,7 @@
 			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);
+						m_portType = (PortType)CToolUnits::toInt16(pszData);
 					}
 					return 0;
 				});
@@ -109,7 +138,7 @@
 			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);
+						m_portMode = (PortMode)CToolUnits::toInt16(pszData);
 					}
 					return 0;
 				});
@@ -130,7 +159,7 @@
 			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);
+						m_cassetteType = (CassetteType)CToolUnits::toInt16(pszData);
 					}
 					return 0;
 				});
@@ -151,7 +180,7 @@
 			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);
+						m_transferMode = (TransferMode)CToolUnits::toInt16(pszData);
 					}
 					return 0;
 				});
@@ -358,13 +387,13 @@
 		attrubutes.addAttribute(new CAttribute("Index",
 			std::to_string(m_nIndex).c_str(), "", weight++));
 		attrubutes.addAttribute(new CAttribute("Type",
-			getPortTypeDescription(m_nType, strTemp).c_str(), "", weight++));
+			getPortTypeDescription(m_portType, strTemp).c_str(), "", weight++));
 		attrubutes.addAttribute(new CAttribute("Mode",
-			getPortModeDescription(m_nMode, strTemp).c_str(), "", weight++));
+			getPortModeDescription(m_portMode, strTemp).c_str(), "", weight++));
 		attrubutes.addAttribute(new CAttribute("CassetteType",
-			getPortCassetteTypeDescription(m_nCassetteType, strTemp).c_str(), "", weight++));
+			getPortCassetteTypeDescription(m_cassetteType, strTemp).c_str(), "", weight++));
 		attrubutes.addAttribute(new CAttribute("TransferMode",
-			getPortTransferModeDescription(m_nTransferMode, strTemp).c_str(), "", weight++));
+			getPortTransferModeDescription(m_transferMode, strTemp).c_str(), "", weight++));
 		attrubutes.addAttribute(new CAttribute("Enable",
 			m_bEnable ? "Eanble" : "Disable", "", weight++));
 		attrubutes.addAttribute(new CAttribute("Auto Change",
@@ -374,21 +403,6 @@
 	int CLoadPort::recvIntent(CPin* pPin, CIntent* pIntent)
 	{
 		return __super::recvIntent(pPin, pIntent);
-	}
-
-	int CLoadPort::outputGlass(int port)
-	{
-		return __super::outputGlass(port);
-	}
-
-	BOOL CLoadPort::glassWillArrive(CGlass* pGlass)
-	{
-		BOOL bRet = __super::glassWillArrive(pGlass);
-		if (!bRet) {
-			return FALSE;
-		}
-
-		return (m_glassList.size() < 8);
 	}
 
 	int CLoadPort::sendCassetteCtrlCmd(short cmd,
@@ -441,29 +455,64 @@
 		return m_bEnable;
 	}
 
-	int CLoadPort::getPortType()
+	PortType CLoadPort::getPortType()
 	{
-		return m_nType;
+		return m_portType;
 	}
 
-	int CLoadPort::getPortMode()
+	PortMode CLoadPort::getPortMode()
 	{
-		return m_nMode;
+		return m_portMode;
 	}
 
-	int CLoadPort::getCessetteType()
+	CassetteType CLoadPort::getCessetteType()
 	{
-		return m_nCassetteType;
+		return m_cassetteType;
 	}
 
-	int CLoadPort::getTransferMode()
+	TransferMode CLoadPort::getTransferMode()
 	{
-		return m_nTransferMode;
+		return m_transferMode;
 	}
 
 	BOOL CLoadPort::isAutoChange()
 	{
 		return m_bAutoChangeEnable;
+	}
+
+	int CLoadPort::getPortStatus()
+	{
+		return m_portStatusReport.getPortStatus();
+	}
+
+	int CLoadPort::getCassetteSequenceNo()
+	{
+		return m_portStatusReport.getCassetteSequenceNo();
+	}
+
+	std::string& CLoadPort::getCassetteId()
+	{
+		return m_portStatusReport.getCassetteId();
+	}
+
+	int CLoadPort::getLoadingCassetteType()
+	{
+		return m_portStatusReport.getLoadingCassetteType();
+	}
+
+	int CLoadPort::getQTimeFlag()
+	{
+		return m_portStatusReport.getQTimeFlag();
+	}
+
+	int CLoadPort::getCassetteMappingState()
+	{
+		return m_portStatusReport.getCassetteMappingState();
+	}
+
+	int CLoadPort::getCassetteStatus()
+	{
+		return m_portStatusReport.getCassetteStatus();
 	}
 
 	/*
@@ -475,9 +524,9 @@
 	 6: Buffer Port-Un-loader in Buffer Type
 	 7: Unloading Partial Port
 	 */
-	std::string& CLoadPort::getPortTypeDescription(int portType, std::string& strDescription)
+	std::string& CLoadPort::getPortTypeDescription(PortType portType, std::string& strDescription)
 	{
-		switch (portType) {
+		switch ((int)portType) {
 		case 1:
 			strDescription = _T("Loading Port");
 			break;
@@ -515,9 +564,9 @@
 	 4: InService
 	 5: TransferReady
 	 */
-	std::string& CLoadPort::getPortModeDescription(int portMode, std::string& strDescription)
+	std::string& CLoadPort::getPortModeDescription(PortMode portMode, std::string& strDescription)
 	{
-		switch (portMode) {
+		switch ((int)portMode) {
 		case 0:
 			strDescription = _T("OutOfService");
 			break;
@@ -549,9 +598,9 @@
 	 2: G2
 	 3: G1&G2
 	 */
-	std::string& CLoadPort::getPortCassetteTypeDescription(int casseteType, std::string& strDescription)
+	std::string& CLoadPort::getPortCassetteTypeDescription(CassetteType casseteType, std::string& strDescription)
 	{
-		switch (casseteType) {
+		switch ((int)casseteType) {
 		case 1:
 			strDescription = _T("G1");
 			break;
@@ -574,9 +623,9 @@
 	 2: AGV Mode
 	 3: Stocker Inline Mode
 	 */
-	std::string& CLoadPort::getPortTransferModeDescription(int mode, std::string& strDescription)
+	std::string& CLoadPort::getPortTransferModeDescription(TransferMode mode, std::string& strDescription)
 	{
-		switch (mode) {
+		switch ((int)mode) {
 		case 1:
 			strDescription = _T("MGV Mode");
 			break;
@@ -607,6 +656,156 @@
 			break;
 		case 2:
 			strDescription = _T("Disable");
+			break;
+		default:
+			strDescription = _T("");
+			break;
+		}
+
+		return strDescription;
+	}
+
+	/*
+	 1: Load Ready(Load Request)
+	 2: Loaded
+	 3: In Use (Load Complete)
+	 4: Unload Ready (Unload Request)
+	 5: Empty (Unload Complete)
+	 6: Blocked
+ */
+	std::string& CLoadPort::getPortStatusDescription(int portStatus, std::string& strDescription)
+	{
+		switch (portStatus) {
+		case 1:
+			strDescription = _T("Load Ready(Load Request)");
+			break;
+		case 2:
+			strDescription = _T("Loaded");
+			break;
+		case 3:
+			strDescription = _T("In Use(Load Complete)");
+			break;
+		case 4:
+			strDescription = _T("Unload Ready(Unload Request)");
+			break;
+		case 5:
+			strDescription = _T("Empty(Unload Complete)");
+			break;
+		case 6:
+			strDescription = _T("Blocked");
+			break;
+		default:
+			strDescription = _T("");
+			break;
+		}
+
+		return strDescription;
+	}
+
+	/*
+	 1: G1 Cassette
+	 2: G2 Cassette
+	 3: G1 + G2 Cassette
+	 4: Empty Cassette
+	 *  Include this item only when cassette exists"
+	*/
+	std::string& CLoadPort::getLoadingCassetteTypeDescription(int type, std::string& strDescription)
+	{
+		switch (type) {
+		case 1:
+			strDescription = _T("G1 Cassette)");
+			break;
+		case 2:
+			strDescription = _T("G2 Cassette");
+			break;
+		case 3:
+			strDescription = _T("G1+G2 Cassette)");
+			break;
+		case 4:
+			strDescription = _T("Empty Cassette)");
+			break;
+		default:
+			strDescription = _T("");
+			break;
+		}
+
+		return strDescription;
+	}
+
+	/*
+	 1: Normal Un-loading
+	 2: Q-Time Over & Un-loading
+	*/
+	std::string& CLoadPort::getQTimeFlagDescription(int flag, std::string& strDescription)
+	{
+		switch (flag) {
+		case 1:
+			strDescription = _T("Normal Un-loading");
+			break;
+		case 2:
+			strDescription = _T("Q-Time Over & Un-loading");
+			break;
+		default:
+			strDescription = _T("");
+			break;
+		}
+
+		return strDescription;
+	}
+
+	/*
+	 1: mapping use
+	 2: mapping not use
+	*/
+	std::string& CLoadPort::getCassetteMappingStateDescription(int state, std::string& strDescription)
+	{
+		switch (state) {
+		case 1:
+			strDescription = _T("Mapping use");
+			break;
+		case 2:
+			strDescription = _T("Mapping not use");
+			break;
+		default:
+			strDescription = _T("");
+			break;
+		}
+
+		return strDescription;
+	}
+
+	/*
+	 1: No Cassette Exist
+	 2: Waiting for Cassette Data
+	 3: Waiting for Start Command
+	 4: Waiting for Processing
+	 5: In Processing
+	 6: Process Paused
+	 7: Process Completed
+	*/
+	std::string& CLoadPort::getCassetteStatusDescription(int state, std::string& strDescription)
+	{
+		switch (state) {
+		case 1:
+			strDescription = _T("No Cassette Exist");
+			break;
+		case 2:
+			strDescription = _T("Waiting for Cassette Data");
+			break;
+		case 3:
+			strDescription = _T("Waiting for Start Command");
+			break;
+		case 4:
+			strDescription = _T("Waiting for Processing");
+			break;
+		case 5:
+			strDescription = _T("In Processing");
+			break;
+		case 6:
+			strDescription = _T("Process Paused");
+			break;
+		case 7:
+			strDescription = _T("Process Completed");
 			break;
 		default:
 			strDescription = _T("");
@@ -859,11 +1058,16 @@
 	/*
 	 * 生成测试用的玻璃列表
 	 */
-	int CLoadPort::testGenerateGlassList(MaterialsType type, int count, const char* pszPrefix, int startSuffix)
+	int CLoadPort::testGenerateGlassList(MaterialsType type, const char* pszPrefix, int startSuffix)
 	{
+		static unsigned short nJobSequenceNo = 0;
+		static unsigned short nCassetteSequenceNo = 0;
+		nCassetteSequenceNo++;
+
+
 		// 如果非空就不生成了
 		Lock();
-		if (!m_glassList.empty()) {
+		if (hasGlass()) {
 			Unlock();
 			return -1;
 		}
@@ -872,13 +1076,19 @@
 
 		char szBuffer[64];
 		int suffix = startSuffix;
-		for (int i = 0; i < count; i++) {
+		for (int i = 0; i < SLOT_MAX; i++) {
+			if (!m_slot[i].isEnable()) continue;
+
 			CJobDataB jb;
 			CJobDataS js;
 
 			sprintf_s(szBuffer, "%s%d", pszPrefix, suffix++);
 			jb.setGlassId(szBuffer);
+			jb.setCassetteSequenceNo(nCassetteSequenceNo);
+			jb.setJobSequenceNo(++nJobSequenceNo);
 			js.setMaterialsType((int)type);
+			js.setCassetteSequenceNo(nCassetteSequenceNo);
+			js.setJobSequenceNo(nJobSequenceNo);
 			if (type == MaterialsType::G1) {
 				js.setGlass1Id(szBuffer);
 			}
@@ -891,7 +1101,8 @@
 			pGlass->setJobDataB(&jb);
 			pGlass->setType(type);
 			pGlass->setJobDataS(&js);
-			addGlassToList(pGlass);
+			pGlass->addRef();
+			m_slot[i].setContext(pGlass);
 		}
 
 		return 0;

--
Gitblit v1.9.3