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