delete useless code
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
/*
|
||||
* Description: Simple Producer demo
|
||||
*/
|
||||
#include <fstream> // 用于 std::ifstream
|
||||
#include <sstream> // 用于 std::stringstream
|
||||
#include <unistd.h>
|
||||
@@ -12,7 +9,6 @@
|
||||
#include "../include/rocketmq/CProducer.h"
|
||||
#include "../include/rocketmq/CMessage.h"
|
||||
#include "../include/rocketmq/CSendResult.h"
|
||||
|
||||
#include "../include/rocketmq/SimpleProducer.h"
|
||||
|
||||
//测试300数据用lnk20241202
|
||||
@@ -135,13 +131,7 @@ 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) {//记录消费日志
|
||||
@@ -365,7 +355,6 @@ void rocketmq_consumer_receive(
|
||||
}
|
||||
}
|
||||
|
||||
// 消费逻辑已通过回调处理,无需额外操作
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//封装生产者类
|
||||
@@ -465,19 +454,6 @@ public:
|
||||
RoundRobinSelector, // 队列选择器回调函数
|
||||
&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.topic:" << topic <<std::endl;
|
||||
@@ -579,56 +555,6 @@ void rocketmq_producer_send(const char* strbody, const char* topic)
|
||||
}
|
||||
#endif
|
||||
|
||||
//lnk20241209队列轮询
|
||||
#if 0
|
||||
// 全局或静态变量,用于维护当前队列索引
|
||||
static int currentQueueId = 0;
|
||||
|
||||
// 队列选择器回调函数:轮询选择队列 ID
|
||||
int RoundRobinSelector(int queueNum, CMessage* msg, void* arg) {
|
||||
if (queueNum == 0) {
|
||||
throw std::runtime_error("No available queues");
|
||||
}
|
||||
// 选择当前队列 ID,并更新索引
|
||||
int queueId = currentQueueId % queueNum;
|
||||
currentQueueId++;
|
||||
// 防止溢出,重置索引
|
||||
if (currentQueueId >= 1024 - queueNum) {
|
||||
currentQueueId = 0;
|
||||
}
|
||||
return queueId;
|
||||
}
|
||||
void StartSendMessage_queue(CProducer* producer, const char* strbody, const char* topic)
|
||||
{
|
||||
CSendResult result;
|
||||
|
||||
// 创建消息并设置一些属性
|
||||
CMessage* msg = CreateMessage(topic);
|
||||
SetMessageTags(msg, G_ROCKETMQ_TAG.c_str());
|
||||
SetMessageKeys(msg, G_ROCKETMQ_KEY.c_str());
|
||||
SetMessageBody(msg, strbody);
|
||||
|
||||
// 动态获取队列数量和 Broker 名称
|
||||
int queueNum = QUEUENUM; // 假设这个是配置的队列数量,比如5
|
||||
|
||||
// 使用 SendMessageOnewayOrderly 发送消息,传递回调函数
|
||||
int sendResult = SendMessageOnewayOrderly(
|
||||
producer,
|
||||
msg,
|
||||
RoundRobinSelector, // 传递符合 QueueSelectorCallback 签名的函数
|
||||
&queueNum // 传递给选择器的额外参数(队列数量)
|
||||
);
|
||||
|
||||
if (sendResult == 0) { // 假设返回 0 表示成功
|
||||
std::cout << "Message sent successfully: " << std::endl;
|
||||
} else {
|
||||
std::cout << "Failed to send message: " << std::endl;
|
||||
}
|
||||
|
||||
// 销毁消息
|
||||
DestroyMessage(msg);
|
||||
}
|
||||
#endif
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// producer_send0测试用
|
||||
void StartSendMessage(CProducer* producer)
|
||||
@@ -716,60 +642,6 @@ void producer_send(const char* strbody)
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#if 0
|
||||
void rocketmq_StartSendMessage(CProducer* producer,const char* strbody,const char* topic)
|
||||
{
|
||||
CSendResult result;
|
||||
|
||||
// create message and set some values for it
|
||||
CMessage* msg = CreateMessage(topic);
|
||||
|
||||
//多前置区分消息tag,一个进程
|
||||
|
||||
SetMessageTags(msg, G_ROCKETMQ_TAG.c_str());
|
||||
SetMessageKeys(msg, G_ROCKETMQ_KEY.c_str());
|
||||
|
||||
SetMessageBody(msg, strbody);
|
||||
// send message
|
||||
SendMessageSync(producer, msg, &result);
|
||||
|
||||
//cout << "rocketmq_result status:" << result.sendStatus << ", msgBody:" << strbody << endl;
|
||||
|
||||
// destroy message
|
||||
DestroyMessage(msg);
|
||||
}
|
||||
|
||||
void rocketmq_producer_send(const char* strbody,const char* topic)
|
||||
{
|
||||
cout << "rocketmq_Producer Initializing....." << endl;
|
||||
|
||||
// create producer and set some values for it
|
||||
CProducer* producer = CreateProducer(G_ROCKETMQ_PRODUCER.c_str());
|
||||
if (producer == NULL) {
|
||||
std::cerr << "Failed to create producer." << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// nameserver
|
||||
SetProducerNameServerAddress(producer, G_ROCKETMQ_IPPORT.c_str());
|
||||
|
||||
// start producer
|
||||
StartProducer(producer);
|
||||
|
||||
cout << "rocketmq_Producer start....." << endl;
|
||||
// send message
|
||||
//rocketmq_StartSendMessage(producer,strbody,topic);
|
||||
//根据队列发消息
|
||||
StartSendMessage_queue(producer,strbody,topic);
|
||||
// shutdown producer
|
||||
ShutdownProducer(producer);
|
||||
// destroy producer
|
||||
DestroyProducer(producer);
|
||||
cout << "rocketmq_Producer Shutdown!" << endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
extern "C" {
|
||||
extern std::string G_MQCONSUMER_TOPIC_RT;
|
||||
@@ -862,84 +734,3 @@ void rocketmq_test_log()
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
void rocketmq_test_300(int mpnum,int front_index) {
|
||||
Ckafka_data_t data;
|
||||
data.strTopic = QString::fromStdString(G_ROCKETMQ_TOPIC);
|
||||
data.mp_id = "0";
|
||||
|
||||
// 读取文件内容
|
||||
std::ifstream file("long_string.txt"); // 文件中存储长字符串
|
||||
std::stringstream buffer;
|
||||
buffer << file.rdbuf();
|
||||
std::string file_contents = buffer.str(); // 获取文件内容
|
||||
std::string base_strText = file_contents;
|
||||
|
||||
// 获取当前时间作为开始时间
|
||||
std::time_t t = std::time(NULL);//获取当前的系统时间(自 1970 年 1 月 1 日以来的秒数,通常称为 UNIX 时间戳)
|
||||
std::tm* time_info = std::localtime(&t);//将 std::time_t(表示当前的 UNIX 时间戳)转换为本地时间(std::tm 结构)
|
||||
time_info->tm_sec = 0; // 清零秒位
|
||||
//time_info->tm_msec = 0; // 清零毫秒位(如果需要更精确,使用高精度时间)
|
||||
|
||||
// 获取当前的时间戳(秒)
|
||||
std::time_t base_time_t = std::mktime(time_info);//将 std::tm 结构(本地时间)转换回 std::time_t(时间戳)
|
||||
|
||||
// 计算每条消息的时间戳,精确到分钟,毫秒和秒清零
|
||||
long long current_time_ms = static_cast<long long>(base_time_t) * 1000; // 每分钟递增,单位毫秒
|
||||
|
||||
// 设定总的消息数量
|
||||
int total_messages = mpnum;
|
||||
|
||||
// 循环发送 300 条消息
|
||||
for (int i = 0; i < total_messages; ++i) {
|
||||
// 修改 Monitor 值
|
||||
data.monitor_id = front_index *10000 + 1 + i;
|
||||
|
||||
data.mp_id = QString::number(data.monitor_id);
|
||||
|
||||
std::string modified_time = my_to_string(current_time_ms); // 时间转换为整数类型(Unix时间戳)
|
||||
|
||||
// 替换消息中的 Monitor 和 TIME 字段(只匹配字段名,不匹配具体数值)
|
||||
std::string modified_strText = base_strText;
|
||||
|
||||
// 替换 Monitor 字段
|
||||
size_t monitor_pos = modified_strText.find("\"Monitor\"");
|
||||
if (monitor_pos != std::string::npos) {
|
||||
size_t colon_pos = modified_strText.find(":", monitor_pos);
|
||||
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, my_to_string(data.monitor_id));
|
||||
}
|
||||
}
|
||||
|
||||
// 替换 TIME 字段
|
||||
size_t time_pos = modified_strText.find("\"TIME\"");
|
||||
if (time_pos != std::string::npos) {
|
||||
size_t colon_pos = modified_strText.find(":", time_pos);
|
||||
size_t quote_pos = 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, modified_time);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新数据
|
||||
data.strText = QString::fromStdString(modified_strText);
|
||||
|
||||
// 发送数据
|
||||
my_rocketmq_send(data);
|
||||
|
||||
// 输出调试信息
|
||||
std::cout << "Sent message " << (i + 1) << " with Monitor " << data.monitor_id << " and TIME " << modified_time << std::endl;
|
||||
|
||||
// 等待下一条消息的发送(固定为1分钟)
|
||||
//QThread::sleep(60); // 每次发送间隔1分钟
|
||||
}
|
||||
|
||||
std::cout << "Finished sending " << total_messages << " messages." << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -111,8 +111,6 @@ extern "C" {
|
||||
return encoded_data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20>ж<EFBFBD><D0B6>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊpower{}<7D><>ʽ
|
||||
/// </summary>
|
||||
@@ -152,38 +150,6 @@ extern "C" {
|
||||
return true; // <20><>ȡ<EFBFBD>ɹ<EFBFBD>
|
||||
}
|
||||
|
||||
//int testbase64(char ** decoded_text) {
|
||||
// unsigned char text[] = "power{SGVsbG8sIFdvcmxkIWV3ZA==}";
|
||||
// size_t encoded_length, decoded_length;
|
||||
|
||||
// char encoded_text[100];
|
||||
|
||||
// if (extract_if_power((char*)text, encoded_text, sizeof(encoded_text), &encoded_length)) {
|
||||
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// long decodedLen = strlen(encoded_text) * 3 / 4;
|
||||
// * decoded_text = (char*)malloc(decodedLen + 1);
|
||||
// // <20><><EFBFBD><EFBFBD>Base64<36><34><EFBFBD><EFBFBD>
|
||||
// int success = base64_decode(encoded_text, strlen(encoded_text), *decoded_text, &decodedLen);
|
||||
// if (decoded_text) {
|
||||
// printf("Decoded: %s\n", (char*)decoded_text); // ע<>⣺<EFBFBD><E2A3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫȷ<D2AA><C8B7><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>null<6C><6C>ֹ<EFBFBD><D6B9><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||
// free(decoded_text); // ע<>⣺<EFBFBD><E2A3BA><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD>ϲ<EFBFBD>Ӧ<EFBFBD><D3A6>ʹ<EFBFBD><CAB9>decoded_text<78><74>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>unsigned char*
|
||||
// // <20><>ʵ<EFBFBD><CAB5>Ӧ<EFBFBD><D3A6><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊchar*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>null<6C><6C>ֹ<EFBFBD><D6B9>
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// printf(" no Decoded: %s\n", text); // ע<>⣺<EFBFBD><E2A3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫȷ<D2AA><C8B7><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>null<6C><6C>ֹ<EFBFBD><D6B9><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||
// }
|
||||
//
|
||||
|
||||
|
||||
// // ע<>⣺<EFBFBD><E2A3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>decoded_text<78><74>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD>ȷ<D7BC>ģ<EFBFBD><C4A3><EFBFBD>Ϊdecoded_text<78><74>unsigned char*<2A>ҿ<EFBFBD><D2BF>ܲ<EFBFBD><DCB2><EFBFBD>null<6C><6C>ֹ<EFBFBD><D6B9><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||
// // <20><>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD>decoded_textת<74><D7AA>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>
|
||||
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,10 +14,8 @@
|
||||
using namespace std;
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
#include "../mms/db_interface.h"
|
||||
#include "../json/cjson.h"//WW 2023-08-27<32><37><EFBFBD><EFBFBD>json<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#include "../include/curl/curl.h"
|
||||
@@ -29,11 +27,8 @@ extern "C" {
|
||||
|
||||
size_t req_reply_datahub(void* ptr, size_t size, size_t nmemb, void* stream)
|
||||
{
|
||||
//<2F><>ע<EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>cookie<69><65><EFBFBD><EFBFBD>Ϣ
|
||||
string* str = (string*)stream;
|
||||
(*str).append((char*)ptr, size * nmemb);
|
||||
//printf(">>>GetDevice in reply %s\n", (char*)ptr);
|
||||
//GetCJson(ptr);
|
||||
return size * nmemb;
|
||||
}
|
||||
|
||||
@@ -42,6 +37,7 @@ void SendWebAPI_Datahub(const string strUrl,char* topic,char* data)
|
||||
|
||||
// curl<72><6C>ʼ<EFBFBD><CABC>
|
||||
CURL* curl = curl_easy_init();
|
||||
|
||||
// curl<72><6C><EFBFBD><EFBFBD>ֵ
|
||||
CURLcode res;
|
||||
if (curl)
|
||||
@@ -60,18 +56,15 @@ void SendWebAPI_Datahub(const string strUrl,char* topic,char* data)
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>URL<52><4C>ַ
|
||||
curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>post<73><74><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>
|
||||
cJSON* json_root = cJSON_CreateObject();
|
||||
|
||||
//cJSON_AddItemToObject(json_root, "topic", cJSON_CreateString("ems_pq_mmxu_stat"));
|
||||
//cJSON_AddItemToObject(json_root, "data", cJSON_CreateString("{\"DATA_TYPE\": \"04\",\"Monitor\": \"4563\",\"Value\": {\"FLAG\": 1,\"TIME\": 1512097260000,\"VOLTAGE\": {\"MAG\": 56.23,\"DUR\": 23,\"STARTTIME\": 1512097260000,\"ENDTIME\": 1512097283000,\"DISKIND\": \"01\",\"WAVEFILE\": \"PQMonitor_PQM1_000001_20230707_103916_596\",\"PHASIC\": \"unknow\"}}}"));
|
||||
cJSON_AddItemToObject(json_root, "topic", cJSON_CreateString(topic));
|
||||
cJSON_AddItemToObject(json_root, "data", cJSON_CreateString(data));
|
||||
|
||||
char* szjson = cJSON_Print(json_root);
|
||||
//printf(">>>json %s\n", szjson);
|
||||
//string strjson = szjson;
|
||||
//char* pszEncodeSecret = curl_easy_escape(curl, strclientsecret.c_str(), strclientsecret.length());
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, szjson);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ssl<73><6C>֤
|
||||
@@ -86,7 +79,6 @@ void SendWebAPI_Datahub(const string strUrl,char* topic,char* data)
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD>պ<EFBFBD>д<EFBFBD>뺯<EFBFBD><EBBAAF>
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, req_reply_datahub);
|
||||
|
||||
|
||||
string resPost0;
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&resPost0);
|
||||
|
||||
@@ -97,8 +89,10 @@ void SendWebAPI_Datahub(const string strUrl,char* topic,char* data)
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);
|
||||
|
||||
printf(">>>Testaliyun datahub Post in curl post\n");
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>post<73><74><EFBFBD><EFBFBD>
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>
|
||||
if (res != CURLE_OK) {
|
||||
printf("aliyun datahub failed res code: ");
|
||||
@@ -119,14 +113,11 @@ void SendWebAPI_Datahub(const string strUrl,char* topic,char* data)
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
|
||||
void DataHub_Send_Datahub(char* topic,char* data)
|
||||
{
|
||||
SendWebAPI_Datahub("http://127.0.0.1:8091/powerQuality/PQDATAHUB",topic,data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4,20 +4,9 @@
|
||||
#include <string>
|
||||
#include "../json/cjson.h"
|
||||
|
||||
//#include <mutex>
|
||||
|
||||
//#include <queue>
|
||||
|
||||
//std::mutex data_mutex; // 用来保护 receivedData 变量
|
||||
|
||||
//#include <atomic>
|
||||
//std::atomic<bool> isrunning(false); // 使用原子变量保证 isrunning 的内存可见性
|
||||
|
||||
//std::queue<std::string> receivedData; // 用于存储接收到的数据
|
||||
bool isrunning = true; //用于线程同步
|
||||
std::string receivedData;
|
||||
|
||||
//std::queue<std::string> receivedData2; // 用于存储接收到的数据
|
||||
bool isrunning2 = true; //用于线程同步
|
||||
std::string receivedData2;
|
||||
|
||||
@@ -32,10 +21,6 @@ std::string rtdata_fail = "{\"code\":\"A0002\", \"msg\":\"3s数据执行失败\"
|
||||
|
||||
// 处理补招请求的函数
|
||||
std::string HandleRecall_http(const httplib::Request& req, httplib::Response& res) {
|
||||
// 打印请求的查询参数
|
||||
//std::cout << "Query parameters: " << std::endl;
|
||||
|
||||
//std::lock_guard<std::mutex> lock(data_mutex);
|
||||
|
||||
if(isrunning == true){ //收到前置信号,收到信息可以处理消息
|
||||
if (req.body.empty()) { //消息体为空
|
||||
@@ -180,21 +165,11 @@ std::string Handleupdate_http(const httplib::Request& req, httplib::Response& re
|
||||
//extern "C" std::string getReceivedData() {
|
||||
extern "C" const char* getReceivedData(int fun) {
|
||||
if(1 == fun){
|
||||
/*if (!receivedData.empty()) {
|
||||
std::string msg = receivedData.front(); // 获取队列中的第一条消息
|
||||
receivedData.pop(); // 从队列中移除这条消息
|
||||
return msg.c_str();
|
||||
}
|
||||
return "recall queue empty";*/
|
||||
|
||||
return receivedData.c_str();
|
||||
}
|
||||
if(2 == fun){
|
||||
/*if (!receivedData2.empty()) {
|
||||
std::string msg = receivedData2.front(); // 获取队列中的第一条消息
|
||||
receivedData2.pop(); // 从队列中移除这条消息
|
||||
return msg.c_str();
|
||||
}
|
||||
return "rtdata queue empty";*/
|
||||
|
||||
return receivedData2.c_str();
|
||||
}
|
||||
return "all queue empty";
|
||||
@@ -223,7 +198,6 @@ extern "C" bool threadmsghttp(int fun) {
|
||||
|
||||
// 启动 HTTP 服务器的函数
|
||||
extern "C" void httprun() {
|
||||
//std::cout << "WebhttpThread::run() is called ...... " << std::endl;
|
||||
|
||||
// 创建 HTTP 服务器对象
|
||||
httplib::Server svr;
|
||||
@@ -237,11 +211,8 @@ extern "C" void httprun() {
|
||||
// 监听路径 /powerQuality/update,绑定处理函数
|
||||
svr.Post("/powerQuality/update", Handleupdate_http); // 使用 POST 方法处理请求
|
||||
|
||||
// 监听端口 10004
|
||||
//std::cout << "Server started at http://0.0.0.0:10004" << std::endl;
|
||||
if (!svr.listen(HTTP_IP, HTTP_PORT)) { // 监听所有 IP
|
||||
std::cerr << "Error: Unable to start server on port 10004" << std::endl;
|
||||
}
|
||||
|
||||
//std::cout << "WebhttpThread::run() is end ...... " << std::endl;
|
||||
}
|
||||
1272
cfg_parse/nacos.cpp
1272
cfg_parse/nacos.cpp
File diff suppressed because it is too large
Load Diff
@@ -32,11 +32,8 @@ char BUCKET_NAME_OBS[2048] = { "test-8601" };
|
||||
|
||||
size_t req_reply_device(void* ptr, size_t size, size_t nmemb, void* stream)
|
||||
{
|
||||
//<2F><>ע<EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>cookie<69><65><EFBFBD><EFBFBD>Ϣ
|
||||
string* str = (string*)stream;
|
||||
(*str).append((char*)ptr, size * nmemb);
|
||||
//printf(">>>GetDevice in reply %s\n", (char*)ptr);
|
||||
//GetCJson(ptr);
|
||||
return size * nmemb;
|
||||
}
|
||||
|
||||
@@ -162,8 +159,6 @@ void SendWebAPI(const string strUrl, char* localpath, char* cloudpath,const char
|
||||
|
||||
char* szjson = cJSON_Print(json_root);
|
||||
printf(">>>json %s\n", szjson);
|
||||
//string strjson = szjson;
|
||||
//char* pszEncodeSecret = curl_easy_escape(curl, strclientsecret.c_str(), strclientsecret.length());
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, szjson);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ssl<73><6C>֤
|
||||
@@ -245,12 +240,10 @@ void SendWebAPI_del(const string strUrl, char* cloudpath, const char* code)
|
||||
//param<61><6D>
|
||||
cJSON_AddItemToObject(json_param, "object_name", cJSON_CreateString(cloudpath));
|
||||
cJSON_AddNullToObject(json_param, "localfile_name");
|
||||
//cJSON_AddItemToObject(json_param, "localfile_name", cJSON_CreateString(localpath));
|
||||
|
||||
char* szjson = cJSON_Print(json_root);
|
||||
printf(">>>json %s\n", szjson);
|
||||
//string strjson = szjson;
|
||||
//char* pszEncodeSecret = curl_easy_escape(curl, strclientsecret.c_str(), strclientsecret.length());
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, szjson);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ssl<73><6C>֤
|
||||
|
||||
@@ -23,19 +23,14 @@ using namespace std;
|
||||
#include "../mms/db_interface.h"
|
||||
#include <iostream>
|
||||
|
||||
char* OSS_ENDPOINT;
|
||||
char* ACCESS_KEY_ID;
|
||||
char* ACCESS_KEY_SECRET;
|
||||
char* OSS_ENDPOINT;
|
||||
char* ACCESS_KEY_ID;
|
||||
char* ACCESS_KEY_SECRET;
|
||||
char* BUCKET_NAME;
|
||||
|
||||
//const char OSS_ENDPOINT[] = "oss-cn-nanjing.aliyuncs.com";
|
||||
//const char ACCESS_KEY_ID[] = "LTAI5tER4bgJxT6Ptie7t2X7";
|
||||
//const char ACCESS_KEY_SECRET[] = "dSYIC5hD3flhTNoLMAxCoKjSPdWFSz";
|
||||
//const char BUCKET_NAME[] = "cn-pq-test";
|
||||
const char OBJECT_NAME[] = "comtrade/temp.json";
|
||||
|
||||
void init_sample_request_options(oss_request_options_t *options, int is_cname);
|
||||
|
||||
void put_object_from_buffer();
|
||||
void put_object_from_buffer_new(char* File_Name, char* data);
|
||||
void put_object_from_file();
|
||||
@@ -52,27 +47,19 @@ void TestOSS()
|
||||
aos_pool_t *pool = NULL;
|
||||
apr_status_t ret;
|
||||
|
||||
// initialize http io system, call it olny once
|
||||
/* <20>ڳ<EFBFBD><DAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>aos_http_io_initialize<7A><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>硢<EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>*/
|
||||
printf(">>>TestOSS ini Start");
|
||||
if (aos_http_io_initialize(NULL, 0) != AOSE_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
printf(">>>TestOSS put Start");
|
||||
// run samples
|
||||
//put_object_from_buffer();
|
||||
//put_object_from_file();
|
||||
|
||||
put_object_from_buffer();
|
||||
get_object_to_file();
|
||||
//get_object_to_buffer();
|
||||
//get_object_to_file();
|
||||
//delete_object();
|
||||
|
||||
printf(">>>TestOSS put End");
|
||||
|
||||
|
||||
// deinitialize http io system, call it olny once
|
||||
aos_http_io_deinitialize();
|
||||
|
||||
return ;
|
||||
@@ -84,7 +71,6 @@ void PutOSS(char* File_Name,char* data) //zw
|
||||
aos_pool_t* pool = NULL;
|
||||
apr_status_t ret;
|
||||
|
||||
// initialize http io system, call it olny once
|
||||
/* <20>ڳ<EFBFBD><DAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>aos_http_io_initialize<7A><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>硢<EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>*/
|
||||
printf(">>>PutOSS ini Start");
|
||||
printf(File_Name);
|
||||
@@ -100,8 +86,6 @@ void PutOSS(char* File_Name,char* data) //zw
|
||||
|
||||
printf(">>>PutOSS put End");
|
||||
|
||||
|
||||
// deinitialize http io system, call it olny once
|
||||
aos_http_io_deinitialize();
|
||||
|
||||
return;
|
||||
@@ -113,22 +97,18 @@ void GetOSS(char* File_Name,char* savepath) //zw
|
||||
aos_pool_t* pool = NULL;
|
||||
apr_status_t ret;
|
||||
|
||||
// initialize http io system, call it olny once
|
||||
/* <20>ڳ<EFBFBD><DAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>aos_http_io_initialize<7A><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>硢<EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>*/
|
||||
printf(">>>GetOSS ini Start");
|
||||
if (aos_http_io_initialize(NULL, 0) != AOSE_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
printf(">>>GetOSS put Start");
|
||||
|
||||
get_object_to_file_new(File_Name,savepath);//ʹ<><CAB9>buffer<65><72><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
|
||||
printf(">>>GetOSS put End");
|
||||
|
||||
|
||||
// deinitialize http io system, call it olny once
|
||||
aos_http_io_deinitialize();
|
||||
|
||||
return;
|
||||
@@ -140,32 +120,29 @@ void DelOSS(char* File_Name)
|
||||
aos_pool_t* pool = NULL;
|
||||
apr_status_t ret;
|
||||
|
||||
// initialize http io system, call it olny once
|
||||
/* <20>ڳ<EFBFBD><DAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>aos_http_io_initialize<7A><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>硢<EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>*/
|
||||
printf(">>>DelOSS ini Start");
|
||||
if (aos_http_io_initialize(NULL, 0) != AOSE_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
printf(">>>DelOSS put Start");
|
||||
|
||||
delete_object_new(File_Name);//ʹ<><CAB9>buffer<65><72><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
|
||||
printf(">>>DelOSS put End");
|
||||
|
||||
|
||||
// deinitialize http io system, call it olny once
|
||||
aos_http_io_deinitialize();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void coutTest() {
|
||||
void coutTest()
|
||||
{
|
||||
std:: cout << "OSS_ENDPOINT:" << OSS_ENDPOINT << std::endl;
|
||||
std::cout << "ACCESS_KEY_ID:" << ACCESS_KEY_ID << std::endl;
|
||||
std::cout << "ACCESS_KEY_SECRET:" << ACCESS_KEY_SECRET << std::endl;
|
||||
std::cout << "BUCKET_NAME:" << BUCKET_NAME << std::endl;
|
||||
|
||||
}
|
||||
|
||||
void init_sample_request_options(oss_request_options_t *options, int is_cname)
|
||||
@@ -175,7 +152,6 @@ void init_sample_request_options(oss_request_options_t *options, int is_cname)
|
||||
aos_str_set(&options->config->access_key_id, ACCESS_KEY_ID);
|
||||
aos_str_set(&options->config->access_key_secret, ACCESS_KEY_SECRET);
|
||||
options->config->is_cname = is_cname;
|
||||
|
||||
options->ctl = aos_http_controller_create(options->pool, 0);
|
||||
}
|
||||
|
||||
@@ -231,7 +207,6 @@ void put_object_from_buffer_new(char* File_Name,char* data)//zw
|
||||
aos_buf_t* content = NULL;
|
||||
char* str = data;
|
||||
aos_status_t* s = NULL;
|
||||
|
||||
aos_pool_create(&p, NULL);
|
||||
options = oss_request_options_create(p);
|
||||
init_sample_request_options(options, is_cname);
|
||||
@@ -323,10 +298,8 @@ void put_object_from_file_new(char* File_Name, char* path)
|
||||
printf("put object from file succeeded\n");
|
||||
}
|
||||
else {
|
||||
printf("put object from file failed, code:%d, error_code:%s, error_msg:%s, request_id:%s\n",
|
||||
s->code, s->error_code, s->error_msg, s->req_id);
|
||||
printf("put object from file failed, code:%d, error_code:%s, error_msg:%s, request_id:%s\n",s->code, s->error_code, s->error_msg, s->req_id);
|
||||
}
|
||||
|
||||
|
||||
aos_pool_destroy(p);
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
1658
json/create_json.cpp
1658
json/create_json.cpp
File diff suppressed because it is too large
Load Diff
@@ -33,12 +33,6 @@ public:
|
||||
}
|
||||
private:
|
||||
|
||||
//static inline unsigned int djb_hash (const char *str, size_t len) {
|
||||
// unsigned int hash = 5381;
|
||||
// for (size_t i = 0 ; i < len ; i++)
|
||||
// hash = ((hash << 5) + hash) + str[i];
|
||||
// return hash;
|
||||
//}
|
||||
};
|
||||
|
||||
class ProducerDeliveryReportCb : public RdKafka::DeliveryReportCb {
|
||||
@@ -88,8 +82,6 @@ bool FeKafkaProducer::init(const std::string &brokerlist, const bool &async, con
|
||||
}
|
||||
#endif
|
||||
|
||||
//std::string broker(host);
|
||||
//broker.append(":").append(std::to_string((long long)port));
|
||||
conf_->set("metadata.broker.list", brokerlist, errstr);
|
||||
if (strcmp(PROTOCOL, "sasl_plaintext") == 0) {
|
||||
conf_->set("security.protocol", PROTOCOL, errstr);
|
||||
@@ -114,17 +106,10 @@ bool FeKafkaProducer::init(const std::string &brokerlist, const bool &async, con
|
||||
{
|
||||
char size_str[256];
|
||||
conf_->set("producer.type", "async", errstr);
|
||||
//conf_->set("queue.buffering.max.messages", std::to_string((long long)size).c_str(), errstr);
|
||||
memset(size_str,0,256);
|
||||
apr_snprintf(size_str,sizeof(size_str),"%i",size);
|
||||
conf_->set("queue.buffering.max.messages", size_str, errstr);
|
||||
|
||||
{
|
||||
//const char* api_version_request = "false";
|
||||
//const char* api_version_fallback = "0.8.2.0";
|
||||
//conf_->set("api.version.request", api_version_request, errstr) ;
|
||||
//conf_->set("broker.version.fallback", api_version_fallback, errstr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -146,7 +131,7 @@ int FeKafkaProducer::send(const char *data, const int &size, const std::string &
|
||||
const int &partition, const std::string *key,const int &timeout)
|
||||
{
|
||||
RdKafka::Topic *tpk = get_topic(topic);
|
||||
//std::cout<<"send data "<<data<<std::endl;
|
||||
|
||||
if (tpk == nullptr) {
|
||||
printf("FIRST: get topic(%s) failed, to create at once \n",topic.c_str());
|
||||
bool ret = create_topic(topic);
|
||||
@@ -169,7 +154,6 @@ int FeKafkaProducer::send(const char *data, const int &size, const std::string &
|
||||
RdKafka::Producer::RK_MSG_COPY /* Copy payload */,
|
||||
const_cast<char*>(data), size,
|
||||
key->c_str(),key->size(), NULL);
|
||||
///*NULL*/ key, NULL);
|
||||
|
||||
if (resp != RdKafka::ERR_NO_ERROR)
|
||||
{
|
||||
|
||||
@@ -39,35 +39,6 @@ public:
|
||||
QString dev_type;//<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
|
||||
QMap<QString, double> mms_str_map; //<2F><><EFBFBD><EFBFBD>ֵ(61850<35><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>ֵ)
|
||||
|
||||
/*
|
||||
json_block_data() //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD> zl 2018-11-22 09:03:30 ----<2D><><EFBFBD>Բ<EFBFBD><D4B2>Գ<EFBFBD>ֵ<EFBFBD><D6B5>
|
||||
{
|
||||
monitorId = 7501; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID
|
||||
partitionSize = 3; //kafka<6B><61><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
func_type = 100; //<2F><>Ӧ(#define<6E>궨<EFBFBD><EAB6A8><EFBFBD><EFBFBD>100 <20><> 400)<29><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
|
||||
data_type = 1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
flag = 0; //<2F><EFBFBD><DEB3><EFBFBD><EFBFBD><EFBFBD>
|
||||
time = 1546099200000; //ʱ<><CAB1><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>) <20><><EFBFBD><EFBFBD>2018-12-30??00:00:00
|
||||
//connectLineCount = 1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
||||
//triggerLineCount = 1; //<2F>Ѵ<EFBFBD><D1B4><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
||||
|
||||
mms_str_map.insert("MMXU4$MX$PhVDev$phsA$cVal$mag$f", 123.4567890); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD> zl 2018-11-22 10:46:15
|
||||
mms_str_map.insert("MHAI2$MX$HRPhV$phsAHar[0]$ang$f", 200.1234567); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD> zl 2018-11-22 10:46:15
|
||||
mms_str_map.insert("MHAI2$MX$HRPhV$phsAHar[47]$ang$f", 300.1234567); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD> zl 2018-11-22 10:46:15
|
||||
mms_str_map.insert("MHAI2$MX$HRPhV$phsAHar[48]$ang$f", 300.1234567); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD> zl 2018-11-22 10:46:15
|
||||
|
||||
mms_str_map.insert("MMXU4$MX$PhVDev$phsB$cVal$mag$f", 123.4567890); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD> zl 2018-11-22 10:46:15
|
||||
mms_str_map.insert("MHAI2$MX$HRPhV$phsBHar[0]$ang$f", 200.1234567); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD> zl 2018-11-22 10:46:15
|
||||
mms_str_map.insert("MHAI2$MX$HRPhV$phsBar[47]$ang$f", 300.1234567); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD> zl 2018-11-22 10:46:15
|
||||
mms_str_map.insert("MHAI2$MX$HRPhV$phsBar[48]$ang$f", 300.1234567); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD> zl 2018-11-22 10:46:15
|
||||
|
||||
mms_str_map.insert("MMXU4$MX$PhVDev$phsC$cVal$mag$f", 123.4567890); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD> zl 2018-11-22 10:46:15
|
||||
mms_str_map.insert("MHAI2$MX$HRPhV$phsCHar[0]$ang$f", 200.1234567); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD> zl 2018-11-22 10:46:15
|
||||
mms_str_map.insert("MHAI2$MX$HRPhV$phsCHar[47]$ang$f", 300.1234567); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD> zl 2018-11-22 10:46:15
|
||||
mms_str_map.insert("MHAI2$MX$HRPhV$phsCHar[48]$ang$f", 300.1234567); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD> zl 2018-11-22 10:46:15
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
class Ckafka_data_t //kafka<6B><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9>
|
||||
@@ -91,30 +62,14 @@ public:
|
||||
QString log_name; //<2F>ն<EFBFBD>id<69><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>id
|
||||
QString id; //<2F>ն<EFBFBD>id<69><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>id
|
||||
QString time; //ʱ<><CAB1>
|
||||
//match_log
|
||||
int base_mat_num;
|
||||
int adv_mat_num;
|
||||
int base_act_num;
|
||||
int adv_act_num;
|
||||
//reason_log
|
||||
int list_num;
|
||||
};
|
||||
//extern QMutex kafka_data_list_mutex;
|
||||
//extern QList<kafka_data_t> kafka_data_list;
|
||||
/* ʹ<><CAB9>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>룺
|
||||
Ckafka_data_t data;
|
||||
data.patition_id = 0;
|
||||
data.strText = QString("{a=1,b=2}");
|
||||
|
||||
kafka_data_list_mutex.lock();
|
||||
kafka_data_list.append(data);
|
||||
kafka_data_list_mutex.unlock();
|
||||
*/
|
||||
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);
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -125,15 +80,11 @@ extern "C" {
|
||||
|
||||
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);
|
||||
void Set_xml_databaseinfo(char* MODEL_ID, char* TMNL_TYPE, char* TMNL_FACTORY, char* FILE_NAME, int year, int month, int day, int hour, int minute, int second);//zw<7A><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><C3BA><EFBFBD>
|
||||
void Set_xml_nodeinfo();//zw<7A><EFBFBD>
|
||||
char* Get_xmlpath(char* devtype);
|
||||
char* Get_IED(char* devtype);
|
||||
char* Get_LDevice(char* devtype);
|
||||
void errorlog_json(char* id, char* ip, int port, int type, char* error_type, char* ERROR_DES, char* ERROR_PARAM);
|
||||
void SoeRptSql(char* id, int state, char* rpt);
|
||||
void connectlog_pgsql(char* id,char* datetime,int status);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -32,8 +32,6 @@ using namespace std;
|
||||
#include "../json/save2json.h"
|
||||
#include "../json/mms_json_inter.h"
|
||||
#include "kafka_producer.h"
|
||||
/*lnk10-11 */
|
||||
//#include "../include/rocketmq/SimpleProducer.h"
|
||||
#include "../include/rocketmq/CPushConsumer.h"
|
||||
#include <vector>
|
||||
#include "../json/cjson.h" //<2F><>json
|
||||
@@ -42,7 +40,6 @@ using namespace std;
|
||||
bool createXmlFile(int devindex, int mpindex, bool realData, bool soeData, int limit,std::string type);
|
||||
extern int recall_json_handle(const char* jstr);
|
||||
extern std::string intToString(int number);
|
||||
//extern int stringToInt(const char* str, int* result);
|
||||
int StringToInt(const std::string& str);
|
||||
extern pthread_mutex_t mtx;//lnk20250115
|
||||
|
||||
@@ -78,13 +75,10 @@ extern QList<oss_data_t> oss_data_list;
|
||||
extern int FILE_FLAG;
|
||||
KafkaSendThread myThrd;
|
||||
//WW 2023-08-22 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>̺߳<DFB3>WebSokcet<65>߳<EFBFBD>
|
||||
SQLExcuteThread sqlThrd; //Sqlִ<6C><D6B4><EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
WebSocketThread socketThrd; //Web Socket<65>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
WebhttpThread webhttpThrd; //Web http<74>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> lnk202411
|
||||
httpThread httpThrd; //Web http<74>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> lnk202411
|
||||
//mqtestThread mqtestThrd; //mqtest<73>߳<EFBFBD> lnk202412
|
||||
//mqtestThread mqtestThrd(nullptr); //mqtest<73>߳<EFBFBD> lnk202412
|
||||
mqconsumerThread mqconsumerThrd;//mq<6D><71><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>lnk20241213
|
||||
|
||||
OnTimerThread onTimerThrd;//<2F><>ʱ<EFBFBD>߳<EFBFBD>
|
||||
@@ -253,45 +247,6 @@ void add_stat_kafka_json_log(char* log_str)
|
||||
QTextStream out(&file);
|
||||
out << (now.toString("yyyy-MM-dd hh:mm:ss") + " " + level_str + " " + QString::fromAscii(log_str)) << endl;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*void TrimLeft(std::string &s)
|
||||
{
|
||||
const std::string &space =" \f\n\t\r\v";
|
||||
s.erase(0, s.find_first_not_of(space));
|
||||
}
|
||||
|
||||
void TrimRight(std::string &s)
|
||||
{
|
||||
const std::string &space =" \f\n\t\r\v";
|
||||
s.erase(s.find_last_not_of(space) + 1);
|
||||
}
|
||||
|
||||
void Trim(std::string &s)
|
||||
{
|
||||
const std::string &space =" \f\n\t\r\v";
|
||||
s.erase(0, s.find_first_not_of(space));
|
||||
s.erase(s.find_last_not_of(space) + 1);
|
||||
}
|
||||
|
||||
|
||||
int is_rpt_Time_exact_hour()
|
||||
{
|
||||
apr_time_t hour_time_t = g_db_info->TimeID[RPT_IDX]/APRTIME_8H*APRTIME_8H;
|
||||
if (g_db_info->TimeID[RPT_IDX]==hour_time_t)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
} */
|
||||
|
||||
//char uuid_str[APR_UUID_FORMATTED_LENGTH+1];
|
||||
//int iii;
|
||||
//for (iii=0;iii<10;iii++) {
|
||||
// apr_uuid_t uuid;
|
||||
// apr_uuid_get(&uuid);
|
||||
// apr_uuid_format(uuid_str,&uuid);
|
||||
// printf("uuid_str=%s \n",uuid_str);
|
||||
//}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/*<2A><><EFBFBD><EFBFBD>rocketmq<6D><71><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>lnk10-10*/
|
||||
@@ -355,7 +310,6 @@ void my_rocketmq_send(Ckafka_data_t& data)
|
||||
|
||||
}
|
||||
rocketmq_producer_send(const_cast<char*>(senddata.c_str()),const_cast<char*>(topic.c_str()));
|
||||
//printf("\nrocketmq send, monitor_id:[%s] topic:[%s] Success\n", key.c_str(), topic.c_str());
|
||||
}
|
||||
|
||||
|
||||
@@ -383,13 +337,10 @@ void my_kafka_send(Ckafka_data_t& data)
|
||||
cfg_Alm_tp = TOPIC_ALARM;
|
||||
cfg_Sng_tp = TOPIC_SNG;
|
||||
|
||||
//QString topic_cfg = settings.value("Kafka/topic","").toString();
|
||||
//printf("!!!!!!!!!kafka producer init Failed(%s)\n", cfg_tp);
|
||||
cout << cfg_His_tp << endl;
|
||||
//std::string brokerlist = brl_cfg.toStdString();//"10.240.16.145:6667,10.240.16.146:6667,10.240.16.147:6667,10.240.16.148:6667,10.240.16.149:6667";
|
||||
std::string brokerlist = BROKER_LIST;
|
||||
|
||||
//topic = topic_cfg.toStdString();//"test";
|
||||
std::string brokerlist = BROKER_LIST;
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
if (kafkaProducer.init(brokerlist)) {
|
||||
@@ -410,9 +361,6 @@ void my_kafka_send(Ckafka_data_t& data)
|
||||
apr_snprintf(tmp_str, sizeof(tmp_str), "%d", data.monitor_id);
|
||||
std::string key = std::string(tmp_str);
|
||||
|
||||
//std::string key_mp_id = data.mp_id.toStdString();
|
||||
|
||||
//key = data.monitor_id;
|
||||
std::string senddata = data.strText.toStdString();
|
||||
if (data.strTopic == "HISDATA")
|
||||
{
|
||||
@@ -439,29 +387,12 @@ void my_kafka_send(Ckafka_data_t& data)
|
||||
{
|
||||
topic = data.strTopic.toStdString();
|
||||
}
|
||||
//QDateTime currentTime = QDateTime::currentDateTime();
|
||||
//QTime time = currentTime.time();
|
||||
|
||||
//if (time >= QTime(23, 30) || time < QTime(01, 00)) {
|
||||
// // The current time is between 23:00 and 00:30
|
||||
// add_sng_log(data.strText.toAscii().data());
|
||||
//}
|
||||
//add_sng_log(data.strText.toAscii().data());
|
||||
if (g_onlyIP[0] != 0)
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD>ģʽ
|
||||
//topic = cfg_Evt_tp;
|
||||
//key = "2606L20071";
|
||||
//senddata = "{\"DATA_TYPE\":\"02\" , \"Monitor\":\"2606123456\" , \"Value\":{\"TIME\":\"1699576200000\", \"F_S\":{\"A\":{ \"PST\":\"0.000000\",\"FLUC\":\"343917.750000\",\"FLUCF\":\"374275.000000\" }, \"B\":{ \"PST\":\"0.000000\",\"FLUC\":\"222171.156250\",\"FLUCF\":\"369039.000000\" }, \"C\":{ \"PST\":\"0.000000\",\"FLUC\":\"208060.968750\",\"FLUCF\":\"369239.000000\" }}}}";
|
||||
//senddata = "{\"DATA_TYPE\":\"04\",\"Monitor\":\"2606L20071\",\"Value\":{\"FLAG\":1,\"TIME\":1700193136480,\"VOLTAGE\":{\"MAG\":95.181,\"DUR\":54,\"STARTTIME\":1700193136480,\"ENDTIME\":1700193136634,\"DISKIND\":\"01\",\"WAVEFILE\":\"PQ_PQLD1_000392_20231117_115216_580\",\"PHASIC\":\"B\"}}}";
|
||||
add_sng_log(data.strText.toAscii().data());
|
||||
//char* cstr = new char[senddata.length() + 1];
|
||||
//std::strcpy(cstr, senddata.c_str());
|
||||
//add_sng_log(cstr);
|
||||
//delete[] cstr; // <20>ͷ<EFBFBD><CDB7>ڴ<EFBFBD><DAB4>ռ<EFBFBD>
|
||||
}
|
||||
#ifdef __GNUC__
|
||||
//send data
|
||||
retsize = kafkaProducer.send(senddata.c_str(), senddata.length(), topic, RdKafka::Topic::PARTITION_UA, &key);
|
||||
#endif
|
||||
|
||||
@@ -471,7 +402,6 @@ void my_kafka_send(Ckafka_data_t& data)
|
||||
else
|
||||
printf("\nFailed kafka send, monitor_id:[%s] topic:[%s]\n", key.c_str(), topic.c_str());
|
||||
|
||||
//printf("\n--------------------------------------\n%s\n--------------------------------------\n",senddata.c_str() ); // WW 2023-08-16
|
||||
}
|
||||
|
||||
void my_datahub_send(Ckafka_data_t& data)
|
||||
@@ -484,21 +414,6 @@ void my_datahub_send(Ckafka_data_t& data)
|
||||
static std::string cfg_Alm_tp;
|
||||
static bool init = false;
|
||||
if (!init) {
|
||||
//QString MyKafkaIniFilename = QString("../etc/") + QString("mykafka.ini"); //+QString::fromAscii(subdir)
|
||||
//QSettings settings(MyKafkaIniFilename, QSettings::IniFormat);
|
||||
|
||||
//QString brl_cfg = settings.value("Kafka/brokerlist", "").toString();
|
||||
//QString topic_his = settings.value("Kafka/HisTopic", "").toString();
|
||||
//QString topic_plt = settings.value("Kafka/PLTTopic", "").toString();
|
||||
//QString topic_pst = settings.value("Kafka/PSTTopic", "").toString();
|
||||
//QString topic_evt = settings.value("Kafka/EventTopic", "").toString();
|
||||
//QString topic_alm = settings.value("Kafka/AlmTopic", "").toString();
|
||||
|
||||
//cfg_His_tp = topic_his.toStdString();
|
||||
//cfg_PLT_tp = topic_plt.toStdString();
|
||||
//cfg_PST_tp = topic_pst.toStdString();
|
||||
//cfg_Evt_tp = topic_evt.toStdString();
|
||||
//cfg_Alm_tp = topic_alm.toStdString();
|
||||
|
||||
cfg_His_tp = TOPIC_STAT;
|
||||
cfg_PLT_tp = TOPIC_PLT;
|
||||
@@ -580,7 +495,6 @@ void KafkaSendThread::run()
|
||||
else if (SEND_FLAG == 2)//datahub<75><62><EFBFBD><EFBFBD>
|
||||
{
|
||||
my_datahub_send(data);
|
||||
//DataHub_Send_Datahub();
|
||||
}
|
||||
else if (SEND_FLAG == 3)//rocketmq<6D><71><EFBFBD><EFBFBD>lnk10-11
|
||||
{
|
||||
@@ -625,8 +539,6 @@ void KafkaSendThread::run()
|
||||
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>
|
||||
@@ -674,134 +586,13 @@ void KafkaSendThread::run()
|
||||
}
|
||||
|
||||
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());
|
||||
ied_t* ied;
|
||||
ied = find_ied_from_dev_code(LD_info->terminal_code);
|
||||
ied_usr_t* ied_usr = GET_IEDEXT_ADDR(ied);
|
||||
int cpuno;
|
||||
for (cpuno = 0; cpuno < ied->cpucount; cpuno++) {
|
||||
LD_info = &(ied_usr->LD_info[cpuno]);
|
||||
data.mp_id.clear();
|
||||
data.mp_id.append(LD_info->mp_id);
|
||||
|
||||
static uint32_t count = 0;
|
||||
printf("BEGIN my_kafka_send no.%i -------->>>>>>>>>>>> %s \n", count,
|
||||
QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toAscii().data());
|
||||
my_kafka_send(data);
|
||||
printf("END my_kafka_send no.%i -------->>>>>>>>>>>> %s \n\n", count++,
|
||||
QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toAscii().data());
|
||||
}
|
||||
}*/
|
||||
//lnk 20241031 <20><><EFBFBD>ټ<EFBFBD>¼ƥ<C2BC><C6A5><EFBFBD>ʡ<EFBFBD><CAA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԡ<EFBFBD><D4A1>쳣
|
||||
/*
|
||||
oss_data_t ossdata;
|
||||
bool oss_data_gotten;
|
||||
|
||||
oss_data_gotten = false;
|
||||
oss_data_list_mutex.lock();
|
||||
if (!oss_data_list.isEmpty()) {
|
||||
oss_data_gotten = true;
|
||||
ossdata = oss_data_list.takeFirst();
|
||||
}
|
||||
oss_data_list_mutex.unlock();
|
||||
|
||||
if (oss_data_gotten) {
|
||||
|
||||
char file_name[256];
|
||||
memset(file_name, 0, 256);
|
||||
sprintf(file_name, "%s", ossdata.filename.toAscii().data());
|
||||
char save_name[256];
|
||||
memset(save_name, 0, 256);
|
||||
sprintf(save_name, "%s", ossdata.savename.toAscii().data());
|
||||
QString uuid_file_name;
|
||||
|
||||
std::ofstream file(save_name); // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3A3ACB4><EFBFBD><EFBFBD>ļ<EFBFBD> example.txt
|
||||
if (file.is_open()) { // <20>ж<EFBFBD><D0B6>ļ<EFBFBD><C4BC>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>
|
||||
file << ossdata.data.toAscii().data() << "\n";
|
||||
file.close(); // <20>ر<EFBFBD><D8B1>ļ<EFBFBD>
|
||||
}
|
||||
else {
|
||||
cout << "Unable to open file\n" << endl;
|
||||
}
|
||||
|
||||
if (FILE_FLAG == 1) {
|
||||
PutOSS(file_name, save_name);
|
||||
char* file;
|
||||
// ʹ<><CAB9>strrchr<68>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>'/'<27><>λ<EFBFBD><CEBB>
|
||||
char* last_slash = strrchr(file_name, '/');
|
||||
if (last_slash != NULL) {
|
||||
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>'/'֮<><D6AE><EFBFBD>IJ<EFBFBD><C4B2>־<EFBFBD><D6BE><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
file = last_slash + 1;
|
||||
}
|
||||
else {
|
||||
// <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB>'/'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
file = file_name;
|
||||
}
|
||||
concatenate_and_separate(file_name, file, &uuid_file_name);
|
||||
}
|
||||
else if (FILE_FLAG == 2) {
|
||||
OBSFile(save_name, file_name, "putObject");
|
||||
char* file;
|
||||
// ʹ<><CAB9>strrchr<68>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>'/'<27><>λ<EFBFBD><CEBB>
|
||||
char* last_slash = strrchr(file_name, '/');
|
||||
if (last_slash != NULL) {
|
||||
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>'/'֮<><D6AE><EFBFBD>IJ<EFBFBD><C4B2>־<EFBFBD><D6BE><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
file = last_slash + 1;
|
||||
}
|
||||
else {
|
||||
// <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB>'/'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
file = file_name;
|
||||
}
|
||||
concatenate_and_separate(file_name, file, &uuid_file_name);
|
||||
}
|
||||
else if (FILE_FLAG == 3) {
|
||||
char* fileName = (char*)malloc(65 * sizeof(char));
|
||||
char* uuid = (char*)malloc(65 * sizeof(char));
|
||||
WebAPI_Uds_Upload(UDS_UPLOAD_URL, save_name, uuid, fileName);
|
||||
concatenate_and_separate(uuid, fileName, &uuid_file_name);
|
||||
free(fileName);
|
||||
free(uuid);
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
*/
|
||||
//lnk 20241031 <20><><EFBFBD>ټ<EFBFBD>¼ƥ<C2BC><C6A5><EFBFBD>ʡ<EFBFBD><CAA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԡ<EFBFBD><D4A1>쳣
|
||||
/*
|
||||
if (ossdata.log_name=="comm") {
|
||||
char tnml_code[128];
|
||||
memset(tnml_code, 0, 128);
|
||||
sprintf(tnml_code, "%s", ossdata.id.toAscii().data());
|
||||
errorlog_pgsql(tnml_code, ossdata.time, uuid_file_name);
|
||||
}
|
||||
else if (ossdata.log_name == "reason") {
|
||||
QString pgsql;
|
||||
pgsql.append(errorlog_num_pgsql(ossdata.id, ossdata.time, uuid_file_name, ossdata.list_num));
|
||||
cout << pgsql.toAscii().data() << endl;
|
||||
}
|
||||
else if (ossdata.log_name == "match") {
|
||||
QString pqsql;
|
||||
pqsql.append(errorlog_datamatch_pgsql(ossdata.id, ossdata.time, ossdata.base_mat_num, ossdata.adv_mat_num, ossdata.base_act_num, ossdata.adv_act_num, uuid_file_name));
|
||||
cout << pqsql.toAscii().data() << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::remove(save_name);
|
||||
}
|
||||
else {
|
||||
msleep(1);
|
||||
}*/
|
||||
} //while(1) {
|
||||
}
|
||||
|
||||
|
||||
//<2F>߳̽<DFB3><CCBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
@@ -1637,9 +1428,6 @@ 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);
|
||||
|
||||
|
||||
//<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) {
|
||||
@@ -1975,7 +1763,6 @@ int myMessageCallbackupdate(CPushConsumer* consumer, CMessageExt* msg)
|
||||
}
|
||||
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 << "ledger update Callback received message: " << body << std::endl;
|
||||
if (key) {
|
||||
std::cout << "Message Key: " << key << std::endl;
|
||||
@@ -2011,7 +1798,6 @@ int myMessageCallbackset(CPushConsumer* consumer, CMessageExt* msg)
|
||||
}
|
||||
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;
|
||||
@@ -2046,7 +1832,6 @@ int myMessageCallbacklog(CPushConsumer* consumer, CMessageExt* msg)
|
||||
}
|
||||
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;
|
||||
@@ -2108,8 +1893,6 @@ int myMessageCallbackrecall(CPushConsumer* consumer, CMessageExt* msg)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
return E_CONSUME_SUCCESS;
|
||||
}
|
||||
@@ -2153,12 +1936,8 @@ void mqconsumerThread::run()
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
|
||||
// ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
std::cout << "Consumer is running. " << std::endl;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>̵߳<DFB3><CCB5><EFBFBD>
|
||||
//ShutdownAndDestroyConsumer();
|
||||
}
|
||||
|
||||
//CZY 2023-08-23 get double class voltage level, if false will return 0;
|
||||
@@ -2308,22 +2087,11 @@ void try_start_mqconsumer_thread()
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
json_block_data json_blkd;
|
||||
|
||||
//void init_json_block_data()
|
||||
//{
|
||||
// json_blkd.monitorId = -1;
|
||||
// json_blkd.func_type = g_node_id;
|
||||
// //flag <20><>Ʒ<EFBFBD>ʣ<EFBFBD> <20>쳣<EFBFBD><ECB3A3>1<EFBFBD><31> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0
|
||||
// json_blkd.flag = 0; // //<2F><EFBFBD><DEB3><EFBFBD><EFBFBD>ǣ<EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><DEB3><EFBFBD>0<EFBFBD><EFBFBD><DEB3><EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD>
|
||||
// json_blkd.mms_str_map.clear();
|
||||
//}
|
||||
|
||||
//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>
|
||||
//json_block_data json_blkd; //jsonƴ<6E>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ԭ<>е<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>ICD<43>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD>LDInfo<66>ṹ<EFBFBD>д洢<D0B4><E6B4A2><EFBFBD><EFBFBD>֤һ<D6A4><D2BB><EFBFBD><EFBFBD>·һ<C2B7><D2BB>jsonƴ<6E>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void init_json_block_data(char mp_id[], char voltage_level[], int flicker_flag)//WW 2023<32><33>3<EFBFBD><33>13<31><33>16:38:41 <20><>ICD<43><EFBFBD>
|
||||
{
|
||||
// <20><> char[] ת<><D7AA>Ϊ std::string
|
||||
//QString keyString(mp_id);
|
||||
|
||||
json_block_data* pdata;
|
||||
if (flicker_flag == 1) {
|
||||
@@ -2364,23 +2132,11 @@ void init_json_block_data(char mp_id[], char voltage_level[], int flicker_flag)/
|
||||
pdata->voltage_level = get_voltage_level(voltage_level); //CZY 2023-08-23 add voltage_level
|
||||
}
|
||||
|
||||
//0. json<6F><6E><EFBFBD>ɿ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
||||
//int json_block_create_start(int MonitorId )
|
||||
//{
|
||||
// try_start_kafka_thread();
|
||||
//
|
||||
// init_json_block_data();
|
||||
// json_blkd.monitorId = MonitorId;
|
||||
// printf("\n\n---------- json_block_create_start: MonitorId=%d \n",MonitorId);
|
||||
// return TRUE;
|
||||
//}
|
||||
|
||||
|
||||
int json_block_create_start(char voltage_level[], char monid_char[], int flicker_flag, char temcode[], int line_id)//WW 2023<32><33>3<EFBFBD><33>13<31><33>16:38 : 41 <20><>ICD<43><EFBFBD>
|
||||
{
|
||||
try_start_kafka_thread();
|
||||
//WW 2023-08-22 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>߳<EFBFBD>
|
||||
//try_start_sql_thread();//lnk2024118<31><38><EFBFBD><EFBFBD>Ҫsql<71>߳<EFBFBD>
|
||||
//WW end
|
||||
|
||||
init_json_block_data(monid_char, voltage_level, flicker_flag);
|
||||
json_block_data* pdata;
|
||||
@@ -2423,13 +2179,7 @@ int json_block_create_start(char voltage_level[], char monid_char[], int flicker
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//1. json<6F><6E><EFBFBD>ɿ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
||||
//int json_block_create_time(int MonitorId , long long Time)
|
||||
//{
|
||||
// json_blkd.time = Time;
|
||||
// printf("\njson_block_create_time: MonitorId=%d,Time=%lld \n",MonitorId,Time);
|
||||
// return TRUE;
|
||||
//}
|
||||
|
||||
int json_block_create_time(char monid_char[], long long Time, int flicker_flag)//WW 2023<32><33>3<EFBFBD><33>13<31><33>16:38:41 <20><>ICD<43><EFBFBD>
|
||||
{
|
||||
json_block_data* pdata;
|
||||
@@ -2457,12 +2207,6 @@ int json_block_create_time(char monid_char[], long long Time, int flicker_flag)/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//int json_block_create_flag(int MonitorId , int flag)
|
||||
//{
|
||||
// json_blkd.flag = flag;
|
||||
// printf("\njson_block_create_flag: MonitorId=%d,flag=%d \n",MonitorId,flag);
|
||||
// return TRUE;
|
||||
//}
|
||||
|
||||
int json_block_create_flag(char monid_char[], int flag, int flicker_flag)//WW 2023<32><33>3<EFBFBD><33>13<31><33>16:38:41 <20><>ICD<43><EFBFBD>
|
||||
{
|
||||
@@ -2491,18 +2235,7 @@ int json_block_create_flag(char monid_char[], int flag, int flicker_flag)//WW 20
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//2. json<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻص<DDBB><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
//int json_block_create_data(int MonitorId , char* mms_str , double v )
|
||||
//{
|
||||
// static int count = 0;
|
||||
// //WW2023-08-16 ȥ<><C8A5>logע<67><D7A2>
|
||||
// //printf("#");
|
||||
// //if ( ((count++ %1000)==0) || (count <2000) )
|
||||
// // printf("\n%d:json_block_create_data: MonitorId=%d,mms_str=%s,v=%f \n",count,MonitorId,mms_str,v);
|
||||
//
|
||||
// json_blkd.mms_str_map.insert(QString::fromAscii(mms_str), v);
|
||||
// return TRUE;
|
||||
//}
|
||||
|
||||
|
||||
int json_block_create_data(char monid_char[], char* mms_str, double v, int flicker_flag)//WW 2023<32><33>3<EFBFBD><33>13<31><33>16:38:41 <20><>ICD<43><EFBFBD>
|
||||
{
|
||||
@@ -2535,13 +2268,6 @@ int json_block_create_data(char monid_char[], char* mms_str, double v, int flick
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//3. json<6F><6E><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//int json_block_create_end(int MonitorId )
|
||||
//{
|
||||
// printf("\n---------- json_block_create_end: MonitorId=%d \n\n\n",MonitorId);
|
||||
//
|
||||
// return transfer_json_block_data(&json_blkd);
|
||||
//}
|
||||
|
||||
//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>
|
||||
@@ -2574,8 +2300,6 @@ int json_block_create_end(char v_wiring_type[], char monid_char[], int flicker_f
|
||||
pdata = json_pst_data_map.value(monid_char);
|
||||
}
|
||||
|
||||
|
||||
//int ret = transfer_json_block_data(pdata, DevKind);//CZY 2023-08-17 <20><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
|
||||
if (pdata->mms_str_map.count() == 0) {
|
||||
if (flicker_flag == 1) {
|
||||
json_flicker_data_map.remove(monid_char);
|
||||
@@ -2639,18 +2363,6 @@ void prcess_monitor_comm_2_json(int monitor_id, int status, long long tm)
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//int transfer_json_block_data(json_block_data *data)
|
||||
//{
|
||||
// Ckafka_data_t kafka_data;
|
||||
// kafka_data.patition_id = 0;
|
||||
// kafka_data.strText = QString("Time=%1").arg(data->time);
|
||||
//
|
||||
// kafka_data_list_mutex.lock();
|
||||
// kafka_data_list.append(kafka_data);
|
||||
// kafka_data_list_mutex.unlock();
|
||||
// return TRUE;
|
||||
//}
|
||||
|
||||
void clear_old_comtrade_files()
|
||||
{
|
||||
if (g_node_id != SOE_COMTRADE_BASE_NODE_ID)
|
||||
@@ -2670,12 +2382,8 @@ void clear_old_comtrade_files()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
|
||||
//using namespace std;
|
||||
int process_login_verify()
|
||||
{
|
||||
int length = 64;
|
||||
@@ -2683,7 +2391,6 @@ int process_login_verify()
|
||||
char* p = NULL;
|
||||
int count = 0;
|
||||
char encode_password[256];
|
||||
//password = "njcnpqs@2018"
|
||||
const char* passwordConfirm = "1c0e4e104de596846648ba495bd32601";
|
||||
|
||||
memset(password, 0, sizeof(password));
|
||||
@@ -2694,131 +2401,23 @@ int process_login_verify()
|
||||
system("stty -echo");
|
||||
std::cin.getline(password, 64);
|
||||
system("stty echo");
|
||||
//while (((*p = getch()) != 13) && count < length) {
|
||||
// //putch('*');
|
||||
// //fflush(stdin);
|
||||
|
||||
// p++;
|
||||
// count++;
|
||||
//}
|
||||
password[length] = '\0';
|
||||
//printf("input typed password : %s \n",password);
|
||||
|
||||
MyGetSM4Code(password, (unsigned char*)"epri.sgcc.com.cn", encode_password);
|
||||
|
||||
//printf("encode_password : %s ,should be %s \n",encode_password,passwordConfirm);
|
||||
return (strcmp(encode_password, passwordConfirm));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////
|
||||
//WW 2023-08-22 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>̺߳<DFB3>WebSokcet<65>߳<EFBFBD>
|
||||
|
||||
void SQLExcuteThread::run()
|
||||
{
|
||||
//if (THREE_SECS_DATA_BASE_NODE_ID == g_node_id)//3<><33><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4>䲻<EFBFBD><E4B2BB>Ҫд<D2AA><D0B4>
|
||||
//return;
|
||||
|
||||
if (1 != g_iOTLFlag) {
|
||||
Sql_data_list.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
static uint32_t connect_state = 0;
|
||||
static uint32_t sql_count = 0;//2024-04-01
|
||||
const char* pSql = nullptr;
|
||||
printf("SqlExcuteThread::run() is called ...... \n\n");
|
||||
|
||||
while (1)
|
||||
{
|
||||
msleep(1);
|
||||
if (!Sql_data_list.isEmpty())
|
||||
{
|
||||
if (0 == sql_count++ % 300)
|
||||
{
|
||||
//db.connected
|
||||
int rtState = OTLDbconnected();
|
||||
//int rtState = db.connected;
|
||||
if (rtState == 0 || connect_state != 0) {
|
||||
OTLDisconnect();
|
||||
int ret = OTLConnect();
|
||||
if (ret != 0 && ret != 32031) {
|
||||
bool bExit = false;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
OTLDisconnect();
|
||||
ret = OTLConnect();
|
||||
if (ret != 0 && ret != 32031) {
|
||||
if (2 == i)
|
||||
bExit = true;
|
||||
else
|
||||
printf(">>>Postgresql reconnect %d times,errorcode= %d \n", i + 1, ret);
|
||||
}
|
||||
}
|
||||
if (bExit) {
|
||||
printf(">>>Postgresql reconnect 3 times,errorcode= %d,end thread!\n", ret);
|
||||
sleep(30);
|
||||
continue;
|
||||
//return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// printf("(д<><D0B4>)Sqlִ<6C><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Sql_data_list<73><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>= %d<><64>ʵ<EFBFBD><CAB5>Ԫ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>= %d \n", g_iSqlListSize, Sql_data_list.size());
|
||||
|
||||
Sql_data_list_mutex.lock();
|
||||
|
||||
std::string strSql = Sql_data_list.takeFirst().toStdString();
|
||||
printf("get one sql \n");
|
||||
if (strSql.length() < 11)
|
||||
{
|
||||
// printf("(д<><D0B4>)Sqlִ<6C><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Sql_data_listʣ<74><CAA3>Ԫ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>= %d<><64><EFBFBD><EFBFBD>ǰִ<C7B0><D6B4>Sql= %s<><73>continue<75><65>һ<EFBFBD><D2BB><EFBFBD>䣡\n", Sql_data_list.count(), strSql.c_str());
|
||||
continue;
|
||||
}
|
||||
pSql = strSql.c_str();
|
||||
Sql_data_list_mutex.unlock();
|
||||
|
||||
//printf("BEGIN my_sql_excute no.%i -------->>>>>>>> %s \n", count, QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toAscii().data());
|
||||
/*if (2 == Log_Enable)
|
||||
printf("(д<><D0B4>)Sqlִ<6C><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Sql_data_listʣ<74><CAA3>Ԫ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>= %i<><69><EFBFBD><EFBFBD>ǰִ<C7B0><D6B4>Sql.%i= %s \n", Sql_data_list.count(), count, pSql);*/
|
||||
printf("write one sql %s \n", pSql);
|
||||
int rt = write_to_db(pSql);
|
||||
connect_state = rt;
|
||||
printf("connect state %d \n", connect_state);
|
||||
//if (0 == rt)
|
||||
//{
|
||||
// if (1 == Log_Enable)
|
||||
// printf("(д<><D0B4>)Sqlִ<6C>гɹ<D0B3>.%i \n", count);
|
||||
// else
|
||||
// printf("(д<><D0B4>)Sqlִ<6C>гɹ<D0B3>.%i<><69>Sql= %s \n", count, pSql);
|
||||
//}
|
||||
//printf("END my_sql_excute no.%i -------->>>>>>>> %s \n\n", count++, QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toAscii().data());
|
||||
}
|
||||
}
|
||||
|
||||
printf(">>>SqlExcuteThread::run() is end!!!\n");
|
||||
}
|
||||
|
||||
void try_start_sql_thread()
|
||||
{
|
||||
static int sql_thread_created = 0;
|
||||
if (!sql_thread_created) {
|
||||
//if (2 == Log_Enable)
|
||||
// printf(">>><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Sqlִ<6C><D6B4><EFBFBD>̣߳<DFB3>\n");
|
||||
sqlThrd.start();
|
||||
sql_thread_created = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void try_start_socket_thread()
|
||||
{
|
||||
static int socket_thread_created = 0;
|
||||
if (!socket_thread_created) {
|
||||
//if (2 == Log_Enable)
|
||||
// printf(">>><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Web Socket<65>̣߳<DFB3>\n");
|
||||
socketThrd.start();
|
||||
socket_thread_created = 1;
|
||||
}
|
||||
@@ -2876,8 +2475,6 @@ void try_start_ontimer_thread()
|
||||
{
|
||||
static int ontimer_thread_created = 0;
|
||||
if (!ontimer_thread_created) {
|
||||
//if (2 == Log_Enable)
|
||||
// printf(">>><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Web Socket<65>̣߳<DFB3>\n");
|
||||
onTimerThrd.start();
|
||||
ontimer_thread_created = 1;
|
||||
}
|
||||
@@ -2888,18 +2485,13 @@ void try_start_ontimer_thread()
|
||||
//ZW 2024-01-31 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3>Ż<EFBFBD>
|
||||
static QMap<QString, int> mvl_type_ctrl_map;//ZW 2024-01-31 <20><><EFBFBD>ڱ<EFBFBD><DAB1>浥<EFBFBD>λ<EFBFBD>ȡ<EFBFBD><C8A1>ģ<EFBFBD><C4A3>
|
||||
static int mvl_type_ctrl_map_size;//<2F><><EFBFBD><EFBFBD>
|
||||
//static std::map<int, int> myMap;
|
||||
//<2F><><EFBFBD><EFBFBD>doname<6D><65>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
||||
void add_mvl_type_ctrl(char doname[], int ctrl)
|
||||
{
|
||||
//printf("\nadd_mvl_type_ctrl: %s\n", doname);
|
||||
//printf("\nadd_mvl_type_ctrl: %p////%p\n", &ctrl,©);
|
||||
if (!mvl_type_ctrl_map.contains(doname))
|
||||
{
|
||||
//MVL_TYPE_CTRL* copy = ctrl;
|
||||
mvl_type_ctrl_map.insert(doname, ctrl);
|
||||
}
|
||||
//printf("\nadd_mvl_type_ctrl: %p\n", &doname);
|
||||
}
|
||||
|
||||
//ɾ<><C9BE>map<61><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
||||
|
||||
@@ -57,38 +57,13 @@ extern void redirectErrorOutput(bool enable);
|
||||
extern void redirectWarnOutput(bool enable);
|
||||
extern void redirectNormalOutput(bool enable);
|
||||
extern void redirectDebugOutput(bool enable);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//struct json_pair_info
|
||||
//{
|
||||
// string topic; //<Topic name="HISDATA" desc="<22><>ʷ<EFBFBD><CAB7><EFBFBD><EFBFBD>"> "RTDATA" ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD> "RTDATASOE"ʵʱSOE<4F>¼<EFBFBD> <20><>
|
||||
// string data_type; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>01/04:<3A><>̬/<2F>ٲ<EFBFBD><D9B2><EFBFBD>̬<EFBFBD><CCAC>02/05:<3A><><EFBFBD><EFBFBD>/<2F>ٲ<EFBFBD><D9B2><EFBFBD><EFBFBD>䣬03/06:<3A><>̬/<2F>ٲ<EFBFBD><D9B2><EFBFBD>̬
|
||||
// string item; //<Item name="V" desc="<22><>ѹ" type="4" > <20><>"I" "PQ" <20><>
|
||||
// string sequence; //"A" <20><> "B" <20><> "C" <20><> "T"
|
||||
// string name; //json<6F><6E>key
|
||||
// int type; //6-ֵ<><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>9-ʵʱSOE<4F>¼<EFBFBD>
|
||||
// string mms_ref; //mms<6D><73>ַ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||
// float coeff; //Coefficient:<3A><><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>
|
||||
// unsigned short PltFlag; //0xffff
|
||||
//};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class KafkaSendThread : public QThread
|
||||
{
|
||||
// Q_OBJECT
|
||||
//public:
|
||||
|
||||
protected:
|
||||
void run();
|
||||
};
|
||||
//WW 2023-08-22 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>̺߳<DFB3>WebSocket<65>߳<EFBFBD>
|
||||
class SQLExcuteThread : public QThread
|
||||
{
|
||||
protected:
|
||||
void run();
|
||||
};
|
||||
|
||||
class WebSocketThread : public QThread
|
||||
{
|
||||
@@ -107,12 +82,7 @@ class httpThread : public QThread
|
||||
protected:
|
||||
void run();
|
||||
};
|
||||
//lnk20241202
|
||||
/*class mqtestThread : public QThread
|
||||
{
|
||||
protected:
|
||||
void run();
|
||||
};*/
|
||||
|
||||
//lnk20250106
|
||||
extern bool showinshellflag;
|
||||
|
||||
@@ -644,12 +614,9 @@ protected:
|
||||
//WW 2023-08-22 end
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
//lnk20250106<30><36><EFBFBD><EFBFBD>̨<EFBFBD>˽ṹ
|
||||
typedef struct terminal terminal;
|
||||
typedef struct monitor monitor;
|
||||
|
||||
@@ -74,7 +74,6 @@ int json_block_create_data(char monid_char[], char* mms_str , double v, int flic
|
||||
//3. json<6F><6E><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//lnk2024-8-16<31><36><EFBFBD>Ӳ<EFBFBD><D3B2><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>
|
||||
void add_mvl_type_ctrl(char doname[], int ctrl);
|
||||
@@ -88,15 +87,6 @@ typedef struct LD_info_t LD_info_t;
|
||||
int urcbRealDataHasReceived(int dev_index, LD_info_t* LD_info, long long Time); //lnk20241223
|
||||
#endif
|
||||
|
||||
//void set_log_LineID(int id);
|
||||
//void set_rpt_LineID(int id);
|
||||
|
||||
//void set_log_TimeID(apr_time_t time);
|
||||
//void set_rpt_TimeID(apr_time_t time);
|
||||
|
||||
//void set_log_QualityFlag(int QualityFlag);
|
||||
//void set_rpt_QualityFlag(int QualityFlag);
|
||||
|
||||
int is_rpt_Time_exact_hour() ;
|
||||
|
||||
apr_status_t app_get_private_config(const char *myfilename);
|
||||
@@ -165,7 +155,6 @@ int testbase64();
|
||||
|
||||
|
||||
//////////////////////////////WW 20230822<32><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>WebSocket<65>߳<EFBFBD>
|
||||
void try_start_sql_thread(); //<2F><><EFBFBD><EFBFBD>Sqlִ<6C><D6B4><EFBFBD>߳<EFBFBD>
|
||||
void try_start_socket_thread(); //<2F><><EFBFBD><EFBFBD>Web Socket<65>߳<EFBFBD>
|
||||
void try_start_ontimer_thread();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>߳<EFBFBD>s
|
||||
/////////////////////////////WW end
|
||||
@@ -202,24 +191,11 @@ int parse_device_web_test_front_read();
|
||||
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);
|
||||
int OTL_Select_DecideRecall_web(char* time, char* id);
|
||||
bool CheckPG_To_Recall_web(long long start, long long end, char* Monitorid);
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/*int parse_database_delete(const std::vector<std::string>& codes);
|
||||
int parse_commerror_write(const std::vector<std::string>& codes);
|
||||
int parse_commstatus_write(const std::vector<std::string>& codes);
|
||||
int parse_match_write(const std::vector<std::string>& codes);
|
||||
int parse_dataintegrity_write(const std::vector<std::string>& codes);
|
||||
int parse_rationality_write(const std::vector<std::string>& codes);*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
67
mms/main.c
67
mms/main.c
@@ -26,9 +26,8 @@ extern pthread_mutex_t mtx;
|
||||
extern pt61850app_t *g_pt61850app;
|
||||
extern node_t *g_node;
|
||||
char g_my_conf_fname[256];
|
||||
//extern byte_t g_Master;
|
||||
|
||||
char g_onlyIP[255]; //ֱ<><D6B1>ij<EFBFBD><C4B3>IP<49><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//extern byte_t g_protect_file; //0:<3A><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD> 1:<3A>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD>
|
||||
|
||||
apr_pool_t *g_root_pool;
|
||||
apr_pool_t *g_rdb_pool;
|
||||
@@ -122,7 +121,6 @@ void init_daemon(void)
|
||||
//"--subdir, set the subdir of /CloudForward/ as the working directory, \n"
|
||||
int usage()
|
||||
{
|
||||
// fprintf(stderr,"\n\n******** IEC61850 Protocol ********\n");
|
||||
fprintf(stderr,"\nUsage : pt61850netd_pqfe -d [subdir] \n");
|
||||
|
||||
exit(-1);
|
||||
@@ -179,16 +177,9 @@ int prepare_entironment_2()
|
||||
return (-1);
|
||||
}
|
||||
|
||||
//g_fun_pool = 0;
|
||||
|
||||
//rv = apr_thread_mutex_create(&g_rdb_mutex, APR_THREAD_MUTEX_NESTED,g_root_pool);//<2F><><EFBFBD><EFBFBD>RDB<44><42>
|
||||
//if ( rv != APR_SUCCESS) {
|
||||
// return rv;
|
||||
//}
|
||||
/* Initialize the register table. Call these functions first! */
|
||||
echo_msg1("%-60s","Initialize system register......");
|
||||
//init_default_dbparser_table(); //<2F><><EFBFBD>ݸ<EFBFBD>XML<4D>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>RDB<44><42>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
||||
//load_driver_library(); //<2F><><EFBFBD>ø<EFBFBD><C3B8>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
echo_msg("OK\n\n");
|
||||
|
||||
initTimezoneOffset();
|
||||
@@ -211,11 +202,8 @@ void printf_cur_user()
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
|
||||
// ipcclient_t *ipcclient = NULL;
|
||||
// void *cookie = NULL;
|
||||
uint32_t stimer = 1;
|
||||
apr_status_t rv;
|
||||
// int pid;
|
||||
|
||||
/* Prepare the system context */
|
||||
rv=prepare_entironment_2();
|
||||
@@ -225,22 +213,6 @@ int main(int argc, const char **argv)
|
||||
|
||||
getVersion(argc,argv);
|
||||
|
||||
////////////////////
|
||||
//WW <20><><EFBFBD><EFBFBD>json
|
||||
//TestJson(NULL);
|
||||
//WW 2023-08-31 end
|
||||
///////////////////
|
||||
//TestSMSPost();//WW 2023-08-28<32><38><EFBFBD>Թ<EFBFBD>˾post
|
||||
//TestBodyPost();
|
||||
//TestToken();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դҵ<D4B4><D2B5><EFBFBD><EFBFBD>̨
|
||||
|
||||
////////////////////
|
||||
//WW <20><><EFBFBD><EFBFBD>json
|
||||
//TestOSS();
|
||||
//TestOBS();
|
||||
//WW 2023-09-01 end
|
||||
///////////////////
|
||||
/* Parse the command-line parameter */
|
||||
rv=parse_param(argc, argv);
|
||||
if (rv!=APR_SUCCESS){
|
||||
return rv;
|
||||
@@ -280,9 +252,6 @@ int main(int argc, const char **argv)
|
||||
return rv;
|
||||
}
|
||||
|
||||
//lnk20241024ȥ<34><C8A5><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
//OTLConnect();
|
||||
|
||||
rv = run_protocol();
|
||||
if (rv!=APR_SUCCESS){
|
||||
return rv;
|
||||
@@ -360,10 +329,8 @@ int parse_param(int argc, const char **argv)
|
||||
|
||||
char *p;
|
||||
char temp[128];
|
||||
//int g_front_seg_index, g_front_seg_num;
|
||||
/* Set default command-line parameter */
|
||||
|
||||
g_node_id = 0;
|
||||
//g_protect_file = 0;
|
||||
|
||||
echo_warn2("================= compiled@ %s %s =================\n",__DATE__ , __TIME__ );
|
||||
|
||||
@@ -383,18 +350,7 @@ int parse_param(int argc, const char **argv)
|
||||
break;
|
||||
case 'R':
|
||||
case 'r':
|
||||
// if (opt_arg[0] >= '0' && opt_arg[0] <= '9' )
|
||||
// {
|
||||
// g_client_id = atoi(opt_arg);
|
||||
// if (g_client_id>2||g_client_id<0)
|
||||
// {
|
||||
// printf("Do not support triple or above clients \n ");
|
||||
// return (usage());
|
||||
// }
|
||||
////g_auto_client_id = FALSE;
|
||||
// }
|
||||
// else
|
||||
// return (usage());
|
||||
|
||||
break;
|
||||
case 's':
|
||||
case 'S':
|
||||
@@ -413,11 +369,6 @@ int parse_param(int argc, const char **argv)
|
||||
|
||||
printf("g_front_seg_num:%d",g_front_seg_num);
|
||||
|
||||
//echo_warn2("================= compiled@ %d %d =================\n", g_front_seg_index, g_front_seg_num);
|
||||
//lnk20241206<30><36><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>¼subdir<69><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
|
||||
//echo_warn1("subdir %s ", opt_arg + 6);
|
||||
//strcpy(subdir, opt_arg + 6);
|
||||
|
||||
break;
|
||||
break;
|
||||
case 'a':
|
||||
@@ -433,14 +384,7 @@ int parse_param(int argc, const char **argv)
|
||||
break;
|
||||
case 'f':
|
||||
case 'F':
|
||||
//if (opt_arg[strlen(opt_arg)-1] == '/'
|
||||
// || opt_arg[strlen(opt_arg)-1] == '\\') {
|
||||
// echo_errg( "Error: Bad or invalid file name");
|
||||
// return (usage());
|
||||
// }
|
||||
// //g_my_conf_fname = SHR_GetPrivateFileName(opt_arg,g_root_pool);
|
||||
// echo_warn1("using config file %s!\n", g_my_conf_fname);
|
||||
// break;
|
||||
break;
|
||||
case 'P':
|
||||
case 'p':
|
||||
if (opt_arg[0] >= '0' && opt_arg[0] <= '9' ) {
|
||||
@@ -459,7 +403,6 @@ int parse_param(int argc, const char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////<2F><><EFBFBD>Ӳ<EFBFBD><D3B2>Խ<EFBFBD><D4BD>̵ļ<CCB5><C4BC>غ<EFBFBD><D8BA><EFBFBD>lnk20250304
|
||||
void doMonitorTaskmain(void) {
|
||||
static int stimer = 0;
|
||||
|
||||
@@ -81,39 +81,6 @@ extern char* UDS_UPLOAD_URL;
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
//lnk20250122start
|
||||
#if 0
|
||||
apr_status_t init_rem_dib_table()
|
||||
{
|
||||
int pos = 0;
|
||||
int iedno,chnl_no;
|
||||
ied_t *ied;
|
||||
struct in_addr ip;
|
||||
chnl_usr_t *chnl_usr;
|
||||
|
||||
set_rem_dib_table_size( g_pt61850app->chnl_counts );
|
||||
g_pt61850app->chnl_usr = apr_pcalloc( g_init_pool,g_pt61850app->chnl_counts*sizeof(chnl_usr_t*) );
|
||||
printf( "set_rem_dib_table_size %d \n",g_pt61850app->chnl_counts );
|
||||
for(iedno=0 ; iedno<g_node->n_clients; iedno++) {
|
||||
ied = g_node->clients[iedno];
|
||||
for(chnl_no=0 ; chnl_no<ied->chncount; chnl_no++) {
|
||||
chnl_usr = ied->channel[chnl_no].connect;
|
||||
g_pt61850app->chnl_usr[pos] = chnl_usr;
|
||||
ip.s_addr = htonl(ied->channel[chnl_no].addr);
|
||||
strcpy(chnl_usr->ip_str,inet_ntoa(ip));
|
||||
printf( " add_rem_dib_table %s:%d \n",chnl_usr->ip_str ,ied->channel[chnl_no].port );
|
||||
add_rem_dib_table (pos++,chnl_usr->ip_str,ied->channel[chnl_no].port );
|
||||
{
|
||||
char comm_str[256];
|
||||
memset(comm_str,0,256);
|
||||
apr_snprintf(comm_str,sizeof(comm_str),"%16s:%d\t\tinited",chnl_usr->ip_str,ied->channel[chnl_no].port);
|
||||
add_comm_log(comm_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
apr_status_t init_rem_dib_table()
|
||||
{
|
||||
int pos = 0;
|
||||
@@ -174,19 +141,7 @@ void CloseIECReports(chnl_usr_t *chnl_usr)
|
||||
continue;
|
||||
if ( rptinfo->chnl_id != chnl_usr->chnl_id)
|
||||
continue;
|
||||
/*get_rpt_inst_name(rptinfo,rpt_inst_name);
|
||||
ret = mms_unregister_iec_rpt (chnl_usr->net_info, &g_rpt_typeids,
|
||||
LD_info->LD_name,rpt_inst_name,g_pt61850app->mmsOpTimeout );
|
||||
if(ret == SD_FAILURE)
|
||||
{
|
||||
echo_warn3("unregister iec_rpt failed !!! domain: %s ,rpt_inst_name: %s ,chnl_id: %d \n",
|
||||
LD_info->LD_name,rpt_inst_name,chnl_usr->chnl_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("unregister iec_rpt succeed, domain: %s ,rpt_inst_name: %s ,chnl_id: %d \n",
|
||||
LD_info->LD_name,rpt_inst_name,chnl_usr->chnl_id);
|
||||
} */
|
||||
|
||||
rptinfo->rpt_registered = FALSE;
|
||||
//ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>10<31><30><EFBFBD><EFBFBD> <20><>ע<EFBFBD><D7A2>һ<EFBFBD>ε<EFBFBD><CEB5><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||
rptinfo->m_LastRegisterFailedTime = sGetMsTime() -10*60*1000;
|
||||
@@ -195,24 +150,6 @@ void CloseIECReports(chnl_usr_t *chnl_usr)
|
||||
}
|
||||
}
|
||||
|
||||
void prcess_ied_comm_2_json(ied_t *ied,int status)
|
||||
{
|
||||
ied_usr_t *ied_usr = NULL;
|
||||
LD_info_t *LD_info = NULL;
|
||||
int cpuno ;
|
||||
apr_time_t tm = apr_time_now()/1000;
|
||||
|
||||
if (!three_secs_enabled)
|
||||
return;
|
||||
ied_usr = (ied_usr_t*)ied->usr_ext;
|
||||
for(cpuno=0 ; cpuno<ied->cpucount; cpuno++) {
|
||||
LD_info = &(ied_usr->LD_info[cpuno]);
|
||||
if (LD_info ) {
|
||||
//prcess_monitor_comm_2_json(LD_info->line_id,status,tm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void closeChannel(chnl_usr_t *chnl_usr)
|
||||
{
|
||||
char comm_str[256];
|
||||
@@ -221,9 +158,6 @@ void closeChannel(chnl_usr_t *chnl_usr)
|
||||
add_comm_log(comm_str);
|
||||
FRONT_MP_NUM--;
|
||||
echo_warn1("Close Channel IP: %s",chnl_usr->ip_str );
|
||||
//prcess_ied_comm_2_json(chnl_usr->chnl->ied,STATUS_BREAKOFF);
|
||||
//RDB_SetIedChnlStatus(chnl_usr->chnl->ied, STATUS_BREAKOFF, chnl_usr->chnl_id);
|
||||
//write_status_to_db(0,chnl_usr->chnl->addr);
|
||||
|
||||
CloseIECReports(chnl_usr);
|
||||
echo_warn1("-------Close Channel IP: %s success!!!!!!!!!", chnl_usr->ip_str);
|
||||
@@ -247,15 +181,15 @@ void closeChannel(chnl_usr_t *chnl_usr)
|
||||
|
||||
if (ret != SD_SUCCESS){
|
||||
echo_warn("---------disconnectFromServer success!\n");
|
||||
//cout<<endl<<endl<<GetIP()<<" mms_disconnectFromServer failed ,Disconnect it roughly!"<<endl;
|
||||
|
||||
echo_warn2( "CHANNEL %s,NetInfo= %x mms_disconnectFromServer failed ,Disconnect it roughly! \n",chnl_usr->ip_str,chnl_usr->net_info);
|
||||
//mms_release_connection(chnl_usr->net_info); ???????
|
||||
|
||||
mvl_free_req_ctrl(chnl_usr->m_reqCtrl);
|
||||
|
||||
chnl_usr->net_info->user_ext = NULL;
|
||||
chnl_usr->net_info = NULL;
|
||||
|
||||
//cout<<"CHANNEL Close roughly, NetInfo_Channel_Map.entries()= "<<NetInfo_Channel_Map.entries()<<endl;
|
||||
|
||||
chnl_usr->m_reqCtrl = NULL;
|
||||
chnl_usr->net_info = NULL;
|
||||
chnl_usr->m_state = CHANNEL_DISCONNECTED;
|
||||
@@ -270,7 +204,7 @@ void closeChannel(chnl_usr_t *chnl_usr)
|
||||
}else {
|
||||
chnl_usr->m_state = CHANNEL_DISCONNECTED;
|
||||
chnl_usr->m_ClosedMsTime = sGetMsTime();
|
||||
//cout<<"m_ClosedMsTime "<<m_ClosedMsTime<<endl;
|
||||
|
||||
chnl_usr->chnl->status = STATUS_BREAKOFF;
|
||||
}
|
||||
}
|
||||
@@ -280,7 +214,7 @@ ST_VOID Callback_channel_disconnect_ind(MVL_NET_INFO * NetInfo, ST_INT discType)
|
||||
chnl_usr_t *chnl_usr;
|
||||
|
||||
chnl_usr = (chnl_usr_t*)NetInfo->user_ext;
|
||||
//cout<<"NetInfo_Channel_Map.entries()= "<<NetInfo_Channel_Map.entries()<<endl;
|
||||
|
||||
if ( chnl_usr ) {
|
||||
if(chnl_usr->m_state == CHANNEL_CONNECTING)
|
||||
{ //do nothing;
|
||||
@@ -296,22 +230,15 @@ ST_VOID Callback_channel_disconnect_ind(MVL_NET_INFO * NetInfo, ST_INT discType)
|
||||
printf("Do nothing,m_state == CHANNEL_DISCONNECTED ,NetInfo = %x",NetInfo);
|
||||
}
|
||||
|
||||
//cout <<"NetInfo_Channel_Map[NetInfo] " << pCh <<endl ;
|
||||
|
||||
chnl_usr->net_info = NULL;
|
||||
NetInfo->user_ext = NULL;
|
||||
|
||||
}
|
||||
printf(" Callback_channel_disconnect_ind ,NetInfo = %x",NetInfo);
|
||||
/* cout<<"after: NetInfo_Channel_Map.entries()= "<<NetInfo_Channel_Map.entries()<<endl;*/
|
||||
|
||||
//zw<7A><EFBFBD> 2023 - 8 - 17 ͨѶ<CDA8>жϻص<CFBB><D8B5><EFBFBD><EFBFBD><EFBFBD> PG<50><47><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>жϴ<D0B6><CFB4><EFBFBD>
|
||||
ied_usr_t* ied_usr = (ied_usr_t*)(chnl_usr->chnl[0].ied->usr_ext);
|
||||
//printf("%s", ied_usr->terminal_code);
|
||||
//connectlog_pgsql(ied_usr->terminal_code);
|
||||
//apr_time_t tm = apr_time_now();//
|
||||
//printf("time: %llu", tm);
|
||||
//apr_time_exp_t pTm;
|
||||
//apr_time_exp_gmt(&pTm, tm);
|
||||
//printf("time: %u %u %u", pTm.tm_year, pTm.tm_mon, pTm.tm_mday);
|
||||
}
|
||||
|
||||
|
||||
@@ -369,26 +296,25 @@ void ChannelCheckIECReports(chnl_usr_t *chnl_usr)
|
||||
ied_usr = GET_IEDEXT_ADDR(ied);
|
||||
channel = chnl_usr->chnl;
|
||||
|
||||
//printf("check error %s !!!!!!!!!!!!!!cpucount:%d\n",((ied_usr_t*)chnl_usr->chnl->ied->usr_ext)->terminal_id,(int)ied->cpucount);
|
||||
|
||||
//printf("1 chnl_usr->ip_str = %s \n",chnl_usr->ip_str);
|
||||
for(cpuno=0 ; cpuno<ied->cpucount; cpuno++)
|
||||
//for(cpuno = ied->cpucount - 1; cpuno >= 0; cpuno--)
|
||||
|
||||
{
|
||||
LD_info = &(ied_usr->LD_info[cpuno]); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
if (LD_info->cpuno==0)
|
||||
continue;
|
||||
//printf("2 chnl_usr->ip_str = %s \n",chnl_usr->ip_str);
|
||||
|
||||
for(rpt_no=0 ; rpt_no<LD_info->rptcount; rpt_no++) { //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>棨ӳ<E6A3A8><D3B3><EFBFBD>ļ<EFBFBD><C4BC>ж<EFBFBD>ȡ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>
|
||||
rptinfo = LD_info->rptinfo[rpt_no] ;
|
||||
/*if ( strstr(rptinfo->rptID,"LLN0$RP$urcbRealData") )
|
||||
continue;*/
|
||||
|
||||
if (judge_rpt_next_should_do(rptinfo)==SHOULD_DO_NOTHING)//<2F><><EFBFBD><EFBFBD><EFBFBD>Ƿ<C7B7>
|
||||
continue;
|
||||
//printf("3 chnl_usr->ip_str = %s \n",chnl_usr->ip_str);
|
||||
|
||||
if(rptinfo->m_curRptSuffix==-1)
|
||||
rptinfo->m_curRptSuffix = g_pt61850app->rptSuffix[g_client_id][0] ;
|
||||
rptinfo->m_curRptSuffix = g_pt61850app->rptSuffix[g_client_id][0] ;
|
||||
|
||||
get_rpt_inst_name(rptinfo,rpt_inst_name);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
if ( ! rptinfo->rpt_registered ) {
|
||||
if ( (sGetMsTime() -rptinfo->m_LastRegisterFailedTime) > 20*1000 ) {
|
||||
//ע<><D7A2>ʧ<EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD><EFBFBD><EFBFBD> 20<32><30> <20><>ע<EFBFBD><D7A2>һ<EFBFBD><D2BB>
|
||||
@@ -397,84 +323,39 @@ void ChannelCheckIECReports(chnl_usr_t *chnl_usr)
|
||||
|
||||
if ( strstr(rptinfo->rptID,"LLN0$BR$brcbFlickerData") )
|
||||
rptinfo->IntgPd = 600; //10<31><30><EFBFBD><EFBFBD>
|
||||
|
||||
/////////////////////////WW 2023-08-30 <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD>뱨<EFBFBD><EBB1A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
rcb_info = mms_register_iec_rpt (chnl_usr->net_info, &g_rpt_typeids,
|
||||
LD_info->LD_name,rpt_inst_name,g_pt61850app->mmsOpTimeout, rptinfo->IntgPd,rptinfo->TrgOpt,
|
||||
(ST_UINT8*)rptinfo->m_EntryID ,(ST_UINT8*)rptinfo->OptFlds);
|
||||
//rcb_info = mms_register_iec_rpt_by_devtype(chnl_usr->net_info, &g_rpt_typeids,
|
||||
// LD_info->LD_name, rpt_inst_name, g_pt61850app->mmsOpTimeout, ied_usr->dev_type, chnl_usr->ip_str, channel->port,
|
||||
// rptinfo->IntgPd, rptinfo->TrgOpt,
|
||||
// (ST_UINT8*)rptinfo->m_EntryID, (ST_UINT8*)rptinfo->OptFlds);
|
||||
//WW end
|
||||
///////////////////////////
|
||||
if( !rcb_info )
|
||||
{
|
||||
if ( ++rptinfo->m_curRptSuffix > g_pt61850app->rptSuffix[g_client_id][1] )
|
||||
rptinfo->m_curRptSuffix = g_pt61850app->rptSuffix[g_client_id][0] ;
|
||||
|
||||
rptinfo->m_LastRegisterFailedTime = sGetMsTime() ;
|
||||
|
||||
echo_err9("\nע<EFBFBD>ᱨ<EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>Rregister iec_rpt failed !!! IED_ID=%d ,CPU=%d , domain: %s ,rpt_inst_name: %s ,ip: %s:%d,chnl_id: %d ,IntgPd=%d ,TrgOpt=0x%x \n",
|
||||
APR_EGENERAL, LD_info->ied->id,LD_info->cpuno,LD_info->LD_name,rpt_inst_name,chnl_usr->ip_str,chnl_usr->chnl->port,
|
||||
chnl_usr->chnl_id, rptinfo->IntgPd,rptinfo->TrgOpt );
|
||||
|
||||
//<2F><><EFBFBD>ټ<EFBFBD>¼<EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD>־lnk20241104
|
||||
/*if (g_node_id == SOE_COMTRADE_BASE_NODE_ID)
|
||||
{
|
||||
//<2F>ݽ<EFBFBD><DDBD>¼<EFBFBD><C2BC><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼
|
||||
SoeRptSql(LD_info->terminal_code,1, rptinfo->rptID);
|
||||
}*/
|
||||
//zw<7A><EFBFBD> 2023 - 8 - 18 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܼ<EFBFBD>¼
|
||||
//printf("start %s \n", Rpt_errorlog_json());
|
||||
//insert into "MEAS_PQ_COMM_ERROR_TR"("TERMINAL_ID","COMM_DATE","FILE_NAME") values('8afaa9a15707483a0157262f8e78077d',date'2023-08-18','FILENAME111')
|
||||
//char ERROR_DES[256] = "", ERROR_PARAM[256] = "";
|
||||
//char** varnames;
|
||||
//int varnum,j;
|
||||
////double beforeCallDomainMsTime = sGetMsTime() ;
|
||||
//ST_RET ret = mms_mvla_getnam(chnl_usr->net_info, VMD_SPEC, NULL, MMS_CLASS_DOM, g_pt61850app->mmsOpTimeout,
|
||||
// &varnames, &varnum, g_pt61850app->tmp_pool);
|
||||
//for (j = 0; j < varnum; ++j) {
|
||||
// //printf("LD %d name: %s \n", j, varnames[j]);
|
||||
// strcat(ERROR_PARAM, varnames[j]);
|
||||
// strcat(ERROR_PARAM, " ");
|
||||
//}
|
||||
|
||||
//ret = mms_mvla_getnam(chnl_usr->net_info, DOM_SPEC, varnames[1], MMS_CLASS_VARLIST, 3,
|
||||
// &varnames, &varnum, g_pt61850app->tmp_pool);
|
||||
//for (j = 0; j < varnum; ++j) {
|
||||
// //printf("LD %d name: [%s] \n", j, varnames[j]);
|
||||
// strcat(ERROR_PARAM, varnames[j]);
|
||||
// strcat(ERROR_PARAM, " ");
|
||||
//}
|
||||
|
||||
//strcat(ERROR_DES, ied_usr->org_name);
|
||||
//strcat(ERROR_DES, ",");
|
||||
//strcat(ERROR_DES, ied_usr->station_name);
|
||||
//strcat(ERROR_DES, ",");
|
||||
//strcat(ERROR_DES, ied_usr->dev_type);
|
||||
//strcat(ERROR_DES, ",");
|
||||
//strcat(ERROR_DES, chnl_usr->ip_str);
|
||||
//strcat(ERROR_DES, ",");
|
||||
//strcat(ERROR_DES, rpt_inst_name);
|
||||
//errorlog_json(LD_info->terminal_code, chnl_usr->ip_str, chnl_usr->chnl->port, g_node_id, "<22><><EFBFBD>津<EFBFBD><E6B4A5>ʧ<EFBFBD><CAA7>", ERROR_DES, ERROR_PARAM);
|
||||
}
|
||||
else
|
||||
{
|
||||
//<2F><><EFBFBD>ټ<EFBFBD>¼<EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD>־lnk20241104
|
||||
/*if (g_node_id == SOE_COMTRADE_BASE_NODE_ID)
|
||||
{
|
||||
//<2F>ݽ<EFBFBD><DDBD>¼<EFBFBD><C2BC><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܼ<EFBFBD>¼
|
||||
SoeRptSql(LD_info->terminal_code, 0, rptinfo->rptID);
|
||||
}*/
|
||||
|
||||
double GIoffset;
|
||||
rptinfo->rpt_registered = TRUE;
|
||||
//rptinfo->m_LastDataTime = sGetMsTime();//WW 2023-08-29 ȥ<><C8A5>
|
||||
rptinfo->m_rcb_info = rcb_info;
|
||||
rptinfo->chnl_id = chnl_usr->chnl_id;
|
||||
chnl_usr->m_NegRespTimes = 0;
|
||||
chnl_usr->m_LastPosRespTime = sGetMsTime();
|
||||
|
||||
echo_msg11("\nRegister iec_rpt succeed, IED_ID=%d ,CPU=%d ,domain: %s ,rpt_inst_name: %s ,ip: %s:%d,chnl_id: %d ,IntgPd=%d ,TrgOpt=0x%x ,OptFlds=0x%x%x \n",
|
||||
LD_info->ied->id,LD_info->cpuno,LD_info->LD_name,rpt_inst_name,chnl_usr->ip_str,chnl_usr->chnl->port,chnl_usr->chnl_id,
|
||||
rptinfo->IntgPd,rptinfo->TrgOpt,rptinfo->OptFlds[0],rptinfo->OptFlds[1] );
|
||||
|
||||
// add here to GI not the same time
|
||||
GIoffset = 0.5 * g_pt61850app->giTime;
|
||||
rptinfo->m_LastGITime = sGetMsTime() - GIoffset*1000;
|
||||
@@ -486,8 +367,10 @@ void ChannelCheckIECReports(chnl_usr_t *chnl_usr)
|
||||
if ( (sGetMsTime() -rptinfo->m_LastUnRegisterFailedTime) > 20*1000 ) {
|
||||
//ȡ<><C8A1>ע<EFBFBD><D7A2>ʧ<EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD><EFBFBD><EFBFBD> 20<32><30> <20><>ȡ<EFBFBD><C8A1>ע<EFBFBD><D7A2>һ<EFBFBD><D2BB>
|
||||
printf("start mms_unregister_iec_rpt................................\n");
|
||||
|
||||
ret = mms_unregister_iec_rpt (chnl_usr->net_info, &g_rpt_typeids,
|
||||
LD_info->LD_name,rpt_inst_name,g_pt61850app->mmsOpTimeout);
|
||||
|
||||
if( ret == SD_FAILURE ) {
|
||||
rptinfo->m_LastUnRegisterFailedTime = sGetMsTime() ;
|
||||
echo_err6("\nȡ<EFBFBD><EFBFBD>ע<EFBFBD>ᱨ<EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>UnRregister iec_rpt failed !!! IED_ID=%d ,CPU=%d , domain: %s ,rpt_inst_name: %s ,ip: %s,chnl_id: %d \n",
|
||||
@@ -500,20 +383,8 @@ void ChannelCheckIECReports(chnl_usr_t *chnl_usr)
|
||||
}
|
||||
printf("end mms_unregister_iec_rpt................................\n");
|
||||
}
|
||||
//double nowMsTime = sGetMsTime() ;
|
||||
//int ScanRateMs = 3*rptinfo->IntgPd*1000;
|
||||
//if (rptinfo->chnl_id==chnl_usr->chnl_id) {
|
||||
// //IECReport_tryGI(chnl_usr,rptinfo);
|
||||
// if ( (ScanRateMs) && BSTR_BIT_GET( &(rptinfo->TrgOpt), TRGOPS_BITNUM_INTEGRITY ) ) // IntgPd<50><64>ʱ<EFBFBD><CAB1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
|
||||
// if ( (nowMsTime - rptinfo->m_LastDataTime) > ScanRateMs )
|
||||
// {
|
||||
// echo_err4("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IntgPd<50><64>ʱ<EFBFBD><CAB1>δ<EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD>ݣ<EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, domain: %s ,rpt_inst_name: %s ,ip: %s,chnl_id: %d \n",
|
||||
// APR_EGENERAL,LD_info->LD_name,rpt_inst_name,chnl_usr->ip_str,chnl_usr->chnl_id);
|
||||
// closeChannel(chnl_usr);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
} //else { //rpt_registered ==TRUE
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -560,7 +431,7 @@ void ChannelCheckIECLogs(chnl_usr_t *chnl_usr)
|
||||
apr_sleep(apr_time_from_sec(1) / 10);
|
||||
|
||||
Check_Recall_Config(LD_info->mp_id);//<2F><><EFBFBD>Ի<EFBFBD>ȡxml<6D>ṹ
|
||||
//add_comm_log(LD_info->mp_id);
|
||||
|
||||
if (LD_info->autorecallcount != 0 && LD_info->autorecallflag != 1) {
|
||||
int i;
|
||||
int failed_count = 0;
|
||||
@@ -568,51 +439,22 @@ void ChannelCheckIECLogs(chnl_usr_t *chnl_usr)
|
||||
|
||||
LD_info->autorecallflag = 1;
|
||||
|
||||
//loginfo->need_steady = 1; loginfo->need_voltage = 1;
|
||||
//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>̬lnk20241030<33><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<DEB8>Check_Recall_Config<69><67>xml<6D>ļ<EFBFBD><C4BC><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ݺ<DDBA>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>LD_info
|
||||
loginfo->need_steady = LD_info->autorecall[i]->need_steady; loginfo->need_voltage = LD_info->autorecall[i]->need_voltage;
|
||||
|
||||
loginfo->start_time = apr_time_from_sec(LD_info->autorecall[i]->start - 5);
|
||||
loginfo->end_time = apr_time_from_sec(LD_info->autorecall[i]->end - 5);
|
||||
//printf("bef mms_jread............. %11d %11d \n", LD_info->autorecall[i]->start, LD_info->autorecall[i]->end);
|
||||
|
||||
if (loginfo->need_steady == 0 && loginfo->need_voltage == 0)
|
||||
continue;
|
||||
if (loginfo->end_time <= loginfo->start_time)
|
||||
continue;
|
||||
/*if ( (sGetMsTime() -loginfo->last_checktime) < 180*1000 )
|
||||
continue;*/
|
||||
|
||||
//loginfo->last_checktime = sGetMsTime();
|
||||
printf("start mms_jread................................\n");
|
||||
//now = sGetMsTime();
|
||||
//last_check_recall_config_time = now;
|
||||
//printf("start ==============%.2f================\n", last_check_recall_config_time);
|
||||
|
||||
echo_msg6("\n mms_jread IED_ID=%d ,CPU=%d ,domain: %s ,logName: %s ,ip: %s,chnl_id: %d \n",
|
||||
LD_info->ied->id, LD_info->cpuno, LD_info->LD_name, loginfo->logName, chnl_usr->ip_str, chnl_usr->chnl_id);
|
||||
//set_log_LineID(LD_info->line_id);
|
||||
//set_line_info(LOG_IDX,LD_info->line_id,LD_info->SubV_Index,LD_info->Dev_Index,LD_info->Sub_Index,LD_info->GD_Index);
|
||||
|
||||
//long long start = LD_info->autorecall[i]->start;
|
||||
//long long end = start;
|
||||
//for (;end < LD_info->autorecall[i]->end;)
|
||||
//{
|
||||
// if (end < LD_info->autorecall[i]->end - 180)
|
||||
// {
|
||||
// start = end;
|
||||
// end = end + 180;
|
||||
// loginfo->start_time = apr_time_from_sec(start - 5);
|
||||
// loginfo->end_time = apr_time_from_sec(end - 5);
|
||||
// }
|
||||
// else {
|
||||
// start = end;
|
||||
// end = LD_info->autorecall[i]->end;
|
||||
// loginfo->start_time = apr_time_from_sec(start - 5);
|
||||
// loginfo->end_time = apr_time_from_sec(end - 5);
|
||||
// }
|
||||
//}
|
||||
|
||||
//printf(" mms_jread..... start time: %d end time: %d\n", start, end);
|
||||
ret = mms_jread(loginfo, chnl_usr->net_info, loginfo->LD_info->LD_name, loginfo->logName,
|
||||
loginfo->start_time, loginfo->end_time, g_pt61850app->mmsOpTimeout, chnl_usr->ip_str);
|
||||
if (ret != SD_SUCCESS) {
|
||||
@@ -640,8 +482,7 @@ void ChannelCheckIECLogs(chnl_usr_t *chnl_usr)
|
||||
Delete_recall_Xml(LD_info->mp_id);
|
||||
}
|
||||
}
|
||||
/*apr_time_from_sec(&loginfo->start_time, 1694275200);
|
||||
apr_time_from_sec(&loginfo->end_time, 1694361600);*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -654,8 +495,7 @@ void process_3s_config(trigger_3s_xml_t *trigger_3s_xml)
|
||||
int trigger_num;
|
||||
ied_t *ied;
|
||||
LD_info_t *LD_info;
|
||||
// int rpt_no;
|
||||
// rptinfo_t *rptinfo;
|
||||
|
||||
int need_write_file;
|
||||
int new_in_work_found;
|
||||
|
||||
@@ -669,7 +509,7 @@ void process_3s_config(trigger_3s_xml_t *trigger_3s_xml)
|
||||
for (j=0; j<trigger_3s_xml->work_trigger_num; j++){
|
||||
trigger_work = &trigger_3s_xml->work_triggers[j];
|
||||
if (trigger_work->dev_idx==trigger[i].dev_idx && trigger_work->line_id==trigger[i].line_id ) {
|
||||
//*trigger_work = trigger[i];
|
||||
|
||||
if (trigger[i].real_data>=0)
|
||||
trigger_work->real_data = trigger[i].real_data;//<2F><><EFBFBD><EFBFBD>rtdata<74><61>־
|
||||
if (trigger[i].soe_data>=0)
|
||||
@@ -805,7 +645,6 @@ void del_process_recall_config(recall_xml_t* recall_xml)
|
||||
|
||||
}
|
||||
|
||||
//remove_recall_xml();
|
||||
}
|
||||
|
||||
void check_3s_config()
|
||||
@@ -827,7 +666,7 @@ void check_3s_config()
|
||||
//<2F><><EFBFBD><EFBFBD>ʵʱ<CAB5><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>lnk20250114
|
||||
//pthread_mutex_lock(&mtx); printf("3s hold lock !!!!!!!!!!!");
|
||||
process_3s_config(&trigger_3s_xml); //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
pthread_mutex_unlock(&mtx); printf("3s free lock !!!!!!!!!!!");
|
||||
//pthread_mutex_unlock(&mtx); printf("3s free lock !!!!!!!!!!!");
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1352,110 +1191,6 @@ void check_disk_quota()
|
||||
freeSizeMB,totalSizeMB);
|
||||
}
|
||||
|
||||
void check_recall_config()
|
||||
{
|
||||
double now;
|
||||
static double last_check_recall_config_time = 0.0;
|
||||
static int recall_flag = 1;// 1-<2D><><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD> 2-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3-<2D><><EFBFBD>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>
|
||||
int recall_lenth = recall_len;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int recall_start = recall_sta;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int recall_dailytime = recall_daily;//ÿ<>ղ<EFBFBD><D5B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
static int recall_count = 0;//<2F><><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
recall_xml_t recall_xml;
|
||||
|
||||
if(g_node_id != HIS_DATA_BASE_NODE_ID)
|
||||
return;
|
||||
now = sGetMsTime();
|
||||
|
||||
if ( fabs(now - last_check_recall_config_time) < 5*1000 ) //wait 5 secs
|
||||
return;
|
||||
last_check_recall_config_time = now;
|
||||
//parse_recall_xml(&recall_xml);
|
||||
//process_recall_config(&recall_xml);
|
||||
//printf("==============%.2f================\n", last_check_recall_config_time);
|
||||
|
||||
apr_time_t previousTime = apr_time_now();//
|
||||
apr_time_exp_t localTime;
|
||||
apr_time_exp_gmt(&localTime, previousTime);
|
||||
if (localTime.tm_hour == recall_dailytime && recall_flag == 1) {
|
||||
recall_flag = 2;
|
||||
recall_count = 0;
|
||||
//recall_pgsql(1);//<2F><><EFBFBD><EFBFBD>ǰһ<C7B0><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
if (recall_flag == 2) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
if (recall_start > 30) {
|
||||
recall_start = 30;
|
||||
}
|
||||
if (recall_lenth > 10) {
|
||||
recall_lenth = 10;
|
||||
}
|
||||
if (recall_start < recall_lenth) //<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>С<EFBFBD>ڲ<EFBFBD><DAB2>г<EFBFBD><D0B3><EFBFBD> <20><><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
||||
{
|
||||
recall_lenth = recall_start;
|
||||
}
|
||||
if (recall_count < recall_lenth)
|
||||
{
|
||||
recall_pgsql(recall_start - recall_count);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//char* day = getoneday(recall_start - recall_count);//<2F><>ȡǰn<C7B0><6E> yyyy-mm-dd
|
||||
//printf("==============%s================\n", day);
|
||||
//deletechar(day);
|
||||
recall_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
recall_flag = 3;
|
||||
}
|
||||
}
|
||||
if (localTime.tm_hour != recall_dailytime && recall_flag == 3) {
|
||||
recall_flag = 1;
|
||||
recall_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void recall_pgsql(int num)
|
||||
{
|
||||
char* day = getoneday(num);//<2F><>ȡǰn<C7B0><6E> yyyy-mm-dd
|
||||
int i = 0;
|
||||
while (i < g_pt61850app->chnl_counts)
|
||||
{
|
||||
chnl_usr_t* chnl_usr;
|
||||
ied_t* ied;
|
||||
ied_usr_t* ied_usr;
|
||||
LD_info_t* LD_info;
|
||||
int cpuno = 0;
|
||||
|
||||
chnl_usr = g_pt61850app->chnl_usr[i];
|
||||
ied = chnl_usr->chnl->ied;
|
||||
ied_usr = GET_IEDEXT_ADDR(ied);
|
||||
if (chnl_usr->m_state == CHANNEL_CONNECTED)
|
||||
{
|
||||
while (cpuno < ied->cpucount)
|
||||
{
|
||||
LD_info = &(ied_usr->LD_info[cpuno]);
|
||||
if (LD_info->logcount <= 0)
|
||||
continue;
|
||||
printf("/home/pq mpid=%s\n", LD_info->mp_id);
|
||||
//<2F>滻<EFBFBD><E6BBBB>web<65>ӿ<EFBFBD>2024-10-21 lnk
|
||||
//int ReDecide = OTL_Select_DecideRecall(day, LD_info->mp_id);
|
||||
//int ReDecide = OTL_Select_DecideRecall_web(day, LD_info->mp_id);//<2F><>ʹ<EFBFBD><CAB9>lnk20241206
|
||||
|
||||
//if (ReDecide == 1) {//<2F><>ʹ<EFBFBD><CAB9>lnk20241206
|
||||
//<2F>滻<EFBFBD><E6BBBB>web<65>ӿ<EFBFBD>2024-10-21 lnk
|
||||
//OTL_Select_recall(day, LD_info->mp_id);
|
||||
//OTL_Select_recall_web(day, LD_info->mp_id);//<2F><>ʹ<EFBFBD><CAB9>lnk20241206
|
||||
//}//<2F><>ʹ<EFBFBD><CAB9>lnk20241206
|
||||
|
||||
g_dead_lock_counter = 0;
|
||||
g_thread_blocked_times = 0;
|
||||
cpuno++;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
deletechar(day);
|
||||
}
|
||||
|
||||
void create_recall_xml()
|
||||
{
|
||||
//<2F><><EFBFBD>ɴ<EFBFBD><C9B4><EFBFBD><EFBFBD><EFBFBD>xml<6D>ļ<EFBFBD>
|
||||
@@ -1468,8 +1203,7 @@ void create_recall_xml()
|
||||
void Delete_recall_Xml(char* id) {
|
||||
if (g_node_id == HIS_DATA_BASE_NODE_ID || g_node_id == NEW_HIS_DATA_BASE_NODE_ID || g_node_id == RECALL_HIS_DATA_BASE_NODE_ID || (g_node_id == RECALL_ALL_DATA_BASE_NODE_ID)) {
|
||||
delete_recall_xml(id);
|
||||
//process_recall_config(&recall_xml);
|
||||
//remove_recall_xml();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1481,34 +1215,22 @@ void Check_Recall_Config(char *id) //
|
||||
memset((char*)&recall_xml, 0, sizeof(recall_xml_t));
|
||||
parse_recall_xml(&recall_xml,id); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
process_recall_config(&recall_xml); //<2F><><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD>ֵ<EFBFBD><D6B5>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>
|
||||
//process_recall_config(&recall_xml);
|
||||
//remove_recall_xml();
|
||||
}
|
||||
/*recall_xml_t recall_xml;
|
||||
memset((char*)&recall_xml, 0, sizeof(recall_xml_t));
|
||||
int ret = parse_recall_xml(&recall_xml);
|
||||
if (0 == ret)
|
||||
process_recall_config(&recall_xml);*/
|
||||
}
|
||||
|
||||
void CheckAllConnectedChannel()
|
||||
{
|
||||
chnl_usr_t *chnl_usr;
|
||||
static uint32_t chnl_sequence_no = 0;
|
||||
//10-11-02 20:18 beijing, only one ied by visited every loop һ<EFBFBD>η<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD>
|
||||
//һ<>η<EFBFBD><CEB7><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ն<EFBFBD>
|
||||
do {
|
||||
chnl_usr = g_pt61850app->chnl_usr[chnl_sequence_no];
|
||||
chnl_sequence_no = (chnl_sequence_no+1) % g_pt61850app->chnl_counts;
|
||||
} while ( (g_onlyIP[0]!=0) && (strcmp(g_onlyIP,chnl_usr->ip_str)!=0) );
|
||||
//for (i=0; i<g_pt61850app->chnl_counts; i++) {
|
||||
//chnl_usr = g_pt61850app->chnl_usr[i] ;
|
||||
//printf("CheckAllConnectedChannel chnl_usr->ip_str = %s \n",chnl_usr->ip_str);
|
||||
|
||||
if(chnl_usr->m_state == CHANNEL_CONNECTED)
|
||||
{
|
||||
/*if(chnl_usr->chnl->ied->id==virtual_ied){
|
||||
chnl_usr->m_state = CHANNEL_CONNECTED;
|
||||
return;
|
||||
}*/
|
||||
|
||||
ChannelCheckIECReports(chnl_usr);//<2F><><EFBFBD><EFBFBD>
|
||||
if ( (g_node_id == SOE_COMTRADE_BASE_NODE_ID) || (g_node_id == HIS_DATA_BASE_NODE_ID) || (g_node_id == NEW_HIS_DATA_BASE_NODE_ID) || (g_node_id == RECALL_HIS_DATA_BASE_NODE_ID) || (g_node_id == RECALL_ALL_DATA_BASE_NODE_ID))
|
||||
ChannelCheckWaveFiles(chnl_usr);//¼<><C2BC><EFBFBD>ļ<EFBFBD>
|
||||
@@ -1518,93 +1240,58 @@ void CheckAllConnectedChannel()
|
||||
{
|
||||
char** varnames ;
|
||||
int varnum;
|
||||
//double beforeCallDomainMsTime = sGetMsTime() ;
|
||||
|
||||
ST_RET ret = mms_mvla_getnam(chnl_usr->net_info, VMD_SPEC, NULL,MMS_CLASS_DOM,g_pt61850app->mmsOpTimeout,
|
||||
&varnames,&varnum,g_pt61850app->tmp_pool);
|
||||
//for ( j = 0; j < varnum; ++j)
|
||||
//printf("LD %d name: %s \n",j,varnames[j]);
|
||||
|
||||
//ret = mms_mvla_getnam(chnl_usr->net_info, DOM_SPEC, varnames[1],MMS_CLASS_VARLIST,3,
|
||||
// &varnames,&varnum,g_pt61850app->tmp_pool);
|
||||
////ret = mms_mvla_getnam(chnl_usr->net_info, DOM_SPEC, varnames[1], MMS_CLASS_VAR, 3,
|
||||
//// &varnames, &varnum, g_pt61850app->tmp_pool);
|
||||
//for ( j = 0; j < varnum; ++j)
|
||||
// printf("LD %d name: [%s] \n",j,varnames[j]);
|
||||
|
||||
//double comdiff = sGetMsTime() - beforeCallDomainMsTime;
|
||||
//cout<<"cost secs to check com "<<int(comdiff)<<endl;
|
||||
//ST_RET ret = mms_mvla_status( chnl_usr->net_info, 15 );
|
||||
chnl_usr->m_LastPosRespTime = sGetMsTime();
|
||||
if (ret == SD_SUCCESS) {
|
||||
//chnl_usr->m_LastPosRespTime = sGetMsTime();
|
||||
|
||||
chnl_usr->m_NegRespTimes = 0;
|
||||
}else {
|
||||
// cout<<" "<<pChannel->GetIP()<<" <20><> domain name ʧ<><CAA7> "<<endl;
|
||||
|
||||
printf("%d--------------\n", chnl_usr->m_NegRespTimes);
|
||||
chnl_usr->m_NegRespTimes++;
|
||||
}
|
||||
}
|
||||
if ( chnl_usr->m_NegRespTimes >=2 ) {
|
||||
//printf("==============chnl_usr->m_NegRespTimes================\n");
|
||||
|
||||
closeChannel(chnl_usr);//???<3F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ mms_release_connection
|
||||
chnl_usr->m_NegRespTimes = 0;
|
||||
chnl_usr->m_LastPosRespTime = sGetMsTime();
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
void CheckNextNotConnectedChannel()
|
||||
{
|
||||
static uint32_t chnl_total_no = 0;
|
||||
chnl_usr_t *chnl_usr;
|
||||
// element_t *elem_a;
|
||||
// element_t *elem_b;
|
||||
|
||||
do {
|
||||
chnl_usr = g_pt61850app->chnl_usr[chnl_total_no];
|
||||
chnl_total_no = (chnl_total_no+1) % g_pt61850app->chnl_counts;
|
||||
} while ( (g_onlyIP[0]!=0) && (strcmp(g_onlyIP,chnl_usr->ip_str)!=0) );
|
||||
|
||||
//printf("check error chnl_total_no !!!!!!!!!!!!!! %d\n",chnl_total_no);
|
||||
|
||||
//10-11-01 22:03 beijing
|
||||
if( ( (chnl_total_no+1)==g_pt61850app->chnl_counts) || (g_onlyIP[0]!=0) ){
|
||||
if(g_pt61850app->initNum<255)
|
||||
g_pt61850app->initNum++;
|
||||
}
|
||||
if(chnl_usr->chnl->ied->chncount == 2){
|
||||
//elem_a = RDB_GetElement(SUBSTATION, chnl_usr->chnl->ied->id,64264, 5);
|
||||
//elem_b = RDB_GetElement(SUBSTATION, chnl_usr->chnl->ied->id,64264, 6);
|
||||
//if(elem_a&&elem_b){
|
||||
// if((((M_DP_NA_1_t*)elem_a->value.data)->diq.parts.DPI == 0x01)&&(((M_DP_NA_1_t*)elem_b->value.data)->diq.parts.DPI == 0x01)){
|
||||
// iecs_set_ied_invalid(chnl_usr->chnl->ied);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
else{
|
||||
//elem_a = RDB_GetElement(SUBSTATION, chnl_usr->chnl->ied->id,64264, 5);
|
||||
//if(elem_a){
|
||||
// if(((M_DP_NA_1_t*)elem_a->value.data)->diq.parts.DPI == 0x01){
|
||||
// iecs_set_ied_invalid(chnl_usr->chnl->ied);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
//printf("check error %s !!!!!!!!!!!!!!\n",((ied_usr_t*)chnl_usr->chnl->ied->usr_ext)->terminal_id);
|
||||
|
||||
if(chnl_usr->m_state == CHANNEL_CONNECTING)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
//printf("check error93 !!!!!!!!!!!!!!\n");
|
||||
|
||||
MVL_REQ_PEND* reqCtrl= chnl_usr->m_reqCtrl ;
|
||||
//printf("check error60 !!!!!!!!!!!!!!\n");
|
||||
|
||||
if( reqCtrl->done == SD_TRUE)
|
||||
{
|
||||
//printf("check error92 !!!!!!!!!!!!!!\n");
|
||||
|
||||
if(reqCtrl->result == SD_SUCCESS)
|
||||
{
|
||||
//printf("check error91 !!!!!!!!!!!!!!\n");
|
||||
|
||||
ALL_RCB_INFO *all_rcb_info;
|
||||
// cout<<endl<<endl<<pChannel->GetIP()<<" CHANNEL_CONNECTED netInfo "<<chnl_usr->net_info<<endl;
|
||||
|
||||
echo_warn4("\nCHANNEL_CONNECTED %s:%d ,NetInfo= %x chnl_usr= %x \n",
|
||||
chnl_usr->ip_str,chnl_usr->chnl->port,chnl_usr->net_info,chnl_usr);
|
||||
mvl_free_req_ctrl(chnl_usr->m_reqCtrl);
|
||||
@@ -1615,7 +1302,7 @@ void CheckNextNotConnectedChannel()
|
||||
|
||||
all_rcb_info = (ALL_RCB_INFO *)chk_calloc(1, sizeof (ALL_RCB_INFO));
|
||||
all_rcb_info->rpt_typeids = &g_rpt_typeids;
|
||||
//assert(chnl_usr->net_info->user_info == NULL);
|
||||
|
||||
if (chnl_usr->net_info->user_info != NULL) {
|
||||
echo_warn("chnl_usr->net_info->user_info is not NULL\n");
|
||||
}
|
||||
@@ -1623,8 +1310,7 @@ void CheckNextNotConnectedChannel()
|
||||
chnl_usr->net_info->user_info = all_rcb_info;
|
||||
chnl_usr->chnl->ied->status = STATUS_NORMAL;
|
||||
chnl_usr->chnl->status = STATUS_NORMAL;
|
||||
//prcess_ied_comm_2_json(chnl_usr->chnl->ied,STATUS_NORMAL);
|
||||
//RDB_SetIedChnlStatus(chnl_usr->chnl->ied, STATUS_NORMAL, chnl_usr->chnl_id);
|
||||
|
||||
{
|
||||
char comm_str[256];
|
||||
memset(comm_str,0,256);
|
||||
@@ -1642,17 +1328,11 @@ void CheckNextNotConnectedChannel()
|
||||
}
|
||||
else
|
||||
{// solaris 9 <20><> 224<32><34>
|
||||
//printf("check error90 !!!!!!!!!!!!!!\n");
|
||||
|
||||
int secsSince = (int)(sGetMsTime() - chnl_usr->m_StartConnectingTime)/1000 ;
|
||||
//cout<<"reqCtrl->result == FAIL, Since StartConnecting "<<secsSince<<"<22><> "<<pChannel->GetIP()<<" !!! "<<endl;
|
||||
|
||||
ied_usr_t* ied_usr = (ied_usr_t*)chnl_usr->chnl->ied->usr_ext;
|
||||
if (g_node_id == STAT_DATA_BASE_NODE_ID || g_node_id == NEW_HIS_DATA_BASE_NODE_ID) {
|
||||
//lnk202411-4
|
||||
//connectlog_pgsql(ied_usr->terminal_code);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
||||
//printf("check error89 !!!!!!!!!!!!!!\n");
|
||||
//connectlog_pgsql(ied_usr->terminal_id,convertMsToDateTimeString(sGetMsTime()),0);//0ʧ<30><CAA7>
|
||||
//printf("check error88 !!!!!!!!!!!!!!\n");
|
||||
}
|
||||
|
||||
printf( "reqCtrl->result == FAIL, Since StartConnecting %i sec ,channel IP %s:%d \n",secsSince,chnl_usr->ip_str,chnl_usr->chnl->port);
|
||||
mvl_free_req_ctrl(chnl_usr->m_reqCtrl);
|
||||
chnl_usr->m_reqCtrl = NULL;
|
||||
@@ -1662,17 +1342,12 @@ void CheckNextNotConnectedChannel()
|
||||
}
|
||||
}
|
||||
else
|
||||
{//
|
||||
//printf("check error61 !!!!!!!!!!!!!!\n");
|
||||
if ( (sGetMsTime() - chnl_usr->m_StartConnectingTime) > 300*1000 ) //300*1000 ) //wait 300 secs ?????
|
||||
{
|
||||
|
||||
if ( (sGetMsTime() - chnl_usr->m_StartConnectingTime) > 300*1000 ) //300*1000 ) //wait 300 secs
|
||||
{
|
||||
ied_usr_t* ied_usr = (ied_usr_t*)chnl_usr->chnl->ied->usr_ext;
|
||||
if (g_node_id == STAT_DATA_BASE_NODE_ID || g_node_id == NEW_HIS_DATA_BASE_NODE_ID) {
|
||||
//connectlog_pgsql(ied_usr->terminal_code);//reqCtrl->doneδ<65><CEB4><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ5<CAB1><35><EFBFBD><EFBFBD>
|
||||
//lnk202411-4
|
||||
//connectlog_pgsql(ied_usr->terminal_id,convertMsToDateTimeString(sGetMsTime()),0);//0ʧ<30><CAA7>
|
||||
}
|
||||
//cout<<pChannel->GetIP()<<" reqCtrl->done == SD_false but time over 300 secs, close channel !!!"<<endl;
|
||||
|
||||
echo_warn2( "reqCtrl->doneδ<65><CEB4><EFBFBD><EFBFBD>,but time over 300 secs, close channel IP %s,NetInfo= %x ",chnl_usr->ip_str,chnl_usr->net_info);
|
||||
if (chnl_usr->net_info->req_pend_list) {
|
||||
echo_warn("reqCtrl->doneδ<65><CEB4><EFBFBD><EFBFBD>,but time over 300 secs!!!!!!!!\n");
|
||||
@@ -1680,94 +1355,60 @@ void CheckNextNotConnectedChannel()
|
||||
chnl_usr->m_reqCtrl = NULL;
|
||||
}
|
||||
mms_release_connection(chnl_usr->net_info);
|
||||
//mvl_free_req_ctrl(chnl_usr->m_reqCtrl); //???
|
||||
|
||||
chnl_usr->net_info->rem_vmd = NULL;
|
||||
chnl_usr->m_state = CHANNEL_DISCONNECTED;
|
||||
chnl_usr->m_ClosedMsTime = sGetMsTime();
|
||||
//if(chnl_usr->chnl->ied->id==virtual_ied){
|
||||
// chnl_usr->m_state = CHANNEL_CONNECTED;
|
||||
// chnl_usr->chnl->ied->status = STATUS_NORMAL;
|
||||
// chnl_usr->chnl->status = STATUS_NORMAL;
|
||||
// //Special_CPU_Set(chnl_usr->chnl->ied, STATUS_NORMAL);
|
||||
// //RDB_SetIedChnlStatus(chnl_usr->chnl->ied, STATUS_NORMAL,0);
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
} //if(pChannel->m_state == CHANNEL_CONNECTING)
|
||||
}
|
||||
|
||||
else if(chnl_usr->m_state == CHANNEL_DISCONNECTED)
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//printf("check error99 !!!!!!!!!!!!!!\n");
|
||||
|
||||
if ( (sGetMsTime() - chnl_usr->m_ClosedMsTime) > NEXT_CONNECT_TIME ) //wait 10 secs
|
||||
{
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//printf("check error98 !!!!!!!!!!!!!!\n");
|
||||
|
||||
ST_RET ret;
|
||||
ST_CHAR serverARName[32];
|
||||
ied_usr_t *ied_usr = (ied_usr_t*)chnl_usr->chnl->ied->usr_ext;
|
||||
apr_snprintf(serverARName,sizeof(serverARName),"%s:%d",chnl_usr->ip_str,chnl_usr->chnl->port);
|
||||
if (chnl_usr->chnl->ied->cpucount != NULL && chnl_usr->chnl->ied->cpucount > 0 && ied_usr->dev_flag == ENABLE) {//2023-09-26 czy <20><><EFBFBD><EFBFBD>line count<0 <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>//lnk20250121<32><31><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD><D5B6><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
ret = mms_connectToServer(ied_usr->dev_key, ied_usr->dev_series, serverARName, &(chnl_usr->net_info), &(chnl_usr->m_reqCtrl));
|
||||
//printf("check error73 !!!!!!!!!!!!!!\n");
|
||||
|
||||
if (ret == SD_SUCCESS)
|
||||
{
|
||||
//printf("check error74 !!!!!!!!!!!!!!\n");
|
||||
//if(chnl_usr->chnl->ied->id==virtual_ied){
|
||||
// chnl_usr->m_state = CHANNEL_CONNECTED;
|
||||
// chnl_usr->chnl->ied->status = STATUS_NORMAL;
|
||||
// chnl_usr->chnl->status = STATUS_NORMAL;
|
||||
// //Special_CPU_Set(chnl_usr->chnl->ied, STATUS_NORMAL);
|
||||
// //RDB_SetIedChnlStatus(chnl_usr->chnl->ied, STATUS_NORMAL,0);
|
||||
// return;
|
||||
//}
|
||||
//echo_warn3("!!!!!!!!!!!!!!!!!!!!!!!!! %s:%d %x \n", chnl_usr->ip_str, chnl_usr->chnl->port, chnl_usr->net_info);
|
||||
|
||||
echo_msg3("mms_connectToServer IP %s:%d ,NetInfo= %x \n", chnl_usr->ip_str, chnl_usr->chnl->port, chnl_usr->net_info);
|
||||
chnl_usr->m_state = CHANNEL_CONNECTING;
|
||||
chnl_usr->m_StartConnectingTime = sGetMsTime();
|
||||
//RDB_SetIedChnlStatus(chnl_usr->chnl->ied, STATUS_NOINIT, chnl_usr->chnl_id);
|
||||
//write_status_to_db(0,chnl_usr->chnl->addr);
|
||||
|
||||
//lnk202411-1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ӳɹ<D3B3>
|
||||
//connectlog_pgsql(ied_usr->terminal_id,convertMsToDateTimeString(sGetMsTime()),1);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//printf("check error97 !!!!!!!!!!!!!!\n");
|
||||
|
||||
chnl_usr->m_ClosedMsTime = sGetMsTime();
|
||||
if (g_node_id == STAT_DATA_BASE_NODE_ID || g_node_id == NEW_HIS_DATA_BASE_NODE_ID) {
|
||||
//lnk202411-4
|
||||
//connectlog_pgsql(ied_usr->terminal_code);//<2F><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//printf("check error96 !!!!!!!!!!!!!!\n");
|
||||
//connectlog_pgsql(ied_usr->terminal_id,convertMsToDateTimeString(sGetMsTime()),0);//<2F><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>״̬û<CCAC>иı䲻<C4B1><E4B2BB>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>20250312
|
||||
//printf("check error95 !!!!!!!!!!!!!!\n");
|
||||
}
|
||||
|
||||
echo_warn3("FAILED: mms_connectToServer IP %s:%d ,NetInfo= %x \n", chnl_usr->ip_str, chnl_usr->chnl->port, chnl_usr->net_info);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}//if(pChannel->m_state == CHANNEL_DISCONNECTED)
|
||||
else if(chnl_usr->m_state == CHANNEL_DISCONNECTING) //need check timeout?<3F><EFBFBD><E1B2BB><EFBFBD><EFBFBD>Զͣ<D4B6><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>???
|
||||
}
|
||||
else if(chnl_usr->m_state == CHANNEL_DISCONNECTING) //need check timeout?<3F><EFBFBD><E1B2BB><EFBFBD><EFBFBD>Զͣ<D4B6><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
//printf("check error92 !!!!!!!!!!!!!!\n");
|
||||
|
||||
MVL_REQ_PEND* reqCtrl= chnl_usr->m_reqCtrl ;
|
||||
if( reqCtrl->done == SD_TRUE)
|
||||
{
|
||||
//printf("check error72 !!!!!!!!!!!!!!\n");
|
||||
//cout<<endl<<endl<<pChannel->GetIP()<<" CHANNEL_DISCONNECTING done"<<endl;
|
||||
|
||||
echo_warn3( "CHANNEL_DISCONNECTING done %s:%d,NetInfo= %x ",chnl_usr->ip_str,chnl_usr->chnl->port,chnl_usr->net_info);
|
||||
mvl_free_req_ctrl(chnl_usr->m_reqCtrl);
|
||||
if(chnl_usr->net_info)
|
||||
chnl_usr->net_info->user_ext = NULL;
|
||||
//NetInfo_Channel_Map.remove(chnl_usr->net_info);
|
||||
//cout<<"CHANNEL_DISCONNECTING done NetInfo_Channel_Map.entries()= "<<NetInfo_Channel_Map.entries()<<endl;
|
||||
|
||||
chnl_usr->m_reqCtrl = NULL;
|
||||
chnl_usr->net_info = NULL;
|
||||
chnl_usr->m_state = CHANNEL_DISCONNECTED;
|
||||
@@ -1779,18 +1420,17 @@ void CheckNextNotConnectedChannel()
|
||||
|
||||
}
|
||||
else
|
||||
{//
|
||||
//printf("check error70 !!!!!!!!!!!!!!\n");
|
||||
// cout<<endl<<endl<<pChannel->GetIP()<<" CHANNEL_DISCONNECTING waiting ..."<<endl;
|
||||
{
|
||||
|
||||
echo_warn2( "CHANNEL_DISCONNECTING waiting ... %s,NetInfo= %x ",chnl_usr->ip_str,chnl_usr->net_info);
|
||||
|
||||
if ( (sGetMsTime() - chnl_usr->m_StartDisconnectingTime) > 30*1000 ) // //wait 30 secs ?????
|
||||
{
|
||||
//cout<<pChannel->GetIP()<<"CHANNEL_DISCONNECTING reqCtrl->done == SD_false but time over 180 secs, close channel !!!"<<endl;
|
||||
|
||||
echo_warn2( "CHANNEL_DISCONNECTING reqCtrl->doneδ<65><CEB4><EFBFBD><EFBFBD>,but time over 180 secs, close channel IP %s,NetInfo= %x ",chnl_usr->ip_str,chnl_usr->net_info);
|
||||
mvl_free_req_ctrl(chnl_usr->m_reqCtrl);
|
||||
chnl_usr->net_info->user_ext = NULL;
|
||||
//NetInfo_Channel_Map.remove(chnl_usr->net_info);
|
||||
|
||||
mms_release_connection(chnl_usr->net_info);
|
||||
chnl_usr->net_info->rem_vmd = NULL;
|
||||
chnl_usr->m_reqCtrl = NULL;
|
||||
@@ -1803,16 +1443,10 @@ void CheckNextNotConnectedChannel()
|
||||
connectlog_pgsql(ied_usr->terminal_id,convertMsToDateTimeString(t_now),0);
|
||||
}
|
||||
}
|
||||
}//if(pChannel->m_state == CHANNEL_DISCONNECTING)
|
||||
//////////////////
|
||||
//printf("check error77 !!!!!!!!!!!!!!\n");
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////*********<2A><><EFBFBD>ؿ<EFBFBD><D8BF>Ʋ<EFBFBD><C6B2><EFBFBD>**********////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
static ST_RET Read_Named_Var(LD_info_t *LD_info,chnl_usr_t *chnl_usr,char* VarName,ST_INT type_id, ST_VOID *dataDest, ST_INT timeOut)
|
||||
{
|
||||
ST_RET ret= SD_FAILURE;
|
||||
@@ -1866,12 +1500,10 @@ static ST_RET Write_Named_Var(LD_info_t *LD_info,chnl_usr_t *chnl_usr,char* VarN
|
||||
int pt61850_write_cn_file(chnl_usr_t *chnl_usr, ied_t *ied, char *rem_filename, char *only_filename_ret)
|
||||
{
|
||||
int ret ;
|
||||
// ticks_t ticks;
|
||||
|
||||
char loc_filename[128], loc_file_fullname[256], rem_file_fullname[256],only_filename_str[256];
|
||||
// int result ;//= FILE_NAME_UNIQUE;
|
||||
// uint8_t cpuNo =0;
|
||||
|
||||
char *only_filename,*the_full_file;
|
||||
// ied_usr_t *ied_usr = GET_IEDEXT_ADDR(ied);
|
||||
|
||||
memset(loc_filename,0,sizeof(loc_filename));
|
||||
memset(only_filename_str,0,sizeof(only_filename_str) );
|
||||
@@ -1965,7 +1597,6 @@ apr_status_t call_cn_wavelist(LD_info_t *LD_info )
|
||||
|
||||
//WW 2023-11-01<30><31>¼<EFBFBD><C2BC><EFBFBD>κ<EFBFBD><CEBA><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>Ϊint<6E><74>fltnumƥ<6D><C6A5>
|
||||
ret2 = parse_file_names_by_fltnum(LD_info->FltNum[i], ldstr, filenames, filenum, &cfg_idx, &dat_idx, file_base_name, file_yyyymm);
|
||||
//ret2 = parse_file_names(file_match_str,filenames,filenum,&cfg_idx,&dat_idx,file_base_name,file_yyyymm);
|
||||
//WW 2023-11-01 end
|
||||
if (ret2 !=APR_SUCCESS)
|
||||
return ret2;
|
||||
@@ -1979,9 +1610,7 @@ apr_status_t call_cn_wavelist(LD_info_t *LD_info )
|
||||
if (ret2==SD_SUCCESS && ret3==SD_SUCCESS ) { //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
|
||||
QVVR_t *qvvr; //<2F><>̬<EFBFBD>¼<EFBFBD>
|
||||
long long start_tm,trig_tm,end_tm;
|
||||
//char ftp_filename[256];
|
||||
//doCommService();
|
||||
//memset(ftp_filename,0,256);
|
||||
|
||||
ret2 = extract_timestamp_from_cfg_file(filenames[cfg_idx],&start_tm,&trig_tm);//<2F><>ȡ<EFBFBD>ļ<EFBFBD><C4BC>Ŀ<EFBFBD>ʼʱ<CABC><CAB1><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
printf(">>>>>>>> extract_timestamp_from_cfg_file end \n");
|
||||
if (ret2 ==APR_SUCCESS) {
|
||||
@@ -2001,8 +1630,6 @@ apr_status_t call_cn_wavelist(LD_info_t *LD_info )
|
||||
char linux_cmd[256] = {0};
|
||||
printf(">>>>>>>> qvvr ok end \n");
|
||||
apr_snprintf(linux_cmd,sizeof(linux_cmd),"./sftp_upload %s %s/%04d",cfg_only_filename_ret,file_yyyymm,LD_info->line_id);//û<><C3BB>ʹ<EFBFBD><CAB9>
|
||||
//printf("\n>>>>>> %s ...... \n",linux_cmd);
|
||||
//system(linux_cmd);
|
||||
|
||||
char loc_file_fullname_cfg[256];//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
memset(loc_file_fullname_cfg, 0, sizeof(loc_file_fullname_cfg));
|
||||
@@ -2041,8 +1668,6 @@ apr_status_t call_cn_wavelist(LD_info_t *LD_info )
|
||||
}
|
||||
|
||||
apr_snprintf(linux_cmd,sizeof(linux_cmd),"./sftp_upload %s %s/%04d",dat_only_filename_ret,file_yyyymm,LD_info->line_id);//<2F><>ͨ<EFBFBD><CDA8>sftp<74>ϴ<EFBFBD><CFB4>ŷ<EFBFBD>json<6F><6E>ȥ
|
||||
//printf("\n>>>>>> %s ...... \n",linux_cmd);
|
||||
//system(linux_cmd);
|
||||
|
||||
char loc_file_fullname_dat[256];
|
||||
memset(loc_file_fullname_dat, 0, sizeof(loc_file_fullname_dat));
|
||||
|
||||
@@ -73,28 +73,22 @@ static ST_VOID log_var_jou_data (ST_INT var_type_id,VAR_ACC_DATA *var ,MMS_DECOD
|
||||
ST_INT data_size; /* size of data element */
|
||||
|
||||
type_ctrl = mvl_type_ctrl_find (var_type_id);
|
||||
//char doname[32];
|
||||
//strcpy(doname, dom_name);
|
||||
//type_ctrl = (MVL_TYPE_CTRL*)(sel_mvl_type_ctrl(doname));
|
||||
//printf ("\naddress: %p \n", type_ctrl);
|
||||
|
||||
if (type_ctrl)
|
||||
{
|
||||
num_rt = type_ctrl->num_rt;
|
||||
rt = type_ctrl->rt;
|
||||
data_size = type_ctrl->data_size;
|
||||
//printf ("\nTYPE: %d %d %d\n", num_rt, data_size, rt->el_size);
|
||||
/* If the TDL produced is longer than max_tdl_len, this function */
|
||||
/* "gracefully" fails (i.e. returns 0). */
|
||||
|
||||
if (ms_runtime_to_tdl (rt, num_rt, tdl_buf, sizeof(tdl_buf))>0)
|
||||
;//SLOGCALWAYS1 (" TYPE: %s", tdl_buf);
|
||||
;
|
||||
else
|
||||
echo_warn (" TYPE: unknown");
|
||||
//printf("\nrt %p and rt_num: %d \n", &type_ctrl->rt,type_ctrl->num_rt);
|
||||
//printf ("\nTYPE: %s \n", tdl_buf);
|
||||
|
||||
va_data_size = data_size;
|
||||
temp_data_buf = (ST_CHAR*)malloc( va_data_size);
|
||||
rc = ms_asn1_to_local (rt, num_rt, var->data, var->len, temp_data_buf);
|
||||
//printf("type_ctrl->num_rt %d %x %x \n", type_ctrl->num_rt , &data, &(var->data));
|
||||
|
||||
my_local_to_data (temp_data_buf,rt,num_rt, data);
|
||||
if (data->item_num==0) {
|
||||
echo_warn("!!!!!!!!!!!!!!!!!!!data num is 0 !!!!!!!!!!!!!!!!\n");
|
||||
@@ -151,8 +145,7 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
|
||||
do_name = strstr(jou_entry->ef.data.list_of_var[j].var_tag, "/");
|
||||
do_name++;
|
||||
}
|
||||
//printf("do_name =====%s=====\n", do_name);
|
||||
//start = sGetMsTime();
|
||||
|
||||
printf("\nbrf if");
|
||||
if (sel_mvl_type_ctrl_flag(do_name) == -1)
|
||||
{
|
||||
@@ -162,20 +155,13 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
|
||||
char doname[32];
|
||||
strcpy(doname, do_name);
|
||||
add_mvl_type_ctrl(doname, var_type_id);
|
||||
//printf("create var_type_id =====%d=====%p======\n", var_type_id, &doname);
|
||||
|
||||
}
|
||||
printf("\nbrf var_type_id");
|
||||
var_type_id = sel_mvl_type_ctrl_flag(do_name);
|
||||
printf("\nafter var_type_id");
|
||||
//end = sGetMsTime();
|
||||
//last_check_recall_config_time = last_check_recall_config_time + end - start;
|
||||
//printf("jou_entry->ef.data.num_of_var =====%d===== =====%d=====\n", jou_entry->ef.data.num_of_var, var_type_id);
|
||||
|
||||
/*var_type_id = mms_var_type_id_create(clientNetInfo, DOM_SPEC,
|
||||
dom_name, do_name, iTimeout);*/
|
||||
//printf("var_type_id =====%d=====\n", var_type_id);
|
||||
if (var_type_id < 0) {
|
||||
//return SD_FAILURE;
|
||||
continue;
|
||||
}
|
||||
log_var_jou_data(var_type_id,&(jou_entry->ef.data.list_of_var[j].value_spec),&mms_dec_data, do_name);
|
||||
@@ -336,10 +322,10 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
|
||||
v = (double)mms_dec_data.data_item[ii].u.data_uint64;
|
||||
else if (mms_dec_data.data_item[ii].type==DATA_DOUBLE_TYPE)
|
||||
v = mms_dec_data.data_item[ii].u.data_double;
|
||||
//printf("%s %s = %f \n",jou_entry->ef.data.list_of_var[j].var_tag, mms_dec_data.data_item[ii].comp_name,v);
|
||||
|
||||
apr_snprintf(mms_ref,sizeof(mms_ref),"%s$%s",do_name,mms_dec_data.data_item[ii].comp_name);
|
||||
if ( (strstr(mms_ref,"]")==NULL) || (strstr(mms_ref,"0]")) )
|
||||
//printf("\nlog read: %s=%f\n",mms_ref,v);
|
||||
|
||||
if (j==0 && ii==0) {
|
||||
printf("\n ----------------------------------------------------------------log read: %s=%f--------------------------------------------------------------\n",mms_ref,v);
|
||||
if ( strstr(mms_ref,"QVVR") ) {
|
||||
@@ -356,31 +342,22 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
|
||||
}
|
||||
if ( ( (loginfo->need_steady==0) &&(log_data_type == STEADY_DATA))
|
||||
|| ( (loginfo->need_voltage==0) &&(log_data_type != STEADY_DATA)) ){
|
||||
//mvl_type_id_destroy(var_type_id);
|
||||
return SD_SUCCESS;
|
||||
}
|
||||
|
||||
if ( log_data_type == QVVR_DATA ) {
|
||||
processQVVR_start(loginfo->LD_info);
|
||||
//processQVVR_time(loginfo->LD_info,t/1000);
|
||||
}
|
||||
else if ( log_data_type == RDRE_DATA ) {
|
||||
processRDRE_start(loginfo->LD_info);
|
||||
}
|
||||
else {
|
||||
/*ied_t* ied;
|
||||
ied = find_ied_from_dev_code(loginfo->LD_info->terminal_code);
|
||||
ied_usr_t* ied_usr = (ied_usr_t*)ied->usr_ext;
|
||||
json_block_create_start( loginfo->LD_info->voltage_level, loginfo->LD_info->mp_id,0, ied_usr->dev_type);*/
|
||||
//json_block_create_time(loginfo->LD_info->line_id,t/1000);
|
||||
}
|
||||
}
|
||||
//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;
|
||||
@@ -400,7 +377,6 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
|
||||
printf("quality = 1 continue");
|
||||
continue;
|
||||
}
|
||||
//set_log_QualityFlag(quality);
|
||||
if (log_data_steady_type == 0) {
|
||||
json_block_create_flag(loginfo->LD_info->mp_id, quality, 0);
|
||||
}
|
||||
@@ -415,9 +391,6 @@ 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 ) {
|
||||
@@ -445,8 +418,6 @@ 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);
|
||||
@@ -471,7 +442,6 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
|
||||
|
||||
}
|
||||
|
||||
//mvl_type_id_destroy(var_type_id);
|
||||
}
|
||||
printf("\naft for");
|
||||
if ( log_data_type == QVVR_DATA ) {
|
||||
@@ -481,10 +451,9 @@ static ST_RET process_jou_entry(loginfo_t *loginfo,apr_time_t t,
|
||||
processRDRE_end(loginfo->LD_info);
|
||||
}
|
||||
else {
|
||||
//json_block_create_end(loginfo->LD_info->mp_id,0);
|
||||
|
||||
}
|
||||
printf("\nend process_jou_entry");
|
||||
//printf("process_jou_entry ==============%.2f================\n", last_check_recall_config_time);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -550,7 +519,7 @@ ST_RET mms_jread (loginfo_t *loginfo,MVL_NET_INFO *clientNetInfo, ST_CHAR *dom_n
|
||||
int cpuno = 0;
|
||||
|
||||
chnl_usr = g_pt61850app->chnl_usr[i];
|
||||
//printf("\n chnl_usr->m_state ===== %d\n", chnl_usr->m_state);
|
||||
|
||||
if (strstr(chnl_usr->ip_str, ip) != NULL)
|
||||
{
|
||||
printf("\nSame Ip %s : %s", chnl_usr->ip_str, ip);
|
||||
@@ -614,25 +583,21 @@ ST_RET mms_jread (loginfo_t *loginfo,MVL_NET_INFO *clientNetInfo, ST_CHAR *dom_n
|
||||
|
||||
if( (last_occur_time.day!=jou_entry->occur_time.day)||(last_occur_time.ms!=jou_entry->occur_time.ms) ) {
|
||||
last_occur_time=jou_entry->occur_time;
|
||||
//append_db_records(LOG_IDX);
|
||||
|
||||
}
|
||||
printf("\nbrf convert_btod_to_apr_time");
|
||||
t = convert_btod_to_apr_time(&jou_entry->occur_time);
|
||||
//set_log_TimeID(convert_btod_to_apr_time(&jou_entry->occur_time));
|
||||
|
||||
if (jou_entry->entry_form_tag == 2)
|
||||
{
|
||||
printf("\nbrf jou_entry->ef.data.list_of_var_pres");
|
||||
if (jou_entry->ef.data.list_of_var_pres)
|
||||
{
|
||||
//for (j = 0; j < jou_entry->ef.data.num_of_var; j++)
|
||||
//{
|
||||
// printf ("\n Var # %d: var_tag = %s", j, jou_entry->ef.data.list_of_var[j].var_tag);
|
||||
// printf ("\n Var # %d: value_spec.len = %d", j,jou_entry->ef.data.list_of_var[j].value_spec.len);
|
||||
//}
|
||||
|
||||
start = sGetMsTime();
|
||||
printf("\nbrf process_jou_entry");
|
||||
process_jou_entry(loginfo,t,jou_entry, clientNetInfo, dom_name, iTimeout) ;
|
||||
//start = sGetMsTime();
|
||||
|
||||
if ( jread_resp->more_follows == 0 && ((i + 1) == jread_resp->num_of_jou_entry)) {
|
||||
printf("\njread_resp->more_follows == 0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
//lnk2024-8-16<31><36><EFBFBD>ӽ<EFBFBD><D3BD>߲<EFBFBD><DFB2><EFBFBD>
|
||||
@@ -650,14 +615,11 @@ ST_RET mms_jread (loginfo_t *loginfo,MVL_NET_INFO *clientNetInfo, ST_CHAR *dom_n
|
||||
end = sGetMsTime();
|
||||
}
|
||||
last_check_recall_config_time = last_check_recall_config_time + end - start;
|
||||
//printf("jread_resp->more_follows = 0 ==============%.2f================\n", last_check_recall_config_time);
|
||||
}
|
||||
else {
|
||||
printf ("\n annotation = %s", jou_entry->ef.annotation);
|
||||
}
|
||||
|
||||
//apr_time_exp_t newTime;
|
||||
//apr_time_exp_gmt(&newTime, t);
|
||||
printf("\nstart timecheck");
|
||||
apr_time_exp_t newTime;
|
||||
apr_time_exp_gmt(&newTime, process_jou_entry_t);
|
||||
@@ -677,10 +639,6 @@ ST_RET mms_jread (loginfo_t *loginfo,MVL_NET_INFO *clientNetInfo, ST_CHAR *dom_n
|
||||
}
|
||||
mvl_free_req_ctrl (reqCtrl); /* CRITICAL: */
|
||||
} while (more_follows);
|
||||
//mvl_type_id_destroy(1);
|
||||
//del_mvl_type_ctrl();
|
||||
//printf("do while ==============%.2f================\n", last_check_recall_config_time);
|
||||
//append_db_records(LOG_IDX);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,17 +25,17 @@ 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__;
|
||||
#endif
|
||||
|
||||
extern RPT_TYPEIDS g_rpt_typeids;
|
||||
//ied_info_t *my_info;
|
||||
|
||||
extern apr_pool_t* g_root_pool;
|
||||
uint8_t set_mx_q;
|
||||
//rdb_t *g_rdb = NULL;
|
||||
|
||||
node_t* g_node = NULL;
|
||||
extern char g_my_conf_fname[256];
|
||||
apr_pool_t* g_init_pool;
|
||||
@@ -51,19 +51,10 @@ uint8_t set_mx_q;
|
||||
|
||||
pt61850app_t* g_pt61850app;
|
||||
|
||||
//application_t g_sysfile_app; //ϵͳ<CFB5>ļ<EFBFBD><C4BC><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>Ϣ<EFBFBD>ṹ
|
||||
//int g_sysfile_appid = -1;
|
||||
//char *g_sysfile_filedir;
|
||||
//byte_t g_Master;
|
||||
//byte_t g_protect_file; //0:<3A><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD> 1:<3A>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ļ<EFBFBD>
|
||||
//apr_time_t g_file_valid_time; //ֻ<>ٻ<EFBFBD>ָ<EFBFBD><D6B8>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>
|
||||
//byte_t g_file_name_len; //<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD>ȣ<F3B3A4B6>Ĭ<EFBFBD><C4AC>Ϊ40<34><30><EFBFBD><EFBFBD>Ϊ0ʱ<30><CAB1>ʾ<EFBFBD><CABE><EFBFBD>ⳤ<EFBFBD><E2B3A4>
|
||||
//byte_t g_file_time_from; //<2F>ļ<EFBFBD><C4BC><EFBFBD>Чʱ<D0A7><CAB1>ȡֵ<C8A1>δ<EFBFBD><CEB4><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>1ȡϵͳʱ<CDB3><CAB1>
|
||||
|
||||
static void* APR_THREAD_FUNC rtdb_worker(apr_thread_t* thd, void* data);
|
||||
|
||||
static apr_status_t pt61850app_init();
|
||||
//static apr_status_t app_process_command(command_t *cmd);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
extern int three_secs_enabled;
|
||||
@@ -145,7 +136,7 @@ static apr_status_t read_DEV_idx_from_db()
|
||||
for (iedno = 0; iedno < g_node->n_clients; iedno++) {
|
||||
ied = g_node->clients[iedno];
|
||||
ied_usr = GET_IEDEXT_ADDR(ied);
|
||||
//read_DEV_Index_from_db(ied->channel[0].addr, &ied_usr->dev_idx);
|
||||
|
||||
for (cpuno = 0; cpuno < ied->cpucount; cpuno++) {
|
||||
LD_info = &(ied_usr->LD_info[cpuno]);
|
||||
if (LD_info->LD_name == NULL)
|
||||
@@ -153,12 +144,12 @@ static apr_status_t read_DEV_idx_from_db()
|
||||
len = strlen(LD_info->LD_name);
|
||||
tmp = LD_info->LD_name[len - 1] - '0';
|
||||
LD_info->line_id = ied_usr->dev_idx * 10 + tmp;
|
||||
//ret = read_line_infos_from_db(LD_info->line_id, &LD_info->SubV_Index,&LD_info->Dev_Index,&LD_info->Sub_Index,&LD_info->GD_Index);
|
||||
|
||||
if (ret != TRUE)
|
||||
LD_info->line_id = -1;
|
||||
if (LD_info->loginfo) {
|
||||
loginfo = LD_info->loginfo[0];
|
||||
//read_updatetime_from_db(ied->channel[0].addr, &loginfo->start_time);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,7 +159,7 @@ static apr_status_t read_DEV_idx_from_db()
|
||||
apr_status_t init_rdb()
|
||||
{
|
||||
apr_status_t rv;
|
||||
// driver_t* driver;
|
||||
|
||||
rv = apr_pool_create(&g_init_pool, g_root_pool);
|
||||
if (rv != APR_SUCCESS) {
|
||||
return rv;
|
||||
@@ -186,50 +177,28 @@ apr_status_t init_rdb()
|
||||
if (rv != APR_SUCCESS) {
|
||||
return rv;
|
||||
}
|
||||
//my_info = apr_pcalloc(g_run_pool,sizeof(ied_info_t));
|
||||
|
||||
rv = pt61850app_init();
|
||||
if (rv != APR_SUCCESS) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*rv = parse_json_cfg();
|
||||
if ( rv != APR_SUCCESS) {
|
||||
echo_errg("Failed to parse json define xml file! \n");
|
||||
return rv;
|
||||
}*/
|
||||
|
||||
init_config();
|
||||
GetServerIndexFromDB();
|
||||
/*lnk10-10*/
|
||||
//<2F><><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>web<65>ӿ<EFBFBD>
|
||||
//rv = parse_device_web_test_ext();
|
||||
//rv = parse_device_web_test_dev();
|
||||
//rv = parse_device_web_test_front_read();
|
||||
//rv = parse_device_web_test_front_write();
|
||||
|
||||
rv = parse_device_cfg_web();
|
||||
|
||||
//rv = parse_device_cfg();
|
||||
//rv = parse_device_cfg_json();
|
||||
//rv = parse_device_cfg_pg();
|
||||
if (rv != APR_SUCCESS) {
|
||||
echo_errg("Parsed device config xml file with error,try to run! \n");
|
||||
return rv;
|
||||
}
|
||||
/*lnk10-10*/
|
||||
//rv = parse_line_cfg_web(); <20>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD>ն<EFBFBD>̨<EFBFBD><CCA8>
|
||||
|
||||
//rv = parse_line_cfg();
|
||||
//rv = parse_line_cfg_pg();
|
||||
|
||||
/*lnk10-10*/
|
||||
rv = parse_model_cfg_web();
|
||||
if (rv != APR_SUCCESS) {
|
||||
echo_errg("Parsed model with error,try to run! \n");
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
//OTL_Select_xmlModel(); //xmlģ<6C><C4A3><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>ȡ
|
||||
Set_xml_nodeinfo();//<2F><><EFBFBD><EFBFBD>xmlģ<6C><C4A3>
|
||||
|
||||
rv = parse_rpt_log_ini();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
@@ -253,7 +222,7 @@ apr_status_t run_protocol()
|
||||
{
|
||||
apr_status_t rv;
|
||||
apr_thread_t* rtdb_thread;
|
||||
// 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>
|
||||
@@ -366,16 +335,6 @@ apr_status_t run_protocol()
|
||||
|
||||
}
|
||||
|
||||
//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();
|
||||
|
||||
@@ -387,44 +346,23 @@ extern uint32_t g_thread_blocked_times;
|
||||
/*--------------------------- <20><><EFBFBD><EFBFBD>ʵʱ<CAB5><CAB1><EFBFBD>߳<EFBFBD> -----------------------------------*/
|
||||
static void* APR_THREAD_FUNC rtdb_worker(apr_thread_t* thd, void* data)
|
||||
{
|
||||
// apr_event_t event;
|
||||
// command_t cmd[1];
|
||||
// int i =0;
|
||||
|
||||
/* Maintenance the clients request */
|
||||
while (1) {
|
||||
|
||||
//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); 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); printf("check connect free lock !!!!!!!!!!!");
|
||||
|
||||
//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); 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 !!!!!!!!!!!");
|
||||
|
||||
pthread_mutex_lock(&mtx);
|
||||
check_ledger_update();//lnk20250113<31><33>ȡ̨<C8A1>˸<EFBFBD><CBB8>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD>˸<EFBFBD><CBB8><EFBFBD>
|
||||
pthread_mutex_unlock(&mtx);
|
||||
|
||||
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>
|
||||
@@ -436,7 +374,6 @@ static void* APR_THREAD_FUNC rtdb_worker(apr_thread_t* thd, void* data)
|
||||
echo_msg("rtdb worker thread terminated...");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
void Set_val_from_61850rpt(element_t* elem, double v)
|
||||
@@ -453,7 +390,6 @@ int Set_q_from_61850rpt(char* q)
|
||||
else
|
||||
quality = 1;
|
||||
return quality;
|
||||
//set_rpt_QualityFlag(quality);
|
||||
}
|
||||
|
||||
#define TIME_T_2036 (66*365* SECONDS_PER_DAY)
|
||||
@@ -481,9 +417,6 @@ apr_time_t convert_btime6_to_apr_time(MMS_BTIME6* bTime6)
|
||||
return ticks;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
61850
|
||||
λ <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֵ
|
||||
@@ -594,8 +527,3 @@ byte_t get_pulse_q_from_61850(char* q_61850)
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -445,7 +445,6 @@ int SendMessageToWeb(int socketClient, int iErrorCode); //
|
||||
void CheckAllConnectedChannel() ;
|
||||
|
||||
void check_3s_config();
|
||||
void check_recall_config();
|
||||
void create_recall_xml();
|
||||
void check_disk_quota();
|
||||
|
||||
|
||||
@@ -549,15 +549,6 @@ void processQVVR_end(LD_info_t* LD_info)
|
||||
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);
|
||||
@@ -583,12 +574,6 @@ void processQVVR_end(LD_info_t* LD_info)
|
||||
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>
|
||||
|
||||
166
set_debug.sh
Normal file
166
set_debug.sh
Normal file
@@ -0,0 +1,166 @@
|
||||
#!/bin/bash
|
||||
|
||||
# @file: set_debug.sh
|
||||
# @brief: 启动或删除进程的脚本
|
||||
# @version: 1.0
|
||||
# @date: 2025/2/8 10:22:43
|
||||
# @author: lunankun
|
||||
|
||||
# 设置日志文件路径
|
||||
LOGFILE="$FEP_ENV/dat/log/start_fe.log"
|
||||
|
||||
# 输出当前时间并打印进程操作信息
|
||||
echo "" ; echo ""
|
||||
echo "****** `date "+%F %R:%S"` start set_debug Processes ******"
|
||||
echo "" >>"$LOGFILE"
|
||||
echo "" >>"$LOGFILE"
|
||||
echo "****** `date "+%F %R:%S"` start set_debug Processes ******" >>"$LOGFILE"
|
||||
|
||||
# 函数检查并处理日志文件大小
|
||||
check_log_file() {
|
||||
if [ -n "$1" ]; then
|
||||
FILE_SIZE=0
|
||||
FILE_SIZE=$(du "$1" | awk '{print $1}')
|
||||
|
||||
if [ $FILE_SIZE -ge 5120 ]; then
|
||||
if [ -f "$1".3 ]; then
|
||||
rm -f "$1".3
|
||||
fi
|
||||
if [ -f "$1".2 ]; then
|
||||
mv "$1".2 "$1".3
|
||||
fi
|
||||
if [ -f "$1".1 ]; then
|
||||
mv "$1".1 "$1".2
|
||||
fi
|
||||
mv "$1" "$1".1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 调用检查日志文件大小的函数
|
||||
check_log_file $LOGFILE
|
||||
|
||||
# 定义查找并杀死进程的函数
|
||||
kill_process_by_pid() {
|
||||
PID=$1
|
||||
if [ -n "$PID" ]; then
|
||||
echo "Found process with PID: $PID"
|
||||
echo "Killing process..."
|
||||
kill -9 $PID
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Process with PID: $PID killed successfully."
|
||||
else
|
||||
echo "Failed to kill the process with PID: $PID."
|
||||
fi
|
||||
else
|
||||
echo "Process not found."
|
||||
fi
|
||||
}
|
||||
|
||||
# 启动进程的函数
|
||||
start_process() {
|
||||
IP=$1
|
||||
TYPE=$2
|
||||
INDEX=$3
|
||||
|
||||
# 根据类型决定启动的进程
|
||||
if [ "$TYPE" == "stat" ]; then
|
||||
PROCESS_NAME="pt61850netd_pqfe -d cfg_stat_data -a $IP -s 0_$INDEX"
|
||||
elif [ "$TYPE" == "recall" ]; then
|
||||
PROCESS_NAME="pt61850netd_pqfe -d cfg_recallhis_data -a $IP -s 0_$INDEX"
|
||||
elif [ "$TYPE" == "comtrade" ]; then
|
||||
PROCESS_NAME="pt61850netd_pqfe -d cfg_soe_comtrade -a $IP -s 0_$INDEX"
|
||||
elif [ "$TYPE" == "3s" ]; then
|
||||
PROCESS_NAME="pt61850netd_pqfe -d cfg_3s_data -a $IP -s 0_$INDEX"
|
||||
else
|
||||
echo "Invalid type: $TYPE. Supported types are stat, recall, comtrade, or 3s."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查是否已经有相同的进程在运行
|
||||
PID=$(ps -ef | grep "$PROCESS_NAME" | grep -v "grep" | awk '{print $2}')
|
||||
|
||||
if [ -n "$PID" ]; then
|
||||
echo "Process '$PROCESS_NAME' already running with PID: $PID. Skipping start."
|
||||
echo "Process '$PROCESS_NAME' already running with PID: $PID. Skipping start." >>"$LOGFILE"
|
||||
else
|
||||
# 启动进程并记录PID
|
||||
echo "Starting process: $PROCESS_NAME"
|
||||
$PROCESS_NAME &
|
||||
sleep 1
|
||||
PID=$(ps -ef | grep "$PROCESS_NAME" | grep -v "grep" | awk '{print $2}')
|
||||
echo "Started process with PID: $PID"
|
||||
|
||||
# 记录日志
|
||||
echo "****** `date "+%F %R:%S"` Started process $PROCESS_NAME with PID: $PID" >>"$LOGFILE"
|
||||
fi
|
||||
}
|
||||
|
||||
# 删除进程的函数
|
||||
delete_process() {
|
||||
IP=$1
|
||||
TYPE=$2
|
||||
INDEX=$3
|
||||
|
||||
if [ "$TYPE" == "stat" ]; then
|
||||
PROCESS_NAME="pt61850netd_pqfe -d cfg_stat_data -a $IP -s 0_$INDEX"
|
||||
elif [ "$TYPE" == "recall" ]; then
|
||||
PROCESS_NAME="pt61850netd_pqfe -d cfg_recallhis_data -a $IP -s 0_$INDEX"
|
||||
elif [ "$TYPE" == "comtrade" ]; then
|
||||
PROCESS_NAME="pt61850netd_pqfe -d cfg_soe_comtrade -a $IP -s 0_$INDEX"
|
||||
elif [ "$TYPE" == "3s" ]; then
|
||||
PROCESS_NAME="pt61850netd_pqfe -d cfg_3s_data -a $IP -s 0_$INDEX"
|
||||
else
|
||||
echo "Invalid type: $TYPE. Supported types are stat, recall, comtrade, or 3s."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 查找进程并获取PID
|
||||
PID=$(ps -ef | grep "$PROCESS_NAME" | grep -v "grep" | awk '{print $2}')
|
||||
|
||||
# 如果找到进程,杀死它
|
||||
if [ -n "$PID" ]; then
|
||||
kill_process_by_pid $PID
|
||||
echo "****** `date "+%F %R:%S"` Deleted process $PROCESS_NAME with PID: $PID" >>"$LOGFILE"
|
||||
else
|
||||
echo "delete Process $PROCESS_NAME not found."
|
||||
echo "delete Process $PROCESS_NAME not found." >>"$LOGFILE"
|
||||
fi
|
||||
}
|
||||
|
||||
# 获取当前脚本的进程ID
|
||||
CURRENT_PID=$$
|
||||
|
||||
# 检查是否有其他的脚本正在运行,排除当前脚本
|
||||
if pgrep -f "set_debug.sh" | grep -v "^$CURRENT_PID$" > /dev/null; then
|
||||
echo "set_debug.sh is already running. Exiting..."
|
||||
echo "set_debug.sh is already running. Exiting..." >>"$LOGFILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 脚本应该等待3秒钟
|
||||
sleep 3
|
||||
|
||||
# 根据入参判断是 start 还是 delete
|
||||
if [ "$1" == "start" ]; then
|
||||
if [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ]; then
|
||||
echo "Usage: $0 start <IP> <stat|recall|comtrade|3s>"
|
||||
exit 1
|
||||
fi
|
||||
start_process $2 $3 $4
|
||||
elif [ "$1" == "delete" ]; then
|
||||
if [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ]; then
|
||||
echo "Usage: $0 delete <IP> <stat|recall|comtrade|3s>"
|
||||
exit 1
|
||||
fi
|
||||
delete_process $2 $3 $4
|
||||
else
|
||||
echo "Invalid option. Usage: $0 {start|delete} {IP} {stat|recall|comtrade|3s}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 获取当前时间并记录进程操作成功的日志
|
||||
DT=$(date "+%F %R:%S.%N")
|
||||
echo "****** ${DT:0:23} set_debug Process operation completed successfully ******"
|
||||
echo "" >>"$LOGFILE"
|
||||
echo "****** ${DT:0:23} set_debug Process operation completed successfully ******" >>"$LOGFILE"
|
||||
Reference in New Issue
Block a user