1
0
Files

65 lines
2.1 KiB
C++
Raw Permalink Normal View History

2026-01-06 19:50:45 +08:00
#pragma once
2026-01-10 17:10:14 +08:00
#include <basalt/char_types.hpp>
2026-01-06 19:50:45 +08:00
#include <basalt/pipe_operator.hpp>
#include <cstdint>
2026-01-08 19:23:19 +08:00
namespace basalt::presenter::cmd_client {
2026-01-06 19:50:45 +08:00
2026-01-06 21:24:47 +08:00
// Protocol codes
enum class ProtocolCode : std::uint8_t {
2026-01-08 19:23:19 +08:00
HANDSHAKE_REQUEST = 0x61, ///< Trainer -> Presenter
HANDSHAKE_RESPONSE = 0x62, ///< Presenter -> Trainer
DATA_READY = 0x01, ///< Presenter -> Trainer
DATA_RECEIVED = 0x02, ///< Trainer -> Presenter
2026-01-08 19:37:25 +08:00
ACTIVELY_STOP = 0x21, ///< Presenter-->Trainer
2026-01-08 20:25:33 +08:00
STOP_REQUEST = 0x71, ///< Presenter<--Trainer
2026-01-08 19:37:25 +08:00
STOP_RESPONSE = 0x72, ///< Presenter-->Trainer
2026-01-06 21:24:47 +08:00
};
// 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
};
struct HandshakePayload {
2026-01-10 17:10:14 +08:00
bool headless;
2026-01-06 21:24:47 +08:00
PixelKind pixel_kind;
std::uint32_t width;
std::uint32_t height;
2026-01-10 17:10:14 +08:00
shared::char_types::BSString engine_name;
std::uint32_t engine_device;
2026-01-10 20:02:50 +08:00
shared::char_types::BSString deliver_name;
std::uint32_t deliver_device;
2026-01-10 17:10:14 +08:00
shared::char_types::BSString object_loader_name;
shared::char_types::BSString object_loader_file;
shared::char_types::BSString anime_loader_name;
shared::char_types::BSString anime_loader_file;
2026-01-06 21:24:47 +08:00
};
// Status
2026-01-08 19:37:25 +08:00
enum class CmdClientStatus {
2026-01-06 21:24:47 +08:00
Ready,
Running,
Stop,
};
2026-01-08 19:37:25 +08:00
class CmdClient {
2026-01-06 19:50:45 +08:00
public:
2026-01-08 19:37:25 +08:00
CmdClient();
~CmdClient();
2026-01-06 19:50:45 +08:00
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-08 19:37:25 +08:00
HandshakePayload wait_handshake();
2026-01-06 19:50:45 +08:00
// Tick function called every frame to send data ready and wait for response
2026-01-08 19:37:25 +08:00
bool tick(bool actively_stop = false);
2026-01-06 19:50:45 +08:00
private:
2026-01-08 19:37:25 +08:00
shared::pipe_operator::PipeOperator m_PipeOperator;
CmdClientStatus m_Status;
2026-01-06 19:50:45 +08:00
};
2026-01-08 19:37:25 +08:00
} // namespace basalt::presenter::cmd_client