初步修改
This commit is contained in:
@@ -56,9 +56,9 @@ protected:
|
||||
};
|
||||
class Data_Source_Map_Display_Data {
|
||||
public:
|
||||
Psc::Copyable_Atomic<bool> base_station_show = true;
|
||||
Psc::Copyable_Atomic<bool> aircraft_show = true;
|
||||
Psc::Copyable_Atomic<bool> constant_screen_size = true;
|
||||
bool base_station_show = true;
|
||||
bool aircraft_show = true;
|
||||
bool constant_screen_size = true;
|
||||
std::string color = "#1677ff";
|
||||
std::string track_point_color = "#ffff00";
|
||||
std::string base_station_color = "#1677ff";
|
||||
@@ -67,9 +67,9 @@ public:
|
||||
std::uint32_t track_point_pixel_size = 8;
|
||||
double aircraft_scale = 1.0;
|
||||
double base_station_scale = 1.0;
|
||||
Psc::Copyable_Atomic<bool> show_icao = true;
|
||||
Psc::Copyable_Atomic<bool> show_call_sign = false;
|
||||
Psc::Copyable_Atomic<bool> show_fly_status = false;
|
||||
bool show_icao = true;
|
||||
bool show_call_sign = false;
|
||||
bool show_fly_status = false;
|
||||
PSC_USE_JSON
|
||||
};
|
||||
class Data_Source_Map_Display_Config {
|
||||
@@ -83,23 +83,22 @@ public:
|
||||
return ret;
|
||||
}
|
||||
void from_base_json(const Psc::JSON* that_json, bool not_exist_use_default_value) {
|
||||
if (that_json == nullptr || that_json->valueType != Psc::Object) {
|
||||
if (that_json == nullptr || that_json->valueType != Psc::Object)
|
||||
throw Psc::json_assign_error(std::make_error_code(std::errc::invalid_argument), "map_display");
|
||||
}
|
||||
map2d.from_base_json(that_json->get("map2d"), not_exist_use_default_value);
|
||||
map3d.from_base_json(that_json->get("map3d"), not_exist_use_default_value);
|
||||
}
|
||||
};
|
||||
class Data_Source_Data {
|
||||
public:
|
||||
Psc::Copyable_Atomic<bool> base_station_has_valid_position{};
|
||||
bool base_station_has_valid_position{};
|
||||
Data_Source_Map_Display_Config map_display;
|
||||
double lat{};
|
||||
double lon{};
|
||||
double alt{};
|
||||
Psc::Copyable_Atomic<bool> ignore_msg_time = false; // 忽略消息时间戳 如果启用 解码位置将不在判断消息自带时间戳
|
||||
Psc::Copyable_Atomic<bool> update_form_gps{};
|
||||
Psc::Copyable_Atomic<bool> keep_mode = true;
|
||||
bool ignore_msg_time = false;
|
||||
bool update_form_gps{};
|
||||
bool keep_mode = true;
|
||||
[[nodiscard]] Psc::JSON to_base_json() const {
|
||||
auto ret = Psc::JSON::object();
|
||||
Ret_J(base_station_has_valid_position) ret.append({"map_display", map_display.to_base_json()});
|
||||
@@ -111,10 +110,56 @@ public:
|
||||
Get_J(lat) Get_J(lon) Get_J(alt) Get_J(ignore_msg_time) Get_J(update_form_gps) Get_J(keep_mode)
|
||||
}
|
||||
};
|
||||
class Data_Source : public std::enable_shared_from_this<Data_Source>,
|
||||
public Data_Source_Handler,
|
||||
public Data_Source_Data {
|
||||
namespace adminive {
|
||||
template <>
|
||||
struct Type_Descriptor<Data_Source_Map_Display_Data> {
|
||||
static auto get() {
|
||||
using T = Data_Source_Map_Display_Data;
|
||||
return object<T>("data_source_map_display", "地图显示",
|
||||
ADMINIVE_FIELD_LABEL(T, base_station_show, "显示基站").creatable().editable().boolean_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, aircraft_show, "显示飞机").creatable().editable().boolean_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, constant_screen_size, "固定屏幕尺寸").creatable().editable().boolean_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, color, "颜色").creatable().editable().color_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, track_point_color, "航迹点颜色").creatable().editable().color_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, base_station_color, "基站颜色").creatable().editable().color_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, aircraft_pixel_size, "飞机像素尺寸").creatable().editable().number_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, base_station_pixel_size, "基站像素尺寸").creatable().editable().number_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, track_point_pixel_size, "航迹点像素尺寸").creatable().editable().number_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, aircraft_scale, "飞机缩放").creatable().editable().number_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, base_station_scale, "基站缩放").creatable().editable().number_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, show_icao, "显示 ICAO").creatable().editable().boolean_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, show_call_sign, "显示呼号").creatable().editable().boolean_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, show_fly_status, "显示飞行状态").creatable().editable().boolean_input());
|
||||
}
|
||||
};
|
||||
template <>
|
||||
struct Type_Descriptor<Data_Source_Map_Display_Config> {
|
||||
static auto get() {
|
||||
using T = Data_Source_Map_Display_Config;
|
||||
return object<T>("data_source_map_display_config", "地图显示配置",
|
||||
ADMINIVE_FIELD_LABEL(T, map2d, "2D 地图").creatable().editable(),
|
||||
ADMINIVE_FIELD_LABEL(T, map3d, "3D 地图").creatable().editable());
|
||||
}
|
||||
};
|
||||
template <>
|
||||
struct Type_Descriptor<Data_Source_Data> {
|
||||
static auto get() {
|
||||
using T = Data_Source_Data;
|
||||
return object<T>("data_source_config", "数据源公共配置",
|
||||
ADMINIVE_FIELD_LABEL(T, base_station_has_valid_position, "基站位置有效").creatable().editable().boolean_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, map_display, "地图显示").creatable().editable(),
|
||||
ADMINIVE_FIELD_LABEL(T, lat, "纬度").creatable().editable().number_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, lon, "经度").creatable().editable().number_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, alt, "高度").creatable().editable().number_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, ignore_msg_time, "忽略消息时间戳").creatable().editable().boolean_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, update_form_gps, "从 GPS 更新位置").creatable().editable().boolean_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, keep_mode, "保留模式").creatable().editable().boolean_input());
|
||||
}
|
||||
};
|
||||
}
|
||||
class Data_Source : public std::enable_shared_from_this<Data_Source>, public Data_Source_Handler {
|
||||
public:
|
||||
adminive::Managed_Value<Data_Source_Data> settings;
|
||||
std::shared_ptr<Data_Source> that();
|
||||
virtual asio::awaitable<std::string> read_coro() {
|
||||
co_return "";
|
||||
@@ -122,7 +167,7 @@ public:
|
||||
bool registered() const;
|
||||
virtual Psc::JSON get_custom_state_json() = 0;
|
||||
Psc::JSON get_state();
|
||||
std::string last_char; // 用于处理奇数字节
|
||||
std::string last_char;
|
||||
Data_Source();
|
||||
asio::awaitable<void> loop_coro() final;
|
||||
std::shared_ptr<SSR::Mode_Msg> last_prase_msg = nullptr;
|
||||
@@ -141,11 +186,15 @@ public:
|
||||
return ret;
|
||||
}
|
||||
virtual Psc::JSON to_json() {
|
||||
return With_Loop_Coro::to_base_json() += Data_Source_Data::to_base_json();
|
||||
return With_Loop_Coro::to_base_json() += settings.snapshot().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);
|
||||
Data_Source_Data::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;
|
||||
});
|
||||
}
|
||||
std::string buffer;
|
||||
std::atomic_bool ask_sleep = false;
|
||||
@@ -156,8 +205,20 @@ public:
|
||||
std::uint16_t port{};
|
||||
PSC_USE_JSON
|
||||
};
|
||||
class TCP_Client_Data_Source : public Data_Source, public TCP_Client_Data_Source_Data {
|
||||
namespace adminive {
|
||||
template <>
|
||||
struct Type_Descriptor<TCP_Client_Data_Source_Data> {
|
||||
static auto get() {
|
||||
using T = TCP_Client_Data_Source_Data;
|
||||
return object<T>("tcp_client_data_source", "TCP 客户端配置",
|
||||
ADMINIVE_FIELD_LABEL(T, ip, "IP 地址").creatable().editable().text_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, port, "端口").creatable().editable().number_input());
|
||||
}
|
||||
};
|
||||
}
|
||||
class TCP_Client_Data_Source : public Data_Source {
|
||||
public:
|
||||
adminive::Managed_Value<TCP_Client_Data_Source_Data> specific;
|
||||
asio::awaitable<void> handle_in_loop_coro() override {
|
||||
co_await cli.tick_coro();
|
||||
co_return;
|
||||
@@ -172,9 +233,10 @@ public:
|
||||
type = "TCP_Client_Data_Source";
|
||||
}
|
||||
asio::awaitable<void> _open() override {
|
||||
const auto value = specific.snapshot();
|
||||
Psc::asio_socket::Sockaddr_In addr;
|
||||
addr.ip = ip;
|
||||
addr.port = port;
|
||||
addr.ip = value.ip;
|
||||
addr.port = value.port;
|
||||
cli.set_dest_address(addr);
|
||||
cli.create();
|
||||
co_await cli.connect_coro();
|
||||
@@ -185,11 +247,15 @@ public:
|
||||
co_return;
|
||||
}
|
||||
Psc::JSON to_json() override {
|
||||
return Data_Source::to_json() += TCP_Client_Data_Source_Data::to_base_json();
|
||||
return Data_Source::to_json() += specific.snapshot().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);
|
||||
TCP_Client_Data_Source_Data::from_base_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;
|
||||
});
|
||||
}
|
||||
asio::awaitable<std::string> read_coro() override {
|
||||
co_return co_await cli.read_coro();
|
||||
@@ -201,31 +267,38 @@ public:
|
||||
Baud_Rate_Type baud_rate{};
|
||||
PSC_USE_JSON
|
||||
};
|
||||
class Serial_Data_Source : public Data_Source, public Serial_Data_Source_Data {
|
||||
namespace adminive {
|
||||
template <>
|
||||
struct Type_Descriptor<Serial_Data_Source_Data> {
|
||||
static auto get() {
|
||||
using T = Serial_Data_Source_Data;
|
||||
return object<T>("serial_data_source", "串口数据源配置",
|
||||
ADMINIVE_FIELD_LABEL(T, port_name, "串口名称").creatable().editable().text_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, baud_rate, "波特率").creatable().editable().select_input());
|
||||
}
|
||||
};
|
||||
}
|
||||
class Serial_Data_Source : public Data_Source {
|
||||
public:
|
||||
adminive::Managed_Value<Serial_Data_Source_Data> specific;
|
||||
Psc::JSON get_custom_state_json() override {
|
||||
return Psc::JSON::object();
|
||||
}
|
||||
Serial_Data_Source() {
|
||||
this->type = "Serial_Data_Source";
|
||||
type = "Serial_Data_Source";
|
||||
}
|
||||
asio::awaitable<void> _open() override {
|
||||
const auto value = specific.snapshot();
|
||||
serial = std::make_unique<Psc::serial::Serial_Coro>();
|
||||
serial->set_serial_name(port_name);
|
||||
serial->set_baud_rate(baud_rate);
|
||||
serial->set_serial_name(value.port_name);
|
||||
serial->set_baud_rate(value.baud_rate);
|
||||
serial->set_parity(Psc::serial::Parity::NoParity);
|
||||
serial->set_data_bits(Psc::serial::DataBits::Data8);
|
||||
serial->set_stop_bits(Psc::serial::StopBits::OneStop);
|
||||
serial->set_flow_control(Psc::serial::FlowControl::HardwareControl);
|
||||
serial->set_buffer_byte_size(10 * 1024);
|
||||
bool ok = serial->open();
|
||||
if (!ok) {
|
||||
std::cerr << "createSerial " + port_name + ":" + std::to_string(baud_rate) + " 打开串口失败!\n";
|
||||
}
|
||||
else {
|
||||
// std::cerr << "createSerial " + serial_name + ":" +
|
||||
// std::to_string(baud_rate) + " 打开串口成功!\n";
|
||||
}
|
||||
if (!serial->open())
|
||||
std::cerr << "createSerial " + value.port_name + ":" + std::to_string(value.baud_rate) + " 打开串口失败!\n";
|
||||
co_return;
|
||||
}
|
||||
asio::awaitable<void> _close() override {
|
||||
@@ -234,29 +307,30 @@ public:
|
||||
co_return;
|
||||
}
|
||||
asio::awaitable<void> handle_in_loop_coro() override {
|
||||
if (serial) {
|
||||
if (serial)
|
||||
co_await serial->tick_coro();
|
||||
}
|
||||
co_return;
|
||||
}
|
||||
asio::awaitable<std::string> read_coro() override {
|
||||
if (!serial) {
|
||||
if (!serial)
|
||||
co_return "";
|
||||
}
|
||||
co_return co_await serial->read_coro();
|
||||
}
|
||||
Psc::JSON to_json() override {
|
||||
return Data_Source::to_json() += Serial_Data_Source_Data::to_base_json();
|
||||
return Data_Source::to_json() += specific.snapshot().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);
|
||||
Serial_Data_Source_Data::from_base_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;
|
||||
});
|
||||
}
|
||||
std::unique_ptr<Psc::serial::Serial_Coro> serial{};
|
||||
~Serial_Data_Source() override {
|
||||
if (serial) {
|
||||
if (serial)
|
||||
serial->close();
|
||||
}
|
||||
}
|
||||
};
|
||||
enum class File_Data_Type {
|
||||
@@ -278,8 +352,21 @@ public:
|
||||
Play_Mode play_mode = Play_Mode::one;
|
||||
PSC_USE_JSON
|
||||
};
|
||||
class File_Data_Source : public Data_Source, public File_Data_Source_Data {
|
||||
namespace adminive {
|
||||
template <>
|
||||
struct Type_Descriptor<File_Data_Source_Data> {
|
||||
static auto get() {
|
||||
using T = File_Data_Source_Data;
|
||||
return object<T>("file_data_source", "文件数据源配置",
|
||||
ADMINIVE_FIELD_LABEL(T, file_path, "文件路径").creatable().editable().text_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, data_type, "数据格式").creatable().editable().select_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, play_mode, "播放模式").creatable().editable().select_input());
|
||||
}
|
||||
};
|
||||
}
|
||||
class File_Data_Source : public Data_Source {
|
||||
public:
|
||||
adminive::Managed_Value<File_Data_Source_Data> specific;
|
||||
bool have_report_play_back_all_success = false;
|
||||
std::string state = "null";
|
||||
Psc::JSON get_custom_state_json() override {
|
||||
@@ -288,7 +375,7 @@ public:
|
||||
return VAR_JSON_5(cur_virtual_time, playback_speed_rate, state, index, part_infos.size());
|
||||
}
|
||||
File_Data_Source() {
|
||||
this->type = "File_Data_Source";
|
||||
type = "File_Data_Source";
|
||||
}
|
||||
~File_Data_Source() override = default;
|
||||
void before_handle_msg(std::shared_ptr<SSR::Mode_Msg>& msg) override;
|
||||
@@ -305,17 +392,21 @@ 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(file_path);
|
||||
return Psc::get_abs_path(specific.member<&File_Data_Source_Data::file_path>().snapshot());
|
||||
}
|
||||
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);
|
||||
File_Data_Source_Data::from_base_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;
|
||||
});
|
||||
}
|
||||
Psc::JSON to_json() override {
|
||||
return Data_Source::to_json() += File_Data_Source_Data::to_base_json();
|
||||
return Data_Source::to_json() += specific.snapshot().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;
|
||||
@@ -333,8 +424,22 @@ public:
|
||||
std::size_t buffer_size{};
|
||||
PSC_USE_JSON
|
||||
};
|
||||
class Dll_Data_Source : public Data_Source, public Dll_Data_Source_Data {
|
||||
namespace adminive {
|
||||
template <>
|
||||
struct Type_Descriptor<Dll_Data_Source_Data> {
|
||||
static auto get() {
|
||||
using T = Dll_Data_Source_Data;
|
||||
return object<T>("dll_data_source", "DLL 数据源配置",
|
||||
ADMINIVE_FIELD_LABEL(T, library_path, "库路径").creatable().editable().text_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, function_name, "函数名").creatable().editable().text_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, data_type, "数据格式").creatable().editable().select_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, buffer_size, "读取缓冲区大小").creatable().editable().number_input());
|
||||
}
|
||||
};
|
||||
}
|
||||
class Dll_Data_Source : public Data_Source {
|
||||
public:
|
||||
adminive::Managed_Value<Dll_Data_Source_Data> specific;
|
||||
Psc::JSON get_custom_state_json() override {
|
||||
auto ret = VAR_JSON_1(state);
|
||||
ret.append({"read_vaild_len", vs.to_string()});
|
||||
@@ -342,21 +447,24 @@ public:
|
||||
}
|
||||
Psc::Value_Statistics vs;
|
||||
Dll_Data_Source() {
|
||||
this->type = "Dll_Data_Source";
|
||||
type = "Dll_Data_Source";
|
||||
}
|
||||
~Dll_Data_Source() override = default;
|
||||
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);
|
||||
Dll_Data_Source_Data::from_base_json(that_json, not_exist_use_default_value);
|
||||
buffer.resize(buffer_size);
|
||||
auto value = specific.snapshot();
|
||||
value.from_base_json(that_json, not_exist_use_default_value);
|
||||
specific.write([&](auto& target) {
|
||||
target = value;
|
||||
});
|
||||
buffer.resize(value.buffer_size);
|
||||
}
|
||||
Psc::JSON to_json() override {
|
||||
return Data_Source::to_json() += Dll_Data_Source_Data::to_base_json();
|
||||
return Data_Source::to_json() += specific.snapshot().to_base_json();
|
||||
}
|
||||
void* lib{};
|
||||
using Func_Type = size_t (*)(char* buf, std::size_t max_len);
|
||||
// using Func_Type = std::uint16_t (*)(char *buf, std::uint16_t max_len);
|
||||
Func_Type read_func_ptr{};
|
||||
using Call_Back = void (*)(char* buf, std::size_t len);
|
||||
using set_Call_back = void (*)(Call_Back);
|
||||
@@ -366,8 +474,9 @@ public:
|
||||
co_return;
|
||||
}
|
||||
asio::awaitable<void> _open() override {
|
||||
const auto value = specific.snapshot();
|
||||
{
|
||||
auto r = Psc::try_load_library(Psc::get_abs_path(library_path));
|
||||
auto r = Psc::try_load_library(Psc::get_abs_path(value.library_path));
|
||||
if (!r) {
|
||||
state = r.error().message();
|
||||
co_return;
|
||||
@@ -375,10 +484,10 @@ public:
|
||||
lib = r.value();
|
||||
}
|
||||
{
|
||||
auto r = Psc::try_load_function(lib, function_name);
|
||||
auto r = Psc::try_load_function(lib, value.function_name);
|
||||
if (!r) {
|
||||
state = r.error().message();
|
||||
std::cout << LOG_POS << " [" << function_name << "] 函数指针加载失败!" << std::endl;
|
||||
std::cout << LOG_POS << " [" << value.function_name << "] 函数指针加载失败!" << std::endl;
|
||||
co_return;
|
||||
}
|
||||
read_func_ptr = (Func_Type)r.value();
|
||||
@@ -395,17 +504,34 @@ public:
|
||||
File_Data_Type data_type = File_Data_Type::BIN_Blank_Text;
|
||||
PSC_USE_JSON
|
||||
};
|
||||
class Shared_Memory_Data_Source : public Data_Source, public Shared_Memory_Data_Source_Data {
|
||||
namespace adminive {
|
||||
template <>
|
||||
struct Type_Descriptor<Shared_Memory_Data_Source_Data> {
|
||||
static auto get() {
|
||||
using T = Shared_Memory_Data_Source_Data;
|
||||
return object<T>("shared_memory_data_source", "共享内存数据源配置",
|
||||
ADMINIVE_FIELD_LABEL(T, shared_memory_name, "共享内存名称").creatable().editable().text_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, shared_memory_size, "共享内存大小").creatable().editable().number_input(),
|
||||
ADMINIVE_FIELD_LABEL(T, data_type, "数据格式").creatable().editable().select_input());
|
||||
}
|
||||
};
|
||||
}
|
||||
class Shared_Memory_Data_Source : public Data_Source {
|
||||
public:
|
||||
adminive::Managed_Value<Shared_Memory_Data_Source_Data> specific;
|
||||
Psc::JSON get_custom_state_json() override {
|
||||
return Psc::JSON::object();
|
||||
}
|
||||
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);
|
||||
Shared_Memory_Data_Source_Data::from_base_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;
|
||||
});
|
||||
}
|
||||
Psc::JSON to_json() override {
|
||||
return Data_Source::to_json() += Shared_Memory_Data_Source_Data::to_base_json();
|
||||
return Data_Source::to_json() += specific.snapshot().to_base_json();
|
||||
}
|
||||
asio::awaitable<void> _open() override;
|
||||
asio::awaitable<void> _close() override;
|
||||
@@ -429,6 +555,7 @@ inline std::shared_ptr<Data_Source> create_data_source_from_type(std::string_vie
|
||||
std::cout << "未知 Data_Source type类型!" << std::endl;
|
||||
throw std::invalid_argument("unknown Data_Source type: " + std::string(t));
|
||||
}
|
||||
ret->type = std::string(t);
|
||||
return ret;
|
||||
}
|
||||
struct Data_Source_Config {
|
||||
@@ -441,14 +568,14 @@ struct Data_Source_Config {
|
||||
map.push_back(ds);
|
||||
}
|
||||
}
|
||||
Psc::JSON list() {
|
||||
Psc::JSON list() const {
|
||||
auto connect_json = Psc::JSON::array();
|
||||
for (auto& it : map.list()) {
|
||||
connect_json.children.emplace_back(it->to_json());
|
||||
}
|
||||
return connect_json;
|
||||
}
|
||||
Psc::JSON to_json() {
|
||||
Psc::JSON to_json() const {
|
||||
Psc::JSON ret = Psc::JSON::object();
|
||||
ret.append({"list", list()});
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user