diff --git a/cfg_parse/cfg_parser.cpp b/cfg_parse/cfg_parser.cpp index c5cd493..fc8064c 100644 --- a/cfg_parse/cfg_parser.cpp +++ b/cfg_parse/cfg_parser.cpp @@ -202,7 +202,7 @@ std::string LEDGER_UPDATE_FN = "LedgerUpdate.log"; const int MAX_CPUNO = 10; //lnk20250121终端台账数量配置 -int IED_COUNT = 200; //默认200 +int IED_COUNT = 300; //默认300 //WW 2-23-08-20 add start otl_connect db; //OTL数据库连接对象 WW 2023-08-20 @@ -12225,7 +12225,18 @@ int parse_device_cfg_web() g_node->n_clients = count_cfg; //这里开辟的ied的空间由配置文件中的终端台账数量决定lnk20250121 - g_node->clients = (ied_t**)apr_pcalloc(g_cfg_pool, IED_COUNT * sizeof(ied_t*));//g_node->clients 这块大内存空间存储了 count_cfg 个 ied_t* 类型的指针(即一个指针数组)这是(指向内存块的指针)的指针数组 + if(IED_COUNT < count_cfg){ //申请数至少是初始化能读取到的台账数,防止设置失误导致的崩溃。 + //如果是多进程,IED_COUNT应该设置为大于平均数, + //如果是单进程则应该设置为大于终端总数, + //单进程多进程同时存在则单进程应该大于终端总数,否则添加台账时单进程部分就无法同步添加。 + g_node->clients = (ied_t**)apr_pcalloc(g_cfg_pool, count_cfg * sizeof(ied_t*)); + //添加提示 + std::cout << "!!!!!!!!!!single process can not add any ledger unless reboot!!!!!!!"<< std::endl; + } + else{ + g_node->clients = (ied_t**)apr_pcalloc(g_cfg_pool, IED_COUNT * sizeof(ied_t*));//g_node->clients 这块大内存空间存储了 count_cfg 个 ied_t* 类型的指针(即一个指针数组)这是(指向内存块的指针)的指针数组 + } + //把ied放入数组 for (int k = 0; k < count_cfg; k++){ diff --git a/json/create_json.cpp b/json/create_json.cpp index 94545d2..e5e24df 100644 --- a/json/create_json.cpp +++ b/json/create_json.cpp @@ -1769,28 +1769,29 @@ int transfer_json_block_data(char v_wiring_type[], json_block_data *data) //json } #endif + ////lnk2024-8-15 区分星型,角型接线 - if (strcmp(v_wiring_type, "01") == 0) //lnk2024-8-15 星型接线 + if (strcmp(v_wiring_type, "1") == 0) //lnk2024-8-15 星型接线 { - cout << "report v_wiring_type is" << v_wiring_type << endl; + cout << "1 report v_wiring_type is" << v_wiring_type << endl; if (xmlinfo_list.contains(data->dev_type)) { cout << "transfer_json_block_data contain data->dev_type" << endl; ctopic_list = xmlinfo_list[data->dev_type]->topicList; } else { - cout << "transfer_json_block_data not contain data->dev_type" << endl; + cout << "transfer_json_block_data not contain data->dev_type:" << data->dev_type.toStdString() << " !!!!"<< endl; ctopic_list = topicList; } } else //lnk2024-8-15 角型接线 { - cout << "report v_wiring_type is" << v_wiring_type << endl; + cout << "2 report v_wiring_type is" << v_wiring_type << endl; if (xmlinfo_list2.contains(data->dev_type)) { cout << "transfer_json_block_data contain data->dev_type" << endl; ctopic_list = xmlinfo_list2[data->dev_type]->topicList; } else { - cout << "transfer_json_block_data not contain data->dev_type" << endl; + cout << "transfer_json_block_data not contain data->dev_type:" << data->dev_type.toStdString() << " !!!!"<< endl; ctopic_list = topicList; } } @@ -3733,6 +3734,13 @@ void Set_xml_databaseinfo(char* MODEL_ID, char* TMNL_TYPE, char* FILE_PATH, char else { }*/ + //调试用 + if (xmlinfo_list.contains(type)) { + std::cout << "xmlinfo_list.contains" << type.toStdString() <valuestring); // 解析 messageBody 字符串 + const char* messageBodyStr = messageJson->valuestring; + if (messageBodyStr == nullptr || strlen(messageBodyStr) == 0) { + std::cerr << "Failed to parse 'messageBody' JSON or it's empty." << std::endl; + cJSON_Delete(root); + return false; + } + + cJSON* messageBody = cJSON_Parse(messageBodyStr); // 解析 messageBody 字符串 if (messageBody == NULL) { std::cerr << "Failed to parse 'messageBody' JSON." << std::endl; cJSON_Delete(root); @@ -793,7 +800,14 @@ bool parseJsonMessageRT(const std::string& body, std::string& devSeries, std::st } // 解析 messageBody 中的 JSON 字符串 - cJSON* messageBody = cJSON_Parse(messageJson->valuestring); // 解析 messageBody 字符串 + const char* messageBodyStr = messageJson->valuestring; + if (messageBodyStr == nullptr || strlen(messageBodyStr) == 0) { + std::cerr << "Failed to parse 'messageBody' JSON or it's empty." << std::endl; + cJSON_Delete(root); + return false; + } + + cJSON* messageBody = cJSON_Parse(messageBodyStr); // 解析 messageBody 字符串 if (messageBody == NULL) { std::cerr << "Failed to parse 'messageBody' JSON." << std::endl; cJSON_Delete(root); @@ -1030,7 +1044,14 @@ void parse_set(const std::string& json_str) { } // 解析 messageBody 中的 JSON 字符串 - cJSON* messageBody = cJSON_Parse(messageJson->valuestring); // 解析 messageBody 字符串 + const char* messageBodyStr = messageJson->valuestring; + if (messageBodyStr == nullptr || strlen(messageBodyStr) == 0) { + std::cerr << "Failed to parse 'messageBody' JSON or it's empty." << std::endl; + cJSON_Delete(root); + return; + } + + cJSON* messageBody = cJSON_Parse(messageBodyStr); // 解析 messageBody 字符串 if (messageBody == NULL) { std::cerr << "Failed to parse 'messageBody' JSON." << std::endl; cJSON_Delete(root); @@ -1053,9 +1074,9 @@ void parse_set(const std::string& json_str) { } //判断是不是自己进程号: - //int index_value = index->valueint; - string index_value_str = index->valuestring; - int index_value = StringToInt(index_value_str); + int index_value = index->valueint; + //string index_value_str = index->valuestring; + //int index_value = StringToInt(index_value_str); //进程号为0的进程处理所有控制消息 if (index_value != g_front_seg_index && g_front_seg_index !=0) { @@ -1355,7 +1376,14 @@ void parse_control(const std::string& json_str, const std::string& output_dir) { } // 解析 messageBody 中的 JSON 字符串 - cJSON* messageBody = cJSON_Parse(messageJson->valuestring); // 解析 messageBody 字符串 + const char* messageBodyStr = messageJson->valuestring; + if (messageBodyStr == nullptr || strlen(messageBodyStr) == 0) { + std::cerr << "Failed to parse 'messageBody' JSON or it's empty." << std::endl; + cJSON_Delete(root); + return; + } + + cJSON* messageBody = cJSON_Parse(messageBodyStr); // 解析 messageBody 字符串 if (messageBody == NULL) { std::cerr << "Failed to parse 'messageBody' JSON." << std::endl; cJSON_Delete(root); @@ -1378,9 +1406,10 @@ void parse_control(const std::string& json_str, const std::string& output_dir) { } //判断是不是自己进程号: - //int index_value = index->valueint; - string index_value_str = index->valuestring; - int index_value = StringToInt(index_value_str); + int index_value = index->valueint; + //string index_value_str = index->valuestring; + //int index_value = StringToInt(index_value_str); + //进程号为0的进程处理所有台账更新消息 if (index_value != g_front_seg_index && g_front_seg_index !=0) { diff --git a/mms/mms_process.c b/mms/mms_process.c index 9e2dad3..e56df68 100644 --- a/mms/mms_process.c +++ b/mms/mms_process.c @@ -121,10 +121,17 @@ apr_status_t init_rem_dib_table() struct in_addr ip; chnl_usr_t *chnl_usr; - set_rem_dib_table_size( IED_COUNT );//按照最大的终端数来申请 - g_pt61850app->chnl_usr = apr_pcalloc( g_init_pool,IED_COUNT*sizeof(chnl_usr_t*) ); - printf( "set_rem_dib_table_size %d \n",IED_COUNT ); - + if(IED_COUNT < g_pt61850app->chnl_counts){ + set_rem_dib_table_size( g_pt61850app->chnl_counts );//按照最大的终端数来申请 + g_pt61850app->chnl_usr = apr_pcalloc( g_init_pool,g_pt61850app->chnl_counts*sizeof(chnl_usr_t*) ); + printf( "set_rem_dib_table_size %d \n",g_pt61850app->chnl_counts ); + } + else{ + set_rem_dib_table_size( IED_COUNT );//按照最大的终端数来申请 + g_pt61850app->chnl_usr = apr_pcalloc( g_init_pool,IED_COUNT*sizeof(chnl_usr_t*) ); + printf( "set_rem_dib_table_size %d \n",IED_COUNT ); + } + for(iedno=0 ; iednon_clients; iedno++) { ied = g_node->clients[iedno]; for(chnl_no=0 ; chnl_nochncount; chnl_no++) {