From 5edb485d226790306097e40ea954efb2ed90dd21 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 11 八月 2025 16:05:09 +0800
Subject: [PATCH] 1.EAP:查询CJSpace和PJSpace功能模拟,Master对EAP查询机器变量的回复;
---
SourceCode/Bond/Servo/CEquipment.cpp | 226 +++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 164 insertions(+), 62 deletions(-)
diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index c7d1cb7..7560957 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -7,26 +7,11 @@
#include "Servo.h"
-#define CHECK_READ_STEP_SIGNAL(addr, data, size) { \
- BOOL bFlag = isBitOn(data, size, addr); \
- SERVO::CStep* pStep = getStep(addr); \
- if (pStep != nullptr) { \
- ((CReadStep*)pStep)->onReadSignal(bFlag ? addr : 0); \
- } \
-}
-
-#define CHECK_WRITE_STEP_SIGNAL(addr, data, size) { \
- BOOL bFlag = isBitOn(data, size, addr); \
- SERVO::CStep* pStep = getStep(addr); \
- if (pStep != nullptr) { \
- ((CWriteStep*)pStep)->onRecvSignal(bFlag ? addr : 0); \
- } \
-}
-
namespace SERVO {
CEquipment::CEquipment() : m_nID(0), m_strName(""), m_strDescription(""), m_station(0, 255)
{
+ m_bEnable = TRUE;
m_listener = { };
m_alive = { FALSE, 0, FALSE };
m_bCimState = FALSE;
@@ -70,6 +55,16 @@
m_outputPins.clear();
DeleteCriticalSection(&m_criticalSection);
+ }
+
+ void CEquipment::SetEnable(BOOL bEnable)
+ {
+ m_bEnable = bEnable;
+ }
+
+ BOOL CEquipment::IsEnabled() const
+ {
+ return m_bEnable;
}
void CEquipment::setListener(EquipmentListener listener)
@@ -406,10 +401,12 @@
m_bLinkSignalToUpstream[i][SIGNAL_INTERLOCK] = isBitOn(pszData, size, index + 2);
m_bLinkSignalToUpstream[i][SIGNAL_SEND_ABLE] = isBitOn(pszData, size, index + 3);
index += 0x40;
+
+ if (m_bLinkSignalToUpstream[i][SIGNAL_SEND_ABLE]) {
+ onSendAble(i+1);
+ }
}
- if(m_bLinkSignalToUpstream[0][SIGNAL_SEND_ABLE]) {
- onSendAble();
- }
+
index += 0x40 * 2;
for (int i = 0; i < 8; i++) {
@@ -418,10 +415,12 @@
m_bLinkSignalToDownstream[i][SIGNAL_INTERLOCK] = isBitOn(pszData, size, index + 2);
m_bLinkSignalToDownstream[i][SIGNAL_RECEIVE_ABLE] = isBitOn(pszData, size, index + 3);
index += 0x40;
+
+ if (m_bLinkSignalToDownstream[0][SIGNAL_RECEIVE_ABLE]) {
+ onReceiveAble(i + 1);
+ }
}
- if (m_bLinkSignalToDownstream[0][SIGNAL_RECEIVE_ABLE]) {
- onReceiveAble();
- }
+
// 其它信号及响应
index = 0x540;
@@ -526,8 +525,12 @@
// EQ Job Event
CHECK_READ_STEP_SIGNAL(STEP_ID_RECIVE_JOB_UPS1, pszData, size);
CHECK_READ_STEP_SIGNAL(STEP_ID_RECIVE_JOB_UPS2, pszData, size);
+ CHECK_READ_STEP_SIGNAL(STEP_ID_RECIVE_JOB_UPS3, pszData, size);
+ CHECK_READ_STEP_SIGNAL(STEP_ID_RECIVE_JOB_UPS4, pszData, size);
CHECK_READ_STEP_SIGNAL(STEP_ID_SENT_OUT_JOB_DOWNS1, pszData, size);
CHECK_READ_STEP_SIGNAL(STEP_ID_SENT_OUT_JOB_DOWNS2, pszData, size);
+ CHECK_READ_STEP_SIGNAL(STEP_ID_SENT_OUT_JOB_DOWNS3, pszData, size);
+ CHECK_READ_STEP_SIGNAL(STEP_ID_SENT_OUT_JOB_DOWNS4, pszData, size);
// Store Job Report #1~15
CHECK_READ_STEP_SIGNAL(STEP_ID_STORE_JOB_REPORT1, pszData, size);
@@ -597,7 +600,7 @@
CHECK_WRITE_STEP_SIGNAL(STEP_ID_IN_OP_CMD_REPLY, pszData, size);
// Panel Data Report
- CHECK_WRITE_STEP_SIGNAL(STEP_ID_PANEL_DATA_REPORT, pszData, size);
+ CHECK_READ_STEP_SIGNAL(STEP_ID_PANEL_DATA_REPORT, pszData, size);
// Panel Data Request
CHECK_WRITE_STEP_SIGNAL(STEP_ID_PANEL_DATA_REQUEST, pszData, size);
@@ -608,6 +611,11 @@
// job process start/end report
CHECK_READ_STEP_SIGNAL(STEP_ID_JOB_PROCESS_START_REPORT, pszData, size);
CHECK_READ_STEP_SIGNAL(STEP_ID_JOB_PROCESS_END_REPORT, pszData, size);
+
+ CHECK_WRITE_STEP_SIGNAL(STEP_ID_PROT1_CASSETTE_CTR_CMD_REPLY, pszData, size);
+ CHECK_WRITE_STEP_SIGNAL(STEP_ID_PROT2_CASSETTE_CTR_CMD_REPLY, pszData, size);
+ CHECK_WRITE_STEP_SIGNAL(STEP_ID_PROT3_CASSETTE_CTR_CMD_REPLY, pszData, size);
+ CHECK_WRITE_STEP_SIGNAL(STEP_ID_PROT4_CASSETTE_CTR_CMD_REPLY, pszData, size);
}
BOOL CEquipment::isBitOn(const char* pszData, size_t size, int index)
@@ -844,17 +852,23 @@
// 找到指定的glass id,
Lock();
- CGlass* pGlass = (CGlass*)m_slot[port - 1].getContext();
- if (pGlass == nullptr && !compareJobData(pJobDataB, pGlass->getJobDataS())) {
+ CGlass* pContext = nullptr;
+ for (int i = 0; i < SLOT_MAX; i++) {
+ CGlass* pGlass = (CGlass*)m_slot[i].getContext();
+ if (pGlass != nullptr && compareJobData(pJobDataB, pGlass->getJobDataS())) {
+ pContext = pGlass;
+ if (pGlass != nullptr) pGlass->addRef();
+ m_slot[i].setContext(nullptr);
+ break;
+ }
+ }
+ if (pContext == nullptr) {
Unlock();
return -3;
}
- if (pGlass != nullptr) pGlass->addRef();
- m_slot[port - 1].setContext(nullptr);
-
- ((CArm*)m_pArm)->tempStore(pGlass);
- pGlass->release();
+ ((CArm*)m_pArm)->tempStore(pContext);
+ pContext->release();
Unlock();
@@ -869,7 +883,7 @@
return 0;
}
- int CEquipment::storedJob(int port, CJobDataB* pJobDataB)
+ int CEquipment::storedJob(int port, CJobDataB* pJobDataB, short putSlot)
{
if (m_pArm == nullptr) {
return -1;
@@ -883,8 +897,8 @@
ASSERT(pGlass);
Lock();
- pGlass->addPath(m_nID, port);
- m_slot[port - 1].setContext(pGlass);
+ pGlass->addPath(m_nID, getSlotUnit(putSlot));
+ m_slot[putSlot - 1].setContext(pGlass);
pGlass->release(); // tempFetchOut需要调用一次release
Unlock();
@@ -895,7 +909,7 @@
if (m_listener.onDataChanged != nullptr) {
m_listener.onDataChanged(this, EDCC_STORED_JOB);
}
-
+
return 0;
}
@@ -943,7 +957,6 @@
CGlass* CEquipment::getGlassWithCassette(int cassetteSequenceNo, int jobSequenceNo)
{
- CSlot* pSlot = nullptr;
for (int i = 0; i < SLOT_MAX; i++) {
if (!m_slot[i].isEnable()) continue;
CGlass* pGlass = (CGlass*)m_slot[i].getContext();
@@ -1261,6 +1274,12 @@
if (m_slot[i].isLock()) continue;
if (!m_slot[i].isEmpty()) continue;
+ int lsPath = m_slot[i].getLinkSignalPath();
+ if (!m_bLinkSignalToDownstream[lsPath][SIGNAL_UPSTREAM_INLINE]
+ || m_bLinkSignalToDownstream[lsPath][SIGNAL_UPSTREAM_TROUBLE]
+ || !m_bLinkSignalToDownstream[lsPath][SIGNAL_INTERLOCK]
+ || !m_bLinkSignalToDownstream[lsPath][SIGNAL_RECEIVE_ABLE]) continue;
+
MaterialsType slotType = m_slot[i].getType();
if (type == MaterialsType::G1 && slotType == MaterialsType::G2) continue;
if (type == MaterialsType::G2 && slotType == MaterialsType::G1) continue;
@@ -1271,6 +1290,21 @@
}
return nullptr;
+ }
+
+ CSlot* CEquipment::isSlotAvailable(unsigned int slot)
+ {
+ if (slot >= 8) return nullptr;
+ if (!m_slot[slot].isEnable()) return nullptr;
+ if (m_slot[slot].isLock()) return nullptr;
+ if (!m_slot[slot].isEmpty()) return nullptr;
+ int lsPath = m_slot[slot].getLinkSignalPath();
+ if (!m_bLinkSignalToDownstream[lsPath][SIGNAL_UPSTREAM_INLINE]
+ || m_bLinkSignalToDownstream[lsPath][SIGNAL_UPSTREAM_TROUBLE]
+ || !m_bLinkSignalToDownstream[lsPath][SIGNAL_INTERLOCK]
+ || !m_bLinkSignalToDownstream[lsPath][SIGNAL_RECEIVE_ABLE]) return nullptr;
+
+ return &m_slot[slot];
}
CSlot* CEquipment::getNonEmptySlot(MaterialsType putSlotType)
@@ -1297,8 +1331,10 @@
if (!m_slot[i].isEnable()) continue;
if (m_slot[i].isLock()) continue;
CGlass* pGlass = (CGlass*)m_slot[i].getContext();
- if (!isSlotProcessed(i+1)) continue;
+ if (!isSlotProcessed(i)) continue;
if (pGlass == nullptr) continue;
+ if (!pGlass->isScheduledForProcessing()) continue;
+ if(pGlass->getInspResult(m_nID, 0) == InspResult::Fail) continue;
int lsPath = m_slot[i].getLinkSignalPath();
if(!m_bLinkSignalToUpstream[lsPath][SIGNAL_UPSTREAM_INLINE]
|| m_bLinkSignalToUpstream[lsPath][SIGNAL_UPSTREAM_TROUBLE]
@@ -1338,6 +1374,43 @@
return &m_slot[i];
}
}
+ }
+
+ return nullptr;
+ }
+
+ CSlot* CEquipment::getProcessedSlotCt(unsigned int slot)
+ {
+ if (slot >= 8) return nullptr;
+ if (!m_slot[slot].isEnable()) return nullptr;
+ if (m_slot[slot].isLock()) return nullptr;
+ CGlass* pGlass = (CGlass*)m_slot[slot].getContext();
+ if (pGlass == nullptr) return nullptr;
+ int lsPath = m_slot[slot].getLinkSignalPath();
+ if (!m_bLinkSignalToUpstream[lsPath][SIGNAL_UPSTREAM_INLINE]
+ || m_bLinkSignalToUpstream[lsPath][SIGNAL_UPSTREAM_TROUBLE]
+ || !m_bLinkSignalToUpstream[lsPath][SIGNAL_INTERLOCK]
+ || !m_bLinkSignalToUpstream[lsPath][SIGNAL_SEND_ABLE]) return nullptr;
+
+ return &m_slot[slot];
+ }
+
+ CSlot* CEquipment::getInspFailSlot()
+ {
+ 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;
+ if (!pGlass->isScheduledForProcessing()) continue;
+ if (pGlass->getInspResult(m_nID, 0) != InspResult::Fail) continue;
+ int lsPath = m_slot[i].getLinkSignalPath();
+ if (!m_bLinkSignalToUpstream[lsPath][SIGNAL_UPSTREAM_INLINE]
+ || m_bLinkSignalToUpstream[lsPath][SIGNAL_UPSTREAM_TROUBLE]
+ || !m_bLinkSignalToUpstream[lsPath][SIGNAL_INTERLOCK]
+ || !m_bLinkSignalToUpstream[lsPath][SIGNAL_SEND_ABLE]) continue;
+
+ return &m_slot[i];
}
return nullptr;
@@ -1383,6 +1456,10 @@
if (pSlot == nullptr) return -1;
pSlot->setContext(nullptr);
+ if (m_listener.onDataChanged != nullptr) {
+ m_listener.onDataChanged(this, EDCC_FETCHOUT_JOB);
+ }
+
return 0;
}
@@ -1430,17 +1507,15 @@
{
LOGI("<CEquipment-%s>onReceivedJob.", m_strName.c_str());
- // 可以在此更新JobDataS数据了
- CGlass* pGlass = getGlassFromSlot(port);
- if (pGlass == nullptr) {
- LOGE("<CEquipment-%s>onSentOutJob,没有找到对应的Glass(CassetteSequenceNo:%d, JobSequenceNo:%d, ID=%s),请检查数据,注意风险。",
- m_strName.c_str(), pJobDataS->getCassetteSequenceNo(), pJobDataS->getJobSequenceNo(),
- pJobDataS->getGlass1Id().c_str());
- return -1;
- }
- pGlass->updateJobDataS(pJobDataS);
- return 0;
+ // 可以在此更新JobDataS数据了
+ int nRet = ((CArm*)m_pArm)->glassUpdateJobDataS(pJobDataS);
+ if (nRet < 0) {
+ LOGE("<CEquipment-%s>onReceivedJob,更新JobDataS失败,glassUpdateJobDataS返回%d",
+ m_strName.c_str(), nRet);
+ }
+
+ return nRet;
}
int CEquipment::decodeSentOutJobReport(CStep* pStep, int port, const char* pszData, size_t size)
@@ -1607,7 +1682,7 @@
index += sizeof(short);
CToolUnits::convertString(&pszData[index], 128 * 2, strPanelJudgeData);
index += 128 * 2;
- CToolUnits::convertString(&pszData[index], 256 * 2, strPanelJudgeData);
+ CToolUnits::convertString(&pszData[index], 256 * 2, strPanelGradeData);
index += 256 * 2;
@@ -1622,6 +1697,15 @@
pStep->addAttribute(new CAttribute("PanelGradeData",
strPanelGradeData.c_str(), "", weight++));
+
+ // 更新检测结果
+ CGlass* pGlass = getGlassWithCassette(cassetteNo, jobSequenceNo);
+ if (pGlass == nullptr) {
+ LOGE("<CEquipment-%s>更新Panel Data失败,找不到对应的Glass.cassetteNo=%d, jobSequenceNo=%d",
+ getName().c_str(), cassetteNo, jobSequenceNo);
+ return -1;
+ }
+ pGlass->setInspResult(m_nID, 0, judgeStringToInspResult(strPanelJudgeData));
return 0;
}
@@ -1787,14 +1871,23 @@
if (m_processState != PROCESS_STATE::Complete) {
setProcessState(PROCESS_STATE::Complete);
}
- CGlass* pGlass = getGlassFromSlot(port);
+
+ CGlass* pGlass = getGlassFromSlot(slotNo);
if (pGlass == nullptr) {
LOGE("<CEquipment-%s>decodeJobProcessEndReport, 找不到对应glass", getName().c_str());
}
else {
- pGlass->processEnd(m_nID, port);
- if (m_processState != PROCESS_STATE::Complete) {
- setProcessState(PROCESS_STATE::Complete);
+ CJobDataS* pJs = pGlass->getJobDataS();
+ if (pJs->getCassetteSequenceNo() == cassetteNo
+ && pJs->getJobSequenceNo() == jobSequenceNo) {
+ pGlass->processEnd(m_nID, getSlotUnit(slotNo));
+ if (m_processState != PROCESS_STATE::Complete) {
+ setProcessState(PROCESS_STATE::Complete);
+ }
+ }
+ else {
+ LOGE("<CEquipment-%s>decodeJobProcessEndReport, jobSequenceNo或jobSequenceNo不匹配",
+ getName().c_str());
}
}
@@ -1844,7 +1937,7 @@
// 如果没有可用位置,报错
Lock();
- CSlot* pSlot = getSlot(port - 1);
+ CSlot* pSlot = getSlot(putSlot - 1);
ASSERT(pSlot);
if (pSlot->getContext() != nullptr) {
Unlock();
@@ -1874,12 +1967,12 @@
short putSlot = 0;
BOOL bCheck = onPreStoredJob(port, pJobDataB, putSlot);
- if (bCheck && port == putSlot) {
- return storedJob(port, pJobDataB);
+ if (bCheck) {
+ return storedJob(port, pJobDataB, putSlot);
}
// 数据异常,处理或显示
- LOGI("<CEquipment-%s>onStoredJob Error.ort:%d|GlassId:%s",
+ LOGI("<CEquipment-%s>onStoredJob Error.port:%d|GlassId:%s",
m_strName.c_str(), port, pJobDataB->getGlassId().c_str());
return -1;
}
@@ -1895,19 +1988,16 @@
* 当从CC-Link检测到设备Send Able为On时调用此函数
* 可能会多次重复调用(根据扫描频率), 注意防呆
*/
- int CEquipment::onSendAble()
+ int CEquipment::onSendAble(int port)
{
- LOGI("<CEquipment-%s>onSendAble.", m_strName.c_str());
- if (m_processState != PROCESS_STATE::Complete) {
- setProcessState(PROCESS_STATE::Complete);
- }
+ // LOGI("<CEquipment-%s>onSendAble.port:%d", m_strName.c_str(), port);
return 0;
}
- int CEquipment::onReceiveAble()
+ int CEquipment::onReceiveAble(int port)
{
- LOGI("<CEquipment-%s>onReceiveAble.", m_strName.c_str());
+ // LOGI("<CEquipment-%s>onReceiveAble.port:%d", m_strName.c_str(), port);
return 0;
}
@@ -1956,4 +2046,16 @@
);
}
}
+
+ InspResult CEquipment::judgeStringToInspResult(std::string& strJudge)
+ {
+ if (strJudge.compare("N") == 0) {
+ return InspResult::Fail;
+ }
+ if (strJudge.compare("G") == 0) {
+ return InspResult::Pass;
+ }
+
+ return InspResult::NotInspected;
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3