| | |
| | | { |
| | | m_nSyncStatus = SS_NONE; |
| | | m_nTotalMasterRecipeCount = 0; |
| | | m_nTotalParameterCount = 0; |
| | | m_nWordThreadAddr = 0; |
| | | m_hWorkStop = nullptr; |
| | | m_hWorkThreadHandle = nullptr; |
| | |
| | | unlock(); |
| | | } |
| | | |
| | | int CRecipesManager::decodeRecipeListReport(const char* pszData, size_t size) |
| | | short CRecipesManager::decodeRecipeListReport(const char* pszData, size_t size) |
| | | { |
| | | int index = 0; |
| | | int unitNo, reportType, totalMasterRecipeCount; |
| | |
| | | ASSERT(pRecipeList); |
| | | |
| | | |
| | | // 这里暂时只处理reportType=4,即Request from EAS |
| | | if (reportType == 4) { |
| | | /* |
| | | 1: Create |
| | | 2: Modify |
| | | 3: Delete |
| | | 4: Request from EAS |
| | | */ |
| | | if (reportType == RT_CREATE) { |
| | | |
| | | } |
| | | else if (reportType == RT_MODIFY) { |
| | | |
| | | } |
| | | else if (reportType == RT_DELETE) { |
| | | |
| | | } |
| | | else if (reportType == RT_REQUEST_FROM_EAS) { |
| | | int nRet = pRecipeList->addRecipePacket(toatlGroupCount, currentGroupCount, pszIdsData, 250 * 2); |
| | | if (MRLRC_CURRENT_RECIPE_COMPLETE == nRet) { |
| | | lock(); |
| | |
| | | return MRLRC_OK; |
| | | } |
| | | |
| | | short CRecipesManager::decodeRecipeParameterReport(const char* pszData, size_t size) |
| | | { |
| | | int index = 0; |
| | | int masterRecipeId, localRecipeId, unitNo, reportType; |
| | | int totalParameterCount; |
| | | int toatlGroupCount, currentGroupCount; |
| | | const char* pszParameterData; |
| | | |
| | | masterRecipeId = CToolUnits::toInt16(&pszData[index]); |
| | | index += 2; |
| | | |
| | | localRecipeId = CToolUnits::toInt16(&pszData[index]); |
| | | index += 2; |
| | | |
| | | unitNo = CToolUnits::toInt16(&pszData[index]); |
| | | index += 2; |
| | | |
| | | reportType = CToolUnits::toInt16(&pszData[index]); |
| | | index += 2; |
| | | |
| | | totalParameterCount = CToolUnits::toInt16(&pszData[index]); |
| | | index += 2; |
| | | |
| | | toatlGroupCount = CToolUnits::toInt16(&pszData[index]); |
| | | index += 2; |
| | | |
| | | currentGroupCount = CToolUnits::toInt16(&pszData[index]); |
| | | index += 2; |
| | | |
| | | pszParameterData = &pszData[index]; |
| | | |
| | | |
| | | lock(); |
| | | if (m_nTotalParameterCount == 0) m_nTotalParameterCount = toatlGroupCount; |
| | | if (m_nTotalParameterCount != toatlGroupCount) { |
| | | return MRLRC_MASTER_RECIPE_LIST_COUNT_NG; |
| | | } |
| | | m_nTimeoutCount = 0; |
| | | unlock(); |
| | | |
| | | |
| | | |
| | | |
| | | // 找到对应CRecipeList, 找不到则新建 |
| | | /* |
| | | lock(); |
| | | CRecipeList* pRecipeList = getRecipeListFromTemp(unitNo); |
| | | if (pRecipeList == nullptr) { |
| | | pRecipeList = new CRecipeList(unitNo); |
| | | m_mapRecipesTemp[unitNo] = pRecipeList; |
| | | } |
| | | unlock(); |
| | | ASSERT(pRecipeList); |
| | | */ |
| | | |
| | | /* |
| | | 1: Create |
| | | 2: Modify |
| | | 3: Delete |
| | | 4: Request from EAS |
| | | */ |
| | | /* |
| | | if (reportType == RT_CREATE) { |
| | | |
| | | } |
| | | else if (reportType == RT_MODIFY) { |
| | | |
| | | } |
| | | else if (reportType == RT_DELETE) { |
| | | |
| | | } |
| | | else if (reportType == RT_REQUEST_FROM_EAS) { |
| | | int nRet = pRecipeList->addRecipePacket(toatlGroupCount, currentGroupCount, pszIdsData, 250 * 2); |
| | | if (MRLRC_CURRENT_RECIPE_COMPLETE == nRet) { |
| | | lock(); |
| | | if (m_nTotalMasterRecipeCount == m_mapRecipesTemp.size()) { |
| | | for (auto item : m_mapRecipes) { |
| | | delete item.second; |
| | | } |
| | | m_mapRecipes = m_mapRecipesTemp; |
| | | m_mapRecipesTemp.clear(); |
| | | m_nSyncStatus = SS_COMPLETE; |
| | | unlock(); |
| | | return MRLRC_OK; |
| | | } |
| | | unlock(); |
| | | } |
| | | else if (MRLRC_CONTINUE == nRet) { |
| | | return MRLRC_CONTINUE; |
| | | } |
| | | } |
| | | */ |
| | | |
| | | return MRLRC_OK; |
| | | } |
| | | |
| | | CRecipeList* CRecipesManager::getRecipeListFromTemp(int unitNo) |
| | | { |
| | | auto iter = m_mapRecipesTemp.find(unitNo); |