modify log4 function and add data trace function
This commit is contained in:
@@ -21,7 +21,7 @@ using namespace std;
|
||||
#define OTL_ODBC_UNIX
|
||||
#include <unistd.h>
|
||||
|
||||
#include "otlv4.h"
|
||||
//#include "otlv4.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include <sstream> //lnk 2024-10-16
|
||||
@@ -40,6 +40,17 @@ using namespace std;
|
||||
#include "../log4cplus/log4.h"//lnk添加log4
|
||||
#include <cstring>
|
||||
|
||||
//同步arm,移除otlv头文件
|
||||
class otl_datetime {
|
||||
public:
|
||||
int year;
|
||||
int month;
|
||||
int day;
|
||||
int hour;
|
||||
int minute;
|
||||
int second;
|
||||
};
|
||||
|
||||
//用于测试时防止数据激增
|
||||
#ifndef apr_time_from_msec
|
||||
#define apr_time_from_msec(ms) ((apr_time_t)(ms) * 1000)
|
||||
@@ -128,6 +139,8 @@ public:
|
||||
char timestamp[64];
|
||||
char status[255];
|
||||
char count_cfg[64]; //不是台账的一部分,用来记录数据库或业务中台的台账数量
|
||||
|
||||
int log_level; //0 ERROR 1 WARN 2 NORMAL 3 DEBUG
|
||||
};
|
||||
|
||||
class terminal_dev //终端台账
|
||||
@@ -154,6 +167,8 @@ public:
|
||||
ledger_monitor line[10];
|
||||
|
||||
char count_cfg[64]; //不是台账的一部分,用来记录数据库或业务中台的台账数量
|
||||
|
||||
int log_level; //0 ERROR 1 WARN 2 NORMAL 3 DEBUG
|
||||
};
|
||||
|
||||
class icd_model //icd模型
|
||||
@@ -1603,6 +1618,22 @@ void parse_terminal_from_data(trigger_update_xml_t* trigger_update_xml, const st
|
||||
strcpy(work_terminal.port, extract_value(data, "port").c_str());
|
||||
strcpy(work_terminal.timestamp, extract_value(data, "updateTime").c_str());
|
||||
|
||||
//添加日志等级
|
||||
std::string level = extract_value(data, "loglevel");
|
||||
int tmp_level = -1;
|
||||
if (!level.empty()) {
|
||||
try {
|
||||
tmp_level = std::stoi(level);
|
||||
} catch (...) {
|
||||
tmp_level = -1;
|
||||
}
|
||||
}
|
||||
if (tmp_level >= 0 && tmp_level <= 3) {
|
||||
work_terminal.log_level = tmp_level;
|
||||
} else {
|
||||
work_terminal.log_level = 1; // 默认 warn
|
||||
}
|
||||
|
||||
//添加guid20250506
|
||||
strncpy(work_terminal.guid, guid_value.c_str(), sizeof(work_terminal.guid) - 1);
|
||||
work_terminal.guid[sizeof(work_terminal.guid) - 1] = '\0';
|
||||
@@ -1637,6 +1668,27 @@ void parse_terminal_from_data(trigger_update_xml_t* trigger_update_xml, const st
|
||||
strcpy(work_monitor.timestamp, timestamp.empty() ? "N/A" : timestamp.c_str());
|
||||
strcpy(work_monitor.terminal_code, terminal_code.empty() ? "N/A" : terminal_code.c_str());
|
||||
strcpy(work_monitor.status, status.empty() ? "N/A" : status.c_str());
|
||||
|
||||
std::string log_level = extract_value(data, "loglevel");
|
||||
int tmp_level = -1;
|
||||
// 尝试解析 monitor loglevel
|
||||
if (!log_level.empty()) {
|
||||
try {
|
||||
tmp_level = std::stoi(log_level);
|
||||
} catch (...) {
|
||||
tmp_level = -1;
|
||||
}
|
||||
}
|
||||
// 判断是否合法
|
||||
if (tmp_level >= 0 && tmp_level <= 3) {
|
||||
work_monitor.log_level = tmp_level;
|
||||
}
|
||||
else if (work_terminal.log_level >= 0 && work_terminal.log_level <= 3) {
|
||||
work_monitor.log_level = work_terminal.log_level; // 继承 terminal
|
||||
}
|
||||
else {
|
||||
work_monitor.log_level = 1; // 默认 warn
|
||||
}
|
||||
|
||||
// 将提取的 monitor 数据存入 work_terminal.line[monitor_count]
|
||||
work_terminal.line[monitor_count] = work_monitor;
|
||||
@@ -3270,6 +3322,7 @@ void printTerminalDevMap(const QMap<QString, terminal_dev*>& terminal_dev_map) {
|
||||
<< ", Device maxProcessNum:" << QString(dev->maxProcessNum)
|
||||
<< ", Address:" << QString(dev->addr_str)
|
||||
<< ", Port:" << QString(dev->port)
|
||||
<< ", log_level:" << QString(dev->log_level)
|
||||
<< ", Timestamp:" << QString(dev->timestamp);
|
||||
|
||||
// 打印监测点信息
|
||||
@@ -3281,6 +3334,7 @@ void printTerminalDevMap(const QMap<QString, terminal_dev*>& terminal_dev_map) {
|
||||
<< ", Voltage Level:" << QString(dev->line[i].voltage_level)
|
||||
<< ", Terminal Connect:" << QString(dev->line[i].terminal_connect)
|
||||
<< ", Timestamp:" << QString(dev->line[i].timestamp)
|
||||
<< ", log_level:" << QString(dev->line[i].log_level)
|
||||
<< ", Status:" << QString(dev->line[i].status);
|
||||
}
|
||||
} else {
|
||||
@@ -3310,6 +3364,7 @@ void printLedger(const ied_usr_t& ied_usr) {
|
||||
std::cout << "|-- tmnl_status: " << ied_usr.tmnl_status << std::endl;
|
||||
std::cout << "|-- terminal_code: " << ied_usr.terminal_code << std::endl;
|
||||
std::cout << "|-- update_flag: " << ied_usr.update_flag << std::endl;
|
||||
std::cout << "|-- log_level: " << ied_usr.log_level << std::endl;
|
||||
|
||||
// 打印每个LD_info的内容
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
@@ -3321,6 +3376,7 @@ void printLedger(const ied_usr_t& ied_usr) {
|
||||
<< (strlen(ied_usr.LD_info[i].LD_name) == 0 ? "NA" : ied_usr.LD_info[i].LD_name)
|
||||
<< std::endl;
|
||||
std::cout << " |-- read_flag: " << ied_usr.LD_info[i].read_flag << std::endl;
|
||||
std::cout << " |-- log_level: " << ied_usr.LD_info[i].log_level << std::endl;
|
||||
//index
|
||||
std::cout << " |-- line_id: " << ied_usr.LD_info[i].line_id << std::endl;
|
||||
//monitorledger
|
||||
@@ -3401,6 +3457,7 @@ void printLedgerinshell(const ied_usr_t& ied_usr, QIODevice* outputDevice) {
|
||||
outputDevice->write("\r\x1B[K");outputDevice->write("|-- tmnl_status: " + QByteArray(ied_usr.tmnl_status) + "\n");
|
||||
outputDevice->write("\r\x1B[K");outputDevice->write("|-- terminal_code: " + QByteArray(ied_usr.terminal_code) + "\n");
|
||||
outputDevice->write("\r\x1B[K");outputDevice->write("|-- update_flag: " + QByteArray::number(ied_usr.update_flag) + "\n");
|
||||
outputDevice->write("\r\x1B[K");outputDevice->write("|-- log_level: " + QByteArray::number(ied_usr.log_level) + "\n");
|
||||
|
||||
// 打印每个LD_info的内容
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
@@ -3412,7 +3469,9 @@ void printLedgerinshell(const ied_usr_t& ied_usr, QIODevice* outputDevice) {
|
||||
outputDevice->write("\r\x1B[K");outputDevice->write(" |-- LD_name: "
|
||||
+ (strlen(ied_usr.LD_info[i].LD_name) == 0 ? QByteArray("NA") : QByteArray(ied_usr.LD_info[i].LD_name))
|
||||
+ "\n");
|
||||
outputDevice->write("\r\x1B[K");outputDevice->write(" |-- read_flag: " + QByteArray::number(ied_usr.LD_info[i].read_flag) + "\n");
|
||||
outputDevice->write("\r\x1B[K");outputDevice->write(" |-- read_flag: " + QByteArray::number(ied_usr.LD_info[i].read_flag) + "\n");
|
||||
|
||||
outputDevice->write("\r\x1B[K");outputDevice->write(" |-- log_level: " + QByteArray::number(ied_usr.LD_info[i].log_level) + "\n");
|
||||
|
||||
// index
|
||||
outputDevice->write("\r\x1B[K");outputDevice->write(" |-- line_id: " + QByteArray::number(ied_usr.LD_info[i].line_id) + "\n");
|
||||
@@ -4004,6 +4063,22 @@ int terminal_ledger_web(QMap<QString, terminal_dev*>* terminal_dev_map,
|
||||
if (updateTime && updateTime->type == cJSON_String) strncpy(dev->timestamp, updateTime->valuestring, sizeof(dev->timestamp) - 1);
|
||||
else strncpy(dev->timestamp, "N/A", sizeof(dev->timestamp) - 1);
|
||||
|
||||
cJSON* logLevel = cJSON_GetObjectItem(item, "log_level"); // log_level
|
||||
int tmp_level = -1;
|
||||
if (logLevel && logLevel->type == cJSON_Number) {
|
||||
tmp_level = logLevel->valueint;
|
||||
}
|
||||
else if (logLevel && logLevel->type == cJSON_String && logLevel->valuestring) {
|
||||
tmp_level = atoi(logLevel->valuestring);
|
||||
}
|
||||
// 判断是否合法 0~3
|
||||
if (tmp_level >= 0 && tmp_level <= 3) {
|
||||
dev->log_level = tmp_level;
|
||||
} else {
|
||||
dev->log_level = 1; // 默认 WARN
|
||||
}
|
||||
printf("dev->log_level: %d\n", dev->log_level);
|
||||
|
||||
// 解析 monitorData 数组
|
||||
cJSON* monitorData = cJSON_GetObjectItem(item, "monitorData");
|
||||
if (monitorData && monitorData->type == cJSON_Array) {
|
||||
@@ -4040,6 +4115,22 @@ int terminal_ledger_web(QMap<QString, terminal_dev*>* terminal_dev_map,
|
||||
if (monitorstatus && monitorstatus->type == cJSON_String) strncpy(dev->line[j].status, monitorstatus->valuestring, sizeof(dev->line[j].status) - 1);
|
||||
else strncpy(dev->line[j].status, "N/A", sizeof(dev->line[j].status) - 1);
|
||||
|
||||
cJSON* logLevel_m = cJSON_GetObjectItem(item, "log_level"); // log_level
|
||||
int tmp_level = -1;
|
||||
if (logLevel_m && logLevel_m->type == cJSON_Number) {
|
||||
tmp_level = logLevel_m->valueint;
|
||||
}
|
||||
else if (logLevel_m && logLevel_m->type == cJSON_String && logLevel_m->valuestring) {
|
||||
tmp_level = atoi(logLevel_m->valuestring);
|
||||
}
|
||||
// 判断是否合法 (0~3)
|
||||
if (tmp_level >= 0 && tmp_level <= 3) {
|
||||
dev->line[j].log_level = tmp_level;
|
||||
} else {
|
||||
dev->line[j].log_level = 1; // 默认 WARN
|
||||
}
|
||||
printf("line[%d].log_level: %d\n", j, dev->line[j].log_level);
|
||||
|
||||
j++;
|
||||
}
|
||||
}
|
||||
@@ -4213,6 +4304,9 @@ int parse_device_cfg_web()
|
||||
//lnk20250210添加进程号
|
||||
char processNo[64];
|
||||
|
||||
//lnk20260304添加日志等级
|
||||
int log_level;
|
||||
|
||||
otl_datetime timestamp;
|
||||
|
||||
// 遍历终端台账容器
|
||||
@@ -4238,305 +4332,279 @@ int parse_device_cfg_web()
|
||||
strncpy(processNo, value->processNo, sizeof(processNo) - 1);//进程号
|
||||
timestamp = parseTimestamp(value->timestamp);
|
||||
|
||||
//处理终端台账
|
||||
ied = g_node->clients[count_real++];
|
||||
//这里申请的空间基于ied的数量,挂载到ied上
|
||||
ied_usr = (ied_usr_t*)apr_pcalloc(g_init_pool, sizeof(ied_usr_t));//终端台账在initpool中申请空间
|
||||
ied->usr_ext = ied_usr;
|
||||
log_level = value->log_level;//日志等级
|
||||
} else {
|
||||
std::cerr << "Warning: terminal_dev pointer is null for key: " << it.key().toStdString() << std::endl;
|
||||
continue; // 跳过空指针
|
||||
}
|
||||
|
||||
if (ied_usr == NULL)
|
||||
return APR_ENOMEM;
|
||||
|
||||
ied_usr->last_call_wavelist_time = sGetMsTime() + g_pt61850app->giTime * 1000;
|
||||
//这里申请的空间基于ied的数量,挂载到ied上
|
||||
ied_usr->LD_info = (LD_info_t*)apr_pcalloc(g_init_pool, MAX_CPUNO * sizeof(LD_info_t));//监测点台账在initpool中申请空间
|
||||
|
||||
if (ied_usr->LD_info == NULL)
|
||||
return APR_ENOMEM;
|
||||
|
||||
ied_usr->dev_flag = ENABLE;//终端有效
|
||||
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;
|
||||
ied->channel[0].status = STATUS_BREAKOFF;
|
||||
ied->cpucount = 0;
|
||||
|
||||
if (strlen(terminal_id) != 0) {
|
||||
apr_snprintf(ied_usr->terminal_id, sizeof(ied_usr->terminal_id), "%s", terminal_id);//terminal_id
|
||||
cout << "ied_usr->terminal_id:" << ied_usr->terminal_id << endl;
|
||||
//处理终端台账
|
||||
ied = g_node->clients[count_real++];
|
||||
//这里申请的空间基于ied的数量,挂载到ied上
|
||||
ied_usr = (ied_usr_t*)apr_pcalloc(g_init_pool, sizeof(ied_usr_t));//终端台账在initpool中申请空间
|
||||
ied->usr_ext = ied_usr;
|
||||
if (ied_usr == NULL)
|
||||
return APR_ENOMEM;
|
||||
ied_usr->last_call_wavelist_time = sGetMsTime() + g_pt61850app->giTime * 1000;
|
||||
//这里申请的空间基于ied的数量,挂载到ied上
|
||||
ied_usr->LD_info = (LD_info_t*)apr_pcalloc(g_init_pool, MAX_CPUNO * sizeof(LD_info_t));//监测点台账在initpool中申请空间
|
||||
if (ied_usr->LD_info == NULL)
|
||||
return APR_ENOMEM;
|
||||
ied_usr->dev_flag = ENABLE;//终端有效
|
||||
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;
|
||||
ied->channel[0].status = STATUS_BREAKOFF;
|
||||
ied->cpucount = 0;
|
||||
if (strlen(terminal_id) != 0) {
|
||||
apr_snprintf(ied_usr->terminal_id, sizeof(ied_usr->terminal_id), "%s", terminal_id);//terminal_id
|
||||
cout << "ied_usr->terminal_id:" << ied_usr->terminal_id << endl;
|
||||
}
|
||||
if (terminal_code != NULL) {
|
||||
apr_snprintf(ied_usr->terminal_code, sizeof(ied_usr->terminal_code), "%s", terminal_code);//terminal_code
|
||||
cout << "ied_usr->terminal_code:" << ied_usr->terminal_code << endl;
|
||||
}
|
||||
/*不需要这三个信息
|
||||
if (org_name != NULL) {
|
||||
apr_snprintf(ied_usr->org_name, sizeof(ied_usr->org_name), "%s", org_name);//org_name
|
||||
cout << "ied_usr->org_name:" << ied_usr->org_name << endl;
|
||||
}
|
||||
if (maint_name != NULL) {
|
||||
apr_snprintf(ied_usr->maint_name, sizeof(ied_usr->maint_name), "%s", maint_name);//maint_name
|
||||
cout << "ied_usr->maint_name:" << ied_usr->maint_name << endl;
|
||||
}
|
||||
if (station_name != NULL) {
|
||||
apr_snprintf(ied_usr->station_name, sizeof(ied_usr->station_name), "%s", station_name);//station_name
|
||||
cout << "ied_usr->station_name:" << ied_usr->station_name << endl;
|
||||
}
|
||||
*/
|
||||
if (tmnl_factory != NULL) {
|
||||
apr_snprintf(ied_usr->tmnl_factory, sizeof(ied_usr->tmnl_factory), "%s", tmnl_factory);//tmnl_factory
|
||||
cout << "ied_usr->tmnl_factory:" << ied_usr->tmnl_factory << endl;
|
||||
}
|
||||
if (tmnl_status != NULL) {
|
||||
apr_snprintf(ied_usr->tmnl_status, sizeof(ied_usr->tmnl_status), "%s", tmnl_status);//tmnl_status
|
||||
cout << "ied_usr->tmnl_status:" << ied_usr->tmnl_status << endl;
|
||||
}
|
||||
if (dev_type != NULL) {
|
||||
apr_snprintf(ied_usr->dev_type, sizeof(ied_usr->dev_type), "%s", dev_type);//dev_type
|
||||
cout << "ied_usr->dev_type:" << ied_usr->dev_type << endl;
|
||||
}
|
||||
//lnk20250210台账进程号
|
||||
if (processNo != NULL) {
|
||||
apr_snprintf(ied_usr->processNo, sizeof(ied_usr->processNo), "%s", processNo);//processNo
|
||||
cout << "ied_usr->processNo:" << ied_usr->processNo << endl;
|
||||
}
|
||||
if (dev_series != NULL) {
|
||||
apr_snprintf(ied_usr->dev_series, sizeof(ied_usr->dev_series), "%s", dev_series);//DEV_Series
|
||||
cout << "defalut dev_series:" << ied_usr->dev_series << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
apr_snprintf(ied_usr->dev_series, sizeof(ied_usr->dev_series), "%s", "");//DEV_Series
|
||||
cout << "defalut dev_series:" << ied_usr->dev_series << endl;
|
||||
}
|
||||
if (dev_key != NULL) {
|
||||
apr_snprintf(ied_usr->dev_key, sizeof(ied_usr->dev_key), "%s", dev_key);//DEV_Key
|
||||
cout << "defalut dev_key:" << ied_usr->dev_key << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
apr_snprintf(ied_usr->dev_key, sizeof(ied_usr->dev_key), "%s", "");//DEV_Key
|
||||
cout << "defalut dev_key:" << ied_usr->dev_key << endl;
|
||||
}
|
||||
//lnk20260304
|
||||
ied_usr->log_level = log_level;//日志等级
|
||||
cout << "ied_usr->log_level:" << ied_usr->log_level << endl;
|
||||
//lnk20241125实时数据用
|
||||
ied_usr->dev_idx = count_real;
|
||||
cout << "dev_idx:" << ied_usr->dev_idx << endl;
|
||||
ied->channel[0].channel_type = CHANNEL_TYPE_IPV4;//channel
|
||||
ied->channel[0].addr_str[LONGNAME - 1] = 0;//DEV_IP
|
||||
if (addr_str != NULL) {
|
||||
ied->channel[0].addr = ntohl(inet_addr(addr_str));//DEV_IP
|
||||
strncpy(ied->channel[0].addr_str, addr_str, LONGNAME - 1);//DEV_IP
|
||||
cout << "ied_usr->addr_str:" << ied->channel[0].addr_str << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
ied->channel[0].addr = ntohl(inet_addr("0.0.0.0"));//DEV_IP
|
||||
strncpy(ied->channel[0].addr_str, addr_str, LONGNAME - 1);//DEV_IP
|
||||
cout << "ied_usr->addr_str:" << ied->channel[0].addr_str << endl;
|
||||
}
|
||||
if (port_char != NULL) {
|
||||
int port = 102;
|
||||
if (stringToInt(port_char, &port)) {
|
||||
// 转换成功,portStr全为数字,并且已经转换为int类型的port
|
||||
ied->channel[0].port = port;//DEV_PortID
|
||||
cout << "ied_usr->port:" << ied->channel[0].port << endl;//DEV_PortID
|
||||
}
|
||||
if (terminal_code != NULL) {
|
||||
apr_snprintf(ied_usr->terminal_code, sizeof(ied_usr->terminal_code), "%s", terminal_code);//terminal_code
|
||||
cout << "ied_usr->terminal_code:" << ied_usr->terminal_code << endl;
|
||||
else {
|
||||
ied->channel[0].port = 102;//DEV_PortID
|
||||
cout << "ied_usr->port:" << port_char << ",非合法端口.使用默认端口:" << ied->channel[0].port << endl;//DEV_PortID
|
||||
}
|
||||
/*不需要这三个信息
|
||||
if (org_name != NULL) {
|
||||
apr_snprintf(ied_usr->org_name, sizeof(ied_usr->org_name), "%s", org_name);//org_name
|
||||
cout << "ied_usr->org_name:" << ied_usr->org_name << endl;
|
||||
|
||||
}
|
||||
if (timestamp.year != 0) {
|
||||
//// 构造struct tm对象
|
||||
struct tm timeinfo;
|
||||
timeinfo.tm_year = timestamp.year - 1900; // 年份需要减去1900
|
||||
timeinfo.tm_mon = timestamp.month - 1; // 月份需要减去1
|
||||
timeinfo.tm_mday = timestamp.day;
|
||||
timeinfo.tm_hour = timestamp.hour;
|
||||
timeinfo.tm_min = timestamp.minute;
|
||||
timeinfo.tm_sec = timestamp.second;
|
||||
time_t time = std::mktime(&timeinfo);
|
||||
ied_usr->time = static_cast<long long>(time);
|
||||
cout << "ied_usr->time:" << ied_usr->time << endl;
|
||||
}
|
||||
//这里申请的空间基于ied的数量,挂载到ied上
|
||||
chnl_usr = (chnl_usr_t*)apr_pcalloc(g_init_pool, sizeof(chnl_usr_t));//拓展定义的通信结构在g_init_pool中申请空间:拓展记录一些开关时间信息
|
||||
ied->channel[0].connect = chnl_usr;
|
||||
chnl_usr->chnl = &(ied->channel[0]);
|
||||
chnl_usr->chnl_id = 0;
|
||||
chnl_usr->m_state = CHANNEL_DISCONNECTED;
|
||||
chnl_usr->m_ClosedMsTime = NEXT_CONNECT_TIME * (-1);
|
||||
g_pt61850app->chnl_counts++;
|
||||
//调试用
|
||||
//std::cout << "value:" << terminal_id <<" "<<terminal_code <<" "<<tmnl_factory <<" "<<dev_series <<" "<<dev_key <<" "<< tmnl_status <<" "<<dev_type <<" "<<addr_str <<" "<<port_char <<" "<< timestamp.year << std::endl;
|
||||
// 遍历监测点信息
|
||||
LD_info_t line_info;
|
||||
int count_real_monitor = 0; //遍历监测点台账的计数器
|
||||
//调试用
|
||||
//std::cout << "n_clients:" << g_node->n_clients << std::endl;
|
||||
if (g_node->n_clients <= 0) {
|
||||
std::cout << "no terminal exist " << std::endl;
|
||||
return APR_EBADF;
|
||||
}
|
||||
char monitor_id[64];
|
||||
//char terminal_code[64];
|
||||
char monitor_name[64];
|
||||
char logical_device_seq[64];
|
||||
char voltage_level[64];
|
||||
char terminal_connect[64];
|
||||
char monitor_status[64];
|
||||
//otl_datetime timestamp;
|
||||
int monitor_log_level = 1;//监测点日志等级
|
||||
//for (int j = 0; j < 10; ++j) { // 假设最多有10个监测点
|
||||
for (int j = 0; value->line[j].monitor_id[0] != '\0'; ++j){
|
||||
ledger_monitor& monitor = value->line[j];
|
||||
// 检查监测点 ID 是否为空以避免访问无效数据
|
||||
/*if (monitor.monitor_id[0] != '\0') {
|
||||
std::cout << " Monitor ID: " << monitor.monitor_id << std::endl;
|
||||
std::cout << " Terminal Code: " << monitor.terminal_code << std::endl; //应该为空,json不带
|
||||
std::cout << " Monitor Name: " << monitor.monitor_name << std::endl;
|
||||
std::cout << " Logical Device Seq: " << monitor.logical_device_seq << std::endl;
|
||||
std::cout << " Voltage Level: " << monitor.voltage_level << std::endl;
|
||||
std::cout << " Terminal Connect: " << monitor.terminal_connect << std::endl;
|
||||
std::cout << " Timestamp: " << monitor.timestamp << std::endl; //应该为空json不带
|
||||
std::cout << " monitor_status: " << monitor.status << std::endl;*/
|
||||
strncpy(monitor_id, monitor.monitor_id, sizeof(monitor_id) - 1);
|
||||
//strncpy(terminal_code, monitor.terminal_code, sizeof(terminal_code) - 1); //从上级获取
|
||||
strncpy(monitor_name, monitor.monitor_name, sizeof(monitor_name) - 1);
|
||||
strncpy(logical_device_seq, monitor.logical_device_seq, sizeof(logical_device_seq) - 1);
|
||||
strncpy(voltage_level, monitor.voltage_level, sizeof(voltage_level) - 1);
|
||||
strncpy(terminal_connect, monitor.terminal_connect, sizeof(terminal_connect) - 1);
|
||||
//timestamp = parseTimestamp(monitor.timestamp); //从上级获取
|
||||
strncpy(monitor_status, monitor.status, sizeof(monitor_status) - 1);//添加监测点状态
|
||||
monitor_log_level = monitor.log_level;//监测点日志等级
|
||||
//监测点台账处理
|
||||
count_real_monitor++;
|
||||
memset(&line_info, 0, sizeof(line_info));
|
||||
line_info.line_id = count_real_monitor; //监测点排号
|
||||
cout << "line_id:" << line_info.line_id << endl;
|
||||
strcpy(line_info.mp_id, monitor_id);
|
||||
cout << "mp_id:" << line_info.mp_id << endl;
|
||||
strcpy(line_info.terminal_code, terminal_code); //从上级获取的终端号
|
||||
cout << "terminal_code:" << line_info.terminal_code << endl;
|
||||
if (isCharPtrEmpty(logical_device_seq)) {
|
||||
line_info.cpuno = 1; //默认监测点实例号1
|
||||
cout << "logical_device_seq:is null,set cpuno:"<< line_info.cpuno << endl;
|
||||
}
|
||||
if (maint_name != NULL) {
|
||||
apr_snprintf(ied_usr->maint_name, sizeof(ied_usr->maint_name), "%s", maint_name);//maint_name
|
||||
cout << "ied_usr->maint_name:" << ied_usr->maint_name << endl;
|
||||
|
||||
else {
|
||||
line_info.cpuno = std::atoi(logical_device_seq);
|
||||
cout << "logical_device_seq:"<< line_info.cpuno << endl;
|
||||
}
|
||||
if (station_name != NULL) {
|
||||
apr_snprintf(ied_usr->station_name, sizeof(ied_usr->station_name), "%s", station_name);//station_name
|
||||
cout << "ied_usr->station_name:" << ied_usr->station_name << endl;
|
||||
}
|
||||
*/
|
||||
if (tmnl_factory != NULL) {
|
||||
apr_snprintf(ied_usr->tmnl_factory, sizeof(ied_usr->tmnl_factory), "%s", tmnl_factory);//tmnl_factory
|
||||
cout << "ied_usr->tmnl_factory:" << ied_usr->tmnl_factory << endl;
|
||||
}
|
||||
if (tmnl_status != NULL) {
|
||||
apr_snprintf(ied_usr->tmnl_status, sizeof(ied_usr->tmnl_status), "%s", tmnl_status);//tmnl_status
|
||||
cout << "ied_usr->tmnl_status:" << ied_usr->tmnl_status << endl;
|
||||
}
|
||||
if (dev_type != NULL) {
|
||||
apr_snprintf(ied_usr->dev_type, sizeof(ied_usr->dev_type), "%s", dev_type);//dev_type
|
||||
cout << "ied_usr->dev_type:" << ied_usr->dev_type << endl;
|
||||
}
|
||||
|
||||
//lnk20250210台账进程号
|
||||
if (processNo != NULL) {
|
||||
apr_snprintf(ied_usr->processNo, sizeof(ied_usr->processNo), "%s", processNo);//processNo
|
||||
cout << "ied_usr->processNo:" << ied_usr->processNo << endl;
|
||||
}
|
||||
|
||||
if (dev_series != NULL) {
|
||||
apr_snprintf(ied_usr->dev_series, sizeof(ied_usr->dev_series), "%s", dev_series);//DEV_Series
|
||||
cout << "defalut dev_series:" << ied_usr->dev_series << endl;
|
||||
}
|
||||
else
|
||||
//cout << "cpuno:" << line_info.cpuno << endl;
|
||||
strcpy(line_info.voltage_level, voltage_level);
|
||||
cout << "voltage_level:" << line_info.voltage_level << endl;
|
||||
strcpy(line_info.v_wiring_type, terminal_connect);
|
||||
cout << "v_wiring_type:" << line_info.v_wiring_type << endl;
|
||||
//lnk2024-8-14记录接线标志
|
||||
if (strcmp(line_info.v_wiring_type, "0") != 0)
|
||||
{
|
||||
apr_snprintf(ied_usr->dev_series, sizeof(ied_usr->dev_series), "%s", "");//DEV_Series
|
||||
cout << "defalut dev_series:" << ied_usr->dev_series << endl;
|
||||
isdelta_flag = 1; //存在一个监测点为角型接线则这个前置就要启动第二个配置列表
|
||||
cout << "monitor_id" << monitor_id << "v_wiring_type:" << line_info.v_wiring_type << "is delta wiring:" << isdelta_flag << endl;
|
||||
DIY_WARNLOG_CODE("process",LOG_CODE_LEDGER,"【WARN】前置连接的监测点 %s 是角形接线,对应终端为%s 终端类型是%s",line_info.mp_id,ied_usr->terminal_id,ied_usr->dev_type);
|
||||
}
|
||||
if (dev_key != NULL) {
|
||||
apr_snprintf(ied_usr->dev_key, sizeof(ied_usr->dev_key), "%s", dev_key);//DEV_Key
|
||||
cout << "defalut dev_key:" << ied_usr->dev_key << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
apr_snprintf(ied_usr->dev_key, sizeof(ied_usr->dev_key), "%s", "");//DEV_Key
|
||||
cout << "defalut dev_key:" << ied_usr->dev_key << endl;
|
||||
}
|
||||
|
||||
//lnk20241125实时数据用
|
||||
ied_usr->dev_idx = count_real;
|
||||
cout << "dev_idx:" << ied_usr->dev_idx << endl;
|
||||
|
||||
ied->channel[0].channel_type = CHANNEL_TYPE_IPV4;//channel
|
||||
ied->channel[0].addr_str[LONGNAME - 1] = 0;//DEV_IP
|
||||
if (addr_str != NULL) {
|
||||
ied->channel[0].addr = ntohl(inet_addr(addr_str));//DEV_IP
|
||||
strncpy(ied->channel[0].addr_str, addr_str, LONGNAME - 1);//DEV_IP
|
||||
cout << "ied_usr->addr_str:" << ied->channel[0].addr_str << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
ied->channel[0].addr = ntohl(inet_addr("0.0.0.0"));//DEV_IP
|
||||
strncpy(ied->channel[0].addr_str, addr_str, LONGNAME - 1);//DEV_IP
|
||||
cout << "ied_usr->addr_str:" << ied->channel[0].addr_str << endl;
|
||||
}
|
||||
if (port_char != NULL) {
|
||||
int port = 102;
|
||||
if (stringToInt(port_char, &port)) {
|
||||
// 转换成功,portStr全为数字,并且已经转换为int类型的port
|
||||
ied->channel[0].port = port;//DEV_PortID
|
||||
cout << "ied_usr->port:" << ied->channel[0].port << endl;//DEV_PortID
|
||||
strcpy(line_info.monitor_status, monitor_status);
|
||||
cout << "monitor_status:" << line_info.monitor_status << endl;
|
||||
//// 构造struct tm对象
|
||||
struct tm timeinfo;
|
||||
timeinfo.tm_year = timestamp.year - 1900; // 年份需要减去1900 //从上级获取的timestamp
|
||||
timeinfo.tm_mon = timestamp.month - 1; // 月份需要减去1
|
||||
timeinfo.tm_mday = timestamp.day;
|
||||
timeinfo.tm_hour = timestamp.hour;
|
||||
timeinfo.tm_min = timestamp.minute;
|
||||
timeinfo.tm_sec = timestamp.second;
|
||||
time_t time = std::mktime(&timeinfo);
|
||||
line_info.time = static_cast<long long>(time);
|
||||
cout << "time:" << line_info.time << endl;
|
||||
strcpy(line_info.name, monitor_name);
|
||||
cout << "name:" << line_info.name << endl;
|
||||
line_info.read_flag = ENABLE; //监测点有效
|
||||
line_info.log_level = monitor_log_level; //监测点日志等级
|
||||
cout << "log_level_monitor:" << line_info.log_level << endl;
|
||||
//ied = find_ied_from_dev_code(line_info.terminal_code); //不需要再找上级终端了,已经在终端里了
|
||||
if (ied && ied->usr_ext && line_info.cpuno && (static_cast<int>(line_info.cpuno) < 10)) {
|
||||
char str[256]; //256大小
|
||||
byte_t cpuno = line_info.cpuno;
|
||||
cout << "cpuno:" << (int)line_info.cpuno << endl;
|
||||
cout << "index cpuno:" << cpuno-1 << endl;
|
||||
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;
|
||||
apr_snprintf(str, sizeof(str), "PQMonitorPQM%d", cpuno);//将监测点逻辑号转为PQMonitorPQM+逻辑号
|
||||
//lnk20250208不使用apr_pstrdup,后续直接复用
|
||||
//ied_usr->LD_info[cpuno - 1].LD_name = apr_pstrdup(g_init_pool, str);//将 str 中的格式化字符串复制到内存池 g_init_pool 中。ied_usr->LD_info[cpuno - 1].LD_name 存储了这个字符串的副本,LD_name 现在是 PQMonitorPQM{cpuno} 的形式。
|
||||
// 从 g_init_pool 内存池中分配固定 256 字节的内存
|
||||
ied_usr->LD_info[cpuno - 1].LD_name = (char *)apr_palloc(g_init_pool, 256);
|
||||
//调试用,申请的地址
|
||||
printf("%s分配内存地址 LD_name[%d]: %p\n", ied_usr->terminal_id, cpuno - 1, (void*)ied_usr->LD_info[cpuno - 1].LD_name);
|
||||
// 清空内存,防止残留数据
|
||||
memset(ied_usr->LD_info[cpuno - 1].LD_name, 0, 256);
|
||||
// 将 str 中的内容复制到预先分配的内存中,最多复制 256 字节(包含结束符)
|
||||
apr_cpystrn(ied_usr->LD_info[cpuno - 1].LD_name, str, 256);
|
||||
|
||||
//这里申请的空间基于ied的数量,挂载到ied上
|
||||
ied_usr->LD_info[cpuno - 1].ht_fcd = apr_hash_make(g_init_pool); //这两行代码分别为 ied_usr->LD_info[cpuno - 1] 的两个成员(ht_fcd 和 ht_full_fcda)创建了空的哈希表。apr_hash_make(g_init_pool) 会在 g_init_pool 内存池中为这两个哈希表分配内存空间
|
||||
ied_usr->LD_info[cpuno - 1].ht_full_fcda = apr_hash_make(g_init_pool);//它们的 key 值和 value 在后续的代码中可能会被填充
|
||||
ied_usr->LD_info[cpuno - 1].rptcount = 0;
|
||||
cout << "rptcount:" << ied_usr->LD_info[cpuno - 1].rptcount << endl;
|
||||
if (cpuno > ied->cpucount) {
|
||||
ied->cpucount = cpuno;
|
||||
}
|
||||
else {
|
||||
ied->channel[0].port = 102;//DEV_PortID
|
||||
cout << "ied_usr->port:" << port_char << ",非合法端口.使用默认端口:" << ied->channel[0].port << endl;//DEV_PortID
|
||||
}
|
||||
}
|
||||
if (timestamp.year != 0) {
|
||||
//// 构造struct tm对象
|
||||
struct tm timeinfo;
|
||||
timeinfo.tm_year = timestamp.year - 1900; // 年份需要减去1900
|
||||
timeinfo.tm_mon = timestamp.month - 1; // 月份需要减去1
|
||||
timeinfo.tm_mday = timestamp.day;
|
||||
timeinfo.tm_hour = timestamp.hour;
|
||||
timeinfo.tm_min = timestamp.minute;
|
||||
timeinfo.tm_sec = timestamp.second;
|
||||
time_t time = std::mktime(&timeinfo);
|
||||
ied_usr->time = static_cast<long long>(time);
|
||||
cout << "ied_usr->time:" << ied_usr->time << endl;
|
||||
}
|
||||
|
||||
//这里申请的空间基于ied的数量,挂载到ied上
|
||||
chnl_usr = (chnl_usr_t*)apr_pcalloc(g_init_pool, sizeof(chnl_usr_t));//拓展定义的通信结构在g_init_pool中申请空间:拓展记录一些开关时间信息
|
||||
ied->channel[0].connect = chnl_usr;
|
||||
chnl_usr->chnl = &(ied->channel[0]);
|
||||
chnl_usr->chnl_id = 0;
|
||||
chnl_usr->m_state = CHANNEL_DISCONNECTED;
|
||||
chnl_usr->m_ClosedMsTime = NEXT_CONNECT_TIME * (-1);
|
||||
g_pt61850app->chnl_counts++;
|
||||
|
||||
//调试用
|
||||
//std::cout << "value:" << terminal_id <<" "<<terminal_code <<" "<<tmnl_factory <<" "<<dev_series <<" "<<dev_key <<" "<< tmnl_status <<" "<<dev_type <<" "<<addr_str <<" "<<port_char <<" "<< timestamp.year << std::endl;
|
||||
|
||||
// 遍历监测点信息
|
||||
LD_info_t line_info;
|
||||
int count_real_monitor = 0; //遍历监测点台账的计数器
|
||||
|
||||
//调试用
|
||||
//std::cout << "n_clients:" << g_node->n_clients << std::endl;
|
||||
|
||||
if (g_node->n_clients <= 0) {
|
||||
std::cout << "no terminal exist " << std::endl;
|
||||
return APR_EBADF;
|
||||
}
|
||||
|
||||
char monitor_id[64];
|
||||
//char terminal_code[64];
|
||||
char monitor_name[64];
|
||||
char logical_device_seq[64];
|
||||
char voltage_level[64];
|
||||
char terminal_connect[64];
|
||||
char monitor_status[64];
|
||||
//otl_datetime timestamp;
|
||||
|
||||
//for (int j = 0; j < 10; ++j) { // 假设最多有10个监测点
|
||||
for (int j = 0; value->line[j].monitor_id[0] != '\0'; ++j){
|
||||
ledger_monitor& monitor = value->line[j];
|
||||
|
||||
// 检查监测点 ID 是否为空以避免访问无效数据
|
||||
/*if (monitor.monitor_id[0] != '\0') {
|
||||
std::cout << " Monitor ID: " << monitor.monitor_id << std::endl;
|
||||
std::cout << " Terminal Code: " << monitor.terminal_code << std::endl; //应该为空,json不带
|
||||
std::cout << " Monitor Name: " << monitor.monitor_name << std::endl;
|
||||
std::cout << " Logical Device Seq: " << monitor.logical_device_seq << std::endl;
|
||||
std::cout << " Voltage Level: " << monitor.voltage_level << std::endl;
|
||||
std::cout << " Terminal Connect: " << monitor.terminal_connect << std::endl;
|
||||
std::cout << " Timestamp: " << monitor.timestamp << std::endl; //应该为空json不带
|
||||
std::cout << " monitor_status: " << monitor.status << std::endl;*/
|
||||
|
||||
strncpy(monitor_id, monitor.monitor_id, sizeof(monitor_id) - 1);
|
||||
//strncpy(terminal_code, monitor.terminal_code, sizeof(terminal_code) - 1); //从上级获取
|
||||
strncpy(monitor_name, monitor.monitor_name, sizeof(monitor_name) - 1);
|
||||
strncpy(logical_device_seq, monitor.logical_device_seq, sizeof(logical_device_seq) - 1);
|
||||
strncpy(voltage_level, monitor.voltage_level, sizeof(voltage_level) - 1);
|
||||
strncpy(terminal_connect, monitor.terminal_connect, sizeof(terminal_connect) - 1);
|
||||
//timestamp = parseTimestamp(monitor.timestamp); //从上级获取
|
||||
strncpy(monitor_status, monitor.status, sizeof(monitor_status) - 1);//添加监测点状态
|
||||
//监测点台账处理
|
||||
count_real_monitor++;
|
||||
|
||||
memset(&line_info, 0, sizeof(line_info));
|
||||
|
||||
line_info.line_id = count_real_monitor; //监测点排号
|
||||
cout << "line_id:" << line_info.line_id << endl;
|
||||
|
||||
strcpy(line_info.mp_id, monitor_id);
|
||||
cout << "mp_id:" << line_info.mp_id << endl;
|
||||
|
||||
strcpy(line_info.terminal_code, terminal_code); //从上级获取的终端号
|
||||
cout << "terminal_code:" << line_info.terminal_code << endl;
|
||||
|
||||
if (isCharPtrEmpty(logical_device_seq)) {
|
||||
line_info.cpuno = 1; //默认监测点实例号1
|
||||
cout << "logical_device_seq:is null,set cpuno:"<< line_info.cpuno << endl;
|
||||
}
|
||||
else {
|
||||
line_info.cpuno = std::atoi(logical_device_seq);
|
||||
cout << "logical_device_seq:"<< line_info.cpuno << endl;
|
||||
}
|
||||
//cout << "cpuno:" << line_info.cpuno << endl;
|
||||
|
||||
strcpy(line_info.voltage_level, voltage_level);
|
||||
cout << "voltage_level:" << line_info.voltage_level << endl;
|
||||
|
||||
strcpy(line_info.v_wiring_type, terminal_connect);
|
||||
cout << "v_wiring_type:" << line_info.v_wiring_type << endl;
|
||||
|
||||
//lnk2024-8-14记录接线标志
|
||||
if (strcmp(line_info.v_wiring_type, "0") != 0)
|
||||
{
|
||||
isdelta_flag = 1; //存在一个监测点为角型接线则这个前置就要启动第二个配置列表
|
||||
cout << "monitor_id" << monitor_id << "v_wiring_type:" << line_info.v_wiring_type << "is delta wiring:" << isdelta_flag << endl;
|
||||
|
||||
DIY_WARNLOG_CODE("process",LOG_CODE_LEDGER,"【WARN】前置连接的监测点 %s 是角形接线,对应终端为%s 终端类型是%s",line_info.mp_id,ied_usr->terminal_id,ied_usr->dev_type);
|
||||
}
|
||||
|
||||
strcpy(line_info.monitor_status, monitor_status);
|
||||
cout << "monitor_status:" << line_info.monitor_status << endl;
|
||||
|
||||
//// 构造struct tm对象
|
||||
struct tm timeinfo;
|
||||
timeinfo.tm_year = timestamp.year - 1900; // 年份需要减去1900 //从上级获取的timestamp
|
||||
timeinfo.tm_mon = timestamp.month - 1; // 月份需要减去1
|
||||
timeinfo.tm_mday = timestamp.day;
|
||||
timeinfo.tm_hour = timestamp.hour;
|
||||
timeinfo.tm_min = timestamp.minute;
|
||||
timeinfo.tm_sec = timestamp.second;
|
||||
|
||||
time_t time = std::mktime(&timeinfo);
|
||||
line_info.time = static_cast<long long>(time);
|
||||
cout << "time:" << line_info.time << endl;
|
||||
|
||||
strcpy(line_info.name, monitor_name);
|
||||
cout << "name:" << line_info.name << endl;
|
||||
|
||||
line_info.read_flag = ENABLE; //监测点有效
|
||||
|
||||
//ied = find_ied_from_dev_code(line_info.terminal_code); //不需要再找上级终端了,已经在终端里了
|
||||
|
||||
if (ied && ied->usr_ext && line_info.cpuno && (static_cast<int>(line_info.cpuno) < 10)) {
|
||||
char str[256]; //256大小
|
||||
byte_t cpuno = line_info.cpuno;
|
||||
|
||||
cout << "cpuno:" << (int)line_info.cpuno << endl;
|
||||
cout << "index cpuno:" << cpuno-1 << endl;
|
||||
|
||||
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;
|
||||
apr_snprintf(str, sizeof(str), "PQMonitorPQM%d", cpuno);//将监测点逻辑号转为PQMonitorPQM+逻辑号
|
||||
|
||||
//lnk20250208不使用apr_pstrdup,后续直接复用
|
||||
//ied_usr->LD_info[cpuno - 1].LD_name = apr_pstrdup(g_init_pool, str);//将 str 中的格式化字符串复制到内存池 g_init_pool 中。ied_usr->LD_info[cpuno - 1].LD_name 存储了这个字符串的副本,LD_name 现在是 PQMonitorPQM{cpuno} 的形式。
|
||||
// 从 g_init_pool 内存池中分配固定 256 字节的内存
|
||||
ied_usr->LD_info[cpuno - 1].LD_name = (char *)apr_palloc(g_init_pool, 256);
|
||||
//调试用,申请的地址
|
||||
printf("%s分配内存地址 LD_name[%d]: %p\n", ied_usr->terminal_id, cpuno - 1, (void*)ied_usr->LD_info[cpuno - 1].LD_name);
|
||||
|
||||
// 清空内存,防止残留数据
|
||||
memset(ied_usr->LD_info[cpuno - 1].LD_name, 0, 256);
|
||||
|
||||
// 将 str 中的内容复制到预先分配的内存中,最多复制 256 字节(包含结束符)
|
||||
apr_cpystrn(ied_usr->LD_info[cpuno - 1].LD_name, str, 256);
|
||||
|
||||
//这里申请的空间基于ied的数量,挂载到ied上
|
||||
ied_usr->LD_info[cpuno - 1].ht_fcd = apr_hash_make(g_init_pool); //这两行代码分别为 ied_usr->LD_info[cpuno - 1] 的两个成员(ht_fcd 和 ht_full_fcda)创建了空的哈希表。apr_hash_make(g_init_pool) 会在 g_init_pool 内存池中为这两个哈希表分配内存空间
|
||||
ied_usr->LD_info[cpuno - 1].ht_full_fcda = apr_hash_make(g_init_pool);//它们的 key 值和 value 在后续的代码中可能会被填充
|
||||
ied_usr->LD_info[cpuno - 1].rptcount = 0;
|
||||
cout << "rptcount:" << ied_usr->LD_info[cpuno - 1].rptcount << endl;
|
||||
|
||||
if (cpuno > ied->cpucount) {
|
||||
ied->cpucount = cpuno;
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if (count_real < count_cfg)
|
||||
if (count_real < count_cfg){
|
||||
g_node->n_clients = count_real;
|
||||
if (count_cfg != count_real)
|
||||
}
|
||||
|
||||
if (count_cfg != count_real){
|
||||
return APR_EBADF;
|
||||
}
|
||||
|
||||
cout << "dev init create count:" << count_real;
|
||||
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
catch (otl_exception& e)
|
||||
catch (...)
|
||||
{
|
||||
printf("\n device error,ERROR code= %d,msg= %s \n", e.code, e.msg);
|
||||
return e.code;
|
||||
printf("\n device error \n");
|
||||
return APR_EBADF;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4727,10 +4795,10 @@ int parse_model_cfg_web()
|
||||
delete_icd_model_map(icd_model_map);
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
catch (otl_exception& e)
|
||||
catch (...)
|
||||
{
|
||||
printf("\n icd model error,ERROR code= %d,msg= %s \n", e.code, e.msg);
|
||||
return e.code;
|
||||
printf("\n icd model error\n");
|
||||
return APR_EBADF;
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////icd模型重构函数lnk20250116
|
||||
@@ -4798,9 +4866,9 @@ char* parse_model_cfg_web_one(ied_t* ied, char* out_model)
|
||||
delete_icd_model_map(icd_model_map);//lnk20250701
|
||||
return NULL;
|
||||
}
|
||||
catch (otl_exception& e)
|
||||
catch (...)
|
||||
{
|
||||
printf("\n icd model error,ERROR code= %d,msg= %s \n", e.code, e.msg);
|
||||
printf("\n icd model error\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -5404,6 +5472,16 @@ int update_one_terminal_ledger(terminal* update, int i,ied_t* ied,int terminal_i
|
||||
apr_snprintf(ied_usr->processNo, sizeof(ied_usr->processNo), "%s", update[i].processNo);
|
||||
printf("ied_usr->processNo: %s\n", ied_usr->processNo);
|
||||
}
|
||||
|
||||
//log_level拷贝到ied_usr中
|
||||
if (update[i].log_level >= 0 && update[i].log_level <= 3) {
|
||||
ied_usr->log_level = update[i].log_level;
|
||||
printf("ied_usr->log_level: %d\n", ied_usr->log_level);
|
||||
} else {
|
||||
ied_usr->log_level = 1; // 默认为1,表示warn级别
|
||||
printf("ied_usr->log_level (default): %d\n", ied_usr->log_level);
|
||||
}
|
||||
|
||||
if (update[i].dev_series != NULL) {
|
||||
apr_snprintf(ied_usr->dev_series, sizeof(ied_usr->dev_series), "%s", update[i].dev_series);
|
||||
printf("ied_usr->dev_series: %s\n", ied_usr->dev_series);
|
||||
@@ -5510,6 +5588,19 @@ int update_one_terminal_ledger(terminal* update, int i,ied_t* ied,int terminal_i
|
||||
strncpy(line_info.monitor_status, monitor_data.status, sizeof(line_info.monitor_status) - 1);
|
||||
strncpy(line_info.terminal_code, monitor_data.terminal_code, sizeof(line_info.terminal_code) - 1);
|
||||
strncpy(logical_device_seq, monitor_data.logical_device_seq, sizeof(logical_device_seq) - 1);
|
||||
|
||||
//log_level拷贝到line_info中
|
||||
if (monitor_data.log_level >= 0 && monitor_data.log_level <= 3) { //优先使用监测点的log_level
|
||||
line_info.log_level = monitor_data.log_level;
|
||||
printf("line_info.log_level (monitor): %d\n", line_info.log_level);
|
||||
} else if (ied_usr->log_level >= 0 && ied_usr->log_level <= 3) { //继承终端的log_level
|
||||
line_info.log_level = ied_usr->log_level;
|
||||
printf("line_info.log_level (inherit terminal): %d\n", line_info.log_level);
|
||||
} else {
|
||||
line_info.log_level = 1;
|
||||
printf("line_info.log_level (default): %d\n", line_info.log_level);
|
||||
}
|
||||
|
||||
if (isCharPtrEmpty(logical_device_seq)) {
|
||||
line_info.cpuno = 1; // 默认监测点实例号1
|
||||
printf("logical_device_seq: is null, set cpuno: %d\n", (int)line_info.cpuno);
|
||||
@@ -5526,6 +5617,7 @@ int update_one_terminal_ledger(terminal* update, int i,ied_t* ied,int terminal_i
|
||||
printf("v_wiring_type: %s\n", line_info.v_wiring_type);
|
||||
printf("monitor_status: %s\n", line_info.monitor_status);
|
||||
printf("name: %s\n", line_info.name);
|
||||
printf("log_level: %d\n", line_info.log_level);
|
||||
|
||||
//lnk20250214角形
|
||||
if (strcmp(line_info.v_wiring_type, "0") != 0)
|
||||
@@ -6137,6 +6229,8 @@ void clearLDInfo(LD_info_t *ld_info) {
|
||||
memset(ld_info->FltNum, 0, sizeof(ld_info->FltNum));
|
||||
|
||||
ld_info->RDRE_FltNum = 0; //录波号清零
|
||||
|
||||
ld_info->log_level = 1; //log_level设为1,默认日志级别为1,后续根据需要调整
|
||||
|
||||
|
||||
}
|
||||
@@ -6185,6 +6279,7 @@ void clearIedUsr(ied_usr_t *ied_usr) {
|
||||
memset(ied_usr->tmnl_factory, 0, sizeof(ied_usr->tmnl_factory));
|
||||
memset(ied_usr->tmnl_status, 0, sizeof(ied_usr->tmnl_status));
|
||||
memset(ied_usr->terminal_code, 0, sizeof(ied_usr->terminal_code));
|
||||
ied_usr->log_level = 1; //log_level设为1,默认日志级别为1,后续根据需要调整
|
||||
}
|
||||
|
||||
// 清空 channel 和 cpuinfo 的非指针部分
|
||||
|
||||
Reference in New Issue
Block a user