From b78a202c2933d345e1983de26948dbdae5d72382 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期四, 12 二月 2026 10:28:06 +0800
Subject: [PATCH] 1.加上限制条件,Port1必须配置Port2, Port3必须配Port4,且是同一ProcessJob
---
SourceCode/Bond/Servo/CMaster.cpp | 498 +++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 462 insertions(+), 36 deletions(-)
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index f51c969..c7703e4 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -63,6 +63,7 @@
m_ullRunTime = 0;
m_state = MASTERSTATE::READY;
m_curveMode = CurveMode::Production;
+ m_schedulingMode = SchedulingMode::Production;
m_pActiveRobotTask = nullptr;
m_nLastError = ER_CODE_NOERROR;
m_isCompareMapsBeforeProceeding = FALSE;
@@ -119,13 +120,6 @@
m_hEventDispatchThreadExit[1] = nullptr;
}
- // 閲婃斁浜哄伐鎼嚭缂撳啿鍖洪噷鐨勭幓鐠�
- for (auto* pGlass : m_bufGlass) {
- if (pGlass != nullptr) {
- pGlass->release();
- }
- }
- m_bufGlass.clear();
DeleteCriticalSection(&m_criticalSection);
}
@@ -319,6 +313,17 @@
return m_curveMode;
}
+ void CMaster::setSchedulingMode(SchedulingMode mode)
+ {
+ m_schedulingMode = mode;
+ LOGI("<Master>SchedulingMode=%s", mode == SchedulingMode::Production ? "Production" : "Tuning");
+ }
+
+ SchedulingMode CMaster::getSchedulingMode() const
+ {
+ return m_schedulingMode;
+ }
+
int CMaster::term()
{
SetEvent(m_hEventReadBitsThreadExit[0]);
@@ -344,6 +349,13 @@
}
m_listEquipment.clear();
+ // release manual-remove buffer before glass pool is torn down
+ for (auto* pGlass : m_bufGlass) {
+ if (pGlass != nullptr) {
+ pGlass->release();
+ }
+ }
+ m_bufGlass.clear();
if (m_pCollector != nullptr) {
m_pCollector->stopLoop();
@@ -695,6 +707,91 @@
continue;
}
+ // 鐢熶骇妯″紡鍥哄畾鏄犲皠锛歅ort1/3 -> G1锛孭ort2/4 -> G2銆�
+ auto isProductionPortTypeMatch = [&](int portIndex, MaterialsType type) -> bool {
+ if (m_schedulingMode != SchedulingMode::Production) return true;
+ const bool isG1Port = (portIndex == 0 || portIndex == 2);
+ if (type == MaterialsType::G1) return isG1Port;
+ if (type == MaterialsType::G2) return !isG1Port;
+ return true;
+ };
+
+ // 鐢熶骇妯″紡锛氭牴鎹嚎涓婃湭閰嶅鐜荤拑鍙嶆帹涓嬩竴鐗囧簲鏉ヨ嚜鍝釜绔彛锛圥ort1<->2, Port3<->4锛夈��
+ auto getPreferredPortForType = [&](MaterialsType targetType) -> int {
+ if (m_schedulingMode != SchedulingMode::Production) return -1;
+
+ auto preferG1ByG2 = [&](CGlass* pG2) -> int {
+ if (pG2 == nullptr || pG2->getType() != MaterialsType::G2 || pG2->getBuddy() != nullptr) return -1;
+ int originPort = -1, originSlot = -1;
+ pG2->getOrginPort(originPort, originSlot);
+ if (originPort == 1) return 0; // Port2 -> Port1
+ if (originPort == 3) return 2; // Port4 -> Port3
+ return -1;
+ };
+ auto preferG2ByG1 = [&](CGlass* pG1) -> int {
+ if (pG1 == nullptr || pG1->getType() != MaterialsType::G1 || pG1->getBuddy() != nullptr) return -1;
+ int originPort = -1, originSlot = -1;
+ pG1->getOrginPort(originPort, originSlot);
+ if (originPort == 0) return 1; // Port1 -> Port2
+ if (originPort == 2) return 3; // Port3 -> Port4
+ return -1;
+ };
+
+ if (targetType == MaterialsType::G1) {
+ int p = preferG1ByG2(pBonder1->getGlassFromSlot(1)); if (p >= 0) return p;
+ p = preferG1ByG2(pBonder2->getGlassFromSlot(1)); if (p >= 0) return p;
+ p = preferG1ByG2(pFliper->getGlassFromSlot(1)); if (p >= 0) return p;
+ p = preferG1ByG2(pAligner->getGlassFromSlot(1)); if (p >= 0) return p;
+ }
+ else if (targetType == MaterialsType::G2) {
+ int p = preferG2ByG1(pBonder1->getGlassFromSlot(2)); if (p >= 0) return p;
+ p = preferG2ByG1(pBonder2->getGlassFromSlot(2)); if (p >= 0) return p;
+ p = preferG2ByG1(pVacuumBake->getGlassFromSlot(1)); if (p >= 0) return p;
+ p = preferG2ByG1(pVacuumBake->getGlassFromSlot(2)); if (p >= 0) return p;
+ p = preferG2ByG1(pAligner->getGlassFromSlot(1)); if (p >= 0) return p;
+ }
+
+ return -1;
+ };
+
+ // Job 妯″紡涓嬭姹� Bonder 鍐呯殑 G1/G2 鏉ヨ嚜鍚屼竴涓� ProcessJob銆�
+ auto validateBonderPairProcessJob = [&](CEquipment* pBonder, const char* bonderName) -> bool {
+ if (m_pActiveRobotTask == nullptr) return false;
+ CGlass* pIncomingG1 = (CGlass*)m_pActiveRobotTask->getContext();
+ CGlass* pExistingG2 = pBonder->getGlassFromSlot(0);
+ if (pIncomingG1 == nullptr || pExistingG2 == nullptr) return true;
+
+ CProcessJob* pjG1 = pIncomingG1->getProcessJob();
+ CProcessJob* pjG2 = pExistingG2->getProcessJob();
+ if (m_bJobMode && (pjG1 == nullptr || pjG2 == nullptr || pjG1 != pjG2)) {
+ std::string pj1 = (pjG1 == nullptr) ? "NULL" : pjG1->id();
+ std::string pj2 = (pjG2 == nullptr) ? "NULL" : pjG2->id();
+ LOGW("<Master>%s閰嶅鎷︽埅锛欸1/G2鏉ヨ嚜涓嶅悓ProcessJob(G1=%s,G2=%s)銆�",
+ bonderName, pj1.c_str(), pj2.c_str());
+ delete m_pActiveRobotTask;
+ m_pActiveRobotTask = nullptr;
+ return false;
+ }
+
+ // 鐢熶骇妯″紡鍥哄畾绔彛瀵癸細Port1<->Port2锛孭ort3<->Port4銆�
+ if (m_schedulingMode == SchedulingMode::Production) {
+ int g1Port = 0, g1Slot = 0, g2Port = 0, g2Slot = 0;
+ pIncomingG1->getOrginPort(g1Port, g1Slot);
+ pExistingG2->getOrginPort(g2Port, g2Slot);
+ const bool pairOk =
+ (g1Port == 0 && g2Port == 1) ||
+ (g1Port == 2 && g2Port == 3);
+ if (!pairOk) {
+ LOGW("<Master>%s閰嶅鎷︽埅锛氱鍙e涓嶅尮閰�(瑕佹眰1<->2鎴�3<->4, 瀹為檯G1Port=%d,G2Port=%d)銆�",
+ bonderName, g1Port + 1, g2Port + 1);
+ delete m_pActiveRobotTask;
+ m_pActiveRobotTask = nullptr;
+ return false;
+ }
+ }
+ return true;
+ };
+
// Bonder1銆丅onder2銆丗liper銆乂acuumBake銆丄ligner锛岀粺璁2鍜孏1鐨勬暟閲�, 閰嶅缁勬暟, 澶氬嚭鐨勭被鍨�
int nG2Count = 0, nG1Count = 0, nGlassGroup, nExtraType;
@@ -746,14 +843,22 @@
// Measurement -> LoadPort
- for (int s = 0; s < 4; s++) {
- PortType pt = pLoadPorts[s]->getPortType();
- if (!rmd.armState[0] && pLoadPorts[s]->isEnable()
- && (pt == PortType::Unloading || pt == PortType::Both)
- && pLoadPorts[s]->getPortStatus() == PORT_INUSE) {
- m_pActiveRobotTask = createTransferTask(pMeasurement, pLoadPorts[s], MaterialsType::G1, secondaryType);
- if (m_pActiveRobotTask != nullptr) {
- goto PORT_PUT;
+ if (m_schedulingMode == SchedulingMode::Production) {
+ if (!rmd.armState[0]) {
+ m_pActiveRobotTask = createTransferTask_returnOrigin(pMeasurement, pLoadPorts);
+ CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
+ }
+ }
+ else {
+ for (int s = 0; s < 4; s++) {
+ PortType pt = pLoadPorts[s]->getPortType();
+ if (!rmd.armState[0] && pLoadPorts[s]->isEnable()
+ && (pt == PortType::Unloading || pt == PortType::Both)
+ && pLoadPorts[s]->getPortStatus() == PORT_INUSE) {
+ m_pActiveRobotTask = createTransferTask(pMeasurement, pLoadPorts[s], MaterialsType::G1, secondaryType);
+ if (m_pActiveRobotTask != nullptr) {
+ goto PORT_PUT;
+ }
}
}
}
@@ -817,11 +922,17 @@
// VacuumBake(G1) -> Bonder
if (!rmd.armState[0] && pBonder1->slotHasGlass(0) && !pBonder1->slotHasGlass(1)) {
m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder1, MaterialsType::G1, MaterialsType::G0);
+ if (m_pActiveRobotTask != nullptr && !validateBonderPairProcessJob(pBonder1, "Bonder1")) {
+ // 鍚� PJ 鏍¢獙澶辫触锛屾湰杞笉涓嬪彂鎼��
+ }
CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
}
if (!rmd.armState[0] && pBonder2->slotHasGlass(0) && !pBonder2->slotHasGlass(1)) {
m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder2, MaterialsType::G1, MaterialsType::G0);
+ if (m_pActiveRobotTask != nullptr && !validateBonderPairProcessJob(pBonder2, "Bonder2")) {
+ // 鍚� PJ 鏍¢獙澶辫触锛屾湰杞笉涓嬪彂鎼��
+ }
CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
}
@@ -860,14 +971,34 @@
else {
primaryType = MaterialsType::G1;
}
+ const int preferredPortForPrimary = getPreferredPortForType(primaryType);
+ {
+ static int s_prevPrimaryType = -1;
+ static int s_prevPreferredPort = -2;
+ const int curPrimaryType = (int)primaryType;
+ if (s_prevPrimaryType != curPrimaryType || s_prevPreferredPort != preferredPortForPrimary) {
+ LOGI("<Master>LoadPort->Aligner瑙勫垯(RUNNING): primaryType=%d, preferredPort=%d",
+ curPrimaryType, preferredPortForPrimary >= 0 ? (preferredPortForPrimary + 1) : 0);
+ s_prevPrimaryType = curPrimaryType;
+ s_prevPreferredPort = preferredPortForPrimary;
+ }
+ }
for (int s = 0; s < 4; s++) {
PortType pt = pLoadPorts[s]->getPortType();
if (!rmd.armState[0] && pLoadPorts[s]->isEnable()
&& (pt == PortType::Loading || pt == PortType::Both)
&& pLoadPorts[s]->getPortStatus() == PORT_INUSE) {
+ if (!isProductionPortTypeMatch(s, primaryType)) {
+ continue;
+ }
+ if (preferredPortForPrimary >= 0 && s != preferredPortForPrimary) {
+ continue;
+ }
m_pActiveRobotTask = createTransferTask(pLoadPorts[s], pAligner, primaryType, secondaryType, 1, m_bJobMode);
if (m_pActiveRobotTask != nullptr) {
+ LOGI("<Master>LoadPort->Aligner鍛戒腑(RUNNING): port=%d, primaryType=%d, preferredPort=%d",
+ s + 1, (int)primaryType, preferredPortForPrimary >= 0 ? (preferredPortForPrimary + 1) : 0);
CGlass* pGlass = (CGlass*)m_pActiveRobotTask->getContext();
if (pGlass->getBuddy() != nullptr) {
delete m_pActiveRobotTask;
@@ -950,6 +1081,91 @@
continue;
}
+ // 鐢熶骇妯″紡鍥哄畾鏄犲皠锛歅ort1/3 -> G1锛孭ort2/4 -> G2銆�
+ auto isProductionPortTypeMatch = [&](int portIndex, MaterialsType type) -> bool {
+ if (m_schedulingMode != SchedulingMode::Production) return true;
+ const bool isG1Port = (portIndex == 0 || portIndex == 2);
+ if (type == MaterialsType::G1) return isG1Port;
+ if (type == MaterialsType::G2) return !isG1Port;
+ return true;
+ };
+
+ // 鐢熶骇妯″紡锛氭牴鎹嚎涓婃湭閰嶅鐜荤拑鍙嶆帹涓嬩竴鐗囧簲鏉ヨ嚜鍝釜绔彛锛圥ort1<->2, Port3<->4锛夈��
+ auto getPreferredPortForType = [&](MaterialsType targetType) -> int {
+ if (m_schedulingMode != SchedulingMode::Production) return -1;
+
+ auto preferG1ByG2 = [&](CGlass* pG2) -> int {
+ if (pG2 == nullptr || pG2->getType() != MaterialsType::G2 || pG2->getBuddy() != nullptr) return -1;
+ int originPort = -1, originSlot = -1;
+ pG2->getOrginPort(originPort, originSlot);
+ if (originPort == 1) return 0; // Port2 -> Port1
+ if (originPort == 3) return 2; // Port4 -> Port3
+ return -1;
+ };
+ auto preferG2ByG1 = [&](CGlass* pG1) -> int {
+ if (pG1 == nullptr || pG1->getType() != MaterialsType::G1 || pG1->getBuddy() != nullptr) return -1;
+ int originPort = -1, originSlot = -1;
+ pG1->getOrginPort(originPort, originSlot);
+ if (originPort == 0) return 1; // Port1 -> Port2
+ if (originPort == 2) return 3; // Port3 -> Port4
+ return -1;
+ };
+
+ if (targetType == MaterialsType::G1) {
+ int p = preferG1ByG2(pBonder1->getGlassFromSlot(1)); if (p >= 0) return p;
+ p = preferG1ByG2(pBonder2->getGlassFromSlot(1)); if (p >= 0) return p;
+ p = preferG1ByG2(pFliper->getGlassFromSlot(1)); if (p >= 0) return p;
+ p = preferG1ByG2(pAligner->getGlassFromSlot(1)); if (p >= 0) return p;
+ }
+ else if (targetType == MaterialsType::G2) {
+ int p = preferG2ByG1(pBonder1->getGlassFromSlot(2)); if (p >= 0) return p;
+ p = preferG2ByG1(pBonder2->getGlassFromSlot(2)); if (p >= 0) return p;
+ p = preferG2ByG1(pVacuumBake->getGlassFromSlot(1)); if (p >= 0) return p;
+ p = preferG2ByG1(pVacuumBake->getGlassFromSlot(2)); if (p >= 0) return p;
+ p = preferG2ByG1(pAligner->getGlassFromSlot(1)); if (p >= 0) return p;
+ }
+
+ return -1;
+ };
+
+ // Job 妯″紡涓嬭姹� Bonder 鍐呯殑 G1/G2 鏉ヨ嚜鍚屼竴涓� ProcessJob銆�
+ auto validateBonderPairProcessJob = [&](CEquipment* pBonder, const char* bonderName) -> bool {
+ if (m_pActiveRobotTask == nullptr) return false;
+ CGlass* pIncomingG1 = (CGlass*)m_pActiveRobotTask->getContext();
+ CGlass* pExistingG2 = pBonder->getGlassFromSlot(0);
+ if (pIncomingG1 == nullptr || pExistingG2 == nullptr) return true;
+
+ CProcessJob* pjG1 = pIncomingG1->getProcessJob();
+ CProcessJob* pjG2 = pExistingG2->getProcessJob();
+ if (m_bJobMode && (pjG1 == nullptr || pjG2 == nullptr || pjG1 != pjG2)) {
+ std::string pj1 = (pjG1 == nullptr) ? "NULL" : pjG1->id();
+ std::string pj2 = (pjG2 == nullptr) ? "NULL" : pjG2->id();
+ LOGW("<Master>%s閰嶅鎷︽埅锛欸1/G2鏉ヨ嚜涓嶅悓ProcessJob(G1=%s,G2=%s)銆�",
+ bonderName, pj1.c_str(), pj2.c_str());
+ delete m_pActiveRobotTask;
+ m_pActiveRobotTask = nullptr;
+ return false;
+ }
+
+ // 鐢熶骇妯″紡鍥哄畾绔彛瀵癸細Port1<->Port2锛孭ort3<->Port4銆�
+ if (m_schedulingMode == SchedulingMode::Production) {
+ int g1Port = 0, g1Slot = 0, g2Port = 0, g2Slot = 0;
+ pIncomingG1->getOrginPort(g1Port, g1Slot);
+ pExistingG2->getOrginPort(g2Port, g2Slot);
+ const bool pairOk =
+ (g1Port == 0 && g2Port == 1) ||
+ (g1Port == 2 && g2Port == 3);
+ if (!pairOk) {
+ LOGW("<Master>%s閰嶅鎷︽埅锛氱鍙e涓嶅尮閰�(瑕佹眰1<->2鎴�3<->4, 瀹為檯G1Port=%d,G2Port=%d)銆�",
+ bonderName, g1Port + 1, g2Port + 1);
+ delete m_pActiveRobotTask;
+ m_pActiveRobotTask = nullptr;
+ return false;
+ }
+ }
+ return true;
+ };
+
// 5.5) 鏆傚仠鐘舵�佹鏌ワ細鑻� CJ 鎴栧湪鍒� PJ 澶勪簬 Paused锛屾殏缂撹皟搴︽柊鐨勬惉閫�
bool pausedByEvent = false;
if (m_pControlJob != nullptr && m_pControlJob->state() == CJState::Paused) {
@@ -1008,19 +1224,27 @@
// 缁勬暟闂ㄩ檺锛氣墺2 缁勬椂涓嶅啀浠� LP 涓婄墖锛岄伩鍏嶅爢绉紙涓庡崟鐗囦竴鑷达級
bool blockLoadFromLP = (nGlassGroup >= 2);
- // 7) Measurement -> LoadPort锛堝浐瀹氾細G1 浼樺厛鍥� LP锛�
+ // 7) Measurement -> LoadPort
if (rmd.armState[0] || rmd.armState[1]) {
LOGD("Arm1 %s, Arm2 %s.",
rmd.armState[0] ? _T("涓嶅彲鐢�") : _T("鍙敤"),
rmd.armState[1] ? _T("涓嶅彲鐢�") : _T("鍙敤"));
}
- for (int s = 0; s < 4; s++) {
- PortType pt = pLoadPorts[s]->getPortType();
- if (!rmd.armState[0] && pLoadPorts[s]->isEnable()
- && (pt == PortType::Unloading || pt == PortType::Both)
- && pLoadPorts[s]->getPortStatus() == PORT_INUSE) {
- m_pActiveRobotTask = createTransferTask(pMeasurement, pLoadPorts[s], MaterialsType::G1, secondaryType);
- if (m_pActiveRobotTask != nullptr) { goto BATCH_PORT_PUT; }
+ if (m_schedulingMode == SchedulingMode::Production) {
+ if (!rmd.armState[0]) {
+ m_pActiveRobotTask = createTransferTask_returnOrigin(pMeasurement, pLoadPorts);
+ CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
+ }
+ }
+ else {
+ for (int s = 0; s < 4; s++) {
+ PortType pt = pLoadPorts[s]->getPortType();
+ if (!rmd.armState[0] && pLoadPorts[s]->isEnable()
+ && (pt == PortType::Unloading || pt == PortType::Both)
+ && pLoadPorts[s]->getPortStatus() == PORT_INUSE) {
+ m_pActiveRobotTask = createTransferTask(pMeasurement, pLoadPorts[s], MaterialsType::G1, secondaryType);
+ if (m_pActiveRobotTask != nullptr) { goto BATCH_PORT_PUT; }
+ }
}
}
@@ -1070,10 +1294,16 @@
// 13) VacuumBake(G1) -> Bonder锛堟Ы绾у垽瀹氾細slot0(G2) 宸叉湁涓� slot1(G1) 涓虹┖锛�
if (!rmd.armState[0] && pBonder1->slotHasGlass(0) && !pBonder1->slotHasGlass(1)) {
m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder1, MaterialsType::G1, MaterialsType::G0);
+ if (m_pActiveRobotTask != nullptr && !validateBonderPairProcessJob(pBonder1, "Bonder1")) {
+ // 鍚� PJ 鏍¢獙澶辫触锛屾湰杞笉涓嬪彂鎼��
+ }
CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
}
if (!rmd.armState[0] && pBonder2->slotHasGlass(0) && !pBonder2->slotHasGlass(1)) {
m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder2, MaterialsType::G1, MaterialsType::G0);
+ if (m_pActiveRobotTask != nullptr && !validateBonderPairProcessJob(pBonder2, "Bonder2")) {
+ // 鍚� PJ 鏍¢獙澶辫触锛屾湰杞笉涓嬪彂鎼��
+ }
CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
}
@@ -1095,15 +1325,35 @@
// 16) LoadPort -> Aligner锛堝彈缁勬暟闂ㄩ檺鎺у埗锛涚粺涓� buddy/鐘舵�佹椂搴忥級
if (blockLoadFromLP) { unlock(); continue; }
+ const int preferredPortForPrimary = getPreferredPortForType(primaryType);
+ {
+ static int s_prevPrimaryType = -1;
+ static int s_prevPreferredPort = -2;
+ const int curPrimaryType = (int)primaryType;
+ if (s_prevPrimaryType != curPrimaryType || s_prevPreferredPort != preferredPortForPrimary) {
+ LOGI("<Master>LoadPort->Aligner瑙勫垯(RUNNING_BATCH): primaryType=%d, preferredPort=%d",
+ curPrimaryType, preferredPortForPrimary >= 0 ? (preferredPortForPrimary + 1) : 0);
+ s_prevPrimaryType = curPrimaryType;
+ s_prevPreferredPort = preferredPortForPrimary;
+ }
+ }
for (int s = 0; s < 4; s++) {
PortType pt = pLoadPorts[s]->getPortType();
if (!rmd.armState[0] && pLoadPorts[s]->isEnable()
&& (pt == PortType::Loading || pt == PortType::Both)
&& pLoadPorts[s]->getPortStatus() == PORT_INUSE) {
+ if (!isProductionPortTypeMatch(s, primaryType)) {
+ continue;
+ }
+ if (preferredPortForPrimary >= 0 && s != preferredPortForPrimary) {
+ continue;
+ }
m_pActiveRobotTask = createTransferTask(pLoadPorts[s], pAligner, primaryType, secondaryType, 1, m_bJobMode);
if (m_pActiveRobotTask != nullptr) {
+ LOGI("<Master>LoadPort->Aligner鍛戒腑(RUNNING_BATCH): port=%d, primaryType=%d, preferredPort=%d",
+ s + 1, (int)primaryType, preferredPortForPrimary >= 0 ? (preferredPortForPrimary + 1) : 0);
auto* pGlass = static_cast<CGlass*>(m_pActiveRobotTask->getContext());
if (pGlass->getBuddy() != nullptr) {
delete m_pActiveRobotTask; m_pActiveRobotTask = nullptr;
@@ -1682,12 +1932,36 @@
pGlass->setProcessJob(pj);
PJWarp& jpWarp = pj->getPjWarp();
+ int portIndex = -1;
+ switch (pPort->getID()) {
+ case EQ_ID_LOADPORT1: portIndex = 0; break;
+ case EQ_ID_LOADPORT2: portIndex = 1; break;
+ case EQ_ID_LOADPORT3: portIndex = 2; break;
+ case EQ_ID_LOADPORT4: portIndex = 3; break;
+ default: break;
+ }
+
+ BOOL scheduled = FALSE;
+ int material = 1; // G1
+ if (1 <= slot && slot <= 8) {
+ if (0 <= portIndex && portIndex <= 3 && jpWarp.selectedPorts[portIndex]) {
+ scheduled = jpWarp.checkSlots[portIndex][slot - 1];
+ material = jpWarp.materialSlots[portIndex][slot - 1];
+ }
+ else {
+ // Backward compatibility for legacy single-port PJWarp.
+ scheduled = jpWarp.checkSlot[slot - 1];
+ material = jpWarp.material[slot - 1];
+ }
+ }
+ material = (material == 2) ? 2 : 1;
+
int nRecipeID = RecipeManager::getInstance().getIdByPPID(pj->recipeSpec());
RecipeInfo stRecipeInfo = RecipeManager::getInstance().getRecipeByPPID(pj->recipeSpec());
std::vector<DeviceRecipe> vecRecipeInfo = stRecipeInfo.vecDeviceList;
- pGlass->setScheduledForProcessing(jpWarp.checkSlot[slot-1]);
- pGlass->setType(static_cast<SERVO::MaterialsType>(jpWarp.material[slot-1]));
+ pGlass->setScheduledForProcessing(scheduled);
+ pGlass->setType(static_cast<SERVO::MaterialsType>(material));
SERVO::CJobDataS* pJobDataS = pGlass->getJobDataS();
if (pJobDataS != nullptr) {
@@ -1695,7 +1969,7 @@
pJobDataS->setLotId(pj->getLotId().c_str());
pJobDataS->setProductId(pj->getProductId().c_str());
pJobDataS->setOperationId(pj->getOperationId().c_str());
- pJobDataS->setMaterialsType(jpWarp.material[slot - 1]);
+ pJobDataS->setMaterialsType(material);
pJobDataS->setMasterRecipe(nRecipeID);
for (const auto& info : vecRecipeInfo) {
const std::string& name = info.strDeviceName;
@@ -1928,6 +2202,16 @@
listener.onReceivedJob = [&](void* pEquipment, int port, CJobDataS* pJobDataS) {
if (m_listener.onJobReceived != nullptr) {
m_listener.onJobReceived(this, (CEquipment*)pEquipment, port, pJobDataS);
+ }
+ };
+ listener.onSentOutJob = [&](void* pEquipment, int port, CJobDataS* pJobDataS) {
+ if (m_listener.onJobSentOut != nullptr) {
+ m_listener.onJobSentOut(this, (CEquipment*)pEquipment, port, pJobDataS);
+ }
+ };
+ listener.onEqStatusChanged = [&](void* pEquipment, int unitId, int status, int reason) {
+ if (m_listener.onEqStatusChanged != nullptr) {
+ m_listener.onEqStatusChanged(this, (CEquipment*)pEquipment, unitId, status, reason);
}
};
pEquipment->setListener(listener);
@@ -2439,11 +2723,19 @@
nRet = pLoadPort1->getPin("Out")->connectPin(pAligner->getPin("In1"));
if (nRet < 0) {
- LOGE("杩炴帴LoadPort1-Fliper澶辫触");
+ LOGE("杩炴帴LoadPort1-Aligner澶辫触");
}
nRet = pLoadPort2->getPin("Out")->connectPin(pAligner->getPin("In2"));
if (nRet < 0) {
- LOGE("杩炴帴LoadPort1-Fliper澶辫触");
+ LOGE("杩炴帴LoadPort2-Aligner澶辫触");
+ }
+ nRet = pLoadPort3->getPin("Out")->connectPin(pAligner->getPin("In3"));
+ if (nRet < 0) {
+ LOGE("杩炴帴LoadPort3-Aligner澶辫触");
+ }
+ nRet = pLoadPort4->getPin("Out")->connectPin(pAligner->getPin("In4"));
+ if (nRet < 0) {
+ LOGE("杩炴帴LoadPort4-Aligner澶辫触");
}
nRet = pAligner->getPin("Out1")->connectPin(pFliper->getPin("In"));
@@ -2488,14 +2780,29 @@
LOGE("杩炴帴BakeCooling-LoadPort3澶辫触");
}
- nRet = pMeasurement->getPin("Out1")->connectPin(pLoadPort3->getPin("In"));
- if (nRet < 0) {
- LOGE("杩炴帴BakeCooling-LoadPort3澶辫触");
- }
+ if (m_schedulingMode == SchedulingMode::Production) {
+ // 鐢熶骇妯″紡锛氭祴閲忚緭鍑哄洖鍒� G1 鍘熶綅锛堥粯璁� Port1 / Port3锛�
+ nRet = pMeasurement->getPin("Out1")->connectPin(pLoadPort1->getPin("In"));
+ if (nRet < 0) {
+ LOGE("杩炴帴Measurement-LoadPort1澶辫触");
+ }
- nRet = pMeasurement->getPin("Out2")->connectPin(pLoadPort4->getPin("In"));
- if (nRet < 0) {
- LOGE("杩炴帴BakeCooling-LoadPort4澶辫触");
+ nRet = pMeasurement->getPin("Out2")->connectPin(pLoadPort3->getPin("In"));
+ if (nRet < 0) {
+ LOGE("杩炴帴Measurement-LoadPort3澶辫触");
+ }
+ }
+ else {
+ // 璋冩満妯″紡锛氱淮鎸佸師杩炴帴锛圤ut1->Port3, Out2->Port4锛�
+ nRet = pMeasurement->getPin("Out1")->connectPin(pLoadPort3->getPin("In"));
+ if (nRet < 0) {
+ LOGE("杩炴帴Measurement-LoadPort3澶辫触");
+ }
+
+ nRet = pMeasurement->getPin("Out2")->connectPin(pLoadPort4->getPin("In"));
+ if (nRet < 0) {
+ LOGE("杩炴帴Measurement-LoadPort4澶辫触");
+ }
}
}
@@ -2725,6 +3032,57 @@
return pTask;
}
+ CRobotTask* CMaster::createTransferTask_returnOrigin(CEquipment* pEqSrc, CLoadPort** pPorts)
+ {
+ if (!pEqSrc->IsEnabled()) {
+ return nullptr;
+ }
+
+ CSlot* pSrcSlot = pEqSrc->getProcessedSlot(MaterialsType::G1, m_bJobMode);
+ if (pSrcSlot == nullptr) {
+ return nullptr;
+ }
+
+ CGlass* pGlass = (CGlass*)pSrcSlot->getContext();
+ if (pGlass == nullptr) {
+ return nullptr;
+ }
+
+ int port = 0, slot = 0;
+ pGlass->getOrginPort(port, slot);
+ if (port < 0 || port >= 4 || slot < 0 || slot >= SLOT_MAX) {
+ return nullptr;
+ }
+
+ CLoadPort* pPort = pPorts[port];
+ if (pPort == nullptr || !pPort->isEnable()) {
+ return nullptr;
+ }
+ PortType pt = pPort->getPortType();
+ if (!(pt == PortType::Unloading || pt == PortType::Both)) {
+ return nullptr;
+ }
+ if (pPort->getPortStatus() != PORT_INUSE) {
+ return nullptr;
+ }
+
+ CSlot* pTarSlot = pPort->getSlot(slot);
+ if (pTarSlot == nullptr) {
+ return nullptr;
+ }
+ if (!pTarSlot->isEnable() || pTarSlot->isLock() || pTarSlot->getContext() != nullptr) {
+ return nullptr;
+ }
+
+ CRobotTask* pTask = new CRobotTask();
+ pTask->setContext(pSrcSlot->getContext());
+ pTask->setEFEM((CEFEM*)getEquipment(EQ_ID_EFEM));
+ taskSeqNo = pTask->setRobotTransferParam(taskSeqNo, 1, pSrcSlot->getPosition(),
+ pTarSlot->getPosition(), pSrcSlot->getNo(), pTarSlot->getNo());
+
+ return pTask;
+ }
+
CRobotTask* CMaster::createTransferTask_continuous_transfer(CEquipment* pSrcEq, int nSrcSlot,
CEquipment* pTarEq, int nTarSlot, int armNo/* = 1*/)
{
@@ -2834,6 +3192,19 @@
pPort->localSetCessetteType(type);
}
+ void CMaster::applySchedulingModePortMapping()
+ {
+ // 鐢熶骇妯″紡锛氬浐瀹� Port1/Port3 涓� G1锛孭ort2/Port4 涓� G2锛圙4 鏈畾涔夛紝鎸� G2 澶勭悊锛�
+ if (m_schedulingMode != SchedulingMode::Production) {
+ return;
+ }
+
+ setPortCassetteType(0, SERVO::CassetteType::G1);
+ setPortCassetteType(1, SERVO::CassetteType::G2);
+ setPortCassetteType(2, SERVO::CassetteType::G1);
+ setPortCassetteType(3, SERVO::CassetteType::G2);
+ }
+
void CMaster::setPortEnable(unsigned int index, BOOL bEnable)
{
ASSERT(index < 4);
@@ -2897,7 +3268,57 @@
static int pid[] = { EQ_ID_LOADPORT1, EQ_ID_LOADPORT2, EQ_ID_LOADPORT3, EQ_ID_LOADPORT4};
CLoadPort* pPort = (CLoadPort*)getEquipment(pid[port]);
- pPort->sendCassetteCtrlCmd(CCC_PROCESS_START, nullptr, 0, 0, 0, nullptr, nullptr);
+ if (pPort == nullptr) return -1;
+
+ short jobExistence[12] = { 0 };
+ short slotProcess = 0;
+ short jobCount = 0; // 0 = Process All Glass
+ bool anyScheduled = false;
+
+ // Prefer hardware scan map for job existence (first 16 slots).
+ const short scanMap = pPort->getScanCassetteMap();
+ if (scanMap != 0) {
+ jobExistence[0] = scanMap;
+ }
+
+ const int maxSlots = 12 * 16;
+ const int totalSlots = (SLOT_MAX < maxSlots) ? SLOT_MAX : maxSlots;
+ for (int slot = 1; slot <= totalSlots; ++slot) {
+ CGlass* pGlass = pPort->getGlassFromSlot(slot);
+ if (pGlass == nullptr) continue;
+
+ const int wordIndex = (slot - 1) / 16;
+ const int bitIndex = (slot - 1) % 16;
+ jobExistence[wordIndex] = (short)(jobExistence[wordIndex] | (1 << bitIndex));
+
+ if (slot <= 16 && pGlass->isScheduledForProcessing()) {
+ slotProcess = (short)(slotProcess | (1 << bitIndex));
+ anyScheduled = true;
+ }
+ }
+
+ if (!anyScheduled) {
+ slotProcess = jobExistence[0];
+ }
+
+ bool hasExistence = false;
+ for (short w : jobExistence) {
+ if (w != 0) { hasExistence = true; break; }
+ }
+ const int portStatus = pPort->getPortStatus();
+ if (!hasExistence) {
+ LOGE("ProcessStart blocked (ProceedWithCarrier): no JobExistence map (port=%u, portStatus=%d, scanMap=%d, cassetteId=%s).",
+ port + 1, portStatus, scanMap, pPort->getCassetteId().c_str());
+ return -2;
+ }
+ if (portStatus != PORT_INUSE) {
+ LOGW("ProcessStart warning (ProceedWithCarrier): port status is %d (expected INUSE).", portStatus);
+ }
+ LOGI("ProcessStart payload (ProceedWithCarrier): port=%u, cassetteId=%s, scanMap=%d, jobExistence0=%d, jobExistence1=%d, slotProcess=%d, anyScheduled=%d",
+ port + 1, pPort->getCassetteId().c_str(), scanMap,
+ (int)jobExistence[0], (int)jobExistence[1], (int)slotProcess, anyScheduled ? 1 : 0);
+
+ pPort->sendCassetteCtrlCmd(CCC_PROCESS_START, jobExistence, 12, slotProcess, jobCount, nullptr, nullptr);
return 0;
}
@@ -3485,6 +3906,11 @@
}
m_pControlJob->abort(description);
+ // 鍏堜笂鎶ヤ竴娆$姸鎬佸彉鍖栵紙渚夸簬 PrJobAbort 瑙﹀彂锛�
+ if (m_listener.onControlJobChanged) {
+ notifyControlJobChanged();
+ }
+
// 閲婃斁Job鐩稿叧
for (auto item : m_processJobs) {
--
Gitblit v1.9.3