更新
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
#ifndef CONFIG_H_H
|
||||
#define CONFIG_H_H
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "../DSP/export.h"
|
||||
#include "../Data_Feed/export.h"
|
||||
#include "../Data_Source/export.h"
|
||||
#include "Core/spdlog/export.h"
|
||||
#include "MLAT.h"
|
||||
#include "Source_Feed_Relation.h"
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
inline bool delete_log = false;
|
||||
extern std::string default_config_path;
|
||||
std::string get_config_path();
|
||||
@@ -79,16 +79,15 @@ struct Mode_ACS_Config : Mode_ACS_Config_Base_Data, Mode_ACS_Config_Data {
|
||||
Psc::JSON to_base_json() const {
|
||||
return Mode_ACS_Config_Base_Data::to_base_json();
|
||||
}
|
||||
void init_base_json(const Psc::JSON* that_json) {
|
||||
Mode_ACS_Config_Base_Data::from_base_json(that_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 init(const Psc::JSON* that_json) {
|
||||
Mode_ACS_Config_Base_Data::from_base_json(that_json);
|
||||
Mode_ACS_Config_Data::from_base_json(that_json);
|
||||
data_feed_config.init(that_json->get("data_feed"));
|
||||
data_source_config.init(that_json->get("data_source"));
|
||||
source_feed_relation_config.from_json(
|
||||
that_json->get("source_feed_relation"));
|
||||
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;
|
||||
}
|
||||
@@ -98,8 +97,7 @@ struct Mode_ACS_Config : Mode_ACS_Config_Base_Data, Mode_ACS_Config_Data {
|
||||
ret += Mode_ACS_Config_Data::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()));
|
||||
ret.append(Psc::JSON("source_feed_relation", source_feed_relation_config.to_json()));
|
||||
return ret;
|
||||
}
|
||||
void server(Global* g);
|
||||
@@ -111,17 +109,26 @@ struct Web_Server_Config {
|
||||
PSC_USE_JSON
|
||||
std::string webapp;
|
||||
};
|
||||
struct Map_Tile_Config {
|
||||
std::string file_format = "directory";
|
||||
std::vector<std::string> directories;
|
||||
std::vector<std::string> files;
|
||||
enum class Map_Tile_File_Format { directory, mbtiles, online };
|
||||
enum class Map_Tile_Y_Axis { xyz, tms };
|
||||
enum class Map_Tile_Projection { web_mercator };
|
||||
enum class Map_Tile_Type { imagery, terrain };
|
||||
enum class Map_Tile_Request_Method { GET };
|
||||
enum class Map_Tile_Zoom_Mode { native, upscale, both };
|
||||
struct Map_Tile_Config_Data {
|
||||
Map_Tile_File_Format file_format = Map_Tile_File_Format::directory;
|
||||
std::string path_layout;
|
||||
std::string y_axis;
|
||||
std::string projection;
|
||||
Map_Tile_Y_Axis y_axis = Map_Tile_Y_Axis::xyz;
|
||||
Map_Tile_Projection projection = Map_Tile_Projection::web_mercator;
|
||||
std::string extension;
|
||||
std::uint32_t tile_size{};
|
||||
std::uint32_t minimum_level{};
|
||||
std::uint32_t maximum_level{};
|
||||
PSC_USE_JSON
|
||||
};
|
||||
struct Map_Tile_Config : Map_Tile_Config_Data {
|
||||
std::vector<std::string> directories;
|
||||
std::vector<std::string> files;
|
||||
std::string encoding;
|
||||
[[nodiscard]] std::vector<std::string> get_true_directories() const {
|
||||
std::vector<std::string> ret;
|
||||
@@ -139,31 +146,35 @@ struct Map_Tile_Config {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
void from_base_json(const Psc::JSON* that_json);
|
||||
void from_base_json(const Psc::JSON* that_json, bool not_exist_use_default_value);
|
||||
[[nodiscard]] Psc::JSON to_base_json() const;
|
||||
[[nodiscard]] Psc::JSON to_public_json(std::string_view url) const;
|
||||
};
|
||||
struct Map_Tile_Source_Config {
|
||||
struct Map_Tile_Source_Config_Data {
|
||||
std::string key;
|
||||
std::string name;
|
||||
std::string tile_type = "imagery";
|
||||
std::string request_method = "GET";
|
||||
Map_Tile_Type tile_type = Map_Tile_Type::imagery;
|
||||
Map_Tile_Request_Method request_method = Map_Tile_Request_Method::GET;
|
||||
PSC_USE_JSON
|
||||
};
|
||||
struct Map_Tile_Source_Config : Map_Tile_Source_Config_Data {
|
||||
std::string url;
|
||||
Map_Tile_Config resource;
|
||||
[[nodiscard]] bool local() const {
|
||||
return resource.file_format != "online";
|
||||
return resource.file_format != Map_Tile_File_Format::online;
|
||||
}
|
||||
void from_base_json(const Psc::JSON* that_json);
|
||||
void from_base_json(const Psc::JSON* that_json, bool not_exist_use_default_value);
|
||||
[[nodiscard]] Psc::JSON to_base_json() const;
|
||||
[[nodiscard]] Psc::JSON to_public_json(std::string_view local_url) const;
|
||||
};
|
||||
struct Map_Resources_Config {
|
||||
std::string current_imagery_key = "imagery";
|
||||
std::vector<Map_Tile_Source_Config> tile_sources;
|
||||
void from_base_json(const Psc::JSON* that_json);
|
||||
void from_base_json(const Psc::JSON* that_json, bool not_exist_use_default_value);
|
||||
[[nodiscard]] Psc::JSON to_base_json() const;
|
||||
[[nodiscard]] Psc::JSON to_public_json() const;
|
||||
[[nodiscard]] bool is_imagery_key(std::string_view key) const;
|
||||
[[nodiscard]] bool is_terrain_key(std::string_view key) const;
|
||||
};
|
||||
struct Map_Camera_Config {
|
||||
double longitude = 121.27;
|
||||
@@ -172,16 +183,15 @@ struct Map_Camera_Config {
|
||||
double heading = 0.0;
|
||||
double pitch = -90.0;
|
||||
double roll = 0.0;
|
||||
void from_base_json(const Psc::JSON* that_json);
|
||||
[[nodiscard]] Psc::JSON to_base_json() const;
|
||||
PSC_USE_JSON
|
||||
};
|
||||
struct Map_Tile_View_Config {
|
||||
std::string current_imagery_key = "imagery";
|
||||
std::string tile_zoom_mode = "native";
|
||||
std::string current_terrain_key = "terrain";
|
||||
Map_Tile_Zoom_Mode tile_zoom_mode = Map_Tile_Zoom_Mode::native;
|
||||
std::uint32_t tile_display_maximum_level = 19;
|
||||
void from_base_json(const Psc::JSON* that_json);
|
||||
void from_base_json(const Psc::JSON* that_json, bool not_exist_use_default_value);
|
||||
[[nodiscard]] Psc::JSON to_base_json() const;
|
||||
[[nodiscard]] static bool is_tile_zoom_mode(std::string_view mode);
|
||||
};
|
||||
struct Map_View_Config {
|
||||
std::string scene_mode = "3d";
|
||||
@@ -189,11 +199,11 @@ struct Map_View_Config {
|
||||
Map_Tile_View_Config map3d;
|
||||
Map_Camera_Config camera;
|
||||
double base_station_fly_to_height_offset_meters = 8000.0;
|
||||
void from_base_json(const Psc::JSON* that_json);
|
||||
void from_base_json(const Psc::JSON* that_json, bool not_exist_use_default_value);
|
||||
[[nodiscard]] Psc::JSON to_base_json() const;
|
||||
[[nodiscard]] static bool is_scene_mode(std::string_view mode);
|
||||
};
|
||||
struct Cesium_Graphics_Config {
|
||||
struct Cesium_Graphics_Config_Data {
|
||||
bool debug_show_frames_per_second = true;
|
||||
std::uint32_t target_frame_rate = 30;
|
||||
bool use_browser_recommended_resolution = true;
|
||||
@@ -220,7 +230,10 @@ struct Cesium_Graphics_Config {
|
||||
double view_axes_panel_size = 84.0;
|
||||
double occlusion_sample_spacing_meters = 250.0;
|
||||
double occlusion_clearance_margin_meters = 10.0;
|
||||
void from_base_json(const Psc::JSON* that_json);
|
||||
PSC_USE_JSON
|
||||
};
|
||||
struct Cesium_Graphics_Config : Cesium_Graphics_Config_Data {
|
||||
void from_base_json(const Psc::JSON* that_json, bool not_exist_use_default_value);
|
||||
[[nodiscard]] Psc::JSON to_base_json() const;
|
||||
};
|
||||
struct Map_Model_Item_Config {
|
||||
@@ -232,7 +245,7 @@ struct Map_Model_Item_Config {
|
||||
Map_Model_Item_Config() = default;
|
||||
explicit Map_Model_Item_Config(std::string url);
|
||||
Map_Model_Item_Config(std::string url, double built_in_size, double heading, double pitch, double roll);
|
||||
void from_base_json(const Psc::JSON* that_json);
|
||||
void from_base_json(const Psc::JSON* that_json, bool not_exist_use_default_value);
|
||||
[[nodiscard]] Psc::JSON to_base_json() const;
|
||||
};
|
||||
struct Map_Model_Config {
|
||||
@@ -241,7 +254,7 @@ struct Map_Model_Config {
|
||||
Map_Model_Item_Config base_station_model{"/ui/model/base-station.glb", 16.635522, 0.0, 0.0, 0.0};
|
||||
Map_Model_Item_Config device_model{"/ui/model/device.glb", 80.0, 0.0, 0.0, 0.0};
|
||||
Map_Model_Config();
|
||||
void from_base_json(const Psc::JSON* that_json);
|
||||
void from_base_json(const Psc::JSON* that_json, bool not_exist_use_default_value);
|
||||
[[nodiscard]] Psc::JSON to_base_json() const;
|
||||
};
|
||||
struct Net_Config {
|
||||
@@ -272,10 +285,10 @@ struct Device_Config {
|
||||
return ret;
|
||||
}
|
||||
Device_Config() = default;
|
||||
void init(const Psc::JSON* that_json) {
|
||||
void from_json(const Psc::JSON* that_json, bool not_exist_use_default_value) {
|
||||
for (auto& li : that_json->get("net")->children) {
|
||||
auto cur = new Net_Config();
|
||||
cur->from_base_json(&li);
|
||||
cur->from_base_json(&li, not_exist_use_default_value);
|
||||
list.push_back(cur);
|
||||
}
|
||||
}
|
||||
@@ -317,8 +330,7 @@ public:
|
||||
Psc::fail_fast();
|
||||
}
|
||||
else {
|
||||
std::cout << get_current_date_string() << " 启动加载配置文件: 【"
|
||||
<< config_path << "】" << std::endl;
|
||||
std::cout << get_current_date_string() << " 启动加载配置文件: 【" << config_path << "】" << std::endl;
|
||||
}
|
||||
std::stringstream ss;
|
||||
std::stringstream buffer;
|
||||
@@ -326,40 +338,39 @@ public:
|
||||
std::string fileContents = buffer.str();
|
||||
return Psc::parse_json(fileContents);
|
||||
}
|
||||
void fromJson(Psc::JSON* that_json) {
|
||||
Get_J(version)
|
||||
mlat.init(that_json->get("mlat"));
|
||||
web_server_config.from_base_json(that_json->get("web_server"));
|
||||
map_resources_config.from_base_json(that_json->get("map_resources"));
|
||||
map_view_config.from_base_json(that_json->get("map_view"));
|
||||
cesium_graphics_config.from_base_json(that_json->get("cesium_graphics"));
|
||||
map_model_config.from_base_json(that_json->get("map_models"));
|
||||
device_config.init(that_json->get("device"));
|
||||
mode_acs.init(that_json->get("mode_acs"));
|
||||
console_config.from_base_json(that_json->get("console"));
|
||||
dsp_config.from_json(that_json->get("dsp"));
|
||||
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);
|
||||
map_resources_config.from_base_json(that_json->get("map_resources"), not_exist_use_default_value);
|
||||
map_view_config.from_base_json(that_json->get("map_view"), not_exist_use_default_value);
|
||||
cesium_graphics_config.from_base_json(that_json->get("cesium_graphics"), not_exist_use_default_value);
|
||||
map_model_config.from_base_json(that_json->get("map_models"), not_exist_use_default_value);
|
||||
device_config.from_json(that_json->get("device"), not_exist_use_default_value);
|
||||
mode_acs.from_json(that_json->get("mode_acs"), not_exist_use_default_value);
|
||||
console_config.from_base_json(that_json->get("console"), not_exist_use_default_value);
|
||||
dsp_config.from_json(that_json->get("dsp"), not_exist_use_default_value);
|
||||
drogon_config = *that_json->get("drogon");
|
||||
http_monitor_config.from_base_json(that_json->get("http_monitor"));
|
||||
external_resources_manager.init(that_json->get("external_database"));
|
||||
http_monitor_config.from_base_json(that_json->get("http_monitor"), not_exist_use_default_value);
|
||||
external_resources_manager.from_json(that_json->get("external_database"), not_exist_use_default_value);
|
||||
}
|
||||
Psc::JSON toJson() {
|
||||
auto ret = Psc::JSON::object({
|
||||
{"version", version},
|
||||
{"dsp", dsp_config.to_base_json()},
|
||||
{"drogon", drogon_config},
|
||||
{"http_monitor", http_monitor_config.to_base_json()},
|
||||
{"mlat", mlat.to_base_json()},
|
||||
{"web_server", web_server_config.to_base_json()},
|
||||
{"map_resources", map_resources_config.to_base_json()},
|
||||
{"map_view", map_view_config.to_base_json()},
|
||||
{"map_models", map_model_config.to_base_json()},
|
||||
{"device", device_config.to_base_json()},
|
||||
{"mode_acs", mode_acs.to_base_json()},
|
||||
//{"ais", ais.to_json()},
|
||||
{"log", log_config.to_base_json()},
|
||||
{"console", console_config.to_base_json()},
|
||||
{"external_database", external_resources_manager.to_base_json()},
|
||||
{"cesium_graphics", cesium_graphics_config.to_base_json()},
|
||||
{"version", version},
|
||||
{"dsp", dsp_config.to_base_json()},
|
||||
{"drogon", drogon_config},
|
||||
{"http_monitor", http_monitor_config.to_base_json()},
|
||||
{"mlat", mlat.to_base_json()},
|
||||
{"web_server", web_server_config.to_base_json()},
|
||||
{"map_resources", map_resources_config.to_base_json()},
|
||||
{"map_view", map_view_config.to_base_json()},
|
||||
{"map_models", map_model_config.to_base_json()},
|
||||
{"device", device_config.to_base_json()},
|
||||
{"mode_acs", mode_acs.to_base_json()},
|
||||
//{"ais", ais.to_json()},
|
||||
{"log", log_config.to_base_json()},
|
||||
{"console", console_config.to_base_json()},
|
||||
{"external_database", external_resources_manager.to_base_json()},
|
||||
{"cesium_graphics", cesium_graphics_config.to_base_json()},
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user