cmake库改造前
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#ifndef ADS_B_HPP
|
||||
#define ADS_B_HPP
|
||||
#include <format>
|
||||
#include <json/config.h>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include "../ACAS/ACAS_9_56.hpp"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <string_view>
|
||||
#include "Core/Statistics/Frequency_Limit.h"
|
||||
#include "Psc_Cpp_Core/Statistics/Frequency_Limit.h"
|
||||
#include "convert/SBS.h"
|
||||
#include "export.h"
|
||||
using namespace Psc;
|
||||
@@ -84,7 +84,6 @@ void set_logger(BaseLogger* logger) {
|
||||
delete mode_s_logger;
|
||||
mode_s_logger = logger;
|
||||
}
|
||||
|
||||
bool parse_absb_17(SSR::Data_Source_Interface* src, SSR::P_S mode_s_msg, JSON& msg_json,
|
||||
std::optional<Position_3D> base_station_pos, const SSR::ADS_B_T::Constraint& air_constraint,
|
||||
const SSR::ADS_B_T::Constraint& surface_constraint) {
|
||||
|
||||
+11
-17
@@ -1,18 +1,17 @@
|
||||
#pragma once
|
||||
#include <functional>
|
||||
#include <string_view>
|
||||
#include "Core/system/export.h"
|
||||
#include "ACAS/ACAS.h"
|
||||
#include "ADS_B/ADS_B.h"
|
||||
#include "Commb/Commb.h"
|
||||
#include "Mode_S/Mode_S.h"
|
||||
#include "Msg.h"
|
||||
#include "Psc_Cpp_Core/system/export.h"
|
||||
#include "convert/DataOutputFormats.h"
|
||||
#include <functional>
|
||||
namespace SSR {
|
||||
#define GET_PRE(name) \
|
||||
std::lock_guard<std::mutex> lock(name.mtx.mtx); \
|
||||
if (!name.value.has_value()) \
|
||||
{ \
|
||||
if (!name.value.has_value()) { \
|
||||
return std::nullopt; \
|
||||
} \
|
||||
auto& w = name.value.value();
|
||||
@@ -86,8 +85,7 @@ public:
|
||||
}
|
||||
virtual Psc::JSON toJson() {
|
||||
Psc::JSON ret = Psc::JSON::object();
|
||||
Ret_J(icao)
|
||||
ret.append({"每秒位置数", get_pest()});
|
||||
Ret_J(icao) ret.append({"每秒位置数", get_pest()});
|
||||
ret.append({"飞机位置轨迹点数", air_pos_track_list.size()});
|
||||
ret.append({"地面位置轨迹点数", surface_pos_track_list.size()});
|
||||
ret.append({"信号强度", signal_level});
|
||||
@@ -171,8 +169,8 @@ public:
|
||||
}
|
||||
RET<bool> is_on_ground() {
|
||||
GET_PRE(Reply_Base_builder)
|
||||
if (w.get_flight_status() == Flight_Status::alert_on_ground || w.get_flight_status() ==
|
||||
Flight_Status::no_alert_on_ground) {
|
||||
if (w.get_flight_status() == Flight_Status::alert_on_ground ||
|
||||
w.get_flight_status() == Flight_Status::no_alert_on_ground) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -185,7 +183,8 @@ public:
|
||||
RET<double> vertical_rate() {
|
||||
GET_PRE(BDS09_Base)
|
||||
auto v = w.get_vertical_rate();
|
||||
if (!v.has_value()) return std::nullopt;
|
||||
if (!v.has_value())
|
||||
return std::nullopt;
|
||||
return v.value() * aero::fpm;
|
||||
}
|
||||
RET<CPR::Position> pos() {
|
||||
@@ -194,7 +193,8 @@ public:
|
||||
// if (it.get_lat().has_value() && it.get_lon().has_value()) {
|
||||
// return CPR::Position{it.get_lat().value(), it.get_lon().value()};
|
||||
// }
|
||||
if (surface_pos_track_list.empty()) return std::nullopt;
|
||||
if (surface_pos_track_list.empty())
|
||||
return std::nullopt;
|
||||
return surface_pos_track_list.last();
|
||||
}
|
||||
RET<double> select_heading() {
|
||||
@@ -210,13 +210,9 @@ public:
|
||||
return w.get_magnetic_heading();
|
||||
}
|
||||
RET<double> altitude_meter() {
|
||||
|
||||
|
||||
|
||||
GET_PRE(BDS05_airborne_position)
|
||||
return w.get_alt_meter();
|
||||
}
|
||||
|
||||
RET<Vortex_Type> vortex_type() {
|
||||
GET_PRE(BDS08_id)
|
||||
return w.get_vortex_type();
|
||||
@@ -291,6 +287,4 @@ public:
|
||||
this->timestamp = std::time(nullptr);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
} // namespace SSR
|
||||
|
||||
+16
-25
@@ -1,20 +1,21 @@
|
||||
#pragma once
|
||||
#include <string_view>
|
||||
#include "Core/Base/JSON.h"
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <tuple>
|
||||
#include "Psc_Cpp_Core/Base/JSON.h"
|
||||
namespace SSR {
|
||||
namespace CPR {
|
||||
using Time = long double;
|
||||
using D = long double;
|
||||
using I = std::int64_t;
|
||||
struct Position {
|
||||
Position(D lat, D lon) : lat(lat), lon(lon) {}
|
||||
Position(D lat, D lon) : lat(lat), lon(lon) {
|
||||
}
|
||||
D lat;
|
||||
D lon;
|
||||
[[nodiscard]] std::string to_string() const;
|
||||
@@ -70,9 +71,11 @@ inline std::optional<std::tuple<Position, Position>> surface_global_decode(I YZ0
|
||||
auto [pos0, pos1] = poses.value();
|
||||
return std::tuple(pos0, pos1);
|
||||
}
|
||||
inline std::optional<std::tuple<Position, Position>> surface_global_decode_ref(I YZ0, I YZ1, I XZ0, I XZ1, D lat_s, D lon_s) {
|
||||
inline std::optional<std::tuple<Position, Position>> surface_global_decode_ref(I YZ0, I YZ1, I XZ0, I XZ1, D lat_s,
|
||||
D lon_s) {
|
||||
auto poses = surface_global_decode(YZ0, YZ1, XZ0, XZ1);
|
||||
if (!poses.has_value()) return std::nullopt;
|
||||
if (!poses.has_value())
|
||||
return std::nullopt;
|
||||
auto [pos0, pos1] = poses.value();
|
||||
auto p0 = Position{bb(pos0.lat, lat_s), bb(pos0.lon, lon_s)};
|
||||
auto p1 = Position{bb(pos1.lat, lat_s), bb(pos1.lon, lon_s)};
|
||||
@@ -88,24 +91,14 @@ inline POS surface_locale_decode(D lat_s, D lon_s, I YZi, I XZi, I i) {
|
||||
return Position{bb(lat, lat_s), bb(lon, lon_s)};
|
||||
}
|
||||
// time
|
||||
std::string lat_lon_airborne_34(double latitude, double longitude,
|
||||
CPR::Frame cpr_format);
|
||||
std::optional<Position> airborne_position(std::string_view msg0,
|
||||
std::string_view msg1, Time t0,
|
||||
Time t1);
|
||||
std::optional<Position> airborne_position_with_ref(std::string_view msg_bin,
|
||||
double lat_ref,
|
||||
double lon_ref, Time t,
|
||||
std::string lat_lon_airborne_34(double latitude, double longitude, CPR::Frame cpr_format);
|
||||
std::optional<Position> airborne_position(std::string_view msg0, std::string_view msg1, Time t0, Time t1);
|
||||
std::optional<Position> airborne_position_with_ref(std::string_view msg_bin, double lat_ref, double lon_ref, Time t,
|
||||
Time t_ref);
|
||||
std::string lat_lon_surface_34(double latitude, double longitude,
|
||||
CPR::Frame cpr_format);
|
||||
std::optional<Position> surface_position(std::string_view msg0,
|
||||
std::string_view msg1, Time t0,
|
||||
Time t1,
|
||||
std::string lat_lon_surface_34(double latitude, double longitude, CPR::Frame cpr_format);
|
||||
std::optional<Position> surface_position(std::string_view msg0, std::string_view msg1, Time t0, Time t1,
|
||||
const CPR::Position& base_station_pos);
|
||||
std::optional<Position> surface_position_with_ref(std::string_view msg_bin,
|
||||
double lat_ref,
|
||||
double lon_ref, Time t,
|
||||
std::optional<Position> surface_position_with_ref(std::string_view msg_bin, double lat_ref, double lon_ref, Time t,
|
||||
Time t_ref);
|
||||
// YZ, NZ, i
|
||||
std::tuple<CPR::I, CPR::I, CPR::I> get(std::string_view msg_bin);
|
||||
@@ -125,10 +118,8 @@ std::tuple<I, I> light_time_second_nano(const Position& p1, const Position& p2);
|
||||
// (Longitude):表示经度,用来指示一个点在地球表面相对于本初子午线的角度。它的范围是从
|
||||
// -180° 到 +180°。 H
|
||||
// (Height):表示高度,通常指的是该点相对于海平面的高度,单位通常是米(m)。
|
||||
void WGS84_LBH_to_XYZ(double longitude, double latitude, double height,
|
||||
double& X, double& Y, double& Z);
|
||||
void XYZ_to_WGS84_LBH(double X, double Y, double Z, double& longitude,
|
||||
double& latitude, double& altitude);
|
||||
void WGS84_LBH_to_XYZ(double longitude, double latitude, double height, double& X, double& Y, double& Z);
|
||||
void XYZ_to_WGS84_LBH(double X, double Y, double Z, double& longitude, double& latitude, double& altitude);
|
||||
} // namespace CPR
|
||||
} // namespace SSR
|
||||
#include <format>
|
||||
|
||||
+9
-21
@@ -1,28 +1,20 @@
|
||||
#pragma once
|
||||
#include <string_view>
|
||||
#include "../HPP.h"
|
||||
#include "Core/Base/global_include.h"
|
||||
#include "Psc_Cpp_Core/Base/global_include.h"
|
||||
namespace SSR {
|
||||
void check_icao(std::string_view icao);
|
||||
namespace T {
|
||||
template <typename That>
|
||||
struct Reply_Base_Builder {
|
||||
PROP_T(std::string, icao, std::string {}
|
||||
);
|
||||
PROP_T(std::string, icao, std::string{});
|
||||
PROP_T(Downlink_Format, df, Downlink_Format::Unknown)
|
||||
PROP_T(Transponder_Capability, transponder_capability,
|
||||
Transponder_Capability::Level_2_plus_airborne)
|
||||
PROP_T(Transponder_Capability, transponder_capability, Transponder_Capability::Level_2_plus_airborne)
|
||||
PROP_T(Flight_Status, flight_status, Flight_Status::not_assigned)
|
||||
PROP_T(Downlink_Request, downlink_request, Downlink_Request::no_request)
|
||||
PROP_T(IDS, ids, IDS::no_information)
|
||||
PROP_Bit_T (
|
||||
|
||||
4
|
||||
,
|
||||
IIS
|
||||
,
|
||||
0
|
||||
) // 询问器标识符代码
|
||||
PROP_Bit_T(4, IIS,
|
||||
0) // 询问器标识符代码
|
||||
void parse(std::string& msg_bin) {
|
||||
icao = decode_icao(msg_bin);
|
||||
df = decode_df(msg_bin);
|
||||
@@ -51,8 +43,7 @@ protected:
|
||||
void set(std::string& msg_bin) {
|
||||
check_icao(icao);
|
||||
PSC_ASSERT(msg_bin.size() == 56 || msg_bin.size() == 112,
|
||||
" Reply_Base_Builder error size == " +
|
||||
std::to_string(msg_bin.size()));
|
||||
" Reply_Base_Builder error size == " + std::to_string(msg_bin.size()));
|
||||
SSR::set_transponder_capability(msg_bin, transponder_capability);
|
||||
set_bin<5, 3>(msg_bin, static_cast<int>(flight_status));
|
||||
set_bin<8, 5>(msg_bin, static_cast<int>(downlink_request));
|
||||
@@ -60,8 +51,7 @@ protected:
|
||||
set_bin<17, 2>(msg_bin, static_cast<int>(ids));
|
||||
}
|
||||
};
|
||||
T_Parser(Reply_Base_Builder)
|
||||
template <typename That>
|
||||
T_Parser(Reply_Base_Builder) template <typename That>
|
||||
struct Alt {
|
||||
PROP_T(int, altitude, 0)
|
||||
void parse(std::string& msg_bin) {
|
||||
@@ -77,8 +67,7 @@ protected:
|
||||
set_bin<19, 13>(msg_bin, encode_altitude13_feet(altitude));
|
||||
}
|
||||
};
|
||||
T_Parser(Alt)
|
||||
template <typename That>
|
||||
T_Parser(Alt) template <typename That>
|
||||
struct Id {
|
||||
// ATC Mode A 所使用的代码
|
||||
PROP_T(std::string, ATC_Squawk, "0000")
|
||||
@@ -95,8 +84,7 @@ protected:
|
||||
set_bin<19, 13>(msg_bin, encode_squawk13(ATC_Squawk));
|
||||
}
|
||||
};
|
||||
T_Parser(Id)
|
||||
template <typename That>
|
||||
T_Parser(Id) template <typename That>
|
||||
struct Surveillance_Altitude_Reply : Alt<That>, BDS_ {
|
||||
void set(std::string& msg_bin) {
|
||||
set_df(msg_bin, Downlink_Format::Surveillance_Altitude_Reply_4);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
#include <string_view>
|
||||
#include "CPR/CPR.h"
|
||||
#include "Core/Base/global_include.h"
|
||||
#include "convert/DataOutputFormats.h"
|
||||
#include "enum.h"
|
||||
#include <functional>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
#include "CPR/CPR.h"
|
||||
#include "Psc_Cpp_Core/Base/global_include.h"
|
||||
#include "convert/DataOutputFormats.h"
|
||||
#include "enum.h"
|
||||
#define STRINGIFY(x) #x
|
||||
// 硬件接收来的 二进制消息族
|
||||
namespace SSR {
|
||||
@@ -55,10 +55,8 @@ struct Play_Back_Time_Point {
|
||||
std::uint32_t second{};
|
||||
[[nodiscard]] std::string to_string() const {
|
||||
std::ostringstream oss;
|
||||
oss << std::setfill('0')
|
||||
<< std::setw(2) << hour << ':'
|
||||
<< std::setw(2) << minute << ':'
|
||||
<< std::setw(2) << second;
|
||||
oss << std::setfill('0') << std::setw(2) << hour << ':' << std::setw(2) << minute << ':' << std::setw(2)
|
||||
<< second;
|
||||
return oss.str();
|
||||
}
|
||||
};
|
||||
@@ -71,8 +69,8 @@ struct Play_Back_Time_Point {
|
||||
}
|
||||
[[nodiscard]] std::string to_string() const {
|
||||
std::ostringstream oss;
|
||||
oss << "Play_Back_Time_Point[" << day_num << ',' << hms().to_string()
|
||||
<< '.' << std::setfill('0') << std::setw(9) << nanosec << ']';
|
||||
oss << "Play_Back_Time_Point[" << day_num << ',' << hms().to_string() << '.' << std::setfill('0')
|
||||
<< std::setw(9) << nanosec << ']';
|
||||
return oss.str();
|
||||
}
|
||||
void normalize() noexcept {
|
||||
@@ -98,9 +96,7 @@ struct Play_Back_Time_Point {
|
||||
return nanosec < other.nanosec;
|
||||
}
|
||||
bool operator==(const Play_Back_Time_Point& other) const noexcept {
|
||||
return day_num == other.day_num &&
|
||||
day_sec == other.day_sec &&
|
||||
nanosec == other.nanosec;
|
||||
return day_num == other.day_num && day_sec == other.day_sec && nanosec == other.nanosec;
|
||||
}
|
||||
bool operator>(const Play_Back_Time_Point& other) const noexcept {
|
||||
return other < *this;
|
||||
@@ -112,8 +108,7 @@ struct Play_Back_Time_Point {
|
||||
return !(*this < other);
|
||||
}
|
||||
[[nodiscard]] double abs_sec() const noexcept {
|
||||
return static_cast<double>(day_num) * static_cast<double>(SECS_PER_DAY) +
|
||||
static_cast<double>(day_sec) +
|
||||
return static_cast<double>(day_num) * static_cast<double>(SECS_PER_DAY) + static_cast<double>(day_sec) +
|
||||
static_cast<double>(nanosec) / static_cast<double>(NANOSECS_PER_SEC);
|
||||
}
|
||||
void add_sec(std::uint64_t sec) noexcept {
|
||||
@@ -144,15 +139,11 @@ public:
|
||||
std::string msg_hex;
|
||||
std::string msg_bin;
|
||||
char signal_level{};
|
||||
explicit Mode_Msg(const std::shared_ptr<Data_Source_Interface>& source,
|
||||
std::string_view packet);
|
||||
explicit Mode_Msg(const std::shared_ptr<Data_Source_Interface>& source, std::string_view packet);
|
||||
Psc::JSON to_Json() override {
|
||||
Psc::JSON ret = Msg::to_Json();
|
||||
Ret_J(msg_hex)
|
||||
Ret_J(signal_level)
|
||||
ret.append({"mlat_timestamp", mlat_timestamp.to_string()});
|
||||
Ret_J(day_num)
|
||||
return ret;
|
||||
Ret_J(msg_hex) Ret_J(signal_level) ret.append({"mlat_timestamp", mlat_timestamp.to_string()});
|
||||
Ret_J(day_num) return ret;
|
||||
}
|
||||
~Mode_Msg() override;
|
||||
Play_Back_Time_Point time() {
|
||||
@@ -165,8 +156,7 @@ public:
|
||||
};
|
||||
class Mode_AC_Msg : public Mode_Msg {
|
||||
public:
|
||||
explicit Mode_AC_Msg(const std::shared_ptr<Data_Source_Interface>& source,
|
||||
std::string_view packet);
|
||||
explicit Mode_AC_Msg(const std::shared_ptr<Data_Source_Interface>& source, std::string_view packet);
|
||||
~Mode_AC_Msg() override;
|
||||
};
|
||||
// 1 + 1 + 6 + 1 + 2/7/14
|
||||
@@ -183,8 +173,7 @@ public:
|
||||
return ret;
|
||||
}
|
||||
// 1a 31 19 b2dd1c7af671 3220
|
||||
explicit Mode_S_Msg(const std::shared_ptr<Data_Source_Interface>& source,
|
||||
std::string_view packet);
|
||||
explicit Mode_S_Msg(const std::shared_ptr<Data_Source_Interface>& source, std::string_view packet);
|
||||
~Mode_S_Msg() override;
|
||||
std::string to_string() override {
|
||||
auto& time = mlat_timestamp;
|
||||
@@ -202,7 +191,8 @@ public:
|
||||
};
|
||||
struct Position_3D : CPR::Position {
|
||||
CPR::D alt;
|
||||
Position_3D(CPR::D lat, CPR::D lon, CPR::D alt) : CPR::Position(lat, lon), alt(alt) {}
|
||||
Position_3D(CPR::D lat, CPR::D lon, CPR::D alt) : CPR::Position(lat, lon), alt(alt) {
|
||||
}
|
||||
};
|
||||
// 这个返回值的意义在于 解码失败后 返回值能反应出是 位置解码失败
|
||||
// 还是奇偶报文解码位置失败 轨迹点上会显示的信息
|
||||
@@ -210,27 +200,24 @@ class Pos_Ret {
|
||||
public:
|
||||
CPR::Position pos;
|
||||
Psc::JSON info;
|
||||
Pos_Ret(CPR::Position p, Psc::JSON info) : pos(p), info(std::move(info)) {}
|
||||
Pos_Ret(CPR::Position p, Psc::JSON info) : pos(p), info(std::move(info)) {
|
||||
}
|
||||
};
|
||||
// 展示出最详细的信息
|
||||
struct Position_Info : Position_3D {
|
||||
std::int64_t sys_day_ns{};
|
||||
std::uint64_t utc{};
|
||||
std::uint64_t odd_even_diff_ns{};
|
||||
Position_Info() : Position_3D(0.0, 0.0, 0.0) {}
|
||||
Position_Info() : Position_3D(0.0, 0.0, 0.0) {
|
||||
}
|
||||
Psc::JSON info;
|
||||
Position_Info(const Pos_Ret& r, CPR::D alt) : Position_3D(r.pos.lat, r.pos.lon, alt), info(r.info) {
|
||||
using namespace std::chrono;
|
||||
utc = static_cast<std::uint64_t>(
|
||||
duration_cast<seconds>(system_clock::now().time_since_epoch()).count());
|
||||
utc = static_cast<std::uint64_t>(duration_cast<seconds>(system_clock::now().time_since_epoch()).count());
|
||||
}
|
||||
Psc::JSON to_json() {
|
||||
Psc::JSON ret = Psc::JSON::object();
|
||||
Ret_J(lat)
|
||||
Ret_J(lon)
|
||||
Ret_J(alt)
|
||||
Ret_J(utc)
|
||||
ret.append_list(info.children);
|
||||
Ret_J(lat) Ret_J(lon) Ret_J(alt) Ret_J(utc) ret.append_list(info.children);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
@@ -262,7 +249,8 @@ struct POS_List {
|
||||
}
|
||||
std::optional<Position_Info> last() {
|
||||
std::lock_guard g(mtx.mtx);
|
||||
if (count == 0) return std::nullopt;
|
||||
if (count == 0)
|
||||
return std::nullopt;
|
||||
std::size_t idx = (head + max_size - 1) % max_size;
|
||||
return buf[idx];
|
||||
}
|
||||
@@ -271,7 +259,8 @@ struct POS_List {
|
||||
std::lock_guard g(mtx.mtx);
|
||||
buf[head] = std::move(new_position);
|
||||
head = (head + 1) % max_size;
|
||||
if (count < max_size) ++count;
|
||||
if (count < max_size)
|
||||
++count;
|
||||
++seq;
|
||||
}
|
||||
Psc::JSON get_last_array_json(std::uint64_t last_seq);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "DataOutputFormats.h"
|
||||
#include "Core/Base/global_include.h"
|
||||
#include "Psc_Cpp_Core/Base/global_include.h"
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
#include <string_view>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
#include <string_view>
|
||||
#include "Core/Base/JSON.h"
|
||||
#include "SSR/global.h"
|
||||
#include <cstring>
|
||||
#include <string_view>
|
||||
#include "Psc_Cpp_Core/Base/JSON.h"
|
||||
#include "SSR/global.h"
|
||||
namespace SSR {
|
||||
// 1纳秒是 10 -9次方秒
|
||||
struct MLAT_timestamp {
|
||||
@@ -29,16 +29,12 @@ struct MLAT_timestamp {
|
||||
Psc::JSON ret = Psc::JSON::object();
|
||||
ret.append({"秒", daysec});
|
||||
ret.append({"纳秒", nanosec});
|
||||
ret.append({
|
||||
"时间", std::to_string(hh) + ":" + std::to_string(mm) + ":" +
|
||||
std::to_string(ss)
|
||||
});
|
||||
ret.append({"时间", std::to_string(hh) + ":" + std::to_string(mm) + ":" + std::to_string(ss)});
|
||||
return ret;
|
||||
}
|
||||
[[nodiscard]] std::string to_string() const {
|
||||
return "{" + std::to_string(daysec) + "," + std::to_string(nanosec) + "}_" +
|
||||
"[" + std::to_string(hh) + "时:" + std::to_string(mm) +
|
||||
"分:" + std::to_string(ss) +
|
||||
return "{" + std::to_string(daysec) + "," + std::to_string(nanosec) + "}_" + "[" + std::to_string(hh) +
|
||||
"时:" + std::to_string(mm) + "分:" + std::to_string(ss) +
|
||||
"秒"
|
||||
"]";
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
#include "py_Mode_S/Common.h"
|
||||
#include "export_type.h"
|
||||
#include <string_view>
|
||||
#include "Core/Statistics/Statistics.h"
|
||||
#include "Psc_Cpp_Core/Statistics/Statistics.h"
|
||||
namespace SSR {
|
||||
void set_logger(BaseLogger* logger);
|
||||
using Parse_Call_Back = std::function<void(
|
||||
|
||||
+28
-40
@@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#include <string_view>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
@@ -14,11 +13,12 @@
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "Core/Base/global_include.h"
|
||||
#include "Core/spdlog/export.h"
|
||||
#include "Psc_Cpp_Core/Base/global_include.h"
|
||||
#include "Psc_Cpp_Core/spdlog/export.h"
|
||||
namespace SSR {
|
||||
extern BaseLogger* mode_s_logger;
|
||||
std::string crc_hex(std::string_view msg_bin, bool encode);
|
||||
@@ -26,10 +26,9 @@ int crc(std::string_view msg_bin, bool encode = false);
|
||||
std::string decode_icao(std::string_view msg_bin);
|
||||
template <typename T>
|
||||
void handle_range_error(std::string_view log_pos, std::string_view field_name, T value, double min, double max) {
|
||||
std::string range =
|
||||
"[" + std::to_string(min) + "," + std::to_string(max) + "]";
|
||||
std::string error_info = "ERROR:" + std::string(field_name) + ":" + std::to_string(value) +
|
||||
"超出范围:" + range + "\n";
|
||||
std::string range = "[" + std::to_string(min) + "," + std::to_string(max) + "]";
|
||||
std::string error_info =
|
||||
"ERROR:" + std::string(field_name) + ":" + std::to_string(value) + "超出范围:" + range + "\n";
|
||||
Log_Type type({}, {{"POS", std::string(log_pos)}});
|
||||
mode_s_logger->error("out of range", type, error_info);
|
||||
// #ifdef WIN32
|
||||
@@ -39,25 +38,24 @@ void handle_range_error(std::string_view log_pos, std::string_view field_name, T
|
||||
// throw std::runtime_error(error_info);
|
||||
}
|
||||
template <typename T>
|
||||
void handle_range_error(std::string_view log_pos,
|
||||
std::string_view field_name, std::optional<T> value,
|
||||
double min, double max) {
|
||||
void handle_range_error(std::string_view log_pos, std::string_view field_name, std::optional<T> value, double min,
|
||||
double max) {
|
||||
handle_range_error(log_pos, field_name, value.value(), min, max);
|
||||
}
|
||||
#define PROP(TYPE, FIELD, DEFAULT) \
|
||||
private: \
|
||||
TYPE FIELD = DEFAULT; \
|
||||
\
|
||||
public: \
|
||||
Builder& set_##FIELD(TYPE value) { \
|
||||
this->FIELD = std::move(value); \
|
||||
return *this; \
|
||||
} \
|
||||
TYPE get_##FIELD() { return this->FIELD; }
|
||||
TYPE get_##FIELD() { \
|
||||
return this->FIELD; \
|
||||
}
|
||||
#define PROP_Bit(bits, FIELD, DEFAULT) \
|
||||
private: \
|
||||
int FIELD = DEFAULT; \
|
||||
\
|
||||
public: \
|
||||
Builder& set_##FIELD(int value) { \
|
||||
int MIN = 0; \
|
||||
@@ -90,7 +88,6 @@ public: \
|
||||
#define PROP_T(TYPE, FIELD, DEFAULT) \
|
||||
protected: \
|
||||
TYPE FIELD = DEFAULT; \
|
||||
\
|
||||
public: \
|
||||
That& set_##FIELD(TYPE value) { \
|
||||
static_cast<That*>(this)->FIELD = std::move(value); \
|
||||
@@ -103,7 +100,6 @@ public: \
|
||||
#define PROP_Range(TYPE, MIN, MAX, FIELD, DEFAULT) \
|
||||
private: \
|
||||
TYPE FIELD = DEFAULT; \
|
||||
\
|
||||
public: \
|
||||
Builder& set_##FIELD(const TYPE& value) { \
|
||||
if (value < MIN || value > MAX) { \
|
||||
@@ -123,7 +119,6 @@ public: \
|
||||
#define PROP_Bit_T_Base(Type, bits, FIELD, DEFAULT) \
|
||||
protected: \
|
||||
Type FIELD = DEFAULT; \
|
||||
\
|
||||
public: \
|
||||
That& set_##FIELD(Type value) { \
|
||||
int MIN = 0; \
|
||||
@@ -143,14 +138,11 @@ public: \
|
||||
} \
|
||||
return value; \
|
||||
}
|
||||
#define PROP_Bit_T(bits, FIELD, DEFAULT) \
|
||||
PROP_Bit_T_Base(unsigned char, bits, FIELD, DEFAULT)
|
||||
#define PROP_Bit_32T(bits, FIELD, DEFAULT) \
|
||||
PROP_Bit_T_Base(unsigned int, bits, FIELD, DEFAULT)
|
||||
#define PROP_Bit_T(bits, FIELD, DEFAULT) PROP_Bit_T_Base(unsigned char, bits, FIELD, DEFAULT)
|
||||
#define PROP_Bit_32T(bits, FIELD, DEFAULT) PROP_Bit_T_Base(unsigned int, bits, FIELD, DEFAULT)
|
||||
#define PROP_Range_T(TYPE, MIN, MAX, FIELD, DEFAULT) \
|
||||
private: \
|
||||
TYPE FIELD = DEFAULT; \
|
||||
\
|
||||
public: \
|
||||
That& set_##FIELD(const TYPE& value) { \
|
||||
if (value < MIN - std::numeric_limits<double>::epsilon() || \
|
||||
@@ -179,7 +171,9 @@ public: \
|
||||
this->set_crc(ret.msg, this->icao, this->bds()); \
|
||||
return ret; \
|
||||
} \
|
||||
void parse(std::string &msg) { T1::parse(msg); } \
|
||||
void parse(std::string& msg) { \
|
||||
T1::parse(msg); \
|
||||
} \
|
||||
Psc::JSON toJson() { \
|
||||
Psc::JSON ret = Psc::JSON::object(); \
|
||||
ret.append_list(T1::toJson().children); \
|
||||
@@ -289,13 +283,11 @@ struct Base_112 {
|
||||
#define ADD_112_1(NAME, _T1) BaseADD1(NAME, Base_112, _T1)
|
||||
#define ADD_112_2(NAME, _T1, _T2) BaseADD2(NAME, Base_112, _T1, _T2)
|
||||
#define ADD_112_3(NAME, _T1, _T2, _T3) BaseADD3(NAME, Base_112, _T1, _T2, _T3)
|
||||
#define ADD_112_4(NAME, _T1, _T2, _T3, _T4) \
|
||||
BaseADD4(NAME, Base_112, _T1, _T2, _T3, _T4)
|
||||
#define ADD_112_4(NAME, _T1, _T2, _T3, _T4) BaseADD4(NAME, Base_112, _T1, _T2, _T3, _T4)
|
||||
#define ADD_56_1(NAME, _T1) BaseADD1(NAME, Base_56, _T1)
|
||||
#define ADD_56_2(NAME, _T1, _T2) BaseADD2(NAME, Base_56, _T1, _T2)
|
||||
#define ADD_56_3(NAME, _T1, _T2, _T3) BaseADD3(NAME, Base_56, _T1, _T2, _T3)
|
||||
#define ADD_56_4(NAME, _T1, _T2, _T3, _T4) \
|
||||
BaseADD4(NAME, Base_56, _T1, _T2, _T3, _T4)
|
||||
#define ADD_56_4(NAME, _T1, _T2, _T3, _T4) BaseADD4(NAME, Base_56, _T1, _T2, _T3, _T4)
|
||||
#define T_Parser(Template_name) \
|
||||
struct Parser_##Template_name : Template_name<Parser_##Template_name> {};
|
||||
// 模式 S 使用三种类型的奇偶校验。
|
||||
@@ -320,14 +312,12 @@ struct with_PI {
|
||||
// All call reply 是基于审讯的报文,PI是 询问器设备码 和 crc 异或而成的
|
||||
// 所以,必须知道询问器标识符 才能校验是否有错误
|
||||
// 每个设备应该只有一个询问器标识符
|
||||
static bool check_crc(std::string& msg_bin, std::string icao_hex,
|
||||
std::string bds = "") {
|
||||
static bool check_crc(std::string& msg_bin, std::string icao_hex, std::string bds = "") {
|
||||
auto crc_24 = std::bitset<24>(crc(msg_bin, true)).to_string();
|
||||
auto last_24 = msg_bin.substr(msg_bin.size() - 24);
|
||||
return crc_24 == last_24;
|
||||
}
|
||||
static std::string parse_transponder_address(std::string& msg_bin,
|
||||
std::string icao_hex) {
|
||||
static std::string parse_transponder_address(std::string& msg_bin, std::string icao_hex) {
|
||||
int size = static_cast<int>(msg_bin.size());
|
||||
icao_hex.resize(6, '0');
|
||||
auto crc_24 = std::bitset<24>(crc(msg_bin, true)).to_string();
|
||||
@@ -357,8 +347,7 @@ struct with_AP {
|
||||
auto PA = xorBin(crc_24, std::bitset<24>(icao).to_string());
|
||||
msg.replace(msg.size() - 24, 24, PA);
|
||||
}
|
||||
static bool check_crc(std::string& msg_bin, std::string icao_hex,
|
||||
std::string bds = "") {
|
||||
static bool check_crc(std::string& msg_bin, std::string icao_hex, std::string bds = "") {
|
||||
int size = static_cast<int>(msg_bin.size());
|
||||
icao_hex.resize(6, '0');
|
||||
bds.resize(6, '0');
|
||||
@@ -391,16 +380,13 @@ struct with_DP {
|
||||
auto icao_24 = hex2bin(icao);
|
||||
auto bds_24 = hex2bin(bds);
|
||||
auto transponder_address = hex2bin(std::string("000000"));
|
||||
auto last24 =
|
||||
xorBin(xorBin(crc_24, icao_24), xorBin(bds_24, transponder_address));
|
||||
auto last24 = xorBin(xorBin(crc_24, icao_24), xorBin(bds_24, transponder_address));
|
||||
msg.replace(msg.size() - 24, 24, last24);
|
||||
}
|
||||
static bool check_crc(std::string& msg_bin, std::string_view icao_hex,
|
||||
std::string_view bds) {
|
||||
static bool check_crc(std::string& msg_bin, std::string_view icao_hex, std::string_view bds) {
|
||||
return true;
|
||||
}
|
||||
static std::string transponder_address(std::string& msg, std::string icao,
|
||||
std::string bds) {
|
||||
static std::string transponder_address(std::string& msg, std::string icao, std::string bds) {
|
||||
int size = static_cast<int>(msg.size());
|
||||
icao.resize(6, '0');
|
||||
bds.resize(6, '0');
|
||||
@@ -413,7 +399,9 @@ struct with_DP {
|
||||
};
|
||||
#define D_BDS(number) \
|
||||
struct BDS##number { \
|
||||
static std::string bds() { return #number; } \
|
||||
static std::string bds() { \
|
||||
return #number; \
|
||||
} \
|
||||
};
|
||||
D_BDS(_) // 凑数的
|
||||
// ADS-B
|
||||
@@ -447,4 +435,4 @@ D_BDS(45) // 气象灾害报告
|
||||
SSR::mode_s_logger->error("", log_type, msg); \
|
||||
return std::nullopt; \
|
||||
}
|
||||
}
|
||||
} // namespace SSR
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Common.h"
|
||||
#include "Core/Base/global_include.h"
|
||||
#include "Psc_Cpp_Core/Base/global_include.h"
|
||||
#include <string_view>
|
||||
#undef max
|
||||
#undef min
|
||||
|
||||
+8
-15
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <string_view>
|
||||
#include "../CPR/CPR.h"
|
||||
#include "Core/Base/global_include.h"
|
||||
#include "Psc_Cpp_Core/Base/global_include.h"
|
||||
#include "SSR/enum.h"
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
@@ -35,12 +35,10 @@ struct Air_Speed {
|
||||
double speed = -1; // kt
|
||||
double angle = -1; // degree
|
||||
int vertical_rate = -1; // ft/min
|
||||
std::string
|
||||
speed_type; // Speed type: 'GS' for ground speed, 'AS' for airspeed
|
||||
std::string speed_type; // Speed type: 'GS' for ground speed, 'AS' for airspeed
|
||||
std::string direction_source; // Optional: Direction source ('TRUE_NORTH' or
|
||||
// 'MAGNETIC_NORTH')
|
||||
std::string
|
||||
vertical_rate_source; // Optional: Vertical rate source ('BARO' or 'GNSS')
|
||||
std::string vertical_rate_source; // Optional: Vertical rate source ('BARO' or 'GNSS')
|
||||
Psc::JSON toJson() {
|
||||
return Psc::JSON::object({
|
||||
{"speed", speed},
|
||||
@@ -78,8 +76,7 @@ void set_df(std::string& msg, Downlink_Format df);
|
||||
// return result;
|
||||
// };
|
||||
Transponder_Capability decode_transponder_capability(std::string_view msg);
|
||||
void set_transponder_capability(std::string& msg,
|
||||
Transponder_Capability transponder_capability);
|
||||
void set_transponder_capability(std::string& msg, Transponder_Capability transponder_capability);
|
||||
int crc(std::string_view msg_bin, bool encode);
|
||||
std::string decode_icao(std::string_view msg_bin);
|
||||
std::string set_icao(std::string& msg, std::string_view icaoHex);
|
||||
@@ -137,8 +134,7 @@ double temperature(double H);
|
||||
double pressure(double H);
|
||||
double density(double H);
|
||||
double vsound(double H);
|
||||
double distance(double lat1, double lon1, double lat2, double lon2,
|
||||
double H = 0);
|
||||
double distance(double lat1, double lon1, double lat2, double lon2, double H = 0);
|
||||
double bearing(double lat1, double lon1, double lat2, double lon2);
|
||||
double tas2mach(double Vtas, double H);
|
||||
double mach2tas(double Mach, double H);
|
||||
@@ -156,8 +152,7 @@ double cas2mach(double Vcas, double H);
|
||||
Airborne position
|
||||
------------------------------------------
|
||||
*/
|
||||
double decode_altitude_12_meter(std::string_view msg_bin,
|
||||
Altitude_type altitude_type);
|
||||
double decode_altitude_12_meter(std::string_view msg_bin, Altitude_type altitude_type);
|
||||
std::string encode_altitude_code_12(double height, Altitude_type altitude_type);
|
||||
Vortex_Type parse_vortex_type(std::string_view msg);
|
||||
// ------------------------------------------
|
||||
@@ -190,8 +185,7 @@ double altitude_diff(std::string_view msg);
|
||||
std::string vertical_rate_code_10(double vertical_rate);
|
||||
double decode_vertical_rate_10(std::string_view vertical_rate);
|
||||
std::string GNSS_barometric_altitudes_difference_8(double altitude_difference);
|
||||
std::string encode_velocity_22(Ground_Speed_Type subType, double track_angle,
|
||||
double ground_speed);
|
||||
std::string encode_velocity_22(Ground_Speed_Type subType, double track_angle, double ground_speed);
|
||||
std::string encode_magnetic_heading_11(double heading);
|
||||
std::string encode_airspeed_10(Air_Speed_Code_Type subtype, double airspeed);
|
||||
// ------------------------------------------
|
||||
@@ -319,8 +313,7 @@ Emergency_Type emergency_status(std::string_view msg);
|
||||
// ------------------------------------------
|
||||
// BDS
|
||||
// ------------------------------------------
|
||||
std::string is50or60(std::string_view msg, double spd_ref, double trk_ref,
|
||||
double alt_ref);
|
||||
std::string is50or60(std::string_view msg, double spd_ref, double trk_ref, double alt_ref);
|
||||
std::string infer(std::string_view msg_bin, bool mrar = false);
|
||||
std::vector<std::string> infer2(std::string_view msg, bool mrar = false);
|
||||
// ADS-B
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "./Common.h"
|
||||
#include "Core/Statistics/Frequency_Limit.h"
|
||||
#include "Psc_Cpp_Core/Statistics/Frequency_Limit.h"
|
||||
#include "SSR/CPR/CPR.h"
|
||||
#include <string_view>
|
||||
#undef max
|
||||
|
||||
+11
-10
@@ -1,15 +1,16 @@
|
||||
_create(interface SSR)
|
||||
|
||||
set(Core Core_Static)
|
||||
|
||||
|
||||
_attach_include_dir("SSR" "${CMAKE_CURRENT_LIST_DIR}")
|
||||
_attach_source_dir("SSR" "${CMAKE_CURRENT_LIST_DIR}/SSR")
|
||||
_attach_source_dir("SSR" "${CMAKE_CURRENT_LIST_DIR}/test")
|
||||
_depend(SSR ${Core})
|
||||
|
||||
|
||||
#_create(dll readsb2)
|
||||
#_attach_include_dir(readsb2 "${CMAKE_CURRENT_LIST_DIR}")
|
||||
#_attach_source_dir(readsb2 "${CMAKE_CURRENT_LIST_DIR}/readsb2")
|
||||
|
||||
|
||||
|
||||
|
||||
set(Core Psc_Core_Static)
|
||||
set(SSR_srcs)
|
||||
append_glob_source(SSR_srcs "${CMAKE_CURRENT_LIST_DIR}/SSR" "${CMAKE_CURRENT_LIST_DIR}/test")
|
||||
add_library(SSR STATIC ${SSR_srcs})
|
||||
target_include_directories(SSR PUBLIC "${CMAKE_CURRENT_LIST_DIR}")
|
||||
target_link_libraries(SSR PUBLIC ${Core})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user