Compare commits
8 Commits
0b8a6739f6
...
zz
| Author | SHA1 | Date | |
|---|---|---|---|
| ad44d5b031 | |||
| 2fffeb7f8a | |||
| 6ad37904f7 | |||
| 16a2c41627 | |||
| 405048ed44 | |||
| 145092b0ba | |||
| 640f6c32b1 | |||
| 5e933b6729 |
@@ -5,13 +5,15 @@ DEPENDPATH += .
|
||||
INCLUDEPATH += . \
|
||||
./source \
|
||||
./source/include \
|
||||
./source/include/inc \
|
||||
./source/include/mmslite \
|
||||
./source/include/pg_inst \
|
||||
./source/include/curl \
|
||||
./source/include/oss_sdk \
|
||||
./source/include/rocketmq
|
||||
./source/include/rocketmq \
|
||||
./source/redisstream
|
||||
|
||||
QMAKE_ORIG_TARGET = $$(TARGET)
|
||||
QMAKE_ORIG_TARGET = $$TARGET
|
||||
|
||||
QT += core xml network
|
||||
CONFIG += thread
|
||||
@@ -20,7 +22,18 @@ DEFINES += _CRT_SECURE_NO_WARNINGS
|
||||
DEFINES += MMS_LITE LINUX=2 MOSI LEAN_T TP0_ENABLED
|
||||
DEFINES += CLIENT _DEBUG _REENTRANT _GNU_SOURCE _LARGEFILE64_SOURCE
|
||||
|
||||
# debug/release flags
|
||||
# 如果 ARM 版本也要保留 RocketMQ / Redis Stream 运行时切换,保留这个宏
|
||||
DEFINES += USE_MQ_MULTI_BACKEND
|
||||
|
||||
# C++ 标准
|
||||
unix {
|
||||
QMAKE_CXXFLAGS -= -std=gnu++98
|
||||
QMAKE_CXXFLAGS -= -std=c++98
|
||||
QMAKE_CXXFLAGS -= -std=gnu++11
|
||||
QMAKE_CXXFLAGS -= -std=c++11
|
||||
QMAKE_CXXFLAGS += -std=gnu++14
|
||||
}
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
message("Building debug version with debug symbols")
|
||||
QMAKE_CFLAGS_DEBUG += -g -O0
|
||||
@@ -39,7 +52,6 @@ win32 {
|
||||
}
|
||||
|
||||
win32 {
|
||||
# RC_FILE=pt61850netd_pqfe.rc
|
||||
SOURCES += source/mms/event.c
|
||||
INCLUDEPATH += ./source/include/apr
|
||||
QMAKE_LFLAGS += /NODEFAULTLIB:libcmt.lib
|
||||
@@ -69,62 +81,51 @@ win32 {
|
||||
}
|
||||
|
||||
unix {
|
||||
# 清掉旧标准
|
||||
QMAKE_CXXFLAGS -= -std=gnu++98
|
||||
QMAKE_CXXFLAGS -= -std=c++98
|
||||
QMAKE_CXXFLAGS -= -std=gnu++11
|
||||
QMAKE_CXXFLAGS -= -std=c++11
|
||||
|
||||
# 只保留一个
|
||||
QMAKE_CXXFLAGS += -std=gnu++14
|
||||
|
||||
include(fe_common.pri)
|
||||
|
||||
SOURCES += source/mms/event2.c
|
||||
INCLUDEPATH += ./source/include/apr-linux
|
||||
|
||||
LIBS += -L/FeProject/lib
|
||||
# LIBS += -L/FeProject/lib/pgodbc
|
||||
|
||||
DEFINES += DEBUG_SISCO
|
||||
VERSION = 1.0.0
|
||||
|
||||
# rpath
|
||||
QMAKE_LFLAGS += -Wl,-rpath,/FeProject/lib \
|
||||
-Wl,-rpath,/FeProject/lib/mmslite
|
||||
# 本地 lib 目录
|
||||
LIBS += -L$$PWD/lib
|
||||
|
||||
# 运行时优先找当前工程 lib。
|
||||
# 如果程序最终放到 /FeProject/bin,旁边有 /FeProject/lib,则推荐 $$ORIGIN/../lib。
|
||||
QMAKE_LFLAGS += -Wl,-rpath,'$$ORIGIN/../lib'
|
||||
QMAKE_LFLAGS += -Wl,-rpath,$$PWD/lib
|
||||
|
||||
LIBS += -lrt -lpthread
|
||||
|
||||
MMS_LIB_SUFFIX = _ld.a
|
||||
LIBS += /FeProject/lib/mmslite/ositcps$$MMS_LIB_SUFFIX \
|
||||
/FeProject/lib/mmslite/mvl$$MMS_LIB_SUFFIX \
|
||||
/FeProject/lib/mmslite/mmsle$$MMS_LIB_SUFFIX \
|
||||
/FeProject/lib/mmslite/mmsl$$MMS_LIB_SUFFIX \
|
||||
/FeProject/lib/mmslite/asn1l$$MMS_LIB_SUFFIX \
|
||||
/FeProject/lib/mmslite/mem$$MMS_LIB_SUFFIX \
|
||||
/FeProject/lib/mmslite/slog$$MMS_LIB_SUFFIX \
|
||||
/FeProject/lib/mmslite/util$$MMS_LIB_SUFFIX \
|
||||
/FeProject/lib/mmslite/ssec0$$MMS_LIB_SUFFIX \
|
||||
/FeProject/lib/libcurl.so \
|
||||
/FeProject/lib/libmxml4.so \
|
||||
/FeProject/lib/librocketmq.so \
|
||||
/FeProject/lib/libhttprun.so \
|
||||
/FeProject/lib/liblog4cplus.so
|
||||
# MMS 静态总库,按 x86 已验证版本方式处理
|
||||
LIBS += $$PWD/lib/libmmslib.a
|
||||
|
||||
LIBS += -lapr-1 -laprutil-1 -ljclite
|
||||
LIBS += -lrdkafka++
|
||||
LIBS += -lrdkafka
|
||||
LIBS += -L/FeProject/lib -llog4cplus
|
||||
LIBS += -L/root/JoyProject/3rdparty/boost_pic_aarch64/lib -Wl,--no-as-needed -lboost_iostreams -Wl,--as-needed
|
||||
LIBS += -L/root/JoyProject/3rdparty/zlib_pic_aarch64/lib -lz
|
||||
# 基础依赖库,全部从 $$PWD/lib 查找
|
||||
LIBS += -lcurl \
|
||||
$$PWD/lib/libmxml4.so \
|
||||
-lrocketmq \
|
||||
-lhttprun \
|
||||
-llog4cplus \
|
||||
-lapr-1 \
|
||||
-laprutil-1 \
|
||||
-ljclite \
|
||||
-lrdkafka++ \
|
||||
-lrdkafka
|
||||
|
||||
# Redis Stream 后端需要
|
||||
#LIBS += -lhiredis \
|
||||
# -lz
|
||||
|
||||
# 如果你的 RedisStreamMQ.cpp 里确实用了 boost_iostreams,再打开这一行。
|
||||
# 如果只是 zlib compress/uncompress,没有用 boost,可以不加。
|
||||
# LIBS += -lboost_iostreams
|
||||
}
|
||||
|
||||
# install
|
||||
target.path = ../../bin
|
||||
INSTALLS += target
|
||||
|
||||
# Input
|
||||
|
||||
HEADERS += source/mms/db_interface.h \
|
||||
source/include/otlv4.h \
|
||||
source/mms/mmsclient.h \
|
||||
@@ -134,11 +135,9 @@ HEADERS += source/mms/db_interface.h \
|
||||
source/misc/SM4.h \
|
||||
source/json/save2json.h \
|
||||
source/json/mms_json_inter.h \
|
||||
# source/json/rdkafka.h \
|
||||
# source/json/rdkafkacpp.h \
|
||||
# source/json/kafka_producer.h \
|
||||
source/json/cjson.h \
|
||||
source/rocketmq/SimpleProducer.h \
|
||||
# source/redisstream/RedisStreamMQ.h \
|
||||
source/cfg_parse/custom_printf.h \
|
||||
source/log4cplus/log4.h
|
||||
|
||||
@@ -161,15 +160,10 @@ SOURCES += source/mms/main.c \
|
||||
source/misc/my_encrypt.cpp \
|
||||
source/json/save2json.cpp \
|
||||
source/cfg_parse/cfg_parser.cpp \
|
||||
# source/json/kafka_producer.cpp \
|
||||
source/json/create_json.cpp \
|
||||
source/json/cjson.c \
|
||||
source/cfg_parse/nacos.cpp \
|
||||
source/cfg_parse/base64.cpp \
|
||||
source/cfg_parse/SimpleProducer.cpp \
|
||||
source/cfg_parse/log4.cpp \
|
||||
# source/cfg_parse/oss_aliyun.cpp \
|
||||
#source/cfg_parse/obs_huaweiyun.cpp \
|
||||
# source/cfg_parse/datahub.cpp \
|
||||
# source/cfg_parse/uds_huaweiyun.cpp
|
||||
|
||||
# source/redisstream/RedisStreamMQ.cpp \
|
||||
source/cfg_parse/log4.cpp
|
||||
@@ -457,6 +457,7 @@ typedef struct mvl_net_info
|
||||
|
||||
ST_VOID *user_info; /* MVL user can use this for 'whatever' */
|
||||
MVL_NET_FILE *file_list; /* linked list of open files on this conn*/
|
||||
ST_VOID *user_ext; /* user can use this for 'whatever', add by Lzm */
|
||||
} MVL_NET_INFO;
|
||||
|
||||
/* Our connection control structures */
|
||||
|
||||
@@ -32,10 +32,12 @@
|
||||
#include <QMutexLocker>
|
||||
#include <QMapIterator>
|
||||
#include <QStringList>
|
||||
#include <QByteArray>
|
||||
#include <QList>
|
||||
|
||||
// ★MOD: 全局追踪表:mp_id -> remaining times
|
||||
//全局追踪表:mp_id -> rpt_no -> remaining times
|
||||
static QMutex g_trace_mutex;
|
||||
static QHash<QString, int> g_trace_map;
|
||||
static QHash<QString, QHash<int, int> > g_trace_map;
|
||||
|
||||
///////////////////////////////////////////////////lnk2024-10-21////////////////////////////////////////////////////////
|
||||
extern void SendJsonAPI_web(const std::string& strUrl, const char* code, const std::string& json, char** ptr);
|
||||
@@ -258,36 +260,77 @@ static QString escape_json_string(const QString& s)
|
||||
return out;
|
||||
}
|
||||
|
||||
// 打开追踪:次数 times(比如 5)
|
||||
// 打开追踪:每个报告各追踪一次
|
||||
void process_trace_command(const std::string& id, int times)
|
||||
{
|
||||
if (times <= 0) return;
|
||||
(void)times;
|
||||
QString qid = QString::fromStdString(id).trimmed();
|
||||
if (qid.isEmpty()) return;
|
||||
|
||||
QList<int> rpt_nos;
|
||||
|
||||
QByteArray qid_bytes = qid.toLocal8Bit();
|
||||
|
||||
pthread_mutex_lock(&mtx);
|
||||
LD_info_t *ld_info = find_LD_info_only_from_mp_id(qid_bytes.data());
|
||||
if (ld_info != NULL && ld_info->rptinfo != NULL && ld_info->rptcount > 0) {
|
||||
for (int i = 0; i < ld_info->rptcount; ++i) {
|
||||
if (ld_info->rptinfo[i] == NULL)
|
||||
continue;
|
||||
|
||||
int rpt_no = ld_info->rptinfo[i]->rptNo;
|
||||
if (!rpt_nos.contains(rpt_no))
|
||||
rpt_nos.append(rpt_no);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&mtx);
|
||||
|
||||
if (rpt_nos.isEmpty()) {
|
||||
cout << "[TRACE] mp_id=" << id << " has no report info" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
QMutexLocker lk(&g_trace_mutex);
|
||||
g_trace_map[qid] = times; // 重新打开就覆盖/重置次数
|
||||
QHash<int, int>& rpt_map = g_trace_map[qid];
|
||||
for (int i = 0; i < rpt_nos.size(); ++i) {
|
||||
int rpt_no = rpt_nos.at(i);
|
||||
rpt_map[rpt_no] = 1;
|
||||
cout << "[TRACE] mp_id=" << id << " add rpt_no=" << rpt_no
|
||||
<< " left=" << rpt_map.value(rpt_no) << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// 查询是否要追踪
|
||||
static bool trace_is_enabled(const QString& mp_id)
|
||||
static bool trace_is_enabled(const QString& mp_id, int rpt_no)
|
||||
{
|
||||
QMutexLocker lk(&g_trace_mutex);
|
||||
auto it = g_trace_map.constFind(mp_id);
|
||||
return (it != g_trace_map.constEnd() && it.value() > 0);
|
||||
QHash<QString, QHash<int, int> >::const_iterator mp_it = g_trace_map.constFind(mp_id);
|
||||
if (mp_it == g_trace_map.constEnd())
|
||||
return false;
|
||||
|
||||
QHash<int, int>::const_iterator rpt_it = mp_it.value().constFind(rpt_no);
|
||||
return (rpt_it != mp_it.value().constEnd() && rpt_it.value() > 0);
|
||||
}
|
||||
|
||||
// 命中一次并扣减;扣到 0 自动删
|
||||
static void trace_hit_and_decrement(const QString& mp_id)
|
||||
static void trace_hit_and_decrement(const QString& mp_id, int rpt_no)
|
||||
{
|
||||
QMutexLocker lk(&g_trace_mutex);
|
||||
auto it = g_trace_map.find(mp_id);
|
||||
if (it == g_trace_map.end()) return;
|
||||
QHash<QString, QHash<int, int> >::iterator mp_it = g_trace_map.find(mp_id);
|
||||
if (mp_it == g_trace_map.end()) return;
|
||||
|
||||
int left = it.value();
|
||||
QHash<int, int>::iterator rpt_it = mp_it.value().find(rpt_no);
|
||||
if (rpt_it == mp_it.value().end()) return;
|
||||
|
||||
int left = rpt_it.value();
|
||||
left -= 1;
|
||||
if (left <= 0) g_trace_map.erase(it);
|
||||
else it.value() = left;
|
||||
if (left <= 0)
|
||||
mp_it.value().erase(rpt_it);
|
||||
else
|
||||
rpt_it.value() = left;
|
||||
|
||||
if (mp_it.value().isEmpty())
|
||||
g_trace_map.erase(mp_it);
|
||||
}
|
||||
|
||||
//追踪61850原始数据
|
||||
@@ -316,15 +359,20 @@ static QString build_mms_json_object(const json_block_data* data)
|
||||
return json;
|
||||
}
|
||||
|
||||
static QString build_trace_json(const json_block_data* data)
|
||||
static QString build_trace_json(const json_block_data* data, const char *v_wiring_type, const char *rpt_id, int rpt_no)
|
||||
{
|
||||
if (!data) return "{}";
|
||||
|
||||
QString mms_json = build_mms_json_object(data);
|
||||
QString wiring_type = v_wiring_type ? QString::fromLocal8Bit(v_wiring_type) : "";
|
||||
QString rpt = rpt_id ? QString::fromLocal8Bit(rpt_id) : "";
|
||||
|
||||
QString json;
|
||||
json += "{";
|
||||
json += QString("\"mp_id\":\"%1\",").arg(escape_json_string(data->mp_id));
|
||||
json += QString("\"v_wiring_type\":\"%1\",").arg(escape_json_string(wiring_type));
|
||||
json += QString("\"rpt_id\":\"%1\",").arg(escape_json_string(rpt));
|
||||
json += QString("\"rpt_no\":%1,").arg(rpt_no);
|
||||
json += QString("\"func_type\":%1,").arg(data->func_type);
|
||||
json += QString("\"data_time\":%1,").arg(QString::number((qlonglong)data->time));
|
||||
json += QString("\"voltage_level\":\"%1\",").arg(QString::number(data->voltage_level, 'f', 6));
|
||||
@@ -335,13 +383,13 @@ static QString build_trace_json(const json_block_data* data)
|
||||
return json;
|
||||
}
|
||||
|
||||
static void send_trace_if_needed(json_block_data* pdata)
|
||||
static void send_trace_if_needed(json_block_data* pdata, const char *v_wiring_type, const char *rpt_id, int rpt_no)
|
||||
{
|
||||
const QString mp_id_q = pdata->mp_id;
|
||||
if (trace_is_enabled(mp_id_q)) {
|
||||
if (trace_is_enabled(mp_id_q, rpt_no)) {
|
||||
|
||||
// 1) 组 json
|
||||
QString jsonText = build_trace_json(pdata);
|
||||
QString jsonText = build_trace_json(pdata, v_wiring_type, rpt_id, rpt_no);
|
||||
|
||||
// 2) 组 KafkaData
|
||||
Ckafka_data_t KafkaData;
|
||||
@@ -355,9 +403,25 @@ static void send_trace_if_needed(json_block_data* pdata)
|
||||
kafka_data_list_mutex.unlock();
|
||||
|
||||
// 3) 次数 -1
|
||||
trace_hit_and_decrement(mp_id_q);
|
||||
trace_hit_and_decrement(mp_id_q, rpt_no);
|
||||
}
|
||||
}
|
||||
|
||||
int trace_json_block_data(char v_wiring_type[], json_block_data *data, const char *rpt_id, int rpt_no)
|
||||
{
|
||||
send_trace_if_needed(data, v_wiring_type, rpt_id, rpt_no);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int trace_json_is_enabled(const char *mp_id, int rpt_no)
|
||||
{
|
||||
QString mp_id_q = mp_id ? QString::fromLocal8Bit(mp_id).trimmed() : "";
|
||||
if (mp_id_q.isEmpty())
|
||||
return 0;
|
||||
|
||||
return trace_is_enabled(mp_id_q, rpt_no) ? 1 : 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////lnk20250710添加频率值存储
|
||||
struct mp_freq_save {
|
||||
double G_FREQ;
|
||||
@@ -1162,9 +1226,12 @@ void printCTopicList(const std::list<CTopic*>& ctopic_list) {
|
||||
val->fValue);
|
||||
}
|
||||
}
|
||||
break; // 只打印第一个 Item 的 SequenceList 和 DataValueList,避免输出过多
|
||||
}
|
||||
break; // 只打印第一个 Monitor 的 ItemList,避免输出过多
|
||||
}
|
||||
|
||||
|
||||
// 如果需要打印 SOEList,可加以下:
|
||||
/*
|
||||
int soeIndex = 0;
|
||||
@@ -1217,9 +1284,6 @@ int transfer_json_block_data(char v_wiring_type[], json_block_data *data) //json
|
||||
print_mms_str_map(data);
|
||||
}
|
||||
|
||||
//数据追踪上送
|
||||
send_trace_if_needed(data);
|
||||
|
||||
list<CTopic*> ctopic_list;
|
||||
|
||||
////lnk2024-8-15 区分星型,角型接线
|
||||
@@ -1562,7 +1626,9 @@ int transfer_json_block_data(char v_wiring_type[], json_block_data *data) //json
|
||||
kafka_data_list_mutex.unlock(); //解锁
|
||||
longjumpflag = true;
|
||||
}
|
||||
|
||||
else if (countflag < num && 0 != time_sec % 7200) {
|
||||
longjumpflag = true;//不发送数据
|
||||
}
|
||||
//lnk20260127
|
||||
if (typeofdata == false || data_have_static == false) {//不合并则处理完闪变就不处理其他数据,如果有统计数据或者数据类型区分了就继续处理其他数据
|
||||
if (longjumpflag == true || shortjumpflag == true) {
|
||||
@@ -2471,6 +2537,9 @@ int transfer_json_block_data(char v_wiring_type[], json_block_data *data) //json
|
||||
kafka_data_list_mutex.unlock(); //解锁
|
||||
longjumpflag = true;
|
||||
}
|
||||
else if (countflag < num && 0 != time_sec % 7200) {
|
||||
longjumpflag = true;//不发送数据
|
||||
}
|
||||
if (typeofdata == false || data_have_static == false) {//不合并则处理完闪变就不处理其他数据
|
||||
if (longjumpflag == true || shortjumpflag == true) {
|
||||
return 1;
|
||||
@@ -3758,4 +3827,3 @@ void Set_xml_nodeinfo_one(char* dev_type)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,8 @@ public:
|
||||
};
|
||||
|
||||
int transfer_json_block_data(char v_wiring_type[], json_block_data* data);//lnk2024-8-16添加参数
|
||||
int trace_json_is_enabled(const char *mp_id, int rpt_no);
|
||||
int trace_json_block_data(char v_wiring_type[], json_block_data* data, const char *rpt_id, int rpt_no);
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -95,4 +97,4 @@ void connectlog_pgsql(char* id,char* datetime,int status);
|
||||
#endif
|
||||
|
||||
|
||||
#endif //MMS_JSON_INTER_92327hyhy0923r_H
|
||||
#endif //MMS_JSON_INTER_92327hyhy0923r_H
|
||||
|
||||
@@ -198,6 +198,7 @@ static QMap<int, QMap<int, QList<long long>>> real_data_report_map; //多个监
|
||||
static QMap<QString, json_block_data*> json_data_map;//CZY 2023-08-17 ww 2023年3月13日17:23:17扩展Map,用于保存各条线路的数据
|
||||
static QMap<QString, json_block_data*> json_flicker_data_map;//CZY 2023-09-11 展Map,用于保存各条线路的闪变数据
|
||||
static QMap<QString, json_block_data*> json_pst_data_map;//CZY 2023-09-11 展Map,用于保存各条线路的闪变数据
|
||||
static QMap<QString, json_block_data*> json_trace_data_map;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////lnk20260310文件控制
|
||||
pthread_mutex_t g_file_req_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
@@ -1539,7 +1540,7 @@ int parse_log(const std::string& json_str) {
|
||||
}
|
||||
else if((level == "measurepoint") && (grade == "TRACE") && (!id.empty() && !is_blank(id))){ //数据追踪
|
||||
//打开监测点数据追踪开关
|
||||
process_trace_command(id,3); //3表示追踪次数
|
||||
process_trace_command(id,1); //每个报告各追踪1次
|
||||
}
|
||||
else{
|
||||
std::cout << "type doesnt match" <<std::endl;
|
||||
@@ -3633,6 +3634,119 @@ int json_block_create_data(char monid_char[], char* mms_str, double v, int flick
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static QString json_trace_block_key(char monid_char[], int flicker_flag, int rpt_no)
|
||||
{
|
||||
QString key;
|
||||
key.append(monid_char ? monid_char : "");
|
||||
key.append("|");
|
||||
key.append(QString::number(flicker_flag));
|
||||
key.append("|");
|
||||
key.append(QString::number(rpt_no));
|
||||
return key;
|
||||
}
|
||||
|
||||
static json_block_data* get_json_trace_block_data(char monid_char[], int flicker_flag, int rpt_no)
|
||||
{
|
||||
QString key = json_trace_block_key(monid_char, flicker_flag, rpt_no);
|
||||
if (!json_trace_data_map.contains(key))
|
||||
return NULL;
|
||||
return json_trace_data_map.value(key);
|
||||
}
|
||||
|
||||
static void init_json_trace_block_data(char monid_char[], char voltage_level[], int flicker_flag, int rpt_no)
|
||||
{
|
||||
QString key = json_trace_block_key(monid_char, flicker_flag, rpt_no);
|
||||
json_block_data* pdata = NULL;
|
||||
if (!json_trace_data_map.contains(key)) {
|
||||
pdata = new json_block_data();
|
||||
json_trace_data_map.insert(key, pdata);
|
||||
}
|
||||
|
||||
pdata = json_trace_data_map.value(key);
|
||||
pdata->monitorId = -1;
|
||||
pdata->func_type = g_node_id;
|
||||
pdata->flag = 0;
|
||||
pdata->time = 0;
|
||||
pdata->voltage_level = get_voltage_level(voltage_level);
|
||||
pdata->mp_id = monid_char ? QString::fromLocal8Bit(monid_char) : QString("not define");
|
||||
pdata->dev_type.clear();
|
||||
pdata->mms_str_map.clear();
|
||||
pdata->data_have_statistic = 0;
|
||||
}
|
||||
|
||||
int json_trace_block_create_start(char voltage_level[], char monid_char[], int flicker_flag, char temcode[], int line_id, char v_wiring_type[], char rpt_id[], int rpt_no)
|
||||
{
|
||||
(void)v_wiring_type;
|
||||
(void)rpt_id;
|
||||
if (!trace_json_is_enabled(monid_char, rpt_no))
|
||||
return 0;
|
||||
|
||||
try_start_kafka_thread();
|
||||
init_json_trace_block_data(monid_char, voltage_level, flicker_flag, rpt_no);
|
||||
|
||||
json_block_data* pdata = get_json_trace_block_data(monid_char, flicker_flag, rpt_no);
|
||||
if (pdata != NULL) {
|
||||
pdata->dev_type.append(temcode ? temcode : "");
|
||||
pdata->monitorId = line_id;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int json_trace_block_create_time(char monid_char[], long long Time, int flicker_flag, char rpt_id[], int rpt_no)
|
||||
{
|
||||
(void)rpt_id;
|
||||
json_block_data* pdata = get_json_trace_block_data(monid_char, flicker_flag, rpt_no);
|
||||
if (pdata == NULL)
|
||||
return 0;
|
||||
|
||||
pdata->time = Time;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int json_trace_block_create_flag(char monid_char[], int flag, int flicker_flag, char rpt_id[], int rpt_no)
|
||||
{
|
||||
(void)rpt_id;
|
||||
json_block_data* pdata = get_json_trace_block_data(monid_char, flicker_flag, rpt_no);
|
||||
if (pdata == NULL)
|
||||
return 0;
|
||||
|
||||
pdata->flag = flag;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int json_trace_block_create_data(char monid_char[], char* mms_str, double v, int flicker_flag, char rpt_id[], int rpt_no)
|
||||
{
|
||||
(void)rpt_id;
|
||||
json_block_data* pdata = get_json_trace_block_data(monid_char, flicker_flag, rpt_no);
|
||||
if (pdata == NULL)
|
||||
return 0;
|
||||
|
||||
pdata->mms_str_map.insert(QString::fromAscii(mms_str), v);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int json_trace_block_create_end(char v_wiring_type[], char monid_char[], int flicker_flag, char rpt_id[], int rpt_no)
|
||||
{
|
||||
QString key = json_trace_block_key(monid_char, flicker_flag, rpt_no);
|
||||
if (!json_trace_data_map.contains(key))
|
||||
return 1;
|
||||
|
||||
json_block_data* pdata = json_trace_data_map.value(key);
|
||||
if (pdata == NULL) {
|
||||
json_trace_data_map.remove(key);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ret = 1;
|
||||
if (pdata->mms_str_map.count() > 0)
|
||||
ret = trace_json_block_data(v_wiring_type, pdata, rpt_id, rpt_no);
|
||||
|
||||
delete pdata;
|
||||
json_trace_data_map.remove(key);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//lnk2024-8-16添加接线参数
|
||||
int json_block_create_end(char v_wiring_type[], char monid_char[], int flicker_flag)//WW 2023年3月13日16:38:41 多ICD修改
|
||||
@@ -3693,7 +3807,7 @@ int json_block_create_end(char v_wiring_type[], char monid_char[], int flicker_f
|
||||
json_pst_data_map.remove(monid_char);
|
||||
|
||||
}
|
||||
printf("---------- json_block_create_end: pdata->mms_str_map.count() == 0 ----------\n");
|
||||
printf("---------- json_block_create_end: mp_id= %s pdata->mms_str_map.count() == 0 ----------\n", monid_char);
|
||||
return 1;
|
||||
}
|
||||
//lnk2024-8-16添加接线参数
|
||||
@@ -3878,4 +3992,4 @@ int sel_mvl_type_ctrl_flag(char doname[])
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
//ZW 2024-01-31 end
|
||||
//ZW 2024-01-31 end
|
||||
|
||||
@@ -74,6 +74,12 @@ int json_block_create_data(char monid_char[], char* mms_str , double v, int flic
|
||||
//lnk2024-8-16添加参数
|
||||
int json_block_create_end(char v_wiring_type[], char monid_char[], int flicker_flag); //CZY 2023-08-17 测试
|
||||
|
||||
int json_trace_block_create_start(char voltage_level[], char monid_char[], int flicker_flag, char temcode[], int line_id, char v_wiring_type[], char rpt_id[], int rpt_no);
|
||||
int json_trace_block_create_time(char monid_char[], long long Time, int flicker_flag, char rpt_id[], int rpt_no);
|
||||
int json_trace_block_create_flag(char monid_char[], int flag, int flicker_flag, char rpt_id[], int rpt_no);
|
||||
int json_trace_block_create_data(char monid_char[], char* mms_str, double v, int flicker_flag, char rpt_id[], int rpt_no);
|
||||
int json_trace_block_create_end(char v_wiring_type[], char monid_char[], int flicker_flag, char rpt_id[], int rpt_no);
|
||||
|
||||
//zw 2024-01-31 补招模式优化
|
||||
void add_mvl_type_ctrl(char doname[], int ctrl);
|
||||
int sel_mvl_type_ctrl_flag(char doname[]);
|
||||
@@ -194,4 +200,4 @@ typedef struct file_dir_req_t
|
||||
#endif
|
||||
|
||||
|
||||
#endif //DB_INTERFACE_7ew2327hyhy0923r_H
|
||||
#endif //DB_INTERFACE_7ew2327hyhy0923r_H
|
||||
|
||||
@@ -219,7 +219,7 @@ void closeChannel(chnl_usr_t *chnl_usr)
|
||||
|
||||
mvl_free_req_ctrl(chnl_usr->m_reqCtrl);
|
||||
|
||||
chnl_usr->net_info->user_info = NULL;
|
||||
chnl_usr->net_info->user_ext = NULL;
|
||||
chnl_usr->net_info = NULL;
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ ST_VOID Callback_channel_disconnect_ind(MVL_NET_INFO * NetInfo, ST_INT discType)
|
||||
{
|
||||
chnl_usr_t *chnl_usr;
|
||||
|
||||
chnl_usr = (chnl_usr_t*)NetInfo->user_info;
|
||||
chnl_usr = (chnl_usr_t*)NetInfo->user_ext;
|
||||
|
||||
if ( chnl_usr ) {
|
||||
if(chnl_usr->m_state == CHANNEL_CONNECTING)
|
||||
@@ -265,7 +265,7 @@ ST_VOID Callback_channel_disconnect_ind(MVL_NET_INFO * NetInfo, ST_INT discType)
|
||||
|
||||
|
||||
chnl_usr->net_info = NULL;
|
||||
NetInfo->user_info = NULL;
|
||||
NetInfo->user_ext = NULL;
|
||||
|
||||
}
|
||||
printf(" Callback_channel_disconnect_ind ,NetInfo = %x",NetInfo);
|
||||
@@ -387,7 +387,7 @@ void ChannelCheckIECReports(chnl_usr_t *chnl_usr)
|
||||
rptinfo = LD_info->rptinfo[rpt_no] ;
|
||||
|
||||
//检查是否需要注册或取消注册报告,或不做任何处理
|
||||
printf("[RPT][CHECK] ip=%s cpu=%d rpt_no=%d rptcount=%d LD_name=%s rptinfo=%p\n",
|
||||
if(DEBUGOPEN)printf("[RPT][CHECK] ip=%s cpu=%d rpt_no=%d rptcount=%d LD_name=%s rptinfo=%p\n",
|
||||
chnl_usr->ip_str,
|
||||
cpuno,
|
||||
rpt_no,
|
||||
@@ -1720,7 +1720,7 @@ void CheckNextNotConnectedChannel()
|
||||
chnl_usr->m_reqCtrl = NULL;
|
||||
|
||||
chnl_usr->m_state = CHANNEL_CONNECTED;
|
||||
chnl_usr->net_info->user_info = chnl_usr;
|
||||
chnl_usr->net_info->user_ext = chnl_usr;
|
||||
|
||||
all_rcb_info = (ALL_RCB_INFO *)chk_calloc(1, sizeof (ALL_RCB_INFO));
|
||||
all_rcb_info->rpt_typeids = &g_rpt_typeids;
|
||||
@@ -1880,7 +1880,7 @@ void CheckNextNotConnectedChannel()
|
||||
echo_warn3( "CHANNEL_DISCONNECTING done %s:%d,NetInfo= %x ",chnl_usr->ip_str,chnl_usr->chnl->port,chnl_usr->net_info);
|
||||
mvl_free_req_ctrl(chnl_usr->m_reqCtrl);
|
||||
if(chnl_usr->net_info)
|
||||
chnl_usr->net_info->user_info = NULL;
|
||||
chnl_usr->net_info->user_ext = NULL;
|
||||
|
||||
chnl_usr->m_reqCtrl = NULL;
|
||||
chnl_usr->net_info = NULL;
|
||||
@@ -1908,7 +1908,7 @@ void CheckNextNotConnectedChannel()
|
||||
|
||||
echo_warn2( "CHANNEL_DISCONNECTING reqCtrl->done未完成,but time over 180 secs, close channel IP %s,NetInfo= %x ",chnl_usr->ip_str,chnl_usr->net_info);
|
||||
mvl_free_req_ctrl(chnl_usr->m_reqCtrl);
|
||||
chnl_usr->net_info->user_info = NULL;
|
||||
chnl_usr->net_info->user_ext = NULL;
|
||||
|
||||
mms_release_connection(chnl_usr->net_info);
|
||||
chnl_usr->net_info->rem_vmd = NULL;
|
||||
|
||||
@@ -844,7 +844,7 @@ ST_VOID u_iec_rpt_ind_data_by_devtype(MVL_VAR_ASSOC** info_va,
|
||||
rptinfo = find_rptinfo_from_net_rpt_info_name(net_info, rcb_info);
|
||||
//rptinfo->m_LastDataTime = sGetMsTime();//WW 2023-08-29 去除
|
||||
LD_info = rptinfo->LD_info;
|
||||
chnl_usr = net_info->user_info;
|
||||
chnl_usr = net_info->user_ext;
|
||||
ied = chnl_usr->chnl->ied;
|
||||
|
||||
not_set_rpt_TimeID_this = TRUE;
|
||||
@@ -993,6 +993,7 @@ ST_VOID u_iec_rpt_ind_data_by_devtype(MVL_VAR_ASSOC** info_va,
|
||||
ied = find_ied_from_dev_code(LD_info->terminal_code);
|
||||
|
||||
ied_usr_t* ied_usr = (ied_usr_t*)ied->usr_ext;
|
||||
json_trace_block_create_start(LD_info->voltage_level, LD_info->mp_id, rptinfo->flickerflag, ied_usr->dev_type, LD_info->line_id, LD_info->v_wiring_type, rcb_info->RptID, rptinfo->rptNo);
|
||||
|
||||
if (rptinfo->flickerflag==1)//CZY 2023-08-17 WW 2022-11-14 只有闪变和第一次进入才会初始化 json_block_create_start(LD_info->line_id);
|
||||
json_block_create_start( LD_info->voltage_level, LD_info->mp_id, rptinfo->flickerflag, ied_usr->dev_type, LD_info->line_id);
|
||||
@@ -1057,6 +1058,7 @@ ST_VOID u_iec_rpt_ind_data_by_devtype(MVL_VAR_ASSOC** info_va,
|
||||
}
|
||||
else {
|
||||
json_block_create_flag(LD_info->mp_id, flag, rptinfo->flickerflag);
|
||||
json_trace_block_create_flag(LD_info->mp_id, flag, rptinfo->flickerflag, rcb_info->RptID, rptinfo->rptNo);
|
||||
not_set_rpt_q_this = FALSE;
|
||||
}
|
||||
}
|
||||
@@ -1076,6 +1078,7 @@ ST_VOID u_iec_rpt_ind_data_by_devtype(MVL_VAR_ASSOC** info_va,
|
||||
}
|
||||
else {
|
||||
json_block_create_time(LD_info->mp_id, t / 1000, rptinfo->flickerflag);
|
||||
json_trace_block_create_time(LD_info->mp_id, t / 1000, rptinfo->flickerflag, rcb_info->RptID, rptinfo->rptNo);
|
||||
printf("rcb_info->RptID=%s ,LineId=%d , Timestamp= %lld \n", rcb_info->RptID, LD_info->line_id, t / 1000);
|
||||
not_set_rpt_TimeID_this = FALSE;
|
||||
/*if (strstr(rcb_info->RptID, "LLN0$RP$urcbRealData")) {//lnk 20250624
|
||||
@@ -1108,8 +1111,10 @@ ST_VOID u_iec_rpt_ind_data_by_devtype(MVL_VAR_ASSOC** info_va,
|
||||
else if (strstr(rcb_info->RptID, "RDRE")) {//CZY 2023-08-17 WW 2022-11-14 修改判断LLN0$BR$brcbRDRE
|
||||
processRDRE_data(LD_info, FULL_FCDA_Name, v);
|
||||
}
|
||||
else
|
||||
else {
|
||||
json_block_create_data(LD_info->mp_id, FULL_FCDA_Name, v, rptinfo->flickerflag);
|
||||
json_trace_block_create_data(LD_info->mp_id, FULL_FCDA_Name, v, rptinfo->flickerflag, rcb_info->RptID, rptinfo->rptNo);
|
||||
}
|
||||
}//else
|
||||
}
|
||||
}
|
||||
@@ -1126,6 +1131,7 @@ ST_VOID u_iec_rpt_ind_data_by_devtype(MVL_VAR_ASSOC** info_va,
|
||||
}
|
||||
else {
|
||||
printf("%d : %d", LD_info->rptRecvFlag, LD_info->rptRecvCheckFlag);
|
||||
json_trace_block_create_end(LD_info->v_wiring_type, LD_info->mp_id, rptinfo->flickerflag, rcb_info->RptID, rptinfo->rptNo);
|
||||
//append_db_records(RPT_IDX);
|
||||
if (rptinfo->flickerflag==1)//CZY 2023-08-17 WW 2022-11-14 增加闪变标志
|
||||
{
|
||||
@@ -1230,7 +1236,7 @@ ST_VOID u_iec_rpt_ind_data(MVL_VAR_ASSOC** info_va,
|
||||
rptinfo = find_rptinfo_from_net_rcb_info(net_info, rcb_info);
|
||||
//rptinfo->m_LastDataTime = sGetMsTime();//WW 2023-08-29 去除
|
||||
LD_info = rptinfo->LD_info;
|
||||
chnl_usr = net_info->user_info;
|
||||
chnl_usr = net_info->user_ext;
|
||||
ied = chnl_usr->chnl->ied;
|
||||
|
||||
not_set_rpt_TimeID_this = TRUE;
|
||||
@@ -1376,6 +1382,7 @@ ST_VOID u_iec_rpt_ind_data(MVL_VAR_ASSOC** info_va,
|
||||
ied = find_ied_from_dev_code(LD_info->terminal_code);
|
||||
|
||||
ied_usr_t* ied_usr = (ied_usr_t*)ied->usr_ext;
|
||||
json_trace_block_create_start(LD_info->voltage_level, LD_info->mp_id, rptinfo->flickerflag, ied_usr->dev_type, LD_info->line_id, LD_info->v_wiring_type, rcb_info->RptID, rptinfo->rptNo);
|
||||
if (rptinfo->flickerflag == 1)//CZY 2023-08-17 WW 2022-11-14 只有闪变和第一次进入才会初始化 json_block_create_start(LD_info->line_id);
|
||||
json_block_create_start(LD_info->voltage_level, LD_info->mp_id, rptinfo->flickerflag, ied_usr->dev_type, LD_info->line_id);
|
||||
else if (rptinfo->flickerflag == 0) {
|
||||
@@ -1461,6 +1468,7 @@ ST_VOID u_iec_rpt_ind_data(MVL_VAR_ASSOC** info_va,
|
||||
}
|
||||
else {
|
||||
json_block_create_flag(LD_info->mp_id, flag, rptinfo->flickerflag);
|
||||
json_trace_block_create_flag(LD_info->mp_id, flag, rptinfo->flickerflag, rcb_info->RptID, rptinfo->rptNo);
|
||||
not_set_rpt_q_this = FALSE;
|
||||
}
|
||||
}
|
||||
@@ -1484,6 +1492,7 @@ ST_VOID u_iec_rpt_ind_data(MVL_VAR_ASSOC** info_va,
|
||||
}
|
||||
else {
|
||||
json_block_create_time(LD_info->mp_id, t / 1000, rptinfo->flickerflag);
|
||||
json_trace_block_create_time(LD_info->mp_id, t / 1000, rptinfo->flickerflag, rcb_info->RptID, rptinfo->rptNo);
|
||||
printf("rcb_info->RptID=%s ,LineId=%d , Timestamp= %lld \n", rcb_info->RptID, LD_info->line_id, t / 1000);
|
||||
not_set_rpt_TimeID_this = FALSE;
|
||||
//if (strstr(rcb_info->RptID, "LLN0$RP$urcbRealData")) {
|
||||
@@ -1497,6 +1506,7 @@ ST_VOID u_iec_rpt_ind_data(MVL_VAR_ASSOC** info_va,
|
||||
printf("rtdata RptID match");
|
||||
if (urcbRealDataHasReceived(ied_usr->dev_idx,rpt_no,LD_info, t / 1000)){//判断时间重复
|
||||
printf("this rt report Time repeats");
|
||||
//json_trace_block_create_end(LD_info->v_wiring_type, LD_info->mp_id, rptinfo->flickerflag, rcb_info->RptID, rptinfo->rptNo);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1531,8 +1541,10 @@ ST_VOID u_iec_rpt_ind_data(MVL_VAR_ASSOC** info_va,
|
||||
ied_usr_t* ied_usr = GET_IEDEXT_ADDR(ied);
|
||||
processGGIO_start_data_end(LD_info->mp_id, FULL_FCDA_Name, v, time, ied_usr->dev_type, LD_info->line_id);//GGIO数据全套处理流程
|
||||
}
|
||||
else
|
||||
else {
|
||||
json_block_create_data(LD_info->mp_id, FULL_FCDA_Name, v, rptinfo->flickerflag);
|
||||
json_trace_block_create_data(LD_info->mp_id, FULL_FCDA_Name, v, rptinfo->flickerflag, rcb_info->RptID, rptinfo->rptNo);
|
||||
}
|
||||
}//else
|
||||
}
|
||||
|
||||
@@ -1550,6 +1562,7 @@ ST_VOID u_iec_rpt_ind_data(MVL_VAR_ASSOC** info_va,
|
||||
}
|
||||
else {
|
||||
printf("%d : %d", LD_info->rptRecvFlag, LD_info->rptRecvCheckFlag);
|
||||
json_trace_block_create_end(LD_info->v_wiring_type, LD_info->mp_id, rptinfo->flickerflag, rcb_info->RptID, rptinfo->rptNo);
|
||||
//append_db_records(RPT_IDX);
|
||||
if (rptinfo->flickerflag == 1)//CZY 2023-08-17 WW 2022-11-14 增加闪变标志
|
||||
{
|
||||
|
||||
@@ -139,7 +139,7 @@ RCB_INFO* FindRcbInfo(MVL_NET_INFO *net_info,ST_CHAR *dom_name, ST_CHAR *rcb_nam
|
||||
int cpuno,rpt_no;
|
||||
char rpt_inst_name[65];
|
||||
|
||||
chnl_usr = net_info->user_info;
|
||||
chnl_usr = net_info->user_ext;
|
||||
ied = chnl_usr->chnl->ied;
|
||||
ied_usr = GET_IEDEXT_ADDR(ied);
|
||||
|
||||
@@ -188,7 +188,7 @@ rptinfo_t* find_rptinfo_from_net_rpt_info_name(MVL_NET_INFO *net_info, RCB_INFO
|
||||
rptinfo_t *rptinfo = NULL;
|
||||
int cpuno,rpt_no;
|
||||
|
||||
chnl_usr = net_info->user_info;
|
||||
chnl_usr = net_info->user_ext;
|
||||
ied = chnl_usr->chnl->ied;
|
||||
ied_usr = GET_IEDEXT_ADDR(ied);
|
||||
|
||||
@@ -232,7 +232,7 @@ rptinfo_t* find_rptinfo_from_net_rcb_info(MVL_NET_INFO *net_info,RCB_INFO *rcb_i
|
||||
rptinfo_t *rptinfo = NULL;
|
||||
int cpuno,rpt_no;
|
||||
|
||||
chnl_usr = net_info->user_info;
|
||||
chnl_usr = net_info->user_ext;
|
||||
ied = chnl_usr->chnl->ied;
|
||||
ied_usr = GET_IEDEXT_ADDR(ied);
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -457,6 +457,7 @@ typedef struct mvl_net_info
|
||||
|
||||
ST_VOID *user_info; /* MVL user can use this for 'whatever' */
|
||||
MVL_NET_FILE *file_list; /* linked list of open files on this conn*/
|
||||
ST_VOID *user_ext; /* user can use this for 'whatever', add by Lzm */
|
||||
} MVL_NET_INFO;
|
||||
|
||||
/* Our connection control structures */
|
||||
|
||||
@@ -379,7 +379,7 @@ HEADERS += mmslib.h \
|
||||
inc/sx_log.h \
|
||||
inc/sx_defs.h \
|
||||
inc/sx_arb.h \
|
||||
inc/STR_UTIL.H \
|
||||
inc/str_util.h \
|
||||
inc/stime.h \
|
||||
inc/stdtime_w32.h \
|
||||
inc/stdtime_tzrules.h \
|
||||
@@ -393,7 +393,7 @@ HEADERS += mmslib.h \
|
||||
inc/stdtime_endian.h \
|
||||
inc/stdtime_config.h \
|
||||
inc/stdtime.h \
|
||||
inc/ssleLog.h \
|
||||
inc/sslelog.h \
|
||||
inc/ssec_int.h \
|
||||
inc/ssec.h \
|
||||
inc/sock_log.h \
|
||||
@@ -401,7 +401,7 @@ HEADERS += mmslib.h \
|
||||
inc/smp_usr.h \
|
||||
inc/smp_log.h \
|
||||
inc/smp.h \
|
||||
inc/Smem.h \
|
||||
inc/smem.h \
|
||||
inc/slog.h \
|
||||
inc/scrndefs.h \
|
||||
inc/scl.h \
|
||||
|
||||
@@ -69,23 +69,26 @@ unix {
|
||||
|
||||
INCLUDEPATH += ./source/include/apr-linux
|
||||
|
||||
LIBS += -L/FeProject/lib
|
||||
LIBS += -L/FeProject/lib/pgodbc
|
||||
|
||||
DEFINES += DEBUG_SISCO
|
||||
VERSION = 1.0.0
|
||||
|
||||
LIBS += -lrt -lpthread
|
||||
|
||||
LIBS += ./lib/libmmslib.a
|
||||
LIBS += -L$$PWD/lib
|
||||
|
||||
LIBS += ./lib/libcurl.so \
|
||||
./lib/libmxml.so \
|
||||
./lib/librocketmq.so \
|
||||
./lib/libhttprun.so \
|
||||
./lib/liblog4cplus.so
|
||||
LIBS += -lapr-1 -laprutil-1 -ljclite
|
||||
LIBS += -lrdkafka++
|
||||
QMAKE_LFLAGS += -Wl,-rpath,/FeProject/lib
|
||||
|
||||
LIBS += -lrt -lpthread
|
||||
|
||||
LIBS += ./lib/libmmslib.a
|
||||
|
||||
LIBS += -lcurl \
|
||||
-lmxml \
|
||||
-lrocketmq \
|
||||
-lhttprun \
|
||||
-llog4cplus \
|
||||
-lapr-1 \
|
||||
-laprutil-1 \
|
||||
-ljclite \
|
||||
-lrdkafka++
|
||||
}
|
||||
|
||||
#install
|
||||
|
||||
117
set_process.sh
117
set_process.sh
@@ -7,6 +7,14 @@
|
||||
# @author: lunankun
|
||||
|
||||
#前置all的重置或者新增都是由稳态的第一个进程来处理,所有进程收到这条消息后先判断自己的进程号是否是1,而且是稳态,否则不处理,所有操作均由这个进程完成,
|
||||
# 默认使用正式版
|
||||
FE_BIN="${FE_BIN:-pt61850netd_pqfe}"
|
||||
|
||||
# 如果最后一个参数是 debug,则使用调试版,并传给 detached 子进程
|
||||
if [ "$#" -gt 0 ] && [ "${!#}" = "debug" ]; then
|
||||
export FE_BIN="pt61850netd_pqfed"
|
||||
set -- "${@:1:$(($#-1))}"
|
||||
fi
|
||||
|
||||
if [ -z "$SETSID" ]; then
|
||||
export SETSID=1
|
||||
@@ -44,6 +52,48 @@ fi
|
||||
echo $$ > "$LOCK_FILE"
|
||||
trap "rm -f $LOCK_FILE" EXIT
|
||||
|
||||
start_fe_by_runtime_debug() {
|
||||
local RUNTIME_CF_FILE="/FeProject/etc/runtime.cf"
|
||||
local LINE BINPATH BIN SPECIAL SLEEPSEC STARTFLAG CMD_STR
|
||||
|
||||
log "[DEBUG_START] start processes from $RUNTIME_CF_FILE"
|
||||
|
||||
while IFS= read -r LINE; do
|
||||
[ -z "$LINE" ] && continue
|
||||
[ "${LINE:0:1}" = "#" ] && continue
|
||||
|
||||
BINPATH=$(echo "$LINE" | awk -F '^' '{printf $1}' | sed 's/^[[:space:]]*//; s/[[:space:]]*$//')
|
||||
BIN=$(echo "$LINE" | awk -F '^' '{printf $2}' | sed 's/^[[:space:]]*//; s/[[:space:]]*$//')
|
||||
SPECIAL=$(echo "$LINE" | awk -F '^' '{printf $4}' | sed 's/^[[:space:]]*//; s/[[:space:]]*$//')
|
||||
SLEEPSEC=$(echo "$LINE" | awk -F '^' '{printf $5}' | sed 's/^[[:space:]]*//; s/[[:space:]]*$//')
|
||||
STARTFLAG=$(echo "$LINE" | awk -F '^' '{printf $7}' | sed 's/^[[:space:]]*//; s/[[:space:]]*$//')
|
||||
|
||||
if echo "$BIN" | grep -q '^fe_watchdog'; then
|
||||
log "[DEBUG_START] skip watchdog: $BIN"
|
||||
continue
|
||||
fi
|
||||
|
||||
[ "$STARTFLAG" = "IGNORE_START" ] && continue
|
||||
[ -z "$BINPATH" ] || [ -z "$BIN" ] && continue
|
||||
[ -z "$SLEEPSEC" ] && SLEEPSEC=0
|
||||
|
||||
sleep "$SLEEPSEC"
|
||||
|
||||
CMD_STR="cd $BINPATH && ./$BIN $SPECIAL"
|
||||
log "[DEBUG_START] $CMD_STR"
|
||||
|
||||
nohup setsid sh -c "$CMD_STR" >>"$LOGFILE" 2>&1 < /dev/null &
|
||||
done < "$RUNTIME_CF_FILE"
|
||||
}
|
||||
|
||||
start_fe_by_mode() {
|
||||
if [ "$FE_BIN" = "pt61850netd_pqfed" ]; then
|
||||
start_fe_by_runtime_debug
|
||||
else
|
||||
/FeProject/boot/start_fe.sh
|
||||
fi
|
||||
}
|
||||
|
||||
get_ini_value() {
|
||||
local key="$1"
|
||||
local line
|
||||
@@ -96,7 +146,7 @@ check_remote_conn_released() {
|
||||
for i in $(seq 1 20); do
|
||||
if ! ss -ntp 2>/dev/null \
|
||||
| grep "${REMOTE_IP}:${REMOTE_PORT}" \
|
||||
| grep -E 'pt61850netd_pqfe|fe_watchdog|fe_main' >/dev/null; then
|
||||
| grep -E "${FE_BIN}|fe_watchdog|fe_main" >/dev/null; then
|
||||
log "[OK] Remote ${REMOTE_IP}:${REMOTE_PORT} released"
|
||||
return 0
|
||||
fi
|
||||
@@ -104,7 +154,7 @@ check_remote_conn_released() {
|
||||
log "[WAIT] Remote ${REMOTE_IP}:${REMOTE_PORT} still exists... ($i/20)"
|
||||
ss -ntp 2>/dev/null \
|
||||
| grep "${REMOTE_IP}:${REMOTE_PORT}" \
|
||||
| grep -E 'pt61850netd_pqfe|fe_watchdog|fe_main' \
|
||||
| grep -E "${FE_BIN}|fe_watchdog|fe_main" \
|
||||
| tee -a "$LOGFILE"
|
||||
sleep 1
|
||||
done
|
||||
@@ -116,7 +166,7 @@ check_remote_conn_released() {
|
||||
log "[FAIL] Remote ${REMOTE_IP}:${REMOTE_PORT} still exists:"
|
||||
ss -ntp 2>/dev/null \
|
||||
| grep "${REMOTE_IP}:${REMOTE_PORT}" \
|
||||
| grep -E 'pt61850netd_pqfe|fe_watchdog|fe_main' \
|
||||
| grep -E "${FE_BIN}|fe_watchdog|fe_main" \
|
||||
| tee -a "$LOGFILE"
|
||||
|
||||
return 1
|
||||
@@ -280,7 +330,7 @@ kill_process_by_name() {
|
||||
|
||||
wait_all_exit() {
|
||||
for i in $(seq 1 30); do
|
||||
COUNT=$(ps -ef | grep -E 'pt61850netd_pqfe|fe_watchdog' | grep -v grep | wc -l)
|
||||
COUNT=$(ps -ef | grep -E "${FE_BIN}|fe_watchdog" | grep -v grep | wc -l)
|
||||
if [ "$COUNT" -eq 0 ]; then
|
||||
echo "All FE processes exited"
|
||||
return 0
|
||||
@@ -304,16 +354,16 @@ handle_reset() {
|
||||
#kill_process_by_name "/FeProject/bin/fe_watchdog"
|
||||
|
||||
# 关闭旧的 stat 进程
|
||||
#kill_process_by_name "/FeProject/bin/pt61850netd_pqfe -d cfg_stat_data"
|
||||
#kill_process_by_name "/FeProject/bin/${FE_BIN} -d cfg_stat_data"
|
||||
|
||||
# 关闭旧的 recall 进程
|
||||
#kill_process_by_name "/FeProject/bin/pt61850netd_pqfe -d cfg_recallhis_data"
|
||||
#kill_process_by_name "/FeProject/bin/${FE_BIN} -d cfg_recallhis_data"
|
||||
|
||||
# 关闭旧的 3s 进程
|
||||
#kill_process_by_name "/FeProject/bin/pt61850netd_pqfe -d cfg_3s_data"
|
||||
#kill_process_by_name "/FeProject/bin/${FE_BIN} -d cfg_3s_data"
|
||||
|
||||
# 关闭旧的 comtrade 进程
|
||||
#kill_process_by_name "/FeProject/bin/pt61850netd_pqfe -d cfg_soe_comtrade"
|
||||
#kill_process_by_name "/FeProject/bin/${FE_BIN} -d cfg_soe_comtrade"
|
||||
|
||||
/FeProject/boot/stop_fe.sh
|
||||
|
||||
@@ -336,23 +386,22 @@ handle_reset() {
|
||||
#看门狗固定放在第一个,防止stop时会把要杀死的进程重启
|
||||
sed -i "2a\\$(printf '/FeProject/bin/ ^ fe_watchdog -m 18192 ^ ^ ^ 1 ^ IGNORE_RESTART ^\n')" /FeProject/etc/runtime.cf
|
||||
# 进程号为 1,按固定格式添加
|
||||
sed -i "2a\\$(printf '/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_stat_data -s 1_1^ ^ ^ 1 ^ ^\n')" /FeProject/etc/runtime.cf
|
||||
sed -i "2a\\$(printf '/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_recallhis_data -s 1_1^ ^ ^ 1 ^ ^\n')" /FeProject/etc/runtime.cf
|
||||
sed -i "2a\\$(printf '/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_3s_data^ ^ ^ 1 ^ ^\n')" /FeProject/etc/runtime.cf
|
||||
sed -i "2a\\$(printf '/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_soe_comtrade^ ^ ^ 1 ^ ^\n')" /FeProject/etc/runtime.cf
|
||||
|
||||
sed -i "2a/FeProject/bin/ ^ ${FE_BIN} -d cfg_stat_data -s 1_1^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
sed -i "2a/FeProject/bin/ ^ ${FE_BIN} -d cfg_recallhis_data -s 1_1^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
sed -i "2a/FeProject/bin/ ^ ${FE_BIN} -d cfg_3s_data^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
sed -i "2a/FeProject/bin/ ^ ${FE_BIN} -d cfg_soe_comtrade^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
else
|
||||
#看门狗固定放在第一个,防止stop时会把要杀死的进程重启
|
||||
sed -i "2a\\$(printf '/FeProject/bin/ ^ fe_watchdog -m 18192 ^ ^ ^ 1 ^ IGNORE_RESTART ^\n')" /FeProject/etc/runtime.cf
|
||||
# 进程号大于 1,按 -s ${i}_ 格式添加
|
||||
for i in $(seq 1 $1); do
|
||||
# 在 runtime.cf 中插入对应的配置行,直接插入变量替换结果
|
||||
sed -i "2a/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_stat_data -s ${i}_${1}^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
sed -i "2a/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_recallhis_data -s ${i}_${1}^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
sed -i "2a/FeProject/bin/ ^ ${FE_BIN} -d cfg_stat_data -s ${i}_${1}^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
sed -i "2a/FeProject/bin/ ^ ${FE_BIN} -d cfg_recallhis_data -s ${i}_${1}^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
done
|
||||
#以下部分没有多进程
|
||||
sed -i "2a\\$(printf '/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_3s_data^ ^ ^ 1 ^ ^\n')" /FeProject/etc/runtime.cf
|
||||
sed -i "2a\\$(printf '/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_soe_comtrade^ ^ ^ 1 ^ ^\n')" /FeProject/etc/runtime.cf
|
||||
sed -i "2a/FeProject/bin/ ^ ${FE_BIN} -d cfg_3s_data^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
sed -i "2a/FeProject/bin/ ^ ${FE_BIN} -d cfg_soe_comtrade^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
|
||||
fi
|
||||
|
||||
@@ -363,8 +412,8 @@ handle_reset() {
|
||||
sync
|
||||
|
||||
# 重新启动服务
|
||||
|
||||
/FeProject/boot/start_fe.sh
|
||||
start_fe_by_mode
|
||||
#/FeProject/boot/start_fe.sh
|
||||
|
||||
echo "****** reset all in $1******" >>"$LOGFILE"
|
||||
elif [ "$2" == "stat" ]; then
|
||||
@@ -373,19 +422,20 @@ handle_reset() {
|
||||
|
||||
# 根据进程号来添加新的进程配置
|
||||
for i in $(seq 1 $1); do
|
||||
sed -i "2a/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_stat_data -s ${i}_${1}^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
sed -i "2a/FeProject/bin/ ^ ${FE_BIN} -d cfg_stat_data -s ${i}_${1}^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
done
|
||||
|
||||
# 关闭旧的看门狗进程
|
||||
kill_process_by_name "/FeProject/bin/fe_watchdog"
|
||||
|
||||
# 关闭旧的 stat 进程
|
||||
kill_process_by_name "/FeProject/bin/pt61850netd_pqfe -d cfg_stat_data"
|
||||
kill_process_by_name "/FeProject/bin/${FE_BIN} -d cfg_stat_data"
|
||||
|
||||
#sleep 5
|
||||
|
||||
# 启动服务不影响其他功能的进程
|
||||
/FeProject/boot/start_fe.sh
|
||||
start_fe_by_mode
|
||||
#/FeProject/boot/start_fe.sh
|
||||
|
||||
echo "****** reset stat in $1******" >>"$LOGFILE"
|
||||
elif [ "$2" == "recall" ]; then
|
||||
@@ -394,18 +444,19 @@ handle_reset() {
|
||||
|
||||
# 根据进程号来添加新的进程配置
|
||||
for i in $(seq 1 $1); do
|
||||
sed -i "2a/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_recallhis_data -s ${i}_${1}^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
sed -i "2a/FeProject/bin/ ^ ${FE_BIN} -d cfg_recallhis_data -s ${i}_${1}^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
done
|
||||
|
||||
# 关闭旧的看门狗进程
|
||||
kill_process_by_name "/FeProject/bin/fe_watchdog"
|
||||
# 关闭旧的 recall 进程
|
||||
kill_process_by_name "/FeProject/bin/pt61850netd_pqfe -d cfg_recallhis_data"
|
||||
kill_process_by_name "/FeProject/bin/${FE_BIN} -d cfg_recallhis_data"
|
||||
|
||||
#sleep 5
|
||||
|
||||
# 启动服务不影响其他功能的进程
|
||||
/FeProject/boot/start_fe.sh
|
||||
start_fe_by_mode
|
||||
#/FeProject/boot/start_fe.sh
|
||||
|
||||
echo "****** reset recall in $1******" >>"$LOGFILE"
|
||||
else
|
||||
@@ -429,22 +480,22 @@ handle_add() {
|
||||
# 如果 $1 在 1 和 10 之间,进入处理逻辑
|
||||
if [ "$2" == "all" ]; then
|
||||
# 检查是否已存在该条目,避免重复添加
|
||||
if ! grep -q "/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_stat_data -s ${1}_${1}^" /FeProject/etc/runtime.cf; then
|
||||
sed -i "2a/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_stat_data -s ${1}_${1}^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
if ! grep -q "/FeProject/bin/ ^ ${FE_BIN} -d cfg_stat_data -s ${1}_${1}^" /FeProject/etc/runtime.cf; then
|
||||
sed -i "2a/FeProject/bin/ ^ ${FE_BIN} -d cfg_stat_data -s ${1}_${1}^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
fi
|
||||
|
||||
if ! grep -q "/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_recallhis_data -s ${1}_${1}^" /FeProject/etc/runtime.cf; then
|
||||
sed -i "2a/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_recallhis_data -s ${1}_${1}^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
if ! grep -q "/FeProject/bin/ ^ ${FE_BIN} -d cfg_recallhis_data -s ${1}_${1}^" /FeProject/etc/runtime.cf; then
|
||||
sed -i "2a/FeProject/bin/ ^ ${FE_BIN} -d cfg_recallhis_data -s ${1}_${1}^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
fi
|
||||
elif [ "$2" == "stat" ]; then
|
||||
# 检查是否已存在该条目,避免重复添加
|
||||
if ! grep -q "/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_stat_data -s ${1}_${1}^" /FeProject/etc/runtime.cf; then
|
||||
sed -i "2a/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_stat_data -s ${1}_${1}^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
if ! grep -q "/FeProject/bin/ ^ ${FE_BIN} -d cfg_stat_data -s ${1}_${1}^" /FeProject/etc/runtime.cf; then
|
||||
sed -i "2a/FeProject/bin/ ^ ${FE_BIN} -d cfg_stat_data -s ${1}_${1}^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
fi
|
||||
elif [ "$2" == "recall" ]; then
|
||||
# 检查是否已存在该条目,避免重复添加
|
||||
if ! grep -q "/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_recallhis_data -s ${1}_${1}^" /FeProject/etc/runtime.cf; then
|
||||
sed -i "2a/FeProject/bin/ ^ pt61850netd_pqfe -d cfg_recallhis_data -s ${1}_${1}^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
if ! grep -q "/FeProject/bin/ ^ ${FE_BIN} -d cfg_recallhis_data -s ${1}_${1}^" /FeProject/etc/runtime.cf; then
|
||||
sed -i "2a/FeProject/bin/ ^ ${FE_BIN} -d cfg_recallhis_data -s ${1}_${1}^ ^ ^ 1 ^ ^" /FeProject/etc/runtime.cf
|
||||
fi
|
||||
else
|
||||
echo "****** process add type null ******"
|
||||
|
||||
Reference in New Issue
Block a user