Files
ECAP_Server/module/Local_Server/DSP/DSP_Config.h
T
2026-06-26 09:36:14 +08:00

108 lines
2.8 KiB
C++

#ifndef PLANTSUNCAT_DSP2_H
#define PLANTSUNCAT_DSP2_H
#include "../server/WebSocket_Manager.h"
#include "global.h"
class Global;
#define USE_PROCESS 0
#ifdef USE_PROCESS
#include "../../../../../core_library/Core/Core/Shared_Memory/Shared_Memory.h"
#endif
// #ifdef WIN32
// #define USE_PROCESS 1
// #endif
// #define USE_PROCESS 1
enum Demod_Mode { LSB, USB, AM, FM };
extern BaseLogger *dsp_logger;
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);
Get_J(band_width);
Get_J(sample_rate);
Get_J(fft_point_number);
Get_J(power_min);
Get_J(power_max);
Get_J(power_offset);
Get_J(demod_mode);
Get_J(audio_gain);
Get_J(color_gain);
}
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_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;
std::lock_guard lock(m);
std::swap(empty, data);
return empty;
}
void push(void *pdata, uint64_t length) {
std::lock_guard lock(m);
data.emplace_back((char *)pdata, length);
}
protected:
std::vector<std::string> data;
Psc::Spin_Lock m;
};
#if USE_PROCESS
void adsb_set_less_30Mhz_ddc_param(double center_freq, double sample_rate,
double band_width, int sw);
void adsb_set_less_30Mhz_fft_param(UHD_FFTWin fft_win_type,
size_t fft_point_number,
size_t fft_period_ms, int sw);
Psc::SM_Block_RingBuffer json_func_call =
Psc::SM_Block_RingBuffer("json_func_call2", 1000);
Psc::SM_Block_RingBuffer rb = Psc::SM_Block_RingBuffer("rb", 2112 * 1000);
Psc::Pure_Share_Memory psm = Psc::Pure_Share_Memory("fft_data", 65536);
void restart_device();
#else
void server(Global *g);
std::shared_ptr<WebSocket_Manager> ws_fft;
std::shared_ptr<WebSocket_Manager> ws_iq;
Memory_Buffer iq_memory_buffer;
std::vector<std::uint8_t> fft_data;
std::mutex fft_mtx;
void *lib{};
#endif
};
#endif