From d119dcff794370b1852c0e9a3cda28d8d2bc6ae8 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期五, 30 五月 2025 17:24:51 +0800
Subject: [PATCH] 1. 添加搬运记录对话框 2. 修复搬运记录的数据库管理类的中文问题

---
 SourceCode/Bond/Servo/CLoadPort.cpp |  359 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 359 insertions(+), 0 deletions(-)

diff --git a/SourceCode/Bond/Servo/CLoadPort.cpp b/SourceCode/Bond/Servo/CLoadPort.cpp
index c7c6040..1c7becf 100644
--- a/SourceCode/Bond/Servo/CLoadPort.cpp
+++ b/SourceCode/Bond/Servo/CLoadPort.cpp
@@ -466,6 +466,41 @@
 		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
@@ -616,6 +651,156 @@
 		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,
@@ -682,6 +867,180 @@
 		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;
+	}
+
 	/*
 	 * 生成测试用的玻璃列表
 	 */

--
Gitblit v1.9.3