From ec2b63378e47ac0aba4e0265b63a5cd26e373a32 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 26 五月 2025 18:02:57 +0800
Subject: [PATCH] 1.添加了状态栏;

---
 SourceCode/Bond/Servo/CLoadPort.cpp |  993 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 977 insertions(+), 16 deletions(-)

diff --git a/SourceCode/Bond/Servo/CLoadPort.cpp b/SourceCode/Bond/Servo/CLoadPort.cpp
index f736ee1..1c7becf 100644
--- a/SourceCode/Bond/Servo/CLoadPort.cpp
+++ b/SourceCode/Bond/Servo/CLoadPort.cpp
@@ -1,11 +1,27 @@
 #include "stdafx.h"
 #include "CLoadPort.h"
+#include "CGlassPool.h"
+#include "Servo.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_nIndex = 0;
+		m_nType = 1;
+		m_nMode = 1;
+		m_nCassetteType = 1;
+		m_nTransferMode = 1;
+		m_bEnable = FALSE;
+		m_bAutoChangeEnable = FALSE;
 	}
 
 	CLoadPort::~CLoadPort()
@@ -39,6 +55,290 @@
 		addPin(SERVO::PinType::OUTPUT, _T("Out2"));
 	}
 
+	void CLoadPort::initSteps()
+	{
+		CEquipment::initSteps();
+
+
+		ASSERT(m_nIndex == 0 || m_nIndex == 1 || m_nIndex == 2 || m_nIndex == 3);
+
+		{
+			// 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 int dev[] = { 0x45, 0x1a5, 0x305, 0x465 };
+			static int addr[] = { 0x480, 0x481, 0x482, 0x483 };
+
+			CEqCassetteCtrlCmdStep* pStep = new CEqCassetteCtrlCmdStep();
+			pStep->setName(pszName[m_nIndex]);
+			pStep->setWriteSignalDev(writeSignalDev[m_nIndex]);
+			pStep->setCtrlCmdDev(dev[m_nIndex]);
+			if (addStep(addr[m_nIndex], pStep) != 0) {
+				delete pStep;
+			}
+		}
+
+		{
+			// Type
+			static char* pszName[] = { STEP_EQ_PORT1_TYPE, STEP_EQ_PORT2_TYPE, STEP_EQ_PORT3_TYPE, STEP_EQ_PORT4_TYPE };
+			static int dev[] = { 0x6010 , 0x6020, 0x6030, 0x6040 };
+			static int writeSignalDev[] = { 0xa0, 0xa1, 0xa2, 0xa3 };
+			static int addr[] = { STEP_ID_PORT1_TYPE_CHANGE, STEP_ID_PORT2_TYPE_CHANGE, STEP_ID_PORT3_TYPE_CHANGE, STEP_ID_PORT4_TYPE_CHANGE };
+
+			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);
+					}
+					return 0;
+				});
+			pStep->setName(pszName[m_nIndex]);
+			pStep->setWriteSignalDev(writeSignalDev[m_nIndex]);
+			if (addStep(addr[m_nIndex], pStep) != 0) {
+				delete pStep;
+			}
+		}
+
+		{
+			// Mode
+			static char* pszName[] = { STEP_EQ_PORT1_MODE, STEP_EQ_PORT2_MODE, STEP_EQ_PORT3_MODE, STEP_EQ_PORT4_MODE };
+			static int dev[] = { 0x6011, 0x6021, 0x6031, 0x6041 };
+			static int writeSignalDev[] = { 0xa8, 0xa9, 0xaa, 0xab };
+			static int addr[] = { STEP_ID_PORT1_MODE_CHANGE, STEP_ID_PORT2_MODE_CHANGE, STEP_ID_PORT3_MODE_CHANGE, STEP_ID_PORT4_MODE_CHANGE };
+
+			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);
+					}
+					return 0;
+				});
+			pStep->setName(pszName[m_nIndex]);
+			pStep->setWriteSignalDev(writeSignalDev[m_nIndex]);
+			if (addStep(addr[m_nIndex], pStep) != 0) {
+				delete pStep;
+			}
+		}
+
+		{
+			// Cassette type
+			static char* pszName[] = { STEP_EQ_PORT1_CASSETTE_TYPE, STEP_EQ_PORT2_CASSETTE_TYPE, STEP_EQ_PORT3_CASSETTE_TYPE, STEP_EQ_PORT4_CASSETTE_TYPE };
+			static int dev[] = { 0x6012, 0x6022, 0x6032, 0x6042 };
+			static int writeSignalDev[] = { 0xb0, 0xb1, 0xb2, 0xb3 };
+			static int addr[] = { STEP_ID_PORT1_CASSETTE_TYPE_CHANGE, STEP_ID_PORT2_CASSETTE_TYPE_CHANGE, STEP_ID_PORT3_CASSETTE_TYPE_CHANGE, STEP_ID_PORT4_CASSETTE_TYPE_CHANGE };
+
+			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);
+					}
+					return 0;
+				});
+			pStep->setName(pszName[m_nIndex]);
+			pStep->setWriteSignalDev(writeSignalDev[m_nIndex]);
+			if (addStep(addr[m_nIndex], pStep) != 0) {
+				delete pStep;
+			}
+		}
+
+		{
+			// Transfer type
+			static char* pszName[] = { STEP_EQ_PORT1_TRANSFER_MODE, STEP_EQ_PORT2_TRANSFER_MODE, STEP_EQ_PORT3_TRANSFER_MODE, STEP_EQ_PORT4_TRANSFER_MODE };
+			static int dev[] = { 0x6014, 0x6024, 0x6034, 0x6044 };
+			static int writeSignalDev[] = { 0xb8, 0xb9, 0xba, 0xbb };
+			static int addr[] = { STEP_ID_PORT1_TRANSFER_MODE_CHANGE, STEP_ID_PORT2_TRANSFER_MODE_CHANGE, STEP_ID_PORT3_TRANSFER_MODE_CHANGE, STEP_ID_PORT4_TRANSFER_MODE_CHANGE };
+
+			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);
+					}
+					return 0;
+				});
+			pStep->setName(pszName[m_nIndex]);
+			pStep->setWriteSignalDev(writeSignalDev[m_nIndex]);
+			if (addStep(addr[m_nIndex], pStep) != 0) {
+				delete pStep;
+			}
+		}
+
+		{
+			// Port enable
+			static char* pszName[] = { STEP_EQ_PORT1_ENABLE, STEP_EQ_PORT2_ENABLE, STEP_EQ_PORT3_ENABLE, STEP_EQ_PORT4_ENABLE };
+			static int dev[] = { 0x6015, 0x6025, 0x6035, 0x6045 };
+			static int writeSignalDev[] = { 0xc0, 0xc1, 0xc2, 0xc3 };
+			static int addr[] = { STEP_ID_PORT1_ENABLE_MODE_CHANGE, STEP_ID_PORT2_ENABLE_MODE_CHANGE, STEP_ID_PORT3_ENABLE_MODE_CHANGE, STEP_ID_PORT4_ENABLE_MODE_CHANGE };
+
+			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_bEnable = (unsigned int)CToolUnits::toInt16(pszData) == 1;
+					}
+					return 0;
+				});
+			pStep->setName(pszName[m_nIndex]);
+			pStep->setWriteSignalDev(writeSignalDev[m_nIndex]);
+			if (addStep(addr[m_nIndex], pStep) != 0) {
+				delete pStep;
+			}
+		}
+
+		{
+			// Type auto change
+			char* pszName[] = { STEP_EQ_PORT1_TYPE_ATUO, STEP_EQ_PORT2_TYPE_ATUO, STEP_EQ_PORT3_TYPE_ATUO, STEP_EQ_PORT4_TYPE_ATUO };
+			static int dev[] = { 0x6016, 0x6026, 0x6036, 0x6046 };
+			static int writeSignalDev[] = { 0xc8, 0xc9, 0xca, 0xcb };
+			static int addr[] = { STEP_ID_PORT1_TYPE_AUTO_CHANGE, STEP_ID_PORT2_TYPE_AUTO_CHANGE, STEP_ID_PORT3_TYPE_AUTO_CHANGE, STEP_ID_PORT4_TYPE_AUTO_CHANGE };
+
+			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_bAutoChangeEnable = (unsigned int)CToolUnits::toInt16(pszData) == 1;
+					}
+					return 0;
+				});
+			pStep->setName(pszName[m_nIndex]);
+			pStep->setWriteSignalDev(writeSignalDev[m_nIndex]);
+			if (addStep(addr[m_nIndex], pStep) != 0) {
+				delete pStep;
+			}
+		}
+
+		{
+			// port command
+			// Port Type Change Command
+			static char* pszName[] = { STEP_PORT1_TYPE_CHANGE, STEP_PORT2_TYPE_CHANGE, STEP_PORT3_TYPE_CHANGE, STEP_PORT4_TYPE_CHANGE };
+			static int dev[] = { 0x024, 0x02c, 0x034, 0x03c };
+
+			CEqWriteStep* pStep = new CEqWriteStep();
+			pStep->setName(pszName[m_nIndex]);
+			pStep->setWriteSignalDev(0x100 + m_nIndex);
+			pStep->setDataDev(dev[m_nIndex]);
+			if (addStep(STEP_ID_PROT1_TYPE_CHANGE_REPLY + m_nIndex, pStep) != 0) {
+				delete pStep;
+			}
+		}
+
+		{
+			// port command
+			// Port Mode Change Command
+			static char* pszName[] = { STEP_PORT1_MODE_CHANGE, STEP_PORT2_MODE_CHANGE, STEP_PORT3_MODE_CHANGE, STEP_PORT4_MODE_CHANGE };
+			static int dev[] = { 0x025, 0x02d, 0x035, 0x03d };
+
+			CEqWriteStep* pStep = new CEqWriteStep();
+			pStep->setName(pszName[m_nIndex]);
+			pStep->setWriteSignalDev(0x108 + m_nIndex);
+			pStep->setDataDev(dev[m_nIndex]);
+			if (addStep(STEP_ID_PROT1_MODE_CHANGE_REPLY + m_nIndex, pStep) != 0) {
+				delete pStep;
+			}
+		}
+
+		{
+			// port command
+			// Port Transfer Mode Change Command
+			static char* pszName[] = { STEP_PORT1_TRANSFER_MODE_CHANGE, STEP_PORT2_TRANSFER_MODE_CHANGE, STEP_PORT3_TRANSFER_MODE_CHANGE, STEP_PORT4_TRANSFER_MODE_CHANGE };
+			static int dev[] = { 0x028, 0x030, 0x038, 0x040 };
+
+			CEqWriteStep* pStep = new CEqWriteStep();
+			pStep->setName(pszName[m_nIndex]);
+			pStep->setWriteSignalDev(0x110 + m_nIndex);
+			pStep->setDataDev(dev[m_nIndex]);
+			if (addStep(STEP_ID_PROT1_TRANSFER_MODE_CHANGE_REPLY + m_nIndex, pStep) != 0) {
+				delete pStep;
+			}
+		}
+
+		{
+			// port command
+			// Port Enable Mode Change Command
+			static char* pszName[] = { STEP_PORT1_ENABLE_MODE_CHANGE, STEP_PORT2_ENABLE_MODE_CHANGE, STEP_PORT3_ENABLE_MODE_CHANGE, STEP_PORT4_ENABLE_MODE_CHANGE };
+			static int dev[] = { 0x029, 0x031, 0x039, 0x041 };
+
+			CEqWriteStep* pStep = new CEqWriteStep();
+			pStep->setName(pszName[m_nIndex]);
+			pStep->setWriteSignalDev(0x118 + m_nIndex);
+			pStep->setDataDev(dev[m_nIndex]);
+			if (addStep(STEP_ID_PROT1_ENABLE_MODE_CHANGE_REPLY + m_nIndex, pStep) != 0) {
+				delete pStep;
+			}
+		}
+
+		{
+			// port command
+			// Port Type Auto Change Command
+			static char* pszName[] = { STEP_PORT1_TYPE_AUTO_CHANGE, STEP_PORT2_TYPE_AUTO_CHANGE, STEP_PORT3_TYPE_AUTO_CHANGE, STEP_PORT4_TYPE_AUTO_CHANGE };
+			static int dev[] = { 0x02A, 0x032, 0x03A, 0x042 };
+
+			CEqWriteStep* pStep = new CEqWriteStep();
+			pStep->setName(pszName[m_nIndex]);
+			pStep->setWriteSignalDev(0x120 + m_nIndex);
+			pStep->setDataDev(dev[m_nIndex]);
+			if (addStep(STEP_ID_PROT1_TYPE_AUTO_CHANGE_REPLY + m_nIndex, pStep) != 0) {
+				delete pStep;
+			}
+		}
+
+		{
+			// port command
+			// Port Cassette Type Change Command
+			static char* pszName[] = { STEP_PORT1_CASSETTE_TYPE_CHANGE, STEP_PORT2_CASSETTE_TYPE_CHANGE, STEP_PORT3_CASSETTE_TYPE_CHANGE, STEP_PORT4_CASSETTE_TYPE_CHANGE };
+			static int dev[] = { 0x026, 0x02E, 0x036, 0x03E };
+
+			CEqWriteStep* pStep = new CEqWriteStep();
+			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) {
+				delete pStep;
+			}
+		}
+
+		{
+			char* pszName[6][4] = { 
+				{STEP_EQ_PORT1_EMPTY, STEP_EQ_PORT2_EMPTY, STEP_EQ_PORT3_EMPTY, STEP_EQ_PORT4_EMPTY},
+				{STEP_EQ_PORT1_LOAD_EADY, STEP_EQ_PORT2_LOAD_EADY, STEP_EQ_PORT3_LOAD_EADY, STEP_EQ_PORT4_LOAD_EADY},
+				{STEP_EQ_PORT1_LOADED, STEP_EQ_PORT2_LOADED, STEP_EQ_PORT3_LOADED, STEP_EQ_PORT4_LOADED},
+				{STEP_EQ_PORT1_INUSE, STEP_EQ_PORT2_INUSE, STEP_EQ_PORT3_INUSE, STEP_EQ_PORT4_INUSE},
+				{STEP_EQ_PORT1_UNLOAD_EADY, STEP_EQ_PORT2_UNLOAD_EADY, STEP_EQ_PORT3_UNLOAD_EADY, STEP_EQ_PORT4_UNLOAD_EADY},
+				{STEP_EQ_PORT1_BLOCKED, STEP_EQ_PORT2_BLOCKED, STEP_EQ_PORT3_BLOCKED, STEP_EQ_PORT4_BLOCKED}
+			};
+			static int dev[] = { 0x6050, 0x6070, 0x6090, 0x60b0 };
+			static int writeSignalDev[6][4] = {
+				{0xd8, 0xd9, 0xda, 0xdb},
+				{0xe0, 0xe1, 0xe2, 0xe3},
+				{0xe8, 0xe9, 0xea, 0xeb},
+				{0xf0, 0xf1, 0xf2, 0xf3},
+				{0xf8, 0xf9, 0xfa, 0xfb},
+				{0x100, 0x101, 0x102, 0x103}
+			};
+			static int addr[6][4] = {
+				{ STEP_ID_PORT1_EMPTY, STEP_ID_PORT2_EMPTY, STEP_ID_PORT3_EMPTY, STEP_ID_PORT4_EMPTY },
+				{ STEP_ID_PORT1_LOAD_READY, STEP_ID_PORT2_LOAD_READY, STEP_ID_PORT3_LOAD_READY, STEP_ID_PORT4_LOAD_READY },
+				{ STEP_ID_PORT1_LOADED, STEP_ID_PORT2_LOADED, STEP_ID_PORT3_LOADED, STEP_ID_PORT4_LOADED },
+				{ STEP_ID_PORT1_INUSE, STEP_ID_PORT2_INUSE, STEP_ID_PORT3_INUSE, STEP_ID_PORT4_INUSE },
+				{ STEP_ID_PORT1_UNLOAD_READY, STEP_ID_PORT2_UNLOAD_READY, STEP_ID_PORT3_UNLOAD_READY, STEP_ID_PORT4_UNLOAD_READY },
+				{ STEP_ID_PORT1_BLOCKED, STEP_ID_PORT2_BLOCKED, STEP_ID_PORT3_BLOCKED, STEP_ID_PORT4_BLOCKED },
+			};
+
+			for (int i = 0; i < 6; i++) {
+				CEqReadStep* pStep = new CEqReadStep(dev[m_nIndex], 32 * 2,
+					[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
+						if (code == ROK && pszData != nullptr && size > 0) {
+							decodePortStatusReport((CStep*)pFrom, pszData, size);
+						}
+						return -1;
+					});
+				pStep->setName(pszName[i][m_nIndex]);
+				pStep->setProp("Port", (void*)(__int64)(m_nIndex + 1));
+				pStep->setWriteSignalDev(writeSignalDev[i][m_nIndex]);
+				if (addStep(addr[i][m_nIndex], pStep) != 0) {
+					delete pStep;
+				}
+			}
+		}
+	}
+
 	void CLoadPort::onTimer(UINT nTimerid)
 	{
 		CEquipment::onTimer(nTimerid);
@@ -52,6 +352,23 @@
 	void CLoadPort::getAttributeVector(CAttributeVector& attrubutes)
 	{
 		__super::getAttributeVector(attrubutes);
+
+		unsigned int weight = 101;
+		std::string strTemp;
+		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++));
+		attrubutes.addAttribute(new CAttribute("Mode",
+			getPortModeDescription(m_nMode, strTemp).c_str(), "", weight++));
+		attrubutes.addAttribute(new CAttribute("CassetteType",
+			getPortCassetteTypeDescription(m_nCassetteType, strTemp).c_str(), "", weight++));
+		attrubutes.addAttribute(new CAttribute("TransferMode",
+			getPortTransferModeDescription(m_nTransferMode, strTemp).c_str(), "", weight++));
+		attrubutes.addAttribute(new CAttribute("Enable",
+			m_bEnable ? "Eanble" : "Disable", "", weight++));
+		attrubutes.addAttribute(new CAttribute("Auto Change",
+			m_bAutoChangeEnable ? "Eanble" : "Disable", "", weight++));
 	}
 
 	int CLoadPort::recvIntent(CPin* pPin, CIntent* pIntent)
@@ -61,19 +378,6 @@
 
 	int CLoadPort::outputGlass(int port)
 	{
-		// 如果列表中没有Panel,模拟生成10张
-		if (m_glassList.empty()) {
-			static int ii = 0;
-			char szBuffer[64];
-			LOGI("<CLoadPort>模拟生成10张PANEL");
-			for (int i = 0; i < 10; i++) {
-				sprintf_s(szBuffer, "P20250320A1A%d", ++ii);
-				CGlass* pGlass = new CGlass();
-				pGlass->setID(szBuffer);
-				addGlassToList(pGlass);
-			}
-		}
-
 		return __super::outputGlass(port);
 	}
 
@@ -92,7 +396,7 @@
 		int jobExistenceSize,
 		short slotProcess,
 		short jopCount,
-		CJobDataB* pJobDataB)
+		CJobDataA* pJobDataA)
 	{
 		int id = getID();
 		if ( !(id == EQ_ID_LOADPORT1 || id == EQ_ID_LOADPORT2) ) {
@@ -102,7 +406,7 @@
 
 		SERVO::CEqCassetteCtrlCmdStep* pStep = (SERVO::CEqCassetteCtrlCmdStep*)getCassetteCtrlCmdStep();
 		ASSERT(pStep);
-		return pStep->sendCtrlCmd(cmd, jobExistence, jobExistenceSize, slotProcess, jopCount, pJobDataB);
+		return pStep->sendCtrlCmd(cmd, jobExistence, jobExistenceSize, slotProcess, jopCount, pJobDataA);
 	}
 
 	CStep* CLoadPort::getCassetteCtrlCmdStep()
@@ -121,4 +425,661 @@
 
 		return pStep;
 	}
+
+	void CLoadPort::setIndex(unsigned int index)
+	{
+		m_nIndex = index;
+	}
+
+	unsigned int CLoadPort::getIndex()
+	{
+		return m_nIndex;
+	}
+
+	BOOL CLoadPort::isEnable()
+	{
+		return m_bEnable;
+	}
+
+	int CLoadPort::getPortType()
+	{
+		return m_nType;
+	}
+
+	int CLoadPort::getPortMode()
+	{
+		return m_nMode;
+	}
+
+	int CLoadPort::getCessetteType()
+	{
+		return m_nCassetteType;
+	}
+
+	int CLoadPort::getTransferMode()
+	{
+		return m_nTransferMode;
+	}
+
+	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();
+	}
+
+	/*
+	 1: Loading Port
+	 2: Unloading Port
+	 3: Both Port
+	 4: Buffer Port-Buffer Type
+	 5: Buffer Port-Loader in Buffer Type
+	 6: Buffer Port-Un-loader in Buffer Type
+	 7: Unloading Partial Port
+	 */
+	std::string& CLoadPort::getPortTypeDescription(int portType, std::string& strDescription)
+	{
+		switch (portType) {
+		case 1:
+			strDescription = _T("Loading Port");
+			break;
+		case 2:
+			strDescription = _T("Unloading Port");
+			break;
+		case 3:
+			strDescription = _T("Both Port");
+			break;
+		case 4:
+			strDescription = _T("Buffer Port - Buffer Type");
+			break;
+		case 5:
+			strDescription = _T("Buffer Port - Loader in Buffer Type");
+			break;
+		case 6:
+			strDescription = _T("Buffer Port - Un-loader in Buffer Type");
+			break;
+		case 7:
+			strDescription = _T("Unloading Partial Port");
+			break;
+		default:
+			strDescription = _T("");
+			break;
+		}
+
+		return strDescription;
+	}
+
+	/*
+	 0: OutOfService
+	 1: TransferBlocked
+	 2: ReadyToLoad
+	 3: ReadyToUnload
+	 4: InService
+	 5: TransferReady
+	 */
+	std::string& CLoadPort::getPortModeDescription(int portMode, std::string& strDescription)
+	{
+		switch (portMode) {
+		case 0:
+			strDescription = _T("OutOfService");
+			break;
+		case 1:
+			strDescription = _T("TransferBlocked");
+			break;
+		case 2:
+			strDescription = _T("ReadyToLoad");
+			break;
+		case 3:
+			strDescription = _T("ReadyToUnload");
+			break;
+		case 4:
+			strDescription = _T("InService");
+			break;
+		case 5:
+			strDescription = _T("TransferReady");
+			break;
+		default:
+			strDescription = _T("");
+			break;
+		}
+
+		return strDescription;
+	}
+
+	/*
+	 1: G1
+	 2: G2
+	 3: G1&G2
+	 */
+	std::string& CLoadPort::getPortCassetteTypeDescription(int casseteType, std::string& strDescription)
+	{
+		switch (casseteType) {
+		case 1:
+			strDescription = _T("G1");
+			break;
+		case 2:
+			strDescription = _T("G2");
+			break;
+		case 3:
+			strDescription = _T("G1&G2");
+			break;
+		default:
+			strDescription = _T("");
+			break;
+		}
+
+		return strDescription;
+	}
+
+	/*
+	 1: MGV Mode
+	 2: AGV Mode
+	 3: Stocker Inline Mode
+	 */
+	std::string& CLoadPort::getPortTransferModeDescription(int mode, std::string& strDescription)
+	{
+		switch (mode) {
+		case 1:
+			strDescription = _T("MGV Mode");
+			break;
+		case 2:
+			strDescription = _T("AGV Mode");
+			break;
+		case 3:
+			strDescription = _T("Stocker Inline Mode");
+			break;
+		default:
+			strDescription = _T("");
+			break;
+		}
+
+		return strDescription;
+	}
+
+
+	/*
+	 1 : Enable
+	 2 : Disable
+	 */
+	std::string& CLoadPort::getEnableModeDescription(int mode, std::string& strDescription)
+	{
+		switch (mode) {
+		case 1:
+			strDescription = _T("Enable");
+			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("");
+			break;
+		}
+
+		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);
+
+
+		static int typeReply[] = { STEP_ID_PROT1_TYPE_CHANGE_REPLY, STEP_ID_PROT2_TYPE_CHANGE_REPLY,
+			STEP_ID_PROT3_TYPE_CHANGE_REPLY, STEP_ID_PROT4_TYPE_CHANGE_REPLY };
+		static int modeReply[] = { STEP_ID_PROT1_MODE_CHANGE_REPLY, STEP_ID_PROT2_MODE_CHANGE_REPLY,
+			STEP_ID_PROT3_MODE_CHANGE_REPLY, STEP_ID_PROT4_MODE_CHANGE_REPLY };
+		static int transferModeReply[] = { STEP_ID_PROT1_TRANSFER_MODE_CHANGE_REPLY, STEP_ID_PROT2_TRANSFER_MODE_CHANGE_REPLY,
+			STEP_ID_PROT3_TRANSFER_MODE_CHANGE_REPLY, STEP_ID_PROT4_TRANSFER_MODE_CHANGE_REPLY };
+		static int enableModeReply[] = { STEP_ID_PROT1_ENABLE_MODE_CHANGE_REPLY, STEP_ID_PROT2_ENABLE_MODE_CHANGE_REPLY,
+			STEP_ID_PROT3_ENABLE_MODE_CHANGE_REPLY, STEP_ID_PROT4_ENABLE_MODE_CHANGE_REPLY };
+		static int typeAutoReply[] = { STEP_ID_PROT1_TYPE_AUTO_CHANGE_REPLY, STEP_ID_PROT2_TYPE_AUTO_CHANGE_REPLY,
+			STEP_ID_PROT3_TYPE_AUTO_CHANGE_REPLY, STEP_ID_PROT4_TYPE_AUTO_CHANGE_REPLY };
+		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);
+	}
+
+	int CLoadPort::decodePortStatusReport(CStep* pStep, const char* pszData, size_t size)
+	{
+		CPortStatusReport portStatusReport;
+		int nRet = portStatusReport.unserialize(&pszData[0], (int)size);
+		if (nRet < 0) return nRet;
+		m_portStatusReport.copyEx(portStatusReport);
+
+
+		// 缓存Attribute,用于调试时显示信息
+		unsigned int weight = 201;
+		CAttributeVector attrubutes;
+		m_portStatusReport.getAttributeVector(attrubutes, weight);
+		pStep->addAttributeVector(attrubutes);
+
+
+		LOGI("<CCassetteTranserStateStep>decodePortStatusReport<Status:%d, CassetteSequenceNo:%d>",
+			m_portStatusReport.getPortStatus(), m_portStatusReport.getCassetteSequenceNo());
+
+
+		return nRet;
+	}
+
+	int CLoadPort::setPortType(PortType type, ONWRITED onWritedBlock/* = nullptr*/)
+	{
+		static char* pszName[] = { STEP_PORT1_TYPE_CHANGE, STEP_PORT2_TYPE_CHANGE, STEP_PORT3_TYPE_CHANGE, STEP_PORT4_TYPE_CHANGE };
+		SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(pszName[m_nIndex]);
+		if (pStep == nullptr) {
+			return -1;
+		}
+
+		LOGI("<CLoadPort-%d>准备设置Port type<%d>", m_nIndex, (int)type);
+		short value = (short)type;
+		if (onWritedBlock != nullptr) {
+			pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
+		}
+		else {
+			pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
+				if (code == WOK) {
+					LOGI("<CLoadPort-%d>设置Port type成功.", m_nIndex);
+				}
+				else {
+					LOGI("<CLoadPort-%d>设置Port type失败,code:%d", m_nIndex, code);
+				}
+
+				return 0;
+				});
+		}
+
+		return 0;
+	}
+
+	int CLoadPort::eablePort(BOOL bEnable, ONWRITED onWritedBlock/* = nullptr*/)
+	{
+		static char* pszName[] = { STEP_PORT1_ENABLE_MODE_CHANGE, STEP_PORT2_ENABLE_MODE_CHANGE, STEP_PORT3_ENABLE_MODE_CHANGE, STEP_PORT4_ENABLE_MODE_CHANGE };
+		SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(pszName[m_nIndex]);
+		if (pStep == nullptr) {
+			return -1;
+		}
+
+		LOGI("<CLoadPort-%d>准备%s Port", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
+		short value = bEnable ? 1 : 2;
+		if (onWritedBlock != nullptr) {
+			pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
+		}
+		else {
+			pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
+				if (code == WOK) {
+					LOGI("<CLoadPort-%d>%s Port成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
+				}
+				else {
+					LOGI("<CLoadPort-%d>%s  Port失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code);
+				}
+
+				return 0;
+				});
+		}
+
+		return 0;
+	}
+
+	int CLoadPort::setPortMode(PortMode mode, ONWRITED onWritedBlock/* = nullptr*/)
+	{
+		static char* pszName[] = { STEP_PORT1_MODE_CHANGE, STEP_PORT2_MODE_CHANGE, STEP_PORT3_MODE_CHANGE, STEP_PORT4_MODE_CHANGE };
+		SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(pszName[m_nIndex]);
+		if (pStep == nullptr) {
+			return -1;
+		}
+
+		LOGI("<CLoadPort-%d>准备设置Port mode<%d>", m_nIndex, (int)mode);
+		short value = (short)mode;
+		if (onWritedBlock != nullptr) {
+			pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
+		}
+		else {
+			pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
+				if (code == WOK) {
+					LOGI("<CLoadPort-%d>设置Port mode成功.", m_nIndex);
+				}
+				else {
+					LOGI("<CLoadPort-%d>设置Port mode失败,code:%d", m_nIndex, code);
+				}
+
+				return 0;
+				});
+		}
+
+		return 0;
+	}
+
+	int CLoadPort::setCassetteType(CassetteType type, ONWRITED onWritedBlock/* = nullptr*/)
+	{
+		static char* pszName[] = { STEP_PORT1_CASSETTE_TYPE_CHANGE, STEP_PORT2_CASSETTE_TYPE_CHANGE, STEP_PORT3_CASSETTE_TYPE_CHANGE, STEP_PORT4_CASSETTE_TYPE_CHANGE };
+		SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(pszName[m_nIndex]);
+		if (pStep == nullptr) {
+			return -1;
+		}
+
+		LOGI("<CLoadPort-%d>准备设置Cassette Type<%d>", m_nIndex, (int)type);
+		short value = (short)type;
+		if (onWritedBlock != nullptr) {
+			pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
+		}
+		else {
+			pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
+				if (code == WOK) {
+					LOGI("<CLoadPort-%d>设置Cassette Type成功.", m_nIndex);
+				}
+				else {
+					LOGI("<CLoadPort-%d>设置Cassette Type失败,code:%d", m_nIndex, code);
+				}
+
+				return 0;
+				});
+		}
+
+		return 0;
+	}
+
+	int CLoadPort::setTransferMode(TransferMode mode, ONWRITED onWritedBlock/* = nullptr*/)
+	{
+		static char* pszName[] = { STEP_PORT1_TRANSFER_MODE_CHANGE, STEP_PORT2_TRANSFER_MODE_CHANGE, STEP_PORT3_TRANSFER_MODE_CHANGE, STEP_PORT4_TRANSFER_MODE_CHANGE };
+		SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(pszName[m_nIndex]);
+		if (pStep == nullptr) {
+			return -1;
+		}
+
+		LOGI("<CLoadPort-%d>准备设置Transfer mode<%d>", m_nIndex, (int)mode);
+		short value = (short)mode;
+		if (onWritedBlock != nullptr) {
+			pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
+		}
+		else {
+			pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
+				if (code == WOK) {
+					LOGI("<CLoadPort-%d>设置Transfer mode成功.", m_nIndex + 1);
+				}
+				else {
+					LOGI("<CLoadPort-%d>设置Transfer mode失败,code:%d", m_nIndex + 1, code);
+				}
+
+				return 0;
+				});
+		}
+
+		return 0;
+	}
+
+	int CLoadPort::eableAutoChange(BOOL bEnable, ONWRITED onWritedBlock/* = nullptr*/)
+	{
+		static char* pszName[] = { STEP_PORT1_TYPE_AUTO_CHANGE, STEP_PORT2_TYPE_AUTO_CHANGE, STEP_PORT3_TYPE_AUTO_CHANGE, STEP_PORT4_TYPE_AUTO_CHANGE };
+		SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(pszName[m_nIndex]);
+		if (pStep == nullptr) {
+			return -1;
+		}
+
+		LOGI("<CLoadPort-%d>准备%s Auto Change", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
+		short value = bEnable ? 1 : 2;
+		if (onWritedBlock != nullptr) {
+			pStep->writeDataEx((const char*)&value, sizeof(short), onWritedBlock);
+		}
+		else {
+			pStep->writeDataEx((const char*)&value, sizeof(short), [&](int code) -> int {
+				if (code == WOK) {
+					LOGI("<CLoadPort-%d>%s Auto Change成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
+				}
+				else {
+					LOGI("<CLoadPort-%d>%s  Auto Change失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code);
+				}
+
+				return 0;
+				});
+		}
+
+		return 0;
+	}
+
+	/*
+	 * 生成测试用的玻璃列表
+	 */
+	int CLoadPort::testGenerateGlassList(MaterialsType type, int count, const char* pszPrefix, int startSuffix)
+	{
+		// 如果非空就不生成了
+		Lock();
+		if (!m_glassList.empty()) {
+			Unlock();
+			return -1;
+		}
+		Unlock();
+
+
+		char szBuffer[64];
+		int suffix = startSuffix;
+		for (int i = 0; i < count; i++) {
+			CJobDataB jb;
+			CJobDataS js;
+
+			sprintf_s(szBuffer, "%s%d", pszPrefix, suffix++);
+			jb.setGlassId(szBuffer);
+			js.setMaterialsType((int)type);
+			if (type == MaterialsType::G1) {
+				js.setGlass1Id(szBuffer);
+			}
+			else if (type == MaterialsType::G2) {
+				js.setGlass2Id(szBuffer);
+			}
+
+			CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass();
+			pGlass->setID(szBuffer);
+			pGlass->setJobDataB(&jb);
+			pGlass->setType(type);
+			pGlass->setJobDataS(&js);
+			addGlassToList(pGlass);
+		}
+
+		return 0;
+	}
+
 }

--
Gitblit v1.9.3