From 690bbf01bc579aff0ca31b2f326c7a6b5d83604d Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 05 六月 2025 10:51:13 +0800
Subject: [PATCH] 1.Slot的部分数据不需要存储,否则影响代码修改Slot布局等信息; 2.Bonder Porcess完成后,合成两片一起搬送的逻辑问题;
---
SourceCode/Bond/Servo/CEquipment.cpp | 126 ++++++++++++++++++++++++++++++++++-------
1 files changed, 104 insertions(+), 22 deletions(-)
diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index 319cb86..bd36700 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -27,7 +27,7 @@
CEquipment::CEquipment() : m_nID(0), m_strName(""), m_strDescription(""), m_station(0, 255)
{
- m_listener = { nullptr, nullptr, nullptr, nullptr, nullptr };
+ m_listener = { };
m_alive = { FALSE, 0, FALSE };
m_bCimState = FALSE;
m_bUpstreamInline = FALSE;
@@ -71,11 +71,7 @@
void CEquipment::setListener(EquipmentListener listener)
{
- m_listener.onAlive = listener.onAlive;
- m_listener.onCimStateChanged = listener.onCimStateChanged;
- m_listener.onAlarm = listener.onAlarm;
- m_listener.onDataChanged = listener.onDataChanged;
- m_listener.onVcrEventReport = listener.onVcrEventReport;
+ m_listener = listener;
}
void CEquipment::setCcLink(CCCLinkIEControl* pCcLink)
@@ -330,7 +326,7 @@
else {
for (int i = 0; i < SLOT_MAX; i++) {
m_slot[i].serialize(ar);
- if (m_slot[i].getContext() != nullptr) {
+ if (m_slot[i].getTempContext() != nullptr) {
CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass();
pGlass->serialize(ar);
m_slot[i].setContext(pGlass);
@@ -726,6 +722,7 @@
CGlass* pGlass = (CGlass*)m_slot[i].getContext();
if (pGlass != nullptr && compareJobDataB(pJobDataB, pGlass->getJobDataB())) {
pContext = pGlass;
+ if (pGlass != nullptr) pGlass->addRef();
m_slot[i].setContext(nullptr);
break;
}
@@ -741,7 +738,6 @@
for (int i = 0; i < SLOT_MAX; i++) {
CGlass* pGlass = (CGlass*)m_slot[i].getContext();
if (pGlass != nullptr && compareJobDataB(pBuddy->getJobDataB(), pGlass->getJobDataB())) {
- pContext->release();
m_slot[i].setContext(nullptr);
break;
}
@@ -754,15 +750,14 @@
Unlock();
if (m_listener.onDataChanged != nullptr) {
- m_listener.onDataChanged(this, 0);
+ m_listener.onDataChanged(this, EDCC_FETCHOUT_JOB);
}
return 0;
}
- int CEquipment::storedJob(CJobDataB* pJobDataB)
+ int CEquipment::storedJob(CJobDataB* pJobDataB, short& putSlot)
{
- /*
if (m_pArm == nullptr) {
return -1;
}
@@ -776,8 +771,7 @@
ASSERT(pGlass);
Lock();
pGlass->addPath(m_nID);
- pGlass->addRef(); // 加入list,addRef
- m_glassList.push_back(pGlass);
+ m_slot[putSlot - 1].setContext(pGlass);
pGlass->release(); // tempFetchOut需要调用一次release
Unlock();
@@ -787,16 +781,20 @@
if (pBuddy != nullptr) {
Lock();
pBuddy->addPath(m_nID);
- pBuddy->addRef(); // 加入list,addRef
- m_glassList.push_back(pBuddy);
+ if (putSlot % 2 == 0) {
+ m_slot[putSlot - 2].setContext(pBuddy);
+ }
+ else {
+ m_slot[putSlot].setContext(pBuddy);
+ }
Unlock();
}
if (m_listener.onDataChanged != nullptr) {
- m_listener.onDataChanged(this, 0);
+ m_listener.onDataChanged(this, EDCC_STORED_JOB);
}
- */
+
return 0;
}
@@ -809,6 +807,20 @@
}
return FALSE;
+ }
+
+ CGlass* CEquipment::getGlass(const char* pszGlassId)
+ {
+ for (int i = 0; i < SLOT_MAX; i++) {
+ if (!m_slot[i].isEnable()) continue;
+ CGlass* pGlass = (CGlass*)m_slot[i].getContext();
+ if (pGlass == nullptr) continue;
+ if (pGlass->getID().compare(pszGlassId) == 0) {
+ return pGlass;
+ }
+ }
+
+ return nullptr;
}
bool CEquipment::isAlarmStep(SERVO::CStep* pStep)
@@ -1056,6 +1068,27 @@
return nullptr;
}
+ CSlot* CEquipment::getAvailableSlotForGlass2(MaterialsType type, const std::vector<int>& candidates)
+ {
+ for (auto item : candidates) {
+ for (int i = 0; i < SLOT_MAX; i++) {
+ if (item == i + 1) {
+ if (!m_slot[i].isEnable()) continue;
+ if (m_slot[i].isLock()) continue;
+ if (!m_slot[i].isEmpty()) continue;
+
+ MaterialsType slotType = m_slot[i].getType();
+ if (type == MaterialsType::G1 && slotType == MaterialsType::G2) continue;
+ if (type == MaterialsType::G2 && slotType == MaterialsType::G1) continue;
+
+ return &m_slot[i];
+ }
+ }
+ }
+
+ return nullptr;
+ }
+
CSlot* CEquipment::getNonEmptySlot(MaterialsType putSlotType)
{
for (int i = 0; i < SLOT_MAX; i++) {
@@ -1067,6 +1100,25 @@
MaterialsType glassType = pGlass->getType();
if (glassType == MaterialsType::G1 && putSlotType == MaterialsType::G2) continue;
if (glassType == MaterialsType::G2 && putSlotType == MaterialsType::G1) continue;
+
+ return &m_slot[i];
+ }
+
+ return nullptr;
+ }
+
+ CSlot* CEquipment::getProcessedSlot(MaterialsType putSlotType)
+ {
+ for (int i = 0; i < SLOT_MAX; i++) {
+ if (!m_slot[i].isEnable()) continue;
+ if (m_slot[i].isLock()) continue;
+ CGlass* pGlass = (CGlass*)m_slot[i].getContext();
+ if (pGlass == nullptr) continue;
+
+ MaterialsType glassType = pGlass->getType();
+ if (glassType == MaterialsType::G1 && putSlotType == MaterialsType::G2) continue;
+ if (glassType == MaterialsType::G2 && putSlotType == MaterialsType::G1) continue;
+ if (!pGlass->isProcessed(m_nID)) continue;
return &m_slot[i];
}
@@ -1102,6 +1154,15 @@
}
return nullptr;
+ }
+
+ BOOL CEquipment::canPlaceGlassInSlot(const short slotIndex)
+ {
+ if (slotIndex >= SLOT_MAX) return FALSE;
+ if (!m_slot[slotIndex].isEnable()) return FALSE;
+ if (m_slot[slotIndex].getContext() != nullptr) return FALSE;
+
+ return TRUE;
}
short CEquipment::decodeRecipeListReport(const char* pszData, size_t size)
@@ -1233,10 +1294,14 @@
return index;
}
- int CEquipment::onPreFetchedOutJob(int port, CJobDataB* pJobDataB)
+ BOOL CEquipment::onPreFetchedOutJob(int port, CJobDataB* pJobDataB)
{
LOGI("<CEquipment-%s>onPreFetchedOutJob:port:%d|GlassId:%s",
m_strName.c_str(), port, pJobDataB->getGlassId().c_str());
+ if (m_listener.onPreFethedOutJob != nullptr) {
+ return m_listener.onPreFethedOutJob(this, pJobDataB);
+ }
+
return TRUE;
}
@@ -1319,7 +1384,7 @@
return 0;
}
- int CEquipment::onPreStoredJob(int port, CJobDataB* pJobDataB)
+ int CEquipment::onPreStoredJob(int port, CJobDataB* pJobDataB, short& putSlot)
{
LOGI("<CEquipment-%s>onPreStoredJob:port:%d|GlassId:%s",
m_strName.c_str(), port, pJobDataB->getGlassId().c_str());
@@ -1331,7 +1396,7 @@
return FALSE;
}
- // 当前不能有任何玻璃,且当前准备进的片是G2
+ // 如果没有可用位置,报错
Lock();
CSlot* pSlot = getAvailableSlotForGlass((MaterialsType)pJobDataS->getMaterialsType());
if (pSlot == nullptr) {
@@ -1341,6 +1406,17 @@
}
Unlock();
+
+ if (m_listener.onPreStoredJob != nullptr) {
+ if (!m_listener.onPreStoredJob(this, pJobDataB, putSlot)) {
+ return FALSE;
+ }
+
+ if(!canPlaceGlassInSlot(putSlot - 1)) {
+ return FALSE;
+ }
+ }
+
return TRUE;
}
@@ -1349,10 +1425,11 @@
LOGI("<CEquipment-%s>onStore:port:%d|GlassId:%s",
m_strName.c_str(), port, pJobDataB->getGlassId().c_str());
- BOOL bCheck = onPreStoredJob(port, pJobDataB);
+ short putSlot = 0;
+ BOOL bCheck = onPreStoredJob(port, pJobDataB, putSlot);
if (bCheck) {
addJobDataB(pJobDataB);
- return storedJob(pJobDataB);
+ return storedJob(pJobDataB, putSlot);
}
// 数据异常,处理或显示
@@ -1364,6 +1441,11 @@
int CEquipment::onProcessData(CProcessData* pProcessData)
{
LOGI("<CEquipment-%s>onProcessData.", m_strName.c_str());
+ CGlass* pGlass = getGlass(pProcessData->getGlassId().c_str());
+ if (pGlass != nullptr) {
+ pGlass->processEnd(m_nID);
+ }
+
return 0;
}
--
Gitblit v1.9.3