From 10f48622c553729352dce9a4484def4bfeaa1083 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期三, 02 七月 2025 14:51:33 +0800
Subject: [PATCH] 1.将OnPanelDataReport相关功能由EFEM移到Aligner; 2.Glass增加最初来源Port和Slot,以便在Aligner检测NG时加退; 3.物流调度增加一个参数,是否检测OK作为调度依据。 4.Alginer检测NG,送回原处;

---
 SourceCode/Bond/Servo/CLoadPort.cpp |  178 ++++++++++++++++++++++++++++++----------------------------
 1 files changed, 92 insertions(+), 86 deletions(-)

diff --git a/SourceCode/Bond/Servo/CLoadPort.cpp b/SourceCode/Bond/Servo/CLoadPort.cpp
index 540a5e6..f6afed4 100644
--- a/SourceCode/Bond/Servo/CLoadPort.cpp
+++ b/SourceCode/Bond/Servo/CLoadPort.cpp
@@ -2,15 +2,8 @@
 #include "CLoadPort.h"
 #include "CGlassPool.h"
 #include "Servo.h"
+#include "ServoCommo.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()
@@ -75,15 +68,15 @@
 
 		{
 			// Cassette Ctrl Cmd
-			static char* pszName[] = { STEP_EQ_P1_CASSETTE_CTRL_CMD,	STEP_EQ_P2_CASSETTE_CTRL_CMD, STEP_EQ_P3_CASSETTE_CTRL_CMD,	STEP_EQ_P4_CASSETTE_CTRL_CMD };
-			static int writeSignalDev[] = { 0x120, 0x121, 0x122, 0x123 };
+			static char* pszName[] = { STEP_EQ_P1_CASSETTE_CTRL_CMD, STEP_EQ_P2_CASSETTE_CTRL_CMD, STEP_EQ_P3_CASSETTE_CTRL_CMD, STEP_EQ_P4_CASSETTE_CTRL_CMD };
+			static int writeSignalDev[] = { 0x130, 0x131, 0x132, 0x133 };
 			static int dev[] = { 0x45, 0x1a5, 0x305, 0x465 };
-			static int addr[] = { 0x480, 0x481, 0x482, 0x483 };
+			static int addr[] = { STEP_ID_PROT1_CASSETTE_CTR_CMD_REPLY, STEP_ID_PROT2_CASSETTE_CTR_CMD_REPLY, STEP_ID_PROT3_CASSETTE_CTR_CMD_REPLY, STEP_ID_PROT4_CASSETTE_CTR_CMD_REPLY };
 
-			CEqCassetteCtrlCmdStep* pStep = new CEqCassetteCtrlCmdStep();
+			CEqWriteStep* pStep = new CEqWriteStep();
 			pStep->setName(pszName[m_nIndex]);
 			pStep->setWriteSignalDev(writeSignalDev[m_nIndex]);
-			pStep->setCtrlCmdDev(dev[m_nIndex]);
+			pStep->setDataDev(dev[m_nIndex]);
 			if (addStep(addr[m_nIndex], pStep) != 0) {
 				delete pStep;
 			}
@@ -300,7 +293,7 @@
 			pStep->setName(pszName[m_nIndex]);
 			pStep->setWriteSignalDev(0x128 + m_nIndex);
 			pStep->setDataDev(dev[m_nIndex]);
-			if (addStep(STEP_ID_PROT1_TYPE_AUTO_CHANGE_REPLY + m_nIndex, pStep) != 0) {
+			if (addStep(STEP_ID_PROT1_CASSETTE_TYPE_CHANGE_REPLY + m_nIndex, pStep) != 0) {
 				delete pStep;
 			}
 		}
@@ -316,12 +309,12 @@
 			};
 			static int dev[] = { 0x6050, 0x6070, 0x6090, 0x60b0 };
 			static int writeSignalDev[6][4] = {
+				{0xc8, 0xc9, 0xca, 0xcb},
+				{0xd0, 0xd1, 0xd2, 0xd3},
 				{0xd8, 0xd9, 0xda, 0xdb},
 				{0xe0, 0xe1, 0xe2, 0xe3},
 				{0xe8, 0xe9, 0xea, 0xeb},
-				{0xf0, 0xf1, 0xf2, 0xf3},
-				{0xf8, 0xf9, 0xfa, 0xfb},
-				{0x100, 0x101, 0x102, 0x103}
+				{0xf0, 0xf1, 0xf2, 0xf3}
 			};
 			static int addr[6][4] = {
 				{ STEP_ID_PORT1_EMPTY, STEP_ID_PORT2_EMPTY, STEP_ID_PORT3_EMPTY, STEP_ID_PORT4_EMPTY },
@@ -337,6 +330,7 @@
 					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 						if (code == ROK && pszData != nullptr && size > 0) {
 							decodePortStatusReport((CStep*)pFrom, pszData, size);
+							return 0;
 						}
 						return -1;
 					});
@@ -346,50 +340,6 @@
 				if (addStep(addr[i][m_nIndex], pStep) != 0) {
 					delete pStep;
 				}
-			}
-		}
-		
-		{
-			// Fetched Out Job Report #1~15
-			char szBuffer[256];
-			CEqReadStep* pStep = new CEqReadStep(0x5c31 + 18 * m_nIndex, 18 * 2,
-				[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
-					if (code == ROK && pszData != nullptr && size > 0) {
-						int port = (int)(__int64)((CEqReadStep*)pFrom)->getProp("Port");
-						if (port > 0) {
-							decodeFetchedOutJobReport((CStep*)pFrom, port, pszData, size);
-						}
-					}
-					return -1;
-				});
-			sprintf_s(szBuffer, "%s%d", STEP_EQ_FETCHED_OUT_JOBn, m_nIndex + 1);
-			pStep->setName(szBuffer);
-			pStep->setProp("Port", (void*)(__int64)(m_nIndex + 1));
-			pStep->setWriteSignalDev(0x023 + m_nIndex);
-			if (addStep(STEP_ID_FETCHED_OUT_JOB_REPORT1 + m_nIndex, pStep) != 0) {
-				delete pStep;
-			}
-		}
-
-		{
-			// Store Job Report #1~15
-			char szBuffer[256];
-			CEqReadStep* pStep = new CEqReadStep(0x5b23 + 18 * m_nIndex, 18 * 2,
-				[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
-					if (code == ROK && pszData != nullptr && size > 0) {
-						int port = (int)(__int64)((CEqReadStep*)pFrom)->getProp("Port");
-						if (port > 0) {
-							decodeStoredJobReport((CStep*)pFrom, port, pszData, size);
-						}
-					}
-					return -1;
-				});
-			sprintf_s(szBuffer, "%s%d", STEP_EQ_STORED_JOBn, m_nIndex + 1);
-			pStep->setName(szBuffer);
-			pStep->setProp("Port", (void*)(__int64)(m_nIndex + 1));
-			pStep->setWriteSignalDev(0x014 + m_nIndex);
-			if (addStep(STEP_ID_STORE_JOB_REPORT1 + m_nIndex, pStep) != 0) {
-				delete pStep;
 			}
 		}
 	}
@@ -458,17 +408,25 @@
 		int jobExistenceSize,
 		short slotProcess,
 		short jopCount,
-		CJobDataA* pJobDataA)
+		CJobDataA* pJobDataA,
+		ONWRITED onWritedBlock)
 	{
-		int id = getID();
-		if ( !(id == EQ_ID_LOADPORT1 || id == EQ_ID_LOADPORT2) ) {
-			return -1;
+		SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getCassetteCtrlCmdStep();
+		ASSERT(pStep);
+
+		char szBuffer[1024] = { 0 };
+		memcpy(&szBuffer[0], &cmd, sizeof(short));
+		if (jobExistence != nullptr && jobExistenceSize == 12) {
+			memcpy(&szBuffer[2], jobExistence, sizeof(short) * jobExistenceSize);
 		}
 
+		memcpy(&szBuffer[26], &slotProcess, sizeof(short));
+		memcpy(&szBuffer[36], &jopCount, sizeof(short));
+		if (pJobDataA != nullptr) {
+			pJobDataA->serialize(&szBuffer[38], 1024 - 38);
+		}
 
-		SERVO::CEqCassetteCtrlCmdStep* pStep = (SERVO::CEqCassetteCtrlCmdStep*)getCassetteCtrlCmdStep();
-		ASSERT(pStep);
-		return pStep->sendCtrlCmd(cmd, jobExistence, jobExistenceSize, slotProcess, jopCount, pJobDataA);
+		return pStep->writeDataEx(szBuffer, 352 * 2, onWritedBlock);
 	}
 
 	CStep* CLoadPort::getCassetteCtrlCmdStep()
@@ -890,12 +848,12 @@
 		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);
+		CHECK_READ_STEP_SIGNAL(type[m_nIndex], pszData, size);
+		CHECK_READ_STEP_SIGNAL(mode[m_nIndex], pszData, size);
+		CHECK_READ_STEP_SIGNAL(cassetteType[m_nIndex], pszData, size);
+		CHECK_READ_STEP_SIGNAL(transferMode[m_nIndex], pszData, size);
+		CHECK_READ_STEP_SIGNAL(enable[m_nIndex], pszData, size);
+		CHECK_READ_STEP_SIGNAL(autoType[m_nIndex], pszData, size);
 
 
 		static int typeReply[] = { STEP_ID_PROT1_TYPE_CHANGE_REPLY, STEP_ID_PROT2_TYPE_CHANGE_REPLY,
@@ -911,12 +869,12 @@
 		static int cassetteTypeReply[] = { STEP_ID_PROT1_CASSETTE_TYPE_CHANGE_REPLY, STEP_ID_PROT2_CASSETTE_TYPE_CHANGE_REPLY,
 			STEP_ID_PROT3_CASSETTE_TYPE_CHANGE_REPLY, STEP_ID_PROT4_CASSETTE_TYPE_CHANGE_REPLY };
 
-		CHECK_READ_STEP_SIGNAL2(typeReply[m_nIndex], pszData, size);
-		CHECK_READ_STEP_SIGNAL2(modeReply[m_nIndex], pszData, size);
-		CHECK_READ_STEP_SIGNAL2(transferModeReply[m_nIndex], pszData, size);
-		CHECK_READ_STEP_SIGNAL2(enableModeReply[m_nIndex], pszData, size);
-		CHECK_READ_STEP_SIGNAL2(typeAutoReply[m_nIndex], pszData, size);
-		CHECK_READ_STEP_SIGNAL2(cassetteTypeReply[m_nIndex], pszData, size);
+		CHECK_WRITE_STEP_SIGNAL(typeReply[m_nIndex], pszData, size);
+		CHECK_WRITE_STEP_SIGNAL(modeReply[m_nIndex], pszData, size);
+		CHECK_WRITE_STEP_SIGNAL(transferModeReply[m_nIndex], pszData, size);
+		CHECK_WRITE_STEP_SIGNAL(enableModeReply[m_nIndex], pszData, size);
+		CHECK_WRITE_STEP_SIGNAL(typeAutoReply[m_nIndex], pszData, size);
+		CHECK_WRITE_STEP_SIGNAL(cassetteTypeReply[m_nIndex], pszData, size);
 	}
 
 	int CLoadPort::decodePortStatusReport(CStep* pStep, const char* pszData, size_t size)
@@ -926,16 +884,24 @@
 		if (nRet < 0) return nRet;
 		m_portStatusReport.copyEx(portStatusReport);
 
+		if (m_portStatusReport.getPortStatus() == PORT_INUSE) {
+			this->sendCassetteCtrlCmd(5, nullptr, 0, 0, 0, nullptr, nullptr);
+		}
+
+
 
 		// 缓存Attribute,用于调试时显示信息
 		unsigned int weight = 201;
-		CAttributeVector attrubutes;
+		CAttributeVector& attrubutes = pStep->attributeVector();
 		m_portStatusReport.getAttributeVector(attrubutes, weight);
-		pStep->addAttributeVector(attrubutes);
 
-
-		LOGI("<CCassetteTranserStateStep>decodePortStatusReport<Status:%d, CassetteSequenceNo:%d>",
-			m_portStatusReport.getPortStatus(), m_portStatusReport.getCassetteSequenceNo());
+		LOGI("<CCassetteTranserStateStep>decodePortStatusReport<Status:%d, CassetteSequenceNo:%d, CassetteId:%s>",
+			m_portStatusReport.getPortStatus(), m_portStatusReport.getCassetteSequenceNo(), 
+			m_portStatusReport.getCassetteId().c_str());
+		if (m_portStatusReport.getPortStatus() == 3) {
+			LOGI("<CCassetteTranserStateStep>InUse<JobExistenceSlot:%d>",
+				m_portStatusReport.getJobExistenceSlot());
+		}
 
 
 		return nRet;
@@ -1168,11 +1134,12 @@
 			js.setCassetteSequenceNo(getNextCassetteSequenceNo());
 			js.setJobSequenceNo(m_slot[i].getNo());
 			sprintf_s(szBuffer, 64, "%05d%05d", js.getCassetteSequenceNo(), js.getJobSequenceNo());
-			js.setGlass1Id(szBuffer);
+			//js.setGlass1Id(szBuffer);
 			js.setJobType(1);
 			js.setMaterialsType((int)type);
 
 			CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass();
+			pGlass->setOriginPort(m_nIndex, i);
 			pGlass->addPath(m_nID, 0);
 			pGlass->processEnd(m_nID, 0);
 			pGlass->setID(szBuffer);
@@ -1184,4 +1151,43 @@
 		return 0;
 	}
 
+	int CLoadPort::testGenerateGlassListFromConfig(const SERVO::PortConfig& config)
+	{
+		char szBuffer[64];
+		for (const auto& slot : config.vecSlot) {
+			int nSlotIndex = slot.nSlotID - 1;
+			if (nSlotIndex < 0 || nSlotIndex >= SLOT_MAX) {
+				continue;
+			}
+			if (!slot.isEnabled) {
+				m_slot[nSlotIndex].setContext(nullptr);
+				continue;
+			}
+
+			CJobDataS js;
+			js.setCassetteSequenceNo(getNextCassetteSequenceNo());
+			js.setJobSequenceNo(m_slot[nSlotIndex].getNo());
+
+			sprintf_s(szBuffer, 64, "%05d%05d", js.getCassetteSequenceNo(), js.getJobSequenceNo());
+			js.setJobType(1);
+			js.setMaterialsType(config.nMaterialType);
+
+			js.setLotId(config.strLotID.c_str());
+			js.setProductId(config.strProductID.c_str());
+			js.setOperationId(config.strOperationID.c_str());
+			js.setGlass1Id(szBuffer);
+
+			CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass();
+			pGlass->setOriginPort(m_nIndex, nSlotIndex);
+			pGlass->addPath(m_nID, 0);
+			pGlass->processEnd(m_nID, 0);
+			pGlass->setID(szBuffer);
+			pGlass->setType(static_cast<SERVO::MaterialsType>(config.nMaterialType));
+			pGlass->setJobDataS(&js);
+
+			m_slot[nSlotIndex].setContext(pGlass);
+		}
+
+		return 0;
+	}
 }

--
Gitblit v1.9.3