SourceCode/Bond/Servo/CMaster.cpp
@@ -506,13 +506,11 @@
            }
            
            // 检查看是否都已经切换到START状态
            /*
            if (!bIomcOk[6]) {
               unlock();
               setState(MASTERSTATE::MSERROR);
               continue;
            }
            */
            unlock();
            if(m_bContinuousTransfer)
@@ -597,52 +595,62 @@
            }
            // 此处检测优先类型和次要类型(G1或G2)
            // 如果其中一Bonder有单个玻璃,优先取它的配对类型,否则无所谓了
            primaryType = MaterialsType::G2;
            secondaryType = MaterialsType::G1;
            // Bonder1、Bonder2、Fliper、VacuumBake、Aligner,统计G2和G1的数量, 配对组数, 多出的类型
            int nG2Count = 0, nG1Count = 0, nGlassGroup, nExtraType;
            if (pBonder1->slotHasGlass(0)) {
               nG2Count++;
            }
            if (pBonder1->slotHasGlass(1)) {
               nG1Count++;
            }
            if (pBonder2->slotHasGlass(0)) {
               nG2Count++;
            }
            if (pBonder2->slotHasGlass(1)) {
               nG1Count++;
            }
            if (!pBonder1->canPlaceGlassInSlot(0) && pBonder1->canPlaceGlassInSlot(1)) {
               // 如果Bonder1有G2了,则取G1
               primaryType = MaterialsType::G1;
               secondaryType = MaterialsType::G0;
            if (pFliper->slotHasGlass(0)) {
               nG2Count++;
            }
            else if (!pBonder2->canPlaceGlassInSlot(0) && pBonder2->canPlaceGlassInSlot(1)) {
               // 如果Bonder2有G2了,则取G1
               primaryType = MaterialsType::G1;
               secondaryType = MaterialsType::G0;
            if (pVacuumBake->slotHasGlass(0)) {
               nG1Count++;
            }
            else if (!pFliper->canPlaceGlassInSlot(0)) {
               primaryType = MaterialsType::G1;
               secondaryType = MaterialsType::G0;
            if (pVacuumBake->slotHasGlass(1)) {
               nG1Count++;
            }
            else if (pBonder1->canPlaceGlassInSlot(0)) {
               // 如果Bonder1没有G2, 则先G2
               primaryType = MaterialsType::G2;
               secondaryType = MaterialsType::G0;
            CGlass* pTempGlass = pAligner->getGlassFromSlot(0);
            if (pTempGlass != nullptr) {
               MaterialsType type = pTempGlass->getType();
               if(type == MaterialsType::G1)
                  nG1Count++;
               else if (type == MaterialsType::G2)
                  nG2Count++;
            }
            else if (pBonder2->canPlaceGlassInSlot(0)) {
               // 如果Bonder2没有G2, 则先G2
               primaryType = MaterialsType::G2;
               secondaryType = MaterialsType::G0;
            nGlassGroup = min(nG1Count, nG2Count);
            if (nG1Count == nG2Count) {
               nExtraType = 0;
            }
            else if (nG1Count > nG2Count) {
               nExtraType = 1;
            }
            else {
               primaryType = MaterialsType::G2;
               secondaryType = MaterialsType::G0;
               nExtraType = 2;
            }
            secondaryType = MaterialsType::G0;
            // Measurement -> LoadPort
            if (rmd.armState[0] || rmd.armState[1]) {
               LOGI("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], primaryType, secondaryType);
                  m_pActiveRobotTask = createTransferTask(pMeasurement, pLoadPorts[s], MaterialsType::G1, secondaryType);
                  if (m_pActiveRobotTask != nullptr) {
                     goto PORT_PUT;
                  }
@@ -689,29 +697,29 @@
            // Fliper(G2) -> Bonder
            auto pSrcSlot = pVacuumBake->getProcessedSlot(primaryType);
            //LOGI("<Master>pSrcSlot = %x, primaryType:%d", pSrcSlot, primaryType);
            //m_nTestFlag = 1;
            //pVacuumBake->m_nTestFlag = 1;
            auto pSrcSlot = pVacuumBake->getProcessedSlot(MaterialsType::G1);
            //LOGI("<Master>pSrcSlot = %x", pSrcSlot,);
            if (pSrcSlot != nullptr && !rmd.armState[1]
               && pBonder1->canPlaceGlassInSlot(0)
               && !pBonder1->hasBondClass()) {
               && pBonder1->canPlaceGlassInSlot(0)) {
               m_pActiveRobotTask = createTransferTask(pFliper, pBonder1, MaterialsType::G2, MaterialsType::G0, 2);
               CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
            }
            if (pSrcSlot != nullptr && !rmd.armState[1] 
               && pBonder2->canPlaceGlassInSlot(0)
               && !pBonder2->hasBondClass()) {
               && pBonder2->canPlaceGlassInSlot(0)) {
               m_pActiveRobotTask = createTransferTask(pFliper, pBonder2, MaterialsType::G2, MaterialsType::G0, 2);
               CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
            }
            //m_nTestFlag = 0
               ;
            // VacuumBake(G1) -> Bonder
            if (!rmd.armState[0] && !pBonder1->hasBondClass()) {
            if (!rmd.armState[0] && pBonder1->slotHasGlass(0) && !pBonder1->slotHasGlass(1)) {
               m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder1, MaterialsType::G1, MaterialsType::G0);
               CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
            }
            if (!rmd.armState[0] && !pBonder2->hasBondClass()) {
            if (!rmd.armState[0] && pBonder2->slotHasGlass(0) && !pBonder2->slotHasGlass(1)) {
               m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder2, MaterialsType::G1, MaterialsType::G0);
               CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
            }
@@ -720,14 +728,14 @@
            // Aligner -> Fliper(G2)
            // Aligner -> VacuumBake(G1)
            if (!rmd.armState[1]) {
               m_pActiveRobotTask = createTransferTask(pAligner, pFliper, primaryType, secondaryType);
               m_pActiveRobotTask = createTransferTask(pAligner, pFliper, MaterialsType::G2, secondaryType);
               CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
            }
            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);
               if (m_nTestFlag == 1) LOGI("createTransferTask 004df %d, %d", MaterialsType::G1, secondaryType);
               m_pActiveRobotTask = createTransferTask(pAligner, pVacuumBake, MaterialsType::G1, secondaryType);
               CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
               m_nTestFlag = 0;
            }
@@ -741,6 +749,17 @@
            // LoadPort -> Aligner
            if (nGlassGroup >= 2) {
               unlock();
               continue;
            }
            if(nExtraType == 0)
               primaryType = MaterialsType::G2;
            else {
               primaryType = MaterialsType::G1;
            }
            for (int s = 0; s < 4; s++) {
               PortType pt = pLoadPorts[s]->getPortType();
               if (!rmd.armState[0] && pLoadPorts[s]->isEnable()
@@ -917,23 +936,23 @@
            // Fliper(G2) -> Bonder
            auto pSrcSlot = pVacuumBake->getProcessedSlot(primaryType);
            if (pSrcSlot != nullptr && !rmd.armState[1] && !pBonder1->hasBondClass()) {
            if (pSrcSlot != nullptr && !rmd.armState[1] && !pBonder1->hasBondGlass()) {
               m_pActiveRobotTask = createTransferTask(pFliper, pBonder1, primaryType, secondaryType, 2);
               CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
            }
            if (pSrcSlot != nullptr && !rmd.armState[1] && !pBonder2->hasBondClass()) {
            if (pSrcSlot != nullptr && !rmd.armState[1] && !pBonder2->hasBondGlass()) {
               m_pActiveRobotTask = createTransferTask(pFliper, pBonder2, primaryType, secondaryType, 2);
               CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
            }
            // VacuumBake(G1) -> Bonder
            if (!rmd.armState[0] && !pBonder1->hasBondClass()) {
            if (!rmd.armState[0] && !pBonder1->hasBondGlass()) {
               m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder1, primaryType, secondaryType);
               CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
            }
            if (!rmd.armState[0] && !pBonder2->hasBondClass()) {
            if (!rmd.armState[0] && !pBonder2->hasBondGlass()) {
               m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder2, primaryType, secondaryType);
               CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
            }
@@ -1123,7 +1142,7 @@
            
            // Bonder1 -> Bonder2
            if ((m_nContinuousTransferStep == CTStep_Unknow || m_nContinuousTransferStep == CTStep_Fliper_Bonder1)
               && !rmd.armState[0] && !pBonder2->hasBondClass()) {
               && !rmd.armState[0] && !pBonder2->hasBondGlass()) {
               m_pActiveRobotTask = createTransferTask_continuous_transfer(pBonder1,
                  1, pBonder2, 1);
               if (m_pActiveRobotTask != nullptr) {
@@ -1135,7 +1154,7 @@
            // Fliper(G2) -> Bonder1
            if ((m_nContinuousTransferStep == CTStep_Unknow || m_nContinuousTransferStep == CTStep_Aligner_Fliper)
               &&!rmd.armState[0] && !pBonder1->hasBondClass()) {
               &&!rmd.armState[0] && !pBonder1->hasBondGlass()) {
               m_pActiveRobotTask = createTransferTask_continuous_transfer(pFliper,
                  0, pBonder1, 1);
               if (m_pActiveRobotTask != nullptr) {