| | |
| | | |
| | | int CModel::init() |
| | | { |
| | | const ULONGLONG boot_model_begin = GetTickCount64(); |
| | | CString strIniFile; |
| | | CString strUnitId; |
| | | strIniFile.Format(_T("%s\\ServoConfiguration.ini"), (LPTSTR)(LPCTSTR)m_strWorkDir); |
| | |
| | | CLog::GetLog()->SetLogsDir(strLogDir); |
| | | CLog::GetLog()->SetEquipmentId((LPTSTR)(LPCTSTR)strUnitId); |
| | | LOGI("\r\n\r\n~~~ Prog Start! ~~~"); |
| | | LOGI("[BOOT][MODEL] init begin"); |
| | | |
| | | |
| | | SECSListener listener; |
| | |
| | | return CAACK_5; |
| | | } |
| | | |
| | | const short scanMap = pLoadPort->getScanCassetteMap(); |
| | | const short downloadMap = pLoadPort->getDownloadCassetteMap(); |
| | | m_hsmsPassive.withVariableLock([&] { |
| | | m_hsmsPassive.setVariableValue("SlotMapScan", pLoadPort->getScanCassetteMap()); |
| | | m_hsmsPassive.setVariableValue("SlotMapDownload", pLoadPort->getDownloadCassetteMap()); |
| | | m_hsmsPassive.requestEventReportSend_SlotMapVerificationOK(); |
| | | m_hsmsPassive.setVariableValue("SlotMapScan", scanMap); |
| | | m_hsmsPassive.setVariableValue("SlotMapDownload", downloadMap); |
| | | if (scanMap != downloadMap) { |
| | | m_hsmsPassive.requestEventReportSend_SlotMapVerificationNG(); |
| | | m_hsmsPassive.requestEventReportSend("SlotMapMismatch"); |
| | | } |
| | | else { |
| | | m_hsmsPassive.requestEventReportSend_SlotMapVerificationOK(); |
| | | } |
| | | }); |
| | | |
| | | if (scanMap != downloadMap) { |
| | | strErrorTxt = "rejected - SlotMap mismatch"; |
| | | return CAACK_5; |
| | | } |
| | | |
| | | // Host 确认 SlotMap 后再开始加工/流程 |
| | | m_master.proceedWithCarrier(portIndex); |
| | |
| | | } |
| | | strVarialbleFile.Format(_T("%s\\HsmsPassive.cache"), (LPTSTR)(LPCTSTR)m_strWorkDir); |
| | | m_hsmsPassive.loadCacheFromFile(strVarialbleFile); |
| | | LOGI("[BOOT][MODEL] HSMS config loaded, cost=%llu ms", |
| | | (unsigned long long)(GetTickCount64() - boot_model_begin)); |
| | | |
| | | |
| | | SERVO::MasterListener masterListener; |
| | |
| | | if (pReport != nullptr) { |
| | | m_hsmsPassive.withVariableLock([&] { |
| | | m_hsmsPassive.setVariableValue("VCRPanelID", pReport->getGlassId().c_str()); |
| | | int nRet = m_hsmsPassive.requestEventReportSend_OCR_PanelID_Read_OK(); |
| | | int nRet = m_hsmsPassive.requestEventReportSend_OCR_PanelID_Read(pReport->getVcrResult()); |
| | | if (nRet != ER_NOERROR) { |
| | | LOGE("<CModel>requestEventReportSend_OCR_PanelID_Read_OK failed, ret=%d", nRet); |
| | | LOGE("<CModel>requestEventReportSend_OCR_PanelID_Read failed, ret=%d", nRet); |
| | | } |
| | | }); |
| | | } |
| | |
| | | (void)pMaster; |
| | | (void)port; |
| | | if (pEquipment == nullptr || pJobDataS == nullptr) return; |
| | | { |
| | | const std::string& g1 = pJobDataS->getGlass1Id(); |
| | | const std::string& g2 = pJobDataS->getGlass2Id(); |
| | | std::string glassId; |
| | | if (!g1.empty() && !g2.empty()) { |
| | | glassId = g1 + "+" + g2; |
| | | } |
| | | else if (!g1.empty()) { |
| | | glassId = g1; |
| | | } |
| | | else { |
| | | glassId = g2; |
| | | } |
| | | const int slotNo = pJobDataS->getTargetSlotNo(); |
| | | m_hsmsPassive.withVariableLock([&] { |
| | | m_hsmsPassive.setVariableValue("SubEqpName", pEquipment->getName().c_str()); |
| | | m_hsmsPassive.setVariableValue("SubEqpSlot", slotNo); |
| | | m_hsmsPassive.setVariableValue("MaterialId", glassId.c_str()); |
| | | m_hsmsPassive.requestEventReportSend("GlassReceivedJob"); |
| | | }); |
| | | } |
| | | const int eqId = pEquipment->getID(); |
| | | const int recipeId = pJobDataS->getMasterRecipe(); |
| | | std::string recipe = RecipeManager::getInstance().getPPIDById(recipeId); |
| | |
| | | m_hsmsPassive.requestEventReportSend("RecipeChanged"); |
| | | }); |
| | | }; |
| | | masterListener.onJobSentOut = [&](void* pMaster, SERVO::CEquipment* pEquipment, int port, SERVO::CJobDataS* pJobDataS) { |
| | | (void)pMaster; |
| | | (void)port; |
| | | if (pEquipment == nullptr || pJobDataS == nullptr) return; |
| | | const std::string& g1 = pJobDataS->getGlass1Id(); |
| | | const std::string& g2 = pJobDataS->getGlass2Id(); |
| | | std::string glassId; |
| | | if (!g1.empty() && !g2.empty()) { |
| | | glassId = g1 + "+" + g2; |
| | | } |
| | | else if (!g1.empty()) { |
| | | glassId = g1; |
| | | } |
| | | else { |
| | | glassId = g2; |
| | | } |
| | | const int slotNo = pJobDataS->getSourceSlotNo(); |
| | | m_hsmsPassive.withVariableLock([&] { |
| | | m_hsmsPassive.setVariableValue("SubEqpName", pEquipment->getName().c_str()); |
| | | m_hsmsPassive.setVariableValue("SubEqpSlot", slotNo); |
| | | m_hsmsPassive.setVariableValue("MaterialId", glassId.c_str()); |
| | | m_hsmsPassive.requestEventReportSend("GlassSentOutJob"); |
| | | }); |
| | | }; |
| | | masterListener.onLoadPortStatusChanged = [&] (void* pMaster, SERVO::CEquipment* pEquipment, short status, __int64 data) { |
| | | LOGE("<CModel>onLoadPortStatusChanged. status = %d", status); |
| | | static std::map<int, short> s_prevPortStatus; |
| | |
| | | |
| | | // Unified PortStateChange event + SV maintenance |
| | | if (pLoadPort != nullptr) { |
| | | const unsigned int portIndex = pLoadPort->getIndex() + 1; |
| | | char stateVid[64] = {0}; |
| | | char modeVid[64] = {0}; |
| | | sprintf_s(stateVid, "PortTransferState_P%u", portIndex); |
| | | sprintf_s(modeVid, "AccessMode_P%u", portIndex); |
| | | m_hsmsPassive.withVariableLock([&] { |
| | | m_hsmsPassive.setVariableValue("PortTransferState", (__int64)status); // maintain SVID=100 |
| | | m_hsmsPassive.setVariableValue("PortStateChangePortId", pLoadPort->getID()); |
| | | m_hsmsPassive.setVariableValue(stateVid, (__int64)status); |
| | | m_hsmsPassive.setVariableValue(modeVid, (__int64)pLoadPort->getPortMode()); |
| | | m_hsmsPassive.setVariableValue("PortId", pLoadPort->getID()); |
| | | m_hsmsPassive.setVariableValue("PortState", (__int64)status); |
| | | m_hsmsPassive.requestEventReportSend("PortStateChange"); |
| | | }); |
| | |
| | | if (status == PORT_INUSE) { |
| | | m_hsmsPassive.withVariableLock([&] { |
| | | if (pLoadPort != nullptr) { |
| | | m_hsmsPassive.setVariableValue("CarrierID", pLoadPort->getCassetteId().c_str()); |
| | | const unsigned int portIndex = pLoadPort->getIndex() + 1; |
| | | char carrierVid[64] = {0}; |
| | | sprintf_s(carrierVid, "CarrierID_P%u", portIndex); |
| | | m_hsmsPassive.setVariableValue(carrierVid, pLoadPort->getCassetteId().c_str()); |
| | | if (prevStatus != PORT_INUSE && pLoadPort->isCompareMapsBeforeProceeding()) { |
| | | // TODO(Host协商): |
| | | // 文档中标明:1-Empty,3-Exist,因此我们可能需要将uint的map转换为list上传 |
| | |
| | | SERVO::CLoadPort* pLoadPort = dynamic_cast<SERVO::CLoadPort*>(pEquipment); |
| | | m_hsmsPassive.withVariableLock([&] { |
| | | if (pLoadPort != nullptr) { |
| | | m_hsmsPassive.setVariableValue("BlockedPortId", pLoadPort->getID()); |
| | | m_hsmsPassive.setVariableValue("PortId", pLoadPort->getID()); |
| | | } |
| | | m_hsmsPassive.requestEventReportSend_Port_Blocked(); |
| | | }); |
| | |
| | | SERVO::CLoadPort* pLoadPort = dynamic_cast<SERVO::CLoadPort*>(pEquipment); |
| | | m_hsmsPassive.withVariableLock([&] { |
| | | if (pLoadPort != nullptr) { |
| | | m_hsmsPassive.setVariableValue("LoadReadyPortId", pLoadPort->getID()); |
| | | m_hsmsPassive.setVariableValue("PortId", pLoadPort->getID()); |
| | | } |
| | | m_hsmsPassive.requestEventReportSend_Port_Load_Ready(); |
| | | }); |
| | |
| | | SERVO::CLoadPort* pLoadPort = dynamic_cast<SERVO::CLoadPort*>(pEquipment); |
| | | m_hsmsPassive.withVariableLock([&] { |
| | | if (pLoadPort != nullptr) { |
| | | m_hsmsPassive.setVariableValue("UnloadReadyPortId", pLoadPort->getID()); |
| | | m_hsmsPassive.setVariableValue("PortId", pLoadPort->getID()); |
| | | if (prevStatus == PORT_INUSE) { |
| | | m_hsmsPassive.setVariableValue("ReadyToReleasePortId", pLoadPort->getID()); |
| | | m_hsmsPassive.setVariableValue("PortId", pLoadPort->getID()); |
| | | m_hsmsPassive.requestEventReportSend_Port_Ready_To_Release(); |
| | | } |
| | | } |
| | |
| | | SERVO::CLoadPort* pLoadPort = dynamic_cast<SERVO::CLoadPort*>(pEquipment); |
| | | m_hsmsPassive.withVariableLock([&] { |
| | | if (pLoadPort != nullptr) { |
| | | m_hsmsPassive.setVariableValue("LoadPortNotAssocPortId", pLoadPort->getID()); |
| | | m_hsmsPassive.setVariableValue("PortId", pLoadPort->getID()); |
| | | } |
| | | m_hsmsPassive.requestEventReportSend_LoadPortNotAssoc(); |
| | | }); |
| | |
| | | auto sendSv = [&](const auto& vidMap, const char* evName) { |
| | | const size_t count = (std::min)(params.size(), vidMap.size()); |
| | | m_hsmsPassive.withVariableLock([&] { |
| | | if (pEquipment != nullptr) { |
| | | m_hsmsPassive.setVariableValue("SubEqpName", pEquipment->getName().c_str()); |
| | | } |
| | | m_hsmsPassive.setVariableValue("SubEqpSlot", 0); |
| | | m_hsmsPassive.setVariableValue("Clock", CToolUnits::getCurrentTimeString().c_str()); |
| | | for (size_t idx = 0; idx < count; ++idx) { |
| | | const std::string val = formatParamValue(params[idx]); |
| | |
| | | auto sendProcess = [&](const auto& vidMap, const char* evName) { |
| | | const size_t count = (std::min)(params.size(), vidMap.size()); |
| | | m_hsmsPassive.withVariableLock([&] { |
| | | if (pEquipment != nullptr) { |
| | | m_hsmsPassive.setVariableValue("SubEqpName", pEquipment->getName().c_str()); |
| | | } |
| | | m_hsmsPassive.setVariableValue("SubEqpSlot", 0); |
| | | m_hsmsPassive.setVariableValue("Clock", CToolUnits::getCurrentTimeString().c_str()); |
| | | for (size_t idx = 0; idx < count; ++idx) { |
| | | const std::string val = formatParamValue(params[idx]); |
| | |
| | | char szBuffer[MAX_PATH]; |
| | | sprintf_s(szBuffer, MAX_PATH, "%s\\AlarmList.csv", (LPTSTR)(LPCTSTR)m_strWorkDir); |
| | | alarmManager.readAlarmFile(szBuffer); |
| | | LOGI("[BOOT][MODEL] Alarm list loaded, cost=%llu ms", |
| | | (unsigned long long)(GetTickCount64() - boot_model_begin)); |
| | | |
| | | |
| | | // Glass数据库 |
| | |
| | | GlassLogDb::Init(path); |
| | | |
| | | |
| | | LOGI("[BOOT][MODEL] init finished, total cost=%llu ms", |
| | | (unsigned long long)(GetTickCount64() - boot_model_begin)); |
| | | return 0; |
| | | } |
| | | |