From 29adbde03b8499f070218181500e5774c301328e Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期四, 19 六月 2025 16:16:37 +0800
Subject: [PATCH] 1. 补充发送信号读取PLC信号 2. 补充结束发送信号给PLC
---
SourceCode/Bond/Servo/Servo.vcxproj.user | 2
SourceCode/Bond/Servo/CEquipment.cpp | 9 +++-
SourceCode/Bond/Servo/CAttributeVector.cpp | 11 +++++
SourceCode/Bond/Servo/CMaster.cpp | 49 +++++++++++++++++++++++-
4 files changed, 63 insertions(+), 8 deletions(-)
diff --git a/SourceCode/Bond/Servo/CAttributeVector.cpp b/SourceCode/Bond/Servo/CAttributeVector.cpp
index 733c629..79e1776 100644
--- a/SourceCode/Bond/Servo/CAttributeVector.cpp
+++ b/SourceCode/Bond/Servo/CAttributeVector.cpp
@@ -19,9 +19,18 @@
void CAttributeVector::addAttribute(CAttribute* pAttribute, BOOL bReplace/* = FALSE*/)
{
+ if (!pAttribute) {
+ return;
+ }
+
+ const std::string& name = pAttribute->getName();
+ if (name.empty()) {
+ return;
+ }
+
if (bReplace) {
for (auto it = m_attributes.begin(); it != m_attributes.end(); ) {
- if ((*it)->getName().compare(pAttribute->getName()) == 0) {
+ if (name.compare((*it)->getName()) == 0) {
delete (*it);
it = m_attributes.erase(it);
}
diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index 2038e25..4baebd5 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -578,7 +578,9 @@
// robot cmd reply
CHECK_WRITE_STEP_SIGNAL(STEP_ID_ROBOT_CMD_REPLY, pszData, size);
-
+
+ // Indexer Operation Mode Change
+ CHECK_WRITE_STEP_SIGNAL(STEP_ID_IN_OP_CMD_REPLY, pszData, size);
}
BOOL CEquipment::isBitOn(const char* pszData, size_t size, int index)
@@ -1021,14 +1023,15 @@
unsigned short operationMode = (unsigned short)((unsigned short)mode + getIndexerOperationModeBaseValue());
LOGI("<CEquipment-%s>准备设置indexerOperationMode<%d>", m_strName.c_str(), (int)mode);
- pStep->writeShort(operationMode, [&, mode, onWritedRetBlock](int code) -> int {
+ pStep->writeShort(operationMode, [&, pStep, mode, onWritedRetBlock](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);
+ retCode = (unsigned int)CToolUnits::toInt16(pszRetData);
+ LOGI("<CEquipment-%s>返回值: %d", m_strName.c_str(), retCode);
}
else {
LOGI("<CEquipment-%s>设置indexerOperationMode失败,code:%d", m_strName.c_str(), code);
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index bcc0ea2..dc45e46 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -340,7 +340,7 @@
int nRet;
CEquipment* pEq[6] = { pEFEM, pBonder1, pBonder2, pBakeCooling,
pVacuumBake, pMeasurement};
- BOOL bIomcOk[7] = {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE};
+ BOOL bIomcOk[7] = {FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE};
std::vector<std::promise<void>> promises(6);
std::vector<std::future<void>> futures;
@@ -356,7 +356,7 @@
goto WAIT;
}
futures.push_back(promises[0].get_future());
-
+ /*
nRet = pEq[1]->indexerOperationModeChange(IDNEXER_OPERATION_MODE::Start,
[&](int writeCode, int retCode) -> void {
bIomcOk[1] = retCode == (int)RET::OK;
@@ -421,6 +421,7 @@
goto WAIT;
}
futures.push_back(promises[5].get_future());
+ */
WAIT:
for (auto& f : futures) {
@@ -450,7 +451,49 @@
// 处理完成当前事务后,切换到停止或就绪状态
else if (m_state == MASTERSTATE::STOPPING) {
unlock();
- Sleep(1000);
+ LOGI("<Master>开始切换各设备到 Stop 模式...");
+
+ std::vector<std::promise<void>> promises(6);
+ std::vector<std::future<void>> futures;
+ BOOL bIomcOk[7] = { FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE };
+
+ int nRet;
+ CEquipment* pEq[6] = { pEFEM, pBonder1, pBonder2, pBakeCooling,
+ pVacuumBake, pMeasurement };
+
+ for (int i = 0; i < 1; ++i) {
+ nRet = pEq[i]->indexerOperationModeChange(IDNEXER_OPERATION_MODE::Stop,
+ [i, &promises, &bIomcOk](int writeCode, int retCode) -> void {
+ bIomcOk[i] = retCode == (int)RET::OK;
+ promises[i].set_value();
+ TRACE("s000%d: ret=%d\n", i + 1, retCode);
+ });
+ if (nRet != 0) {
+ LOGI("<Master>%s切换Stop状态发送失败", pEq[i]->getName().c_str());
+ m_strLastError = pEq[i]->getName() + "切换Stop状态发送失败.";
+ bIomcOk[i] = FALSE;
+ promises[i].set_value(); // 避免 wait 阻塞
+ }
+ futures.push_back(promises[i].get_future());
+ }
+
+ for (auto& f : futures) {
+ f.wait(); // 等待所有完成
+ }
+
+ for (int i = 0; i < 6; ++i) {
+ if (!bIomcOk[i]) {
+ bIomcOk[6] = FALSE;
+ LOGI("<Master>%s切换Stop状态失败", pEq[i]->getName().c_str());
+ }
+ }
+
+ if (!bIomcOk[6]) {
+ setState(MASTERSTATE::MSERROR);
+ continue;
+ }
+
+ LOGI("<Master>所有设备成功切换到 Stop 模式");
setState(MASTERSTATE::READY);
continue;
}
diff --git a/SourceCode/Bond/Servo/Servo.vcxproj.user b/SourceCode/Bond/Servo/Servo.vcxproj.user
index 0c03257..82c7903 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj.user
+++ b/SourceCode/Bond/Servo/Servo.vcxproj.user
@@ -7,6 +7,6 @@
<RemoteDebuggerCommand>\\DESKTOP-IODBVIQ\Servo\Debug\Servo.exe</RemoteDebuggerCommand>
<RemoteDebuggerWorkingDirectory>\\DESKTOP-IODBVIQ\Servo\Debug\</RemoteDebuggerWorkingDirectory>
<RemoteDebuggerServerName>DESKTOP-IODBVIQ</RemoteDebuggerServerName>
- <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+ <DebuggerFlavor>WindowsRemoteDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
\ No newline at end of file
--
Gitblit v1.9.3