From 217f07665553605caa3f3339321d04bd2c3e8256 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 15 五月 2025 17:18:58 +0800
Subject: [PATCH] 1.Bonder 处理ProcessDataReport, 并将G1与G2绑定一起。
---
SourceCode/Bond/Servo/CPageGraph2.cpp | 11 +++
SourceCode/Bond/Servo/CProcessData.cpp | 5 +
SourceCode/Bond/Servo/resource.h | 0
SourceCode/Bond/Servo/CGlass.cpp | 41 +++++++++++++
SourceCode/Bond/Servo/CEquipment.cpp | 32 ++++++++++
SourceCode/Bond/Servo/CGlass.h | 5 +
SourceCode/Bond/Servo/Servo.rc | 0
SourceCode/Bond/Servo/CProcessData.h | 1
SourceCode/Bond/Servo/CEquipment.h | 1
SourceCode/Bond/Servo/CBonder.h | 1
SourceCode/Bond/Servo/CBonder.cpp | 40 +++++++++++++
11 files changed, 134 insertions(+), 3 deletions(-)
diff --git a/SourceCode/Bond/Servo/CBonder.cpp b/SourceCode/Bond/Servo/CBonder.cpp
index a1a47b1..655c99a 100644
--- a/SourceCode/Bond/Servo/CBonder.cpp
+++ b/SourceCode/Bond/Servo/CBonder.cpp
@@ -408,4 +408,44 @@
return bCheck;
}
+
+ int CBonder::onProcessData(CProcessData* pProcessData)
+ {
+ CEquipment::onProcessData(pProcessData);
+
+
+ // 检查数据,当前两片玻璃,一片为G1, 一片为G2, 且pProcessData中的id能匹配G1或G2
+ Lock();
+ if (m_glassList.size() != 2) {
+ Unlock();
+ LOGE("<CBonder-%s>onProcessData,绑定失败,腔体内必须有且仅有两片玻璃!", m_strName.c_str());
+ return -1;
+ }
+
+ CGlass* pGlass1 = m_glassList.front();
+ CGlass* pGlass2 = m_glassList.back();
+ Unlock();
+
+ if (pGlass1->getBuddy() != nullptr || pGlass2->getBuddy() != nullptr) {
+ LOGE("<CBonder-%s>onProcessData,错误!玻璃较早前已被绑定,请检查数据是否正确!", m_strName.c_str());
+ return -1;
+ }
+
+ if (pGlass1->getBuddy() != nullptr || pGlass2->getBuddy() != nullptr) {
+ LOGE("<CBonder-%s>onProcessData,错误!玻璃较早前已被贴合,请检查数据是否正确!", m_strName.c_str());
+ return -1;
+ }
+
+ if (pGlass1->getType() == pGlass2->getType()) {
+ LOGE("<CBonder-%s>onProcessData,错误!两片玻璃未匹配,必须分别为G1和G2类型,请检查数据是否正确!", m_strName.c_str());
+ return -1;
+ }
+
+ pGlass1->setBuddy(pGlass2);
+ pGlass2->setBuddy(pGlass1);
+ LOGE("<CBonder-%s>onProcessData,%s和%s已贴合!", m_strName.c_str(),
+ pGlass1->getID().c_str(), pGlass2->getID().c_str());
+
+ return 0;
+ }
}
diff --git a/SourceCode/Bond/Servo/CBonder.h b/SourceCode/Bond/Servo/CBonder.h
index 746639a..e05dce4 100644
--- a/SourceCode/Bond/Servo/CBonder.h
+++ b/SourceCode/Bond/Servo/CBonder.h
@@ -22,6 +22,7 @@
virtual int recvIntent(CPin* pPin, CIntent* pIntent);
virtual BOOL glassWillArrive(CGlass* pGlass);
virtual BOOL onPreStoredJob(int port, CJobDataB* pJobDataB);
+ virtual int onProcessData(CProcessData* pProcessData);
public:
void setIndex(unsigned int index);
diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index cea483e..c4b51a7 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -311,13 +311,28 @@
Unlock();
}
else {
- Lock();
+ // addGlassToList前不需要上锁,因其内部有锁
int count;
ar >> count;
for (int i = 0; i < count; i++) {
CGlass* pGlass = new CGlass();
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 +801,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();
diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index 831a3df..fe6ed40 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -128,6 +128,7 @@
virtual int onStoredJob(int port, CJobDataB* pJobDataB);
virtual int onProcessData(CProcessData* pProcessData);
void getGlassList(std::list<CGlass*>& list);
+ CGlass* getGlassFromList(const char* pszId);
CGlass* getFrontGlass();
BOOL removeClass(CGlass* pGlass);
bool isAlarmStep(SERVO::CStep* pStep);
diff --git a/SourceCode/Bond/Servo/CGlass.cpp b/SourceCode/Bond/Servo/CGlass.cpp
index 410868a..e2b6259 100644
--- a/SourceCode/Bond/Servo/CGlass.cpp
+++ b/SourceCode/Bond/Servo/CGlass.cpp
@@ -7,6 +7,7 @@
{
m_pPath = nullptr;
m_type = MaterialsType::G1;
+ m_pBuddy = nullptr;
}
CGlass::~CGlass()
@@ -18,6 +19,10 @@
pPath = pTemp;
}
m_pPath = nullptr;
+
+ if (m_pBuddy != nullptr && m_type == MaterialsType::G1) {
+ m_pBuddy->release();
+ }
}
std::string& CGlass::getClassName()
@@ -90,6 +95,7 @@
if (ar.IsStoring())
{
Lock();
+ ar << (int)m_type;
WriteString(ar, m_strID);
ar << (ULONGLONG)m_pPath;
if (m_pPath != nullptr) {
@@ -100,13 +106,19 @@
ar.Write(temp, JOBDATAB_SIZE);
m_jobDataS.serialize(temp, JOBDATAS_SIZE);
ar.Write(temp, JOBDATAS_SIZE);
+ ar << (ULONGLONG)m_pBuddy;
+ WriteString(ar, m_strBuddyId);
Unlock();
}
else
{
- Lock();
- ReadString(ar, m_strID);
ULONGLONG ullPath;
+ int type;
+
+ Lock();
+ ar >> type;
+ m_type = (MaterialsType)type;
+ ReadString(ar, m_strID);
ar >> ullPath;
if (ullPath != 0) {
m_pPath = new CPath();
@@ -117,6 +129,8 @@
m_jobDataB.unserialize(temp, JOBDATAB_SIZE);
ar.Read(temp, JOBDATAS_SIZE);
m_jobDataS.unserialize(temp, JOBDATAS_SIZE);
+ ar >> ullPath; // 这是m_pBuddy, 用不上
+ ReadString(ar, m_strBuddyId);
Unlock();
}
}
@@ -140,4 +154,27 @@
{
return &m_jobDataS;
}
+
+ BOOL CGlass::setBuddy(CGlass* pGlass)
+ {
+ if (m_pBuddy != nullptr) return FALSE;
+ if (pGlass->getType() == this->getType()) return FALSE;
+ m_pBuddy = pGlass;
+ if (m_type == MaterialsType::G1) {
+ m_pBuddy->addRef();
+ }
+ m_strBuddyId = m_pBuddy->getID();
+
+ return TRUE;
+ }
+
+ CGlass* CGlass::getBuddy()
+ {
+ return m_pBuddy;
+ }
+
+ std::string& CGlass::getBuddyId()
+ {
+ return m_strBuddyId;
+ }
}
diff --git a/SourceCode/Bond/Servo/CGlass.h b/SourceCode/Bond/Servo/CGlass.h
index 4fa6b33..ffeeccc 100644
--- a/SourceCode/Bond/Servo/CGlass.h
+++ b/SourceCode/Bond/Servo/CGlass.h
@@ -36,6 +36,9 @@
CJobDataB* getJobDataB();
void setJobDataS(CJobDataS* pJobDataS);
CJobDataS* getJobDataS();
+ BOOL setBuddy(CGlass* pGlass);
+ CGlass* getBuddy();
+ std::string& getBuddyId();
private:
MaterialsType m_type;
@@ -43,6 +46,8 @@
CPath* m_pPath;
CJobDataB m_jobDataB;
CJobDataS m_jobDataS;
+ CGlass* m_pBuddy;
+ std::string m_strBuddyId;
};
}
diff --git a/SourceCode/Bond/Servo/CPageGraph2.cpp b/SourceCode/Bond/Servo/CPageGraph2.cpp
index e8493da..ea4010b 100644
--- a/SourceCode/Bond/Servo/CPageGraph2.cpp
+++ b/SourceCode/Bond/Servo/CPageGraph2.cpp
@@ -227,6 +227,17 @@
}
else if (nCmd == ID_EQSGRAPHITEM_TEST3) {
SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
+ if (pEquipment != nullptr) {
+ SERVO::CGlass* pGlass = pEquipment->getFrontGlass();
+ if (pGlass != nullptr) {
+ SERVO::CProcessData pd;
+ pd.setGlassId(pGlass->getID().c_str());
+ pEquipment->onProcessData(&pd);
+ }
+ }
+ }
+ else if (nCmd == ID_EQSGRAPHITEM_TEST4) {
+ SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
// 娴嬭瘯涓嬪彂Cim Message
/*
diff --git a/SourceCode/Bond/Servo/CProcessData.cpp b/SourceCode/Bond/Servo/CProcessData.cpp
index bf9a8de..ed5a5aa 100644
--- a/SourceCode/Bond/Servo/CProcessData.cpp
+++ b/SourceCode/Bond/Servo/CProcessData.cpp
@@ -20,6 +20,11 @@
return m_strGlassId;
}
+ void CProcessData::setGlassId(const char* pszId)
+ {
+ m_strGlassId = pszId;
+ }
+
std::string& CProcessData::getStartTime()
{
return m_strStartTime;
diff --git a/SourceCode/Bond/Servo/CProcessData.h b/SourceCode/Bond/Servo/CProcessData.h
index 270a359..37b0866 100644
--- a/SourceCode/Bond/Servo/CProcessData.h
+++ b/SourceCode/Bond/Servo/CProcessData.h
@@ -12,6 +12,7 @@
public:
std::string& getGlassId();
+ void setGlassId(const char* pszId);
std::string& getStartTime();
std::string& getEndTime();
unsigned int getTotalParameter();
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index 5de3f29..7cba98a 100644
--- a/SourceCode/Bond/Servo/Servo.rc
+++ b/SourceCode/Bond/Servo/Servo.rc
Binary files differ
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index 250b0c7..40bc4b7 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ
--
Gitblit v1.9.3