diff --git a/cfg_parse/cfg_parser.cpp b/cfg_parse/cfg_parser.cpp index 0b84592..7f76673 100644 --- a/cfg_parse/cfg_parser.cpp +++ b/cfg_parse/cfg_parser.cpp @@ -3484,21 +3484,21 @@ int GetServerIndexFromDB() // void parse_one_rpt_log_ini(int idx, QStringList* rpt_cfg_strlist, QStringList* log_cfg_strlist, char* type) { char* tmp; - tmp = Get_xmlpath(type); - if (tmp == NULL) { + tmp = Get_xmlpath(type);//获取模型id号 + if (tmp == NULL) {//找不到模型编号使用默认的型号和配置文件 //zw修改 2023 - 8 - 15 将触发报告的解析移至XML 原配置RptLogCfg.ini取消 if (strcmp(subdir, "cfg_stat_data") == 0) { QString devtype; devtype.append(type); QString devtype2; - devtype2.append("HL-6810"); + devtype2.append("HL-6810");//稳态默认型号HL-6810 qDebug() << "cfg_stat_data"; QString xml_dir = QString("../") + QString("etc/"); //Linux下调试路径 QDomDocument doc; //新建QDomDocument类对象,它代表一个XML文档 - QFile file(xml_dir + QString("JiangSu_Config.xml")); + QFile file(xml_dir + QString("JiangSu_Config.xml"));//默认配置文件JiangSu_Config.xml if (!file.open(QIODevice::ReadOnly | QFile::Text)) //以只读方式打开xml { qDebug() << "Read RPT Error1"; @@ -3622,7 +3622,7 @@ void parse_one_rpt_log_ini(int idx, QStringList* rpt_cfg_strlist, QStringList* l log_cfg_strlist->append(log_cfg_str); } } - else + else//型号不为空读取指定的配置文件 { QString tmppath; tmppath.append("/FeProject/dat/").append(tmp).append(".xml"); @@ -3685,7 +3685,7 @@ void parse_one_rpt_log_ini(int idx, QStringList* rpt_cfg_strlist, QStringList* l if (node2.isElement()) { rpt_cfg_strlist->append(node2.toElement().attribute("ReportControl")); - qDebug() << node2.toElement().attribute("ReportControl").toAscii().data(); + qDebug() << node2.toElement().attribute("ReportControl").toAscii().data();//读取各个报告配置 } } } @@ -3697,7 +3697,7 @@ void parse_one_rpt_log_ini(int idx, QStringList* rpt_cfg_strlist, QStringList* l n = n.nextSibling(); } - QString log_cfg_str = "LLN0$LG$lcStatisticData,dsStatisticData,PQM1,0,600000,1,0,0,0"; + QString log_cfg_str = "LLN0$LG$lcStatisticData,dsStatisticData,PQM1,0,600000,1,0,0,0";//日志的配置是写死的 log_cfg_strlist->append(log_cfg_str); } @@ -3759,6 +3759,7 @@ void parse_one_rpt_log_ini(int idx, QStringList* rpt_cfg_strlist, QStringList* l n = n.nextSibling(); } + //实时数据没有日志 //QString log_cfg_str = "LLN0$LG$lcStatisticData,dsStatisticData,PQM1,0,600000,1,0,0,0"; //log_cfg_strlist->append(log_cfg_str); } @@ -3799,7 +3800,7 @@ void parse_one_rpt_log_ini(int idx, QStringList* rpt_cfg_strlist, QStringList* l if (node.isElement()) { QString strTag2 = node.toElement().tagName(); //DataType节点 - if ("ReportEvent" == strTag2) + if ("ReportEvent" == strTag2)//区分点 { QDomNodeList list2 = node.childNodes(); //获得元素DataType的所有子节点的列表 for (int i2 = 0; i2 < list2.count(); i2++) //遍历 Monitor列表 @@ -3887,7 +3888,7 @@ int parse_rpt_log_ini() apr_snprintf(buf, sizeof(buf), "%s", rpt_cfg_strlists[type]->at(i).toAscii().constData()); - fill_rptctrl_by_cfg(LD_info, i, buf); + fill_rptctrl_by_cfg(LD_info, i, buf);// } @@ -4905,7 +4906,7 @@ void process_recall_config(recall_xml_t* recall_xml) } else { printf("\n Find LD_info != null \n"); - if (LD_info->autorecallflag != 0 || LD_info->autorecallcount == 0) { + if (LD_info->autorecallflag != 0 || LD_info->autorecallcount == 0) { // if (LD_info->autorecallcount != 0) { for (int j = 0; j < LD_info->autorecallcount; j++) { delete LD_info->autorecall[j]; @@ -12221,7 +12222,7 @@ int parse_device_cfg_web() return APR_ENOMEM; ied_usr->dev_flag = ENABLE;//终端有效 - ied->chncount = 1; + ied->chncount = 1;//设备通信端口总数 //这里申请的空间基于ied的数量,挂载到ied上 ied->channel = (channel_t*)apr_pcalloc(g_cfg_pool, sizeof(channel_t) * ied->chncount);//通信结构在g_cfg_pool中申请空间:终端的ip端口等 ied->channel[0].ied = ied; @@ -14039,7 +14040,7 @@ int update_one_terminal_ledger(terminal* update, int i,ied_t* ied,int terminal_i printf("ied_usr->dev_key (default): %s\n", ied_usr->dev_key); } - ied_usr->dev_idx = terminal_index; //终端排号 + ied_usr->dev_idx = terminal_index; //终端排号,g_node下标 printf("dev_idx: %d\n", ied_usr->dev_idx); ied->channel[0].channel_type = CHANNEL_TYPE_IPV4; // channel @@ -14104,7 +14105,7 @@ int update_one_terminal_ledger(terminal* update, int i,ied_t* ied,int terminal_i chnl_usr = (chnl_usr_t*)ied->channel[0].connect; } - chnl_usr->chnl = &(ied->channel[0]); + chnl_usr->chnl = &(ied->channel[0]);//如果是已有的ied,这个值是原本就存在的,再赋值一次 chnl_usr->chnl_id = 0; chnl_usr->m_state = CHANNEL_DISCONNECTED; chnl_usr->m_ClosedMsTime = NEXT_CONNECT_TIME * (-1); @@ -14176,12 +14177,22 @@ int update_one_terminal_ledger(terminal* update, int i,ied_t* ied,int terminal_i // 填充 LD_info if (ied && ied->usr_ext && line_info.cpuno && ((int)line_info.cpuno < 10)) { char str[256]; - byte_t cpuno = line_info.cpuno; + byte_t cpuno = line_info.cpuno; //使用新台账的逻辑序列号,在使用原有ied的情况下,如果序列号数量小于原有数量,那么新的部分会被覆盖,如果删除时没有清理,原有的其他部分会仍存在内存中,但不会被使用 printf("cpuno: %d\n", line_info.cpuno); printf("index cpuno: %d\n", cpuno - 1); + ied_usr = (ied_usr_t*)ied->usr_ext; - ied_usr->LD_info[cpuno - 1] = line_info; // cpuno默认是1 - ied_usr->LD_info[cpuno - 1].ied = ied; + //ied_usr->LD_info[cpuno - 1] = line_info;//这个放在后面,因为需要先判断原有的指针 + //ied_usr->LD_info[cpuno - 1].ied = ied; //这个放在后面,因为需要先判断原有的指针 + + //用来记录可能的已有的ldname + char *ldname = NULL; + + //用来记录可能已有的报告、日志数组 + loginfo_t **loginfo = NULL; + rptinfo_t **rptinfo = NULL; + + //这些可能是已有的内存,如果存在则需要清除,(在台账删除时就应该清除) apr_snprintf(str, sizeof(str), "PQMonitorPQM%d", cpuno); // 仅在没有值时更新 LD_name,避免重复分配内存 if (ied_usr->LD_info[cpuno - 1].LD_name == NULL) { @@ -14189,21 +14200,53 @@ int update_one_terminal_ledger(terminal* update, int i,ied_t* ied,int terminal_i } else {//已有则替换,在原有空间上覆盖 apr_cpystrn(ied_usr->LD_info[cpuno - 1].LD_name, str, sizeof(ied_usr->LD_info[cpuno - 1].LD_name)); } + ldname = ied_usr->LD_info[cpuno - 1].LD_name; - // 更新哈希表,避免重复分配内存,原来的ied就分配了空的哈希表就不再分配,这个哈希表暂时没有作用 - if (ied_usr->LD_info[cpuno - 1].ht_fcd == NULL) { - ied_usr->LD_info[cpuno - 1].ht_fcd = apr_hash_make(g_init_pool); +///////// //清空已有的补招数组占用空间 + if (ied_usr->LD_info[cpuno - 1]->autorecallcount != 0) { + for (int j = 0; j < ied_usr->LD_info[cpuno - 1]->autorecallcount; j++) { + if(NULL != ied_usr->LD_info[cpuno - 1]->autorecall[j]){ + delete ied_usr->LD_info[cpuno - 1]->autorecall[j]; + } + } + if(NULL != ied_usr->LD_info[cpuno - 1]->autorecall){ + delete ied_usr->LD_info[cpuno - 1]->autorecall; + } + + ied_usr->LD_info[cpuno - 1]->autorecallcount = 0; + } + +//////// //记录原有的报告和日志数组 + loginfo = ied_usr->LD_info[cpuno - 1].loginfo?ied_usr->LD_info[cpuno - 1].loginfo:NULL; + rptinfo = ied_usr->LD_info[cpuno - 1].rptinfo?ied_usr->LD_info[cpuno - 1].rptinfo:NULL; + + + //避免重复分配内存,如果使用已存在的ied,那么它之前初始化就分配了哈希表,如果在删除台账时没有清除,则需要将原来的清除 + if (ied_usr->LD_info[cpuno - 1].ht_fcd != NULL) { + apr_hash_destroy(ied_usr->LD_info[cpuno - 1].ht_fcd); } - if (ied_usr->LD_info[cpuno - 1].ht_full_fcda == NULL) { - ied_usr->LD_info[cpuno - 1].ht_full_fcda = apr_hash_make(g_init_pool); + if (ied_usr->LD_info[cpuno - 1].ht_full_fcda != NULL) { + apr_hash_destroy(ied_usr->LD_info[cpuno - 1].ht_full_fcda); } - ied_usr->LD_info[cpuno - 1].rptcount = 0; + + ied_usr->LD_info[cpuno - 1] = line_info;//这个放在后面,因为需要先判断原有的指针 + ied_usr->LD_info[cpuno - 1].ied = ied; //这个放在后面,因为需要先判断原有的指针 + ied_usr->LD_info[cpuno - 1].LD_name = ldname;//记录原有的或者新的ldname + + ied_usr->LD_info[cpuno - 1].ht_fcd = apr_hash_make(g_init_pool); //重新创建哈希表 + ied_usr->LD_info[cpuno - 1].ht_full_fcda = apr_hash_make(g_init_pool); + + ied_usr->LD_info[cpuno - 1].rptcount = 0; //报告数清零,这个值在ied_usr->LD_info[cpuno - 1] = line_info;时应该就已清0,报告的空间会在报告块初始化时分配 printf("rptcount: %d\n", ied_usr->LD_info[cpuno - 1].rptcount); - if (cpuno > ied->cpucount) { - ied->cpucount = cpuno;//如果原有的监测点比新增的监测点多,没有被覆盖的部分仍存在内存中,但是这个值会保证我们不会访问到那些之前的没有被覆盖的监测点 + + //使用原有的报告日志空间 + ied_usr->LD_info[cpuno - 1].loginfo = loginfo; + ied_usr->LD_info[cpuno - 1].rptinfo = rptinfo; + + if (cpuno > ied->cpucount) {//新台账的逻辑号大于ied原有的cpu数(初始化是0),则更新cpu数,用来记录有多少个监测点 + ied->cpucount = cpuno; } } - // ied_usr->LD_info[j] = line_info; printf("Monitor Info [ID: %s, Name: %s] saved in LD_info\n", line_info.mp_id, line_info.name); } return 0; @@ -14333,6 +14376,111 @@ apr_pool_t* create_sub_pool(apr_pool_t* parent_pool, const char* terminal_id) { return new_sub_pool; } +////////////////////////////////////////////////////////////////////////////////////////////////// +//台账变更的报告块初始化 +int parse_rpt_log_ini_one(ied_t* ied) +{ + QMap rpt_cfg_strlists; + QMap log_cfg_strlists; + + int iedno, cpuno; + ied_usr_t* ied_usr; + LD_info_t* LD_info; + char buf[256]; + + ied_usr = GET_IEDEXT_ADDR(ied); + QString type; + type.append(ied_usr->dev_type); + if (!rpt_cfg_strlists.contains(type)) + { + QStringList* rpt_temp = new QStringList(); + QStringList* log_temp = new QStringList(); + rpt_cfg_strlists.insert(type, rpt_temp);//报告控制列表 + log_cfg_strlists.insert(type, log_temp);//日志控制列表 + //g_DevFlag没有使用 + parse_one_rpt_log_ini(g_DevFlag, rpt_cfg_strlists[type], log_cfg_strlists[type], ied_usr->dev_type); + } + for (cpuno = 0; cpuno < ied->cpucount; cpuno++) {//根据ied实际的检测点数遍历 + LD_info = &(ied_usr->LD_info[cpuno]); + char str[256]; + char* tmp = Get_IED(ied_usr->dev_type); + qDebug() << tmp << endl; + + //这些可能是已有的内存lnk20250122 + apr_snprintf(str, sizeof(str), tmp, cpuno + 1); + + //ied_usr->LD_info[cpuno].LD_name = apr_pstrdup(g_init_pool, str);//lnk20250122 + + // 仅在没有值时更新 LD_name,避免重复分配内存 + if (ied_usr->LD_info[cpuno].LD_name == NULL) { + ied_usr->LD_info[cpuno].LD_name = apr_pstrdup(g_init_pool, str); + } else {//已有则替换,在原有空间上覆盖 + apr_cpystrn(ied_usr->LD_info[cpuno - 1].LD_name, str, sizeof(ied_usr->LD_info[cpuno - 1].LD_name)); + } + //这些可能是已有的内存lnk20250122 + + delete[] tmp; + + //初始化监测点的报告控制 + init_rptctrl_by_count(LD_info, rpt_cfg_strlists[type]->size()); + for (int i = 0; i < rpt_cfg_strlists[type]->size(); ++i) { + apr_snprintf(buf, sizeof(buf), "%s", rpt_cfg_strlists[type]->at(i).toAscii().constData()); + fill_rptctrl_by_cfg(LD_info, i, buf); + } + //初始化监测点的日志控制 + init_logctrl_by_count(LD_info, log_cfg_strlists[type]->size()); + for (int i = 0; i < log_cfg_strlists[type]->size(); ++i) { + apr_snprintf(buf, sizeof(buf), "%s", log_cfg_strlists[type]->at(i).toAscii().constData()); + char* tmp = Get_LDevice(ied_usr->dev_type); + fill_logctrl_by_cfg(LD_info, i, buf, tmp); + delete[] tmp; + } + } + + //报告控制块和日志控制块处理结束后清理容器 + for (QMap::iterator it1 = log_cfg_strlists.begin(); it1 != log_cfg_strlists.end(); ++it1) + { + delete it1.value(); + } + for (QMap::iterator it2 = rpt_cfg_strlists.begin(); it2 != rpt_cfg_strlists.end(); ++it2) + { + delete it2.value(); + } + rpt_cfg_strlists.clear(); + log_cfg_strlists.clear(); + + return APR_SUCCESS; +} +////////////////////////////////////////////////////////////remdibtable +apr_status_t init_rem_dib_table_one(ied_t *ied) +{ + int pos = 0; + int iedno,chnl_no; + struct in_addr ip; + chnl_usr_t *chnl_usr; + + ied_usr_t* ied_usr; + + //插入的位置和g_node一样 + ied_usr = (ied_usr_t*)ied->usr_ext; + pos = ied_usr->dev_idx; + + for(chnl_no=0 ; chnl_nochncount; chnl_no++) { + chnl_usr = ied->channel[chnl_no].connect; + g_pt61850app->chnl_usr[pos] = chnl_usr; + ip.s_addr = htonl(ied->channel[chnl_no].addr); + strcpy(chnl_usr->ip_str,inet_ntoa(ip)); + printf( " add_rem_dib_table %s:%d \n",chnl_usr->ip_str ,ied->channel[chnl_no].port ); + add_rem_dib_table (pos++,chnl_usr->ip_str,ied->channel[chnl_no].port );//当前终端的IP端口记录到表中,这里要注意添加的下标,如果删除终端,这个表内的内容仍存在,再次使用时会被替换 + { + char comm_str[256]; + memset(comm_str,0,256); + apr_snprintf(comm_str,sizeof(comm_str),"%16s:%d\t\tinited",chnl_usr->ip_str,ied->channel[chnl_no].port); + add_comm_log(comm_str); + } + } + return APR_SUCCESS; +} /*封装C可调用的台账更新函数 *///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/mms/mms_process.c b/mms/mms_process.c index 57e5432..30084b7 100644 --- a/mms/mms_process.c +++ b/mms/mms_process.c @@ -79,7 +79,8 @@ extern int recall_daily; extern char* UDS_UPLOAD_URL; /////////////////////////////////////////////////////////////////// - +//lnk20250122start +#if 0 apr_status_t init_rem_dib_table() { int pos = 0; @@ -110,7 +111,40 @@ apr_status_t init_rem_dib_table() } return APR_SUCCESS; } +#endif +apr_status_t init_rem_dib_table() +{ + int pos = 0; + int iedno,chnl_no; + ied_t *ied; + 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 ); + + for(iedno=0 ; iednon_clients; iedno++) { + ied = g_node->clients[iedno]; + for(chnl_no=0 ; chnl_nochncount; chnl_no++) { + chnl_usr = ied->channel[chnl_no].connect; + g_pt61850app->chnl_usr[pos] = chnl_usr; + ip.s_addr = htonl(ied->channel[chnl_no].addr); + strcpy(chnl_usr->ip_str,inet_ntoa(ip)); + printf( " add_rem_dib_table %s:%d \n",chnl_usr->ip_str ,ied->channel[chnl_no].port ); + add_rem_dib_table (pos++,chnl_usr->ip_str,ied->channel[chnl_no].port ); + { + char comm_str[256]; + memset(comm_str,0,256); + apr_snprintf(comm_str,sizeof(comm_str),"%16s:%d\t\tinited",chnl_usr->ip_str,ied->channel[chnl_no].port); + add_comm_log(comm_str); + } + } + } + return APR_SUCCESS; +} +//lnk20250122end void CloseIECReports(chnl_usr_t *chnl_usr) { @@ -844,17 +878,17 @@ void process_ledger_update(trigger_update_xml_t *ledger_update_xml) int new_client_count = g_node->n_clients + 1; // 增加一个新的台账 //判断新增进程后是否超过原有的台账数组,如果超过了就从不使能的ied空间中找可用空间,如果还是没有那就提示不能荷载更多终端 - if(new_client_count > IED_COUNT){ + if(new_client_count > IED_COUNT){ //不更新台账数量 ied_t *ied_unused = NULL; ied_usr_t* ied_usr_unused = NULL; - ied_unused = find_ied_from_terminal_id(); + ied_unused = find_ied_unused();//遍历g_node找到第一个不使用的ied,这个ied之前初始化时分配过空间,直接占用 if(ied_unused != NULL){ ied_usr_unused = (ied_usr_t*)ied_unused->usr_ext; ied = ied_unused; //新增的ied指向已有的未使用的ied空间 - terminal_index = ied_usr_unused->dev_idx //记录这个ied的编号 + terminal_index = ied_usr_unused->dev_idx //记录这个ied的编号,即g_node的下标 //打印提示 - printf("!!!!!!!!ied index:%d ,terminal_id:%s has been taken!!!!!!!!!!\n",ied_usr_unused->dev_idx,ied_usr_unused->terminal_id); + printf("!!!!!!!!ied index:%d ,origin terminal_id:%s has been taken!!!!!!!!!!\n",ied_usr_unused->dev_idx,ied_usr_unused->terminal_id); //终端初始化,不需要再申请空间 ied_usr = (ied_usr_t*)ied->usr_ext; @@ -863,6 +897,7 @@ void process_ledger_update(trigger_update_xml_t *ledger_update_xml) ied_usr->dev_flag = ENABLE;//终端有效 ied->chncount = 1; //通信端口数 + //不再分配通道空间 ied->channel[0].ied = ied; //通道的所属设备 ied->channel[0].status = STATUS_BREAKOFF;//初始化为通信中断 ied->cpucount = 0; //监测点数初始为0,读取监测点台账时写入 @@ -870,13 +905,13 @@ void process_ledger_update(trigger_update_xml_t *ledger_update_xml) ied_take = 1;//ied之前存在 } - else{ + else{ //在已有的全部台账中都没找到不使用的ied,说明这个进程可挂的台账满了,不再处理 printf("!!!!!!!!!!ledger array is full!!!!!!\n"); return; } - } - else{//新增台帐后仍在台账范围 + }//新台账数量小于等于设定的台账数量 + else{ // 新增的台账在已有的台账数组中记录 g_node->clients[new_client_count - 1] = (ied_t*)apr_pcalloc(g_cfg_pool, sizeof(ied_t)); @@ -942,18 +977,18 @@ void process_ledger_update(trigger_update_xml_t *ledger_update_xml) //4-配置映射文件/////////////////////////////////// //5-报告块初始化////////////////////////////// - + parse_rpt_log_ini_one(ied); //5-报告块初始化/////////////////////////////////// //6-init_rem_dib_table////////////////////////////// - + init_rem_dib_table_one(ied) //6-init_rem_dib_table/////////////////////////////////// } } //////////////////////////////////////////////////////////////////////////////modify - update = ledger_update_xml->modify_updates; //处理新增台账部分 + update = ledger_update_xml->modify_updates; //处理修改台账部分 update_num = ledger_update_xml->modify_update_num; printf("modify ledger num:%d\n",update_num); for (i=0; ichannel) { - apr_pool_clear(ied_to_remove->channel); // 释放 g_cfg_pool 内存池中的 channel 内存 - ied_to_remove->channel = NULL; - } - // 释放 ied监测点台账结构体的内存 - if (ied_to_remove->usr_ext->LD_info) { - apr_pool_clear(ied_to_remove->usr_ext->LD_info); // 释放 g_init_pool 内存池中的 LD_info 内存 - ed_to_remove->usr_ext->LD_info = NULL; - } - - // 释放 ied台账结构体的内存 - if (ied_to_remove->usr_ext) { - apr_pool_clear(ied_to_remove->usr_ext); // 释放 g_init_pool 内存池中的 ied_usr 内存 - ied_to_remove->usr_ext = NULL; - } - - // 移动指针数组中的元素 - for (i = index_to_remove; i < g_node->n_clients - 1; i++) { - g_node->clients[i] = g_node->clients[i + 1]; - } - - // 重新分配内存以调整指针数组的大小 - ied_t** new_clients = (ied_t**)apr_pcalloc(g_cfg_pool, (g_node->n_clients - 1) * sizeof(ied_t*)); - memcpy(new_clients, g_node->clients, (g_node->n_clients - 1) * sizeof(ied_t*)); - - //释放原来的内存块 - apr_pool_clear(g_node->clients); - - // 更新指针数组和台账数量 - g_node->clients = new_clients; - g_node->n_clients--; //3-删除台账内容/////////////////////////////////// diff --git a/mms/parse_xml.c b/mms/parse_xml.c index 4712cca..43b5e03 100644 --- a/mms/parse_xml.c +++ b/mms/parse_xml.c @@ -97,6 +97,8 @@ apr_status_t app_get_private_config(const char *myfilename) 104,1,2 */ +//lnk20250122start +#if 0 int init_rptctrl_by_count(LD_info_t* LD_info,int rptcount) { int j,i; @@ -117,6 +119,37 @@ int init_rptctrl_by_count(LD_info_t* LD_info,int rptcount) return 0; } +#endif + +#define MAX_RPT_COUNT 20 + +int init_rptctrl_by_count(LD_info_t* LD_info,int rptcount) +{ + int j,i; + LD_info->rptcount = rptcount; + + if(LD_info->rptinfo == NULL){ //如果是空的说明是第一次初始化,需要申请空间,直接给每个监测点申请20个报告位,如果台账删除直接清空内容,如果需要重用直接重新赋值 + LD_info->rptinfo = apr_pcalloc( g_init_pool,MAX_RPT_COUNT*sizeof(rptinfo_t*) ); + } + + for(j=0; jrptinfo[j] == NULL){//如果是空的说明是第一次初始化,需要申请空间,否则沿用原来的空间,直接进行值的初始化 + LD_info->rptinfo[j] = apr_pcalloc( g_init_pool,sizeof(rptinfo_t) ); + } + LD_info->rptinfo[j]->LD_info = LD_info; + LD_info->rptinfo[j]->m_LastRegisterFailedTime = sGetMsTime() -10*60*1000; + LD_info->rptinfo[j]->m_LastUnRegisterFailedTime = sGetMsTime() -10*60*1000; + LD_info->rptinfo[j]->IntgPd = 60; + LD_info->rptinfo[j]->m_rcb_info = NULL; + LD_info->rptinfo[j]->rpt_registered = FALSE; + LD_info->rptinfo[j]->m_curRptSuffix = -1; + for(i=0; i<8; i++) + LD_info->rptinfo[j]->m_EntryID[i] = 0xff; + } + + return 0; +} +//lnk20250122end //ReportControl: 装置ID,CPUID,ID,RCBName, intgPd, dchg, qchg, dupd, period ,gi, 实例名是否增加后缀,  // seqNum, timeStamp, reasonCode, dataSet, dataRef, bufOvfl, entryID, configRef, segmentation @@ -218,6 +251,9 @@ int fill_rptctrl_by_cfg(LD_info_t* LD_info,int rptno,char *buf) 104,1,2 */ + +//lnk20250122start +#if 0 int init_logctrl_by_count(LD_info_t* LD_info,int logcount) { int j; @@ -233,6 +269,31 @@ int init_logctrl_by_count(LD_info_t* LD_info,int logcount) return 0; } +#endif + +#define MAX_LOG_COUNT 20 + +int init_logctrl_by_count(LD_info_t* LD_info,int logcount) +{ + int j; + LD_info->logcount = logcount; + + if(LD_info->loginfo == NULL){ + LD_info->loginfo = apr_pcalloc(g_init_pool, MAX_LOG_COUNT * sizeof(loginfo_t*)); //new loginfo_t*[logcount]; + } + for(j=0; jloginfo[j] == NULL){ + LD_info->loginfo[j] = apr_pcalloc(g_init_pool, sizeof(loginfo_t));//new loginfo_t[1]; + } + LD_info->loginfo[j]->LD_info = LD_info; + + LD_info->loginfo[j]->IntgPd = 600; + //LD_info->loginfo[j]->m_lcb_info = NULL; + } + + return 0; +} +//lnk20250122end // // 106,2,1,LLN0$LG$lcStatisticData,dsStatisticData,PQM1,0,600000,1,0,0,0 diff --git a/mms/rdb_client.h b/mms/rdb_client.h index 5499e85..9189010 100644 --- a/mms/rdb_client.h +++ b/mms/rdb_client.h @@ -475,7 +475,9 @@ void print_trigger_update_xml(const trigger_update_xml_t* trigger_update); char* parse_model_cfg_web_one(ied_t* ied); void Set_xml_nodeinfo_one(char* dev_type); void create_ledger_log(trigger_update_xml_t* ledger_update_xml); -ied_t* find_ied_from_terminal_id(); +ied_t* find_ied_unused(); +int parse_rpt_log_ini_one(ied_t* ied); +apr_status_t init_rem_dib_table_one(ied_t *ied); //////////////////////////////// int parse_3s_xml(trigger_3s_xml_t* trigger_3s_xml); int create_3s_xml(trigger_3s_xml_t* trigger_3s_xml); diff --git a/mms/rdb_ext_utils.c b/mms/rdb_ext_utils.c index 60cf2dd..eb8788d 100644 --- a/mms/rdb_ext_utils.c +++ b/mms/rdb_ext_utils.c @@ -309,7 +309,7 @@ ied_t* find_ied_from_terminal_id(char terminal_id[]) return NULL; } //lnk20250121找不使用的ied空间 -ied_t* find_ied_from_terminal_id() +ied_t* find_ied_unused() { ied_t* ied_find_unused = NULL; int iedno; @@ -318,7 +318,7 @@ ied_t* find_ied_from_terminal_id() ied_find_unused = g_node->clients[iedno]; ied_usr_find_unused = (ied_usr_t*)ied_find_unused->usr_ext; if (ied_usr_find_unused && ied_usr_find_unused->dev_flag == UNUSED) { - return ied_find_unused; + return ied_find_unused;//找到第一个就返回 } } return NULL;