| | |
| | | #include "stdafx.h" |
| | | #include "stdafx.h" |
| | | #include "CLoadPort.h" |
| | | #include "CGlassPool.h" |
| | | #include "Servo.h" |
| | |
| | | m_bAutoChangeEnable = FALSE; |
| | | m_nNextCassetteSequenceNo = 0; |
| | | m_isCompareMapsBeforeProceeding = FALSE; |
| | | m_downloadCassetteMap = 0; |
| | | } |
| | | |
| | | CLoadPort::~CLoadPort() |
| | |
| | | CEquipment::term(); |
| | | } |
| | | |
| | | // 必须要实现的虚函数,在此初始化Pin列表 |
| | | // 必须要实现的虚函数,在此初始化Pin列表 |
| | | void CLoadPort::initPins() |
| | | { |
| | | // 加入Pin初始化代码 |
| | | LOGI("<CLoadPort>initPins"); |
| | | // 加入Pin初始化代码 |
| | | LOGD("<CLoadPort>initPins"); |
| | | addPin(SERVO::PinType::INPUT, _T("In")); |
| | | addPin(SERVO::PinType::OUTPUT, _T("Out")); |
| | | } |
| | | |
| | | // 必须要实现的虚函数,在此初始化Slot信息 |
| | | // 必须要实现的虚函数,在此初始化Slot信息 |
| | | void CLoadPort::initSlots() |
| | | { |
| | | for (int i = 0; i < SLOT_MAX; i++) { |
| | |
| | | CEquipment::onTimer(nTimerid); |
| | | |
| | | |
| | | // 从配置读出的enable,初始化时写给efem |
| | | // 从配置读出的enable,初始化时写给efem |
| | | static int i_enable[4] = { 0 }; |
| | | if ((++i_enable[m_nIndex]) == 10 + m_nIndex) { |
| | | if ((++i_enable[m_nIndex]) == 20 + m_nIndex) { |
| | | eablePort(m_bEnable, [&](int code) -> int { |
| | | LOGI("<LoadPort-%d>eablePort:code=%d", m_nIndex, code); |
| | | return 0; |
| | |
| | | |
| | | |
| | | |
| | | // 模拟测试 |
| | | // 模拟测试 |
| | | /* |
| | | if (m_nIndex == 0) { |
| | | static int ii = 0; |
| | | ii++; |
| | | if (ii == 50) { |
| | | char szBuffer[64] = {0}; |
| | | CStep* pStep = getStepWithName(STEP_EQ_PORT1_INUSE); |
| | | CStep* pStep = getStepWithName(STEP_EQ_PORT1_BLOCKED); |
| | | CPortStatusReport portStatusReport; |
| | | portStatusReport.setPortStatus(PORT_INUSE); |
| | | portStatusReport.setPortStatus(PORT_BLOCKED); |
| | | portStatusReport.setJobExistenceSlot(0xf); |
| | | portStatusReport.setCassetteId("CID1001"); |
| | | int nRet = portStatusReport.serialize(szBuffer, 64); |
| | | decodePortStatusReport(pStep, szBuffer, 64); |
| | | LOGI("<CLoadPort>Port1载入模拟数据, id:CID1001 map: 0xf"); |
| | | } |
| | | } |
| | | if (m_nIndex == 1) { |
| | |
| | | ii++; |
| | | if (ii == 55) { |
| | | char szBuffer[64] = { 0 }; |
| | | CStep* pStep = getStepWithName(STEP_EQ_PORT1_INUSE); |
| | | CStep* pStep = getStepWithName(STEP_EQ_PORT2_BLOCKED); |
| | | CPortStatusReport portStatusReport; |
| | | portStatusReport.setPortStatus(PORT_INUSE); |
| | | portStatusReport.setJobExistenceSlot(0xf); |
| | | portStatusReport.setPortStatus(PORT_BLOCKED); |
| | | portStatusReport.setJobExistenceSlot(0xff ); |
| | | portStatusReport.setCassetteId("CID1004"); |
| | | int nRet = portStatusReport.serialize(szBuffer, 64); |
| | | decodePortStatusReport(pStep, szBuffer, 64); |
| | | LOGI("<CLoadPort>Port2载入模拟数据, id:CID1004 map: 0xff"); |
| | | } |
| | | } |
| | | */ |
| | | } |
| | | |
| | | void CLoadPort::serialize(CArchive& ar) |
| | |
| | | m_portStatusReport.serialize(ar); |
| | | } |
| | | else { |
| | | int temp; |
| | | ar >> m_nIndex; |
| | | m_portStatusReport.serialize(ar); |
| | | } |
| | |
| | | return (m_nIndex + 1) * 1000 + m_nNextCassetteSequenceNo; |
| | | } |
| | | |
| | | int CLoadPort::getPortCassetteSnSeed() |
| | | { |
| | | return m_nNextCassetteSequenceNo; |
| | | } |
| | | |
| | | void CLoadPort::setPortCassetteSnSeed(int seed) |
| | | { |
| | | m_nNextCassetteSequenceNo = seed; |
| | | if (m_nNextCassetteSequenceNo >= 1000) { |
| | | m_nNextCassetteSequenceNo = 0; |
| | | } |
| | | } |
| | | |
| | | void CLoadPort::setIndex(unsigned int index) |
| | | { |
| | | m_nIndex = index; |
| | | |
| | | std::string id = "Port" + std::to_string(index + 1); |
| | | m_portStatusReport.setCassetteId(id.c_str()); |
| | | } |
| | | |
| | | unsigned int CLoadPort::getIndex() |
| | |
| | | std::string& CLoadPort::getCassetteId() |
| | | { |
| | | return m_portStatusReport.getCassetteId(); |
| | | } |
| | | |
| | | void CLoadPort::simulateSetCassetteId(const char* pszCarrierId) |
| | | { |
| | | m_portStatusReport.setCassetteId(pszCarrierId); |
| | | } |
| | | |
| | | int CLoadPort::getLoadingCassetteType() |
| | |
| | | m_portStatusReport.copyEx(portStatusReport); |
| | | |
| | | |
| | | // 当port状态为InUse, 比较map |
| | | // 当port状态为InUse, 比较map |
| | | if (m_portStatusReport.getPortStatus() == PORT_INUSE) { |
| | | if (m_isCompareMapsBeforeProceeding) { |
| | | short scanMap = getScanCassetteMap(); |
| | | short downloadMap = getDownloadCassetteMap(); |
| | | if (scanMap == downloadMap) { |
| | | generateGlassList(scanMap); |
| | | this->sendCassetteCtrlCmd(CCC_PROCESS_START, nullptr, 0, 0, 0, nullptr, nullptr); |
| | | } |
| | | else { |
| | | this->sendCassetteCtrlCmd(CCC_PROCESS_CANCEL, nullptr, 0, 0, 0, nullptr, nullptr); |
| | | // 生成玻璃列表:来自 EFEM 扫描到的 map |
| | | generateGlassList(getScanCassetteMap()); |
| | | |
| | | // 抛出到应用层做提示 |
| | | if (m_listener.onMapMismatch != nullptr) { |
| | | m_listener.onMapMismatch(this, scanMap, downloadMap); |
| | | } |
| | | } |
| | | } |
| | | else { |
| | | // 抛出到应用层做选择要加工的片子 |
| | | generateGlassList(getScanCassetteMap()); |
| | | // CompareMapsBeforeProceeding:不在此处自动 Start/Cancel,改为等待 Host 决策(ProceedWithCarrier/ProceedWithSlotMap/CarrierRelease) |
| | | // Host 决策入口:S3F17 CarrierAction -> listener.onCarrierAction -> CMaster::proceedWithCarrier()/carrierRelease() |
| | | if (m_isCompareMapsBeforeProceeding) { |
| | | // 这里仅等待,具体上报由上层在 PORT_INUSE 事件中触发(S6F11 CheckSlotMap) |
| | | } |
| | | } |
| | | if (m_listener.onPortStatusChanged != nullptr) { |
| | |
| | | } |
| | | |
| | | |
| | | // 缓存Attribute,用于调试时显示信息 |
| | | // 缓存Attribute,用于调试时显示信息 |
| | | unsigned int weight = 201; |
| | | CAttributeVector& attrubutes = pStep->attributeVector(); |
| | | m_portStatusReport.getAttributeVector(attrubutes, weight); |
| | |
| | | return -1; |
| | | } |
| | | |
| | | LOGI("<CLoadPort-%d>准备设置Port type<%d>", m_nIndex, (int)type); |
| | | LOGI("<CLoadPort-%d>准备设置Port type<%d>", m_nIndex, (int)type); |
| | | short value = (short)type; |
| | | pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int { |
| | | // test |
| | | code = WOK; |
| | | if (code == WOK) { |
| | | m_portType = type; |
| | | LOGI("<CLoadPort-%d>设置Port type成功.", m_nIndex); |
| | | LOGI("<CLoadPort-%d>设置Port type成功.", m_nIndex); |
| | | } |
| | | else { |
| | | LOGI("<CLoadPort-%d>设置Port type失败,code:%d", m_nIndex, code); |
| | | LOGE("<CLoadPort-%d>设置Port type失败,code:%d", m_nIndex, code); |
| | | } |
| | | if (onWritedBlock != nullptr) { |
| | | return onWritedBlock(code); |
| | |
| | | return -1; |
| | | } |
| | | |
| | | LOGI("<CLoadPort-%d>准备%s Port", m_nIndex, bEnable ? _T("启用") : _T("禁用")); |
| | | LOGI("<CLoadPort-%d>准备%s Port", m_nIndex, bEnable ? _T("启用") : _T("禁用")); |
| | | short value = bEnable ? 1 : 2; |
| | | pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int { |
| | | // test |
| | | code = WOK; |
| | | if (code == WOK) { |
| | | m_bEnable = bEnable; |
| | | LOGI("<CLoadPort-%d>%s Port成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用")); |
| | | LOGI("<CLoadPort-%d>%s Port成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用")); |
| | | } |
| | | else { |
| | | LOGI("<CLoadPort-%d>%s Port失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code); |
| | | LOGE("<CLoadPort-%d>%s Port失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code); |
| | | } |
| | | if (onWritedBlock != nullptr) { |
| | | return onWritedBlock(code); |
| | |
| | | return -1; |
| | | } |
| | | |
| | | LOGI("<CLoadPort-%d>准备设置Port mode<%d>", m_nIndex, (int)mode); |
| | | LOGI("<CLoadPort-%d>准备设置Port mode<%d>", m_nIndex, (int)mode); |
| | | short value = (short)mode; |
| | | pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int { |
| | | // test |
| | | code = WOK; |
| | | if (code == WOK) { |
| | | m_portMode = mode; |
| | | LOGI("<CLoadPort-%d>设置Port mode成功.", m_nIndex); |
| | | LOGI("<CLoadPort-%d>设置Port mode成功.", m_nIndex); |
| | | } |
| | | else { |
| | | LOGI("<CLoadPort-%d>设置Port mode失败,code:%d", m_nIndex, code); |
| | | LOGE("<CLoadPort-%d>设置Port mode失败,code:%d", m_nIndex, code); |
| | | } |
| | | if (onWritedBlock != nullptr) { |
| | | return onWritedBlock(code); |
| | |
| | | return -1; |
| | | } |
| | | |
| | | LOGI("<CLoadPort-%d>准备设置Cassette Type<%d>", m_nIndex, (int)type); |
| | | LOGI("<CLoadPort-%d>准备设置Cassette Type<%d>", m_nIndex, (int)type); |
| | | short value = (short)type; |
| | | pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int { |
| | | // test |
| | | code = WOK; |
| | | if (code == WOK) { |
| | | LOGI("<CLoadPort-%d>设置Cassette Type成功.", m_nIndex); |
| | | LOGI("<CLoadPort-%d>设置Cassette Type成功.", m_nIndex); |
| | | } |
| | | else { |
| | | LOGI("<CLoadPort-%d>设置Cassette Type失败,code:%d", m_nIndex, code); |
| | | LOGE("<CLoadPort-%d>设置Cassette Type失败,code:%d", m_nIndex, code); |
| | | } |
| | | if (onWritedBlock != nullptr) { |
| | | return onWritedBlock(code); |
| | |
| | | return -1; |
| | | } |
| | | |
| | | LOGI("<CLoadPort-%d>准备设置Transfer mode<%d>", m_nIndex, (int)mode); |
| | | LOGI("<CLoadPort-%d>准备设置Transfer mode<%d>", m_nIndex, (int)mode); |
| | | short value = (short)mode; |
| | | pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int { |
| | | // test |
| | | code = WOK; |
| | | if (code == WOK) { |
| | | m_transferMode = mode; |
| | | LOGI("<CLoadPort-%d>设置Transfer mode成功.", m_nIndex + 1); |
| | | LOGI("<CLoadPort-%d>设置Transfer mode成功.", m_nIndex + 1); |
| | | } |
| | | else { |
| | | LOGI("<CLoadPort-%d>设置Transfer mode失败,code:%d", m_nIndex + 1, code); |
| | | LOGE("<CLoadPort-%d>设置Transfer mode失败,code:%d", m_nIndex + 1, code); |
| | | } |
| | | if (onWritedBlock != nullptr) { |
| | | return onWritedBlock(code); |
| | |
| | | return -1; |
| | | } |
| | | |
| | | LOGI("<CLoadPort-%d>准备%s Auto Change", m_nIndex, bEnable ? _T("启用") : _T("禁用")); |
| | | LOGI("<CLoadPort-%d>准备%s Auto Change", m_nIndex, bEnable ? _T("启用") : _T("禁用")); |
| | | short value = bEnable ? 1 : 2; |
| | | pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int { |
| | | // test |
| | | code = WOK; |
| | | if (code == WOK) { |
| | | m_bAutoChangeEnable = bEnable; |
| | | LOGI("<CLoadPort-%d>%s Auto Change成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用")); |
| | | LOGI("<CLoadPort-%d>%s Auto Change成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用")); |
| | | } |
| | | else { |
| | | LOGI("<CLoadPort-%d>%s Auto Change失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code); |
| | | LOGE("<CLoadPort-%d>%s Auto Change失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code); |
| | | } |
| | | if (onWritedBlock != nullptr) { |
| | | return onWritedBlock(code); |
| | |
| | | |
| | | short CLoadPort::getDownloadCassetteMap() |
| | | { |
| | | // 暂时未实现此功能 |
| | | short map = 0; |
| | | return map; |
| | | return m_downloadCassetteMap; |
| | | } |
| | | |
| | | void CLoadPort::setDownloadCassetteMap(short map) |
| | | { |
| | | m_downloadCassetteMap = map; |
| | | } |
| | | |
| | | /* |
| | | * 生成测试用的玻璃列表 |
| | | * 生成测试用的玻璃列表 |
| | | */ |
| | | int CLoadPort::testGenerateGlassList(MaterialsType type) |
| | | { |
| | | // 如果非空就不生成了 |
| | | // 如果非空就不生成了 |
| | | Lock(); |
| | | if (hasGlass()) { |
| | | Unlock(); |
| | |
| | | |
| | | CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass(); |
| | | pGlass->setOriginPort(m_nIndex, i); |
| | | pGlass->addPath(m_nID, 0); |
| | | pGlass->addPath(m_nID, 0, i + 1); |
| | | pGlass->processEnd(m_nID, 0); |
| | | pGlass->setID(szBuffer); |
| | | pGlass->setType(type); |
| | |
| | | } |
| | | |
| | | /* |
| | | * 根据efem扫描到的map,生成玻璃列表 |
| | | * 根据efem扫描到的map,生成玻璃列表 |
| | | */ |
| | | int CLoadPort::generateGlassList(short map) |
| | | { |
| | | // 先释放较早前的数据 |
| | | // 先释放较早前的数据 |
| | | Lock(); |
| | | for (int i = 0; i < SLOT_MAX; i++) { |
| | | m_slot[i].setContext(nullptr); |
| | |
| | | Unlock(); |
| | | |
| | | |
| | | // 根据map生成新的 |
| | | // 根据map生成新的 |
| | | char szBuffer[64]; |
| | | for (int i = 0; i < SLOT_MAX; i++) { |
| | | if (!m_slot[i].isEnable()) continue; |
| | | if (!(map >> i) & 1) continue; |
| | | if (((map >> i) & 1) == 0) continue; |
| | | |
| | | CJobDataS js; |
| | | js.setCassetteSequenceNo(getNextCassetteSequenceNo()); |
| | |
| | | CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass(); |
| | | pGlass->setOriginPort(m_nIndex, i); |
| | | pGlass->setScheduledForProcessing(i % 2 == 1); |
| | | pGlass->addPath(m_nID, 0); |
| | | pGlass->addPath(m_nID, 0, i + 1); |
| | | pGlass->processEnd(m_nID, 0); |
| | | pGlass->setID(szBuffer); |
| | | pGlass->setType(m_cassetteType); |
| | |
| | | |
| | | CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass(); |
| | | pGlass->setOriginPort(m_nIndex, nSlotIndex); |
| | | pGlass->addPath(m_nID, 0); |
| | | pGlass->addPath(m_nID, 0, slot.nSlotID); |
| | | pGlass->processEnd(m_nID, 0); |
| | | pGlass->setID(szBuffer); |
| | | pGlass->setType(static_cast<SERVO::MaterialsType>(config.nMaterialType)); |
| | |
| | | { |
| | | m_isCompareMapsBeforeProceeding = bCompare; |
| | | } |
| | | |
| | | BOOL CLoadPort::isCompareMapsBeforeProceeding() const |
| | | { |
| | | return m_isCompareMapsBeforeProceeding; |
| | | } |
| | | } |