50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#ifndef UNIFIED_MANAGER_HPP
|
|
#define UNIFIED_MANAGER_HPP
|
|
|
|
#include "serialComm.hpp"
|
|
#include <memory>
|
|
#include <thread>
|
|
#include <atomic>
|
|
#include <mutex>
|
|
|
|
// Unified device manager (Serial )
|
|
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
|