45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
#ifndef LEDDISPLAYDEVICE_H
|
|
#define LEDDISPLAYDEVICE_H
|
|
|
|
#include "ILedDisplayDevice.h"
|
|
|
|
#include <cstdint>
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
class CLedDisplayDevice : public ILedDisplayDevice
|
|
{
|
|
public:
|
|
CLedDisplayDevice();
|
|
~CLedDisplayDevice() override;
|
|
|
|
int Open(const LedDisplayConfig& config) override;
|
|
void Close() override;
|
|
bool IsConnected() const override;
|
|
int SendResult(const LedDisplayResult& result) override;
|
|
const LedDisplayConfig& GetConfig() const override;
|
|
void SetStatusCallback(LedDisplayStatusCallback callback, void* user) override;
|
|
|
|
private:
|
|
void NotifyStatus(ELedDisplayStatus status, const std::string& message);
|
|
bool ConnectLocked();
|
|
void CloseSocketLocked();
|
|
bool SendFrameLocked(const std::vector<uint8_t>& data);
|
|
bool ReceiveAckLocked();
|
|
std::vector<uint8_t> BuildRealtimeData(const LedDisplayResult& result) const;
|
|
std::string BuildResultText(const LedDisplayResult& result) const;
|
|
void SetLastError(const std::string& error);
|
|
|
|
private:
|
|
mutable std::mutex m_mutex;
|
|
LedDisplayConfig m_config;
|
|
intptr_t m_socket = -1;
|
|
bool m_connected = false;
|
|
std::string m_lastError;
|
|
LedDisplayStatusCallback m_statusCallback;
|
|
void* m_statusUser = nullptr;
|
|
};
|
|
|
|
#endif // LEDDISPLAYDEVICE_H
|