This commit is contained in:
2026-07-28 14:51:38 +08:00
parent 259b7b54a4
commit 35b18c3e98
7 changed files with 49 additions and 24 deletions
@@ -1,38 +1,38 @@
#include "BaseStation.h"
#include "Base_Station.h"
namespace SSR {
struct HULC_Status_Message;
}
double BaseStation::theoretical_detection_range_meters(double base_height_meters,
double Base_Station::theoretical_detection_range_meters(double base_height_meters,
double target_height_meters) {
return static_cast<double>(SSR::CPR::radio_line_of_sight_range_meters(base_height_meters, target_height_meters));
}
std::optional<SSR::Position_3D> BaseStation::get_pos() {
std::optional<SSR::Position_3D> Base_Station::get_pos() {
std::lock_guard g(mtx);
if (!hulc.GPS_has_valid_fix()) {
return std::nullopt;
}
return SSR::Position_3D{hulc.get_latitude(), hulc.get_longitude(), static_cast<SSR::CPR::D>(hulc.Alt)};
}
double BaseStation::get_height() {
double Base_Station::get_height() {
std::lock_guard g(mtx);
return hulc.Alt;
}
bool BaseStation::has_valid_position() {
bool Base_Station::has_valid_position() {
std::lock_guard g(mtx);
return hulc.GPS_has_valid_fix();
}
void BaseStation::set_msg(const SSR::HULC_Status_Message &msg) {
void Base_Station::set_msg(const SSR::HULC_Status_Message &msg) {
std::lock_guard g(mtx);
hulc = msg;
if (handle_when_updated)
handle_when_updated(msg);
}
std::string BaseStation::to_string() {
std::string Base_Station::to_string() {
std::lock_guard g(mtx);
return "BaseStation:[" + std::to_string(hulc.get_latitude()) + ", " +
std::to_string(hulc.get_longitude()) + "]";
}
Psc::JSON BaseStation::to_Json() {
Psc::JSON Base_Station::to_Json() {
std::lock_guard g(mtx);
auto ret = Psc::JSON::object();
ret.append({"序列号", hulc.SerNum});
@@ -1,6 +1,6 @@
#pragma once
#include "global.h"
class BaseStation {
class Base_Station {
public:
std::string to_string();
Psc::JSON to_Json();
+1 -1
View File
@@ -541,7 +541,7 @@ void database_server(Global *g) {
ret = db->base_station.to_Json();
auto target_height =
g->mode_acs.adsb_theoretical_target_altitude_meters.load();
auto range = BaseStation::theoretical_detection_range_meters(db->alt,
auto range = Base_Station::theoretical_detection_range_meters(db->alt,
target_height);
ret.append({"latitude", db->lat});
ret.append({"longitude", db->lon});
+7 -7
View File
@@ -1,15 +1,15 @@
#pragma once
#include <string_view>
#include "../Aircraft/Aircraft.h"
#include "../Aircraft/Flight_VTO.h"
#include "../External_Database/export.h"
#include "BaseStation.h"
#include "Local_Server/server/With_Loop_Coro.h"
#include <functional>
#include <memory>
#include <shared_mutex>
#include <string_view>
#include <unordered_map>
#include <vector>
#include "../Aircraft/Aircraft.h"
#include "../Aircraft/Flight_VTO.h"
#include "../External_Database/export.h"
#include "Base_Station.h"
#include "Local_Server/server/With_Loop_Coro.h"
template <
typename Key_Type,
typename Value_Type,
@@ -153,7 +153,7 @@ public:
std::shared_ptr<SSR::Aircraft_Info> create_aircraft(std::string_view icao) override;
Psc::JSON get_aircraftlist();
Psc::JSON get_aircraftlist(int limit_msg_num);
BaseStation base_station;
Base_Station base_station;
void delete_timeout_aircraft();
std::string get_key() override {
return key;