41 Commits

Author SHA1 Message Date
lnk
2a8f2c996c fix mq 2025-04-10 16:07:39 +08:00
lnk
633682ae0c fix qvvr new funtion 2025-04-02 15:16:11 +08:00
lnk
2ab30dfbc6 add funtion in qvvr offline 2025-04-02 11:48:18 +08:00
lnk
07015b523e use list in test device 2025-03-28 13:43:55 +08:00
lnk
e8b5f08c6b fix cpu 100% and consumer now dont recive history message 2025-03-26 10:51:18 +08:00
lnk
fa629ee071 fix delta wiring 2025-03-18 11:25:20 +08:00
lnk
97e4da3df7 fix ledger update 2025-03-13 16:35:19 +08:00
lnk
f2bec8c94e fix connect info and soe 2025-03-12 14:33:55 +08:00
lnk
4e860b9ffb fix connect info 2025-03-12 11:45:53 +08:00
lnk
d1242aae7a fix soe and add connect info 2025-03-11 21:07:17 +08:00
lnk
f2556662ed fix soe 2025-03-11 11:29:24 +08:00
lnk
3347361203 fix soe 2025-03-10 21:26:17 +08:00
lnk
2e50baee04 debug recall 2025-03-07 18:27:03 +08:00
lnk
8a5087f1b7 fix recallhis in pingtest 2025-03-06 18:41:48 +08:00
lnk
5c61b6cd2d fix bug in pst 2025-03-06 15:24:49 +08:00
lnk
135f48f373 fix bug in test shell and bug in front -a mode 2025-03-06 10:32:40 +08:00
lnk
28811fbae7 finish develop 2025-03-05 17:47:47 +08:00
lnk
1df5385fc9 fix bug in log upload 2025-03-04 17:29:04 +08:00
lnk
87f0a48ad7 fix test shell with debug 2025-03-03 18:20:00 +08:00
lnk
a1a184a043 add echo to testshell and modify mqsend 2025-02-28 16:28:15 +08:00
lnk
c843247d68 finish log realdata send funtion 2025-02-27 16:28:04 +08:00
lnk
f167d705a9 fix log realdata send funtion 2025-02-26 16:39:10 +08:00
lnk
c597ee5b9b add log realdata send funtion 2025-02-25 16:33:11 +08:00
lnk
d1fa47e3f1 finish ledger update code 2025-02-24 16:45:42 +08:00
lnk
7009b1c7d6 add ppv in statistic data 2025-02-21 16:24:41 +08:00
lnk
183685b017 fix rt data 2025-02-18 17:10:22 +08:00
lnk
a110614220 fix rt data and mult front 2025-02-17 16:58:14 +08:00
lnk
322f41a03b add delta process 2025-02-14 16:44:38 +08:00
lnk
399c3151a8 ledgerupdate testing fix segfault in add ledger 2025-02-13 11:51:05 +08:00
lnk
792e129971 ledgerupdate testing 2025-02-12 16:08:36 +08:00
lnk
898d5e043d ledgerupdate testing 2025-02-11 18:23:19 +08:00
lnk
faaef4f166 modify for ledgerupdate 2025-02-10 17:03:15 +08:00
lnk
3a37ce9c5b modify for ledgerupdate 2025-02-08 17:04:39 +08:00
lnk
7549ec48bb modify for ledgerupdate 2025-02-07 16:46:53 +08:00
lnk
5795542cb9 modify for ledgerupdate 2025-01-23 16:32:26 +08:00
lnk
acd2b65852 modify for ledgerupdate 2025-01-22 17:00:34 +08:00
lnk
5f5a3be6c9 modify for ledgerupdate 2025-01-21 17:48:37 +08:00
lnk
760dffe884 modify for ledgerupdate 2025-01-17 17:10:18 +08:00
lnk
040b1bd5f6 modify for ledgerupdate 2025-01-16 19:16:26 +08:00
lnk
c078194a8d Merge branch 'develop' of http://192.168.1.22:3000/FrontFacing-backend/cn_front-nexus into develop
first commit
2025-01-16 16:32:08 +08:00
2d4aa9a017 Initial commit 2025-01-16 15:27:29 +08:00
28 changed files with 5516 additions and 1088 deletions

34
.gitignore vendored Normal file
View File

@@ -0,0 +1,34 @@
# ---> C++
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app

View File

@@ -136,6 +136,8 @@
"simpleproducer.h": "c",
"stdbool.h": "c",
"node.h": "c",
"save2json.h": "c"
"save2json.h": "c",
"custom_printf.h": "c",
"suicacse.h": "c"
}
}

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# cn_front-nexus
衔接终端设备与系统的枢纽

View File

@@ -8,6 +8,7 @@
#include <iostream>
#include <string>
#include "../mms/db_interface.h"
#include "../include/rocketmq/CProducer.h"
#include "../include/rocketmq/CMessage.h"
#include "../include/rocketmq/CSendResult.h"
@@ -27,6 +28,10 @@
//lnk20241209添加队列选择
#include <cstring>
//引入消费起点
#include "../include/rocketmq/DefaultMQPushConsumer.h"
#include "../include/rocketmq/ConsumeType.h"
// 引入提供的消费者接口头文件
#include "../include/rocketmq/CPushConsumer.h"
#include "../include/rocketmq/CCommon.h"
@@ -130,13 +135,13 @@ RocketMQConsumer::RocketMQConsumer(const std::string& consumerName, const std::s
std::cout << "error setting groupId"<< std::endl;
throw std::runtime_error("Failed to set Consumer Group ID.");
}
/*
// 设置消费模式为广播模式
if (SetPushConsumerMessageModel(consumer_, BROADCASTING) != 0) {
DestroyPushConsumer(consumer_);
std::cout << "error setting messagemodel"<< std::endl;
}
*/
//调试用
std::string consumerlog = "./mqconsumer/" + consumerName +".log";
if ( (SetPushConsumerLogPath(consumer_,consumerlog.c_str()) || SetPushConsumerLogFileNumAndSize(consumer_,10,100) || SetPushConsumerLogLevel(consumer_,E_LOG_LEVEL_DEBUG) ) != 0) {//记录消费日志
@@ -396,6 +401,8 @@ public:
// 设置 nameserver 地址
SetProducerNameServerAddress(producer_, nameServer.c_str());
SetProducerSessionCredentials(producer_, G_MQCONSUMER_ACCESSKEY.c_str(),G_MQCONSUMER_SECRETKEY.c_str(), "");
// 启动生产者
StartProducer(producer_);
@@ -406,6 +413,32 @@ public:
RocketMQProducer(const RocketMQProducer&) = delete;
RocketMQProducer& operator=(const RocketMQProducer&) = delete;
void printSendResult(const CSendResult& result) {
std::cout << "SendResult:" << std::endl;
std::cout << " Status: ";
switch (result.sendStatus) {
case E_SEND_OK:
std::cout << "E_SEND_OK";
break;
case E_SEND_FLUSH_DISK_TIMEOUT:
std::cout << "E_SEND_FLUSH_DISK_TIMEOUT";
break;
case E_SEND_FLUSH_SLAVE_TIMEOUT:
std::cout << "E_SEND_FLUSH_SLAVE_TIMEOUT";
break;
case E_SEND_SLAVE_NOT_AVAILABLE:
std::cout << "E_SEND_SLAVE_NOT_AVAILABLE";
break;
default:
std::cout << "UNKNOWN(" << result.sendStatus << ")";
break;
}
std::cout << std::endl;
std::cout << " MsgID : " << result.msgId << std::endl;
std::cout << " Offset: " << result.offset << std::endl;
}
// 发送消息
void sendMessage(const char* strbody, const char* topic, const std::string& tags, const std::string& keys) {
CSendResult result;
@@ -433,8 +466,21 @@ public:
&queueNum // 传递给选择器的额外参数(队列数量)
);
//调试用
/*int sendResult = SendMessageSync(
producer_,
msg,
&result
);
int ret = SendMessageSync(producer_, msg, &result);
if (ret == 0) {
printSendResult(result);
} else {
std::cerr << "SendMessageSync failed with ret=" << ret << std::endl;
}*/
if (sendResult == 0) { // 假设返回 0 表示成功
std::cout << "Message sent successfully." << std::endl;
std::cout << "Message sent successfully.topic:" << topic <<std::endl;
} else {
std::cout << "Failed to send message." << std::endl;
}
@@ -723,6 +769,8 @@ void rocketmq_producer_send(const char* strbody,const char* topic)
}
#endif
extern "C" {
extern std::string G_MQCONSUMER_TOPIC_RT;
void rocketmq_test_rt()
@@ -766,6 +814,21 @@ void rocketmq_test_set()//用来测试进程控制脚本
data.mp_id = 123123;
my_rocketmq_send(data);
}
void rocketmq_test_only()//用来测试进程控制脚本
{
Ckafka_data_t data;
data.monitor_id = 123123;
data.strTopic = QString::fromStdString(G_MQCONSUMER_TOPIC_SET);
std::ifstream file("set_debug.txt"); // 文件中存储长字符串
std::stringstream buffer;
buffer << file.rdbuf(); // 读取整个文件内容
data.strText = QString::fromStdString(buffer.str());
data.mp_id = 123123;
my_rocketmq_send(data);
}
extern std::string G_MQCONSUMER_TOPIC_RC;
void rocketmq_test_rc()
{
@@ -780,14 +843,27 @@ void rocketmq_test_rc()
data.mp_id = 123123;
my_rocketmq_send(data);
}
extern std::string G_MQCONSUMER_TOPIC_LOG;
void rocketmq_test_log()
{
Ckafka_data_t data;
data.monitor_id = 123123;
data.strTopic = QString::fromStdString(G_MQCONSUMER_TOPIC_LOG);
std::ifstream file("log_test.txt"); // 文件中存储长字符串
std::stringstream buffer;
buffer << file.rdbuf(); // 读取整个文件内容
data.strText = QString::fromStdString(buffer.str());
data.mp_id = 123123;
my_rocketmq_send(data);
}
std::string to_string(long long value) {
std::stringstream ss;
ss << value;
return ss.str();
}
#if 0
void rocketmq_test_300(int mpnum,int front_index) {
Ckafka_data_t data;
data.strTopic = QString::fromStdString(G_ROCKETMQ_TOPIC);
@@ -822,7 +898,7 @@ void rocketmq_test_300(int mpnum,int front_index) {
data.mp_id = QString::number(data.monitor_id);
std::string modified_time = to_string(current_time_ms); // 时间转换为整数类型Unix时间戳
std::string modified_time = my_to_string(current_time_ms); // 时间转换为整数类型Unix时间戳
// 替换消息中的 Monitor 和 TIME 字段(只匹配字段名,不匹配具体数值)
std::string modified_strText = base_strText;
@@ -834,7 +910,7 @@ void rocketmq_test_300(int mpnum,int front_index) {
size_t quote_pos = modified_strText.find("\"", colon_pos);
size_t end_quote_pos = modified_strText.find("\"", quote_pos + 1);
if (colon_pos != std::string::npos && quote_pos != std::string::npos && end_quote_pos != std::string::npos) {
modified_strText.replace(quote_pos + 1, end_quote_pos - quote_pos - 1, to_string(data.monitor_id));
modified_strText.replace(quote_pos + 1, end_quote_pos - quote_pos - 1, my_to_string(data.monitor_id));
}
}
@@ -864,3 +940,6 @@ void rocketmq_test_300(int mpnum,int front_index) {
std::cout << "Finished sending " << total_messages << " messages." << std::endl;
}
#endif

File diff suppressed because it is too large Load Diff

308
cfg_parse/custom_printf.h Normal file
View File

@@ -0,0 +1,308 @@
// custom_printf.h
#ifndef CUSTOM_PRINTF_H
#define CUSTOM_PRINTF_H
#include <stdio.h>
#include <stdarg.h>
#include <QtGlobal> // ✅ 确保 QtMsgType 被正确包含
#ifdef __cplusplus
#include <list>
#include <string>
// 假设这些是你管理输出的列表
extern std::list<std::string> errorList;
extern std::list<std::string> warnList;
extern std::list<std::string> normalList;
extern std::list<std::string> debugList;
// 开关
extern bool errorOutputEnabled;
extern bool warnOutputEnabled;
extern bool normalOutputEnabled;
extern bool debugOutputEnabled;
void redirectErrorOutput(bool enabled);
void redirectWarnOutput(bool enabled);
void redirectNormalOutput(bool enabled);
// ------------------ 重定向函数 ------------------
void redirectDebugOutput(bool enable);
// ------------------ Qt 的消息处理函数 (Qt4) ------------------
// Qt4 使用 qInstallMsgHandler(...),签名: void myMsgHandler(QtMsgType, const char*)
void myQtMsgHandler(QtMsgType type, const char* msg);
extern pthread_mutex_t errorListMutex;
extern pthread_mutex_t warnListMutex;
extern pthread_mutex_t normalListMutex;
extern pthread_mutex_t debugListMutex;
extern "C"
{
#endif
void echo_msg_debugexy(const char *file_name, int line_no, const char *fmt, ...);
void echo_msg_warnexy(const char *file_name, int line_no, const char *fmt, ...);
void echo_msg_errexy(const char *file_name, int line_no, int rv, const char *fmt, ...);
#define echo_msg_debugexy(file_name, line_no, ...) \
echo_msg_debugexy(file_name, line_no, __VA_ARGS__)
#define echo_msg_warnexy(file_name, line_no, ...) \
echo_msg_warnexy(file_name, line_no, __VA_ARGS__)
#define echo_msg_errexy(file_name, line_no, rv, ...) \
echo_msg_errexy(file_name, line_no, rv, __VA_ARGS__)
// ======================= echo_warnX =======================
#ifdef echo_warn
#undef echo_warn
#endif
#define echo_warn(s) \
echo_msg_warnexy(__FILE__, __LINE__, ("%s"), s)
#ifdef echo_warn1
#undef echo_warn1
#endif
#define echo_warn1(fmt, s0) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0))
#ifdef echo_warn2
#undef echo_warn2
#endif
#define echo_warn2(fmt, s0, s1) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1))
#ifdef echo_warn3
#undef echo_warn3
#endif
#define echo_warn3(fmt, s0, s1, s2) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2))
#ifdef echo_warn4
#undef echo_warn4
#endif
#define echo_warn4(fmt, s0, s1, s2, s3) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3))
#ifdef echo_warn5
#undef echo_warn5
#endif
#define echo_warn5(fmt, s0, s1, s2, s3, s4) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3), (s4))
#ifdef echo_warn6
#undef echo_warn6
#endif
#define echo_warn6(fmt, s0, s1, s2, s3, s4, s5) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3), (s4), (s5))
#ifdef echo_warn7
#undef echo_warn7
#endif
#define echo_warn7(fmt, s0, s1, s2, s3, s4, s5, s6) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3), (s4), (s5), (s6))
#ifdef echo_warn8
#undef echo_warn8
#endif
#define echo_warn8(fmt, s0, s1, s2, s3, s4, s5, s6, s7) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3), (s4), (s5), (s6), (s7))
#ifdef echo_warn9
#undef echo_warn9
#endif
#define echo_warn9(fmt, s0, s1, s2, s3, s4, s5, s6, s7, s8) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8))
#ifdef echo_warn10
#undef echo_warn10
#endif
#define echo_warn10(fmt, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9))
#ifdef echo_warn11
#undef echo_warn11
#endif
#define echo_warn11(fmt, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9), (s10))
#ifdef echo_warn12
#undef echo_warn12
#endif
#define echo_warn12(fmt, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11) \
echo_msg_warnexy(__FILE__, __LINE__, (fmt), (s0), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9), (s10), (s11))
// ======================= echo_errX =======================
#ifdef echo_err
#undef echo_err
#endif
#define echo_err(s, rv) \
echo_msg_errexy(__FILE__, __LINE__, (rv), ("%s"), (s))
#ifdef echo_errg
#undef echo_errg
#endif
#define echo_errg(s) \
echo_msg_errexy(__FILE__, __LINE__, (APR_EGENERAL), ("%s"), (s))
#ifdef echo_err1
#undef echo_err1
#endif
#define echo_err1(fmt, rv, s1) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1))
#ifdef echo_err2
#undef echo_err2
#endif
#define echo_err2(fmt, rv, s1, s2) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2))
#ifdef echo_err3
#undef echo_err3
#endif
#define echo_err3(fmt, rv, s1, s2, s3) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3))
#ifdef echo_err4
#undef echo_err4
#endif
#define echo_err4(fmt, rv, s1, s2, s3, s4) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4))
#ifdef echo_err5
#undef echo_err5
#endif
#define echo_err5(fmt, rv, s1, s2, s3, s4, s5) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4), (s5))
#ifdef echo_err6
#undef echo_err6
#endif
#define echo_err6(fmt, rv, s1, s2, s3, s4, s5, s6) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4), (s5), (s6))
#ifdef echo_err7
#undef echo_err7
#endif
#define echo_err7(fmt, rv, s1, s2, s3, s4, s5, s6, s7) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7))
#ifdef echo_err8
#undef echo_err8
#endif
#define echo_err8(fmt, rv, s1, s2, s3, s4, s5, s6, s7, s8) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8))
#ifdef echo_err9
#undef echo_err9
#endif
#define echo_err9(fmt, rv, s1, s2, s3, s4, s5, s6, s7, s8, s9) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9))
#ifdef echo_err10
#undef echo_err10
#endif
#define echo_err10(fmt, rv, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9), (s10))
#ifdef echo_err11
#undef echo_err11
#endif
#define echo_err11(fmt, rv, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9), (s10), (s11))
#ifdef echo_err12
#undef echo_err12
#endif
#define echo_err12(fmt, rv, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12) \
echo_msg_errexy(__FILE__, __LINE__, (rv), (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9), (s10), (s11), (s12))
// ======================= echo_msgX =======================
#ifdef echo_msg
#undef echo_msg
#endif
#define echo_msg(s) \
echo_msg_debugexy(__FILE__, __LINE__, ("%s"), (s))
#ifdef echo_msg1
#undef echo_msg1
#endif
#define echo_msg1(fmt, s1) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1))
#ifdef echo_msg2
#undef echo_msg2
#endif
#define echo_msg2(fmt, s1, s2) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2))
#ifdef echo_msg3
#undef echo_msg3
#endif
#define echo_msg3(fmt, s1, s2, s3) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3))
#ifdef echo_msg4
#undef echo_msg4
#endif
#define echo_msg4(fmt, s1, s2, s3, s4) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4))
#ifdef echo_msg5
#undef echo_msg5
#endif
#define echo_msg5(fmt, s1, s2, s3, s4, s5) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4), (s5))
#ifdef echo_msg6
#undef echo_msg6
#endif
#define echo_msg6(fmt, s1, s2, s3, s4, s5, s6) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4), (s5), (s6))
#ifdef echo_msg7
#undef echo_msg7
#endif
#define echo_msg7(fmt, s1, s2, s3, s4, s5, s6, s7) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7))
#ifdef echo_msg8
#undef echo_msg8
#endif
#define echo_msg8(fmt, s1, s2, s3, s4, s5, s6, s7, s8) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8))
#ifdef echo_msg9
#undef echo_msg9
#endif
#define echo_msg9(fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9))
#ifdef echo_msg10
#undef echo_msg10
#endif
#define echo_msg10(fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9), (s10))
#ifdef echo_msg11
#undef echo_msg11
#endif
#define echo_msg11(fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9), (s10), (s11))
#ifdef echo_msg12
#undef echo_msg12
#endif
#define echo_msg12(fmt, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12) \
echo_msg_debugexy(__FILE__, __LINE__, (fmt), (s1), (s2), (s3), (s4), (s5), (s6), (s7), (s8), (s9), (s10), (s11), (s12))
// 自定义的 printf 函数
int customPrintf(const char* format, ...);
#ifdef __cplusplus
}
#endif
// 使用宏将 printf 替换为 customPrintf
#define printf customPrintf
#endif // CUSTOM_PRINTF_H

View File

@@ -20,7 +20,9 @@ extern "C" {
void rocketmq_test_rt();
void rocketmq_test_ud();
void rocketmq_test_rc();
void rocketmq_test_log();
void rocketmq_test_set();
void rocketmq_test_only();
void rocketmq_test_300(int mpnum,int front_index);
}
//void rocketmq_test_300(int mpnum,int front_index);//20241202lnk

File diff suppressed because it is too large Load Diff

View File

@@ -110,8 +110,8 @@ public:
kafka_data_list.append(data);
kafka_data_list_mutex.unlock();
*/
int transfer_json_block_data(json_block_data *data);
int transfer_json_block_data(char v_wiring_type[], json_block_data* data);//lnk2024-8-16<31><36><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>
//int transfer_json_block_data(json_block_data *data);
void errorlog_pgsql(char* id, QString time, QString filename);
QString errorlog_num_pgsql(QString monitorId, QString datatime, QString filename, int count);
QString errorlog_datamatch_pgsql(QString id, QString time, int BASE_MAT_NUM, int ADV_MAT_NUM, int BASE_ACT_NUM, int ADV_ACT_NUM, QString filename);
@@ -123,7 +123,7 @@ QString errorlog_datamatch_pgsql(QString id, QString time, int BASE_MAT_NUM, int
extern "C" {
#endif /* __cplusplus */
int transfer_json_qvvr_data(unsigned int func_type,int monitor_id,float mag,float dur,long long start_tm,long long end_tm,int dis_kind, char* uuid_cfg, char* uuid_dat, char* mp_id, char* Qvvr_rptname, char* devtype);
int transfer_json_qvvr_data(unsigned int func_type,int monitor_id,double mag,double dur,long long start_tm,long long end_tm,int dis_kind, char* uuid_cfg, char* uuid_dat, char* mp_id, char* Qvvr_rptname, char* devtype);
void processGGIO_start_data_end(char* mp_id, char* fullname, double v,long long time,char* devtype,int monitor_id);
//void errorlog_num(CDataValue* pDataValue, double value, int monitorId, double UL, int maxcount);
//void errorlog_num_json(int monitorId);

View File

@@ -46,6 +46,7 @@ extern std::string intToString(int number);
int StringToInt(const std::string& str);
extern pthread_mutex_t mtx;//lnk20250115
#ifdef __cplusplus
extern "C" {
#include "../mms/rdb_client.h"
@@ -59,6 +60,7 @@ extern "C" {
extern int comtrade_remain_file_num;
extern node_t* g_node; //lnk20241223
extern LD_info_t* find_LD_info_only_from_mp_id(char* mp_id);//lnk20241223
extern void print_terminal(const terminal* tmnl);
#ifdef __cplusplus
}
#endif
@@ -66,6 +68,8 @@ extern "C" {
#define nullptr NULL
#endif
extern int INITFLAG;
extern QMutex kafka_data_list_mutex;
extern QList<Ckafka_data_t> kafka_data_list;
@@ -117,6 +121,16 @@ extern std::string G_MQCONSUMER_TOPIC_SET;//topie_recall
extern std::string G_MQCONSUMER_TAG_SET;//tag
extern std::string G_MQCONSUMER_KEY_SET;//key
extern std::string G_MQCONSUMER_TOPIC_LOG;//topie_log
extern std::string G_MQCONSUMER_TAG_LOG;//tag
extern std::string G_MQCONSUMER_KEY_LOG;//key
extern std::string G_LOG_TOPIC;//topie
extern std::string G_LOG_TAG;//tag
extern std::string G_LOG_KEY;//key
bool showinshellflag =false;
#define APRTIME_8H (28800000000ULL)
#define APRTIME_1H (3600000000ULL)
///////////////////////////////////////////////////////////////////////////////
@@ -125,11 +139,8 @@ const int MAX_LIST_SIZE = 16;
static QMap<int, QList<long long> > real_data_report_map;
static QMap<QString, json_block_data*> json_data_map;//CZY 2023-08-17 ww 2023<32><33>3<EFBFBD><33>13<31><33>17:23:17<31><37>չMap<61><70><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
static QMap<QString, json_block_data*> json_flicker_data_map;//CZY 2023-09-11 չMap<61><70><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
static QMap<QString, json_block_data*> json_pst_data_map;//CZY 2023-09-11 չMap<61><70><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int urcbRealDataHasReceived(int dev_index, LD_info_t* LD_info, long long Time)
{
QList<long long>& ts_list = real_data_report_map[LD_info->line_id];
@@ -293,8 +304,8 @@ void my_rocketmq_send(Ckafka_data_t& data)
static std::string cfg_Evt_tp;
static std::string cfg_Alm_tp;
static std::string cfg_Rt_tp;
static bool inited = false;
if (!inited) {
static bool init = false;
if (!init) {
cfg_His_tp = TOPIC_STAT;
cfg_PLT_tp = TOPIC_PLT;
@@ -303,7 +314,7 @@ void my_rocketmq_send(Ckafka_data_t& data)
cfg_Alm_tp = TOPIC_ALARM;
cfg_Rt_tp = TOPIC_RTDATA;
inited = true;
init = true;
}
std::string key = data.mp_id.toStdString();
@@ -335,6 +346,7 @@ void my_rocketmq_send(Ckafka_data_t& data)
else
{
topic = data.strTopic.toStdString();
}
if (g_onlyIP[0] != 0)
{
@@ -361,8 +373,8 @@ void my_kafka_send(Ckafka_data_t& data)
static std::string cfg_Evt_tp;
static std::string cfg_Alm_tp;
static std::string cfg_Sng_tp;
static bool inited = false;
if (!inited) {
static bool init = false;
if (!init) {
cfg_His_tp = TOPIC_STAT;
cfg_PLT_tp = TOPIC_PLT;
@@ -391,7 +403,7 @@ void my_kafka_send(Ckafka_data_t& data)
else
printf("kafka producer init Failed(%s)\n", brokerlist.c_str());
#endif
inited = true;
init = true;
}
char tmp_str[256];
@@ -470,8 +482,8 @@ void my_datahub_send(Ckafka_data_t& data)
static std::string cfg_PST_tp;
static std::string cfg_Evt_tp;
static std::string cfg_Alm_tp;
static bool inited = false;
if (!inited) {
static bool init = false;
if (!init) {
//QString MyKafkaIniFilename = QString("../etc/") + QString("mykafka.ini"); //+QString::fromAscii(subdir)
//QSettings settings(MyKafkaIniFilename, QSettings::IniFormat);
@@ -494,7 +506,7 @@ void my_datahub_send(Ckafka_data_t& data)
cfg_Evt_tp = TOPIC_EVENT;
cfg_Alm_tp = TOPIC_ALARM;
inited = true;
init = true;
}
std::string key = data.mp_id.toStdString();
@@ -582,6 +594,93 @@ void KafkaSendThread::run()
printf("END my_kafka_send no.%i -------->>>>>>>>>>>> %s \n\n", count++,
QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toAscii().data());
}
//lnk20250225<32><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
Ckafka_data_t log_send;
log_send.strTopic = QString::fromStdString(G_LOG_TOPIC);
bool log_gotten;
log_gotten = false;
if(!showinshellflag){
if (debugOutputEnabled) {
// <20><><EFBFBD><EFBFBD> normalOutputEnabled <20><> warnOutputEnabled <20><>Ϊ 0<><30><EFBFBD><EFBFBD> errorOutputEnabled Ϊ 1<><31>ȡ errorList <20><><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD> errorList <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pthread_mutex_lock(&debugListMutex);
if (!debugList.empty()) {
log_gotten = true;
log_send.strText = QString::fromStdString(debugList.front());//<2F><>ȷ<EFBFBD><C8B7>list<73><74>ȷ
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD>հ<EFBFBD><D5B0>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>
if (log_send.strText.trimmed().isEmpty()) {
debugList.pop_front(); // ֱ<>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
log_gotten = false; // <20><><EFBFBD><EFBFBD>û<EFBFBD>л<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>־
} else {
debugList.pop_front(); // ֻ<>зǿհ<C7BF><D5B0>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
}
pthread_mutex_unlock(&debugListMutex);
}
else if (normalOutputEnabled) {
// <20><><EFBFBD><EFBFBD> normalOutputEnabled Ϊ 1<><31><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD> normalList <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD> normalList <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pthread_mutex_lock(&normalListMutex);
if (!normalList.empty()) {
//qDebug() << "flag of list:" << normalOutputEnabled << " " << warnOutputEnabled << " " << errorOutputEnabled << " " << "warnList size: " << warnList.size() << "normalList size: " << normalList.size() << "errorList size: " << errorList.size()<<endl;
log_gotten = true;
log_send.strText = QString::fromStdString(normalList.front());
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD>հ<EFBFBD><D5B0>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>
if (log_send.strText.trimmed().isEmpty()) {
normalList.pop_front(); // ֱ<>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
log_gotten = false; // <20><><EFBFBD><EFBFBD>û<EFBFBD>л<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>־
} else {
normalList.pop_front(); // ֻ<>зǿհ<C7BF><D5B0>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
}
pthread_mutex_unlock(&normalListMutex);
} else if (warnOutputEnabled) {
// <20><><EFBFBD><EFBFBD> normalOutputEnabled Ϊ 0<><30><EFBFBD><EFBFBD> warnOutputEnabled Ϊ 1<><31><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD> warnList <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD> warnList <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pthread_mutex_lock(&warnListMutex);
if (!warnList.empty()) {
log_gotten = true;
log_send.strText = QString::fromStdString(warnList.front());
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD>հ<EFBFBD><D5B0>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>
if (log_send.strText.trimmed().isEmpty()) {
warnList.pop_front(); // ֱ<>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
log_gotten = false; // <20><><EFBFBD><EFBFBD>û<EFBFBD>л<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>־
} else {
warnList.pop_front(); // ֻ<>зǿհ<C7BF><D5B0>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
}
pthread_mutex_unlock(&warnListMutex);
} else if (errorOutputEnabled) {
// <20><><EFBFBD><EFBFBD> normalOutputEnabled <20><> warnOutputEnabled <20><>Ϊ 0<><30><EFBFBD><EFBFBD> errorOutputEnabled Ϊ 1<><31>ȡ errorList <20><><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD> errorList <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pthread_mutex_lock(&errorListMutex);
if (!errorList.empty()) {
log_gotten = true;
log_send.strText = QString::fromStdString(errorList.front());
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD>հ<EFBFBD><D5B0>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>
if (log_send.strText.trimmed().isEmpty()) {
errorList.pop_front(); // ֱ<>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
log_gotten = false; // <20><><EFBFBD><EFBFBD>û<EFBFBD>л<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>־
} else {
errorList.pop_front(); // ֻ<>зǿհ<C7BF><D5B0>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
}
pthread_mutex_unlock(&errorListMutex);
}
}
if (log_gotten) {
//qDebug() << "send log to topic:" << log_send.strTopic << endl;
static uint32_t count = 0;
//printf("BEGIN current log send no.%i -------->>>>>>>>>>>> %s \n", count,QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toAscii().data());
my_rocketmq_send(log_send);
}
QThread::msleep(1); // <20><><EFBFBD><EFBFBD> CPU <20><>תlnk20250326
/*if (data_gotten) {
LD_info_t* LD_info = find_LD_info_only_from_mp_id(data.mp_id.toAscii().data());
@@ -704,7 +803,7 @@ void KafkaSendThread::run()
}*/
} //while(1) {
//<2F>߳̽<DFB3><CCBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ShutdownAndDestroyProducer();//lnk20241211
}
@@ -719,8 +818,31 @@ std::string extractDataJson(const char* inputJson) {
return "";
}
// <20><>ȡ "messageBody" <20><><EFBFBD><EFBFBD>
cJSON* messageJson = cJSON_GetObjectItem(root, "messageBody");
if (messageJson == NULL || messageJson->type != cJSON_String) {
std::cerr << "'messageJson' is missing or is not an cJSON_String" << std::endl;
cJSON_Delete(root);
return "";
}
// <20><><EFBFBD><EFBFBD> messageBody <20>е<EFBFBD> JSON <20>ַ<EFBFBD><D6B7><EFBFBD>
const char* messageBodyStr = messageJson->valuestring;
if (messageBodyStr == nullptr || strlen(messageBodyStr) == 0) {
std::cerr << "Failed to parse 'messageBody' JSON or it's empty." << std::endl;
cJSON_Delete(root);
return "";
}
cJSON* messageBody = cJSON_Parse(messageBodyStr); // <20><><EFBFBD><EFBFBD> messageBody <20>ַ<EFBFBD><D6B7><EFBFBD>
if (messageBody == NULL) {
std::cerr << "Failed to parse 'messageBody' JSON." << std::endl;
cJSON_Delete(root);
return "";
}
// <20><>ȡ "data" <20><><EFBFBD><EFBFBD>
cJSON* data = cJSON_GetObjectItem(root, "data");
cJSON* data = cJSON_GetObjectItem(messageBody, "data");
if (data == NULL || data->type != cJSON_Array) {
std::cerr << "'data' is missing or is not an array" << std::endl;
cJSON_Delete(root);
@@ -766,12 +888,35 @@ bool parseJsonMessageRT(const std::string& body, std::string& devSeries, std::st
return false;
}
// <20><>ȡ "messageBody" <20><><EFBFBD><EFBFBD>
cJSON* messageJson = cJSON_GetObjectItem(root, "messageBody");
if (messageJson == NULL || messageJson->type != cJSON_String) {
std::cerr << "'messageJson' is missing or is not an cJSON_String" << std::endl;
cJSON_Delete(root);
return false;
}
// <20><><EFBFBD><EFBFBD> messageBody <20>е<EFBFBD> JSON <20>ַ<EFBFBD><D6B7><EFBFBD>
const char* messageBodyStr = messageJson->valuestring;
if (messageBodyStr == nullptr || strlen(messageBodyStr) == 0) {
std::cerr << "Failed to parse 'messageBody' JSON or it's empty." << std::endl;
cJSON_Delete(root);
return false;
}
cJSON* messageBody = cJSON_Parse(messageBodyStr); // <20><><EFBFBD><EFBFBD> messageBody <20>ַ<EFBFBD><D6B7><EFBFBD>
if (messageBody == NULL) {
std::cerr << "Failed to parse 'messageBody' JSON." << std::endl;
cJSON_Delete(root);
return false;
}
// <20><>ȡ<EFBFBD>ֶ<EFBFBD>
cJSON* devSeriesItem = cJSON_GetObjectItem(root, "devSeries");
cJSON* lineItem = cJSON_GetObjectItem(root, "line");
cJSON* realDataItem = cJSON_GetObjectItem(root, "realData");
cJSON* soeDataItem = cJSON_GetObjectItem(root, "soeData");
cJSON* limitItem = cJSON_GetObjectItem(root, "limit");
cJSON* devSeriesItem = cJSON_GetObjectItem(messageBody, "devSeries");
cJSON* lineItem = cJSON_GetObjectItem(messageBody, "line");
cJSON* realDataItem = cJSON_GetObjectItem(messageBody, "realData");
cJSON* soeDataItem = cJSON_GetObjectItem(messageBody, "soeData");
cJSON* limitItem = cJSON_GetObjectItem(messageBody, "limit");
if (devSeriesItem && lineItem && realDataItem && soeDataItem && limitItem) {
devSeries = devSeriesItem->valuestring;
@@ -894,6 +1039,46 @@ void close_listening_socket() {
}
}
//<2F><><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ip<69><70>ʽ
bool isValidIP(const std::string &ip) {
std::vector<std::string> parts;
std::stringstream ss(ip);
std::string part;
// ʹ<><CAB9> "." <20><>Ϊ<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD> IP <20><>ַ<EFBFBD>ָ<EFBFBD><D6B8>ɸ<EFBFBD><C9B8><EFBFBD><EFBFBD><EFBFBD>
while (getline(ss, part, '.')) {
parts.push_back(part);
}
// IP <20><>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 4 <20><><EFBFBD><EFBFBD>
if (parts.size() != 4) {
return false;
}
// У<><D0A3>ÿһ<C3BF><D2BB><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0 <20><> 255 ֮<><D6AE>
for (size_t i = 0; i < parts.size(); ++i) {
// У<><D0A3>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
for (size_t j = 0; j < parts[i].size(); ++j) {
if (!isdigit(parts[i][j])) {
return false;
}
}
// ת<><D7AA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>Χ<EFBFBD><CEA7>
int num = atoi(parts[i].c_str());
if (num < 0 || num > 255) {
return false;
}
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><E3A3A8> 01<30><31>001 <20>ȣ<EFBFBD>
if (parts[i].length() > 1 && parts[i][0] == '0') {
return false;
}
}
return true;
}
//ִ<>нű<D0BD><C5B1><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD>
void execute_bash(string fun,int process_num,string type)
{
@@ -916,6 +1101,29 @@ void execute_bash(string fun,int process_num,string type)
system(command);
}
//ִ<>нű<D0BD><C5B1><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD>
void execute_bash_debug(string fun,string ip,string type,int proindex)
{
const char* script = "/FeProject/bin/set_debug.sh";//ʹ<><CAB9>setsid<69><64>ֹ<EFBFBD>˿<EFBFBD>ռ<EFBFBD><D5BC>
const char* param1 = fun.c_str();
const char* param2 = ip.c_str();
const char* param3 = type.c_str();
// <20><> proindex ת<><D7AA>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
char param4[32];
snprintf(param4, sizeof(param4), "%d", proindex);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
char command[256];
snprintf(command, sizeof(command), "%s %s %s %s %s &", script, param1, param2, param3,param4);
std::cout << "command:" << command <<std::endl;
// ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
system(command);
}
void parse_set(const std::string& json_str) {
// <20><><EFBFBD><EFBFBD> JSON <20>ַ<EFBFBD><D6B7><EFBFBD>
cJSON* root = cJSON_Parse(json_str.c_str());
@@ -924,15 +1132,38 @@ void parse_set(const std::string& json_str) {
return;
}
// <20><>ȡ "messageBody" <20><><EFBFBD><EFBFBD>
cJSON* messageJson = cJSON_GetObjectItem(root, "messageBody");
if (messageJson == NULL || messageJson->type != cJSON_String) {
std::cerr << "'messageJson' is missing or is not an cJSON_String" << std::endl;
cJSON_Delete(root);
return ;
}
// <20><><EFBFBD><EFBFBD> messageBody <20>е<EFBFBD> JSON <20>ַ<EFBFBD><D6B7><EFBFBD>
const char* messageBodyStr = messageJson->valuestring;
if (messageBodyStr == nullptr || strlen(messageBodyStr) == 0) {
std::cerr << "Failed to parse 'messageBody' JSON or it's empty." << std::endl;
cJSON_Delete(root);
return;
}
cJSON* messageBody = cJSON_Parse(messageBodyStr); // <20><><EFBFBD><EFBFBD> messageBody <20>ַ<EFBFBD><D6B7><EFBFBD>
if (messageBody == NULL) {
std::cerr << "Failed to parse 'messageBody' JSON." << std::endl;
cJSON_Delete(root);
return ;
}
// <20><>ȡ code <20>ֶ<EFBFBD>
cJSON* code = cJSON_GetObjectItem(root, "code");
cJSON* code = cJSON_GetObjectItem(messageBody, "code");
if (code == nullptr) {
std::cout << "Missing 'code' in JSON." << std::endl;
cJSON_Delete(root);
return;
}
cJSON* index = cJSON_GetObjectItem(root, "index");
cJSON* index = cJSON_GetObjectItem(messageBody, "index");
if (index == nullptr) {
std::cout << "Missing 'index' in JSON." << std::endl;
cJSON_Delete(root);
@@ -940,11 +1171,11 @@ void parse_set(const std::string& json_str) {
}
//<2F>ж<EFBFBD><D0B6>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>̺ţ<CCBA>
//int index_value = index->valueint;
string index_value_str = index->valuestring;
int index_value = StringToInt(index_value_str);
int index_value = index->valueint;
//string index_value_str = index->valuestring;
//int index_value = StringToInt(index_value_str);
//<2F><><EFBFBD>̺<EFBFBD>Ϊ0<CEAA>Ľ<EFBFBD><C4BD>̴<EFBFBD><CCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD>˸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
//<2F><><EFBFBD>̺<EFBFBD>Ϊ0<CEAA>Ľ<EFBFBD><C4BD>̴<EFBFBD><CCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
if (index_value != g_front_seg_index && g_front_seg_index !=0) {
std::cout << "msg index:"<< index_value <<"doesnt match self index:" << g_front_seg_index << std::endl;
cJSON_Delete(root);
@@ -962,7 +1193,7 @@ void parse_set(const std::string& json_str) {
if(g_node_id == STAT_DATA_BASE_NODE_ID && g_front_seg_index == 1){
std::cout << "cfg_stat_data process" << g_front_seg_index <<" handle this msg" << std::endl;
// <20><><EFBFBD><EFBFBD> set_process
cJSON* data = cJSON_GetObjectItem(root, "data");
cJSON* data = cJSON_GetObjectItem(messageBody, "data");
if (data != nullptr && data->type == cJSON_Array) {
int data_size = cJSON_GetArraySize(data);
for (int i = 0; i < data_size; i++) {
@@ -995,6 +1226,46 @@ void parse_set(const std::string& json_str) {
}
}
else if (code_str == "set_debug"){
if(g_node_id == STAT_DATA_BASE_NODE_ID && g_front_seg_index == 1){
std::cout << "cfg_stat_data process" << g_front_seg_index <<" handle this msg" << std::endl;
// <20><><EFBFBD><EFBFBD> set_process
cJSON* data = cJSON_GetObjectItem(messageBody, "data");
if (data != nullptr && data->type == cJSON_Array) {
int data_size = cJSON_GetArraySize(data);
for (int i = 0; i < data_size; i++) {
cJSON* item = cJSON_GetArrayItem(data, i);
std::string fun = cJSON_GetObjectItem(item, "fun")->valuestring?cJSON_GetObjectItem(item, "fun")->valuestring:"NULL";
std::string ip = cJSON_GetObjectItem(item, "ip")->valuestring?cJSON_GetObjectItem(item, "ip")->valuestring:"NULL";
std::string frontType = cJSON_GetObjectItem(item, "frontType")->valuestring?cJSON_GetObjectItem(item, "frontType")->valuestring:"NULL";
cJSON *index_item = cJSON_GetObjectItem(item, "proindex");
int proindex = 0; // Ĭ<><C4AC>ֵ
if (index_item != NULL && index_item->type == cJSON_Number) {
proindex = index_item->valueint;
}
std::cout << "proindex is :" << proindex <<std::endl;
//У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if((fun == "start" || fun == "delete") &&
isValidIP(ip) &&
(frontType == "stat" || frontType == "recall" || frontType == "3s" || frontType == "comtrade") &&
(proindex >= 10 && proindex < 100)){ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õĽ<C3B5><C4BD>̺<EFBFBD>Ӧ<EFBFBD>ô<EFBFBD><C3B4><EFBFBD>10С<30><D0A1>100
execute_bash_debug(fun, ip, frontType,proindex);
std::cout << "!!!!!!!!!!!!!!!! execute mark:" << i << " !!!!!!!!!!!!!!!" <<std::endl;
}
else{
std::cout << "param is not executable" <<std::endl;
}
}
std::cout << "this msg should only execute once" <<std::endl;
}
}
else{
std::cout << "only cfg_stat_data index 1 can control process,this process not handle this msg" << std::endl;
}
}
else{
std::cout << "set process code str error" <<std::endl;
}
@@ -1080,6 +1351,10 @@ std::string prepare_update(const std::string& code_str, const terminal& json_dat
add_indent(xmlStream, indentLevel);
xmlStream << "<series>" << json_data.dev_series << "</series>" << std::endl;
//lnk20250210
add_indent(xmlStream, indentLevel);
xmlStream << "<processNo>" << json_data.processNo << "</processNo>" << std::endl;
add_indent(xmlStream, indentLevel);
xmlStream << "<devKey>" << json_data.dev_key << "</devKey>" << std::endl;
@@ -1126,14 +1401,16 @@ std::string prepare_update(const std::string& code_str, const terminal& json_dat
// <20><><EFBFBD><EFBFBD> modify <20><> add <20><>ǩ
if (code_str == "ledger_modify") {
indentLevel--;
add_indent(xmlStream, indentLevel);
xmlStream << "</modify>" << std::endl;
indentLevel--;
}
else {
indentLevel--;
add_indent(xmlStream, indentLevel);
xmlStream << "</add>" << std::endl;
indentLevel--;
}
} else if (code_str == "delete_terminal") {
@@ -1184,6 +1461,133 @@ int StringToInt(const std::string& str) {
return number;
}
// <20><><EFBFBD><EFBFBD> JSON <20>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
void parse_log(const std::string& json_str) {
// <20><><EFBFBD><EFBFBD> JSON <20>ַ<EFBFBD><D6B7><EFBFBD>
cJSON* root = cJSON_Parse(json_str.c_str());
if (root == nullptr) {
std::cout << "Error parsing JSON." << std::endl;
return;
}
// <20><>ȡ "messageBody" <20><><EFBFBD><EFBFBD>
cJSON* messageJson = cJSON_GetObjectItem(root, "messageBody");
if (messageJson == NULL || messageJson->type != cJSON_String) {
std::cerr << "'messageJson' is missing or is not an cJSON_String" << std::endl;
cJSON_Delete(root);
return ;
}
// <20><><EFBFBD><EFBFBD> messageBody <20>е<EFBFBD> JSON <20>ַ<EFBFBD><D6B7><EFBFBD>
const char* messageBodyStr = messageJson->valuestring;
if (messageBodyStr == nullptr || strlen(messageBodyStr) == 0) {
std::cerr << "Failed to parse 'messageBody' JSON or it's empty." << std::endl;
cJSON_Delete(root);
return;
}
cJSON* messageBody = cJSON_Parse(messageBodyStr); // <20><><EFBFBD><EFBFBD> messageBody <20>ַ<EFBFBD><D6B7><EFBFBD>
if (messageBody == NULL) {
std::cerr << "Failed to parse 'messageBody' JSON." << std::endl;
cJSON_Delete(root);
return ;
}
// <20><>ȡ code <20>ֶ<EFBFBD>
cJSON* code = cJSON_GetObjectItem(messageBody, "code");
if (code == nullptr) {
std::cout << "Missing 'code' in JSON." << std::endl;
cJSON_Delete(root);
return;
}
cJSON* index = cJSON_GetObjectItem(messageBody, "index");
if (index == nullptr) {
std::cout << "Missing 'index' in JSON." << std::endl;
cJSON_Delete(root);
return;
}
//<2F>ж<EFBFBD><D0B6>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>̺ţ<CCBA>
int index_value = index->valueint;
//string index_value_str = index->valuestring;
//int index_value = StringToInt(index_value_str);
//<2F><><EFBFBD>̺<EFBFBD>Ϊ0<CEAA>Ľ<EFBFBD><C4BD>̴<EFBFBD><CCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD>˸<EFBFBD><CBB8><EFBFBD><EFBFBD><EFBFBD>Ϣ
if (index_value != g_front_seg_index) {
std::cout << "msg index:"<< index_value <<"doesnt match self index:" << g_front_seg_index << std::endl;
cJSON_Delete(root);
return;
}
//<2F><><EFBFBD>̺<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>
std::cout << "msg index:"<< index_value <<" self index:" << g_front_seg_index << std::endl;
// <20><><EFBFBD><EFBFBD> code <20>ֶ<EFBFBD>ִֵ<D6B5>в<EFBFBD>ͬ<EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD>߼<EFBFBD>
std::string code_str = code->valuestring;
if (code_str == "set_log") {
// <20><><EFBFBD><EFBFBD> set_process
cJSON* data = cJSON_GetObjectItem(messageBody, "data");
if (data != nullptr && data->type == cJSON_Array) {
int data_size = cJSON_GetArraySize(data);
for (int i = 0; i < data_size; i++) {
cJSON* item = cJSON_GetArrayItem(data, i);
std::string fun = cJSON_GetObjectItem(item, "fun")->valuestring;
std::string level = cJSON_GetObjectItem(item, "level")->valuestring;
std::string frontType = cJSON_GetObjectItem(item, "frontType")->valuestring;
//У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(frontType == subdir){
if(fun == "open"){
if (level == "ERROR"){
// <20><><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
redirectErrorOutput(true);
}
else if (level == "WARN"){
// <20><><EFBFBD>ø澯<C3B8><E6BEAF><EFBFBD><EFBFBD>
redirectWarnOutput(true);
redirectErrorOutput(true);
}
else if (level == "NORMAL"){
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>
redirectNormalOutput(true);
redirectErrorOutput(true);
redirectWarnOutput(true);
}
else if (level == "DEBUG"){
// <20><><EFBFBD><EFBFBD> debug (ֻ<>浽 debugList<73><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ն<EFBFBD>)
redirectDebugOutput(true);
redirectErrorOutput(true);
redirectWarnOutput(true);
redirectNormalOutput(true);
}
else{
std::cout << "level error" <<std::endl;
}
}
else{
redirectDebugOutput(false);
redirectErrorOutput(false);
redirectWarnOutput(false);
redirectNormalOutput(false);
std::cout << "close all log" <<std::endl;
}
}
else{
std::cout << "front type doesnt match" <<std::endl;
}
}
std::cout << "this msg should only execute once" <<std::endl;
}
}
// <20>ͷ<EFBFBD> JSON <20><><EFBFBD><EFBFBD>
cJSON_Delete(root);
}
// <20><><EFBFBD><EFBFBD> JSON <20>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
void parse_control(const std::string& json_str, const std::string& output_dir) {
// <20><><EFBFBD><EFBFBD> JSON <20>ַ<EFBFBD><D6B7><EFBFBD>
@@ -1193,15 +1597,38 @@ void parse_control(const std::string& json_str, const std::string& output_dir) {
return;
}
// <20><>ȡ "messageBody" <20><><EFBFBD><EFBFBD>
cJSON* messageJson = cJSON_GetObjectItem(root, "messageBody");
if (messageJson == NULL || messageJson->type != cJSON_String) {
std::cerr << "'messageJson' is missing or is not an cJSON_String" << std::endl;
cJSON_Delete(root);
return ;
}
// <20><><EFBFBD><EFBFBD> messageBody <20>е<EFBFBD> JSON <20>ַ<EFBFBD><D6B7><EFBFBD>
const char* messageBodyStr = messageJson->valuestring;
if (messageBodyStr == nullptr || strlen(messageBodyStr) == 0) {
std::cerr << "Failed to parse 'messageBody' JSON or it's empty." << std::endl;
cJSON_Delete(root);
return;
}
cJSON* messageBody = cJSON_Parse(messageBodyStr); // <20><><EFBFBD><EFBFBD> messageBody <20>ַ<EFBFBD><D6B7><EFBFBD>
if (messageBody == NULL) {
std::cerr << "Failed to parse 'messageBody' JSON." << std::endl;
cJSON_Delete(root);
return ;
}
// <20><>ȡ code <20>ֶ<EFBFBD>
cJSON* code = cJSON_GetObjectItem(root, "code");
cJSON* code = cJSON_GetObjectItem(messageBody, "code");
if (code == nullptr) {
std::cout << "Missing 'code' in JSON." << std::endl;
cJSON_Delete(root);
return;
}
cJSON* index = cJSON_GetObjectItem(root, "index");
cJSON* index = cJSON_GetObjectItem(messageBody, "index");
if (index == nullptr) {
std::cout << "Missing 'index' in JSON." << std::endl;
cJSON_Delete(root);
@@ -1209,9 +1636,10 @@ void parse_control(const std::string& json_str, const std::string& output_dir) {
}
//<2F>ж<EFBFBD><D0B6>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>̺ţ<CCBA>
//int index_value = index->valueint;
string index_value_str = index->valuestring;
int index_value = StringToInt(index_value_str);
int index_value = index->valueint;
//string index_value_str = index->valuestring;
//int index_value = StringToInt(index_value_str);
//<2F><><EFBFBD>̺<EFBFBD>Ϊ0<CEAA>Ľ<EFBFBD><C4BD>̴<EFBFBD><CCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD>˸<EFBFBD><CBB8><EFBFBD><EFBFBD><EFBFBD>Ϣ
if (index_value != g_front_seg_index && g_front_seg_index !=0) {
@@ -1231,7 +1659,7 @@ void parse_control(const std::string& json_str, const std::string& output_dir) {
std::cout << "add or update ledger" <<std::endl;
// <20><><EFBFBD><EFBFBD> add_terminal <20><> ledger_modify
cJSON* data = cJSON_GetObjectItem(root, "data");
cJSON* data = cJSON_GetObjectItem(messageBody, "data");
if (data != nullptr && data->type == cJSON_Array) {
int data_size = cJSON_GetArraySize(data);
for (int i = 0; i < data_size; i++) {
@@ -1299,6 +1727,11 @@ void parse_control(const std::string& json_str, const std::string& output_dir) {
else
std::strncpy(json_data.dev_series, "N/A", sizeof(json_data.dev_series) - 1);
//lnk20250210̨<30>˽<EFBFBD><CBBD>̺<EFBFBD>
cJSON* processNo = cJSON_GetObjectItem(item, "processNo"); // processNoתΪ<D7AA>ַ<EFBFBD><D6B7><EFBFBD>
if (processNo && processNo->type == cJSON_Number) snprintf(json_data.processNo, sizeof(json_data.processNo), "%d", processNo->valueint);
else strncpy(json_data.processNo, "N/A", sizeof(json_data.processNo) - 1);
cJSON* ip = cJSON_GetObjectItem(item, "ip"); // addr_str
if (ip && ip->type == cJSON_String)
std::strncpy(json_data.addr_str, ip->valuestring, sizeof(json_data.addr_str) - 1);
@@ -1350,16 +1783,18 @@ void parse_control(const std::string& json_str, const std::string& output_dir) {
else
std::strncpy(monitor_data.status, "N/A", sizeof(monitor_data.status) - 1);
cJSON* lineNo = cJSON_GetObjectItem(item, "lineNo"); // logical_device_seq
cJSON* lineNo = cJSON_GetObjectItem(monitor_item, "lineNo"); // logical_device_seq
if (lineNo && lineNo->type == cJSON_String)
std::strncpy(monitor_data.logical_device_seq, lineNo->valuestring, sizeof(monitor_data.logical_device_seq) - 1);
else
else
std::strncpy(monitor_data.logical_device_seq, "N/A", sizeof(monitor_data.logical_device_seq) - 1);
cJSON* ptType = cJSON_GetObjectItem(item, "ptType"); // terminal_connect
cJSON* ptType = cJSON_GetObjectItem(monitor_item, "ptType"); // terminal_connect
if (ptType && ptType->type == cJSON_String)
std::strncpy(monitor_data.terminal_connect, ptType->valuestring, sizeof(monitor_data.terminal_connect) - 1);
else
else
std::strncpy(monitor_data.terminal_connect, "N/A", sizeof(monitor_data.terminal_connect) - 1);
std::strncpy(monitor_data.timestamp, json_data.timestamp, sizeof(monitor_data.timestamp) - 1);
@@ -1370,6 +1805,8 @@ void parse_control(const std::string& json_str, const std::string& output_dir) {
}
}
print_terminal(&json_data);
// ׼<><D7BC> XML <20><><EFBFBD>ݲ<EFBFBD>д<EFBFBD><D0B4><EFBFBD>ļ<EFBFBD>
std::string xmlContent = prepare_update(code_str, json_data);
if (xmlContent != "") {
@@ -1393,7 +1830,7 @@ void parse_control(const std::string& json_str, const std::string& output_dir) {
std::cout << "delete ledger" <<std::endl;
// <20><><EFBFBD><EFBFBD> delete_terminal
cJSON* data = cJSON_GetObjectItem(root, "data");
cJSON* data = cJSON_GetObjectItem(messageBody, "data");
if (data != nullptr && data->type == cJSON_Array) {
int data_size = cJSON_GetArraySize(data);
for (int i = 0; i < data_size; i++) {
@@ -1461,6 +1898,8 @@ int find_mp_index_from_mp_id(std::string line)
int myMessageCallbackrtdata(CPushConsumer* consumer, CMessageExt* msg)
{
if(INITFLAG != 1)return 1;//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
if (msg == NULL) {
std::cerr << "Received null message." << std::endl;
return E_RECONSUME_LATER;
@@ -1495,12 +1934,12 @@ int myMessageCallbackrtdata(CPushConsumer* consumer, CMessageExt* msg)
}
//mq<6D><71><EFBFBD><EFBFBD>ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ѯ̨<D1AF><CCA8>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pthread_mutex_lock(&mtx);
pthread_mutex_lock(&mtx); std::cout << "update ledger xml hold lock !!!!!!!!!!!" << std::endl;
int dev_index = find_dev_index_from_dev_id(devid);
int mp_index = find_mp_index_from_mp_id(line);
pthread_mutex_unlock(&mtx);
pthread_mutex_unlock(&mtx); std::cout << "update ledger xml free lock !!!!!!!!!!!" << std::endl;
if(dev_index == 0 || mp_index == 0){
std::cerr << "dev index or mp index is 0" << std::endl;
@@ -1520,6 +1959,8 @@ int myMessageCallbackrtdata(CPushConsumer* consumer, CMessageExt* msg)
int myMessageCallbackupdate(CPushConsumer* consumer, CMessageExt* msg)
{
if(INITFLAG != 1)return 1;//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
if (msg == NULL) {
std::cerr << "Received null message." << std::endl;
return E_RECONSUME_LATER;
@@ -1555,6 +1996,7 @@ int myMessageCallbackupdate(CPushConsumer* consumer, CMessageExt* msg)
int myMessageCallbackset(CPushConsumer* consumer, CMessageExt* msg)
{
if(INITFLAG != 1)return 1;//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
if (msg == NULL) {
std::cerr << "Received null message." << std::endl;
return E_RECONSUME_LATER;
@@ -1587,8 +2029,44 @@ int myMessageCallbackset(CPushConsumer* consumer, CMessageExt* msg)
return E_CONSUME_SUCCESS;
}
int myMessageCallbacklog(CPushConsumer* consumer, CMessageExt* msg)
{
if(INITFLAG != 1)return 1;//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
if (msg == NULL) {
std::cerr << "Received null message." << std::endl;
return E_RECONSUME_LATER;
}
const char* body = GetMessageBody(msg);
const char* key = GetMessageKeys(msg);
if (body == NULL) {
std::cerr << "Message body is NULL." << std::endl;
return E_RECONSUME_LATER;
}
else{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E7A3AC>ӡ<EFBFBD><D3A1>Ϣ<EFBFBD><CFA2><EFBFBD>ݣ<EFBFBD>
std::cout << "process Callback received message: " << body << std::endl;
if (key) {
std::cout << "Message Key: " << key << std::endl;
}
else {
std::cout << "Message Key: N/A" << std::endl;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD≯<EFBFBD><CCB8><EFBFBD><EFBFBD><EFBFBD>Ϣ
parse_log(body);
}
// <20><><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
return E_CONSUME_SUCCESS;
}
int myMessageCallbackrecall(CPushConsumer* consumer, CMessageExt* msg)
{
if(INITFLAG != 1)return 1;//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD>
std::cout << "myMessageCallbackrecall"<< std::endl;
@@ -1620,9 +2098,9 @@ int myMessageCallbackrecall(CPushConsumer* consumer, CMessageExt* msg)
std::cout << "extractDataJson:"<< result.c_str() <<std::endl;
if (!result.empty()) {
pthread_mutex_lock(&mtx);
pthread_mutex_lock(&mtx); std::cout << "recall mq hold lock !!!!!!!!!!!" << std::endl;
recall_json_handle(result.c_str()); // ʹ<><CAB9> c_str() <20><>ȡ const char* <20><><EFBFBD><EFBFBD>
pthread_mutex_unlock(&mtx);
pthread_mutex_unlock(&mtx); std::cout << "recall mq free lock !!!!!!!!!!!" << std::endl;
}
else{
std::cerr << "recall data is NULL." << std::endl;
@@ -1636,10 +2114,11 @@ int myMessageCallbackrecall(CPushConsumer* consumer, CMessageExt* msg)
return E_CONSUME_SUCCESS;
}
void mqconsumerThread::run()
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߲<EFBFBD><DFB2><EFBFBD>
std::string consumerName = std::string(subdir) + intToString(g_front_seg_index); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID
std::string consumerName = subdir + intToString(g_front_seg_index) + "_start_" + QDateTime::currentDateTime().toString("yyyyMMddhhmmss").toStdString(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID+<2B><><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7>Ϣ
std::string nameServer = G_MQCONSUMER_IPPORT; // NameServer<65><72>ַ
@@ -1663,6 +2142,9 @@ void mqconsumerThread::run()
subscriptions.push_back(Subscription(G_MQCONSUMER_TOPIC_SET, G_MQCONSUMER_TAG_SET, myMessageCallbackset));
}
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>5 //<2F><><EFBFBD>н<EFBFBD><D0BD>̶<EFBFBD><CCB6><EFBFBD><E1B6A9><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD>topic<69><63><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>ܽ<EFBFBD><DCBD>̵<EFBFBD><CCB5><EFBFBD>־<EFBFBD><D6BE><EFBFBD>Ͳ<EFBFBD><CDB2>ܻ<EFBFBD><DCBB><EFBFBD>Ӱ<EFBFBD><D3B0>
subscriptions.push_back(Subscription(G_MQCONSUMER_TOPIC_LOG, G_MQCONSUMER_TAG_LOG, myMessageCallbacklog));
try {
rocketmq_consumer_receive(consumerName, nameServer, subscriptions);
}
@@ -2061,7 +2543,8 @@ int json_block_create_data(char monid_char[], char* mms_str, double v, int flick
// return transfer_json_block_data(&json_blkd);
//}
int json_block_create_end(char monid_char[], int flicker_flag)//WW 2023<32><33>3<EFBFBD><33>13<31><33>16:38:41 <20><>ICD<43>޸<EFBFBD>
//lnk2024-8-16<31><36><EFBFBD>ӽ<EFBFBD><D3BD>߲<EFBFBD><DFB2><EFBFBD>
int json_block_create_end(char v_wiring_type[], char monid_char[], int flicker_flag)//WW 2023<32><33>3<EFBFBD><33>13<31><33>16:38:41 <20><>ICD<43>޸<EFBFBD>
{
json_block_data* pdata;
if (flicker_flag == 1) {
@@ -2110,7 +2593,8 @@ int json_block_create_end(char monid_char[], int flicker_flag)//WW 2023
printf("---------- json_block_create_end: pdata->mms_str_map.count() == 0 ----------\n");
return 1;
}
int ret = transfer_json_block_data(pdata);
//lnk2024-8-16<31><36><EFBFBD>ӽ<EFBFBD><D3BD>߲<EFBFBD><DFB2><EFBFBD>
int ret = transfer_json_block_data(v_wiring_type, pdata);
if (pdata != NULL)
delete pdata;
@@ -2361,11 +2845,9 @@ void try_start_http_thread()
int try_start_mqtest_thread(int argc, char *argv[])
{
//<2F><>ʹ<EFBFBD>ü򵥵<C3BC>ѭ<EFBFBD><D1AD><EFBFBD>̣߳<DFB3><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>app<70><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>ѭ<EFBFBD><D1AD><EFBFBD>̣߳<DFB3><CCA3><EFBFBD><EFBFBD>ҿ<EFBFBD><D2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/*static int mqtest_thread_created = 0;
if (!mqtest_thread_created) {
mqtestThrd.start();
mqtest_thread_created = 1;
}*/
//<2F><>װqt<71><74>ӡ
qInstallMsgHandler(myQtMsgHandler);
QCoreApplication a(argc, argv);
// <20><><EFBFBD><EFBFBD> QThread <20><> Worker <20><><EFBFBD><EFBFBD>
@@ -2384,8 +2866,6 @@ int try_start_mqtest_thread(int argc, char *argv[])
// <20><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
thread->start();
//std::cout << "start_mqtest"<<std::endl;
// ȷ<><C8B7><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>˳<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>߳<EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>ȷ<EFBFBD>˳<EFBFBD>
QObject::connect(&a, SIGNAL(aboutToQuit()), thread, SLOT(quit()));

View File

@@ -28,10 +28,16 @@ extern "C" {
#include <map>
#include <list>
#include "../mms/db_interface.h"
#include <QThread>
//lnk20250106
#include "../include/rocketmq/SimpleProducer.h"
//<2F><>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
#include "../cfg_parse/custom_printf.h"//lnk20250225
#include <csignal>
#include <unistd.h>
#include <QTcpServer>
#include <QTcpSocket>
#include <QMutex>
@@ -44,8 +50,15 @@ extern "C" {
#include <iostream>
extern int G_TEST_NUM;
extern void ledger(const char* terminal_id = NULL,QIODevice* outputDevice = NULL);
extern void value_print(const char *variableName, QTcpSocket *clientSocket);
extern int TEST_PORT;
extern void redirectErrorOutput(bool enable);
extern void redirectWarnOutput(bool enable);
extern void redirectNormalOutput(bool enable);
extern void redirectDebugOutput(bool enable);
//////////////////////////////////////////////////////////////////////////////
//struct json_pair_info
//{
@@ -101,30 +114,79 @@ protected:
void run();
};*/
//lnk20250106
//ʹ<><CAB9>telnet 127.0.0.1 12345<34><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
extern bool showinshellflag;
#ifdef __cplusplus
extern "C" {
#endif
void doMonitorTaskmain(void);
#ifdef __cplusplus
}
#endif
// ====================== Telnet <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ======================
// Telnet <20><><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>:
#define IAC 255 // Interpret As Command
#define DONT 254
#define TELDO 253
#define WONT 252
#define WILL 251
// Telnet ѡ<><EFBFBD><EEB3A3>:
#define TELOPT_ECHO 1 // <20><><EFBFBD><EFBFBD>
#define TELOPT_SUPPRESS_GO_AHEAD 3 // SGA
#define TELOPT_LINEMODE 34 // <20><>ģʽ
/**
* @brief Worker<65><EFBFBD><E0A3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Telnet<65><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD>
*/
class Worker : public QObject
{
Q_OBJECT
public:
Worker(QObject *parent = NULL) : QObject(parent), server(NULL), TEST_NUM(G_TEST_NUM) {}
~Worker() {
if (server) {
server->close();
delete server;
}
Worker(QObject *parent = NULL)
: QObject(parent),
server(NULL),
TEST_NUM(G_TEST_NUM),
timer(NULL),
historyIndex(-1),
stopViewLog(true),
g_stopTelnetTest(true),
activeClient(NULL)
{
}
~Worker() {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>
stopServer();
}
void handleViewLogCommand(const QString& command, QTcpSocket* clientSocket);
int init_ping_telnet(QTcpSocket* clientSocket, int& ip_count, int& telnet_count);
void telnetetst(QTcpSocket* clientSocket);
public slots:
/**
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void startServer() {
server = new QTcpServer();
if (server) {
qDebug() << "Server is already running!";
return; // <20><>ֹ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
// <20><><EFBFBD><EFBFBD> QTcpServer <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD>
server = new QTcpServer(this);
connect(server, SIGNAL(newConnection()), this, SLOT(onNewConnection()));
// <20><><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>˿<EFBFBD>
if (!server->listen(QHostAddress::Any, TEST_PORT)) {
std::cout << "Server failed to start!" << std::endl;
qDebug() << "Server failed to start!";
delete server;
server = NULL;
emit serverError();
return;
} else {
@@ -135,18 +197,58 @@ public slots:
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(doPeriodicTask()));
timer->start(60000); // ÿ60<36><EFBFBD><EBB4A5>һ<EFBFBD><D2BB>
timer->start(60000); // ÿ60<36><EFBFBD><EBB4A5>һ<EFBFBD><D2BB>
std::cout << "Timer started, event loop running in thread: " << QThread::currentThreadId() << std::endl;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD><DABA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6BBBB><EFBFBD>̵߳ļ<CCB5><C4BC><EFBFBD>
QTimer *monitorTimer = new QTimer(this);
connect(monitorTimer, SIGNAL(timeout()), this, SLOT(doMonitorTask()));
monitorTimer->start(1000); // ÿ1<C3BF><EFBFBD><EBB4A5>һ<EFBFBD><D2BB>
std::cout << "Timer started, event loop running in thread: "
<< QThread::currentThreadId() << std::endl;
qDebug() << "Timer started, event loop running in thread:" << QThread::currentThreadId();
}
/**
* @brief ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void stopServer() {
// ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
if (server) {
server->close();
delete server;
server = NULL;
qDebug() << "Server stopped.";
}
// ֹͣ<CDA3><D6B9>ʱ<EFBFBD><CAB1>
if (timer) {
timer->stop();
delete timer;
timer = NULL;
qDebug() << "Timer stopped.";
}
}
/**
* @brief <20><><EFBFBD><EFBFBD>TEST_NUM
*/
void setTestNum(int num) {
QMutexLocker locker(&mutex);
TEST_NUM = num;
}
void setTestlog(bool flag) {
redirectErrorOutput(flag);
redirectWarnOutput(flag);
redirectNormalOutput(flag);
redirectDebugOutput(flag);
}
private slots:
/**
* @brief <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
*/
void doPeriodicTask() {
QMutexLocker locker(&mutex);
std::cout << "Executing TEST_NUM is " << TEST_NUM << std::endl;
@@ -159,6 +261,16 @@ private slots:
}
}
/**
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void doMonitorTask() {
doMonitorTaskmain();
}
/**
* @brief <20><><EFBFBD><EFBFBD><EFBFBD>¿ͻ<C2BF><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
*/
void onNewConnection() {
if (!server) return;
@@ -166,121 +278,356 @@ private slots:
qDebug() << "New connection established!";
std::cout << "New connection established!\n";
// <20><><EFBFBD><EFBFBD> readyRead / disconnected
connect(clientSocket, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
connect(clientSocket, SIGNAL(disconnected()), clientSocket, SLOT(deleteLater()));
// <20><><EFBFBD>ͻ<EFBFBD><EFBFBD>˷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD> Telnet Э<EFBFBD><EFBFBD>
sendTelnetNegotiation(clientSocket);
// <20><><EFBFBD>ͻ<EFBFBD>ӭ<EFBFBD><D3AD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>
if (clientSocket) {
std::cout << "clientSocket OK\n";
clientSocket->write("Welcome to the test shell. Type 'help' for available commands.\n> ");
clientSocket->flush(); // ȷ<><C8B7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
clientSocket->write("\r\x1B[K");
clientSocket->write("Welcome to the test shell. Type 'help' for available commands.\r\n");
printPrompt(clientSocket); // ͳһ<CDB3><D2BB>ӡ<EFBFBD><D3A1>ʾ<EFBFBD><CABE>
}
}
/**
* @brief <20><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB>˷<EFBFBD><CBB7>͵<EFBFBD>Telnet<65><74><EFBFBD><EFBFBD>
*/
void onReadyRead() {
QTcpSocket *clientSocket = qobject_cast<QTcpSocket *>(sender());
std::cout << "onReadyRead\n";
if (!clientSocket) {
std::cout << "Invalid socket\n";
return;
}
std::cout << "read all\n";
QByteArray data = clientSocket->readAll();
QString command = QString::fromUtf8(data).trimmed(); // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ<EEB2A2><C8A5>ǰ<EFBFBD><C7B0><EFBFBD>ո<EFBFBD>
for (int i = 0; i < data.size(); ++i) {
unsigned char c = static_cast<unsigned char>(data[i]);
qDebug() << "Received command:" << command;
std::cout << "Received command: " << command.toStdString() << "\n";
// <20><><EFBFBD>ͻ<EFBFBD><CDBB>˷<EFBFBD><CBB7>͡<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBA1B1><EFBFBD><EFBFBD>
clientSocket->write("Received command\n> ");
clientSocket->flush();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ʾ<EFBFBD><CABE>
clientSocket->write("test_shell> ");
clientSocket->flush(); // ȷ<><C8B7><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
// <20><><EFBFBD><EFBFBD> TEST_NUM
if (command.startsWith("TEST_NUM=")) {
bool ok;
int num = command.mid(9).toInt(&ok); // <20><>ȡ<EFBFBD>Ⱥź<C8BA><C5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>
if (ok) {
setTestNum(num); // <20><><EFBFBD><EFBFBD> TEST_NUM
clientSocket->write("TEST_NUM updated\n> ");
std::cout << "TEST_NUM updated\n";
} else {
clientSocket->write("Invalid number\n> ");
std::cout << "Invalid number\n";
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⵽ IAC(255)<29><>˵<EFBFBD><CBB5><EFBFBD><EFBFBD> Telnet Э<><D0AD>ָ<EFBFBD><D6B8>
if (c == IAC) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TELDO/DONT/WILL/WONT + option
if (i + 1 < data.size()) {
unsigned char cmd = static_cast<unsigned char>(data[i+1]);
if (cmd == TELDO || cmd == DONT || cmd == WILL || cmd == WONT) {
i += 2; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD>ֽ<EFBFBD>
} else {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>IAC SB)<29><><EFBFBD>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֽ<EFBFBD>
i += 1;
}
}
continue;
}
}
// <20><><EFBFBD><EFBFBD> rc <20><><EFBFBD><EFBFBD>
else if (command.startsWith("rc")) {
qDebug() << "Executing rocketmq_test_rc()";
std::cout << "Executing rocketmq_test_rc()\n";
rocketmq_test_rc(); // <20><><EFBFBD><EFBFBD> rc <20><><EFBFBD><EFBFBD>
clientSocket->write("Executed rocketmq_test_rc\n> ");
}
// <20><><EFBFBD><EFBFBD> rt <20><><EFBFBD><EFBFBD>
else if (command.startsWith("rt")) {
qDebug() << "Executing rocketmq_test_rt()";
std::cout << "Executing rocketmq_test_rt()\n";
rocketmq_test_rt(); // <20><><EFBFBD><EFBFBD> rt <20><><EFBFBD><EFBFBD>
clientSocket->write("Executed rocketmq_test_rt\n> ");
}
// <20><><EFBFBD><EFBFBD> ud <20><><EFBFBD><EFBFBD>
else if (command.startsWith("ud")) {
qDebug() << "Executing rocketmq_test_ud()";
std::cout << "Executing rocketmq_test_ud()\n";
rocketmq_test_ud(); // <20><><EFBFBD><EFBFBD> ud <20><><EFBFBD><EFBFBD>
clientSocket->write("Executed rocketmq_test_ud\n> ");
}
else if (command.startsWith("set")) {
qDebug() << "Executing rocketmq_test_set()";
std::cout << "Executing rocketmq_test_set()\n";
rocketmq_test_set(); // <20><><EFBFBD><EFBFBD> set <20><><EFBFBD><EFBFBD>
clientSocket->write("Executed rocketmq_test_set\n> ");
}
else if (command.startsWith("ledger")) {
qDebug() << "Executing ledger()";
std::cout << "Executing ledger()\n";
// <20><>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
QStringList parts = command.split(" "); // <20><><EFBFBD>ݿո<DDBF><D5B8>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>
if (parts.size() > 1) { // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>а<EFBFBD><D0B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> id<69>ţ<EFBFBD>
QString terminalId = parts[1];
std::cout << "Calling ledger with terminal_id: " << terminalId.toStdString() << std::endl;
// <20>޸ģ<DEB8><C4A3><EFBFBD><EFBFBD><EFBFBD> ledger ʱ<><CAB1><EFBFBD><EFBFBD> clientSocket <20><>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>
ledger(terminalId.toStdString().c_str(), clientSocket); // <20><><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ledger<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD> clientSocket
clientSocket->write("Executed ledger with terminal_id\n> ");
} else {
std::cout << "Calling ledger without parameters\n";
// <20>޸ģ<DEB8><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޲<EFBFBD><DEB2><EFBFBD><EFBFBD><EFBFBD> ledger<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD> clientSocket
ledger(NULL, clientSocket); // <20><><EFBFBD><EFBFBD><EFBFBD>޲<EFBFBD><DEB2><EFBFBD><EFBFBD><EFBFBD> ledger<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD> clientSocket
clientSocket->write("Executed ledger without parameters\n> ");
// 1) <20><><EFBFBD><EFBFBD> '`' <20>˳<EFBFBD> viewlog <20><>ping
if (c == '`') {
std::cout << "Received '`' from shell socket! Exiting viewlog...\n";
if (activeClient == clientSocket) {
stopViewLog = true;
g_stopTelnetTest = true;
clientSocket->write("\r\x1B[K");
clientSocket->write("\r\nLog view stopped. Returning to shell.\r\n");
printPrompt(clientSocket);
}
return;
}
}
// <20><><EFBFBD><EFBFBD>δ֪<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
else {
clientSocket->write("Unknown command\n> ");
}
// 2) <20>س<EFBFBD><D8B3><EFBFBD><EFBFBD>У<EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (c == '\r' || c == '\n') {
if (!currentCommand.isEmpty()) {
// <20>ӵ<EFBFBD><D3B5><EFBFBD>ʷ
if (commandHistory.isEmpty() || commandHistory.last() != currentCommand) {
commandHistory.append(currentCommand);
}
historyIndex = commandHistory.size();
clientSocket->flush();
// ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>հ<EFBFBD>
//QString trimmedCmd = currentCommand.trimmed();
currentCommand.remove(0, 1);
processCommand(currentCommand, clientSocket);
currentCommand.clear();
} else {
// <20><><EFBFBD><EFBFBD> => <20><><EFBFBD><EFBFBD>ӡ<EFBFBD>µ<EFBFBD><C2B5><EFBFBD>ʾ<EFBFBD><CABE>
printPrompt(clientSocket);
}
continue;
}
// 3) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (c == '\x1b') {
if (i + 2 < data.size() && data[i+1] == '[') {
char arrow = data[i+2];
if (arrow == 'A') {
handleUpArrow(clientSocket);
} else if (arrow == 'B') {
handleDownArrow(clientSocket);
}
i += 2;
}
continue;
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>̶<EFBFBD>Ϊ "> "<22><><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ2
const int promptLength = 1;
// 4) <20>˸<EFBFBD><CBB8><EFBFBD>
if (c == '\x7f' || c == '\b') {
// <20><><EFBFBD><EFBFBD> currentCommand <20>ij<EFBFBD><C4B3>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>ַ<EFBFBD>
if (currentCommand.length() > promptLength) {
currentCommand.chop(1);
// <20><><EFBFBD><EFBFBD><EFBFBD>˸<EFBFBD><CBB8><EFBFBD><EFBFBD><EFBFBD> "\b \b" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ַ<EFBFBD>
clientSocket->write("\b \b");
clientSocket->flush();
}
continue;
}
// 5) <20><>ͨ<EFBFBD>ַ<EFBFBD>
currentCommand.append(static_cast<char>(c));
clientSocket->write((const char*)&c, 1);
clientSocket->flush();
}
}
signals:
void serverError();
private:
// ========== Telnet Э<>̺<EFBFBD><CCBA><EFBFBD> ==========
void sendTelnetNegotiation(QTcpSocket *socket)
{
// <20><><EFBFBD><EFBFBD> WILL ECHO / WILL SUPPRESS-GO-AHEAD / DONT LINEMODE
static const unsigned char will_echo[3] = { IAC, WILL, TELOPT_ECHO };
static const unsigned char will_sga[3] = { IAC, WILL, TELOPT_SUPPRESS_GO_AHEAD };
static const unsigned char dont_linemode[3] = { IAC, DONT, TELOPT_LINEMODE };
socket->write(reinterpret_cast<const char*>(will_echo), 3);
socket->write(reinterpret_cast<const char*>(will_sga), 3);
socket->write(reinterpret_cast<const char*>(dont_linemode), 3);
socket->flush();
}
/**
* @brief <20><>ӡ<EFBFBD><D3A1>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ͳһʹ<D2BB><CAB9>\r\n<><6E><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>Ҵ<EFBFBD>ӡ"> "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void printPrompt(QTcpSocket *clientSocket)
{
clientSocket->write("\n\r\x1B[K> ");
clientSocket->flush();
}
/**
* @brief ִ<><D6B4>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѱ<EFBFBD>trimmed<65><64>
*/
void processCommand(const QString &cmd, QTcpSocket *clientSocket) {
qDebug() << "Received command:" << cmd;
std::cout << "Received command: " << cmd.toStdString() << "\n";
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (cmd == "help") {
QString helpText = "Available commands:\r\n";
helpText += "TEST_NUM=<num> - Set the TEST_NUM\r\n";
helpText += "LOG=<bool> - Set the LOG\r\n";
helpText += "telnettest - Set the telnettest\r\n";
helpText += "rc - Execute rocketmq_test_rc\r\n";
helpText += "rt - Execute rocketmq_test_rt\r\n";
helpText += "ud - Execute rocketmq_test_ud\r\n";
helpText += "set - Execute rocketmq_test_set\r\n";
helpText += "only - Execute rocketmq_test_only\r\n";
helpText += "log - Execute rocketmq_test_log\r\n";
helpText += "soe - Execute http_test_soe\r\n";
helpText += "qvvr - Execute http_test_qvvr\r\n";
helpText += "connect - Execute http_test_connect\r\n";
helpText += "ledger <id> - Execute ledger with optional terminal_id\r\n";
helpText += "viewlog <level> - View logs (ERROR, WARN, NORMAL, DEBUG)\r\n";
helpText += "value <valuename> - Execute value print with valuename : frontindex remtable iedcount frontfun log init\r\n";
helpText += "exit - Exit the shell\r\n";
helpText += "help - Show this help message\r\n";
clientSocket->write("\r\x1B[K");
clientSocket->write(helpText.toUtf8());
}
else if (cmd.startsWith("viewlog")) {
showinshellflag = true;
handleViewLogCommand(cmd, clientSocket);
}
else if (cmd.startsWith("TEST_NUM=")) {
bool ok;
int num = cmd.mid(9).toInt(&ok);
if (ok) {
setTestNum(num);
clientSocket->write("\r\x1B[K");
clientSocket->write("TEST_NUM updated\r\n");
} else {
clientSocket->write("\r\x1B[K");
clientSocket->write("Invalid number\r\n");
}
}
else if (cmd.startsWith("LOG=")) {
bool ok;
bool flag = cmd.mid(4).toInt(&ok);
if (ok) {
setTestlog(flag);
clientSocket->write("\r\x1B[K");
clientSocket->write("TEST_NUM updated\r\n");
} else {
clientSocket->write("\r\x1B[K");
clientSocket->write("Invalid number\r\n");
}
}
else if (cmd.startsWith("telnettest")) {
g_stopTelnetTest = false;
telnetetst(clientSocket);
clientSocket->write("\r\x1B[K");
clientSocket->write("Executed telnettest warning!!! it woont stop until finish!!!\r\n");
}
else if (cmd.startsWith("rc")) {
rocketmq_test_rc();
clientSocket->write("\r\x1B[K");
clientSocket->write("Executed rocketmq_test_rc\r\n");
}
else if (cmd.startsWith("rt")) {
rocketmq_test_rt();
clientSocket->write("\r\x1B[K");
clientSocket->write("Executed rocketmq_test_rt\r\n");
}
else if (cmd.startsWith("ud")) {
rocketmq_test_ud();
clientSocket->write("\r\x1B[K");
clientSocket->write("Executed rocketmq_test_ud\r\n");
}
else if (cmd.startsWith("set")) {
rocketmq_test_set();
clientSocket->write("\r\x1B[K");
clientSocket->write("Executed rocketmq_test_set\r\n");
}
else if (cmd.startsWith("only")) {
rocketmq_test_only();
clientSocket->write("\r\x1B[K");
clientSocket->write("Executed rocketmq_test_only\r\n");
}
else if (cmd.startsWith("log")) {
rocketmq_test_log();
clientSocket->write("\r\x1B[K");
clientSocket->write("Executed rocketmq_test_log\r\n");
}
else if (cmd.startsWith("soe")) {
SOEFileWeb_test();
clientSocket->write("\r\x1B[K");
clientSocket->write("Executed http_test_soe\r\n");
}
else if (cmd.startsWith("qvvr")) {
qvvr_test();
clientSocket->write("\r\x1B[K");
clientSocket->write("Executed http_test_qvvr\r\n");
}
else if (cmd.startsWith("connect")) {
comflag_test();
clientSocket->write("\r\x1B[K");
clientSocket->write("Executed http_test_connect\r\n");
}
else if (cmd.startsWith("ledger")) {
QStringList parts = cmd.split(" ");
if (parts.size() > 1) {
QString terminalId = parts[1];
ledger(terminalId.toStdString().c_str(), clientSocket);
clientSocket->write("\r\x1B[K");
clientSocket->write("Executed ledger with terminal_id\r\n");
} else {
ledger(NULL, clientSocket);
clientSocket->write("\r\x1B[K");
clientSocket->write("Executed ledger without parameters\r\n");
}
}
else if (cmd.startsWith("value")) {
QStringList parts = cmd.split(" ");
if (parts.size() > 1) {
QString variableName = parts[1];
clientSocket->write("\r\x1B[K");
clientSocket->write("Executed value with variable name: " + variableName.toUtf8() + "\r\n");
value_print(variableName.toStdString().c_str(), clientSocket);
} else {
clientSocket->write("\r\x1B[K");
clientSocket->write("Please provide a variable name\r\n");
}
}
else if (cmd == "exit") {
clientSocket->write("\r\x1B[K");
clientSocket->write("Goodbye! Exiting shell...\r\n");
clientSocket->flush();
clientSocket->disconnectFromHost();
clientSocket->waitForDisconnected();
return;
}
else {
clientSocket->write("\r\x1B[K> ");
clientSocket->write("Unknown command\r\n");
clientSocket->flush();
}
// <20><><EFBFBD><EFBFBD><EEB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󣬴<EFBFBD>ӡ<EFBFBD><D3A1>ʾ<EFBFBD><CABE>
printPrompt(clientSocket);
}
/**
* @brief <20>ϼ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void handleUpArrow(QTcpSocket *clientSocket) {
if (!commandHistory.isEmpty() && historyIndex > 0) {
historyIndex--;
currentCommand = commandHistory[historyIndex];
// <20><><EFBFBD>У<EFBFBD>\r<>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD> + \x1B[K<><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
clientSocket->write("\r\x1B[K> ");
clientSocket->write(currentCommand.toUtf8());
clientSocket->flush();
}
}
/**
* @brief <20>¼<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>
*/
void handleDownArrow(QTcpSocket *clientSocket) {
if (!commandHistory.isEmpty() && historyIndex < commandHistory.size() - 1) {
historyIndex++;
currentCommand = commandHistory[historyIndex];
clientSocket->write("\r\x1B[K> ");
clientSocket->write(currentCommand.toUtf8());
clientSocket->flush();
}
else if (historyIndex == commandHistory.size() - 1) {
historyIndex = commandHistory.size();
currentCommand.clear();
clientSocket->write("\r\x1B[K> ");
clientSocket->flush();
}
}
private:
QTcpServer *server;
QTimer *timer;
int TEST_NUM;
QMutex mutex;
// <20><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
QList<QString> commandHistory; // <20><EFBFBD><E6B4A2>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD>
int historyIndex; // <20><>ǰ<EFBFBD><C7B0>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
QString currentCommand; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// viewlog <20><><EFBFBD><EFBFBD>
bool stopViewLog;
//ping<6E><67><EFBFBD><EFBFBD>
bool g_stopTelnetTest;
QTcpSocket* activeClient;
};
//lnk20241213
class mqconsumerThread : public QThread
{
@@ -330,6 +677,7 @@ struct terminal //
char dev_type[64];
char dev_key[255];
char dev_series[255];
char processNo[64]; //lnk20250210<31><30><EFBFBD>̺<EFBFBD>
char addr_str[64];
char port[64];
char timestamp[64];

View File

@@ -51,7 +51,7 @@ using namespace std;
SM4 sm4Encode;
sm4Encode.sm4_enc((char*)input,seriseLen+4,(char*)output,szKey);
printf("%lld || %s || %x %x %x %x\n", now_secs, output, pTime[3], pTime[2], pTime[1], pTime[0]);
printf("now_secs:%lld ||series: %s ||ptime: %x %x %x %x\n", now_secs, output, pTime[3], pTime[2], pTime[1], pTime[0]);//lnk20250304
}
void MyGetSM4Code(char* input,unsigned char* szKey,char* output)

View File

@@ -72,7 +72,8 @@ int json_block_create_flag(char monid_char[], int flag, int flicker_flag);
//2. json<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻص<DDBB><D8B5><EFBFBD><EFBFBD><EFBFBD>
int json_block_create_data(char monid_char[], char* mms_str , double v, int flicker_flag);
//3. json<6F><6E><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int json_block_create_end(char monid_char[], int flicker_flag); //CZY 2023-08-17 <20><EFBFBD><EFBFBD><EFBFBD>
//lnk2024-8-16<31><36><EFBFBD>Ӳ<EFBFBD><EFBFBD><EFBFBD>
int json_block_create_end(char v_wiring_type[], char monid_char[], int flicker_flag); //CZY 2023-08-17 <20><><EFBFBD><EFBFBD>
//int json_block_create_end(int MonitorId,int devkind);//CZY 2023-08-17 <20><><EFBFBD><EFBFBD>
//zw 2024-01-31 <20><><EFBFBD><EFBFBD>ģʽ<C4A3>Ż<EFBFBD>
@@ -110,7 +111,6 @@ int parse_device_cfg_json();
int parse_device_cfg_pg();
int parse_line_cfg_pg();
void init_config();
int init_ping_telnet();
int GetServerIndexFromDB();
int parse_device_cfg();
@@ -189,10 +189,8 @@ void DeletcRecallXml();
/*lnk10-11*////////////////////////////////////////////////////////////////////////
void rocketmq_test();
void rocketmq_test_300(int mpnum,int front_index);
void curltest();
void SOEFileWeb_test();
void qvvr_test();
void integrity_test();
void comflag_test();
int parse_device_web_test_ext();
@@ -206,6 +204,7 @@ int parse_device_web_test_front_write();
int parse_device_cfg_web();
//int parse_line_cfg_web();
int parse_model_cfg_web();
void SOEFileWeb(char* localpath,char* cloudpath,char* wavepath);
void OTL_Select_recall_web(char* time, char* id);

View File

@@ -106,7 +106,15 @@ ST_VOID doCommService ();
ST_VOID init_log_cfg (ST_VOID);
ST_VOID set_rem_dib_table_size (ST_INT size);
//lnk20250207
#ifdef __cplusplus
extern "C" {
#endif
ST_VOID add_rem_dib_table (ST_INT pos,ST_CHAR *remAr,unsigned short port);
#ifdef __cplusplus
}
#endif
ST_RET mms_connectToServer (ST_CHAR * dev_key,ST_CHAR *dev_series, ST_CHAR *serverARName,
MVL_NET_INFO **clientNetInfo, MVL_REQ_PEND **reqCtrl);

View File

@@ -17,6 +17,9 @@
/*lnk10-10 */
#include "../include/rocketmq/SimpleProducer.h"
#include "../cfg_parse/custom_printf.h"//lnk20250225
extern G_TEST_FLAG;
extern pthread_mutex_t mtx;
@@ -35,6 +38,8 @@ uint32_t g_node_id = 0;
uint32_t g_min_free_size = 1024;
int g_need_password = 0;
int INITFLAG = 0; //lnk20250304
char subdir[128] = "cfg_stat_data" ;
int usage();
@@ -276,34 +281,34 @@ int main(int argc, const char **argv)
}
//lnk20241024ȥ<34><C8A5><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>
//OTLConnect();
//OTLConnect();
rv = run_protocol();
if (rv!=APR_SUCCESS){
return rv;
}
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD>־,<2C><>ֹ<EFBFBD><D6B9>δ׼<CEB4><D7BC><EFBFBD><EFBFBD>ȫ<EFBFBD>ͽ<EFBFBD><CDBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±<EFBFBD><C2B1><EFBFBD>
INITFLAG = 1;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
printf("INITFLAG=%d\n",INITFLAG);
if (1 == G_TEST_FLAG) {
//lnk<6E><6B><EFBFBD><EFBFBD>mqģ<71><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ֻ<EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
printf("try_start_mqtest_thread \n");
int ret = try_start_mqtest_thread(0,NULL);
// <20>ȴ<EFBFBD><C8B4>߳<EFBFBD><DFB3>˳<EFBFBD>
echo_warn1("%-60s","System shutdown now......");
apr_pool_destroy(g_root_pool);
echo_msg("OK\n");
return ret;
}
while(1) {
/* sleep 1s, just like 1s timer */
apr_sleep(apr_time_from_sec(1));
/* ÿ30<33><30><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD>һ<EFBFBD><D2BB>״̬ */
/*<2A><><EFBFBD><EFBFBD>mq<6D><71><EFBFBD><EFBFBD>lnk10-10 */
//rocketmq_test_rt();
//rocketmq_test_ud();
//rocketmq_test_rc();
/*lnk20241029recall<6C>ӿڲ<D3BF><DAB2><EFBFBD>*/
//curltest();
/*202411-1lnk<6E><6B><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD> */
//SOEFileWeb_test();
//<2F><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD>
//qvvr_test();
//apr_sleep(apr_time_from_sec(3));
//comflag_test();
//apr_sleep(apr_time_from_sec(3));
if( !(stimer++ % 60) ) {//<2F><><EFBFBD><EFBFBD>
if (g_dead_lock_counter++ >=3) {//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
g_thread_blocked_times++;
@@ -327,9 +332,10 @@ int main(int argc, const char **argv)
}
//lnk20241211 <20><><EFBFBD>Ӳ<EFBFBD><D3B2>Կ<EFBFBD><D4BF><EFBFBD>
pthread_mutex_lock(&mtx);//<2F><><EFBFBD>̶߳<DFB3>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD>ȡ̨<C8A1>˼<EFBFBD><CBBC><EFBFBD>
pthread_mutex_lock(&mtx);
if (!G_TEST_FLAG && g_front_num_count >= 30 && g_onlyIP[0] == 0 && g_node->n_clients>10) {//30<33><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD>˴<EFBFBD><CBB4><EFBFBD>ʮ<EFBFBD><CAAE><EFBFBD>ն<EFBFBD>
MVL_LOG_ACSE0("MYLOG: g_front_num_count>=20, so exit to restart ");
apr_sleep(apr_time_from_sec(10));
exit(-1039);
}
@@ -454,3 +460,41 @@ int parse_param(int argc, const char **argv)
}
///////////////////////////////////////////////////////////////<2F><><EFBFBD>Ӳ<EFBFBD><D3B2>Խ<EFBFBD><D4BD>̵ļ<CCB5><C4BC>غ<EFBFBD><D8BA><EFBFBD>lnk20250304
void doMonitorTaskmain(void) {
static int stimer = 0;
stimer++;
if( !(stimer++ % 60) ) {//<2F><><EFBFBD><EFBFBD>
if (g_dead_lock_counter++ >=3) {//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
g_thread_blocked_times++;
g_dead_lock_counter = 0;
}
MVL_LOG_ACSE1 ("MYLOG: current g_thread_blocked_times = %u ", g_thread_blocked_times);
if (FRONT_MP_NUM <= 1) {//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
g_front_num_count++;
}
else {
g_front_num_count = 0;
}
}
//work<72>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD>3*13<31><33><EFBFBD>ӣ<EFBFBD><D3A3>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>
if (g_thread_blocked_times>=13) {
MVL_LOG_ACSE0 ("MYLOG: g_thread_blocked_times>=3, so exit to restart ");
apr_sleep(apr_time_from_sec(10));
exit(-1039);
}
//lnk20241211 <20><><EFBFBD>Ӳ<EFBFBD><D3B2>Կ<EFBFBD><D4BF><EFBFBD>
pthread_mutex_lock(&mtx);
if (!G_TEST_FLAG && g_front_num_count >= 30 && g_onlyIP[0] == 0 && g_node->n_clients>10) {//30<33><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD>˴<EFBFBD><CBB4><EFBFBD>ʮ<EFBFBD><CAAE><EFBFBD>ն<EFBFBD>
MVL_LOG_ACSE0("MYLOG: g_front_num_count>=20, so exit to restart ");
apr_sleep(apr_time_from_sec(10));
exit(-1039);
}
pthread_mutex_unlock(&mtx);
}

File diff suppressed because it is too large Load Diff

View File

@@ -38,6 +38,7 @@
#include "tp4.h"
#include "db_interface.h"
#include "../cfg_parse/custom_printf.h"//lnk20250225
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
@@ -199,6 +200,9 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
v = mms_dec_data.data_item[ii].u.data_double;
apr_snprintf(mms_ref, sizeof(mms_ref), "%s$%s", do_name, mms_dec_data.data_item[ii].comp_name);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
printf("u.data_str: %s (as hex: 0x%X)\n", mms_dec_data.data_item[ii].u.data_str, *((ST_UINT16*)mms_dec_data.data_item[ii].u.data_str));
if (strstr(mms_ref, "QVVR")) {
log_data_type = QVVR_DATA;
timeflag = FALSE;
@@ -212,30 +216,83 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
length_FCDA = strlen(mms_ref);
if (('$' == mms_ref[length_FCDA - 2]) && ('t' == mms_ref[length_FCDA - 1])) {
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20250307
printf("readtime = 1");
readtime = 1;
t = convert_btime6_to_apr_time(&(mms_dec_data.data_item[ii].u.data_bTime6));
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><E5B1A3>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ϣ
apr_time_exp_t xt;
// ʹ<>ñ<EFBFBD><C3B1><EFBFBD>ʱ<EFBFBD><CAB1>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> apr_time_exp_gmt(&xt, t) <20>õ<EFBFBD> GMT ʱ<>
if (apr_time_exp_lt(&xt, t) == APR_SUCCESS) {
// tm_year <20><>ʾ<EFBFBD><CABE> 1900 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD> 1900<30><30>tm_mon <20><>ΧΪ 0~11<31><31><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA> 1
printf("Converted time: %04d-%02d-%02d %02d:%02d:%02d.%06d\n",
xt.tm_year + 1900,
xt.tm_mon + 1,
xt.tm_mday,
xt.tm_hour,
xt.tm_min,
xt.tm_sec,
xt.tm_usec);
} else {
printf("Failed to convert apr_time_t\n");
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
if (('$' == mms_ref[length_FCDA - 2]) && ('q' == mms_ref[length_FCDA - 1])) {
if (log_data_type == STEADY_DATA) {
readquailty = 1;
char* q = mms_dec_data.data_item[ii].u.data_str;
if (q[0] == '0' && q[1] == '0')
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20250307
if (q != NULL)
{
int i;
for (i = 0; q[i] != '\0'; i++)
{
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> '\0' <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE>ų<EFBFBD><C5B3><EFBFBD> '\0' */
if (q[i] == '\0')
continue;
printf("q[%d] = %c\n", i, q[i]);
}
printf("!!!!!\n");
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20250307
if (q[0] == '0' && q[1] == '0'){
quality = 0;
else
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20250307
printf("quality = 0");
}else{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20250307
printf("quality = 1");
quality = 1;
}
}
}
if (readtime == 1 && readquailty == 1) {
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20250307
printf("readtime == 1 && readquailty = 1");
break;
}
}
if (readtime == 1 && readquailty == 1) {
if (quality == 1) {
if (0) {//<2F><><EFBFBD>ԣ<EFBFBD>Ҫ<EFBFBD>Ļ<EFBFBD>quality == 0
timeflag = TRUE;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20250307
printf("readtime == 1 && readquailty = 1 && quality == 1 continue");
continue;
}
else
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20250307
printf("readtime == 1 && readquailty = 1 && quality == 0 log");
timeflag = FALSE;
if (process_jou_entry_t == 0) {
process_jou_entry_t = t;
@@ -250,9 +307,9 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
{
printf("\n newTime: %d %d %d %d %d %d", newTime.tm_year, newTime.tm_mon, newTime.tm_mday, newTime.tm_hour, newTime.tm_min, newTime.tm_sec);
printf("\n preTime: %d %d %d %d %d %d", preTime.tm_year, preTime.tm_mon, preTime.tm_mday, preTime.tm_hour, preTime.tm_min, preTime.tm_sec);
json_block_create_end(loginfo->LD_info->mp_id, 0);//<2F><>̬
json_block_create_end(loginfo->LD_info->mp_id, 1);//<2F><><EFBFBD><EFBFBD>
json_block_create_end(loginfo->LD_info->mp_id, 2);//<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
json_block_create_end(loginfo->LD_info->v_wiring_type,loginfo->LD_info->mp_id, 0);//<2F><>̬
json_block_create_end(loginfo->LD_info->v_wiring_type,loginfo->LD_info->mp_id, 1);//<2F><><EFBFBD><EFBFBD>
json_block_create_end(loginfo->LD_info->v_wiring_type,loginfo->LD_info->mp_id, 2);//<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
process_jou_entry_t = t;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
ied_t* ied;
@@ -321,14 +378,26 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
//set_db_value(LOG_IDX,mms_ref,v,FALSE);
length_FCDA = strlen( mms_ref );
if ( ('$'==mms_ref[length_FCDA-2]) && ('q'==mms_ref[length_FCDA-1]) ) {
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20250307
//printf("going q");
if(not_set_log_q_this && ( log_data_type == STEADY_DATA )) {
int quality = 0;
char* q = mms_dec_data.data_item[ii].u.data_str;
if (q[0]=='0'&& q[1]=='0')
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20250307
printf("q[0] = %c ,q[1] = %c !!!!!",q[0],q[1]);
if (q[0]=='0'&& q[1]=='0'){
printf("quality = 0");
quality = 0;
else
}else{
printf("quality = 1");
quality = 1;
if (quality == 1) {
}
if (0) {//<2F><><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>Ҫ<EFBFBD>Ļ<EFBFBD>quality == 0
printf("quality = 1 continue");
continue;
}
//set_log_QualityFlag(quality);
@@ -345,6 +414,10 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
}
}
else if ( ('$'==mms_ref[length_FCDA-2]) && ('t'==mms_ref[length_FCDA-1]) ) {
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20250307
//printf("going t");
if (not_set_log_t_this) {
apr_time_t t = convert_btime6_to_apr_time(&(mms_dec_data.data_item[ii].u.data_bTime6));
if ( log_data_type == QVVR_DATA ) {
@@ -372,6 +445,9 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
}
}
else {
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20250307
//printf("going v");
if ( log_data_type == QVVR_DATA ){
processQVVR_data(loginfo->LD_info,mms_ref,v);
}
@@ -559,9 +635,10 @@ ST_RET mms_jread (loginfo_t *loginfo,MVL_NET_INFO *clientNetInfo, ST_CHAR *dom_n
//start = sGetMsTime();
if ( jread_resp->more_follows == 0 && ((i + 1) == jread_resp->num_of_jou_entry)) {
printf("\njread_resp->more_follows == 0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
json_block_create_end(loginfo->LD_info->mp_id, 0);//more followsΪ0 <20><><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD> ǿ<>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><CCAC><EFBFBD>ݵ<EFBFBD>json<6F><6E>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
json_block_create_end(loginfo->LD_info->mp_id, 1);
json_block_create_end(loginfo->LD_info->mp_id, 2);
//lnk2024-8-16<EFBFBD><EFBFBD><EFBFBD>ӽ<EFBFBD><EFBFBD>߲<EFBFBD><EFBFBD><EFBFBD>
json_block_create_end(loginfo->LD_info->v_wiring_type, loginfo->LD_info->mp_id, 0);//more followsΪ0 <20><><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> ǿ<>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><CCAC><EFBFBD>ݵ<EFBFBD>json<6F><6E>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
json_block_create_end(loginfo->LD_info->v_wiring_type, loginfo->LD_info->mp_id, 1);
json_block_create_end(loginfo->LD_info->v_wiring_type, loginfo->LD_info->mp_id, 2);
ied_t* ied;
ied = find_ied_from_dev_code(loginfo->LD_info->terminal_code);

View File

@@ -56,6 +56,7 @@
#include "rdb_client.h"
#include "db_interface.h"
#include "../json/mms_json_inter.h"
#include "../cfg_parse/custom_printf.h"//lnk20250225
/************************************************************************/
/* For debug version, use a static pointer to avoid duplication of */
/* __FILE__ strings. */
@@ -1058,10 +1059,10 @@ ST_VOID u_iec_rpt_ind_data_by_devtype(MVL_VAR_ASSOC** info_va,
}
else if (('$' == FULL_FCDA_Name[length_FCDA - 2]) && ('t' == FULL_FCDA_Name[length_FCDA - 1])) {
if (not_set_rpt_TimeID_this) {
apr_time_t t = convert_btime6_to_apr_time(&(mms_dec_data.data_item[ii].u.data_bTime6));
apr_time_t t = convert_btime6_to_apr_time(&(mms_dec_data.data_item[ii].u.data_bTime6));//΢<><CEA2>
if (strstr(rcb_info->RptID, "QVVR")) {//CZY 2023-08-17 WW 2022-11-14 <20>޸<EFBFBD><DEB8>ж<EFBFBD>LLN0$BR$brcbQVVR
if (strstr(FULL_FCDA_Name, "VarStr$t")) {
processQVVR_time(LD_info, t / 1000);
processQVVR_time(LD_info, t / 1000);//<2F><><EFBFBD><EFBFBD>
not_set_rpt_TimeID_this = FALSE;
}
}
@@ -1127,13 +1128,13 @@ ST_VOID u_iec_rpt_ind_data_by_devtype(MVL_VAR_ASSOC** info_va,
{
//ied_usr_t* ied_usr = ied->usr_ext;//CZY 2023-08-17 WW 2022<32><32>12<31><32>6<EFBFBD><36>14:09:08 <20><><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>ICD֧<44><D6A7>
//int devkind = ied_usr->dev_flag;
json_block_create_end(LD_info->mp_id, rptinfo->flickerflag);
json_block_create_end(LD_info->v_wiring_type, LD_info->mp_id, rptinfo->flickerflag); //lnk2024-8-16<31><36><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>
}
else if(rptinfo->flickerflag == 0){//CZY 2023-08-17 WW 2022-11-14 <20><><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
if (LD_info->rptRecvFlag == LD_info->rptRecvCheckFlag) {
//ied_usr_t* ied_usr = ied->usr_ext;//CZY 2023-08-17 WW 2022<32><32>12<31><32>6<EFBFBD><36>14:09:08 <20><><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>ICD֧<44><D6A7>
//int devkind = ied_usr->dev_flag;
json_block_create_end(LD_info->mp_id, rptinfo->flickerflag);
json_block_create_end(LD_info->v_wiring_type, LD_info->mp_id, rptinfo->flickerflag); //lnk2024-8-16<31><36><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>
LD_info->rptRecvCheckFlag = 0;
}
}
@@ -1141,7 +1142,7 @@ ST_VOID u_iec_rpt_ind_data_by_devtype(MVL_VAR_ASSOC** info_va,
if (LD_info->rptPstRecvFlag == LD_info->rptPstRecvCheckFlag) {
//ied_usr_t* ied_usr = ied->usr_ext;//CZY 2023-08-17 WW 2022<32><32>12<31><32>6<EFBFBD><36>14:09:08 <20><><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>ICD֧<44><D6A7>
//int devkind = ied_usr->dev_flag;
json_block_create_end(LD_info->mp_id, rptinfo->flickerflag);
json_block_create_end(LD_info->v_wiring_type, LD_info->mp_id, rptinfo->flickerflag); //lnk2024-8-16<31><36><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>
LD_info->rptPstRecvCheckFlag = 0;
}
}
@@ -1522,13 +1523,13 @@ ST_VOID u_iec_rpt_ind_data(MVL_VAR_ASSOC** info_va,
{
//ied_usr_t* ied_usr = ied->usr_ext;//CZY 2023-08-17 WW 2022<32><32>12<31><32>6<EFBFBD><36>14:09:08 <20><><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>ICD֧<44><D6A7>
//int devkind = ied_usr->dev_flag;
json_block_create_end(LD_info->mp_id, rptinfo->flickerflag);
json_block_create_end(LD_info->v_wiring_type, LD_info->mp_id, rptinfo->flickerflag);//lnk<6E><6B><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>
}
else if (rptinfo->flickerflag == 0) {//CZY 2023-08-17 WW 2022-11-14 <20><><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
if (LD_info->rptRecvFlag == LD_info->rptRecvCheckFlag) {
//ied_usr_t* ied_usr = ied->usr_ext;//CZY 2023-08-17 WW 2022<32><32>12<31><32>6<EFBFBD><36>14:09:08 <20><><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>ICD֧<44><D6A7>
//int devkind = ied_usr->dev_flag;
json_block_create_end(LD_info->mp_id, rptinfo->flickerflag);
json_block_create_end(LD_info->v_wiring_type, LD_info->mp_id, rptinfo->flickerflag);//lnk<6E><6B><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>
LD_info->rptRecvCheckFlag = 0;
}
}
@@ -1536,7 +1537,7 @@ ST_VOID u_iec_rpt_ind_data(MVL_VAR_ASSOC** info_va,
if (LD_info->rptPstRecvFlag == LD_info->rptPstRecvCheckFlag) {
//ied_usr_t* ied_usr = ied->usr_ext;//CZY 2023-08-17 WW 2022<32><32>12<31><32>6<EFBFBD><36>14:09:08 <20><><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>ICD֧<44><D6A7>
//int devkind = ied_usr->dev_flag;
json_block_create_end(LD_info->mp_id, rptinfo->flickerflag);
json_block_create_end(LD_info->v_wiring_type, LD_info->mp_id, rptinfo->flickerflag);//lnk<6E><6B><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>
LD_info->rptPstRecvCheckFlag = 0;
}
}
@@ -2154,9 +2155,10 @@ ST_RET u_iec_rpt_ind(MVL_COMM_EVENT* event)
mvl_info_data_to_local(event, va_num, info_va);
//<2F><><EFBFBD><EFBFBD><E6B4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk20250114
pthread_mutex_lock(&mtx);
//pthread_mutex_lock(&mtx); printf("rpt hold lock !!!!!!!!!!!");
u_iec_rpt_ind_data(info_va, OptFldsData, InclusionData, rcb_info, va_total, event->net_info);
pthread_mutex_unlock(&mtx);
//pthread_mutex_unlock(&mtx); printf("rpt free lock !!!!!!!!!!!");
}
CLEANUP:
@@ -2200,6 +2202,9 @@ static ST_RET myLocToTextBs(ST_UCHAR* pSrc, RUNTIME_TYPE* rt, ST_CHAR* text)
ST_CHAR* destBuf;
ST_UCHAR mask;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//printf("pSrc[0]: 0x%X, pSrc[1]: 0x%X, text: %s\n", pSrc[0], pSrc[1], text);
//printf("%s text_len %d %d pSrc %d %d \n", text, strlen(text), rt->u.p.el_len, pSrc[0], pSrc[1]);
text[0] = 0;
@@ -2241,6 +2246,10 @@ static ST_RET myLocToTextBs(ST_UCHAR* pSrc, RUNTIME_TYPE* rt, ST_CHAR* text)
}
}
destBuf[i] = 0;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//printf("pSrc[0]: 0x%X, pSrc[1]: 0x%X, text: %s\n", pSrc[0], pSrc[1], text);
return (SD_SUCCESS);
}
/************************************************************************/
@@ -2451,7 +2460,7 @@ void my_local_to_data(ST_CHAR* datptr, SD_CONST RUNTIME_TYPE* rt_head,
break;
case RT_BIT_STRING:
myLocToTextBs((ST_UCHAR*)datptr, rt_ptr, tmpBuf);
myLocToTextBs((ST_UCHAR*)datptr, rt_ptr, tmpBuf);//<2F><><EFBFBD><EFBFBD><E6B4A2><EFBFBD>ڴ<EFBFBD><DAB4>еı<D0B5><C4B1>ش<EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD><CEAA>Ӧ<EFBFBD><D3A6><EFBFBD>ı<EFBFBD><C4B1>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD> '1' <20><> '0' <20><><EFBFBD>ɣ<EFBFBD>
strcpy(data->data_item[valid_item_num].comp_name, (const char*)attr_str);
data->data_item[valid_item_num].size = abs(rt_ptr->u.p.el_len);
data->data_item[valid_item_num].type = DATA_STR_TYPE;

View File

@@ -79,7 +79,7 @@
#include "../mms/db_interface.h"
#include <ctype.h> //lnk20241119
#include "../cfg_parse/custom_printf.h"//lnk20250225
extern uint32_t g_node_id;
extern char subdir[128];
unsigned int g_no_auth = 0;
@@ -1176,8 +1176,7 @@ S_SEC_ENCRYPT_CTRL *encryptCtrl = NULL; /* conn enctryption info */
//lnk20241119<31><39><EFBFBD><EFBFBD><EFBFBD>жϺʹ<CFBA>ӡ<EFBFBD><D3A1>ȷ<EFBFBD><C8B7>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԿΪ<D4BF><CEAA>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><C3BC><EFBFBD>
if (!is_empty_or_whitespace(dev_series) || !is_empty_or_whitespace(dev_key)) {
printf("dev_series= %s\n", dev_series);
printf("dev_key= %s\n", dev_key);
printf("dev_series= %s,dev_key= %s\n", dev_series,dev_key);
/* Fill out an authentication structure */
authInfo = &authInfoStr;
authInfo->auth_pres = SD_TRUE;

View File

@@ -195,7 +195,7 @@
#include "mvl_log.h"
#include "mloguser.h"
#include "mmsop_en.h"
#include "../cfg_parse/custom_printf.h"//lnk20250225
#if defined(MAP30_ACSE)
#include "suicacse.h"

View File

@@ -12,7 +12,7 @@
#include <string.h>
#include "rdb_client.h"
#include "xmltools.h"
#include "../cfg_parse/custom_printf.h"//lnk20250225
//int comtrade_remain_file_num = 2147483647;
int comtrade_remain_file_num = 0;
@@ -97,6 +97,8 @@ apr_status_t app_get_private_config(const char *myfilename)
<!-- װ<><D7B0>ID,CPUID,ReportCtrlNum -->
<ReportControlCount>104,1,2</ReportControlCount>
*/
//lnk20250122start
#if 0
int init_rptctrl_by_count(LD_info_t* LD_info,int rptcount)
{
int j,i;
@@ -117,6 +119,37 @@ int init_rptctrl_by_count(LD_info_t* LD_info,int rptcount)
return 0;
}
#endif
#define MAX_RPT_COUNT 20
int init_rptctrl_by_count(LD_info_t* LD_info,int rptcount)
{
int j,i;
LD_info->rptcount = rptcount;
if(LD_info->rptinfo == NULL){ //<2F><><EFBFBD><EFBFBD><EFBFBD>ǿյ<C7BF>˵<EFBFBD><CBB5><EFBFBD>ǵ<EFBFBD>һ<EFBFBD>γ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ռ䣬ֱ<E4A3AC>Ӹ<EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>20<32><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD><CCA8>ɾ<EFBFBD><C9BE>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD>¸<EFBFBD>ֵ
LD_info->rptinfo = apr_pcalloc( g_init_pool,MAX_RPT_COUNT*sizeof(rptinfo_t*) );
}
for(j=0; j<rptcount; j++) {
if(LD_info->rptinfo[j] == NULL){//<2F><><EFBFBD><EFBFBD><EFBFBD>ǿյ<C7BF>˵<EFBFBD><CBB5><EFBFBD>ǵ<EFBFBD>һ<EFBFBD>γ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ռ<D5BC><E4A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD>Ŀռ䣬ֱ<E4A3AC>ӽ<EFBFBD><D3BD><EFBFBD>ֵ<EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC>
LD_info->rptinfo[j] = apr_pcalloc( g_init_pool,sizeof(rptinfo_t) );
}
LD_info->rptinfo[j]->LD_info = LD_info;
LD_info->rptinfo[j]->m_LastRegisterFailedTime = sGetMsTime() -10*60*1000;
LD_info->rptinfo[j]->m_LastUnRegisterFailedTime = sGetMsTime() -10*60*1000;
LD_info->rptinfo[j]->IntgPd = 60;
LD_info->rptinfo[j]->m_rcb_info = NULL;
LD_info->rptinfo[j]->rpt_registered = FALSE;
LD_info->rptinfo[j]->m_curRptSuffix = -1;
for(i=0; i<8; i++)
LD_info->rptinfo[j]->m_EntryID[i] = 0xff;
}
return 0;
}
//lnk20250122end
//ReportControl: װ<><D7B0>ID,CPUID,ID,RCBName, intgPd, dchg, qchg, dupd, period ,gi, ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>Ӻ<EFBFBD>׺,<2C><>
// seqNum, timeStamp, reasonCode, dataSet, dataRef, bufOvfl, entryID, configRef, segmentation
@@ -218,6 +251,9 @@ int fill_rptctrl_by_cfg(LD_info_t* LD_info,int rptno,char *buf)
<!-- װ<><D7B0>ID,CPUID,LogCtrlNum -->
<LogControlCount>104,1,2</LogControlCount>
*/
//lnk20250122start
#if 0
int init_logctrl_by_count(LD_info_t* LD_info,int logcount)
{
int j;
@@ -233,6 +269,31 @@ int init_logctrl_by_count(LD_info_t* LD_info,int logcount)
return 0;
}
#endif
#define MAX_LOG_COUNT 20
int init_logctrl_by_count(LD_info_t* LD_info,int logcount)
{
int j;
LD_info->logcount = logcount;
if(LD_info->loginfo == NULL){
LD_info->loginfo = apr_pcalloc(g_init_pool, MAX_LOG_COUNT * sizeof(loginfo_t*)); //new loginfo_t*[logcount];
}
for(j=0; j<logcount; j++) {
if(LD_info->loginfo[j] == NULL){
LD_info->loginfo[j] = apr_pcalloc(g_init_pool, sizeof(loginfo_t));//new loginfo_t[1];
}
LD_info->loginfo[j]->LD_info = LD_info;
LD_info->loginfo[j]->IntgPd = 600;
//LD_info->loginfo[j]->m_lcb_info = NULL;
}
return 0;
}
//lnk20250122end
//<!--LogControl:IEDID,CPUID,ID,LCBName,DatasetName,LogName,reasonCode,intgPd,dchg,qchg,dupd,period -->
// <LogControl>106,2,1,LLN0$LG$lcStatisticData,dsStatisticData,PQM1,0,600000,1,0,0,0</LogControl>

View File

@@ -24,6 +24,7 @@ extern int g_front_seg_index;
extern int g_front_seg_num;
#include "../include/rocketmq/SimpleProducer.h"
#include "../cfg_parse/custom_printf.h"//lnk20250225
////////////////////////////////////////////
#ifdef DEBUG_SISCO
SD_CONST static ST_CHAR* SD_CONST thisFileName = __FILE__;
@@ -255,6 +256,11 @@ apr_status_t run_protocol()
// apr_thread_t* mms_thread;
static apr_threadattr_t* worker_attr = NULL;
//lnk20250214//<2F><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD>̺<EFBFBD>0<EFBFBD><30>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>̨<EFBFBD>ˣ<EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD>ٸ<EFBFBD><D9B8><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC>Ľ<EFBFBD><C4BD>̺<EFBFBD>
if (g_onlyIP[0] != 0 && g_front_seg_index == 0 && g_front_seg_num >= 10){ //<2F><><EFBFBD><EFBFBD>web<65>˿<EFBFBD><CBBF>ƴ򿪵ĵ<F2BFAAB5><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
g_front_seg_index = g_front_seg_num; //<2F><><EFBFBD>½<EFBFBD><C2BD>̺<EFBFBD>Ϊ<EFBFBD><CEAA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õĽ<C3B5><C4BD>̺ţ<CCBA><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵʱ<CAB5><CAB1>־
}
init_MMS();
if (worker_attr == NULL)
@@ -274,7 +280,7 @@ apr_status_t run_protocol()
if ((rv = apr_thread_create(&rtdb_thread, worker_attr, rtdb_worker, NULL, g_run_pool)) != APR_SUCCESS)
return rv;
try_start_kafka_thread();
try_start_kafka_thread();//mq<6D>߳<EFBFBD>
//lnk20241213<31><33><EFBFBD><EFBFBD>mq<6D><71><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
try_start_mqconsumer_thread();
@@ -283,11 +289,14 @@ apr_status_t run_protocol()
if (g_onlyIP[0] != 0 || g_node_id == NEW_HIS_DATA_BASE_NODE_ID || g_node_id == HIS_DATA_BASE_NODE_ID || g_node_id == RECALL_ALL_DATA_BASE_NODE_ID)
{
printf("g_onlyIP[0] != 0!\n\a");
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̲<EFBFBD><CCB2><EFBFBD><EFBFBD><EFBFBD>socket<65><74>http<74>߳<EFBFBD>
}
else
else //socket<65><74>http<74><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵߳Ŀ<CCB5><C4BF><EFBFBD>
{
printf("g_onlyIP[0] == 0!\n\a");
if(1 == SOCKETENABLE)
if (1 == SOCKETENABLE)
{
server_socket = socket(AF_INET, SOCK_STREAM, 0);
if (server_socket == -1) {
@@ -332,7 +341,8 @@ apr_status_t run_protocol()
printf("try_start_socket_thread \n");
try_start_socket_thread();
}
if(HTTPENABLE)
if (1 == HTTPENABLE)
{
//lnk20241029<32><39><EFBFBD><EFBFBD>http<74>߳<EFBFBD>///////////////////////////////////////////////////////////////////////////////////////////////
if (g_node_id == STAT_DATA_BASE_NODE_ID)//ͳ<>Ʋɼ<C6B2>
@@ -352,32 +362,23 @@ apr_status_t run_protocol()
try_start_http_thread();
//lnk20241029<32><39><EFBFBD><EFBFBD>http<74>߳<EFBFBD>///////////////////////////////////////////////////////////////////////////////////////////////////
}
}
if (1 == G_TEST_FLAG) {
//lnk<6E><6B><EFBFBD><EFBFBD>mqģ<71><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
printf("try_start_mqtest_thread \n");
try_start_mqtest_thread(0,NULL);
}
//lnkɾ<6B><C9BE><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>߳<EFBFBD>
#if 0
if (1 == g_iOTLFlag) {
printf("try_start_sql_thread \n");
try_start_sql_thread();
}
else
printf("sql_thread ignore \n");
#endif
printf("try_start_ontimer_thread \n");
try_start_ontimer_thread();
//OTLTestSelect();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>
///////////////////WW end
return APR_SUCCESS;
}
@@ -393,32 +394,41 @@ static void* APR_THREAD_FUNC rtdb_worker(apr_thread_t* thd, void* data)
/* Maintenance the clients request */
while (1) {
/*<2A><><EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>rocketmq<6D><71>Ϣ lnk10-10*/
//producer_send0();
//pthread_mutex_lock(&mtx); printf("work hold lock !!!!!!!!!!!");
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//printf("check error4 !!!!!!!!!!!!!!\n");
doCommService();//<2F><><EFBFBD><EFBFBD>61850<35><30>Ϣ
check_3s_config();//3<><33><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD>̶<EFBFBD>ȡ3<C8A1><EFBFBD><EBB4A5>
pthread_mutex_lock(&mtx);
//pthread_mutex_lock(&mtx); printf("check connect hold lock !!!!!!!!!!!");
CheckNextNotConnectedChannel();//<2F><><EFBFBD>г<EFBFBD><D0B3><EFBFBD><EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>״̬
pthread_mutex_unlock(&mtx);
//pthread_mutex_unlock(&mtx); printf("check connect free lock !!!!!!!!!!!");
pthread_mutex_lock(&mtx);
//pthread_mutex_lock(&mtx); printf("check prt hold lock !!!!!!!!!!!");
CheckAllConnectedChannel();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6A1A2>־<EFBFBD><D6BE><EFBFBD>١<EFBFBD><D9A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pthread_mutex_unlock(&mtx);
//pthread_mutex_unlock(&mtx); printf("check prt free lock !!!!!!!!!!!");
//check_recall_config();//<2F><><EFBFBD>ٽ<EFBFBD><D9BD>̶<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
create_recall_xml();//<2F><><EFBFBD>ɴ<EFBFBD><C9B4><EFBFBD><EFBFBD><EFBFBD>xml<6D>ļ<EFBFBD>
pthread_mutex_lock(&mtx); //printf("work hold lock !!!!!!!!!!!");
check_ledger_update();//lnk20250113<31><33>ȡ̨<C8A1>˸<EFBFBD><CBB8>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD>˸<EFBFBD><CBB8><EFBFBD>
pthread_mutex_unlock(&mtx); //printf("work free lock !!!!!!!!!!!");
//Check_Recall_Config();
/*if ((g_protect_file) && (g_pt61850app->initNum>=MIN_INIT_NUM) ) {
tryCallWaveList_in_AllIeds();
}*/
//clear_old_comtrade_files();
check_disk_quota();//<2F>жϴ<D0B6><CFB4>̿ռ<CCBF>
apr_pool_clear(g_pt61850app->tmp_pool);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
g_dead_lock_counter = 0;
g_thread_blocked_times = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
}

View File

@@ -68,6 +68,10 @@ CHECK_NOTHING CHECK_SYN
#define DEFAULT_EDIT_FXDAREANO (0x80FE) /**< Ĭ<>ϱ<CFB1><E0BCAD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD> */
#define FIXED_AREA_GRP_DOT2_EDIT_AREA (2) /**< <20><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>-><3E><EFBFBD><E0BCAD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD> */
//lnk<6E><6B><EFBFBD><EFBFBD>ʹ<EFBFBD>ܱ<EFBFBD>־20250121
#define ENABLE 1
#define UNUSED 0
extern unsigned int g_node_id;
typedef struct element_usr_t element_usr_t;
@@ -93,7 +97,7 @@ struct ied_info_t{
char value[50][20];
};
//lnk20250113<31><33><EFBFBD><EFBFBD>̨<EFBFBD>˸<EFBFBD><CBB8>½ṹ///////////////////////////////
#define MAX_UPDATEA_NUM 300
#define MAX_UPDATEA_NUM 10
typedef struct trigger_update_xml_t trigger_update_xml_t;
struct trigger_update_xml_t{
int work_update_num;
@@ -228,8 +232,8 @@ struct QVVR_t{
int QVVR_start;
int QVVR_type;
long long QVVR_time;
float QVVR_PerTime;
float QVVR_Amg;
double QVVR_PerTime;
double QVVR_Amg;
char QVVR_Rptname[128];
uint32_t timestamp;
@@ -323,6 +327,7 @@ struct ied_usr_t{
char terminal_code[256];//CZY 2023-08-30 <20>ն˱<D5B6><CBB1><EFBFBD>
int update_flag;//CZY 2023-08-20 ̨<>˸<EFBFBD><CBB8>±<EFBFBD>־ 0:keep 2:delete 4:update 8:add
char processNo[64];//̨<>˽<EFBFBD><CBBD>̺<EFBFBD>
};
@@ -463,11 +468,21 @@ LD_info_t* find_LD_info_only_from_mp_id(char* mp_id);
////////////////////////////////lnk20250115
int parse_ledger_update_xml(trigger_update_xml_t* trigger_update_xml);
extern const int MAX_CPUNO;
extern int stringToInt(const char* str, int* result);
extern bool isCharPtrEmpty(const char* str);
extern int parse_ledger_update_xml(trigger_update_xml_t* trigger_update_xml);
extern int update_one_terminal_ledger(terminal* update, int i,ied_t* ied,int terminal_index);
extern void print_trigger_update_xml(const trigger_update_xml_t* trigger_update);
int stringToInt(const char* str, int* result);
bool isCharPtrEmpty(const char* str);
int parse_ledger_update_xml(trigger_update_xml_t* trigger_update_xml);
int update_one_terminal_ledger(terminal* update, int i,ied_t* ied,int terminal_index,int ied_take);
void print_trigger_update_xml(const trigger_update_xml_t* trigger_update);
char* parse_model_cfg_web_one(ied_t* ied);
void Set_xml_nodeinfo_one(char* dev_type);
void create_ledger_log(trigger_update_xml_t* ledger_update_xml);
ied_t* find_ied_unused();
int parse_rpt_log_ini_one(ied_t* ied);
apr_status_t init_rem_dib_table_one(ied_t *ied);
void clearIed(ied_t *ied);
void clearIedUsr(ied_usr_t *ied_usr);
////////////////////////////////
int parse_3s_xml(trigger_3s_xml_t* trigger_3s_xml);
int create_3s_xml(trigger_3s_xml_t* trigger_3s_xml);

View File

@@ -13,6 +13,7 @@
#include "rdb_client.h"
#include "xmltools.h"
#include "db_interface.h"
#include "../cfg_parse/custom_printf.h"//lnk20250225
//extern rdb_t* g_rdb ;
extern node_t* g_node ;
extern char g_my_conf_fname[256];
@@ -308,6 +309,21 @@ ied_t* find_ied_from_terminal_id(char terminal_id[])
}
return NULL;
}
//lnk20250121<32>Ҳ<EFBFBD>ʹ<EFBFBD>õ<EFBFBD>ied<65>ռ<EFBFBD>
ied_t* find_ied_unused()
{
ied_t* ied_find_unused = NULL;
int iedno;
ied_usr_t* ied_usr_find_unused = NULL;
for (iedno = 0; iedno < g_node->n_clients; iedno++) {
ied_find_unused = g_node->clients[iedno];
ied_usr_find_unused = (ied_usr_t*)ied_find_unused->usr_ext;
if (ied_usr_find_unused && ied_usr_find_unused->dev_flag == UNUSED) {
return ied_find_unused;//<2F>ҵ<EFBFBD><D2B5><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>
}
}
return NULL;
}
LD_info_t* find_LD_info_from_line_id(ied_t* ied, int line_id)
{
@@ -471,16 +487,18 @@ void processQVVR_data(LD_info_t* LD_info,char* FULL_FCDA_Name,double v)
LD_info->qvvr[LD_info->qvvr_idx].QVVR_start = (v>0.99) ? 1:0;
}
else if ( strstr(FULL_FCDA_Name,"VVaTm$mag$f") )
LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime = v;
LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime = (float)v;
else if ( strstr(FULL_FCDA_Name,"VVa$mag$f") )
LD_info->qvvr[LD_info->qvvr_idx].QVVR_Amg = v;
LD_info->qvvr[LD_info->qvvr_idx].QVVR_Amg = (float)v;
else {
if ( strstr(FULL_FCDA_Name,"DipStr$stVal") && (v>0.99) ) //<2F><>ѹ<EFBFBD>ݽ<EFBFBD>
LD_info->qvvr[LD_info->qvvr_idx].QVVR_type = 1;
LD_info->qvvr[LD_info->qvvr_idx].QVVR_type = 1210002;//<2F><><EFBFBD>սӿ<D5BD><D3BF>޸<EFBFBD>
else if ( strstr(FULL_FCDA_Name,"SwlStr$stVal") && (v>0.99) ) //<2F><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>
LD_info->qvvr[LD_info->qvvr_idx].QVVR_type = 2;
LD_info->qvvr[LD_info->qvvr_idx].QVVR_type = 1210001;
else if ( strstr(FULL_FCDA_Name,"IntrStr$stVal") && (v>0.99) ) //<2F><>ѹ<EFBFBD>ж<EFBFBD>
LD_info->qvvr[LD_info->qvvr_idx].QVVR_type = 3;
LD_info->qvvr[LD_info->qvvr_idx].QVVR_type = 1210004;
}
if (strstr(FULL_FCDA_Name, "QVVR")) {
@@ -498,16 +516,7 @@ void processQVVR_end(LD_info_t* LD_info)
ied_t *ied = LD_info->ied;
ied_usr_t *ied_usr = GET_IEDEXT_ADDR(ied);
int ret;
long long end_tm = (long long)(LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime*1000) + LD_info->qvvr[LD_info->qvvr_idx].QVVR_time; //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>dz<EFBFBD><C7B3><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>ʱ<EFBFBD><CAB1>
ret = transfer_json_qvvr_data(g_node_id, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ʹ<EFBFBD><CAB9>
LD_info->line_id, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LD_info->qvvr[LD_info->qvvr_idx].QVVR_Amg, LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime, LD_info->qvvr[LD_info->qvvr_idx].QVVR_time, end_tm, LD_info->qvvr[LD_info->qvvr_idx].QVVR_type, //<2F><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A1A2>ʼʱ<CABC><EFBFBD><E4A1A2><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A1A2>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
"", "", //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>Ϊ<EFBFBD><CEAA>
LD_info->mp_id, LD_info->qvvr[LD_info->qvvr_idx].QVVR_Rptname, ied_usr->dev_type);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3>ļ<EFBFBD><C4BC>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD>¼<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD>
if(!ret)//ʧ<><CAA7>
{
printf("\n~~~~~~~~~~~~~~~~~ QVVR_json_data send error: line_id=%d \n",LD_info->line_id);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
int find_paired = FALSE;
@@ -517,12 +526,47 @@ void processQVVR_end(LD_info_t* LD_info)
return;
for (i=0;i<QVVR_NUM;i++) { //<2F>ݽ<EFBFBD>/<2F><><EFBFBD><EFBFBD>/<2F>жϵȽ<CFB5><C8BD><EFBFBD><EBB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD>λ<EFBFBD><CEBB>
if (i==LD_info->qvvr_idx) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㵱ǰ<E3B5B1><C7B0><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
if (i==LD_info->qvvr_idx) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㵱ǰ<E3B5B1><C7B0><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>,<2C><>һ<EFBFBD>μ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>κ󣬵<CEBA>һ<EFBFBD>εĵ<CEB5><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD>ŵ<EFBFBD>ΪQVVR_DATA_RECEIVED<45><44>
//<2F>ڶ<EFBFBD><DAB6>μ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>Σ<EFBFBD><CEA3>ڶ<EFBFBD><DAB6>εĵ<CEB5>һ<EFBFBD><D2BB><EFBFBD>¼<EFBFBD>qvvr_idx=1<><31>1<EFBFBD><31><EFBFBD><EFBFBD>ΪQVVR_DATA_RECEIVED<45><44>QVVR_start=1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>
//<2F>ڶ<EFBFBD><DAB6>εĵڶ<C4B5><DAB6><EFBFBD><EFBFBD>¼<EFBFBD>qvvr_idx=1<><31>QVVR_start=0<><30><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>0<EFBFBD>У<EFBFBD>0ΪQVVR_DATA_PAIRED
//<2F>ڶ<EFBFBD><DAB6>εĵ<CEB5><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>qvvr_idx=2<><32>2<EFBFBD><32><EFBFBD><EFBFBD>ΪQVVR_DATA_RECEIVED<45><44>QVVR_start=1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼
//<2F>ڶ<EFBFBD><DAB6><EFBFBD>¼<EFBFBD><C2BC>ƥ<EFBFBD><C6A5><EFBFBD>ļ<EFBFBD>ʱӦ<CAB1><D3A6>ƥ<EFBFBD>䵽1<E4B5BD>ŵ<EFBFBD>qvvrtime<6D><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><31><C3BB>QVVR_DATA_PAIRED<45><44><EFBFBD>ԶԲ<D4B6><D4B2>ϣ<EFBFBD><CFA3><EFBFBD>Ҫ<EFBFBD>޸<EFBFBD><DEB8>߼<EFBFBD>
continue;
if (LD_info->qvvr[i].used_status != QVVR_DATA_RECEIVED)//<2F><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
continue;
//<2F><><EFBFBD><EFBFBD>ijλ<C4B3>õIJ<C3B5><C4B2><EFBFBD>Ҳû<D2B2>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD>λ<EFBFBD>õIJ<C3B5><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͺ͵<CDBA>ǰλ<C7B0>õIJ<C3B5><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ж<EFBFBD>lnk20250311
if (fabs((LD_info->qvvr[LD_info->qvvr_idx].QVVR_time - LD_info->qvvr[i].QVVR_time)/1.0
- LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime) > 1.0){
printf("~~~~~~~fail in pair qvvr node %f~~~~~~~~~~ \n",fabs((LD_info->qvvr[LD_info->qvvr_idx].QVVR_time - LD_info->qvvr[i].QVVR_time)/1.0
- LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime));
continue;
}
//<2F><><EFBFBD><EFBFBD>ijλ<C4B3>õIJ<C3B5><C4B2><EFBFBD>Ҳû<D2B2>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD>λ<EFBFBD>õIJ<C3B5><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͺ͵<CDBA>ǰλ<C7B0>õIJ<C3B5><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>£<EFBFBD><C2A3>ݽ<EFBFBD><DDBD>¼<EFBFBD>һ<EFBFBD>λᷢ<CEBB><E1B7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ͽ<EFBFBD><CDBD><EFBFBD>
if ( (LD_info->qvvr[i].QVVR_type==0)||(LD_info->qvvr[i].QVVR_type==LD_info->qvvr[LD_info->qvvr_idx].QVVR_type) ) {
long long end_tm = (long long)(LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime*1000) + LD_info->qvvr[i].QVVR_time;//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>dz<EFBFBD><C7B3><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A3AC><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//printf("~~~~~~~this qvvr node type before record is %d~~~~~~~~~~ \n",LD_info->qvvr[i].QVVR_type);
//printf("~~~~~~~this qvvr node QVVR_PerTime before record is %f~~~~~~~~~~ \n",LD_info->qvvr[i].QVVR_PerTime);
//printf("~~~~~~~this qvvr node QVVR_Amg before record is %f~~~~~~~~~~ \n",LD_info->qvvr[i].QVVR_Amg);
//printf("~~~~~~~this qvvr node QVVR_time before record is %lld~~~~~~~~~~ \n",LD_info->qvvr[i].QVVR_time);
//printf("~~~~~~~this qvvr node used_status before record is %d~~~~~~~~~~ \n",LD_info->qvvr[i].used_status);
//printf("~~~~~~~this qvvr node QVVR_start before record is %d~~~~~~~~~~ \n",LD_info->qvvr[i].QVVR_start);
//printf("~~~~~~~this qvvr node timestamp before record is %d~~~~~~~~~~ \n",LD_info->qvvr[i].timestamp);
printf("\n~~~~~~~now qvvr node type before record is %d~~~~~~~~~~ \n",LD_info->qvvr[LD_info->qvvr_idx].QVVR_type);
printf("~~~~~~~now qvvr node QVVR_PerTime before record is %f~~~~~~~~~~ \n",LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime);
printf("~~~~~~~now qvvr node QVVR_Amg before record is %f~~~~~~~~~~ \n",LD_info->qvvr[LD_info->qvvr_idx].QVVR_Amg);
printf("~~~~~~~now qvvr node QVVR_time before record is %lld~~~~~~~~~~ \n",LD_info->qvvr[LD_info->qvvr_idx].QVVR_time);
printf("~~~~~~~now qvvr node used_status before record is %d~~~~~~~~~~ \n",LD_info->qvvr[LD_info->qvvr_idx].used_status);
printf("~~~~~~~now qvvr node QVVR_start before record is %d~~~~~~~~~~ \n",LD_info->qvvr[LD_info->qvvr_idx].QVVR_start);
printf("~~~~~~~now qvvr node timestamp before record is %d~~~~~~~~~~ \n",LD_info->qvvr[LD_info->qvvr_idx].timestamp);
LD_info->qvvr[i].used_status = QVVR_DATA_PAIRED; //ƥ<><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LD_info->qvvr[i].QVVR_type = LD_info->qvvr[LD_info->qvvr_idx].QVVR_type;
LD_info->qvvr[i].QVVR_PerTime = LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime;
@@ -530,6 +574,36 @@ void processQVVR_end(LD_info_t* LD_info)
LD_info->qvvr[LD_info->qvvr_idx].used_status = QVVR_DATA_NOT_USED; //<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ͷ<EFBFBD>
find_paired = TRUE;
printf("~~~~~~~this qvvr node QVVR_PerTime after record is %f~~~~~~~~~~ \n",LD_info->qvvr[i].QVVR_PerTime);
printf("~~~~~~~this qvvr node QVVR_Amg after record is %f~~~~~~~~~~ \n",LD_info->qvvr[i].QVVR_Amg);
printf("~~~~~~~this qvvr node used_status after record is %d~~~~~~~~~~ \n",LD_info->qvvr[i].used_status);
printf("~~~~~~~this qvvr node QVVR_type after record is %d~~~~~~~~~~ \n",LD_info->qvvr[i].QVVR_type);
printf("~~~~~~~this qvvr node QVVR_time after record is %lld~~~~~~~~~~ \n",LD_info->qvvr[i].QVVR_time);
printf("~~~~~~~this qvvr node timestamp before record is %d~~~~~~~~~~ \n",LD_info->qvvr[i].timestamp);
printf("~~~~~~~this qvvr node QVVR_start before record is %d~~~~~~~~~~ \n",LD_info->qvvr[i].QVVR_start);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//printf("\n~~~~~~~qvvr node %d status is pair~~~~~~~~~~ \n",i);
//printf("Before calling: &QVVR_Amg = %p, &QVVR_PerTime = %p\n",
//&LD_info->qvvr[LD_info->qvvr_idx].QVVR_Amg,
//&LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime);
//ƥ<><C6A5><EFBFBD><EFBFBD><EFBFBD>ٷ<EFBFBD>qvvr<76><72><EFBFBD><EFBFBD>ʼʱ<CABC><CAB1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A3AC><EFBFBD>ǵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ʱֻ<CAB1><D6BB>ʱ<EFBFBD><CAB1>û<EFBFBD><C3BB>ֵ<EFBFBD><D6B5><EFBFBD>Ǹ<EFBFBD>ʱ<EFBFBD><CAB1>
ret = transfer_json_qvvr_data(g_node_id, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ʹ<EFBFBD><CAB9>
LD_info->line_id, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
(double)LD_info->qvvr[LD_info->qvvr_idx].QVVR_Amg,
(double)LD_info->qvvr[LD_info->qvvr_idx].QVVR_PerTime,
LD_info->qvvr[i].QVVR_time,
end_tm,
LD_info->qvvr[LD_info->qvvr_idx].QVVR_type, //<2F><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A1A2>ʼʱ<CABC><EFBFBD><E4A1A2><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A1A2>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>
"", "", //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>Ϊ<EFBFBD><CEAA>
LD_info->mp_id, LD_info->qvvr[LD_info->qvvr_idx].QVVR_Rptname, ied_usr->dev_type);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3>ļ<EFBFBD><C4BC>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD>¼<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD>
if(!ret)//ʧ<><CAA7>
{
printf("\n~~~~~~~~~~~~~~~~~ QVVR_json_data send error: line_id=%d \n",LD_info->line_id);
}
break;
}
}
@@ -562,13 +636,18 @@ QVVR_t* find_qvvr_by_trig_tm(LD_info_t* LD_info, long long trig_tm)
// <20><><EFBFBD>㵱ǰ QVVR <20><><EFBFBD>ݵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB4A5>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>
diff = abs(LD_info->qvvr[i].QVVR_time - trig_tm);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
printf("QVVRTIME:%lld >>>>> COMTRADE trig_tm:%lld >>>>> diff:%lld\n",LD_info->qvvr[i].QVVR_time,trig_tm,diff);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> QVVR <20><><EFBFBD>ݵ<EFBFBD>״̬<D7B4><CCAC> "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<22><>QVVR_DATA_PAIRED<45><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>С<EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD> 1<><31><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>
if ((LD_info->qvvr[i].used_status == QVVR_DATA_PAIRED) && (diff <= 1)) {
// <20><><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><E4A3AC><EFBFBD>ظ<EFBFBD> QVVR <20><><EFBFBD>ݵ<EFBFBD>ָ<EFBFBD><D6B8>
printf(">>>>> pair QVVR success>>>>>> \n");
return &(LD_info->qvvr[i]);
}
}
printf(">>>>> pair QVVR fail>>>>>> \n");
// <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ҵ<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD> QVVR <20><><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD> NULL
return NULL;
}

View File

@@ -2,6 +2,7 @@
#ifndef VER_CONF_H_KHCYDOPFRUYDIYFIHUIVUGUGG
#define VER_CONF_H_KHCYDOPFRUYDIYFIHUIVUGUGG
#include "stdio.h"
#include "../cfg_parse/custom_printf.h"//lnk20250225
const char* PROGRAM_VERSION = "1.0.2.7";
const char* PROGRAM_CREATE_TIME="2024-09-18";

BIN
pt61850netd_pqfe Normal file

Binary file not shown.

View File

@@ -14,6 +14,20 @@ 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 编译选项配置
CONFIG(debug, debug|release) {
message("Building debug version with debug symbols")
# 强制生成调试信息并禁用优化
QMAKE_CFLAGS_DEBUG += -g -O0
QMAKE_CXXFLAGS_DEBUG += -g -O0
CONFIG += force_debug_info
} else {
message("Building release version")
# release 通常开启优化
QMAKE_CFLAGS_RELEASE += -O2
QMAKE_CXXFLAGS_RELEASE += -O2
}
win32 {
DEFINES -= UNICODE
DEFINES += _AFXDLL
@@ -109,7 +123,8 @@ HEADERS += source/mms/db_interface.h \
source/json/rdkafkacpp.h \
source/json/kafka_producer.h \
source/json/cjson.h \
source/include/rocketmq/SimpleProducer.h
source/include/rocketmq/SimpleProducer.h \
source/cfg_parse/custom_printf.h
SOURCES += source/mms/main.c \
source/mms/clntobj.c \
source/mms/logcfgx.c \

BIN
pt61850netd_pqfed Normal file

Binary file not shown.