初步修改

This commit is contained in:
2026-08-09 14:13:35 +08:00
parent 1e1e77e41a
commit 6fe0bed78e
26 changed files with 2007 additions and 681 deletions
+146 -59
View File
@@ -9,9 +9,29 @@
#include "MLAT.h"
#include "Psc_Cpp_Core/spdlog/export.h"
#include "Source_Feed_Relation.h"
#include "adminive/json.hpp"
#include "adminive/managed.hpp"
inline bool delete_log = false;
extern std::string default_config_path;
std::string get_config_path();
extern std::string default_config_directory;
std::string get_config_directory();
enum class Config_Section {
version,
dsp,
drogon,
http_monitor,
mlat,
web_server,
map_resources,
map_view,
map_models,
device,
mode_acs,
log,
console,
external_database,
cesium_graphics,
count
};
struct Log_Config {
~Log_Config() {
if (delete_log)
@@ -40,66 +60,85 @@ struct Http_Monitor_Config {
std::size_t slow_scope_threshold_ms = 100;
PSC_USE_JSON
};
struct Mode_ACS_Config_Base_Data {
Psc::Copyable_Atomic<std::size_t> timeout_seconds{};
struct Mode_ACS_Config_Data {
std::size_t timeout_seconds{};
SSR::CPR::D max_speed_m_s{};
SSR::CPR::D air_pos_timeout = 8;
SSR::CPR::D surface_pos_timeout = 32;
Psc::Copyable_Atomic<std::size_t> read_milliseconds{};
std::size_t read_milliseconds{};
bool wait_process_msg{};
bool time_space_filter{};
bool speed_filter{};
std::size_t max_track_point_size{};
std::size_t mode_s_max_num{};
std::size_t mode_other_max_num{};
std::size_t report_data_feed_msg_mum{};
std::size_t default_min_aircraft_list_num{};
std::size_t aircraft_change_list_min_position_points = 2;
bool aircraft_change_list_adsb_range_filter = true;
double aircraft_change_list_adsb_range_factor = 1.2;
double adsb_theoretical_target_altitude_meters = 10000.0;
bool ignore_df_11{};
bool monitor_msg_live{};
PSC_USE_JSON
};
struct Mode_ACS_Config_Data {
Psc::Copyable_Atomic<bool> wait_process_msg;
Psc::Copyable_Atomic<bool> time_space_filter;
Psc::Copyable_Atomic<bool> speed_filter;
Psc::Copyable_Atomic<std::size_t> max_track_point_size{};
Psc::Copyable_Atomic<std::size_t> mode_s_max_num{};
Psc::Copyable_Atomic<std::size_t> mode_other_max_num{};
Psc::Copyable_Atomic<std::size_t> report_data_feed_msg_mum{};
Psc::Copyable_Atomic<std::size_t> default_min_aircraft_list_num{};
Psc::Copyable_Atomic<std::size_t> aircraft_change_list_min_position_points = 2;
Psc::Copyable_Atomic<bool> aircraft_change_list_adsb_range_filter = true;
Psc::Copyable_Atomic<double> aircraft_change_list_adsb_range_factor = 1.2;
Psc::Copyable_Atomic<double> adsb_theoretical_target_altitude_meters = 10000.0;
Psc::Copyable_Atomic<bool> ignore_df_11{};
Psc::Copyable_Atomic<bool> monitor_msg_live{};
PSC_USE_JSON
namespace adminive {
template <>
struct Type_Descriptor<Mode_ACS_Config_Data> {
static auto get() {
using T = Mode_ACS_Config_Data;
return object<T>("mode_acs_config", "Mode ACS 基础配置",
ADMINIVE_FIELD_LABEL(T, timeout_seconds, "目标超时时间(秒)").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, max_speed_m_s, "飞机最大速度(m/s").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, air_pos_timeout, "空中 CPR 超时(秒)").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, surface_pos_timeout, "地面 CPR 超时(秒)").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, read_milliseconds, "读取数据源延时(毫秒)").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, wait_process_msg, "等待处理消息").editable().boolean_input(),
ADMINIVE_FIELD_LABEL(T, time_space_filter, "时空过滤").editable().boolean_input(),
ADMINIVE_FIELD_LABEL(T, speed_filter, "速度过滤").editable().boolean_input(),
ADMINIVE_FIELD_LABEL(T, max_track_point_size, "最大航迹点数量").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, mode_s_max_num, "Mode S 最大数量").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, mode_other_max_num, "其他 Mode 最大数量").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, report_data_feed_msg_mum, "数据馈送消息上报数量").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, default_min_aircraft_list_num, "默认最小飞机列表数量").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, aircraft_change_list_min_position_points, "飞机变化列表最少位置点").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, aircraft_change_list_adsb_range_filter, "基站理论范围过滤").editable().boolean_input(),
ADMINIVE_FIELD_LABEL(T, aircraft_change_list_adsb_range_factor, "范围过滤系数").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, adsb_theoretical_target_altitude_meters, "理论目标高度(米)").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, ignore_df_11, "忽略 DF11").editable().boolean_input(),
ADMINIVE_FIELD_LABEL(T, monitor_msg_live, "监控 Mode ACS 消息").editable().boolean_input());
}
};
struct Mode_ACS_Config : Mode_ACS_Config_Base_Data, Mode_ACS_Config_Data {
DELETE_COPY(Mode_ACS_Config)
}
struct Mode_ACS_Config {
adminive::Managed_Value<Mode_ACS_Config_Data> settings;
Data_feed_Config data_feed_config;
Data_Source_Config data_source_config;
Source_Feed_Relation_Config source_feed_relation_config;
Psc::Copyable_Atomic<std::size_t> Report_Data_Feed_Message_Num{};
std::size_t Report_Data_Feed_Message_Num{};
Mode_ACS_Config() = default;
~Mode_ACS_Config() {
if (delete_log)
std::cout << " ~Mode_S_Config()" << std::endl;
}
Psc::JSON to_base_json() const {
return Mode_ACS_Config_Base_Data::to_base_json();
}
void init_base_json(const Psc::JSON* that_json, bool not_exist_use_default_value) {
Mode_ACS_Config_Base_Data::from_base_json(that_json, not_exist_use_default_value);
}
void from_json(const Psc::JSON* that_json, bool not_exist_use_default_value) {
Mode_ACS_Config_Base_Data::from_base_json(that_json, not_exist_use_default_value);
Mode_ACS_Config_Data::from_base_json(that_json, not_exist_use_default_value);
data_feed_config.init(that_json->get("data_feed"), not_exist_use_default_value);
data_source_config.init(that_json->get("data_source"), not_exist_use_default_value);
source_feed_relation_config.from_json(that_json->get("source_feed_relation"), not_exist_use_default_value);
if (monitor_msg_live) {
SSR::Monitor_Mode_ACS_Message_Num = this->monitor_msg_live;
}
}
Psc::JSON to_base_json() {
Psc::JSON ret = Mode_ACS_Config_Base_Data::to_base_json();
ret += Mode_ACS_Config_Data::to_base_json();
auto ret = settings.snapshot().to_base_json();
ret.append(Psc::JSON("data_feed", data_feed_config.to_json()));
ret.append(Psc::JSON("data_source", data_source_config.to_json()));
ret.append(Psc::JSON("source_feed_relation", source_feed_relation_config.to_json()));
return ret;
}
void from_json(const Psc::JSON* that_json, bool not_exist_use_default_value) {
auto value = settings.snapshot();
value.from_base_json(that_json, not_exist_use_default_value);
settings.write([&](auto& target) {
target = value;
});
data_feed_config.init(that_json->get("data_feed"), not_exist_use_default_value);
data_source_config.init(that_json->get("data_source"), not_exist_use_default_value);
source_feed_relation_config.from_json(that_json->get("source_feed_relation"), not_exist_use_default_value);
SSR::Monitor_Mode_ACS_Message_Num = value.monitor_msg_live;
}
void server(Global* g);
};
struct Web_Server_Config {
@@ -232,7 +271,67 @@ struct Cesium_Graphics_Config_Data {
double occlusion_clearance_margin_meters = 10.0;
PSC_USE_JSON
};
struct Cesium_Graphics_Config : Cesium_Graphics_Config_Data {
namespace adminive {
template <>
struct Type_Descriptor<Cesium_Graphics_Config_Data> {
static auto get() {
using T = Cesium_Graphics_Config_Data;
auto descriptor = object<T>("cesium_graphics_config", "Cesium 图形配置",
ADMINIVE_FIELD_LABEL(T, debug_show_frames_per_second, "显示帧率").editable().boolean_input(),
ADMINIVE_FIELD_LABEL(T, target_frame_rate, "目标帧率").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, use_browser_recommended_resolution, "使用浏览器推荐分辨率").editable().boolean_input(),
ADMINIVE_FIELD_LABEL(T, resolution_scale, "分辨率缩放").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, msaa_samples, "MSAA 采样数").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, fxaa, "启用 FXAA").editable().boolean_input(),
ADMINIVE_FIELD_LABEL(T, shadows, "启用阴影").editable().boolean_input(),
ADMINIVE_FIELD_LABEL(T, enable_lighting, "启用光照").editable().boolean_input(),
ADMINIVE_FIELD_LABEL(T, solar_lighting, "启用太阳光照").editable().boolean_input(),
ADMINIVE_FIELD_LABEL(T, solar_light_intensity, "太阳光强度").editable().required().number_input().visible_on("${$self.solar_lighting}"),
ADMINIVE_FIELD_LABEL(T, maximum_screen_space_error, "最大屏幕空间误差").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, terrain_enabled_in_3d, "3D 启用地形").editable().boolean_input(),
ADMINIVE_FIELD_LABEL(T, terrain_exaggeration, "地形夸张系数").editable().required().number_input().visible_on("${$self.terrain_enabled_in_3d}"),
ADMINIVE_FIELD_LABEL(T, terrain_limit_maximum_level, "限制地形最大层级").editable().boolean_input().visible_on("${$self.terrain_enabled_in_3d}"),
ADMINIVE_FIELD_LABEL(T, terrain_maximum_level, "地形最大层级").editable().required().number_input().visible_on("${$self.terrain_enabled_in_3d && $self.terrain_limit_maximum_level}"),
ADMINIVE_FIELD_LABEL(T, terrain_cache_tiles, "地形缓存瓦片数").editable().required().number_input().visible_on("${$self.terrain_enabled_in_3d}"),
ADMINIVE_FIELD_LABEL(T, terrain_occlusion_enabled, "启用地形遮挡").editable().boolean_input().visible_on("${$self.terrain_enabled_in_3d}"),
ADMINIVE_FIELD_LABEL(T, surface_navigation_reference_visible, "显示地表导航参考").editable().boolean_input(),
ADMINIVE_FIELD_LABEL(T, view_axes_visible, "显示视图坐标轴").editable().boolean_input(),
ADMINIVE_FIELD_LABEL(T, performance_panel_x, "性能面板 X").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, performance_panel_y, "性能面板 Y").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, view_axes_panel_x, "坐标轴面板 X").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, view_axes_panel_y, "坐标轴面板 Y").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, view_axes_panel_size, "坐标轴面板尺寸").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, occlusion_sample_spacing_meters, "遮挡采样间距(米)").editable().required().number_input(),
ADMINIVE_FIELD_LABEL(T, occlusion_clearance_margin_meters, "遮挡净空余量(米)").editable().required().number_input());
return descriptor.validator([](const T& value, Validation_Context& validation) {
if (value.target_frame_rate < 1 || value.target_frame_rate > 120)
validation.error("target_frame_rate", "必须在 1 到 120 之间");
if (value.resolution_scale < 0.2 || value.resolution_scale > 1.5)
validation.error("resolution_scale", "必须在 0.2 到 1.5 之间");
if (value.msaa_samples < 1 || value.msaa_samples > 8)
validation.error("msaa_samples", "必须在 1 到 8 之间");
if (value.maximum_screen_space_error < 1 || value.maximum_screen_space_error > 16)
validation.error("maximum_screen_space_error", "必须在 1 到 16 之间");
if (value.terrain_maximum_level > 24)
validation.error("terrain_maximum_level", "不能大于 24");
if (value.terrain_cache_tiles < 16 || value.terrain_cache_tiles > 2048)
validation.error("terrain_cache_tiles", "必须在 16 到 2048 之间");
if (value.performance_panel_x < 0)
validation.error("performance_panel_x", "不能小于 0");
if (value.performance_panel_y < 0)
validation.error("performance_panel_y", "不能小于 0");
if (value.view_axes_panel_y < 0)
validation.error("view_axes_panel_y", "不能小于 0");
if (value.view_axes_panel_size < 48 || value.view_axes_panel_size > 240)
validation.error("view_axes_panel_size", "必须在 48 到 240 之间");
if (value.occlusion_sample_spacing_meters < 10 || value.occlusion_sample_spacing_meters > 5000)
validation.error("occlusion_sample_spacing_meters", "必须在 10 到 5000 之间");
});
}
};
}
struct Cesium_Graphics_Config {
adminive::Managed_Value<Cesium_Graphics_Config_Data> settings;
void from_base_json(const Psc::JSON* that_json, bool not_exist_use_default_value);
[[nodiscard]] Psc::JSON to_base_json() const;
};
@@ -322,22 +421,7 @@ public:
Http_Monitor_Config http_monitor_config;
std::string version;
External_Resources_Manager external_resources_manager;
static Psc::JSON load() {
std::string config_path = get_config_path();
std::ifstream iso(config_path);
if (!iso.is_open()) {
std::cerr << config_path << " can not open!" << std::endl;
Psc::fail_fast();
}
else {
std::cout << get_current_date_string() << " 启动加载配置文件: 【" << config_path << "" << std::endl;
}
std::stringstream ss;
std::stringstream buffer;
buffer << iso.rdbuf();
std::string fileContents = buffer.str();
return Psc::parse_json(fileContents);
}
static Psc::JSON load();
void from_base_json(Psc::JSON* that_json, bool not_exist_use_default_value) {
Get_J(version) mlat.from_json(that_json->get("mlat"), not_exist_use_default_value);
web_server_config.from_base_json(that_json->get("web_server"), not_exist_use_default_value);
@@ -375,5 +459,8 @@ public:
return ret;
}
static void save();
static void save(Config_Section section);
static void save(Config_Section section, const Psc::JSON& value);
static void merge(Config_Section section, const Psc::JSON& value);
};
#endif