构建时间版本号
This commit is contained in:
@@ -95,8 +95,6 @@ void assign_config_section(Config_Section section, Function&& function) {
|
||||
}
|
||||
Psc::JSON config_section_value(Global& global, Config_Section section) {
|
||||
switch (section) {
|
||||
case Config_Section::version:
|
||||
return Psc::JSON(global.version);
|
||||
case Config_Section::dsp:
|
||||
return global.dsp_config.to_base_json();
|
||||
case Config_Section::drogon:
|
||||
@@ -236,10 +234,13 @@ void Mode_ACS_Config::from_json(const Psc::JSON* that_json) {
|
||||
migrate_legacy_source_feed_relations(that_json, data_source_config, data_feed_config);
|
||||
data_topology_view.write([&](auto& value) { value.from_json(that_json->get("data_topology_view")); });
|
||||
}
|
||||
Config::Config() : version(get_ecap_build_version()) {
|
||||
}
|
||||
void Config::create_missing_config_files() {
|
||||
std::filesystem::create_directories(config_directory());
|
||||
std::error_code ignored_error;
|
||||
std::filesystem::remove(config_directory() / "device.json", ignored_error);
|
||||
std::filesystem::remove(config_directory() / "version.json", ignored_error);
|
||||
for (std::size_t index = 0; index < static_cast<std::size_t>(Config_Section::count); ++index) {
|
||||
const auto section = static_cast<Config_Section>(index);
|
||||
if (std::filesystem::exists(config_section_path(section)))
|
||||
@@ -270,7 +271,6 @@ void Config::from_log_json(const Psc::JSON* that_json) {
|
||||
assign_config_section(Config_Section::log, [&] { log_config.from_base_json(that_json); });
|
||||
}
|
||||
void Config::from_base_json(Psc::JSON* that_json) {
|
||||
assign_config_section(Config_Section::version, [&] { Get_J(version) });
|
||||
assign_config_section(Config_Section::mlat, [&] { mlat.from_json(that_json->get("mlat")); });
|
||||
assign_config_section(Config_Section::web_server,
|
||||
[&] { web_server_config.from_base_json(that_json->get("web_server")); });
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
#include "../Build_Version_Api.h"
|
||||
#include "../DSP/export.h"
|
||||
#include "../Data_Feed/export.h"
|
||||
#include "../Data_Source/export.h"
|
||||
@@ -15,7 +16,6 @@
|
||||
inline bool delete_log = false;
|
||||
extern std::string default_config_directory;
|
||||
#define ECAP_CONFIG_SECTION_LIST(X) \
|
||||
X(version) \
|
||||
X(dsp) \
|
||||
X(drogon) \
|
||||
X(http_monitor) \
|
||||
@@ -488,7 +488,7 @@ struct Type_Descriptor<Map_Model_Config> {
|
||||
}
|
||||
class Config {
|
||||
public:
|
||||
Config() = default;
|
||||
Config();
|
||||
DELETE_COPY(Config)
|
||||
MLAT_Config mlat;
|
||||
Web_Server_Config web_server_config;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#include "Config_Default.h"
|
||||
Default_Config_File make_default_config_file(Config_Section section, const std::filesystem::path& directory) {
|
||||
switch (section) {
|
||||
case Config_Section::version:
|
||||
return make_default_version_config(directory);
|
||||
case Config_Section::dsp:
|
||||
return make_default_dsp_config(directory);
|
||||
case Config_Section::drogon:
|
||||
|
||||
@@ -7,7 +7,6 @@ struct Default_Config_File {
|
||||
Psc::JSON value;
|
||||
};
|
||||
Default_Config_File make_default_config_file(Config_Section section, const std::filesystem::path& directory);
|
||||
Default_Config_File make_default_version_config(const std::filesystem::path& directory);
|
||||
Default_Config_File make_default_dsp_config(const std::filesystem::path& directory);
|
||||
Default_Config_File make_default_drogon_config(const std::filesystem::path& directory);
|
||||
Default_Config_File make_default_http_monitor_config(const std::filesystem::path& directory);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include <string_view>
|
||||
namespace config_default {
|
||||
#if defined(ECAP_TARGET_WINDOWS)
|
||||
inline constexpr std::string_view dsp_library_path = "@/dll_source.dll";
|
||||
inline constexpr std::string_view webapp_path = "@/../third_party/eacp_webapp/wwwroot";
|
||||
inline constexpr std::string_view tile_directory = "C:/tiles";
|
||||
inline constexpr std::string_view file_source_path = "D:/ae/proj/projects/ECAP_Server/data/BIN_Blank_Text/ADS-B_195_0205.txt";
|
||||
inline constexpr std::string_view sqlite_path = "@/../data/sqlite/ecap.sqlite";
|
||||
#elif defined(ECAP_TARGET_LINUX)
|
||||
inline constexpr std::string_view dsp_library_path = "@/lib9002/lib9002.so";
|
||||
inline constexpr std::string_view webapp_path = "@/wwwroot";
|
||||
inline constexpr std::string_view tile_directory = "/home/heco/tiles";
|
||||
inline constexpr std::string_view sqlite_path = "@/../ecap.sqlite";
|
||||
#else
|
||||
#error Unsupported ecap_server target platform
|
||||
#endif
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "Config_Default.h"
|
||||
#include "Target_Defaults.h"
|
||||
Default_Config_File make_default_dsp_config(const std::filesystem::path& directory) {
|
||||
DSP_Config config;
|
||||
config.library_path = ECAP_DEFAULT_DSP_LIBRARY_PATH;
|
||||
config.library_path = config_default::dsp_library_path;
|
||||
config.center_freq = 16000000;
|
||||
config.band_width = 6000;
|
||||
config.sample_rate = 60000;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "Config_Default.h"
|
||||
#include "Target_Defaults.h"
|
||||
namespace {
|
||||
Psc::JSON make_resource(std::string name, std::string download_url, std::string description,
|
||||
std::uint64_t update_interval_seconds, std::time_t last_updated_at) {
|
||||
@@ -10,10 +11,10 @@ Psc::JSON make_resource(std::string name, std::string download_url, std::string
|
||||
resource.last_updated_at = last_updated_at;
|
||||
return resource.to_base_json();
|
||||
}
|
||||
} // namespace
|
||||
}
|
||||
Default_Config_File make_default_external_database_config(const std::filesystem::path& directory) {
|
||||
External_Resources_Manager config;
|
||||
config.ecap_sqlite_path = ECAP_DEFAULT_SQLITE_PATH;
|
||||
config.ecap_sqlite_path = config_default::sqlite_path;
|
||||
auto value = Psc::JSON::object();
|
||||
value.append({"ecap_sqlite_path", config.ecap_sqlite_path});
|
||||
auto resources = Psc::JSON::array();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "Config_Default.h"
|
||||
#include "Target_Defaults.h"
|
||||
namespace {
|
||||
Map_Tile_Source_Config make_local_tile_source(std::string key, std::string name, Map_Tile_Type tile_type,
|
||||
std::vector<std::string> files,
|
||||
@@ -28,11 +29,11 @@ Map_Tile_Source_Config make_online_tile_source(std::string key, std::string name
|
||||
source.resource.maximum_level = maximum_level;
|
||||
return source;
|
||||
}
|
||||
} // namespace
|
||||
}
|
||||
Default_Config_File make_default_map_resources_config(const std::filesystem::path& directory) {
|
||||
Map_Resources_Config config;
|
||||
config.current_imagery_key = "mixed_imagery";
|
||||
const auto tile_directory = std::string(ECAP_DEFAULT_TILE_DIRECTORY);
|
||||
const auto tile_directory = std::string(config_default::tile_directory);
|
||||
config.tile_sources = {
|
||||
make_local_tile_source("mixed_imagery", "本地混合图", Map_Tile_Type::imagery,
|
||||
{tile_directory + "/混合图-世界-0-8.mbtiles", tile_directory + "/混合图-中国-9-10.mbtiles",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "Config_Default.h"
|
||||
#include "Target_Defaults.h"
|
||||
namespace {
|
||||
void configure_source_display(Data_Source_Map_Display_Data& display, std::string color,
|
||||
std::uint32_t aircraft_pixel_size, std::uint32_t base_station_pixel_size,
|
||||
@@ -25,14 +26,14 @@ std::shared_ptr<Dll_Data_Source> make_dll_source() {
|
||||
value.ignore_msg_time = true;
|
||||
});
|
||||
source->specific.write([](auto& value) {
|
||||
value.library_path = ECAP_DEFAULT_DSP_LIBRARY_PATH;
|
||||
value.library_path = config_default::dsp_library_path;
|
||||
value.function_name = "adsb_read";
|
||||
value.data_type = File_Data_Type::BIN_Blank_Text;
|
||||
value.buffer_size = 200000;
|
||||
});
|
||||
return source;
|
||||
}
|
||||
#if ECAP_DEFAULT_FILE_SOURCE
|
||||
#if defined(ECAP_TARGET_WINDOWS)
|
||||
std::shared_ptr<File_Data_Source> make_file_source() {
|
||||
auto source = std::make_shared<File_Data_Source>();
|
||||
source->key = "aaaa";
|
||||
@@ -46,7 +47,7 @@ std::shared_ptr<File_Data_Source> make_file_source() {
|
||||
value.ignore_msg_time = true;
|
||||
});
|
||||
source->specific.write([](auto& value) {
|
||||
value.file_path = ECAP_DEFAULT_FILE_SOURCE_PATH;
|
||||
value.file_path = config_default::file_source_path;
|
||||
value.data_type = File_Data_Type::BIN_Blank_Text;
|
||||
value.play_mode = Play_Mode::loop;
|
||||
});
|
||||
@@ -82,7 +83,7 @@ std::shared_ptr<Data_Feed_TCP_Server> make_tcp_server_feed(std::string key, bool
|
||||
});
|
||||
return feed;
|
||||
}
|
||||
} // namespace
|
||||
}
|
||||
Default_Config_File make_default_mode_acs_config(const std::filesystem::path& directory) {
|
||||
Mode_ACS_Config config;
|
||||
config.settings.write([](auto& value) {
|
||||
@@ -98,7 +99,7 @@ Default_Config_File make_default_mode_acs_config(const std::filesystem::path& di
|
||||
value.default_min_aircraft_list_num = 10;
|
||||
});
|
||||
config.data_source_config.map.push_back(make_dll_source());
|
||||
#if ECAP_DEFAULT_FILE_SOURCE
|
||||
#if defined(ECAP_TARGET_WINDOWS)
|
||||
config.data_source_config.map.push_back(make_file_source());
|
||||
#endif
|
||||
config.data_feed_config.map.push_back(make_tcp_server_feed("Port_10003", true, Output_Data_Format::BIN, true,
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#include "Config_Default.h"
|
||||
Default_Config_File make_default_version_config(const std::filesystem::path& directory) {
|
||||
return {Config_Section::version, directory / "version.json", Psc::JSON("v1.0.5")};
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "Config_Default.h"
|
||||
#include "Target_Defaults.h"
|
||||
Default_Config_File make_default_web_server_config(const std::filesystem::path& directory) {
|
||||
Web_Server_Config config;
|
||||
config.webapp = ECAP_DEFAULT_WEBAPP_PATH;
|
||||
config.webapp = config_default::webapp_path;
|
||||
config.listen_port = 9081;
|
||||
return {Config_Section::web_server, directory / "web_server.json", config.to_base_json()};
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ void Global::handle_old_logs() {
|
||||
std::cerr << "Error: " + Psc::platform_2_utf8(ex.what()) + "\n";
|
||||
}
|
||||
}
|
||||
Global::Global() {
|
||||
Global::Global() : Config() {
|
||||
auto j = load();
|
||||
from_log_json(j.get("log"));
|
||||
handle_old_logs();
|
||||
|
||||
Reference in New Issue
Block a user