From dba7d2725cefc162ef58a53bb12b4656434c8bc0 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 30 六月 2025 08:42:17 +0800
Subject: [PATCH] 1.调试后更新优化;

---
 SourceCode/Bond/Servo/CLoadPort.cpp |  147 +++++++++++++++++++++++-------------------------
 1 files changed, 71 insertions(+), 76 deletions(-)

diff --git a/SourceCode/Bond/Servo/CLoadPort.cpp b/SourceCode/Bond/Servo/CLoadPort.cpp
index 81361bc..25d2306 100644
--- a/SourceCode/Bond/Servo/CLoadPort.cpp
+++ b/SourceCode/Bond/Servo/CLoadPort.cpp
@@ -12,6 +12,14 @@
 	}																		\
 }
 
+#define CHECK_WRITE_STEP_SIGNAL2(addr, data, size) {							\
+	BOOL bFlag = isBitOn(data, size, addr);									\
+	SERVO::CStep* pStep = getStep(addr);									\
+	if (pStep != nullptr) {													\
+		((CWriteStep*)pStep)->onRecvSignal(bFlag ? addr : 0);				\
+	}																		\
+}
+
 namespace SERVO {
 	CLoadPort::CLoadPort() : CEquipment()
 	{
@@ -22,6 +30,7 @@
 		m_transferMode = TransferMode::AGVMode;
 		m_bEnable = FALSE;
 		m_bAutoChangeEnable = FALSE;
+		m_nNextCassetteSequenceNo = 0;
 	}
 
 	CLoadPort::~CLoadPort()
@@ -299,7 +308,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;
 			}
 		}
@@ -345,50 +354,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;
 			}
 		}
 	}
@@ -485,6 +450,16 @@
 		Unlock();
 
 		return pStep;
+	}
+
+	short CLoadPort::getNextCassetteSequenceNo()
+	{
+		m_nNextCassetteSequenceNo++;
+		if (m_nNextCassetteSequenceNo >= 1000) {
+			m_nNextCassetteSequenceNo = 0;
+		}
+
+		return (m_nIndex + 1) * 1000 + m_nNextCassetteSequenceNo;
 	}
 
 	void CLoadPort::setIndex(unsigned int index)
@@ -900,12 +875,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_SIGNAL2(typeReply[m_nIndex], pszData, size);
+		CHECK_WRITE_STEP_SIGNAL2(modeReply[m_nIndex], pszData, size);
+		CHECK_WRITE_STEP_SIGNAL2(transferModeReply[m_nIndex], pszData, size);
+		CHECK_WRITE_STEP_SIGNAL2(enableModeReply[m_nIndex], pszData, size);
+		CHECK_WRITE_STEP_SIGNAL2(typeAutoReply[m_nIndex], pszData, size);
+		CHECK_WRITE_STEP_SIGNAL2(cassetteTypeReply[m_nIndex], pszData, size);
 	}
 
 	int CLoadPort::decodePortStatusReport(CStep* pStep, const char* pszData, size_t size)
@@ -918,10 +893,8 @@
 
 		// 缓存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());
@@ -1138,13 +1111,8 @@
 	/*
 	 * 生成测试用的玻璃列表
 	 */
-	int CLoadPort::testGenerateGlassList(MaterialsType type, const char* pszPrefix, int startSuffix)
+	int CLoadPort::testGenerateGlassList(MaterialsType type)
 	{
-		static unsigned short nJobSequenceNo = 0;
-		static unsigned short nCassetteSequenceNo = 0;
-		nCassetteSequenceNo++;
-
-
 		// 如果非空就不生成了
 		Lock();
 		if (hasGlass()) {
@@ -1155,32 +1123,21 @@
 
 
 		char szBuffer[64];
-		int suffix = startSuffix;
 		for (int i = 0; i < 1; 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.setCassetteSequenceNo(getNextCassetteSequenceNo());
+			js.setJobSequenceNo(m_slot[i].getNo());
+			sprintf_s(szBuffer, 64, "%05d%05d", js.getCassetteSequenceNo(), js.getJobSequenceNo());
+			//js.setGlass1Id(szBuffer);
+			js.setJobType(1);
 			js.setMaterialsType((int)type);
-			js.setCassetteSequenceNo(nCassetteSequenceNo);
-			js.setJobSequenceNo(nJobSequenceNo);
-			if (type == MaterialsType::G1) {
-				js.setGlass1Id(szBuffer);
-			}
-			else if (type == MaterialsType::G2) {
-				js.setGlass2Id(szBuffer);
-			}
 
 			CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass();
 			pGlass->addPath(m_nID, 0);
 			pGlass->processEnd(m_nID, 0);
 			pGlass->setID(szBuffer);
-			pGlass->setJobDataB(&jb);
 			pGlass->setType(type);
 			pGlass->setJobDataS(&js);
 			m_slot[i].setContext(pGlass);
@@ -1189,4 +1146,42 @@
 		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->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