2026-01-06 19:50:45 +08:00
|
|
|
#pragma once
|
|
|
|
|
#include <basalt/pipe_operator.hpp>
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
|
|
namespace Basalt::Presenter {
|
|
|
|
|
|
2026-01-06 21:24:47 +08:00
|
|
|
// Protocol codes
|
|
|
|
|
enum class ProtocolCode : std::uint8_t {
|
|
|
|
|
HANDSHAKE_REQUEST = 0x61, //< Trainer -> Presenter
|
|
|
|
|
HANDSHAKE_RESPONSE = 0x62, //< Presenter -> Trainer
|
|
|
|
|
DATA_READY = 0x01, //< Presenter -> Trainer
|
|
|
|
|
DATA_RECEIVED = 0x02, //< Trainer -> Presenter
|
|
|
|
|
STOP_REQUEST = 0x71, //< Both directions
|
|
|
|
|
STOP = 0x71 //< Both directions (same code)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Pixel kind values
|
|
|
|
|
enum class PixelKind : std::uint8_t {
|
|
|
|
|
GRAY_FLOAT32 = 0x01, ///< Grayscale represented by one float32
|
|
|
|
|
GRAY_U8 = 0x02, ///< Grayscale represented by one u8
|
|
|
|
|
RGB_FLOAT32 = 0x03, ///< RGB represented by three float32
|
|
|
|
|
RGB_U8 = 0x04 ///< RGB represented by three u8
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
|
struct HandshakePayload {
|
|
|
|
|
PixelKind pixel_kind;
|
|
|
|
|
std::uint32_t width;
|
|
|
|
|
std::uint32_t height;
|
|
|
|
|
};
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
// Status
|
|
|
|
|
enum class ClientStatus {
|
|
|
|
|
Ready,
|
|
|
|
|
Running,
|
|
|
|
|
Stop,
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-06 19:50:45 +08:00
|
|
|
class CommandClient {
|
|
|
|
|
public:
|
2026-01-06 21:24:47 +08:00
|
|
|
CommandClient();
|
2026-01-06 19:50:45 +08:00
|
|
|
~CommandClient();
|
|
|
|
|
|
2026-01-06 21:24:47 +08:00
|
|
|
public:
|
2026-01-06 19:50:45 +08:00
|
|
|
// Wait for handshake from Trainer, send response with data properties
|
2026-01-06 21:24:47 +08:00
|
|
|
HandshakePayload WaitHandshake();
|
2026-01-06 19:50:45 +08:00
|
|
|
// Tick function called every frame to send data ready and wait for response
|
|
|
|
|
bool Tick(bool actively_stop = false);
|
|
|
|
|
|
|
|
|
|
private:
|
2026-01-06 21:24:47 +08:00
|
|
|
Shared::PipeOperator m_PipeOperator;
|
|
|
|
|
ClientStatus m_Status;
|
2026-01-06 19:50:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Basalt::Presenter
|