From 258d9d2d72bbf199cd86fd3e7bd824e1f117bab8 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 29 五月 2025 17:49:46 +0800
Subject: [PATCH] 1.放片物流控制和模拟测试;
---
SourceCode/Bond/Servo/CRobotTask.h | 3 +
SourceCode/Bond/Servo/CEquipment.cpp | 49 ++++++++++-----
SourceCode/Bond/Servo/CRobotTask.cpp | 15 +++++
SourceCode/Bond/Servo/CMaster.cpp | 70 ++++++++++++++++++-----
SourceCode/Bond/Servo/CEquipment.h | 10 ++
5 files changed, 113 insertions(+), 34 deletions(-)
diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index d9fb8e9..7cb8a5b 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, nullptr };
+ m_listener = { };
m_alive = { FALSE, 0, FALSE };
m_bCimState = FALSE;
m_bUpstreamInline = FALSE;
@@ -71,12 +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.onPreFethedOutJob = listener.onPreFethedOutJob;
+ m_listener = listener;
}
void CEquipment::setCcLink(CCCLinkIEControl* pCcLink)
@@ -761,9 +756,8 @@
return 0;
}
- int CEquipment::storedJob(CJobDataB* pJobDataB)
+ int CEquipment::storedJob(CJobDataB* pJobDataB, short& putSlot)
{
- /*
if (m_pArm == nullptr) {
return -1;
}
@@ -777,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();
@@ -792,12 +786,12 @@
m_glassList.push_back(pBuddy);
Unlock();
}
-
+ */
if (m_listener.onDataChanged != nullptr) {
m_listener.onDataChanged(this, EDCC_STORED_JOB);
}
- */
+
return 0;
}
@@ -1105,6 +1099,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)
{
return m_recipesManager.decodeRecipeListReport(pszData, size);
@@ -1324,7 +1327,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());
@@ -1336,7 +1339,7 @@
return FALSE;
}
- // 当前不能有任何玻璃,且当前准备进的片是G2
+ // 如果没有可用位置,报错
Lock();
CSlot* pSlot = getAvailableSlotForGlass((MaterialsType)pJobDataS->getMaterialsType());
if (pSlot == nullptr) {
@@ -1346,6 +1349,17 @@
}
Unlock();
+
+ if (m_listener.onPreStoredJob != nullptr) {
+ if (!m_listener.onPreStoredJob(this, pJobDataB, putSlot)) {
+ return FALSE;
+ }
+
+ if(!canPlaceGlassInSlot(putSlot - 1)) {
+ return FALSE;
+ }
+ }
+
return TRUE;
}
@@ -1354,10 +1368,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);
}
// 数据异常,处理或显示
diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index fbd6ed7..df7e015 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -45,6 +45,7 @@
typedef std::function<void(void* pEiuipment, int state, int alarmId, int unitId, int level)> ONALARM;
typedef std::function<void(void* pEiuipment, void* pReport)> ONVCREVENTREPORT;
typedef std::function<BOOL(void* pEiuipment, CJobDataB* pJobDataB)> ONPREFETCHEDOUTJOB;
+ typedef std::function<BOOL(void* pEiuipment, CJobDataB* pJobDataB, short& putSlot)> ONPRESTOREDJOB;
typedef struct _EquipmentListener
{
ONALIVE onAlive;
@@ -53,6 +54,7 @@
ONDATACHANGED onDataChanged;
ONVCREVENTREPORT onVcrEventReport;
ONPREFETCHEDOUTJOB onPreFethedOutJob;
+ ONPRESTOREDJOB onPreStoredJob;
} EquipmentListener;
@@ -104,12 +106,12 @@
std::vector<CPin*>& CEquipment::getOutputPins();
virtual int recvIntent(CPin* pPin, CIntent* pIntent);
virtual int fetchedOutJob(CJobDataB* pJobDataB);
- virtual int storedJob(CJobDataB* pJobDataB);
+ virtual int storedJob(CJobDataB* pJobDataB, short& putSlot);
virtual int onReceivedJob(int port, CJobDataS* pJobDataS);
virtual int onSentOutJob(int port, CJobDataS* pJobDataS);
virtual BOOL onPreFetchedOutJob(int port, CJobDataB* pJobDataB);
virtual int onFetchedOutJob(int port, CJobDataB* pJobDataB);
- virtual BOOL onPreStoredJob(int port, CJobDataB* pJobDataB);
+ virtual BOOL onPreStoredJob(int port, CJobDataB* pJobDataB, short& putSlot);
virtual int onStoredJob(int port, CJobDataB* pJobDataB);
virtual int onProcessData(CProcessData* pProcessData);
virtual int getIndexerOperationModeBaseValue();
@@ -162,6 +164,10 @@
// 是否有玻璃
BOOL hasGlass();
+ // 指定槽位是否可以放置玻璃
+ BOOL canPlaceGlassInSlot(const short slotIndex);
+
+
// 以下为从CC-Link读取到的Bit标志位检测函数
public:
BOOL isAlive();
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index e05c2f7..d536f7c 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -33,7 +33,7 @@
CMaster::CMaster()
{
- m_listener = {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr};
+ m_listener = {};
m_bDataModify = FALSE;
m_hEventReadBitsThreadExit[0] = ::CreateEvent(NULL, TRUE, FALSE, NULL);
m_hEventReadBitsThreadExit[1] = ::CreateEvent(NULL, TRUE, FALSE, NULL);
@@ -83,12 +83,7 @@
void CMaster::setListener(MasterListener listener)
{
- m_listener.onMasterStateChanged = listener.onMasterStateChanged;
- m_listener.onEqAlive = listener.onEqAlive;
- m_listener.onEqCimStateChanged = listener.onEqCimStateChanged;
- m_listener.onEqAlarm = listener.onEqAlarm;
- m_listener.onEqVcrEventReport = listener.onEqVcrEventReport;
- m_listener.onEqDataChanged = listener.onEqDataChanged;
+ m_listener = listener;
}
CRobotTask* CMaster::getActiveRobotTask()
@@ -469,19 +464,54 @@
CEquipment* p = (CEquipment*)pEquipment;
- // 取放片,更新当前搬送任务
+ // 取片,更新当前搬送任务
BOOL bOk = FALSE;
lock();
- if (m_pActiveRobotTask != nullptr && m_pActiveRobotTask->getSrcPosition() == p->getID()) {
- CGlass* pGlass = p->getGlassFromSlot(m_pActiveRobotTask->getSrcSlot());
- if (pGlass != nullptr) {
- CJobDataB* pJobDataBSrc = pGlass->getJobDataB();
- if (pJobDataBSrc != nullptr
- && pJobDataBSrc->getCassetteSequenceNo() == pJobDataB->getCassetteSequenceNo()
- && pJobDataBSrc->getJobSequenceNo() == pJobDataB->getJobSequenceNo()) {
+ if (m_pActiveRobotTask != nullptr) {
+ if (m_pActiveRobotTask->getSrcPosition() == p->getID()) {
+ CGlass* pGlass = p->getGlassFromSlot(m_pActiveRobotTask->getSrcSlot());
+ if (pGlass != nullptr) {
+ CJobDataB* pJobDataBSrc = pGlass->getJobDataB();
+ if (pJobDataBSrc != nullptr
+ && pJobDataBSrc->getCassetteSequenceNo() == pJobDataB->getCassetteSequenceNo()
+ && pJobDataBSrc->getJobSequenceNo() == pJobDataB->getJobSequenceNo()) {
+ bOk = TRUE;
+ LOGI("<CMaster>onPreFethedOutJob, 已校验数据一致性.");
+ }
+ }
+ }
+ else if (p->getID() == EQ_ID_ARM_TRAY1 || p->getID() == EQ_ID_ARM_TRAY2) {
+ bOk = TRUE;
+ }
+ }
+ unlock();
+
+ if (!bOk) {
+ LOGE("<CMaster>onPreFethedOutJob, 数据校验失败.");
+ }
+
+ return bOk;
+
+ };
+ listener.onPreStoredJob = [&](void* pEquipment, CJobDataB* pJobDataB, short& slot) -> BOOL {
+ CEquipment* p = (CEquipment*)pEquipment;
+
+
+ // 放片,更新当前搬送任务
+ BOOL bOk = FALSE;
+ lock();
+ if (m_pActiveRobotTask != nullptr) {
+ if (m_pActiveRobotTask->getTarPosition() == p->getID()) {
+ CGlass* pGlass = p->getGlassFromSlot(m_pActiveRobotTask->getTarSlot());
+ if (pGlass == nullptr) {
bOk = TRUE;
+ slot = m_pActiveRobotTask->getTarSlot();
LOGI("<CMaster>onPreFethedOutJob, 已校验数据一致性.");
}
+ }
+ else if (p->getID() == EQ_ID_ARM_TRAY1 || p->getID() == EQ_ID_ARM_TRAY2) {
+ slot = 1;
+ bOk = TRUE;
}
}
unlock();
@@ -513,7 +543,17 @@
lock();
if (m_pActiveRobotTask != nullptr && m_pActiveRobotTask->getTarPosition() == p->getID()) {
m_pActiveRobotTask->stored();
+ m_pActiveRobotTask->completed();
LOGI("放片完成...");
+
+ // 完成此条搬送任务,但要把数据和消息上抛应用层
+ unlock();
+
+
+
+ lock();
+ delete m_pActiveRobotTask;
+ m_pActiveRobotTask = nullptr;
}
unlock();
}
diff --git a/SourceCode/Bond/Servo/CRobotTask.cpp b/SourceCode/Bond/Servo/CRobotTask.cpp
index 17113b4..3b19a24 100644
--- a/SourceCode/Bond/Servo/CRobotTask.cpp
+++ b/SourceCode/Bond/Servo/CRobotTask.cpp
@@ -120,6 +120,21 @@
return m_state;
}
+ void CRobotTask::completed()
+ {
+ m_state = ROBOT_TASK_STATE::Completed;
+ }
+
+ void CRobotTask::error()
+ {
+ m_state = ROBOT_TASK_STATE::Error;
+ }
+
+ void CRobotTask::abort()
+ {
+ m_state = ROBOT_TASK_STATE::Abort;
+ }
+
int CRobotTask::getSrcPosition()
{
return m_robotCmdParam.getPosition;
diff --git a/SourceCode/Bond/Servo/CRobotTask.h b/SourceCode/Bond/Servo/CRobotTask.h
index 0fa435f..1fee5f2 100644
--- a/SourceCode/Bond/Servo/CRobotTask.h
+++ b/SourceCode/Bond/Servo/CRobotTask.h
@@ -22,6 +22,9 @@
time_t getStoredTime();
time_t getFinishTime();
ROBOT_TASK_STATE getState();
+ void completed();
+ void error();
+ void abort();
int getSrcPosition();
int getSrcSlot();
int getTarPosition();
--
Gitblit v1.9.3