修改
This commit is contained in:
@@ -6,44 +6,36 @@
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <chrono>
|
||||
#include <fmt/core.h>
|
||||
|
||||
// Unified device manager (Serial )
|
||||
// Unified device manager (Serial only)
|
||||
class UnifiedDeviceManager {
|
||||
private:
|
||||
// Device instances
|
||||
std::unique_ptr<SerialComm> m_serial;
|
||||
std::unique_ptr<CameraManager> m_camera;
|
||||
|
||||
// Thread management
|
||||
|
||||
std::thread m_serialReconnectThread;
|
||||
std::atomic<bool> m_serialConnected;
|
||||
std::atomic<bool> m_shouldStop;
|
||||
|
||||
|
||||
std::mutex m_serialMutex;
|
||||
|
||||
|
||||
int m_retryIntervalMs;
|
||||
|
||||
// Serial reconnect thread
|
||||
|
||||
void serialReconnectThreadFunc();
|
||||
|
||||
public:
|
||||
UnifiedDeviceManager(int retryIntervalMs = 500);
|
||||
~UnifiedDeviceManager();
|
||||
|
||||
// Control methods
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
// Status check
|
||||
|
||||
bool isSerialConnected() const { return m_serialConnected.load(); }
|
||||
|
||||
|
||||
// Serial operations (thread-safe)
|
||||
bool sendData(const char* data, size_t length);
|
||||
int receiveData(uint8_t* buffer, size_t maxLength);
|
||||
|
||||
// Camera operations (thread-safe)
|
||||
bool grabFrame(cv::Mat& frame);
|
||||
const char* getCameraName() const;
|
||||
};
|
||||
|
||||
#endif // UNIFIED_MANAGER_HPP
|
||||
|
||||
Reference in New Issue
Block a user