LAPTOP-SNT8I5JK\Boounion
2025-08-27 38f2ff1e5bc6c4434875e03b8cadc8f3f4e39bf6
SourceCode/Bond/Servo/CMaster.cpp
@@ -63,6 +63,7 @@
      m_nContinuousTransferCount = 0;
      m_nContinuousTransferStep = CTStep_Unknow;
      m_pControlJob = nullptr;
      m_nTestFlag = 0;
      InitializeCriticalSection(&m_criticalSection);
   }
@@ -598,23 +599,38 @@
            // 此处检测优先类型和次要类型(G1或G2)
            // 如果其中一Bonder有单个玻璃,优先取它的配对类型,否则无所谓了
            primaryType = MaterialsType::G1;
            secondaryType = MaterialsType::G2;
            if ((!pBonder1->canPlaceGlassInSlot(0) && !pBonder1->canPlaceGlassInSlot(1))
               && (!pBonder2->canPlaceGlassInSlot(0) && !pBonder2->canPlaceGlassInSlot(1))) {
               // 如果G1和G2都满了,那就看Aligner, 如果Aligner有玻璃为G1, 则取G2
               CGlass* pGlass = pAligner->getGlassFromSlot(1);
               if (pGlass != nullptr && pGlass->getType() == MaterialsType::G1) {
                  primaryType = MaterialsType::G2;
                  secondaryType = MaterialsType::G1;
               }
            }
            else if ((pBonder1->canPlaceGlassInSlot(0) && !pBonder1->canPlaceGlassInSlot(1))
               || (pBonder2->canPlaceGlassInSlot(0) && !pBonder2->canPlaceGlassInSlot(1))) {
               primaryType = MaterialsType::G2;
               secondaryType = MaterialsType::G1;
            }
            primaryType = MaterialsType::G2;
            secondaryType = MaterialsType::G1;
            if (!pBonder1->canPlaceGlassInSlot(0) && pBonder1->canPlaceGlassInSlot(1)) {
               // 如果Bonder1有G2了,则取G1
               primaryType = MaterialsType::G1;
               secondaryType = MaterialsType::G0;
            }
            else if (!pBonder2->canPlaceGlassInSlot(0) && pBonder2->canPlaceGlassInSlot(1)) {
               // 如果Bonder2有G2了,则取G1
               primaryType = MaterialsType::G1;
               secondaryType = MaterialsType::G0;
            }
            else if (!pFliper->canPlaceGlassInSlot(0)) {
               primaryType = MaterialsType::G1;
               secondaryType = MaterialsType::G0;
            }
            else if (pBonder1->canPlaceGlassInSlot(0)) {
               // 如果Bonder1没有G2, 则先G2
               primaryType = MaterialsType::G2;
               secondaryType = MaterialsType::G0;
            }
            else if (pBonder2->canPlaceGlassInSlot(0)) {
               // 如果Bonder2没有G2, 则先G2
               primaryType = MaterialsType::G2;
               secondaryType = MaterialsType::G0;
            }
            else {
               primaryType = MaterialsType::G2;
               secondaryType = MaterialsType::G0;
            }
            // Measurement -> LoadPort
            if (rmd.armState[0] || rmd.armState[1]) {
@@ -674,24 +690,29 @@
            // Fliper(G2) -> Bonder
            auto pSrcSlot = pVacuumBake->getProcessedSlot(primaryType);
            if (pSrcSlot != nullptr && !rmd.armState[1] && !pBonder1->hasBondClass()) {
               m_pActiveRobotTask = createTransferTask(pFliper, pBonder1, primaryType, secondaryType, 2);
            //LOGI("<Master>pSrcSlot = %x, primaryType:%d", pSrcSlot, primaryType);
            if (pSrcSlot != nullptr && !rmd.armState[1]
               && pBonder1->canPlaceGlassInSlot(0)
               && !pBonder1->hasBondClass()) {
               m_pActiveRobotTask = createTransferTask(pFliper, pBonder1, MaterialsType::G2, MaterialsType::G0, 2);
               CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
            }
            if (pSrcSlot != nullptr && !rmd.armState[1] && !pBonder2->hasBondClass()) {
               m_pActiveRobotTask = createTransferTask(pFliper, pBonder2, primaryType, secondaryType, 2);
            if (pSrcSlot != nullptr && !rmd.armState[1]
               && pBonder2->canPlaceGlassInSlot(0)
               && !pBonder2->hasBondClass()) {
               m_pActiveRobotTask = createTransferTask(pFliper, pBonder2, MaterialsType::G2, MaterialsType::G0, 2);
               CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
            }
            // VacuumBake(G1) -> Bonder
            if (!rmd.armState[0] && !pBonder1->hasBondClass()) {
               m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder1, primaryType, secondaryType);
               m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder1, MaterialsType::G1, MaterialsType::G0);
               CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
            }
            if (!rmd.armState[0] && !pBonder2->hasBondClass()) {
               m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder2, primaryType, secondaryType);
               m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder2, MaterialsType::G1, MaterialsType::G0);
               CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
            }
@@ -704,8 +725,11 @@
            }
            if (!rmd.armState[0]) {
               // m_nTestFlag = 1;
               if (m_nTestFlag == 1) LOGI("createTransferTask 004df %d, %d", primaryType, secondaryType);
               m_pActiveRobotTask = createTransferTask(pAligner, pVacuumBake, primaryType, secondaryType);
               CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
               m_nTestFlag = 0;
            }
@@ -761,6 +785,10 @@
            if (m_pControlJob->state() == CJState::Queued) {
               LOGI("<Master>ControlJob已经启动");
               m_pControlJob->start();
               if (m_listener.onCjStart != nullptr) {
                  m_listener.onCjStart(this, m_pControlJob);
               }
            }
            if (m_pControlJob->state() == CJState::Paused) {
               LOGI("<Master>ControlJob已经恢复运行");
@@ -1315,7 +1343,7 @@
               if (pGlass == nullptr) {
                  bOk = TRUE;
                  slot = m_pActiveRobotTask->getTarSlot();
                  LOGI("<CMaster>onPreFethedOutJob, 已校验数据一致性.");
                  LOGI("<CMaster>onPreStoredJob, 已校验数据一致性.");
               }
            }
@@ -1326,7 +1354,7 @@
               if (pGlass == nullptr && m_pActiveRobotTask->getSrcSlot() == port) {
                  bOk = TRUE;
                  slot = m_pActiveRobotTask->getSrcSlot();
                  LOGI("<CMaster>onPreFethedOutJob, 已校验数据一致性.");
                  LOGI("<CMaster>onPreStoredJob, 已校验数据一致性.");
               }
            }
         }
@@ -1925,16 +1953,17 @@
      if (!pSrcEq->IsEnabled()) { 
         return nullptr;
      }
      CRobotTask* pTask = nullptr;
      CSlot* pSrcSlot, * pTarSlot;
      pSrcEq->m_nTestFlag = m_nTestFlag;
      pTarSlot = pTarEq->getAvailableSlotForGlass(primaryType);
      pSrcSlot = pSrcEq->getProcessedSlot(primaryType, bJobMode);
      if (pSrcSlot == nullptr || nullptr == pTarSlot) {
      if (m_nTestFlag == 1) LOGI("createTransferTask 003 %x, %x", pTarSlot, pSrcSlot);
      if (pSrcSlot == nullptr || nullptr == pTarSlot && secondaryType != SERVO::MaterialsType::G0) {
         pTarSlot = pTarEq->getAvailableSlotForGlass(secondaryType);
         pSrcSlot = pSrcEq->getProcessedSlot(secondaryType, bJobMode);
      }
      if (m_nTestFlag == 1) LOGI("createTransferTask 004 %x, %x", pTarSlot, pSrcSlot);
      if (pSrcSlot != nullptr && nullptr != pTarSlot) {
         pTask = new CRobotTask();