修复问题
This commit is contained in:
@@ -53,7 +53,7 @@ Data_Source::Data_Source() {
|
||||
// parse_format = std::make_shared<Input_Format>();
|
||||
// 写入到配置文件是懒加载 其他保存时他跟着保存
|
||||
base_station.handle_when_updated = [this](SSR::HULC_Status_Message msg) {
|
||||
if (!settings.member<&Data_Source_Data::update_form_gps>().snapshot())
|
||||
if (!settings.member<&Data_Source_Data::update_form_gps>().read([](const auto& value) { return value; }))
|
||||
return;
|
||||
settings.write([&](auto& value) {
|
||||
value.lat = msg.get_latitude();
|
||||
@@ -179,7 +179,7 @@ std::optional<std::string> File_Data_Source::get_raw_line(int& ret_index) {
|
||||
}
|
||||
std::optional<std::string> log_info = std::nullopt;
|
||||
if (index == part_infos.size()) {
|
||||
const auto config = specific.snapshot();
|
||||
const auto config = specific.read([](const auto& value) { return value; });
|
||||
if (config.play_mode == Play_Mode::loop) {
|
||||
index = 0;
|
||||
}
|
||||
@@ -308,7 +308,7 @@ asio::awaitable<void> File_Data_Source::_close() {
|
||||
}
|
||||
asio::awaitable<void> File_Data_Source::_open() {
|
||||
std::lock_guard g(mtx);
|
||||
const auto config = specific.snapshot();
|
||||
const auto config = specific.read([](const auto& value) { return value; });
|
||||
auto path = Psc::get_abs_path(config.file_path);
|
||||
namespace fs = std::filesystem;
|
||||
if (!fs::exists(path)) {
|
||||
@@ -360,7 +360,7 @@ void File_Data_Source::origin_data_transform_mode_data(std::string& mode_data) {
|
||||
std::lock_guard g(mtx);
|
||||
assert(mode_data.size() == 0);
|
||||
int ret_index = 0;
|
||||
const auto config = specific.snapshot();
|
||||
const auto config = specific.read([](const auto& value) { return value; });
|
||||
if (config.play_mode != Play_Mode::analysis) {
|
||||
std::optional<std::string> log_info = get_raw_line(ret_index);
|
||||
mode_data = log_info.has_value() ? get_true_from_raw_line(this, config.data_type, ret_index, log_info.value()) : "";
|
||||
@@ -419,7 +419,7 @@ void Dll_Data_Source::origin_data_transform_mode_data(std::string& mode_data) {
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
if (read_func_ptr == nullptr)
|
||||
return;
|
||||
const auto config = specific.snapshot();
|
||||
const auto config = specific.read([](const auto& value) { return value; });
|
||||
auto buf = reinterpret_cast<char*>(buffer.data());
|
||||
auto len = read_func_ptr(buf, config.buffer_size);
|
||||
vs.update(len);
|
||||
@@ -437,7 +437,7 @@ void Dll_Data_Source::origin_data_transform_mode_data(std::string& mode_data) {
|
||||
mode_data = ret;
|
||||
}
|
||||
asio::awaitable<void> Shared_Memory_Data_Source::_open() {
|
||||
const auto config = specific.snapshot();
|
||||
const auto config = specific.read([](const auto& value) { return value; });
|
||||
sm = std::make_unique<Psc::SM_RingBuffer>();
|
||||
sm->init(config.shared_memory_name, config.shared_memory_size);
|
||||
co_return;
|
||||
@@ -461,7 +461,7 @@ void Shared_Memory_Data_Source::origin_data_transform_mode_data(std::string& mod
|
||||
if (Global::instance()->console_config.mode_s_console) {
|
||||
std::cout << "read:" << data << std::endl;
|
||||
}
|
||||
const auto config = specific.snapshot();
|
||||
const auto config = specific.read([](const auto& value) { return value; });
|
||||
auto ret = get_true_from_raw_line(this, config.data_type, -1, data);
|
||||
mode_data = ret;
|
||||
}
|
||||
|
||||
@@ -186,14 +186,12 @@ public:
|
||||
return ret;
|
||||
}
|
||||
virtual Psc::JSON to_json() {
|
||||
return With_Loop_Coro::to_base_json() += settings.snapshot().to_base_json();
|
||||
return With_Loop_Coro::to_base_json() += settings.read([](const auto& value) { return value.to_base_json(); });
|
||||
}
|
||||
virtual void from_json(const Psc::JSON* that_json, bool not_exist_use_default_value) {
|
||||
With_Loop_Coro::from_base_json(that_json, 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;
|
||||
settings.write([&](auto& value) {
|
||||
value.from_base_json(that_json, not_exist_use_default_value);
|
||||
});
|
||||
}
|
||||
std::string buffer;
|
||||
@@ -233,7 +231,7 @@ public:
|
||||
type = "TCP_Client_Data_Source";
|
||||
}
|
||||
asio::awaitable<void> _open() override {
|
||||
const auto value = specific.snapshot();
|
||||
const auto value = specific.read([](const auto& value) { return value; });
|
||||
Psc::asio_socket::Sockaddr_In addr;
|
||||
addr.ip = value.ip;
|
||||
addr.port = value.port;
|
||||
@@ -247,14 +245,12 @@ public:
|
||||
co_return;
|
||||
}
|
||||
Psc::JSON to_json() override {
|
||||
return Data_Source::to_json() += specific.snapshot().to_base_json();
|
||||
return Data_Source::to_json() += specific.read([](const auto& value) { return value.to_base_json(); });
|
||||
}
|
||||
void from_json(const Psc::JSON* that_json, bool not_exist_use_default_value) override {
|
||||
Data_Source::from_json(that_json, not_exist_use_default_value);
|
||||
auto value = specific.snapshot();
|
||||
value.from_base_json(that_json, not_exist_use_default_value);
|
||||
specific.write([&](auto& target) {
|
||||
target = value;
|
||||
specific.write([&](auto& value) {
|
||||
value.from_base_json(that_json, not_exist_use_default_value);
|
||||
});
|
||||
}
|
||||
asio::awaitable<std::string> read_coro() override {
|
||||
@@ -288,7 +284,7 @@ public:
|
||||
type = "Serial_Data_Source";
|
||||
}
|
||||
asio::awaitable<void> _open() override {
|
||||
const auto value = specific.snapshot();
|
||||
const auto value = specific.read([](const auto& value) { return value; });
|
||||
serial = std::make_unique<Psc::serial::Serial_Coro>();
|
||||
serial->set_serial_name(value.port_name);
|
||||
serial->set_baud_rate(value.baud_rate);
|
||||
@@ -317,14 +313,12 @@ public:
|
||||
co_return co_await serial->read_coro();
|
||||
}
|
||||
Psc::JSON to_json() override {
|
||||
return Data_Source::to_json() += specific.snapshot().to_base_json();
|
||||
return Data_Source::to_json() += specific.read([](const auto& value) { return value.to_base_json(); });
|
||||
}
|
||||
void from_json(const Psc::JSON* that_json, bool not_exist_use_default_value) override {
|
||||
Data_Source::from_json(that_json, not_exist_use_default_value);
|
||||
auto value = specific.snapshot();
|
||||
value.from_base_json(that_json, not_exist_use_default_value);
|
||||
specific.write([&](auto& target) {
|
||||
target = value;
|
||||
specific.write([&](auto& value) {
|
||||
value.from_base_json(that_json, not_exist_use_default_value);
|
||||
});
|
||||
}
|
||||
std::unique_ptr<Psc::serial::Serial_Coro> serial{};
|
||||
@@ -392,21 +386,19 @@ public:
|
||||
std::shared_ptr<Cache_Msg> pre_cache = nullptr;
|
||||
std::deque<std::shared_ptr<Cache_Msg>> cache_list;
|
||||
std::string get_true_file_path() const {
|
||||
return Psc::get_abs_path(specific.member<&File_Data_Source_Data::file_path>().snapshot());
|
||||
return Psc::get_abs_path(specific.member<&File_Data_Source_Data::file_path>().read([](const auto& value) { return value; }));
|
||||
}
|
||||
asio::awaitable<void> _close() override;
|
||||
asio::awaitable<void> _open() override;
|
||||
std::vector<std::string> readBinaryFileAsString(std::string_view filepath, size_t part_size);
|
||||
void from_json(const Psc::JSON* that_json, bool not_exist_use_default_value) override {
|
||||
Data_Source::from_json(that_json, not_exist_use_default_value);
|
||||
auto value = specific.snapshot();
|
||||
value.from_base_json(that_json, not_exist_use_default_value);
|
||||
specific.write([&](auto& target) {
|
||||
target = value;
|
||||
specific.write([&](auto& value) {
|
||||
value.from_base_json(that_json, not_exist_use_default_value);
|
||||
});
|
||||
}
|
||||
Psc::JSON to_json() override {
|
||||
return Data_Source::to_json() += specific.snapshot().to_base_json();
|
||||
return Data_Source::to_json() += specific.read([](const auto& value) { return value.to_base_json(); });
|
||||
}
|
||||
void origin_data_transform_mode_data(std::string& data) override;
|
||||
void handle_mode_s(std::shared_ptr<SSR::Mode_S_Msg>& msg) override;
|
||||
@@ -453,15 +445,14 @@ public:
|
||||
std::vector<std::uint8_t> buffer;
|
||||
void from_json(const Psc::JSON* that_json, bool not_exist_use_default_value) override {
|
||||
Data_Source::from_json(that_json, not_exist_use_default_value);
|
||||
auto value = specific.snapshot();
|
||||
value.from_base_json(that_json, not_exist_use_default_value);
|
||||
specific.write([&](auto& target) {
|
||||
target = value;
|
||||
const auto buffer_size = specific.write([&](auto& value) {
|
||||
value.from_base_json(that_json, not_exist_use_default_value);
|
||||
return value.buffer_size;
|
||||
});
|
||||
buffer.resize(value.buffer_size);
|
||||
buffer.resize(buffer_size);
|
||||
}
|
||||
Psc::JSON to_json() override {
|
||||
return Data_Source::to_json() += specific.snapshot().to_base_json();
|
||||
return Data_Source::to_json() += specific.read([](const auto& value) { return value.to_base_json(); });
|
||||
}
|
||||
void* lib{};
|
||||
using Func_Type = size_t (*)(char* buf, std::size_t max_len);
|
||||
@@ -474,7 +465,7 @@ public:
|
||||
co_return;
|
||||
}
|
||||
asio::awaitable<void> _open() override {
|
||||
const auto value = specific.snapshot();
|
||||
const auto value = specific.read([](const auto& value) { return value; });
|
||||
{
|
||||
auto r = Psc::try_load_library(Psc::get_abs_path(value.library_path));
|
||||
if (!r) {
|
||||
@@ -524,14 +515,12 @@ public:
|
||||
}
|
||||
void from_json(const Psc::JSON* that_json, bool not_exist_use_default_value) override {
|
||||
Data_Source::from_json(that_json, not_exist_use_default_value);
|
||||
auto value = specific.snapshot();
|
||||
value.from_base_json(that_json, not_exist_use_default_value);
|
||||
specific.write([&](auto& target) {
|
||||
target = value;
|
||||
specific.write([&](auto& value) {
|
||||
value.from_base_json(that_json, not_exist_use_default_value);
|
||||
});
|
||||
}
|
||||
Psc::JSON to_json() override {
|
||||
return Data_Source::to_json() += specific.snapshot().to_base_json();
|
||||
return Data_Source::to_json() += specific.read([](const auto& value) { return value.to_base_json(); });
|
||||
}
|
||||
asio::awaitable<void> _open() override;
|
||||
asio::awaitable<void> _close() override;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "Data_Source_Handler.h"
|
||||
#include <string_view>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include "Data_Source.h"
|
||||
#include "Local_Server/server/Global.h"
|
||||
#include "Local_Server/server/io_coro.h"
|
||||
@@ -145,7 +147,7 @@ size_t Data_Source_Handler::process_mode_acs_data(std::string_view origin_data)
|
||||
}
|
||||
};
|
||||
auto f = [this, source, handle_packet](std::string& packet) {
|
||||
const auto wait = Global::instance()->mode_acs.settings.member<&Mode_ACS_Config_Data::wait_process_msg>().snapshot();
|
||||
const auto wait = Global::instance()->mode_acs.settings.member<&Mode_ACS_Config_Data::wait_process_msg>().read([](const auto& value) { return value; });
|
||||
if (wait) {
|
||||
handle_packet(packet);
|
||||
}
|
||||
@@ -168,29 +170,28 @@ void Data_Source_Handler::handle_mode_s(std::shared_ptr<SSR::Mode_S_Msg>& mode_s
|
||||
mem2hex(t, true, " "), mem2hex(mode_s_msg->packet, true, " "), t, mode_s_msg->packet);
|
||||
Psc::fail_fast(data);
|
||||
}
|
||||
const auto cfg = Global::instance()->mode_acs.settings.snapshot();
|
||||
const auto source_cfg = source->settings.snapshot();
|
||||
bool time_space_filter = cfg.time_space_filter;
|
||||
bool speed_filter = cfg.speed_filter;
|
||||
bool use_system_time = source_cfg.ignore_msg_time;
|
||||
const auto mode_config = Global::instance()->mode_acs.settings.read([](const auto& value) {
|
||||
return std::tuple{value.time_space_filter, value.speed_filter, value.aircraft_change_list_adsb_range_filter, value.aircraft_change_list_adsb_range_factor, value.max_speed_m_s, value.air_pos_timeout, value.surface_pos_timeout};
|
||||
});
|
||||
const auto source_config = source->settings.read([](const auto& value) {
|
||||
return std::tuple{value.ignore_msg_time, value.base_station_has_valid_position, value.lat, value.lon, value.alt};
|
||||
});
|
||||
const auto [time_space_filter, speed_filter, range_filter, range_factor, max_speed_m_s, air_pos_timeout, surface_pos_timeout] = mode_config;
|
||||
const auto [use_system_time, base_station_has_valid_position, lat, lon, alt] = source_config;
|
||||
auto base_station_pos = source->base_station.get_pos();
|
||||
if (!base_station_pos && source_cfg.base_station_has_valid_position)
|
||||
base_station_pos = SSR::Position_3D{source_cfg.lat, source_cfg.lon, source_cfg.alt};
|
||||
auto range_filter = cfg.aircraft_change_list_adsb_range_filter;
|
||||
auto range_factor = cfg.aircraft_change_list_adsb_range_factor;
|
||||
SSR::ADS_B_T::Constraint air_constraint{cfg.max_speed_m_s, cfg.air_pos_timeout, SSR::cpr_cb, time_space_filter,
|
||||
speed_filter, use_system_time, base_station_pos, source_cfg.alt,
|
||||
range_filter, range_factor};
|
||||
SSR::ADS_B_T::Constraint surface_constraint{cfg.max_speed_m_s, cfg.surface_pos_timeout, SSR::cpr_cb, time_space_filter,
|
||||
speed_filter, use_system_time, base_station_pos, source_cfg.alt,
|
||||
range_filter, range_factor};
|
||||
if (!base_station_pos && base_station_has_valid_position)
|
||||
base_station_pos = SSR::Position_3D{lat, lon, alt};
|
||||
SSR::ADS_B_T::Constraint air_constraint{max_speed_m_s, air_pos_timeout, SSR::cpr_cb, time_space_filter,
|
||||
speed_filter, use_system_time, base_station_pos, alt, range_filter, range_factor};
|
||||
SSR::ADS_B_T::Constraint surface_constraint{max_speed_m_s, surface_pos_timeout, SSR::cpr_cb, time_space_filter,
|
||||
speed_filter, use_system_time, base_station_pos, alt, range_filter, range_factor};
|
||||
SSR::parse_mode_s_bin(source.get(), mode_s_msg, base_station_pos, air_constraint, surface_constraint);
|
||||
auto base = source->get_aircraft(mode_s_msg->icao);
|
||||
if (base) {
|
||||
auto derived = std::dynamic_pointer_cast<Aircraft>(base);
|
||||
derived->refresh_external_database_info();
|
||||
}
|
||||
if (Global::instance()->mlat.settings.member<&MLAT_Config_Data::merge>().snapshot()) {
|
||||
if (Global::instance()->mlat.settings.member<&MLAT_Config_Data::merge>().read([](const auto& value) { return value; })) {
|
||||
auto& mh = Global::instance()->mlat_handler;
|
||||
mh.push(mode_s_msg);
|
||||
auto tt = mh.get_all();
|
||||
@@ -288,31 +289,33 @@ void Data_Source_Handler::refresh_data_feed_key_list() {
|
||||
const auto feeds = global->mode_acs.data_feed_config.map.list();
|
||||
const auto relations = global->mode_acs.source_feed_relation_config.map.list();
|
||||
for (const auto& relation : relations) {
|
||||
const auto config = relation->settings.snapshot();
|
||||
if (!config.enable || relation->type != "One_to_One_Relation")
|
||||
continue;
|
||||
const auto source = global->mode_acs.data_source_config.map.get(config.source_key);
|
||||
const auto feed = global->mode_acs.data_feed_config.map.get(config.feed_key);
|
||||
if (source.has_value() && feed.has_value() && source.value()->enabled() && feed.value()->enabled() && !assignment.contains(config.feed_key))
|
||||
assignment.emplace(config.feed_key, config.source_key);
|
||||
relation->settings.read([&](const auto& config) {
|
||||
if (!config.enable || relation->type != "One_to_One_Relation")
|
||||
return;
|
||||
const auto source = global->mode_acs.data_source_config.map.get(config.source_key);
|
||||
const auto feed = global->mode_acs.data_feed_config.map.get(config.feed_key);
|
||||
if (source.has_value() && feed.has_value() && source.value()->enabled() && feed.value()->enabled() && !assignment.contains(config.feed_key))
|
||||
assignment.emplace(config.feed_key, config.source_key);
|
||||
});
|
||||
}
|
||||
for (const auto& relation : relations) {
|
||||
const auto config = relation->settings.snapshot();
|
||||
if (!config.enable || relation->type != "Name_One_To_Many_Relation")
|
||||
continue;
|
||||
const auto source = global->mode_acs.data_source_config.map.get(config.source_key);
|
||||
if (!source.has_value() || !source.value()->enabled())
|
||||
continue;
|
||||
const std::string& prefix = config.feed_name.empty() ? config.source_key : config.feed_name;
|
||||
for (const auto& feed : feeds) {
|
||||
if (!feed->enabled() || assignment.contains(feed->key) || !feed->key.starts_with(prefix))
|
||||
continue;
|
||||
assignment.emplace(feed->key, config.source_key);
|
||||
}
|
||||
relation->settings.read([&](const auto& config) {
|
||||
if (!config.enable || relation->type != "Name_One_To_Many_Relation")
|
||||
return;
|
||||
const auto source = global->mode_acs.data_source_config.map.get(config.source_key);
|
||||
if (!source.has_value() || !source.value()->enabled())
|
||||
return;
|
||||
const std::string& prefix = config.feed_name.empty() ? config.source_key : config.feed_name;
|
||||
for (const auto& feed : feeds) {
|
||||
if (!feed->enabled() || assignment.contains(feed->key) || !feed->key.starts_with(prefix))
|
||||
continue;
|
||||
assignment.emplace(feed->key, config.source_key);
|
||||
}
|
||||
});
|
||||
}
|
||||
bool use_default = false;
|
||||
for (const auto& relation : relations) {
|
||||
if (relation->type == "First_Source_To_All_Feed_Relation" && relation->settings.member<&Source_Feed_Relation_Data::enable>().snapshot()) {
|
||||
if (relation->type == "First_Source_To_All_Feed_Relation" && relation->settings.member<&Source_Feed_Relation_Data::enable>().read([](const auto& value) { return value; })) {
|
||||
use_default = true;
|
||||
break;
|
||||
}
|
||||
@@ -351,12 +354,12 @@ std::optional<std::string> convert_to_send_format(Data_Source_Handler* ds, const
|
||||
auto& type = msg->type;
|
||||
auto fs = dynamic_cast<File_Data_Source*>(msg->source.get());
|
||||
if (fs) {
|
||||
if (fs->specific.member<&File_Data_Source_Data::play_mode>().snapshot() == Play_Mode::analysis) {
|
||||
if (fs->specific.member<&File_Data_Source_Data::play_mode>().read([](const auto& value) { return value; }) == Play_Mode::analysis) {
|
||||
// std::cout << fs->key << " analysis i ==" << i << std::endl;
|
||||
}
|
||||
}
|
||||
// 出口输出的条件
|
||||
const auto feed_format = feed->output_format.snapshot();
|
||||
const auto feed_format = feed->output_format.read([](const auto& value) { return value; });
|
||||
const auto output_format = feed_format.type;
|
||||
const auto use_mode_ac = feed_format.use_mode_ac;
|
||||
const auto use_status = feed_format.use_status;
|
||||
@@ -488,9 +491,9 @@ void Data_Source_Handler::push_to_feed(const std::shared_ptr<SSR::Msg>& msg) {
|
||||
refresh_data_feed_key_list();
|
||||
need_refresh_data_feed_key_list = false;
|
||||
}
|
||||
const auto mode_config = Global::instance()->mode_acs.settings.snapshot();
|
||||
const auto other_size = mode_config.mode_other_max_num;
|
||||
const auto s_size = mode_config.mode_s_max_num;
|
||||
const auto [other_size, s_size] = Global::instance()->mode_acs.settings.read([](const auto& value) {
|
||||
return std::pair{value.mode_other_max_num, value.mode_s_max_num};
|
||||
});
|
||||
std::vector<std::string> list;
|
||||
for (const auto& item : cached_data_feed_key_list) {
|
||||
auto& key = item.key;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "../server/Global.h"
|
||||
#include "../server/Performance_Monitor.h"
|
||||
#include "../server/WebSocket_Manager.h"
|
||||
|
||||
#include <tuple>
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
@@ -290,7 +290,7 @@ void register_aircraft_stream_ws() {
|
||||
}
|
||||
}
|
||||
Aircraft::Aircraft(std::string_view icao) : Aircraft_Info(icao) {
|
||||
auto size = Global::instance()->mode_acs.settings.member<&Mode_ACS_Config_Data::max_track_point_size>().snapshot();
|
||||
auto size = Global::instance()->mode_acs.settings.member<&Mode_ACS_Config_Data::max_track_point_size>().read([](const auto& value) { return value; });
|
||||
air_pos_track_list.init(size);
|
||||
surface_pos_track_list.init(size);
|
||||
}
|
||||
@@ -332,7 +332,7 @@ void DataBase::delete_timeout_aircraft() {
|
||||
std::cout << "未初始化的 timestamp " << LOG_POS << std::endl;
|
||||
}
|
||||
long long time = std::time(nullptr) - item->timestamp;
|
||||
return time > Global::instance()->mode_acs.settings.member<&Mode_ACS_Config_Data::timeout_seconds>().snapshot();
|
||||
return time > Global::instance()->mode_acs.settings.member<&Mode_ACS_Config_Data::timeout_seconds>().read([](const auto& value) { return value; });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -360,16 +360,17 @@ std::vector<std::shared_ptr<SSR::Aircraft_Info>>
|
||||
DataBase::get_visible_aircraft_snapshot() {
|
||||
std::vector<std::shared_ptr<SSR::Aircraft_Info>> ret;
|
||||
auto g = Global::instance();
|
||||
auto min_position_points =
|
||||
g->mode_acs.settings.member<&Mode_ACS_Config_Data::aircraft_change_list_min_position_points>().snapshot();
|
||||
auto range_filter = g->mode_acs.settings.member<&Mode_ACS_Config_Data::aircraft_change_list_adsb_range_filter>().snapshot();
|
||||
auto range_factor = g->mode_acs.settings.member<&Mode_ACS_Config_Data::aircraft_change_list_adsb_range_factor>().snapshot();
|
||||
const auto [min_position_points, range_filter, range_factor] = g->mode_acs.settings.read([](const auto& value) {
|
||||
return std::tuple{value.aircraft_change_list_min_position_points, value.aircraft_change_list_adsb_range_filter, value.aircraft_change_list_adsb_range_factor};
|
||||
});
|
||||
auto source = g->source(get_key());
|
||||
auto base_position = base_station.get_pos();
|
||||
if (source) {
|
||||
const auto source_config = source->settings.snapshot();
|
||||
if (!base_position && source_config.base_station_has_valid_position) {
|
||||
base_position = SSR::Position_3D{source_config.lat, source_config.lon, source_config.alt};
|
||||
const auto [valid_position, lat, lon, alt] = source->settings.read([](const auto& value) {
|
||||
return std::tuple{value.base_station_has_valid_position, value.lat, value.lon, value.alt};
|
||||
});
|
||||
if (!base_position && valid_position) {
|
||||
base_position = SSR::Position_3D{lat, lon, alt};
|
||||
}
|
||||
}
|
||||
for (auto &it : aircraft_map.values()) {
|
||||
@@ -541,13 +542,14 @@ void database_server(Global *g) {
|
||||
if (db) {
|
||||
ret = db->base_station.to_Json();
|
||||
auto target_height =
|
||||
g->mode_acs.settings.member<&Mode_ACS_Config_Data::adsb_theoretical_target_altitude_meters>().snapshot();
|
||||
const auto source_config = db->settings.snapshot();
|
||||
auto range = Base_Station::theoretical_detection_range_meters(source_config.alt,
|
||||
target_height);
|
||||
ret.append({"latitude", source_config.lat});
|
||||
ret.append({"longitude", source_config.lon});
|
||||
ret.append({"height", source_config.alt});
|
||||
g->mode_acs.settings.member<&Mode_ACS_Config_Data::adsb_theoretical_target_altitude_meters>().read([](const auto& value) { return value; });
|
||||
const auto [lat, lon, alt] = db->settings.read([](const auto& value) {
|
||||
return std::tuple{value.lat, value.lon, value.alt};
|
||||
});
|
||||
auto range = Base_Station::theoretical_detection_range_meters(alt, target_height);
|
||||
ret.append({"latitude", lat});
|
||||
ret.append({"longitude", lon});
|
||||
ret.append({"height", alt});
|
||||
ret.append({"adsb_theoretical_target_altitude_meters", target_height});
|
||||
ret.append({"adsb_theoretical_detection_range_meters", range});
|
||||
ret.append({"理论探测范围", range});
|
||||
@@ -615,7 +617,7 @@ void database_server(Global *g) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto limit_msg_num = g->mode_acs.settings.member<&Mode_ACS_Config_Data::default_min_aircraft_list_num>().snapshot();
|
||||
auto limit_msg_num = g->mode_acs.settings.member<&Mode_ACS_Config_Data::default_min_aircraft_list_num>().read([](const auto& value) { return value; });
|
||||
auto t = params.get("limit_msg_num");
|
||||
if (t) {
|
||||
HTTP_REQUIRE_VALUE(requested_limit_msg_num, t->try_number_val<int>())
|
||||
|
||||
Reference in New Issue
Block a user