From a68073a77792dc96cecbfb79693d531bc51ebbac Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期五, 08 八月 2025 18:01:35 +0800
Subject: [PATCH] 1. 修复保存图片分配率问题 2. 修复获取相机配置的问题 3. 添加侧面检的视觉模块
---
EdgeInspector_App/WebSocket/WebSocketClient.h | 250 +++++++++++++++++++++++++-------------------------
1 files changed, 125 insertions(+), 125 deletions(-)
diff --git a/EdgeInspector_App/WebSocket/WebSocketClient.h b/EdgeInspector_App/WebSocket/WebSocketClient.h
index bd47a7b..ea850b0 100644
--- a/EdgeInspector_App/WebSocket/WebSocketClient.h
+++ b/EdgeInspector_App/WebSocket/WebSocketClient.h
@@ -1,129 +1,129 @@
-#ifndef WEBSOCKETCLIENT_H
+锘�#ifndef WEBSOCKETCLIENT_H
#define WEBSOCKETCLIENT_H
-#include <websocketpp/config/asio_no_tls_client.hpp>
-#include <websocketpp/client.hpp>
-#include <string>
-#include <vector>
-#include <iostream>
-#include <thread>
-#include <atomic>
-#include <mutex>
-#include <functional>
-#include <chrono>
-
-typedef websocketpp::client<websocketpp::config::asio_client> client;
-
-class WebSocketClient {
-public:
- using message_ptr = websocketpp::config::asio_client::message_type::ptr;
- using connection_hdl = websocketpp::connection_hdl;
- using OpenHandler = std::function<void()>;
- using MessageHandler = std::function<void(const std::string&)>;
- using CloseHandler = std::function<void()>;
- using FailHandler = std::function<void()>;
- using PongHandler = std::function<void(const std::string&)>;
-
- WebSocketClient();
- ~WebSocketClient();
-
- // 连接到指定的URI
- void connect(const std::string& uri);
-
- // 增加客户端的状态标识
- bool is_busy() const;
- void set_busy(bool busy);
-
- // 发送文本消息
- void send(const std::string& message);
-
- // 发送二进制数据
- void send_binary(const std::vector<char>& binary_data);
-
- // 通过队列发送文本消息
- void enqueue_message(const std::string& message);
-
- // 通过队列发送二进制数据
- void enqueue_binary(const std::vector<char>& binary_data);
-
- // 处理下一个消息
- void process_next_message();
- void process_next_binary();
-
- // 发送文本消息并等待回复
- bool send_and_wait(const std::string& message, int timeout_ms);
-
- // 发送二进制数据并等待回复
- bool send_binary_and_wait(const std::vector<char>& binary_data, int timeout_ms);
-
- // 关闭连接
- void close();
-
- // 设置各种回调函数
- void set_open_handler(OpenHandler handler);
- void set_message_handler(MessageHandler handler);
- void set_close_handler(CloseHandler handler);
- void set_fail_handler(FailHandler handler);
- void set_pong_handler(PongHandler handler);
-
- // 设置心跳间隔(单位:秒)
- void set_heartbeat_interval(int interval);
-
- // 获取当前连接的URL
- std::string get_current_url();
-
- // 检查当前连接是否仍然有效
- bool is_connected() const;
-
-private:
- // WebSocket 运行函数
- void run();
-
- // 心跳检查函数
- void heartbeat();
-
- // 回调函数触发器
- void on_open(websocketpp::connection_hdl hdl);
- void on_message(connection_hdl hdl, message_ptr msg);
- void on_close(websocketpp::connection_hdl hdl);
- void on_fail(websocketpp::connection_hdl hdl);
- void on_pong(websocketpp::connection_hdl hdl, const std::string& payload);
-
-private:
- // WebSocket客户端实例
- client m_client;
-
- // WebSocket 连接句柄
- connection_hdl m_hdl;
-
- // 线程相关
- std::thread m_thread;
- std::thread m_heartbeat_thread;
- std::atomic<bool> m_connected;
- std::atomic<bool> m_reconnect;
- int m_heartbeat_interval;
- bool m_message_received;
-
- // 发送队列
- std::queue<std::string> m_message_queue;
- std::queue<std::vector<char>> m_binary_queue;
-
- // 标识客户端是否忙碌
- std::atomic<bool> m_busy;
-
- // 线程同步相关
- bool m_close_done;
- std::condition_variable m_cv;
-
- // 互斥锁,用于保护共享资源
- std::mutex m_mutex;
-
- // 回调函数
- OpenHandler m_open_handler;
- MessageHandler m_message_handler;
- CloseHandler m_close_handler;
- FailHandler m_fail_handler;
- PongHandler m_pong_handler;
-};
+//#include <websocketpp/config/asio_no_tls_client.hpp>
+//#include <websocketpp/client.hpp>
+//#include <string>
+//#include <vector>
+//#include <iostream>
+//#include <thread>
+//#include <atomic>
+//#include <mutex>
+//#include <functional>
+//#include <chrono>
+//
+//typedef websocketpp::client<websocketpp::config::asio_client> client;
+//
+//class WebSocketClient {
+//public:
+// using message_ptr = websocketpp::config::asio_client::message_type::ptr;
+// using connection_hdl = websocketpp::connection_hdl;
+// using OpenHandler = std::function<void()>;
+// using MessageHandler = std::function<void(const std::string&)>;
+// using CloseHandler = std::function<void()>;
+// using FailHandler = std::function<void()>;
+// using PongHandler = std::function<void(const std::string&)>;
+//
+// WebSocketClient();
+// ~WebSocketClient();
+//
+// // 杩炴帴鍒版寚瀹氱殑URI
+// void connect(const std::string& uri);
+//
+// // 澧炲姞瀹㈡埛绔殑鐘舵�佹爣璇�
+// bool is_busy() const;
+// void set_busy(bool busy);
+//
+// // 鍙戦�佹枃鏈秷鎭�
+// void send(const std::string& message);
+//
+// // 鍙戦�佷簩杩涘埗鏁版嵁
+// void send_binary(const std::vector<char>& binary_data);
+//
+// // 閫氳繃闃熷垪鍙戦�佹枃鏈秷鎭�
+// void enqueue_message(const std::string& message);
+//
+// // 閫氳繃闃熷垪鍙戦�佷簩杩涘埗鏁版嵁
+// void enqueue_binary(const std::vector<char>& binary_data);
+//
+// // 澶勭悊涓嬩竴涓秷鎭�
+// void process_next_message();
+// void process_next_binary();
+//
+// // 鍙戦�佹枃鏈秷鎭苟绛夊緟鍥炲
+// bool send_and_wait(const std::string& message, int timeout_ms);
+//
+// // 鍙戦�佷簩杩涘埗鏁版嵁骞剁瓑寰呭洖澶�
+// bool send_binary_and_wait(const std::vector<char>& binary_data, int timeout_ms);
+//
+// // 鍏抽棴杩炴帴
+// void close();
+//
+// // 璁剧疆鍚勭鍥炶皟鍑芥暟
+// void set_open_handler(OpenHandler handler);
+// void set_message_handler(MessageHandler handler);
+// void set_close_handler(CloseHandler handler);
+// void set_fail_handler(FailHandler handler);
+// void set_pong_handler(PongHandler handler);
+//
+// // 璁剧疆蹇冭烦闂撮殧锛堝崟浣嶏細绉掞級
+// void set_heartbeat_interval(int interval);
+//
+// // 鑾峰彇褰撳墠杩炴帴鐨刄RL
+// std::string get_current_url();
+//
+// // 妫�鏌ュ綋鍓嶈繛鎺ユ槸鍚︿粛鐒舵湁鏁�
+// bool is_connected() const;
+//
+//private:
+// // WebSocket 杩愯鍑芥暟
+// void run();
+//
+// // 蹇冭烦妫�鏌ュ嚱鏁�
+// void heartbeat();
+//
+// // 鍥炶皟鍑芥暟瑙﹀彂鍣�
+// void on_open(websocketpp::connection_hdl hdl);
+// void on_message(connection_hdl hdl, message_ptr msg);
+// void on_close(websocketpp::connection_hdl hdl);
+// void on_fail(websocketpp::connection_hdl hdl);
+// void on_pong(websocketpp::connection_hdl hdl, const std::string& payload);
+//
+//private:
+// // WebSocket瀹㈡埛绔疄渚�
+// client m_client;
+//
+// // WebSocket 杩炴帴鍙ユ焺
+// connection_hdl m_hdl;
+//
+// // 绾跨▼鐩稿叧
+// std::thread m_thread;
+// std::thread m_heartbeat_thread;
+// std::atomic<bool> m_connected;
+// std::atomic<bool> m_reconnect;
+// int m_heartbeat_interval;
+// bool m_message_received;
+//
+// // 鍙戦�侀槦鍒�
+// std::queue<std::string> m_message_queue;
+// std::queue<std::vector<char>> m_binary_queue;
+//
+// // 鏍囪瘑瀹㈡埛绔槸鍚﹀繖纰�
+// std::atomic<bool> m_busy;
+//
+// // 绾跨▼鍚屾鐩稿叧
+// bool m_close_done;
+// std::condition_variable m_cv;
+//
+// // 浜掓枼閿侊紝鐢ㄤ簬淇濇姢鍏变韩璧勬簮
+// std::mutex m_mutex;
+//
+// // 鍥炶皟鍑芥暟
+// OpenHandler m_open_handler;
+// MessageHandler m_message_handler;
+// CloseHandler m_close_handler;
+// FailHandler m_fail_handler;
+// PongHandler m_pong_handler;
+//};
#endif // WEBSOCKETCLIENT_H
\ No newline at end of file
--
Gitblit v1.9.3