| | |
| | | else if (nStream == 10 && pHeader->function == 3) { |
| | | replyTerminalDisplay(pMessage); |
| | | } |
| | | else if (nStream == 16 && pHeader->function == 15) { |
| | | replyPRJobMultiCreate(pMessage); |
| | | } |
| | | }; |
| | | |
| | | PassiveListener listener; |
| | |
| | | return 0; |
| | | } |
| | | |
| | | // S16F15 |
| | | int CHsmsPassive::replyPRJobMultiCreate(IMessage* pRecv) |
| | | { |
| | | if (m_pPassive == NULL || STATE::SELECTED != m_pPassive->getState()) { |
| | | return ER_NOTSELECT; |
| | | } |
| | | ISECS2Item* pBody = pRecv->getBody(); |
| | | if (pBody == nullptr || pBody->getType() != SITYPE::L) ER_PARAM_ERROR; |
| | | |
| | | |
| | | // 解释数据,得到CProcessJob |
| | | ISECS2Item* pItemPjs, * pItemPj,* pItemCarriers, * pItemCarrier, *pItemSlots, *pItemRecipes; |
| | | unsigned int DATAID; |
| | | const char* pszPrjobid, *pszMF, *pszCarrierId, *pszRecipeName; |
| | | std::string strCarrierId; |
| | | unsigned int len; |
| | | unsigned char slot, PRRECIPEMETHOD; |
| | | std::vector<unsigned char> slots; |
| | | std::vector<SERVO::CProcessJob*> pjs; |
| | | |
| | | if (!pBody->getSubItemU4(0, DATAID)) return ER_PARAM_ERROR; |
| | | pItemPjs = pBody->getSubItem(1); |
| | | if (pItemPjs == nullptr) return ER_PARAM_ERROR; |
| | | for (int i = 0; i < pItemPjs->getSubItemSize(); i++) { |
| | | pItemPj = pItemPjs->getSubItem(i); |
| | | if (pItemPj == nullptr) continue; |
| | | if (!pItemPj->getSubItemString(0, pszPrjobid)) continue; |
| | | if (!pItemPj->getSubItemBinary(1, pszMF, len)) continue; |
| | | pItemCarriers = pItemPj->getSubItem(2); |
| | | if (pItemCarriers == nullptr) continue; |
| | | pItemRecipes = pItemPj->getSubItem(3); |
| | | if (pItemRecipes == nullptr) continue; |
| | | SERVO::CProcessJob* pj = new SERVO::CProcessJob(pszPrjobid); |
| | | int size = pItemCarriers->getSubItemSize(); |
| | | for (int j = 0; j < size; j++) { |
| | | pItemCarrier = pItemCarriers->getSubItem(j); |
| | | strCarrierId.clear(); |
| | | if (pItemCarrier->getSubItemString(0, pszCarrierId)) { |
| | | strCarrierId = pszCarrierId; |
| | | } |
| | | |
| | | slots.clear(); |
| | | pItemSlots = pItemCarrier->getSubItem(1); |
| | | if (pItemSlots != nullptr) { |
| | | int size2 = pItemSlots->getSubItemSize(); |
| | | for (int k = 0; k < size2; k++) { |
| | | if (pItemSlots->getSubItemU1(k, slot)) { |
| | | slots.push_back(slot); |
| | | } |
| | | } |
| | | } |
| | | pj->addCarrier(strCarrierId, slots); |
| | | } |
| | | if (pItemRecipes->getSubItemU1(0, PRRECIPEMETHOD) |
| | | && pItemRecipes->getSubItemString(1, pszRecipeName)) { |
| | | pj->setRecipe(SERVO::RecipeMethod(PRRECIPEMETHOD), std::string(pszRecipeName)); |
| | | } |
| | | |
| | | pjs.push_back(pj); |
| | | } |
| | | |
| | | ASSERT(m_listener.onPRJobMultiCreate != nullptr); |
| | | int nRet = m_listener.onPRJobMultiCreate(this, pjs); |
| | | |
| | | |
| | | // 回复报文 |
| | | IMessage* pMessage = NULL; |
| | | HSMS_Create1Message(pMessage, m_nSessionId, 16, 16, ++m_nSystemByte); |
| | | ASSERT(pMessage); |
| | | ISECS2Item* pItemPrjobIds = pMessage->getBody()->addItem(); |
| | | ISECS2Item* pItemErrors = pMessage->getBody()->addItem(); |
| | | bool bHasError = false; |
| | | for (auto p : pjs) { |
| | | if (p->issue().empty()) { |
| | | pItemPrjobIds->addItem(p->id().c_str(), "PRJOBID"); |
| | | } |
| | | else { |
| | | bHasError = true; |
| | | } |
| | | } |
| | | if (bHasError) { |
| | | pItemErrors->addBoolItem(false, "ACKA"); |
| | | ISECS2Item* pItemErrors2 = pItemErrors->addItem(); |
| | | for (auto p : pjs) { |
| | | if (!p->issue().empty()) { |
| | | ISECS2Item* pItemErr = pItemErrors2->addItem(); |
| | | pItemErr->addU4Item(p->issue()[0].code, "ERRCODE"); |
| | | pItemErr->addItem(("<" + p->id() + ">" + p->issue()[0].text).c_str(), "ERRTEXT"); |
| | | } |
| | | } |
| | | } |
| | | m_pPassive->sendMessage(pMessage); |
| | | LOGI("<HSMS>[SECS Msg SEND]S16F16 (SysByte=%u)", pMessage->getHeader()->systemBytes); |
| | | HSMS_Destroy1Message(pMessage); |
| | | |
| | | |
| | | // 释放有问题(未添加到master)的内存 |
| | | for (auto p : pjs) { |
| | | if(!p->issue().empty()) delete p; |
| | | } |
| | | pjs.clear(); |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | // S5F1 |
| | | int CHsmsPassive::requestAlarmReport(int ALCD, int ALID, const char* ALTX) |
| | | { |