使用boost pfr 遍历结构体

This commit is contained in:
2026-06-26 09:36:14 +08:00
parent 26b5c8a54d
commit 472e609f13
17 changed files with 1322 additions and 1622 deletions
+2 -2
View File
@@ -66,10 +66,10 @@ void DSP_Config::server(Global *g) {
#endif
set_fft_point_number(this->fft_point_number);
g->save();
res->setBody(warp(to_json()).to_json_string());
res->setBody(warp(to_base_json()).to_json_string());
});
svr.Post(api + "get_dsp_config", [this](HTTP_Param) {
res->setBody(warp(to_json()).to_json_string());
res->setBody(warp(to_base_json()).to_json_string());
});
drogon::app().registerHandler(
+24 -38
View File
@@ -18,21 +18,27 @@ class Global;
enum Demod_Mode { LSB, USB, AM, FM };
extern BaseLogger *dsp_logger;
struct DSP_Config : Base_DSP {
std::string url;
std::uint16_t port{};
std::int64_t power_min;
std::int64_t power_max;
std::int64_t power_offset;
std::uint64_t frame_rate;
bool debug;
Demod_Mode demod_mode;
std::int64_t audio_gain;
std::int64_t color_gain;
class DSP_Config_Data {
public:
std::string url;
std::uint16_t port{};
std::int64_t power_min;
std::int64_t power_max;
std::int64_t power_offset;
std::uint64_t frame_rate;
bool debug;
Demod_Mode demod_mode;
std::int64_t audio_gain;
std::int64_t color_gain;
PSC_USE_JSON
};
class DSP_Config : public Base_DSP, public DSP_Config_Data{
public:
~DSP_Config();
void close_dsp_device() const;
void init_update(const Psc::JSON *that_json) {
Get_J(port);
Get_J(center_freq);
@@ -46,36 +52,16 @@ struct DSP_Config : Base_DSP {
Get_J(audio_gain);
Get_J(color_gain);
}
void init(const Psc::JSON *that_json) {
init_update(that_json);
Get_J(url);
Get_J(fft_period_ms);
Get_J(fft_win_type);
Get_J(debug);
Get_J(frame_rate);
Get_J(library_path);
void from_json(const Psc::JSON *that_json) {
Base_DSP::from_base_json(that_json);
DSP_Config_Data::from_base_json(that_json);
}
Psc::JSON to_json() const {
Psc::JSON ret = Base_DSP::to_json();
Ret_J(url);
Ret_J(port);
Ret_J(power_min);
Ret_J(power_max);
Ret_J(power_offset);
Ret_J(frame_rate);
Ret_J(debug);
Ret_J(demod_mode);
Ret_J(audio_gain);
Ret_J(color_gain);
return ret;
Psc::JSON to_base_json() const {
return Base_DSP::to_base_json() += DSP_Config_Data::to_base_json();
}
void init_env();
void set_fft_point_number(uint64_t fft_point_number, bool force = false);
std::atomic<bool> record_iq_stream_ing = false;
struct Memory_Buffer {
std::vector<std::string> get_all() {
std::vector<std::string> empty;
+4 -22
View File
@@ -3,32 +3,14 @@
#include "Core/Base/JSON.h"
#include "Core/spdlog/export.h"
struct Base_DSP {
class Base_DSP {
public:
std::string library_path;
std::uint64_t center_freq{};
std::uint64_t band_width{};
std::uint64_t sample_rate{};
std::atomic<std::uint64_t> fft_point_number = 1024;
Psc::Copyable_Atomic<std::uint64_t> fft_point_number = 1024;
int fft_period_ms;
UHD_FFTWin fft_win_type;
[[nodiscard]] Psc::JSON to_json() const {
Psc::JSON ret = Psc::JSON::object();
Ret_J(library_path);
Ret_J(center_freq);
Ret_J(band_width);
Ret_J(sample_rate);
Ret_J(fft_point_number);
Ret_J(fft_period_ms);
Ret_J(fft_win_type);
return ret;
}
void load(Psc::JSON *that_json) {
Get_J(library_path);
Get_J(center_freq);
Get_J(band_width);
Get_J(sample_rate);
Get_J(fft_point_number);
Get_J(fft_period_ms);
Get_J(fft_win_type);
}
PSC_USE_JSON
};