| | |
| | | |
| | | 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); |
| | |
| | | for (auto p : pjs) { |
| | | LOGI("<Model>onPRJobMultiCreate %s %s", p->id().c_str(), p->recipeSpec().c_str()); |
| | | } |
| | | |
| | | auto rejectAll = [&](uint32_t code, const std::string& msg) -> int { |
| | | LOGW("<Model>onPRJobMultiCreate rejected: %s", msg.c_str()); |
| | | for (auto p : pjs) { |
| | | if (p != nullptr) p->addIssue(code, msg); |
| | | } |
| | | return -1; |
| | | }; |
| | | |
| | | // 单 PJ 模式:只接受 1 条且当前无在制 PJ |
| | | if (pjs.size() != 1) { |
| | | return rejectAll(1200, "Only 1 ProcessJob supported (single-PJ mode)"); |
| | | } |
| | | if (!m_master.isProcessJobsEmpty()) { |
| | | return rejectAll(1201, "ProcessJob exists, cannot create new in single-PJ mode"); |
| | | } |
| | | |
| | | int nRet = m_master.setProcessJobs(pjs); |
| | | auto processJobs = m_master.getProcessJobs(); |
| | | std::vector<SERVO::CVariable> vars; |
| | |
| | | } |
| | | 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; |
| | |
| | | |
| | | // 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(stateVid, (__int64)status); |
| | | m_hsmsPassive.setVariableValue(modeVid, (__int64)pLoadPort->getPortMode()); |
| | | m_hsmsPassive.setVariableValue("PortStateChangePortId", 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上传 |
| | |
| | | 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; |
| | | } |
| | | |