| | |
| | | #include "RecipeManager.h" |
| | | #include "GlassLogDb.h" |
| | | #include "CParam.h" |
| | | #include "CJobDataS.h" |
| | | #include <algorithm> |
| | | #include <iomanip> |
| | | #include <sstream> |
| | | #include <array> |
| | | #include <map> |
| | | |
| | | |
| | |
| | | |
| | | // PJobSpace: how many ProcessJobs can be created (current implementation supports 0/1). |
| | | m_hsmsPassive.setVariableValue("PJobSpace", (__int64)(m_master.isProcessJobsEmpty() ? 1 : 0)); |
| | | } |
| | | |
| | | void CModel::notifyControlJobChanged() |
| | | { |
| | | // 1) 刷新派生 SV |
| | | refreshDerivedSVs(); |
| | | // 2) 通知上层 UI(RX_CODE_CONTROLJOB_CHANGED) |
| | | notify(RX_CODE_CONTROLJOB_CHANGED); |
| | | } |
| | | |
| | | bool CModel::raiseSoftAlarm(int alarmId, |
| | | const std::string& desc, |
| | | int level /*= -1*/, |
| | | int deviceId /*= 0*/, |
| | | int unitId /*= 0*/, |
| | | const char* deviceName /*= "Software"*/, |
| | | const char* unitName /*= "App"*/) |
| | | { |
| | | AlarmManager& alarmManager = AlarmManager::getInstance(); |
| | | const AlarmInfo* info = alarmManager.getAlarmInfoByID(alarmId); |
| | | |
| | | int severity = level; |
| | | if (severity < 0 && info != nullptr) severity = info->nAlarmLevel; |
| | | if (severity < 0) severity = 0; |
| | | |
| | | std::string descText = desc; |
| | | if (descText.empty() && info != nullptr) { |
| | | descText = !info->strDescription.empty() ? info->strDescription : info->strAlarmText; |
| | | } |
| | | if (descText.empty()) { |
| | | descText = CToolUnits::formatString("Alarm %d", alarmId); |
| | | } |
| | | |
| | | AlarmData alarmData; |
| | | alarmData.nId = alarmId; |
| | | alarmData.nSeverityLevel = severity; |
| | | alarmData.nDeviceId = deviceId; |
| | | alarmData.nUnitId = unitId; |
| | | alarmData.strDeviceName = deviceName; |
| | | alarmData.strUnitName = unitName; |
| | | // 若未显式提供设备/单元名称,尝试通过 deviceId/unitId 解析(soft alarm 默认均为 0) |
| | | if (alarmData.strDeviceName.empty()) { |
| | | alarmData.strDeviceName = alarmManager.getDeviceNameById(deviceId); |
| | | } |
| | | if (alarmData.strUnitName.empty()) { |
| | | alarmData.strUnitName = alarmManager.getUnitNameById(deviceId, unitId); |
| | | } |
| | | alarmData.strStartTime = CToolUnits::timeToString2(CToolUnits::getTimestamp()); |
| | | alarmData.strEndTime = ""; |
| | | alarmData.strDescription = descText; |
| | | |
| | | int nAlarmEventId = 0; |
| | | bool result = alarmManager.addAlarm(alarmData, nAlarmEventId); |
| | | if (result) { |
| | | notify(RX_CODE_ALARM_SET); |
| | | if (m_master.isAlarmReportEnable()) { |
| | | m_hsmsPassive.requestAlarmReport(1, alarmId, descText.c_str()); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | void CModel::clearSoftAlarm(int alarmId, int deviceId, int unitId) |
| | | { |
| | | AlarmManager& alarmManager = AlarmManager::getInstance(); |
| | | alarmManager.clearAlarmByAttributes(alarmId, deviceId, unitId, CToolUnits::getCurrentTimeString()); |
| | | notify(RX_CODE_ALARM_CLEAR); |
| | | if (m_master.isAlarmReportEnable()) { |
| | | const AlarmInfo* info = alarmManager.getAlarmInfoByID(alarmId); |
| | | std::string descText; |
| | | if (info != nullptr) descText = info->strAlarmText; |
| | | m_hsmsPassive.requestAlarmReport(0, alarmId, descText.c_str()); |
| | | } |
| | | } |
| | | |
| | | void CModel::setControlState(ControlState newState) |
| | |
| | | |
| | | int CModel::init() |
| | | { |
| | | const ULONGLONG boot_model_begin = GetTickCount64(); |
| | | CString strIniFile; |
| | | CString strUnitId; |
| | | strIniFile.Format(_T("%s\\ServoConfiguration.ini"), (LPTSTR)(LPCTSTR)m_strWorkDir); |
| | |
| | | // CGlassPool |
| | | m_glassPool.initPool(); |
| | | |
| | | // 将 Model 上下文传递给 Master,便于 Master 触发软件级报警等跨层操作 |
| | | m_master.setModelCtx(this); |
| | | |
| | | |
| | | // Log |
| | | CString strLogDir; |
| | |
| | | CLog::GetLog()->SetLogsDir(strLogDir); |
| | | CLog::GetLog()->SetEquipmentId((LPTSTR)(LPCTSTR)strUnitId); |
| | | LOGI("\r\n\r\n~~~ Prog Start! ~~~"); |
| | | LOGI("[BOOT][MODEL] init begin"); |
| | | |
| | | |
| | | SECSListener listener; |
| | |
| | | setControlState(ControlState::OnlineRemote); |
| | | } |
| | | }; |
| | | listener.onEQConstantRequest = [&](void* pFrom, std::vector<EQConstant>& eqcs) -> void { |
| | | // 在此填充常量值,目前仅是加1后返回 |
| | | for (auto& item : eqcs) { |
| | | sprintf_s(item.szValue, EQCONSTANT_VALUE_MAX, "Test%d", item.id + 1); |
| | | } |
| | | }; |
| | | listener.onEQConstantSend = [&](void* pFrom, std::vector<EQConstant>& eqcs) -> void { |
| | | // 在此保存和设置机器常量值 |
| | | for (auto& item : eqcs) { |
| | | LOGI("onEQConstantRequest: %d, %s", item.id, item.szValue); |
| | | } |
| | | }; |
| | | listener.onDatetimeSync = [&](void* pFrom, SYSTEMTIME& time) -> void { |
| | | LOGI("onDatetimeSync: %d%02d%02d%02d%02d%02d", time.wYear, |
| | | time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond); |
| | |
| | | if (ids.empty()) { |
| | | m_master.enableEventReport(bEnable); |
| | | } |
| | | }; |
| | | listener.onDeletePPID = [&](void* pFrom, const std::vector<std::string>& ppids) -> bool { |
| | | (void)pFrom; |
| | | bool allOk = true; |
| | | std::vector<std::string> targets = ppids; |
| | | if (targets.empty()) { |
| | | // L:0 => delete all PPIDs |
| | | targets = RecipeManager::getInstance().getAllPPID(); |
| | | } |
| | | for (auto& ppid : targets) { |
| | | bool ok = RecipeManager::getInstance().deleteRecipeByPPID(ppid); |
| | | allOk = allOk && ok; |
| | | LOGI("<CModel>DeletePPID: %s, result=%s", ppid.c_str(), ok ? "OK" : "FAIL"); |
| | | } |
| | | return allOk; |
| | | }; |
| | | listener.onEnableDisableAlarmReport = [&](void* pFrom, bool bEnable, unsigned int id) -> void { |
| | | LOGI("onEnableDisableAlarmReport bEnable:%s, id:%d", bEnable ? _T("YES") : _T("NO"), id); |
| | |
| | | // 真正的“开始”由 ProceedWithSlotMap 决策触发。 |
| | | // 仅当未开启 CompareMapsBeforeProceeding 时,才沿用旧逻辑直接 Start。 |
| | | LOGI("<CModel>ProceedWithCarrier"); |
| | | if (m_master.getControlJob() == nullptr || m_master.isProcessJobsEmpty()) { |
| | | strErrorTxt = "rejected - ControlJob/ProcessJob not ready"; |
| | | LOGW("<CModel>ProceedWithCarrier rejected: no CJ/PJ, port=%d", portIndex + 1); |
| | | return CAACK_5; |
| | | } |
| | | if (pLoadPort == nullptr || !pLoadPort->isCompareMapsBeforeProceeding()) { |
| | | m_master.proceedWithCarrier(portIndex); |
| | | } |
| | |
| | | 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; |
| | |
| | | CString strVarialbleFile; |
| | | strVarialbleFile.Format(_T("%s\\VariableList.txt"), (LPTSTR)(LPCTSTR)m_strWorkDir); |
| | | m_hsmsPassive.loadVarialbles((LPTSTR)(LPCTSTR)strVarialbleFile); |
| | | strVarialbleFile.Format(_T("%s\\DataVariableList.txt"), (LPTSTR)(LPCTSTR)m_strWorkDir); |
| | | m_hsmsPassive.loadDataVarialbles((LPTSTR)(LPCTSTR)strVarialbleFile); |
| | | strVarialbleFile.Format(_T("%s\\EquipmentConstantList.txt"), (LPTSTR)(LPCTSTR)m_strWorkDir); |
| | | m_hsmsPassive.loadEquipmentConstants((LPTSTR)(LPCTSTR)strVarialbleFile); |
| | | setControlState(m_currentControlState); |
| | | refreshDerivedSVs(); |
| | | m_hsmsPassive.init(this, "APP", 7000); |
| | |
| | | m_hsmsPassive.loadReports((LPTSTR)(LPCTSTR)strVarialbleFile); |
| | | strVarialbleFile.Format(_T("%s\\CollectionEventList.txt"), (LPTSTR)(LPCTSTR)m_strWorkDir); |
| | | m_hsmsPassive.loadCollectionEvents((LPTSTR)(LPCTSTR)strVarialbleFile); |
| | | { |
| | | auto events = m_hsmsPassive.getCollectionEvents(); |
| | | std::vector<unsigned int> ceids; |
| | | ceids.reserve(events.size()); |
| | | for (auto e : events) { |
| | | if (e != nullptr) ceids.push_back(e->getEventId()); |
| | | } |
| | | m_master.setAllowedCeids(ceids); |
| | | } |
| | | 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; |
| | | auto formatParamValue = [](const CParam& p) { |
| | | std::ostringstream oss; |
| | | oss.setf(std::ios::fixed); |
| | | oss << std::setprecision(4) << p.getDoubleValue(); |
| | | return oss.str(); |
| | | }; |
| | | masterListener.onMasterStateChanged = [&](void* pMaster, SERVO::MASTERSTATE state) -> void { |
| | | LOGI("<CModel>Master state changed(%d)", (int)state); |
| | | notify(RX_CODE_MASTER_STATE_CHANGED); |
| | | }; |
| | | masterListener.onControlJobChanged = [this](void* pMaster) { |
| | | (void)pMaster; |
| | | this->refreshDerivedSVs(); |
| | | this->notifyControlJobChanged(); |
| | | }; |
| | | masterListener.onEqAlive = [&](void* pMaster, SERVO::CEquipment* pEquipment, BOOL bAlive) -> void { |
| | | LOGI("<CModel>Equipment onAlive:%s(%s).", pEquipment->getName().c_str(), |
| | |
| | | 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); |
| | | } |
| | | }); |
| | | } |
| | |
| | | notifyPtrAndInt(RX_CODE_EQ_ROBOT_TASK, pTask, nullptr, code); |
| | | |
| | | }; |
| | | masterListener.onJobReceived = [&](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->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); |
| | | if (recipe.empty()) { |
| | | recipe = std::to_string(recipeId); |
| | | } |
| | | const std::string prev = pEquipment->getCurrentRecipe(); |
| | | if (recipe.empty() || recipe == prev) { |
| | | pEquipment->setCurrentRecipe(recipe); |
| | | return; |
| | | } |
| | | pEquipment->setCurrentRecipe(recipe); |
| | | m_hsmsPassive.withVariableLock([&] { |
| | | m_hsmsPassive.setVariableValue("Clock", CToolUnits::getCurrentTimeString().c_str()); |
| | | m_hsmsPassive.setVariableValue("EQPPExecName", recipe.c_str()); |
| | | m_hsmsPassive.setVariableValue("SubEqpName", pEquipment->getName().c_str()); |
| | | const char* recipeVid = nullptr; |
| | | switch (eqId) { |
| | | case EQ_ID_Bonder1: recipeVid = "Bonder1CurrentRecipe"; break; |
| | | case EQ_ID_Bonder2: recipeVid = "Bonder2CurrentRecipe"; break; |
| | | case EQ_ID_VACUUMBAKE: recipeVid = "VacuumBakeCurrentRecipe"; break; |
| | | case EQ_ID_BAKE_COOLING: recipeVid = "BakeCoolingCurrentRecipe"; break; |
| | | case EQ_ID_MEASUREMENT: recipeVid = "MeasurementCurrentRecipe"; break; |
| | | case EQ_ID_EFEM: recipeVid = "EFEMCurrentRecipe"; break; |
| | | default: break; |
| | | } |
| | | if (recipeVid != nullptr) { |
| | | m_hsmsPassive.setVariableValue(recipeVid, recipe.c_str()); |
| | | } |
| | | 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(); |
| | | }); |
| | |
| | | } |
| | | }); |
| | | }; |
| | | masterListener.onSVDataReport = [&](void* pMaster, SERVO::CEquipment* pEquipment, const std::vector<CParam>& params) { |
| | | (void)pMaster; |
| | | const int eqId = pEquipment ? pEquipment->getID() : 0; |
| | | |
| | | 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]); |
| | | m_hsmsPassive.setVariableValue(std::to_string(vidMap[idx]).c_str(), val.c_str()); |
| | | } |
| | | m_hsmsPassive.requestEventReportSend(evName); |
| | | }); |
| | | }; |
| | | |
| | | if (eqId == EQ_ID_Bonder1 || eqId == EQ_ID_Bonder2) { |
| | | static constexpr std::array<int, 19> vids = { |
| | | 6000,6001,6002,6003,6004,6005,6006,6007,6008,6009, |
| | | 6010,6011,6012,6013,6014,6015,6016,6017,6018 |
| | | }; |
| | | sendSv(vids, "BonderSVData"); |
| | | } |
| | | else if (eqId == EQ_ID_VACUUMBAKE) { |
| | | static constexpr std::array<int, 18> vids = { |
| | | 6200,6201,6202,6203,6204,6205,6206,6207,6208, |
| | | 6209,6210,6211,6212,6213,6214,6215,6216,6217 |
| | | }; |
| | | sendSv(vids, "VacuumBakeSVData"); |
| | | } |
| | | else if (eqId == EQ_ID_BAKE_COOLING) { |
| | | static constexpr std::array<int, 20> vids = { |
| | | 6400,6401,6402,6403,6404,6405,6406,6407,6408,6409, |
| | | 6410,6411,6412,6413,6414,6415,6416,6417,6418,6419 |
| | | }; |
| | | sendSv(vids, "BakeCoolingSVData"); |
| | | } |
| | | else if (eqId == EQ_ID_MEASUREMENT) { |
| | | static constexpr std::array<int, 2> vids = { 6600, 6601 }; |
| | | sendSv(vids, "MeasurementSVData"); |
| | | } |
| | | }; |
| | | masterListener.onProcessDataReport = [&](void* pMaster, SERVO::CEquipment* pEquipment, const std::vector<CParam>& params) { |
| | | (void)pMaster; |
| | | const int eqId = pEquipment ? pEquipment->getID() : 0; |
| | | if (eqId != EQ_ID_Bonder1 && eqId != EQ_ID_Bonder2) return; |
| | | |
| | | auto formatVal = [](const CParam& p) { |
| | | std::ostringstream oss; |
| | | oss.setf(std::ios::fixed); |
| | | oss << std::setprecision(4) << p.getDoubleValue(); |
| | | return oss.str(); |
| | | 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]); |
| | | m_hsmsPassive.setVariableValue(std::to_string(vidMap[idx]).c_str(), val.c_str()); |
| | | } |
| | | m_hsmsPassive.requestEventReportSend(evName); |
| | | }); |
| | | }; |
| | | |
| | | static const int vidMap[] = { |
| | | 6100,6101,6102,6103,6104,6105,6106,6107,6108,6109,6110, |
| | | 6111,6112,6113,6114,6115,6116,6117,6118,6119,6120,6121 |
| | | }; |
| | | const size_t count = (std::min)(params.size(), sizeof(vidMap) / sizeof(vidMap[0])); |
| | | m_hsmsPassive.withVariableLock([&] { |
| | | m_hsmsPassive.setVariableValue("Clock", CToolUnits::getCurrentTimeString().c_str()); |
| | | for (size_t idx = 0; idx < count; ++idx) { |
| | | auto& p = params[idx]; |
| | | std::string val = formatVal(p); |
| | | m_hsmsPassive.setVariableValue(std::to_string(vidMap[idx]).c_str(), val.c_str()); |
| | | } |
| | | m_hsmsPassive.requestEventReportSend("BonderProcessData"); |
| | | }); |
| | | if (eqId == EQ_ID_Bonder1 || eqId == EQ_ID_Bonder2) { |
| | | static constexpr std::array<int, 22> vids = { |
| | | 6100,6101,6102,6103,6104,6105,6106,6107,6108,6109,6110, |
| | | 6111,6112,6113,6114,6115,6116,6117,6118,6119,6120,6121 |
| | | }; |
| | | sendProcess(vids, "BonderProcessData"); |
| | | } |
| | | else if (eqId == EQ_ID_VACUUMBAKE) { |
| | | static constexpr std::array<int, 5> vids = { 6300,6301,6302,6303,6304 }; |
| | | sendProcess(vids, "VacuumBakeProcessData"); |
| | | } |
| | | else if (eqId == EQ_ID_BAKE_COOLING) { |
| | | static constexpr std::array<int, 4> vids = { 6500,6501,6502,6503 }; |
| | | sendProcess(vids, "BakeCoolingProcessData"); |
| | | } |
| | | else if (eqId == EQ_ID_MEASUREMENT) { |
| | | static constexpr std::array<int, 4> vids = { 6700,6701,6702,6703 }; |
| | | sendProcess(vids, "MeasurementProcessData"); |
| | | } |
| | | }; |
| | | masterListener.onCTRoundEnd = [&](void* pMaster, int round) { |
| | | m_configuration.setContinuousTransferCount(round); |
| | |
| | | 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; |
| | | } |
| | | |