qvvr has bug

This commit is contained in:
lnk
2025-05-20 16:31:12 +08:00
parent 093e8e5dd6
commit 3ad2e7c590
12 changed files with 314 additions and 44 deletions

View File

@@ -185,6 +185,8 @@ int IED_COUNT = 300; //默认300
extern int INITFLAG;
extern uint32_t g_ontime_blocked_times;
//lnk2024-8-14添加角型接线标志,0不存在角形接线1存在角形接线
int isdelta_flag = 0;
@@ -1442,7 +1444,12 @@ int parse_rpt_log_ini()
if(tmp == NULL){std::cerr << "front read ied config error!" << std::endl;continue;}
qDebug() << tmp << endl;
apr_snprintf(str, sizeof(str), tmp, cpuno + 1);
//apr_snprintf(str, sizeof(str), tmp, cpuno + 1);
//ied_usr->LD_info[cpuno].LD_name = apr_pstrdup(g_init_pool, str);
//已经分配过内存,直接复制到里面
apr_snprintf(ied_usr->LD_info[cpuno].LD_name, sizeof(ied_usr->LD_info[cpuno].LD_name), tmp, cpuno + 1);
delete[] tmp;
@@ -3453,12 +3460,14 @@ int terminal_ledger_web(QMap<QString, terminal_dev*>* terminal_dev_map,
// 参数验证
if (num <= 0) {
std::cerr << "Error: 'num' must be greater than 0." << std::endl;
DIY_ERRORLOG("process","【ERROR】前置的多进程最大进程号为:%d,应该为大于0的整数",num);
return 1; // 返回适当的错误码
}
index = index - 1;
if (index < 0 || index >= num) {
std::cerr << "Error: 'index' must be in the range [0, num-1]." << std::endl;
std::cerr << "Error: 'index' must be in the range [0, num]." << std::endl;
DIY_ERRORLOG("process","【ERROR】前置当前进程的进程号为:%d,应该为0到最大进程号范围内的整数",index);
return 1; // 返回适当的错误码
}
}
@@ -3466,6 +3475,7 @@ int terminal_ledger_web(QMap<QString, terminal_dev*>* terminal_dev_map,
// 获取参数
if (codes.empty()) {
std::cerr << "Error: 'codes' vector is empty." << std::endl;
DIY_ERRORLOG("process","【ERROR】前置的%s%d号进程调用web台账接口的入参为空",get_front_msg_from_subdir(), g_front_seg_index);
return 1;
}
@@ -3558,9 +3568,7 @@ int terminal_ledger_web(QMap<QString, terminal_dev*>* terminal_dev_map,
}*/
while (1) {
// 请求接口
SendJsonAPI_web(WEB_DEVICE, "", parm.c_str(), &ptr);
SendJsonAPI_web(WEB_DEVICE, "", parm.c_str(), &ptr);
if (ptr != NULL) {
@@ -3826,9 +3834,14 @@ int parse_device_cfg_web()
std::cout << "input_jstr: " << input_jstr << std::endl; // 输出结果
DIY_DEBUGLOG("process","【DEBUG】前置的%s%d号进程调用web接口获取台账使用的请求输入为:%s",get_front_msg_from_subdir(), g_front_seg_index,input_jstr);
codes.push_back(input_jstr); //是否需要筛选状态直接在配置文件控制
terminal_ledger_web(&terminal_dev_map,codes,g_front_seg_index,g_front_seg_num);
if(terminal_ledger_web(&terminal_dev_map,codes,g_front_seg_index,g_front_seg_num)){
return APR_EBADF;
}
codes.clear();
//调试用
@@ -3855,9 +3868,15 @@ int parse_device_cfg_web()
//判断是否相等
if(max_process_num != max_index){
// 调用执行脚本函数
close_listening_socket();
execute_bash("reset", max_process_num, "all");
if(max_process_num > 0 && max_process_num < 10){
DIY_WARNLOG("process","【WARN】前置比对台账获取的进程数:%s和本地配置的进程数:%s,不匹配,按照台账进程数重置前置的进程数量",max_process_num,max_index);
// 调用执行脚本函数
close_listening_socket();
execute_bash("reset", max_process_num, "all");
}
else{
DIY_ERRORLOG("process","【ERROR】前置从台账获取的进程数:%s不符合范围1~9,按照本地配置进程数启动进程",max_process_num);
}
}
}
@@ -3865,6 +3884,8 @@ int parse_device_cfg_web()
std::cout << "terminal_ledger_num:" << count_cfg << std::endl;
DIY_DEBUGLOG("process","【DEBUG】前置的%s%d号进程调用获取到的台账的数量为:%d",get_front_msg_from_subdir(), g_front_seg_index,count_cfg);
//如果当前进程获取的台账为0按照配置数量申请空间台账内容为空
g_node->n_clients = count_cfg;
@@ -3877,9 +3898,12 @@ int parse_device_cfg_web()
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;
DIY_WARNLOG("process","【WARN】前置的%s%d号进程获取到的台账的数量大于配置文件中给单个进程配置的台账数量:%d,这个进程将按照获取到的台账的数量来创建台账空间,这个进程不能直接通过台账添加来新增台账,只能通过重启进程或者先删除已有台账再添加台账的方式来添加新台账",get_front_msg_from_subdir(), g_front_seg_index,IED_COUNT);
}
else{
g_node->clients = (ied_t**)apr_pcalloc(g_cfg_pool, IED_COUNT * sizeof(ied_t*));//g_node->clients 这块大内存空间存储了 count_cfg 个 ied_t* 类型的指针(即一个指针数组)这是(指向内存块的指针)的指针数组
DIY_INFOLOG("process","【NORMAL】前置的%s%d号进程根据配置文件中给单个进程配置的台账数量:%d来创建台账空间",get_front_msg_from_subdir(), g_front_seg_index,IED_COUNT);
}
//把ied放入数组
@@ -4555,6 +4579,9 @@ void OnTimerThread::run()
}
counter++;
//清空计数器
g_ontime_blocked_times =0;
msleep(1000);
}
printf(">>>OnTimerThread::run() is end!!!\n");
@@ -6466,9 +6493,9 @@ void send_reply_to_kafka(const std::string& guid, const std::string& step, const
oss << "{"
<< "\"guid\":\"" << guid << "\","
<< "\"step\":\"" << step << "\","
<< "\"result\":\"" << result << "\""
<< "\"processNo\":\"" << g_front_seg_index << "\""
<< "\"frontType\":\"" << get_front_type_from_subdir() << "\""
<< "\"result\":\"" << result << "\","
<< "\"processNo\":\"" << g_front_seg_index << "\","
<< "\"frontType\":\"" << get_front_type_from_subdir() << "\","
<< "\"nodeId\":\"" << FRONT_INST << "\""
<< "}";