From 02fe6422964aab86753818744b901b2c299c06a4 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 22 五月 2025 11:30:29 +0800
Subject: [PATCH] 1.Port cmd功能和界面操作实现; 2.操作提示框界面实现;

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

diff --git a/SourceCode/Bond/Servo/CLoadPort.cpp b/SourceCode/Bond/Servo/CLoadPort.cpp
index c7c6040..940dbbc 100644
--- a/SourceCode/Bond/Servo/CLoadPort.cpp
+++ b/SourceCode/Bond/Servo/CLoadPort.cpp
@@ -682,6 +682,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