From ae6ef5e9343aba44b7547ecc4afab935ebdf4806 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期四, 19 六月 2025 09:13:09 +0800
Subject: [PATCH] Merge branch 'clh' into liuyang

---
 SourceCode/Bond/Servo/CPageGraph2.cpp                           |    5 
 SourceCode/Bond/Servo/CWriteStep.h                              |   12 +
 SourceCode/Bond/Servo/CVacuumBake.cpp                           |    8 
 SourceCode/Bond/Servo/CRobotCmdTestDlg.cpp                      |    2 
 SourceCode/Bond/Servo/CWriteStep.cpp                            |   29 +++
 SourceCode/Bond/Servo/CRobotTask.cpp                            |    2 
 SourceCode/Bond/Servo/CLoadPort.cpp                             |   78 ++++++---
 SourceCode/Bond/Servo/CBakeCooling.cpp                          |    8 
 /dev/null                                                       |    0 
 SourceCode/Bond/Servo/CEqWriteStep.h                            |    2 
 SourceCode/Bond/Servo/CMeasurement.cpp                          |    8 
 SourceCode/Bond/Servo/CEqWriteStep.cpp                          |    9 +
 SourceCode/Bond/Servo/CEquipment.cpp                            |   93 +++++++----
 SourceCode/Bond/Servo/CEFEM.cpp                                 |   55 ------
 SourceCode/Bond/Servo/CMaster.cpp                               |   15 -
 SourceCode/Bond/Servo/CEquipment.h                              |    9 +
 SourceCode/Bond/Servo/ServoCommo.h                              |    7 
 Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.7(3).xlsx |    0 
 SourceCode/Bond/Servo/CBonder.h                                 |    1 
 SourceCode/Bond/Servo/CBonder.cpp                               |   77 ++++++---
 SourceCode/Bond/Servo/Common.h                                  |    2 
 21 files changed, 257 insertions(+), 165 deletions(-)

diff --git a/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.1.xlsx b/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.1.xlsx
deleted file mode 100644
index be48abf..0000000
--- a/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.1.xlsx
+++ /dev/null
Binary files differ
diff --git a/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.2.xlsx b/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.2.xlsx
deleted file mode 100644
index 77c0949..0000000
--- a/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.2.xlsx
+++ /dev/null
Binary files differ
diff --git "a/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.4\0501\051.xlsx" "b/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.4\0501\051.xlsx"
deleted file mode 100644
index 907bfd3..0000000
--- "a/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.4\0501\051.xlsx"
+++ /dev/null
Binary files differ
diff --git "a/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.5\0504\051.xlsx" "b/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.5\0504\051.xlsx"
deleted file mode 100644
index 0a62420..0000000
--- "a/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.5\0504\051.xlsx"
+++ /dev/null
Binary files differ
diff --git "a/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.5\0505\051.xlsx" "b/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.5\0505\051.xlsx"
deleted file mode 100644
index 8b3d58f..0000000
--- "a/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.5\0505\051.xlsx"
+++ /dev/null
Binary files differ
diff --git a/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.5.xlsx b/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.5.xlsx
deleted file mode 100644
index e7d314b..0000000
--- a/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.5.xlsx
+++ /dev/null
Binary files differ
diff --git "a/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.7\0503\051.xlsx" "b/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.7\0503\051.xlsx"
new file mode 100644
index 0000000..7078aa7
--- /dev/null
+++ "b/Document/ESWIN_EAS_Bonder_Inline_Mapping_Address_v1.1.7\0503\051.xlsx"
Binary files differ
diff --git a/SourceCode/Bond/Servo/CBakeCooling.cpp b/SourceCode/Bond/Servo/CBakeCooling.cpp
index f7af2a6..5387d13 100644
--- a/SourceCode/Bond/Servo/CBakeCooling.cpp
+++ b/SourceCode/Bond/Servo/CBakeCooling.cpp
@@ -239,7 +239,7 @@
 		{
 			// Received Job Report Upstream #1~9
 			char szBuffer[256];
-			for (int i = 0; i < 9; i++) {
+			for (int i = 0; i < 1; i++) {
 				CEqReadStep* pStep = new CEqReadStep(0x10c90 + 320 * i, 320 * 2,
 					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 						if (code == ROK && pszData != nullptr && size > 0) {
@@ -263,7 +263,7 @@
 		{
 			// Sent Out Job Report Downstream #1~9
 			char szBuffer[256];
-			for (int i = 0; i < 9; i++) {
+			for (int i = 0; i < 1; i++) {
 				CEqReadStep* pStep = new CEqReadStep(0x10000 + 320 * i, 320 * 2,
 					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 						if (code == ROK && pszData != nullptr && size > 0) {
@@ -287,7 +287,7 @@
 		{
 			// Fetched Out Job Report #1~15
 			char szBuffer[256];
-			for (int i = 0; i < 15; i++) {
+			for (int i = 0; i < 1; i++) {
 				CEqReadStep* pStep = new CEqReadStep(0x11c31 + 18 * i, 18 * 2,
 					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 						if (code == ROK && pszData != nullptr && size > 0) {
@@ -311,7 +311,7 @@
 		{
 			// Stored Job Report #1~15
 			char szBuffer[256];
-			for (int i = 0; i < 15; i++) {
+			for (int i = 0; i < 1; i++) {
 				CEqReadStep* pStep = new CEqReadStep(0x11b23 + 18 * i, 18 * 2,
 					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 						if (code == ROK && pszData != nullptr && size > 0) {
diff --git a/SourceCode/Bond/Servo/CBonder.cpp b/SourceCode/Bond/Servo/CBonder.cpp
index cbeabd5..0943eea 100644
--- a/SourceCode/Bond/Servo/CBonder.cpp
+++ b/SourceCode/Bond/Servo/CBonder.cpp
@@ -244,7 +244,7 @@
 		{
 			// Received Job Report Upstream #1~9
 			char szBuffer[256];
-			for (int i = 0; i < 9; i++) {
+			for (int i = 0; i < 1; i++) {
 				CEqReadStep* pStep = new CEqReadStep((m_nIndex == 0 ? 0x8c90 : 0xcc90) + 320 * i, 320 * 2,
 					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 						if (code == ROK && pszData != nullptr && size > 0) {
@@ -267,7 +267,7 @@
 		{
 			// Sent Out Job Report Downstream #1~9
 			char szBuffer[256];
-			for (int i = 0; i < 9; i++) {
+			for (int i = 0; i < 1; i++) {
 				CEqReadStep* pStep = new CEqReadStep((m_nIndex == 0 ? 0x8000 : 0xc000) + 320 * i, 320 * 2,
 					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 						if (code == ROK && pszData != nullptr && size > 0) {
@@ -291,7 +291,7 @@
 		{
 			// Fetched Out Job Report #1~15
 			char szBuffer[256];
-			for (int i = 0; i < 15; i++) {
+			for (int i = 0; i < 1; i++) {
 				CEqReadStep* pStep = new CEqReadStep((m_nIndex == 0 ? 0x9c31 : 0xdc31) + 18 * i, 18 * 2,
 					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 						if (code == ROK && pszData != nullptr && size > 0) {
@@ -315,7 +315,7 @@
 		{
 			// Stored Job Report #1~15
 			char szBuffer[256];
-			for (int i = 0; i < 15; i++) {
+			for (int i = 0; i < 1; i++) {
 				CEqReadStep* pStep = new CEqReadStep((m_nIndex == 0 ? 0x9b23 : 0xdb23) + 18 * i, 18 * 2,
 					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 						if (code == ROK && pszData != nullptr && size > 0) {
@@ -333,6 +333,18 @@
 				if (addStep(STEP_ID_STORE_JOB_REPORT1 + i, pStep) != 0) {
 					delete pStep;
 				}
+			}
+		}
+
+		{
+			// Indexer Operation Mode Change
+			CEqWriteStep* pStep = new CEqWriteStep();
+			pStep->setName(STEP_EQ_IN_OP_MODE_CHANGE);
+			pStep->setWriteSignalDev(0x370);
+			pStep->setDataDev(0x923);
+			pStep->setRetDataDev(0xa00e, 2);
+			if (addStep(STEP_ID_IN_OP_CMD_REPLY, pStep) != 0) {
+				delete pStep;
 			}
 		}
 
@@ -429,32 +441,41 @@
 		CEquipment::onProcessData(pProcessData);
 
 
-		// 检查数据,当前两片玻璃,一片为G1, 一片为G2, 且pProcessData中的id能匹配G1或G2
-		Lock();
-		CGlass* pGlass2 = getGlassFromSlot(1);
-		CGlass* pGlass1 = getGlassFromSlot(2);
-		if (pGlass1 == nullptr || pGlass2 == nullptr) {
-			LOGE("<CBonder-%s>onProcessData,错误!不满足两片玻璃且分别为G1与G2的条件,请检查数据是否正确!", m_strName.c_str());
-			Unlock();
-			return -1;
-		}
-		if (pGlass1->getBuddy() != nullptr) {
-			LOGE("<CBonder-%s>onProcessData,错误!玻璃较早前已被绑定,请检查数据是否正确!", m_strName.c_str());
-			Unlock();
-			return -1;
-		}
+		return 0;
+	}
 
-		if (pGlass1->getType() != MaterialsType::G1 || pGlass2->getType() != MaterialsType::G2) {
-			LOGE("<CBonder-%s>onProcessData,错误!两片玻璃未匹配,必须分别为G1和G2类型,请检查数据是否正确!", m_strName.c_str());
-			Unlock();
-			return -1;
-		}
+	int CBonder::onProcessStateChanged(PROCESS_STATE state)
+	{
+		CEquipment::onProcessStateChanged(state);
 
-		pGlass1->setBuddy(pGlass2);
-		getSlot(0)->setContext(nullptr);
-		LOGE("<CBonder-%s>onProcessData,%s和%s已贴合!", m_strName.c_str(),
-			pGlass1->getID().c_str(), pGlass2->getID().c_str());
-		Unlock();
+		if (state == PROCESS_STATE::Complete) {
+			// 检查数据,当前两片玻璃,一片为G1, 一片为G2, 且pProcessData中的id能匹配G1或G2
+			Lock();
+			CGlass* pGlass2 = getGlassFromSlot(1);
+			CGlass* pGlass1 = getGlassFromSlot(2);
+			if (pGlass1 == nullptr || pGlass2 == nullptr) {
+				LOGE("<CBonder-%s>onProcessData,错误!不满足两片玻璃且分别为G1与G2的条件,请检查数据是否正确!", m_strName.c_str());
+				Unlock();
+				return -1;
+			}
+			if (pGlass1->getBuddy() != nullptr) {
+				LOGE("<CBonder-%s>onProcessData,错误!玻璃较早前已被绑定,请检查数据是否正确!", m_strName.c_str());
+				Unlock();
+				return -1;
+			}
+
+			if (pGlass1->getType() != MaterialsType::G1 || pGlass2->getType() != MaterialsType::G2) {
+				LOGE("<CBonder-%s>onProcessData,错误!两片玻璃未匹配,必须分别为G1和G2类型,请检查数据是否正确!", m_strName.c_str());
+				Unlock();
+				return -1;
+			}
+
+			pGlass1->setBuddy(pGlass2);
+			getSlot(0)->setContext(nullptr);
+			LOGE("<CBonder-%s>onProcessStateChanged,%s和%s已贴合!", m_strName.c_str(),
+				pGlass1->getID().c_str(), pGlass2->getID().c_str());
+			Unlock();
+		}
 
 		return 0;
 	}
diff --git a/SourceCode/Bond/Servo/CBonder.h b/SourceCode/Bond/Servo/CBonder.h
index 7771c57..7fa6aea 100644
--- a/SourceCode/Bond/Servo/CBonder.h
+++ b/SourceCode/Bond/Servo/CBonder.h
@@ -22,6 +22,7 @@
         virtual void getAttributeVector(CAttributeVector& attrubutes);
         virtual int recvIntent(CPin* pPin, CIntent* pIntent);
         virtual int onProcessData(CProcessData* pProcessData);
+        virtual int onProcessStateChanged(PROCESS_STATE state);
         virtual int getIndexerOperationModeBaseValue();
 
     public:
diff --git a/SourceCode/Bond/Servo/CEFEM.cpp b/SourceCode/Bond/Servo/CEFEM.cpp
index 33e6b29..c9f4f2e 100644
--- a/SourceCode/Bond/Servo/CEFEM.cpp
+++ b/SourceCode/Bond/Servo/CEFEM.cpp
@@ -22,7 +22,7 @@
 		m_pPort[3] = nullptr;
 		m_pAligner = nullptr;
 		m_pFliper = nullptr;
-		m_robotData.status = ROBOT_STATUS::Idle;
+		m_robotData.status = ROBOT_STATUS::Setup;
 		m_robotData.position = ROBOT_POSITION::Port1;
 		m_robotData.armState[0] = FALSE;
 		m_robotData.armState[1] = FALSE;
@@ -549,55 +549,7 @@
 				pStep->setName(szBuffer);
 				pStep->setProp("Upstream", (void*)(__int64)(i + 1));
 				pStep->setWriteSignalDev(0x0 + i);
-				if (addStep(STEP_ID_FETCHED_OUT_JOB_REPORT1 + i, pStep) != 0) {
-					delete pStep;
-				}
-			}
-		}
-
-		{
-			// Fetched Out Job Report #1~15
-			char szBuffer[256];
-			for (int i = 0; i < 15; i++) {
-				CEqReadStep* pStep = new CEqReadStep(0x5c31 + 18 * i, 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, i+1);
-				pStep->setName(szBuffer);
-				pStep->setProp("Port", (void*)(__int64)(i + 1));
-				pStep->setWriteSignalDev(0x023 + i);
-				if (addStep(STEP_ID_FETCHED_OUT_JOB_REPORT1 + i, pStep) != 0) {
-					delete pStep;
-				}
-			}
-		}
-
-		{
-			// Store Job Report #1~15
-			char szBuffer[256];
-			for (int i = 0; i < 15; i++) {
-				CEqReadStep* pStep = new CEqReadStep(0x5b23 + 18 * i, 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, i + 1);
-				pStep->setName(szBuffer);
-				pStep->setProp("Port", (void*)(__int64)(i + 1));
-				pStep->setWriteSignalDev(0x014 + i);
-				if (addStep(STEP_ID_STORE_JOB_REPORT1 + i, pStep) != 0) {
+				if (addStep(STEP_ID_RECIVE_JOB_UPS1 + i, pStep) != 0) {
 					delete pStep;
 				}
 			}
@@ -628,9 +580,10 @@
 		{
 			// Indexer Operation Mode Change
 			CEqWriteStep* pStep = new CEqWriteStep();
-			pStep->setName(STEP_EFEM_IN_OP_MODE_CHANGE);
+			pStep->setName(STEP_EQ_IN_OP_MODE_CHANGE);
 			pStep->setWriteSignalDev(0x070);
 			pStep->setDataDev(0x023);
+			pStep->setRetDataDev(0x600e, 2);
 			if (addStep(STEP_ID_IN_OP_CMD_REPLY, pStep) != 0) {
 				delete pStep;
 			}
diff --git a/SourceCode/Bond/Servo/CEqWriteStep.cpp b/SourceCode/Bond/Servo/CEqWriteStep.cpp
index 5bd1025..0546675 100644
--- a/SourceCode/Bond/Servo/CEqWriteStep.cpp
+++ b/SourceCode/Bond/Servo/CEqWriteStep.cpp
@@ -64,4 +64,13 @@
 
 		return 0;
 	}
+
+	int CEqWriteStep::onReadRetDataError()
+	{
+		if (m_onWritedBlock != nullptr) {
+			m_onWritedBlock(WREAD_RET_ERR);
+		}
+
+		return 0;
+	}
 }
diff --git a/SourceCode/Bond/Servo/CEqWriteStep.h b/SourceCode/Bond/Servo/CEqWriteStep.h
index 2ec74ba..0684a30 100644
--- a/SourceCode/Bond/Servo/CEqWriteStep.h
+++ b/SourceCode/Bond/Servo/CEqWriteStep.h
@@ -5,6 +5,7 @@
 
 #define WOK				0
 #define WTIMEOUT		-1
+#define WREAD_RET_ERR	-2
 
 namespace SERVO {
 	typedef std::function<int(int code)> ONWRITED;
@@ -23,6 +24,7 @@
 		int writeDataEx(const char* pszData, int size, ONWRITED onWritedBlock = nullptr);
 		virtual int onComplete();
 		virtual int onTimeout();
+		virtual int onReadRetDataError();
 
 	private:
 		int m_nDataDev;
diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index 473afdb..ef24f61 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -39,6 +39,7 @@
 		m_pCclink = nullptr;
 		m_nBaseAlarmId = 0;
 		m_pArm = nullptr;
+		m_processState = PROCESS_STATE::Ready;
 		InitializeCriticalSection(&m_criticalSection);
 	}
 
@@ -142,6 +143,16 @@
 		pStep->setCcLink(m_pCclink);
 		m_mapStep[addr] = pStep;
 		return 0;
+	}
+
+	void CEquipment::setProcessState(PROCESS_STATE state)
+	{
+		m_processState = state;
+		onProcessStateChanged(m_processState);
+
+		if (m_listener.onProcessStateChanged != nullptr) {
+			m_listener.onProcessStateChanged(this, m_processState);
+		}
 	}
 
 	void CEquipment::init()
@@ -394,7 +405,9 @@
 			m_bLinkSignal[i][SIGNAL_SEND_ABLE] = isBitOn(pszData, size, index + 3);
 			index += 0x40;
 		}		 
-
+		if(m_bLinkSignal[0][SIGNAL_SEND_ABLE]) {
+			onSendAble();
+		}
 
 		// 其它信号及响应
 		index = 0x540;
@@ -795,6 +808,11 @@
 		pContext->release();
 		Unlock();
 
+
+		if (m_processState != PROCESS_STATE::Ready) {
+			setProcessState(PROCESS_STATE::Ready);
+		}
+
 		if (m_listener.onDataChanged != nullptr) {
 			m_listener.onDataChanged(this, EDCC_FETCHOUT_JOB);
 		}
@@ -821,22 +839,9 @@
 		pGlass->release();				// tempFetchOut需要调用一次release
 		Unlock();
 
-
-		// 如果此玻璃已经贴合,贴合的玻璃也要从加入到列表中
-		/*
-		CGlass* pBuddy = pGlass->getBuddy();
-		if (pBuddy != nullptr) {
-			Lock();
-			pBuddy->addPath(m_nID, 0);
-			if (putSlot % 2 == 0) {
-				m_slot[putSlot - 2].setContext(pBuddy);
-			}
-			else {
-				m_slot[putSlot].setContext(pBuddy);
-			}
-			Unlock();
+		if (m_processState != PROCESS_STATE::Processing) {
+			setProcessState(PROCESS_STATE::Processing);
 		}
-		*/
 
 		if (m_listener.onDataChanged != nullptr) {
 			m_listener.onDataChanged(this, EDCC_STORED_JOB);
@@ -1007,30 +1012,34 @@
 		return 0;
 	}
 
-	int CEquipment::indexerOperationModeChange(IDNEXER_OPERATION_MODE mode, ONWRITED onWritedBlock/* = nullptr*/)
+	int CEquipment::indexerOperationModeChange(IDNEXER_OPERATION_MODE mode, ONWRITEDRET onWritedRetBlock)
 	{
-		SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(STEP_EFEM_IN_OP_MODE_CHANGE);
+		SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(STEP_EQ_IN_OP_MODE_CHANGE);
 		if (pStep == nullptr) {
 			return -1;
 		}
 
 		unsigned short operationMode = (unsigned short)((unsigned short)mode + getIndexerOperationModeBaseValue());
 		LOGI("<CEquipment-%s>准备设置indexerOperationMode<%d>", m_strName.c_str(), (int)mode);
-		if (onWritedBlock != nullptr) {
-			pStep->writeShort(operationMode, onWritedBlock);
-		}
-		else {
-			pStep->writeShort(operationMode, [&, mode](int code) -> int {
-				if (code == WOK) {
-					LOGI("<CEquipment-%s>设置indexerOperationMode成功.", m_strName.c_str());
-				}
-				else {
-					LOGI("<CEquipment-%s>设置indexerOperationMode失败,code:%d", m_strName.c_str(), code);
-				}
+		pStep->writeShort(operationMode, [&, mode](int code) -> int {
+			int retCode = 0;
+			if (code == WOK) {
+				LOGI("<CEquipment-%s>设置indexerOperationMode成功.", m_strName.c_str());
+				const char* pszRetData = nullptr;
+				pStep->getReturnData(pszRetData);
+				ASSERT(pszRetData);
+				retCode = (unsigned int)CToolUnits::toInt16(pszRetData);	
+			}
+			else {
+				LOGI("<CEquipment-%s>设置indexerOperationMode失败,code:%d", m_strName.c_str(), code);
+			}
 
-				return 0;
-				});
-		}
+			if (onWritedRetBlock != nullptr) {
+				onWritedRetBlock(code, retCode);
+			}
+
+			return 0;
+		});
 
 		return 0;
 	}
@@ -1595,6 +1604,26 @@
 		return 0;
 	}
 
+	/*
+	 * 当从CC-Link检测到设备Send Able为On时调用此函数
+	 * 可能会多次重复调用(根据扫描频率), 注意防呆
+	 */
+	int CEquipment::onSendAble()
+	{
+		LOGI("<CEquipment-%s>onSendAble.", m_strName.c_str());
+
+		if (m_processState != PROCESS_STATE::Complete) {
+			setProcessState(PROCESS_STATE::Complete);
+		}
+
+		return 0;
+	}
+
+	int CEquipment::onProcessStateChanged(PROCESS_STATE state)
+	{
+		return 0;
+	}
+
 	int CEquipment::getIndexerOperationModeBaseValue()
 	{
 		return 0;
diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index a9dfdf7..76e78b0 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -43,6 +43,7 @@
 #define SIGNAL_UPSTREAM_TROUBLE	1
 #define SIGNAL_INTERLOCK		2
 #define SIGNAL_SEND_ABLE		3
+	typedef std::function<int(int writeCode, int retCode)> ONWRITEDRET;
 
 	typedef std::function<void(void* pEiuipment, BOOL bAlive)> ONALIVE;
 	typedef std::function<void(void* pEiuipment, int code)> ONDATACHANGED;
@@ -50,6 +51,7 @@
 	typedef std::function<void(void* pEiuipment, void* pReport)> ONVCREVENTREPORT;
 	typedef std::function<BOOL(void* pEiuipment, CJobDataB* pJobDataB)> ONPREFETCHEDOUTJOB;
 	typedef std::function<BOOL(void* pEiuipment, CJobDataB* pJobDataB, short& putSlot)> ONPRESTOREDJOB;
+	typedef std::function<void(void* pEiuipment, PROCESS_STATE state)> ONPROCESSSTATE;
 	typedef struct _EquipmentListener
 	{
 		ONALIVE				onAlive;
@@ -59,6 +61,7 @@
 		ONVCREVENTREPORT	onVcrEventReport;
 		ONPREFETCHEDOUTJOB	onPreFethedOutJob;
 		ONPRESTOREDJOB		onPreStoredJob;
+		ONPROCESSSTATE		onProcessStateChanged;
 	} EquipmentListener;
 
 
@@ -119,6 +122,8 @@
 		virtual BOOL onPreStoredJob(int port, CJobDataB* pJobDataB, short& putSlot);
 		virtual int onStoredJob(int port, CJobDataB* pJobDataB);
 		virtual int onProcessData(CProcessData* pProcessData);
+		virtual int onSendAble();
+		virtual int onProcessStateChanged(PROCESS_STATE state);
 		virtual int getIndexerOperationModeBaseValue();
 		bool isAlarmStep(SERVO::CStep* pStep);
 		bool isVcrEventStep(SERVO::CStep* pStep);
@@ -136,7 +141,7 @@
 		int clearCimMessage(short id, short nTouchPanelNo);
 		int setDateTime(short year, short month, short day, short hour, short minute, short second);
 		int setDispatchingMode(DISPATCHING_MODE mode, ONWRITED onWritedBlock = nullptr);
-		int indexerOperationModeChange(IDNEXER_OPERATION_MODE mode, ONWRITED onWritedBlock = nullptr);
+		int indexerOperationModeChange(IDNEXER_OPERATION_MODE mode, ONWRITEDRET onWritedRetBlock);
 
 
 
@@ -225,6 +230,7 @@
 		int removeJobDataS(int nCassetteSequenceNo, int nJobSequenceNo);
 		CJobDataS* getJobDataS(int nCassetteSequenceNo, int nJobSequenceNo);
 		BOOL compareJobDataB(CJobDataB* pJobDataB1, CJobDataB* pJobDataB2);
+		void setProcessState(PROCESS_STATE state);
 
 	protected:
 		EquipmentListener m_listener;
@@ -256,6 +262,7 @@
 		int m_nBaseAlarmId;
 		CRecipesManager m_recipesManager;
 		CSlot m_slot[SLOT_MAX];
+		PROCESS_STATE m_processState;
 
 	private:
 		CEquipment* m_pArm;
diff --git a/SourceCode/Bond/Servo/CLoadPort.cpp b/SourceCode/Bond/Servo/CLoadPort.cpp
index bafeca1..81361bc 100644
--- a/SourceCode/Bond/Servo/CLoadPort.cpp
+++ b/SourceCode/Bond/Servo/CLoadPort.cpp
@@ -57,30 +57,12 @@
 	// 必须要实现的虚函数,在此初始化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");
+		for (int i = 0; i < SLOT_MAX; i++) {
+			m_slot[i].enable();
+			m_slot[i].setPosition(m_nID);
+			m_slot[i].setNo(i + 1);
+			m_slot[i].setName((std::string("Slot") + std::to_string(i+1)).c_str());
+		}
 	}
 
 	void CLoadPort::initSteps()
@@ -363,6 +345,50 @@
 				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;
 			}
 		}
 	}
@@ -838,6 +864,8 @@
 
 	void CLoadPort::onReceiveLBData(const char* pszData, size_t size)
 	{
+		__super::onReceiveLBData(pszData, 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,
@@ -1128,7 +1156,7 @@
 
 		char szBuffer[64];
 		int suffix = startSuffix;
-		for (int i = 0; i < SLOT_MAX; i++) {
+		for (int i = 0; i < 1; i++) {
 			if (!m_slot[i].isEnable()) continue;
 
 			CJobDataB jb;
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index 96ad405..a751764 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -613,17 +613,6 @@
 
 			// 读标志位
 			for (auto item : m_listEquipment) {
-				//if (item->getID() == EQ_ID_Bonder1 ||
-				//	item->getID() == EQ_ID_Bonder2) {
-				//	const StationIdentifier& station = item->getStation();
-				//	MemoryBlock& block = item->getReadBitBlock();
-
-				//	int nRet = m_cclink.ReadData2(station, (DeviceType)block.type,
-				//		block.start, block.size, block.buffer);
-				//	if (0 == nRet) {
-				//		item->onReceiveLBData(block.buffer, block.size);
-				//	}
-				//}
 				const StationIdentifier& station = item->getStation();
 				MemoryBlock& block = item->getReadBitBlock();
 
@@ -788,7 +777,9 @@
 				unlock();
 			}
 		};
-
+		listener.onProcessStateChanged = [&](void* pEquipment, PROCESS_STATE state) -> void {
+			LOGI("<Master>onProcessStateChanged<%d>", (int)state);
+		};
 		pEquipment->setListener(listener);
 		pEquipment->setCcLink(&m_cclink);
 		m_listEquipment.push_back(pEquipment);
diff --git a/SourceCode/Bond/Servo/CMeasurement.cpp b/SourceCode/Bond/Servo/CMeasurement.cpp
index a20066f..46478f0 100644
--- a/SourceCode/Bond/Servo/CMeasurement.cpp
+++ b/SourceCode/Bond/Servo/CMeasurement.cpp
@@ -239,7 +239,7 @@
 		{
 			// Received Job Report Upstream #1~9
 			char szBuffer[256];
-			for (int i = 0; i < 9; i++) {
+			for (int i = 0; i < 1; i++) {
 				CEqReadStep* pStep = new CEqReadStep(0x18c90 + 320 * i, 320 * 2,
 					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 						if (code == ROK && pszData != nullptr && size > 0) {
@@ -263,7 +263,7 @@
 		{
 			// Sent Out Job Report Downstream #1~9
 			char szBuffer[256];
-			for (int i = 0; i < 9; i++) {
+			for (int i = 0; i < 1; i++) {
 				CEqReadStep* pStep = new CEqReadStep(0x18000 + 320 * i, 320 * 2,
 					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 						if (code == ROK && pszData != nullptr && size > 0) {
@@ -287,7 +287,7 @@
 		{
 			// Fetched Out Job Report #1~15
 			char szBuffer[256];
-			for (int i = 0; i < 15; i++) {
+			for (int i = 0; i < 1; i++) {
 				CEqReadStep* pStep = new CEqReadStep(0x19c31 + 18 * i, 18 * 2,
 					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 						if (code == ROK && pszData != nullptr && size > 0) {
@@ -311,7 +311,7 @@
 		{
 			// Stored Job Report #1~15
 			char szBuffer[256];
-			for (int i = 0; i < 15; i++) {
+			for (int i = 0; i < 1; i++) {
 				CEqReadStep* pStep = new CEqReadStep(0x19b23 + 18 * i, 18 * 2,
 					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 						if (code == ROK && pszData != nullptr && size > 0) {
diff --git a/SourceCode/Bond/Servo/CPageGraph2.cpp b/SourceCode/Bond/Servo/CPageGraph2.cpp
index 45a272b..08dae61 100644
--- a/SourceCode/Bond/Servo/CPageGraph2.cpp
+++ b/SourceCode/Bond/Servo/CPageGraph2.cpp
@@ -212,17 +212,18 @@
 		else if (nCmd == ID_EQSGRAPHITEM_TEST1) {
 			BOOL bTestGenerate = FALSE;
 			SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
-			if (pEquipment->getID() == EQ_ID_LOADPORT1 && !pEquipment->hasGlass()) {
+			if (pEquipment->getID() == EQ_ID_LOADPORT4 && !pEquipment->hasGlass()) {
 				((SERVO::CLoadPort*)pEquipment)->testGenerateGlassList(SERVO::MaterialsType::G1, 
 					"P20250320G1X", 1);
 				bTestGenerate = TRUE;
 			}
+			/*
 			else if (pEquipment->getID() == EQ_ID_LOADPORT2 && !pEquipment->hasGlass()) {
 				((SERVO::CLoadPort*)pEquipment)->testGenerateGlassList(SERVO::MaterialsType::G2,
 					"P20250320G2X", 1);
 				bTestGenerate = TRUE;
 			}
-			
+			*/
 			if (!bTestGenerate) {
 				SERVO::CRobotTask* pTask = theApp.m_model.getMaster().getActiveRobotTask();
 				if (pTask != nullptr) {
diff --git a/SourceCode/Bond/Servo/CRobotCmdTestDlg.cpp b/SourceCode/Bond/Servo/CRobotCmdTestDlg.cpp
index 5c92b59..f8da27b 100644
--- a/SourceCode/Bond/Servo/CRobotCmdTestDlg.cpp
+++ b/SourceCode/Bond/Servo/CRobotCmdTestDlg.cpp
@@ -270,6 +270,8 @@
 
 void CRobotCmdTestDlg::AppendLogLineRichStyled(const CString& content, COLORREF color /*= RGB(0, 0, 0)*/)
 {
+	if (!::IsWindow(GetSafeHwnd())) return;
+
 	// 鏃堕棿鎴�
 	CString timestamp;
 	CTime now = CTime::GetCurrentTime();
diff --git a/SourceCode/Bond/Servo/CRobotTask.cpp b/SourceCode/Bond/Servo/CRobotTask.cpp
index ed82d43..5b4fbab 100644
--- a/SourceCode/Bond/Servo/CRobotTask.cpp
+++ b/SourceCode/Bond/Servo/CRobotTask.cpp
@@ -227,7 +227,7 @@
 		ASSERT(m_pEFEM);
 		m_state = ROBOT_TASK_STATE::Picking;
 
-		m_pEFEM->robotSendMoveToGet(m_robotCmdParam->sequenceNo,
+		m_pEFEM->robotSendGet(m_robotCmdParam->sequenceNo,
 			m_robotCmdParam[ACTION_PICK].armNo,
 			m_robotCmdParam[ACTION_PICK].getPosition,
 			m_robotCmdParam[ACTION_PICK].getSlotNo,
diff --git a/SourceCode/Bond/Servo/CVacuumBake.cpp b/SourceCode/Bond/Servo/CVacuumBake.cpp
index b011df5..0dec6ba 100644
--- a/SourceCode/Bond/Servo/CVacuumBake.cpp
+++ b/SourceCode/Bond/Servo/CVacuumBake.cpp
@@ -239,7 +239,7 @@
 		{
 			// Received Job Report Upstream #1~9
 			char szBuffer[256];
-			for (int i = 0; i < 9; i++) {
+			for (int i = 0; i < 1; i++) {
 				CEqReadStep* pStep = new CEqReadStep(0x14c90 + 320 * i, 320 * 2,
 					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 						if (code == ROK && pszData != nullptr && size > 0) {
@@ -263,7 +263,7 @@
 		{
 			// Sent Out Job Report Downstream #1~9
 			char szBuffer[256];
-			for (int i = 0; i < 9; i++) {
+			for (int i = 0; i < 1; i++) {
 				CEqReadStep* pStep = new CEqReadStep(0x14000 + 320 * i, 320 * 2,
 					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 						if (code == ROK && pszData != nullptr && size > 0) {
@@ -287,7 +287,7 @@
 		{
 			// Fetched Out Job Report #1~15
 			char szBuffer[256];
-			for (int i = 0; i < 15; i++) {
+			for (int i = 0; i < 1; i++) {
 				CEqReadStep* pStep = new CEqReadStep(0x15c31 + 18 * i, 18 * 2,
 					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 						if (code == ROK && pszData != nullptr && size > 0) {
@@ -311,7 +311,7 @@
 		{
 			// Stored Job Report #1~15
 			char szBuffer[256];
-			for (int i = 0; i < 15; i++) {
+			for (int i = 0; i < 1; i++) {
 				CEqReadStep* pStep = new CEqReadStep(0x15b23 + 18 * i, 18 * 2,
 					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 						if (code == ROK && pszData != nullptr && size > 0) {
diff --git a/SourceCode/Bond/Servo/CWriteStep.cpp b/SourceCode/Bond/Servo/CWriteStep.cpp
index 0470421..2e79b5a 100644
--- a/SourceCode/Bond/Servo/CWriteStep.cpp
+++ b/SourceCode/Bond/Servo/CWriteStep.cpp
@@ -55,6 +55,18 @@
 		m_nWriteSignalDev = dev;
 	}
 
+	void CWriteStep::setRetDataDev(int dev, int size)
+	{
+		m_nReturnDevNo = dev;
+		m_nReturnDataSize = size;
+	}
+
+	int CWriteStep::getReturnData(const char*& pszData)
+	{
+		pszData = m_szReturnBuf;
+		return m_nReturnDataSize;
+	}
+
 	void CWriteStep::onRecvSignal(BOOL bSignal)
 	{
 		Lock();
@@ -111,6 +123,18 @@
 					goto RESET;
 				}
 				ResetEvent(m_hRecvSignalOn);
+
+
+				// 3.9读数据,如果有
+				if (m_nReturnDataSize > 0) {
+					int nRet = m_pCclink->ReadData2(m_station, DeviceType::W, m_nReturnDevNo,
+						(long)min(READ_BUFFER_MAX, m_nReturnDataSize), m_szReturnBuf);
+					if (0 != nRet) {
+						LOGI("<CEqReadStep>Read return data error.");
+						onReadRetDataError();
+						return -1;
+					}
+				}
 
 
 				// 4.写OFF
@@ -196,4 +220,9 @@
 	{
 		return 0;
 	}
+
+	int CWriteStep::onReadRetDataError()
+	{
+		return 0;
+	}
 }
diff --git a/SourceCode/Bond/Servo/CWriteStep.h b/SourceCode/Bond/Servo/CWriteStep.h
index 6bb6b30..e8e66cf 100644
--- a/SourceCode/Bond/Servo/CWriteStep.h
+++ b/SourceCode/Bond/Servo/CWriteStep.h
@@ -19,8 +19,14 @@
 		virtual void getAttributeVector(CAttributeVector& attrubutes);
 		virtual int onComplete();
 		virtual int onTimeout();
+		virtual int onReadRetDataError();
 		inline void nextStep();
 		inline void resetStep();
+		virtual void setRetDataDev(int dev, int size);
+
+	public:
+		int getReturnData(const char*& pszData);
+
 
 	protected:
 		HANDLE m_hWorkThreadHandle;
@@ -33,6 +39,12 @@
 		char m_szBuffer[1024];
 		int m_nWriteDataSize;
 		int m_nWriteDevNo;
+
+	protected:
+		// return code or data
+		char m_szReturnBuf[1024];
+		int m_nReturnDataSize;
+		int m_nReturnDevNo;
 	};
 }
 
diff --git a/SourceCode/Bond/Servo/Common.h b/SourceCode/Bond/Servo/Common.h
index a3296d6..3a3055d 100644
--- a/SourceCode/Bond/Servo/Common.h
+++ b/SourceCode/Bond/Servo/Common.h
@@ -218,7 +218,7 @@
 #define STEP_EQ_STORED_JOB15			_T("EQStoredJobReport15")
 #define STEP_EQ_DISPATCHINT_MODE_CHANGE	_T("EQDispatchingModeChangeCommand")
 #define STEP_EFEM_ROBOT_CMD				_T("EFEMRobotCmd")
-#define STEP_EFEM_IN_OP_MODE_CHANGE		_T("EFEMIndexerOperationModeChangeCommand")
+#define STEP_EQ_IN_OP_MODE_CHANGE		_T("EQIndexerOperationModeChangeCommand")
 #define STEP_PORT1_TYPE_CHANGE			_T("Port1TypeChange")
 #define STEP_PORT2_TYPE_CHANGE			_T("Port2TypeChange")
 #define STEP_PORT3_TYPE_CHANGE			_T("Port3TypeChange")
diff --git a/SourceCode/Bond/Servo/ServoCommo.h b/SourceCode/Bond/Servo/ServoCommo.h
index aa02acc..20e4434 100644
--- a/SourceCode/Bond/Servo/ServoCommo.h
+++ b/SourceCode/Bond/Servo/ServoCommo.h
@@ -149,6 +149,13 @@
 		BOOL armState[2];
 	} ROBOT_MONITORING_DATA, RMDATA;
 
+	/* 工艺(加工处理)状态 */
+	enum class PROCESS_STATE {
+		Ready = 0,
+		Processing,
+		Complete,
+		Error
+	};
 
 	/* EQ Data changed code */
 #define EDCC_FETCHOUT_JOB				1000	/* 取片 */

--
Gitblit v1.9.3