| | |
| | | #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; |
| | |
| | | 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) |
| | |
| | | // 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); |
| | |
| | | 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); |
| | |
| | | // 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) |
| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | 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) |
| | |
| | | return nullptr; |
| | | } |
| | | |
| | | CSlot* CEquipment::getProcessedSlot(MaterialsType putSlotType) |
| | | CSlot* CEquipment::getProcessedSlot(MaterialsType putSlotType, BOOL bJobMode/* = FALSE*/) |
| | | { |
| | | for (int i = 0; i < SLOT_MAX; i++) { |
| | | if (!m_slot[i].isEnable()) continue; |
| | |
| | | CGlass* pGlass = (CGlass*)m_slot[i].getContext(); |
| | | if (!isSlotProcessed(i)) continue; |
| | | if (pGlass == nullptr) continue; |
| | | if (!pGlass->isScheduledForProcessing()) continue; |
| | | if (bJobMode && pGlass->getProcessJob() == nullptr) 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] |
| | |
| | | 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; |
| | |
| | | |
| | | if (pSlot == nullptr) return -1; |
| | | pSlot->setContext(nullptr); |
| | | if (m_listener.onDataChanged != nullptr) { |
| | | m_listener.onDataChanged(this, EDCC_FETCHOUT_JOB); |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | |
| | | int CEquipment::decodeVCREventReport(CStep* pStep, const char* pszData, size_t size) |
| | | { |
| | | CVcrEventReport vcrEventReport; |
| | | vcrEventReport.unserialize(pszData, size); |
| | | vcrEventReport.unserialize(pszData, (int)size); |
| | | LOGI("<CEquipment-%s>decodeVCREventReport<Result:%d, GlassId:%s>\n", m_strName.c_str(), |
| | | vcrEventReport.getVcrResult(), |
| | | vcrEventReport.getGlassId().c_str()); |
| | |
| | | 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; |
| | | |
| | | |
| | |
| | | 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; |
| | | } |
| | |
| | | */ |
| | | int CEquipment::onSendAble(int port) |
| | | { |
| | | LOGI("<CEquipment-%s>onSendAble.port:%d", m_strName.c_str(), port); |
| | | // LOGI("<CEquipment-%s>onSendAble.port:%d", m_strName.c_str(), port); |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | int CEquipment::onReceiveAble(int port) |
| | | { |
| | | LOGI("<CEquipment-%s>onReceiveAble.port:%d", m_strName.c_str(), port); |
| | | // LOGI("<CEquipment-%s>onReceiveAble.port:%d", m_strName.c_str(), port); |
| | | |
| | | return 0; |
| | | } |
| | |
| | | ); |
| | | } |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | } |