delete useless code
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user