From 2a803976ed12e59f3e082e7c08941ef5004e6ea1 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期二, 20 五月 2025 11:40:10 +0800
Subject: [PATCH] 1. 添加机器臂命令配置界面
---
SourceCode/Bond/Servo/CEquipment.cpp | 88 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 86 insertions(+), 2 deletions(-)
diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index cea483e..1d3f312 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -3,6 +3,8 @@
#include "ToolUnits.h"
#include <regex>
#include "CArm.h"
+#include "CGlassPool.h"
+#include "Servo.h"
#define CHECK_READ_STEP_SIGNAL(addr, data, size) { \
@@ -311,13 +313,28 @@
Unlock();
}
else {
- Lock();
+ // addGlassToList前不需要上锁,因其内部有锁
int count;
ar >> count;
for (int i = 0; i < count; i++) {
- CGlass* pGlass = new CGlass();
+ CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass();
pGlass->serialize(ar);
addGlassToList(pGlass);
+ }
+
+ // 梳理各玻璃之间的绑定关系
+ Lock();
+ std::list<CGlass*> list = m_glassList;
+ for (auto item : list) {
+ std::string& strBuddyId = item->getBuddyId();
+ if (!strBuddyId.empty()) {
+ for (auto item2 : m_glassList) {
+ if (strBuddyId.compare(item2->getID()) == 0) {
+ item->setBuddy(item2);
+ TRACE("绑定关系: %s <- %s\n", item->getID().c_str(), item2->getID().c_str());
+ }
+ }
+ }
}
Unlock();
}
@@ -786,6 +803,21 @@
}
}
+ CGlass* CEquipment::getGlassFromList(const char* pszId)
+ {
+ CGlass* pGlass = nullptr;
+ Lock();
+ for (auto item : m_glassList) {
+ if (item->getID().compare(pszId) == 0) {
+ pGlass = item;
+ break;
+ }
+ }
+ Unlock();
+
+ return pGlass;
+ }
+
BOOL CEquipment::removeClass(CGlass* pGlass)
{
Lock();
@@ -853,6 +885,19 @@
return -3;
}
+ // 如果此玻璃已经贴合,贴合的玻璃也要从列表中移除
+ CGlass* pBuddy = pContext->getBuddy();
+ if (pBuddy != nullptr) {
+ for (auto iter = m_glassList.begin(); iter != m_glassList.end(); iter++) {
+ if ((*iter)->getID().compare(pBuddy->getID()) == 0) {
+ (*iter)->release();
+ m_glassList.erase(iter);
+ break;
+ }
+ }
+ }
+
+
((CArm*)m_pArm)->tempStore(pContext);
pContext->release();
Unlock();
@@ -883,6 +928,18 @@
m_glassList.push_back(pGlass);
pGlass->release(); // tempFetchOut需要调用一次release
Unlock();
+
+
+ // 如果此玻璃已经贴合,贴合的玻璃也要从加入到列表中
+ CGlass* pBuddy = pGlass->getBuddy();
+ if (pBuddy != nullptr) {
+ Lock();
+ pBuddy->addPath(m_nID);
+ pBuddy->addRef(); // 加入list,addRef
+ m_glassList.push_back(pBuddy);
+ Unlock();
+ }
+
if (m_listener.onDataChanged != nullptr) {
m_listener.onDataChanged(this, 0);
@@ -1006,6 +1063,33 @@
return pStep->setDateTime(year, month, day, hour, minute, second);
}
+ int CEquipment::setDispatchingMode(DISPATCHING_MODE mode, ONWRITED onWritedBlock/* = nullptr*/)
+ {
+ SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(STEP_EQ_DISPATCHINT_MODE_CHANGE);
+ if (pStep == nullptr) {
+ return -1;
+ }
+
+ LOGI("<CEquipment-%s>准备设置DispatchingMode<%d>", m_strName.c_str(), (int)mode);
+ if (onWritedBlock != nullptr) {
+ pStep->writeShort((short)mode, onWritedBlock);
+ }
+ else {
+ pStep->writeShort((short)mode, [&, mode](int code) -> int {
+ if (code == WOK) {
+ LOGI("<CEquipment-%s>设置DispatchingMode成功.", m_strName.c_str());
+ }
+ else {
+ LOGI("<CEquipment-%s>设置DispatchingMode失败,code:%d", m_strName.c_str(), code);
+ }
+
+ return 0;
+ });
+ }
+
+ return 0;
+ }
+
int CEquipment::masterRecipeListRequest(short unitNo)
{
SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(STEP_EQ_MASTER_RECIPE_LIST_REQ);
--
Gitblit v1.9.3