| | |
| | | if (pszBuffer == nullptr) { |
| | | index += sizeof(int); |
| | | for (auto item : m_listActionSpooling) { |
| | | index += item->serialize(pszBuffer, nBufferSize); |
| | | if (item == nullptr || item->getSendMessage() == nullptr) { |
| | | LOGE("<HSMS>skip spooling item: null send message"); |
| | | continue; |
| | | } |
| | | int nRet = item->serialize(nullptr, 0); |
| | | if (nRet <= 0) { |
| | | LOGE("<HSMS>skip spooling item: serialize failed"); |
| | | continue; |
| | | } |
| | | index += nRet; |
| | | } |
| | | |
| | | index += calcSpoolCfgSize(); |
| | |
| | | return index; |
| | | } |
| | | else { |
| | | int nTemp, nRet; |
| | | int nTemp = 0; |
| | | int nRet = 0; |
| | | |
| | | nTemp = (int)m_listActionSpooling.size(); |
| | | for (auto item : m_listActionSpooling) { |
| | | if (item == nullptr || item->getSendMessage() == nullptr) { |
| | | continue; |
| | | } |
| | | if (item->serialize(nullptr, 0) > 0) { |
| | | ++nTemp; |
| | | } |
| | | } |
| | | |
| | | memcpy(&pszBuffer[index], &nTemp, sizeof(int)); |
| | | index += sizeof(int); |
| | | |
| | | for (auto item : m_listActionSpooling) { |
| | | if (item == nullptr || item->getSendMessage() == nullptr) { |
| | | LOGE("<HSMS>skip spooling item: null send message"); |
| | | continue; |
| | | } |
| | | nRet = item->serialize(&pszBuffer[index], nBufferSize); |
| | | if (nRet <= 0) break; |
| | | if (nRet <= 0) { |
| | | LOGE("<HSMS>skip spooling item: serialize failed"); |
| | | continue; |
| | | } |
| | | index += nRet; |
| | | } |
| | | |
| | |
| | | for (int i = 0; i < nTemp; i++) { |
| | | CHsmsAction* pAction = new CHsmsAction(); |
| | | nRet = pAction->unserialize(&pszBuffer[index], nBufferSize - index); |
| | | if (nRet <= 0) break; |
| | | if (nRet <= 0 || pAction->getSendMessage() == nullptr) { |
| | | delete pAction; |
| | | break; |
| | | } |
| | | index += nRet; |
| | | m_listActionSpooling.push_back(pAction); |
| | | } |
| | |
| | | Unlock(); |
| | | if (!selected) { |
| | | IMessage* pMsg = pAction->getSendMessage(); |
| | | if (pMsg == NULL) { |
| | | LOGE("<HSMS>spooling drop: null send message"); |
| | | delete pAction; |
| | | continue; |
| | | } |
| | | uint8_t streamId = 0; |
| | | uint8_t functionId = 0; |
| | | if (pMsg && pMsg->getHeader()) { |
| | |
| | | |
| | | if (pAction->isNeedWaitReply()) { |
| | | // 如果需要等待回复 |
| | | IMessage* pMessage = pAction->getSendMessage(); |
| | | if (pMessage == NULL) { |
| | | LOGE("<HSMS>drop action: null send message"); |
| | | delete pAction; |
| | | continue; |
| | | } |
| | | Lock(); |
| | | m_pActiveAction = pAction; |
| | | IMessage* pMessage = pAction->getSendMessage(); |
| | | Unlock(); |
| | | |
| | | ASSERT(pMessage); |
| | |
| | | Unlock(); |
| | | } |
| | | else { |
| | | IMessage* pMessage = pAction->getSendMessage(); |
| | | if (pMessage == NULL) { |
| | | LOGE("<HSMS>drop action: null send message"); |
| | | delete pAction; |
| | | continue; |
| | | } |
| | | Lock(); |
| | | m_listActionSent.push_back(pAction); |
| | | IMessage* pMessage = pAction->getSendMessage(); |
| | | Unlock(); |
| | | |
| | | ASSERT(pMessage); |
| | |
| | | |
| | | Lock(); |
| | | CHsmsAction* pAction = new CHsmsAction(ACTION_HELLO, FALSE, m_nActionTimeout); |
| | | m_listAction.push_back(pAction); |
| | | IMessage* pMessage = NULL; |
| | | HSMS_Create1Message(pMessage, m_nSessionId, 1 | REPLY, 1, ++m_nSystemByte); |
| | | ASSERT(pMessage); |
| | | if (HSMS_Create1Message(pMessage, m_nSessionId, 1 | REPLY, 1, ++m_nSystemByte) != 0 || pMessage == NULL) { |
| | | LOGE("<HSMS>S1F1 create message failed"); |
| | | delete pAction; |
| | | Unlock(); |
| | | return ER_CREATED_MESSAGE; |
| | | } |
| | | pAction->setSendMessage(pMessage); |
| | | m_listAction.push_back(pAction); |
| | | |
| | | SetEvent(m_hCimWorkEvent); |
| | | Unlock(); |
| | |
| | | CHsmsAction* pAction = new CHsmsAction(ACTION_ALARM_REPORT, TRUE, m_nActionTimeout); |
| | | |
| | | IMessage* pMessage = NULL; |
| | | HSMS_Create1Message(pMessage, m_nSessionId, 5 | REPLY, 1, ++m_nSystemByte); |
| | | ASSERT(pMessage); |
| | | if (HSMS_Create1Message(pMessage, m_nSessionId, 5 | REPLY, 1, ++m_nSystemByte) != 0 || pMessage == NULL) { |
| | | LOGE("<HSMS>S5F1 create message failed"); |
| | | delete pAction; |
| | | Unlock(); |
| | | return ER_CREATED_MESSAGE; |
| | | } |
| | | ISECS2Item* pItem = pMessage->getBody(); |
| | | pItem->addBinaryItem(szALCD, 1, "ALCD"); |
| | | pItem->addU4Item(ALID, "ALID"); |
| | |
| | | Lock(); |
| | | CHsmsAction* pAction = new CHsmsAction(ACTION_EVENT_REPORT, TRUE, m_nActionTimeout); |
| | | IMessage* pMessage = NULL; |
| | | HSMS_Create1Message(pMessage, m_nSessionId, 6 | REPLY, 11, ++m_nSystemByte); |
| | | ASSERT(pMessage); |
| | | if (HSMS_Create1Message(pMessage, m_nSessionId, 6 | REPLY, 11, ++m_nSystemByte) != 0 || pMessage == NULL) { |
| | | LOGE("<HSMS>S6F11 create message failed"); |
| | | delete pAction; |
| | | Unlock(); |
| | | return ER_CREATED_MESSAGE; |
| | | } |
| | | ISECS2Item* pItem = pMessage->getBody(); |
| | | // pItem->addU2Item(++DATAID, "DATAID"); // 根据别的日志显示DATAID恒为0,所以我们先照使用0 |
| | | pItem->addU2Item(0, "DATAID"); |