| | |
| | | (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.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) { |
| | |
| | | m_hsmsPassive.setVariableValue("CurrentProcessState", (__int64)state); |
| | | m_hsmsPassive.requestEventReportSend("ProcessStateChanged"); |
| | | |
| | | // SubEqp events (per equipment, ignore slot distinction except payload) |
| | | static std::map<int, SERVO::PROCESS_STATE> s_prevSubEqpState; |
| | | const auto prevEqState = s_prevSubEqpState[eqId]; |
| | | if (prevEqState != state) { |
| | | // state change |
| | | m_hsmsPassive.requestEventReportSend("SubEqpStateChange"); |
| | | } |
| | | if (state == SERVO::PROCESS_STATE::Processing) { |
| | | m_hsmsPassive.requestEventReportSend_SubEqpStart(); |
| | | } |
| | | else if (state == SERVO::PROCESS_STATE::Complete) { |
| | | m_hsmsPassive.requestEventReportSend_SubEqpEnd(); |
| | | } |
| | | s_prevSubEqpState[eqId] = state; |
| | | |
| | | // Unit events (per equipment slot) |
| | | static std::map<int, std::map<int, SERVO::PROCESS_STATE>> s_prevUnitState; |
| | | const auto prevUnitState = s_prevUnitState[eqId][slotNo]; |
| | | if (prevUnitState != state) { |
| | | m_hsmsPassive.requestEventReportSend("UnitStateChange"); |
| | | std::string panelId; |
| | | if (pEquipment != nullptr && slotNo > 0) { |
| | | if (auto* pGlass = pEquipment->getGlassFromSlot(slotNo)) { |
| | | panelId = pGlass->getID(); |
| | | } |
| | | } |
| | | if (state == SERVO::PROCESS_STATE::Processing) { |
| | | m_hsmsPassive.setVariableValue("PanelStartID", panelId.c_str()); |
| | | m_hsmsPassive.requestEventReportSend("UnitStart"); |
| | | } |
| | | else if (state == SERVO::PROCESS_STATE::Complete) { |
| | | m_hsmsPassive.setVariableValue("PanelEndID", panelId.c_str()); |
| | | m_hsmsPassive.requestEventReportSend("UnitEnd"); |
| | | } |
| | | s_prevUnitState[eqId][slotNo] = state; |
| | | } |
| | | }); |
| | | }; |
| | | masterListener.onEqStatusChanged = [&](void* pMaster, SERVO::CEquipment* pEquipment, int unitId, int status, int reason) { |
| | | (void)pMaster; |
| | | if (pEquipment == nullptr) return; |
| | | m_hsmsPassive.withVariableLock([&] { |
| | | m_hsmsPassive.setVariableValue("SubEqpName", pEquipment->getName().c_str()); |
| | | m_hsmsPassive.setVariableValue("SubEqpSlot", unitId); |
| | | m_hsmsPassive.setVariableValue("EquipmentStatus", (__int64)status); |
| | | m_hsmsPassive.requestEventReportSend("SubEqpStateChange"); |
| | | }); |
| | | }; |
| | | masterListener.onSVDataReport = [&](void* pMaster, SERVO::CEquipment* pEquipment, const std::vector<CParam>& params) { |
| | | (void)pMaster; |
| | | const int eqId = pEquipment ? pEquipment->getID() : 0; |