| | |
| | | m_nContinuousTransferCount = 0; |
| | | m_nContinuousTransferStep = CTStep_Unknow; |
| | | m_pControlJob = nullptr; |
| | | m_nTestFlag = 0; |
| | | InitializeCriticalSection(&m_criticalSection); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // 检查看是否都已经切换到START状态 |
| | | /* |
| | | if (!bIomcOk[6]) { |
| | | unlock(); |
| | | setState(MASTERSTATE::MSERROR); |
| | | continue; |
| | | } |
| | | */ |
| | | |
| | | unlock(); |
| | | if(m_bContinuousTransfer) |
| | |
| | | } |
| | | |
| | | |
| | | // 此处检测优先类型和次要类型(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; |
| | | // Bonder1、Bonder2、Fliper、VacuumBake、Aligner,统计G2和G1的数量, 配对组数, 多出的类型 |
| | | int nG2Count = 0, nG1Count = 0, nGlassGroup, nExtraType; |
| | | if (pBonder1->slotHasGlass(0)) { |
| | | nG2Count++; |
| | | } |
| | | if (pBonder1->slotHasGlass(1)) { |
| | | nG1Count++; |
| | | } |
| | | else if ((pBonder1->canPlaceGlassInSlot(0) && !pBonder1->canPlaceGlassInSlot(1)) |
| | | || (pBonder2->canPlaceGlassInSlot(0) && !pBonder2->canPlaceGlassInSlot(1))) { |
| | | primaryType = MaterialsType::G2; |
| | | secondaryType = MaterialsType::G1; |
| | | |
| | | if (pBonder2->slotHasGlass(0)) { |
| | | nG2Count++; |
| | | } |
| | | if (pBonder2->slotHasGlass(1)) { |
| | | nG1Count++; |
| | | } |
| | | |
| | | if (pFliper->slotHasGlass(0)) { |
| | | nG2Count++; |
| | | } |
| | | |
| | | if (pVacuumBake->slotHasGlass(0)) { |
| | | nG1Count++; |
| | | } |
| | | if (pVacuumBake->slotHasGlass(1)) { |
| | | nG1Count++; |
| | | } |
| | | |
| | | CGlass* pTempGlass = pAligner->getGlassFromSlot(0); |
| | | if (pTempGlass != nullptr) { |
| | | MaterialsType type = pTempGlass->getType(); |
| | | if(type == MaterialsType::G1) |
| | | nG1Count++; |
| | | else if (type == MaterialsType::G2) |
| | | nG2Count++; |
| | | } |
| | | nGlassGroup = min(nG1Count, nG2Count); |
| | | |
| | | if (nG1Count == nG2Count) { |
| | | nExtraType = 0; |
| | | } |
| | | else if (nG1Count > nG2Count) { |
| | | nExtraType = 1; |
| | | } |
| | | else { |
| | | 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; |
| | | } |
| | |
| | | |
| | | |
| | | // Fliper(G2) -> Bonder |
| | | auto pSrcSlot = pVacuumBake->getProcessedSlot(primaryType); |
| | | if (pSrcSlot != nullptr && !rmd.armState[1] && !pBonder1->hasBondClass()) { |
| | | m_pActiveRobotTask = createTransferTask(pFliper, pBonder1, primaryType, secondaryType, 2); |
| | | //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)) { |
| | | 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)) { |
| | | 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()) { |
| | | m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder1, primaryType, secondaryType); |
| | | 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()) { |
| | | m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder2, primaryType, secondaryType); |
| | | 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); |
| | | } |
| | | |
| | |
| | | // 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_pActiveRobotTask = createTransferTask(pAligner, pVacuumBake, primaryType, secondaryType); |
| | | // m_nTestFlag = 1; |
| | | 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; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | // 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() |
| | |
| | | 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已经恢复运行"); |
| | |
| | | |
| | | // 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); |
| | | } |
| | |
| | | else { |
| | | LOGE("<Master>Glass(%s)从等待列队到工艺列队转移失败.", |
| | | pGlass->getID().c_str()); |
| | | } |
| | | |
| | | // 这里上报Panel Start事件 |
| | | if (m_listener.onPanelStart != nullptr) { |
| | | m_listener.onPanelStart(this, pGlass); |
| | | } |
| | | |
| | | goto BATCH_PORT_GET; |
| | |
| | | |
| | | // 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) { |
| | |
| | | |
| | | // 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) { |
| | |
| | | if (pGlass == nullptr) { |
| | | bOk = TRUE; |
| | | slot = m_pActiveRobotTask->getTarSlot(); |
| | | LOGI("<CMaster>onPreFethedOutJob, 已校验数据一致性."); |
| | | LOGI("<CMaster>onPreStoredJob, 已校验数据一致性."); |
| | | } |
| | | } |
| | | |
| | |
| | | if (pGlass == nullptr && m_pActiveRobotTask->getSrcSlot() == port) { |
| | | bOk = TRUE; |
| | | slot = m_pActiveRobotTask->getSrcSlot(); |
| | | LOGI("<CMaster>onPreFethedOutJob, 已校验数据一致性."); |
| | | LOGI("<CMaster>onPreStoredJob, 已校验数据一致性."); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (m_pActiveRobotTask->getSrcPosition() == EQ_ID_MEASUREMENT) { |
| | | CGlass* pGlass = (CGlass*)m_pActiveRobotTask->getContext(); |
| | | pGlass->complete(); |
| | | this->saveState(); |
| | | bool bMoved = glassFromInPorcessToComplete(pGlass); |
| | | if (bMoved) { |
| | | LOGI("<Master>Glass(%s)从工艺列队到完成列队转移成功.", |
| | |
| | | LOGE("<Master>Glass(%s)从工艺列队到完成列队转移失败.", |
| | | pGlass->getID().c_str()); |
| | | } |
| | | if (m_listener.onPanelEnd != nullptr) { |
| | | m_listener.onPanelEnd(this, pGlass); |
| | | } |
| | | |
| | | // 检查PJ是否已经完成 |
| | | CProcessJob* pJob = getGlassProcessJob((CGlass*)m_pActiveRobotTask->getContext()); |
| | | if (pJob != nullptr && checkAndUpdatePjComplete(pJob)) { |
| | | this->saveState(); |
| | | LOGE("<Master>ProcessJob(%s)完成.", |
| | | pJob->id().c_str()); |
| | | if (m_listener.onPjEnd != nullptr) { |
| | | m_listener.onPjEnd(this, pJob); |
| | | } |
| | | |
| | | // 检查CJ是否已经完成 |
| | | ASSERT(m_pControlJob); |
| | | if (checkAndUpdateCjComplete(m_pControlJob)) { |
| | | this->saveState(); |
| | | LOGE("<Master>ControlJob(%s)完成.", |
| | | m_pControlJob->id().c_str()); |
| | | if (m_listener.onCjEnd != nullptr) { |
| | | m_listener.onCjEnd(this, pJob); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | // 模拟测试 |
| | | /* |
| | | static int aaa = 0; |
| | | aaa++; |
| | | if (aaa % 30 == 0) { |
| | |
| | | CGlass* pGlass = m_queueGlasses.front(); |
| | | pGlass->start(); |
| | | glassFromQueueToInPorcess(pGlass); |
| | | this->saveState(); |
| | | |
| | | // 这里上报Panel Start事件 |
| | | if (m_listener.onPanelStart != nullptr) { |
| | | m_listener.onPanelStart(this, pGlass); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | CGlass* pGlass = m_inProcesGlasses.front(); |
| | | pGlass->complete(); |
| | | glassFromInPorcessToComplete(pGlass); |
| | | this->saveState(); |
| | | |
| | | // 这里上报Panel End事件 |
| | | if (m_listener.onPanelEnd != nullptr) { |
| | | m_listener.onPanelEnd(this, pGlass); |
| | | } |
| | | |
| | | CProcessJob* pJob = getGlassProcessJob(pGlass); |
| | | if (pJob != nullptr && checkAndUpdatePjComplete(pJob)) { |
| | | processJobFromInPorcessToComplete(pJob); |
| | | this->saveState(); |
| | | LOGE("<Master>ProcessJob(%s)完成.", |
| | | pJob->id().c_str()); |
| | | if (m_listener.onPjEnd != nullptr) { |
| | | m_listener.onPjEnd(this, pJob); |
| | | } |
| | | |
| | | // 检查CJ是否已经完成 |
| | | ASSERT(m_pControlJob); |
| | | if (checkAndUpdateCjComplete(m_pControlJob)) { |
| | | this->saveState(); |
| | | LOGE("<Master>ControlJob(%s)完成.", |
| | | m_pControlJob->id().c_str()); |
| | | if (m_listener.onCjEnd != nullptr) { |
| | | m_listener.onCjEnd(this, pJob); |
| | | } |
| | | } |
| | | } |
| | | */ |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | void CMaster::connectEquipments() |
| | |
| | | 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(); |
| | |
| | | for (const auto pj : pjs) { |
| | | if (pj->state() == PJState::Queued) { |
| | | pj->start(); |
| | | } |
| | | return pj; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | return false; |
| | | } |
| | | |
| | | bool CMaster::processJobFromInPorcessToComplete(CProcessJob* pProcessJob) |
| | | { |
| | | auto it = std::find(m_inProcesJobs.begin(), m_inProcesJobs.end(), pProcessJob); |
| | | if (it != m_inProcesJobs.end()) { |
| | | m_completeProcessJobs.push_back(*it); |
| | | m_inProcesJobs.erase(it); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | bool CMaster::checkAndUpdatePjComplete(CProcessJob* pJob) |
| | | { |
| | | ASSERT(pJob); |
| | |
| | | |
| | | for (auto c : pJob->carriers()) { |
| | | for (auto g : c.contexts) { |
| | | CGlass* pGlass = (CGlass*)g; |
| | | if (pGlass->state() != GlsState::Aborted |
| | | && pGlass->state() != GlsState::Completed |
| | | && pGlass->state() != GlsState::Failed) return false; |
| | | auto state = ((CGlass*)g)->state(); |
| | | if (state != GlsState::Aborted && state != GlsState::Completed |
| | | && state != GlsState::Failed) return false; |
| | | } |
| | | } |
| | | |
| | | return pJob->complete(); |
| | | } |
| | | |
| | | bool CMaster::checkAndUpdateCjComplete(CControlJob* pJob) |
| | | { |
| | | ASSERT(pJob); |
| | | auto state = pJob->state(); |
| | | if (state != CJState::Executing && state != CJState::Paused) return false; |
| | | |
| | | for (auto pj : pJob->getPjs()) { |
| | | auto state = pj->state(); |
| | | if (state != PJState::Aborted && state != PJState::Completed |
| | | && state != PJState::Failed) { |
| | | return false; |
| | | } |
| | | } |
| | | |