add mq log and add test type in test mod
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
|
||||
//lnk20241031用于上传和下载文件
|
||||
#include "../json/cjson.h"
|
||||
|
||||
#include "../log4cplus/log4.h"//lnk添加log4
|
||||
///////////////////////////////////////////////////lnk2024-10-21////////////////////////////////////////////////////////
|
||||
extern void SendJsonAPI_web(const std::string& strUrl, const char* code, const std::string& json, char** ptr);
|
||||
extern std::string WEB_INTEGRITY;
|
||||
@@ -2518,6 +2520,9 @@ void Set_xml_databaseinfo(char* MODEL_ID, char* TMNL_TYPE, char* FILE_PATH, char
|
||||
sprintf(save_name, "%s", Qsavename.toAscii().data());
|
||||
cout << file_name << "!!!!!!!!!!!!!!!!!!!!!!!!!!" << save_name << endl;
|
||||
|
||||
//mq日志
|
||||
DIY_WARNLOG("process","【WARN】前置获取到终端类型%s,该终端类型对应的映射文件为%s,映射文件将下载并保存在本地为%s",TMNL_TYPE,FILE_PATH,save_name);
|
||||
|
||||
//20241028 lnk 替换为文件下载web接口
|
||||
//构造文件下载接口参数
|
||||
//接口示例http://192.168.1.125:10215/file/download?filePath=/path/xxx.txt
|
||||
@@ -2547,14 +2552,18 @@ void Set_xml_databaseinfo(char* MODEL_ID, char* TMNL_TYPE, char* FILE_PATH, char
|
||||
outFile.write(fileContent, strlen(fileContent));
|
||||
outFile.close();
|
||||
std::cout << "File saved successfully!" << std::endl;
|
||||
//mq日志
|
||||
DIY_WARNLOG("process","【WARN】前置下载映射文件%s成功",save_name);
|
||||
} else {
|
||||
std::cerr << "Error: Unable to open file for writing." << std::endl;
|
||||
DIY_ERRORLOG("process","【ERROR】前置写入本地映射文件%s失败",save_name);
|
||||
}
|
||||
|
||||
// 释放分配的内存
|
||||
free(fileContent);
|
||||
} else {
|
||||
std::cerr << "Error: Unable to download file." << std::endl;
|
||||
DIY_ERRORLOG("process","【ERROR】前置调用文件下载接口下载远端文件文件%s失败",FILE_PATH);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ extern "C" {
|
||||
|
||||
#include <iostream>
|
||||
extern int G_TEST_NUM;
|
||||
extern int G_TEST_TYPE;
|
||||
extern void ledger(const char* terminal_id = NULL,QIODevice* outputDevice = NULL);
|
||||
extern void value_print(const char *variableName, QTcpSocket *clientSocket);
|
||||
extern int TEST_PORT;
|
||||
@@ -121,6 +122,7 @@ public:
|
||||
: QObject(parent),
|
||||
server(NULL),
|
||||
TEST_NUM(G_TEST_NUM),
|
||||
TEST_TYPE(G_TEST_TYPE),
|
||||
timer(NULL),
|
||||
historyIndex(-1),
|
||||
stopViewLog(true),
|
||||
@@ -208,6 +210,14 @@ public slots:
|
||||
TEST_NUM = num;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 设置TEST_TYPE
|
||||
*/
|
||||
void setTestType(int type) {
|
||||
QMutexLocker locker(&mutex);
|
||||
TEST_TYPE = type;
|
||||
}
|
||||
|
||||
void setTestlog(bool flag) {
|
||||
redirectErrorOutput(flag);
|
||||
redirectWarnOutput(flag);
|
||||
@@ -221,13 +231,13 @@ private slots:
|
||||
*/
|
||||
void doPeriodicTask() {
|
||||
QMutexLocker locker(&mutex);
|
||||
std::cout << "Executing TEST_NUM is " << TEST_NUM << std::endl;
|
||||
qDebug() << "doPeriodicTask() called. TEST_NUM = " << TEST_NUM;
|
||||
std::cout << "Executing TEST_NUM is " << TEST_NUM << "Executing TEST_TYPE is " << TEST_TYPE << std::endl;
|
||||
qDebug() << "doPeriodicTask() called. TEST_NUM = " << TEST_NUM << "Executing TEST_TYPE is " << TEST_TYPE;
|
||||
|
||||
if (TEST_NUM != 0) {
|
||||
qDebug() << "Executing rocketmq_test_300()";
|
||||
std::cout << "Executing rocketmq_test_300()\n";
|
||||
rocketmq_test_300(TEST_NUM, g_front_seg_index);
|
||||
rocketmq_test_300(TEST_NUM, g_front_seg_index,TEST_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,6 +412,7 @@ private:
|
||||
if (cmd == "help") {
|
||||
QString helpText = "Available commands:\r\n";
|
||||
helpText += "TEST_NUM=<num> - Set the TEST_NUM\r\n";
|
||||
helpText += "TEST_TYPE=<num> - Set the TEST_TYPE 0:use ledger,1:use number\r\n";
|
||||
helpText += "LOG=<bool> - Set the LOG\r\n";
|
||||
helpText += "telnettest - Set the telnettest\r\n";
|
||||
helpText += "rc - Execute rocketmq_test_rc\r\n";
|
||||
@@ -437,13 +448,25 @@ private:
|
||||
clientSocket->write("Invalid number\r\n");
|
||||
}
|
||||
}
|
||||
else if (cmd.startsWith("TEST_TYPE=")) {
|
||||
bool ok;
|
||||
int type = cmd.mid(10).toInt(&ok);
|
||||
if (ok) {
|
||||
setTestType(type);
|
||||
clientSocket->write("\r\x1B[K");
|
||||
clientSocket->write("TEST_TYPE updated\r\n");
|
||||
} else {
|
||||
clientSocket->write("\r\x1B[K");
|
||||
clientSocket->write("Invalid type\r\n");
|
||||
}
|
||||
}
|
||||
else if (cmd.startsWith("LOG=")) {
|
||||
bool ok;
|
||||
bool flag = cmd.mid(4).toInt(&ok);
|
||||
if (ok) {
|
||||
setTestlog(flag);
|
||||
clientSocket->write("\r\x1B[K");
|
||||
clientSocket->write("TEST_NUM updated\r\n");
|
||||
clientSocket->write("LOG updated\r\n");
|
||||
} else {
|
||||
clientSocket->write("\r\x1B[K");
|
||||
clientSocket->write("Invalid number\r\n");
|
||||
@@ -583,6 +606,7 @@ private:
|
||||
QTcpServer *server;
|
||||
QTimer *timer;
|
||||
int TEST_NUM;
|
||||
int TEST_TYPE;
|
||||
QMutex mutex;
|
||||
|
||||
// 历史命令相关
|
||||
|
||||
Reference in New Issue
Block a user