缩减代码
This commit is contained in:
@@ -13,10 +13,6 @@ std::optional<SSR::Position_3D> Base_Station::get_pos() {
|
||||
}
|
||||
return SSR::Position_3D{hulc.get_latitude(), hulc.get_longitude(), static_cast<SSR::CPR::D>(hulc.Alt)};
|
||||
}
|
||||
double Base_Station::get_height() {
|
||||
std::lock_guard g(mtx);
|
||||
return hulc.Alt;
|
||||
}
|
||||
bool Base_Station::has_valid_position() {
|
||||
std::lock_guard g(mtx);
|
||||
return hulc.GPS_has_valid_fix();
|
||||
|
||||
@@ -5,7 +5,6 @@ public:
|
||||
std::string to_string();
|
||||
Psc::JSON to_Json();
|
||||
std::optional<SSR::Position_3D> get_pos();
|
||||
double get_height();
|
||||
bool has_valid_position();
|
||||
void set_msg(const SSR::HULC_Status_Message& msg);
|
||||
static double theoretical_detection_range_meters(double base_height_meters, double target_height_meters);
|
||||
|
||||
@@ -3,26 +3,6 @@
|
||||
#include <string_view>
|
||||
#include "../server/Global.h"
|
||||
#include "Database.h"
|
||||
Psc::serial::Serial* create_serial(std::string_view serial_name, Baud_Rate_Type baud_rate) {
|
||||
auto serial = new Psc::serial::Serial;
|
||||
serial->set_serial_name(serial_name);
|
||||
serial->set_baud_rate(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);
|
||||
if (!serial->open()) {
|
||||
std::cerr << "createSerial " + std::string(serial_name) + ":" + std::to_string(baud_rate) + " 打开串口失败!\n";
|
||||
Psc::fail_fast();
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
// std::cerr << "createSerial " + serial_name + ":" +
|
||||
// std::to_string(baud_rate) + " 打开串口成功!\n";
|
||||
}
|
||||
return serial;
|
||||
}
|
||||
std::shared_ptr<Data_Source> create_from_json(const JSON* that_json, bool not_exist_use_default_value) {
|
||||
std::string type = that_json->get_string("type");
|
||||
std::shared_ptr<Data_Source> ret = create_data_source_from_type(type);
|
||||
@@ -62,10 +42,6 @@ Data_Source::Data_Source() {
|
||||
});
|
||||
};
|
||||
}
|
||||
std::string Data_Source::thread_key() const {
|
||||
// return "Data_Source_Handle_Thread:[" + key + "]";
|
||||
return key + "_DS_HT";
|
||||
}
|
||||
void File_Data_Source::before_handle_msg(std::shared_ptr<SSR::Mode_Msg>& msg) {
|
||||
auto cur = std::dynamic_pointer_cast<SSR::Mode_Msg>(msg);
|
||||
if (cur != nullptr) {
|
||||
|
||||
@@ -175,7 +175,6 @@ public:
|
||||
co_return;
|
||||
}
|
||||
Frequency_Limit statistic_fl;
|
||||
std::string thread_key() const;
|
||||
Psc::JSON statistic_json() {
|
||||
Psc::JSON ret = With_Loop_Coro::to_base_json();
|
||||
ret.append({"aircraft_total", get_aircraft_num()});
|
||||
|
||||
@@ -233,21 +233,7 @@ void Data_Source_Handler::handle_mode_s(std::shared_ptr<SSR::Mode_S_Msg>& mode_s
|
||||
oss << "\t\tds:" << msg->source->get_key();
|
||||
oss << "\ttime:" << msg->mlat_timestamp.to_string() << std::endl;
|
||||
}
|
||||
// if (have_pos) {
|
||||
// std::cout << oss.str() << std::endl;
|
||||
pure_log("@/logs/mlat.log", oss.str());
|
||||
// }
|
||||
// if (t.size() > 3 && have_pos && icao == "78139F") {
|
||||
// size_t i = 1;
|
||||
// auto range = hex_mlat_map.equal_range(t.msg_hex());
|
||||
// // 遍历与key_to_find对应的所有元素
|
||||
// for (auto it = range.first; it != range.second; ++it) {
|
||||
// oss << "\t" << i++ << " " << it->second.msg << std::endl;
|
||||
// }
|
||||
// oss << "===================================================\n";
|
||||
// std::cout << oss.str() << std::endl;
|
||||
// pure_log("@/logs/icao/" + icao + "_mlat.log", oss.str(), true);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -370,13 +356,13 @@ std::optional<std::string> convert_to_send_format(Data_Source_Handler* ds, const
|
||||
if (!use_status)
|
||||
return std::nullopt;
|
||||
auto data = static_cast<SSR::Msg*>(msg.get());
|
||||
if (output_format == Output_Data_Format::BIN || output_format == Output_Data_Format::BIN_ID) {
|
||||
if (output_format == Output_Data_Format::BIN) {
|
||||
send_msg = SSR::packet_to_escape_format(data->packet);
|
||||
}
|
||||
}
|
||||
else if (type == SSR::Msg::Radarcape_status) {
|
||||
auto data = static_cast<SSR::Msg*>(msg.get());
|
||||
if (output_format == Output_Data_Format::BIN || output_format == Output_Data_Format::BIN_ID) {
|
||||
if (output_format == Output_Data_Format::BIN) {
|
||||
send_msg = SSR::packet_to_escape_format(data->packet);
|
||||
}
|
||||
}
|
||||
@@ -385,21 +371,10 @@ std::optional<std::string> convert_to_send_format(Data_Source_Handler* ds, const
|
||||
return std::nullopt;
|
||||
auto data = static_cast<SSR::Mode_AC_Msg*>(msg.get());
|
||||
std::string& msg_hex = data->msg_hex;
|
||||
char signal_level = data->signal_level;
|
||||
SSR::MLAT_timestamp& mlat_timestamp = data->mlat_timestamp;
|
||||
if (output_format == Output_Data_Format::BIN) {
|
||||
// send_msg = create_Binary_Format_memory(msg_hex, signal_level,
|
||||
// &mlat_timestamp);
|
||||
send_msg = SSR::packet_to_escape_format(msg->packet);
|
||||
}
|
||||
else if (output_format == Output_Data_Format::BIN_ID) {
|
||||
// std::uint32_t id;
|
||||
// {
|
||||
// id = Global::instance()->mlat_server.id;
|
||||
// }
|
||||
// auto bin_id_packet = mode_s_msg_packet_to_server_packet(id,
|
||||
// data->packet); send_msg = packet_to_escape_format(bin_id_packet);
|
||||
}
|
||||
else if (output_format == Output_Data_Format::AVR) {
|
||||
send_msg = SSR::create_AVR_format(msg_hex);
|
||||
}
|
||||
@@ -412,7 +387,6 @@ std::optional<std::string> convert_to_send_format(Data_Source_Handler* ds, const
|
||||
std::string& icao = s_msg->icao;
|
||||
SSR::Downlink_Format& df = s_msg->df;
|
||||
std::string& msg_hex = s_msg->msg_hex;
|
||||
auto& signal_level = s_msg->signal_level;
|
||||
SSR::MLAT_timestamp& mlat_timestamp = s_msg->mlat_timestamp;
|
||||
auto aircraft = ds->get_aircraft(s_msg->icao);
|
||||
if (output_format == Output_Data_Format::SBS) {
|
||||
@@ -462,16 +436,6 @@ std::optional<std::string> convert_to_send_format(Data_Source_Handler* ds, const
|
||||
}
|
||||
if (output_format == Output_Data_Format::BIN) {
|
||||
send_msg = SSR::packet_to_escape_format(s_msg->packet);
|
||||
// send_msg = create_Binary_Format_memory(msg_hex, signal_level,
|
||||
// &mlat_timestamp);
|
||||
}
|
||||
else if (output_format == Output_Data_Format::BIN_ID) {
|
||||
// std::uint32_t id;
|
||||
// {
|
||||
// id = Global::instance()->mlat_server.id;
|
||||
// }
|
||||
// auto bin_id_packet = mode_s_msg_packet_to_server_packet(id,
|
||||
// data->packet); send_msg = packet_to_escape_format(bin_id_packet);
|
||||
}
|
||||
else if (output_format == Output_Data_Format::AVR) {
|
||||
send_msg = SSR::create_AVR_format(msg_hex);
|
||||
|
||||
@@ -407,14 +407,6 @@ Psc::JSON DataBase::aircraft_change_item_json(SSR::Aircraft_Info *info) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
JSON DataBase::get_all_aircraft_json() {
|
||||
JSON json = JSON::array();
|
||||
for (auto &it : get_visible_aircraft_snapshot()) {
|
||||
json.children.push_back(aircraft_change_item_json(it.get()));
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
Psc::JSON DataBase::get_aircraft_change_update_json(
|
||||
std::unordered_map<std::string, std::string> &client_versions) {
|
||||
JSON ret = JSON::object();
|
||||
|
||||
@@ -159,7 +159,6 @@ public:
|
||||
return key;
|
||||
}
|
||||
std::atomic<size_t> have_pos_aircraft_num{};
|
||||
Psc::JSON get_all_aircraft_json();
|
||||
std::vector<std::shared_ptr<SSR::Aircraft_Info>> get_visible_aircraft_snapshot();
|
||||
std::uint64_t aircraft_change_version(SSR::Aircraft_Info* info);
|
||||
Psc::JSON aircraft_change_item_json(SSR::Aircraft_Info* info);
|
||||
|
||||
Reference in New Issue
Block a user