初始化添加pqdif判断,新增pqdif进程
This commit is contained in:
@@ -156,6 +156,7 @@ public:
|
||||
char dev_type[64];
|
||||
char dev_key[255];
|
||||
char dev_series[255];
|
||||
char com_type[32];
|
||||
char addr_str[64];
|
||||
char port[64];
|
||||
char timestamp[64];
|
||||
@@ -859,7 +860,10 @@ void init_config() {
|
||||
}
|
||||
else if (g_node_id == SOE_COMTRADE_BASE_NODE_ID) {//暂态录波
|
||||
TEST_PORT = TEST_PORT + SOE_COMTRADE_BASE_NODE_ID + g_front_seg_index;
|
||||
}
|
||||
}
|
||||
else if (g_node_id == PQDIF_DATA_BASE_NODE_ID) {
|
||||
TEST_PORT = TEST_PORT + PQDIF_DATA_BASE_NODE_ID + g_front_seg_index;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3388,6 +3392,31 @@ void SendJsonAPI_web(const std::string& strUrl, const char* code, const std::str
|
||||
}
|
||||
|
||||
// 打印 terminal_dev_map 中所有内容的函数
|
||||
static bool is_cfg_pqdif_process()
|
||||
{
|
||||
return std::strstr(subdir, "cfg_pqdif_data") != NULL;
|
||||
}
|
||||
|
||||
static bool is_pqdif_com_type(const char* com_type)
|
||||
{
|
||||
QString type = com_type ? QString::fromLocal8Bit(com_type).trimmed() : QString();
|
||||
return type.compare("pqdif", Qt::CaseInsensitive) == 0;
|
||||
}
|
||||
|
||||
static bool terminal_should_bind_to_current_process(const terminal_dev* dev)
|
||||
{
|
||||
if (dev == NULL)
|
||||
return false;
|
||||
|
||||
if (is_pqdif_com_type(dev->com_type))
|
||||
return is_cfg_pqdif_process();
|
||||
|
||||
if (is_cfg_pqdif_process())
|
||||
return false;
|
||||
|
||||
return (atoi(dev->processNo) == g_front_seg_index || g_front_seg_index == 0);
|
||||
}
|
||||
|
||||
void printTerminalDevMap(const QMap<QString, terminal_dev*>& terminal_dev_map) {
|
||||
QMap<QString, terminal_dev*>::const_iterator it;
|
||||
for (it = terminal_dev_map.constBegin(); it != terminal_dev_map.constEnd(); ++it) {
|
||||
@@ -3406,6 +3435,7 @@ void printTerminalDevMap(const QMap<QString, terminal_dev*>& terminal_dev_map) {
|
||||
<< ", Device Type:" << QString(dev->dev_type)
|
||||
<< ", Device Key:" << QString(dev->dev_key)
|
||||
<< ", Device Series:" << QString(dev->dev_series)
|
||||
<< ", Device comType:" << QString(dev->com_type)
|
||||
<< ", Device processNo:" << QString(dev->processNo)
|
||||
<< ", Device maxProcessNum:" << QString(dev->maxProcessNum)
|
||||
<< ", Address:" << QString(dev->addr_str)
|
||||
@@ -4085,6 +4115,13 @@ int terminal_ledger_web(QMap<QString, terminal_dev*>* terminal_dev_map,
|
||||
else strncpy(dev->dev_series, "N/A", sizeof(dev->dev_series) - 1);
|
||||
dev->dev_series[sizeof(dev->dev_series) - 1] = '\0';
|
||||
|
||||
cJSON* comType = cJSON_GetObjectItem(item, "comType");
|
||||
if (comType == NULL)
|
||||
comType = cJSON_GetObjectItem(item, "com_type");
|
||||
if (comType && comType->type == cJSON_String) strncpy(dev->com_type, comType->valuestring, sizeof(dev->com_type) - 1);
|
||||
else strncpy(dev->com_type, "mms", sizeof(dev->com_type) - 1);
|
||||
dev->com_type[sizeof(dev->com_type) - 1] = '\0';
|
||||
|
||||
//lnk20250210台账进程号
|
||||
cJSON* processNo = cJSON_GetObjectItem(item, "processNo"); // processNo转为字符串
|
||||
if (processNo && processNo->type == cJSON_Number) snprintf(dev->processNo, sizeof(dev->processNo), "%d", processNo->valueint);
|
||||
@@ -4190,19 +4227,20 @@ int terminal_ledger_web(QMap<QString, terminal_dev*>* terminal_dev_map,
|
||||
|
||||
//lnk20260312防止内存泄漏
|
||||
bool inserted = false;
|
||||
bool should_bind = terminal_should_bind_to_current_process(dev);
|
||||
|
||||
// 检查是否存在重复键
|
||||
if (terminal_dev_map->contains(key)) {
|
||||
std::cerr << "Duplicate terminal_code found: " << key.toStdString() << std::endl;
|
||||
|
||||
// 删除旧的 terminal_dev 对象以避免内存泄漏
|
||||
delete terminal_dev_map->value(key);
|
||||
if (should_bind) delete terminal_dev_map->value(key);
|
||||
|
||||
// 移除旧的键值对
|
||||
terminal_dev_map->remove(key);
|
||||
if (should_bind) terminal_dev_map->remove(key);
|
||||
|
||||
// 插入新的 terminal_dev 对象
|
||||
if(atoi(dev->processNo) == g_front_seg_index || g_front_seg_index == 0){//lnk20250210匹配进程号
|
||||
if(should_bind){//lnk20250210匹配进程号
|
||||
//调试用
|
||||
std::cout<< "process num match" << std::endl;
|
||||
terminal_dev_map->insert(key, dev);
|
||||
@@ -4210,7 +4248,7 @@ int terminal_ledger_web(QMap<QString, terminal_dev*>* terminal_dev_map,
|
||||
}//后续修改为只有进程号匹配上index才录入当前进程
|
||||
} else {
|
||||
// 插入新的 terminal_dev 对象
|
||||
if(atoi(dev->processNo) == g_front_seg_index || g_front_seg_index == 0){//lnk20250210匹配进程号
|
||||
if(should_bind){//lnk20250210匹配进程号
|
||||
//调试用
|
||||
std::cout<< "process num match" << std::endl;
|
||||
terminal_dev_map->insert(key, dev);
|
||||
@@ -7290,6 +7328,8 @@ const char* get_front_msg_from_subdir() {
|
||||
return "实时数据进程";
|
||||
else if (std::strstr(subdir, "cfg_soe_comtrade") != NULL)
|
||||
return "暂态和告警进程";
|
||||
else if (std::strstr(subdir, "cfg_pqdif_data") != NULL)
|
||||
return "pqdif处理进程";
|
||||
else if (std::strstr(subdir, "cfg_recallhis_data") != NULL)
|
||||
return "稳态补招进程";
|
||||
else if (std::strstr(subdir, "cfg_stat_data") != NULL)
|
||||
@@ -7511,4 +7551,4 @@ void read_latest_ledger_file(char** out) {
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user