From 4ec3b6e0317c579c856ceb9f4c7c5146753af5bf Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 05 六月 2025 08:40:08 +0800
Subject: [PATCH] Merge branch 'clh'
---
SourceCode/Bond/Servo/CEquipment.cpp | 121 +++++++++++++++++++++++++++++++++-------
1 files changed, 100 insertions(+), 21 deletions(-)
diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index 319cb86..0a7d384 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,13 +771,13 @@
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();
// 如果此玻璃已经贴合,贴合的玻璃也要从加入到列表中
+ /*
CGlass* pBuddy = pGlass->getBuddy();
if (pBuddy != nullptr) {
Lock();
@@ -791,12 +786,12 @@
m_glassList.push_back(pBuddy);
Unlock();
}
-
+ */
if (m_listener.onDataChanged != nullptr) {
- m_listener.onDataChanged(this, 0);
+ m_listener.onDataChanged(this, EDCC_STORED_JOB);
}
- */
+
return 0;
}
@@ -809,6 +804,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 +1065,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 +1097,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 +1151,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 +1291,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 +1381,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 +1393,7 @@
return FALSE;
}
- // 当前不能有任何玻璃,且当前准备进的片是G2
+ // 如果没有可用位置,报错
Lock();
CSlot* pSlot = getAvailableSlotForGlass((MaterialsType)pJobDataS->getMaterialsType());
if (pSlot == nullptr) {
@@ -1341,6 +1403,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 +1422,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 +1438,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