1
0

refactor shared

This commit is contained in:
2026-01-08 19:23:19 +08:00
parent 07cc58fb36
commit 64368b7837
23 changed files with 400 additions and 234 deletions

View File

@@ -3,14 +3,14 @@ target_sources(BasaltPresenter
PRIVATE PRIVATE
main.cpp main.cpp
dll_loader.cpp dll_loader.cpp
command_client.cpp cmd_client.cpp
) )
target_sources(BasaltPresenter target_sources(BasaltPresenter
PUBLIC PUBLIC
FILE_SET HEADERS FILE_SET HEADERS
FILES FILES
dll_loader.hpp dll_loader.hpp
command_client.hpp cmd_client.hpp
) )
target_include_directories(BasaltPresenter target_include_directories(BasaltPresenter
PUBLIC PUBLIC

View File

@@ -1,8 +1,8 @@
#include "command_client.hpp" #include "cmd_client.hpp"
#include <basalt/char_types.hpp> #include <basalt/char_types.hpp>
#include <stdexcept> #include <stdexcept>
namespace Basalt::Presenter { namespace basalt::presenter::cmd_client {
CommandClient::CommandClient() : m_PipeOperator(BSTEXT("ed0e3f1f-d214-4880-9562-640bce15e72e")), m_Status(ClientStatus::Ready) {} CommandClient::CommandClient() : m_PipeOperator(BSTEXT("ed0e3f1f-d214-4880-9562-640bce15e72e")), m_Status(ClientStatus::Ready) {}

View File

@@ -2,16 +2,17 @@
#include <basalt/pipe_operator.hpp> #include <basalt/pipe_operator.hpp>
#include <cstdint> #include <cstdint>
namespace Basalt::Presenter { namespace basalt::presenter::cmd_client {
// Protocol codes // Protocol codes
enum class ProtocolCode : std::uint8_t { enum class ProtocolCode : std::uint8_t {
HANDSHAKE_REQUEST = 0x61, //< Trainer -> Presenter HANDSHAKE_REQUEST = 0x61, ///< Trainer -> Presenter
HANDSHAKE_RESPONSE = 0x62, //< Presenter -> Trainer HANDSHAKE_RESPONSE = 0x62, ///< Presenter -> Trainer
DATA_READY = 0x01, //< Presenter -> Trainer DATA_READY = 0x01, ///< Presenter -> Trainer
DATA_RECEIVED = 0x02, //< Trainer -> Presenter DATA_RECEIVED = 0x02, ///< Trainer -> Presenter
STOP_REQUEST = 0x71, //< Both directions ACTIVELY_STOP = 0x21, ///< Presenter-->Trainer
STOP = 0x71 //< Both directions (same code) STOP_REQUEST = 0X71, ///< Presenter<--Trainer
STOP_RESPONSE = 0x72, //< Presenter-->Trainer
}; };
// Pixel kind values // Pixel kind values

View File

@@ -8,9 +8,9 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
using ::Basalt::Shared::Char::BSStringView; using ::basalt::shared::char_types::BSStringView;
namespace Basalt::Presenter { namespace basalt::presenter::dll_loader {
static std::filesystem::path get_executable() { static std::filesystem::path get_executable() {
#if defined(BASALT_OS_WINDOWS) #if defined(BASALT_OS_WINDOWS)

View File

@@ -1,5 +1,4 @@
#include <basalt/char_types.hpp> #include <basalt/char_types.hpp>
#include <string_view>
#if defined(BASALT_OS_WINDOWS) #if defined(BASALT_OS_WINDOWS)
#include <Windows.h> #include <Windows.h>
@@ -7,7 +6,7 @@
#include <dlfcn.h> #include <dlfcn.h>
#endif #endif
namespace Basalt::Presenter { namespace basalt::presenter::dll_loader {
enum class DllKind { enum class DllKind {
Engine, ///< Render engine Engine, ///< Render engine
@@ -25,7 +24,7 @@ namespace Basalt::Presenter {
#endif #endif
public: public:
DllLoader(DllKind kind, const Shared::Char::BSStringView& filename); DllLoader(DllKind kind, const shared::char_types::BSStringView& filename);
~DllLoader(); ~DllLoader();
private: private:

View File

@@ -3,8 +3,11 @@ target_sources(BasaltShared
PRIVATE PRIVATE
# Sources # Sources
basalt/pipe_operator.cpp basalt/pipe_operator.cpp
basalt/kernel.cpp
basalt/math.cpp basalt/math.cpp
basalt/engine.cpp
basalt/deliver.cpp
basalt/object_loader.cpp
basalt/anime_loader.cpp
) )
target_sources(BasaltShared target_sources(BasaltShared
@@ -15,8 +18,12 @@ FILES
basalt/char_types.hpp basalt/char_types.hpp
basalt/export_macro.hpp basalt/export_macro.hpp
basalt/pipe_operator.hpp basalt/pipe_operator.hpp
basalt/kernel.hpp
basalt/math.hpp basalt/math.hpp
basalt/guid.hpp
basalt/engine.hpp
basalt/deliver.hpp
basalt/object_loader.hpp
basalt/anime_loader.hpp
) )
target_include_directories(BasaltShared target_include_directories(BasaltShared
PUBLIC PUBLIC

View File

@@ -0,0 +1,13 @@
#include "anime_loader.hpp"
namespace basalt::shared::anime_loader {
IAnimeLoader::IAnimeLoader() {
}
IAnimeLoader::~IAnimeLoader() {
}
}

View File

@@ -0,0 +1,13 @@
#pragma once
namespace basalt::shared::anime_loader {
class IAnimeLoader {
public:
IAnimeLoader();
virtual ~IAnimeLoader();
protected:
};
} // namespace basalt::shared::anime_loader

View File

@@ -12,9 +12,9 @@
#define BSTEXT(x) x #define BSTEXT(x) x
#endif #endif
namespace Basalt::Shared::Char { namespace basalt::shared::char_types {
using BSString = std::basic_string<BSCHAR>; using BSString = std::basic_string<BSCHAR>;
using BSStringView = std::basic_string_view<BSCHAR>; using BSStringView = std::basic_string_view<BSCHAR>;
}; // namespace Basalt::Shared::Char }; // namespace basalt::shared::char_types

View File

@@ -0,0 +1,29 @@
#include "deliver.hpp"
#include <stdexcept>
namespace basalt::shared::deliver {
IDeliver::IDeliver() {}
IDeliver::~IDeliver() {}
guid::Guid IDeliver::GetGuid() const {
throw std::logic_error("unimplemented function");
}
void IDeliver::Startup(DeliverConfig &&config) {
if (this->status != DeliverStatus::Ready) throw std::runtime_error("unexpected deliver status");
this->config = std::move(config);
this->status = DeliverStatus::Running;
}
void IDeliver::Transmit() {
if (this->status != DeliverStatus::Running) throw std::runtime_error("unexpected deliver status");
}
void IDeliver::Shutdown() {
if (this->status != DeliverStatus::Running) throw std::runtime_error("unexpected deliver status");
this->status = DeliverStatus::Stop;
}
}

View File

@@ -0,0 +1,33 @@
#pragma once
#include "guid.hpp"
namespace basalt::shared::deliver {
struct DeliverConfig {
guid::Guid engine; ///< The GUID of render engine.
};
enum class DeliverStatus {
Ready, ///< Engine was allocated but not initialized.
Running, ///< Engine has been initialized and running.
Stop, ///< Engine is shutdown.
};
class IDeliver {
public:
IDeliver();
virtual ~IDeliver();
public:
virtual guid::Guid GetGuid() const;
virtual void Startup(DeliverConfig&& config);
virtual void Transmit();
virtual void Shutdown();
protected:
DeliverConfig config;
DeliverStatus status;
};
}

View File

@@ -0,0 +1,34 @@
#include "engine.hpp"
#include <stdexcept>
namespace basalt::shared::engine {
IEngine::IEngine() : config(), status(EngineStatus::Ready) {}
IEngine::~IEngine() {
if (this->status != EngineStatus::Stop) {
this->Shutdown();
}
}
guid::Guid IEngine::GetGuid() const {
throw std::logic_error("unimplemented function");
}
void IEngine::Startup(EngineConfig &&config) {
if (this->status != EngineStatus::Ready) throw std::runtime_error("unexpected engine status");
this->config = std::move(config);
this->status = EngineStatus::Running;
}
bool IEngine::Tick() {
if (this->status != EngineStatus::Running) throw std::runtime_error("unexpected engine status");
return false;
}
void IEngine::Shutdown() {
if (this->status != EngineStatus::Running) throw std::runtime_error("unexpected engine status");
this->status = EngineStatus::Stop;
}
}

View File

@@ -0,0 +1,41 @@
#pragma once
#include "guid.hpp"
#include <string>
#include <cinttypes>
namespace basalt::shared::engine {
struct EngineConfig {
bool headless; ///< Whether enable headless mode (No Window created).
std::uint32_t width; ///< Window width.
std::uint32_t height; ///< Window height.
guid::Guid deliver; ///< The GUID of deliver.
};
enum class EngineStatus {
Ready, ///< Engine was allocated but not initialized.
Running, ///< Engine has been initialized and running.
Stop, ///< Engine is shutdown.
};
class IEngine {
public:
IEngine();
virtual ~IEngine();
public:
virtual guid::Guid GetGuid() const;
virtual void Startup(EngineConfig&& config);
/**
* @brief
* @return True for active exit.
*/
virtual bool Tick();
virtual void Shutdown();
protected:
EngineConfig config;
EngineStatus status;
};
} // namespace basalt::shared::engine

View File

@@ -0,0 +1,50 @@
#pragma once
#include <cinttypes>
#include <compare>
namespace basalt::shared::guid {
struct Guid {
std::uint32_t d1, d2;
constexpr Guid(std::uint32_t gd1 = 0, std::uint32_t gd2 = 0) : d1(gd1), d2(gd2) {}
Guid(const Guid& rhs) : d1(rhs.d1), d2(rhs.d2) {}
Guid(Guid&& rhs) noexcept : d1(rhs.d1), d2(rhs.d2) {}
Guid& operator=(const Guid& rhs) {
this->d1 = rhs.d1;
this->d2 = rhs.d2;
return *this;
}
Guid& operator=(Guid&& rhs) noexcept {
this->d1 = rhs.d1;
this->d2 = rhs.d2;
return *this;
}
auto operator<=>(const Guid& rhs) const {
if (auto cmp = this->d1 <=> rhs.d1; cmp != 0) return cmp;
return this->d2 <=> rhs.d2;
}
bool operator==(const Guid& rhs) const { return ((this->d1 == rhs.d1) && (this->d2 == rhs.d2)); }
};
constexpr Guid DIRECTX8_ENGINE{0x0, 0x1};
constexpr Guid DIRECTX9_ENGINE{0x0, 0x2};
constexpr Guid DIRECTX11_ENGINE{0x0, 0x3};
constexpr Guid DIRECTX12_ENGINE{0x0, 0x4};
constexpr Guid OPENGL_ENGINE{0x0, 0x5};
constexpr Guid VULKAN_ENGINE{0x0, 0x6};
constexpr Guid CUDA_DELIVER{0x1, 0x1};
constexpr Guid ROCM_DELIVER{0x1, 0x2};
constexpr Guid PIPE_DELIVER{0x1, 0x3};
constexpr Guid TCP_DELIVER{0x1, 0x4};
constexpr Guid MMAP_DELIVER{0x1, 0x5};
constexpr Guid TINYOBJLOADER_OBJECT_LOADER{0x2, 0x1};
constexpr Guid CGLTF_OBJECT_LOADER{0x2, 0x2};
constexpr Guid ASSIMP_OBJECT_LOADER{0x2, 0x3};
constexpr Guid HOMEBREW_ANIME_LOADER{0x3, 0x1};
}

View File

@@ -1,65 +0,0 @@
#include "kernel.hpp"
#include <stdexcept>
namespace Basalt::Shared::Kernel {
#pragma region Engine
IEngine::IEngine() : config(), status(EngineStatus::Ready) {}
IEngine::~IEngine() {
if (this->status != EngineStatus::Stop) {
this->Shutdown();
}
}
Guid IEngine::GetGuid() const {
throw std::logic_error("unimplemented function");
}
void IEngine::Startup(EngineConfig &&config) {
if (this->status != EngineStatus::Ready) throw std::runtime_error("unexpected engine status");
this->config = std::move(config);
this->status = EngineStatus::Running;
}
bool IEngine::Tick() {
if (this->status != EngineStatus::Running) throw std::runtime_error("unexpected engine status");
return false;
}
void IEngine::Shutdown() {
if (this->status != EngineStatus::Running) throw std::runtime_error("unexpected engine status");
this->status = EngineStatus::Stop;
}
#pragma endregion
#pragma region Deliver
IDeliver::IDeliver() {}
IDeliver::~IDeliver() {}
Guid IDeliver::GetGuid() const {
throw std::logic_error("unimplemented function");
}
void IDeliver::Startup(DeliverConfig &&config) {
if (this->status != DeliverStatus::Ready) throw std::runtime_error("unexpected deliver status");
this->config = std::move(config);
this->status = DeliverStatus::Running;
}
void IDeliver::Transmit() {
if (this->status != DeliverStatus::Running) throw std::runtime_error("unexpected deliver status");
}
void IDeliver::Shutdown() {
if (this->status != DeliverStatus::Running) throw std::runtime_error("unexpected deliver status");
this->status = DeliverStatus::Stop;
}
#pragma endregion
} // namespace Basalt::Shared::Kernel

View File

@@ -1,123 +0,0 @@
#pragma once
#include "char_types.hpp"
#include <string>
#include <cinttypes>
namespace Basalt::Shared::Kernel {
#pragma region Guid & Predefined Guid
struct Guid {
std::uint32_t d1, d2;
constexpr Guid(std::uint32_t gd1 = 0, std::uint32_t gd2 = 0) : d1(gd1), d2(gd2) {}
Guid(const Guid& rhs) : d1(rhs.d1), d2(rhs.d2) {}
Guid(Guid&& rhs) noexcept : d1(rhs.d1), d2(rhs.d2) {}
Guid& operator=(const Guid& rhs) {
this->d1 = rhs.d1;
this->d2 = rhs.d2;
return *this;
}
Guid& operator=(Guid&& rhs) noexcept {
this->d1 = rhs.d1;
this->d2 = rhs.d2;
return *this;
}
auto operator<=>(const Guid& rhs) const {
if (auto cmp = this->d1 <=> rhs.d1; cmp != 0) return cmp;
return this->d2 <=> rhs.d2;
}
bool operator==(const Guid& rhs) const { return ((this->d1 == rhs.d1) && (this->d2 == rhs.d2)); }
};
constexpr Guid DIRECTX8_ENGINE{0x0, 0x1};
constexpr Guid DIRECTX9_ENGINE{0x0, 0x2};
constexpr Guid DIRECTX11_ENGINE{0x0, 0x3};
constexpr Guid DIRECTX12_ENGINE{0x0, 0x4};
constexpr Guid OPENGL_ENGINE{0x0, 0x5};
constexpr Guid VULKAN_ENGINE{0x0, 0x6};
constexpr Guid CUDA_DELIVER{0x1, 0x1};
constexpr Guid ROCM_DELIVER{0x1, 0x2};
constexpr Guid PIPE_DELIVER{0x1, 0x3};
constexpr Guid TCP_DELIVER{0x1, 0x4};
constexpr Guid MMAP_DELIVER{0x1, 0x5};
constexpr Guid TINYOBJLOADER_OBJECT_LOADER{0x2, 0x1};
constexpr Guid CGLTF_OBJECT_LOADER{0x2, 0x2};
constexpr Guid ASSIMP_OBJECT_LOADER{0x2, 0x3};
constexpr Guid HOMEBREW_ANIME_LOADER{0x3, 0x1};
#pragma endregion
#pragma region Engine
struct EngineConfig {
bool headless; ///< Whether enable headless mode (No Window created).
std::basic_string<BSCHAR> title; ///< Window title.
std::uint32_t width; ///< Window width.
std::uint32_t height; ///< Window height.
Guid deliver; ///< The GUID of deliver.
};
enum class EngineStatus {
Ready, ///< Engine was allocated but not initialized.
Running, ///< Engine has been initialized and running.
Stop, ///< Engine is shutdown.
};
class IEngine {
public:
IEngine();
virtual ~IEngine();
public:
virtual Guid GetGuid() const;
virtual void Startup(EngineConfig&& config);
/**
* @brief
* @return True for active exit.
*/
virtual bool Tick();
virtual void Shutdown();
protected:
EngineConfig config;
EngineStatus status;
};
#pragma endregion
#pragma region Deliver
struct DeliverConfig {
Guid engine; ///< The GUID of render engine.
};
enum class DeliverStatus {
Ready, ///< Engine was allocated but not initialized.
Running, ///< Engine has been initialized and running.
Stop, ///< Engine is shutdown.
};
class IDeliver {
public:
IDeliver();
virtual ~IDeliver();
public:
virtual Guid GetGuid() const;
virtual void Startup(DeliverConfig&& config);
virtual void Transmit();
virtual void Shutdown();
protected:
DeliverConfig config;
DeliverStatus status;
};
#pragma endregion
} // namespace Basalt::Shared::Kernel

View File

@@ -1,5 +1,82 @@
#include "math.hpp" #include "math.hpp"
#include <stdexcept> // Include for std::out_of_range
namespace Basalt::Shared::Math { namespace Basalt::Shared::Math {
} #pragma region Vector3
FloatPoint& Vector3::operator[](size_t index) {
switch (index) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
default:
throw std::out_of_range("Vector3 index out of range");
}
}
const FloatPoint& Vector3::operator[](size_t index) const {
switch (index) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
default:
throw std::out_of_range("Vector3 index out of range");
}
}
#pragma endregion
#pragma region Vector4
FloatPoint& Vector4::operator[](size_t index) {
switch (index) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
case 3:
return w;
default:
throw std::out_of_range("Vector4 index out of range");
}
}
const FloatPoint& Vector4::operator[](size_t index) const {
switch (index) {
case 0:
return x;
case 1:
return y;
case 2:
return z;
case 3:
return w;
default:
throw std::out_of_range("Vector4 index out of range");
}
}
#pragma endregion
#pragma region Matrix4x4
Vector4& Matrix4x4::operator[](size_t index) {
return data.at(index);
}
const Vector4& Matrix4x4::operator[](size_t index) const {
return data.at(index);
}
#pragma endregion
} // namespace Basalt::Shared::Math

View File

@@ -1,5 +1,6 @@
#pragma once #pragma once
#include <stdexcept> #include <stdexcept>
#include <array> // Include array for std::array::at
namespace Basalt::Shared::Math { namespace Basalt::Shared::Math {
@@ -7,19 +8,26 @@ namespace Basalt::Shared::Math {
struct Vector3 { struct Vector3 {
FloatPoint x, y, z; FloatPoint x, y, z;
};
struct Vector4 { FloatPoint& operator[](size_t index);
FloatPoint x, y, z, w; const FloatPoint& operator[](size_t index) const;
};
struct Matrix4x4 {
Vector4 data[4];
}; };
//template<typename TEle, size_t VCnt> struct Vector4 {
// requires(std::integral<TEle> || std::floating_point<TEle>) FloatPoint x, y, z, w;
//struct Vector {
// TEle factor[VCnt]; FloatPoint& operator[](size_t index);
//}; const FloatPoint& operator[](size_t index) const;
};
struct Matrix4x4 {
private:
std::array<Vector4, 4> data; // Use std::array instead of raw array for .at() method
public:
Vector4& operator[](size_t index);
const Vector4& operator[](size_t index) const;
};
#define NOT_IMPLEMENTED throw std::logic_error("not implemented function"); #define NOT_IMPLEMENTED throw std::logic_error("not implemented function");
@@ -31,4 +39,4 @@ namespace Basalt::Shared::Math {
#undef NOT_IMPLEMENTED #undef NOT_IMPLEMENTED
} // namespace Basalt::Shared::Math } // namespace Basalt::Shared::Math

View File

@@ -0,0 +1,13 @@
#include "object_loader.hpp"
namespace basalt::shared::object_loader {
IObjectLoader::IObjectLoader() {
}
IObjectLoader::~IObjectLoader() {
}
}

View File

@@ -0,0 +1,13 @@
#pragma once
namespace basalt::shared::object_loader {
class IObjectLoader {
public:
IObjectLoader();
virtual ~IObjectLoader();
protected:
};
} // namespace basalt::shared::object_loader

View File

@@ -9,9 +9,9 @@
#include <sys/stat.h> #include <sys/stat.h>
#endif #endif
namespace Basalt::Shared { namespace basalt::shared::pipe_operator {
PipeOperator::PipeOperator(const std::basic_string_view<BSCHAR> name) { PipeOperator::PipeOperator(const char_types::BSStringView& name) {
#if defined(BASALT_OS_WINDOWS) #if defined(BASALT_OS_WINDOWS)
// Create Windows pipe name from given name // Create Windows pipe name from given name
auto fullname = std::format(BSTEXT("\\\\.\\pipe\\{}"), name); auto fullname = std::format(BSTEXT("\\\\.\\pipe\\{}"), name);

View File

@@ -1,13 +1,15 @@
#pragma once #pragma once
#include "char_types.hpp" #include "char_types.hpp"
#include <string>
#include <string_view> #include <string_view>
#if defined(BASALT_OS_WINDOWS) #if defined(BASALT_OS_WINDOWS)
#include <Windows.h> #include <Windows.h>
#else #else
// Nothing was included in POSIX
#endif #endif
namespace Basalt::Shared { namespace basalt::shared::pipe_operator {
class PipeOperator { class PipeOperator {
public: public:
@@ -20,7 +22,7 @@ namespace Basalt::Shared {
#endif #endif
public: public:
PipeOperator(const std::basic_string_view<BSCHAR> name); PipeOperator(const char_types::BSStringView& name);
~PipeOperator(); ~PipeOperator();
// Delete copy ctor // Delete copy ctor
PipeOperator(const PipeOperator&) = delete; PipeOperator(const PipeOperator&) = delete;
@@ -29,10 +31,30 @@ namespace Basalt::Shared {
PipeOperator(PipeOperator&&) noexcept; PipeOperator(PipeOperator&&) noexcept;
PipeOperator& operator=(PipeOperator&& other) noexcept; PipeOperator& operator=(PipeOperator&& other) noexcept;
public:
void Read(void* buffer, size_t size); void Read(void* buffer, size_t size);
void Write(const void* buffer, size_t size); void Write(const void* buffer, size_t size);
template<typename TPod>
void ReadPod(TPod& buffer) {
Read(&buffer, sizeof(TPod));
}
template<typename TPod>
void WritePod(const TPod& buffer) {
Write(&buffer, sizeof(TPod));
}
void ReadString(std::string& buffer) {
size_t length = 0;
ReadPod(length);
buffer.resize(length);
Read(buffer.data(), length);
}
void WriteString(std::string_view& buffer) {
WritePod(buffer.size());
Write(buffer.data(), buffer.size());
}
private: private:
Handle m_Handle; Handle m_Handle;
}; };
} // namespace Basalt::Shared } // namespace basalt::shared::pipe_operator

View File

@@ -14,14 +14,15 @@ Command protocol is tramsmitted by system named pipe.
The name of pipe is `\\.\pipe\ed0e3f1f-d214-4880-9562-640bce15e72e` on Windows The name of pipe is `\\.\pipe\ed0e3f1f-d214-4880-9562-640bce15e72e` on Windows
or `/tmp/ed0e3f1f-d214-4880-9562-640bce15e72e` on POSIX. or `/tmp/ed0e3f1f-d214-4880-9562-640bce15e72e` on POSIX.
|Code|Direction|Comment| |Code|Mnemonic|Direction|Comment|
|:---|:---|:---| |:---|:---|:---|:---|
|`0x61`|Presenter<--Trainer|Handshake code (Are Presenter ready?)| |`0x61`|HANDSHAKE_REQUEST|Presenter<--Trainer|Handshake code (Are Presenter ready?)|
|`0x62`|Presenter-->Trainer|Handshake code (Presenter is ready).| |`0x62`|HANDSHAKE_RESPONSE|Presenter-->Trainer|Handshake code (Presenter is ready).|
|`0x01`|Presenter-->Trainer|Data was ready. Please Trainer receive it.| |`0x01`|DATA_READY|Presenter-->Trainer|Data was ready by Presenter. Trainer please receive it.|
|`0x02`|Presenter<--Trainer|Data has been received. Please go into next loop.| |`0x02`|DATA_RECEIVED|Presenter<--Trainer|Data has been received by Trainer. Please go into next loop.|
|`0x71`|Presenter-->Trainer|Actively Stop (Presenter request stop).| |`0x21`|ACTIVELY_STOP|Presenter-->Trainer|Something was happened in Presenter and it want to stop.|
|`0x71`|Presenter<--Trainer|Stop (Trainer agree the stop request, or trainer actively stop).| |`0x71`|STOP_REQUEST|Presenter<--Trainer|Trainer order Presenter to stop and quit.|
|`0x72`|STOP_RESPONSE|Presenter-->Trainer|Presenster is stopped.|
### Handshake ### Handshake