3D优化
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
#ifndef PSC_GLOBAL_INCLUDE_H
|
||||
#define PSC_GLOBAL_INCLUDE_H
|
||||
#include "Core/Statistics/Statistics.h"
|
||||
#include "Core/socket/ByteOrder.h"
|
||||
#include "SSR/export.h"
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
@@ -11,10 +8,13 @@
|
||||
#include <queue>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <string_view>
|
||||
#include "Core/Statistics/Statistics.h"
|
||||
#include "Core/socket/ByteOrder.h"
|
||||
#include "SSR/export.h"
|
||||
class Global;
|
||||
class Invalid_Http_Param final : public std::runtime_error {
|
||||
public:
|
||||
@@ -23,28 +23,28 @@ public:
|
||||
[[noreturn]] inline void throw_invalid_http_param(const char* detail) {
|
||||
throw Invalid_Http_Param(detail);
|
||||
}
|
||||
#define CHECK_JSON_PARAM \
|
||||
auto o_params = Psc::try_parse_json(req->body().data()); \
|
||||
if (!o_params.has_value()) { \
|
||||
throw_invalid_http_param("request body is not valid JSON"); \
|
||||
} \
|
||||
auto ¶ms = o_params.value(); \
|
||||
auto that_json = ¶ms;
|
||||
#define HTTP_REQUIRE_VALUE(NAME, EXPRESSION) \
|
||||
auto o_http_##NAME = (EXPRESSION); \
|
||||
if (!o_http_##NAME.has_value()) { \
|
||||
throw_invalid_http_param(#NAME); \
|
||||
} \
|
||||
auto NAME = std::move(o_http_##NAME).value();
|
||||
#define HTTP_REQUIRE_PTR(NAME, EXPRESSION) \
|
||||
auto NAME = (EXPRESSION); \
|
||||
if ((NAME) == nullptr) { \
|
||||
throw_invalid_http_param(#NAME); \
|
||||
}
|
||||
#define HTTP_REQUIRE_TRUE(EXPRESSION, DETAIL) \
|
||||
if (!(EXPRESSION)) { \
|
||||
throw_invalid_http_param(DETAIL); \
|
||||
}
|
||||
#define CHECK_JSON_PARAM \
|
||||
auto o_params = Psc::try_parse_json(req->body().data()); \
|
||||
if (!o_params.has_value()) { \
|
||||
throw_invalid_http_param("request body is not valid JSON"); \
|
||||
} \
|
||||
auto& params = o_params.value(); \
|
||||
auto that_json = ¶ms;
|
||||
#define HTTP_REQUIRE_VALUE(NAME, EXPRESSION) \
|
||||
auto o_http_##NAME = (EXPRESSION); \
|
||||
if (!o_http_##NAME.has_value()) { \
|
||||
throw_invalid_http_param(#NAME); \
|
||||
} \
|
||||
auto NAME = std::move(o_http_##NAME).value();
|
||||
#define HTTP_REQUIRE_PTR(NAME, EXPRESSION) \
|
||||
auto NAME = (EXPRESSION); \
|
||||
if ((NAME) == nullptr) { \
|
||||
throw_invalid_http_param(#NAME); \
|
||||
}
|
||||
#define HTTP_REQUIRE_TRUE(EXPRESSION, DETAIL) \
|
||||
if (!(EXPRESSION)) { \
|
||||
throw_invalid_http_param(DETAIL); \
|
||||
}
|
||||
template <typename Value_Type>
|
||||
class Ordered_List {
|
||||
public:
|
||||
@@ -218,9 +218,7 @@ public:
|
||||
// Ret_J(speed);
|
||||
std::string t = "null";
|
||||
if (total_num != 0) {
|
||||
t = std::to_string(static_cast<double>(crc_error_num) /
|
||||
static_cast<double>(total_num)) +
|
||||
"%";
|
||||
t = std::to_string(static_cast<double>(crc_error_num) / static_cast<double>(total_num)) + "%";
|
||||
}
|
||||
ret.append({"crc误码率", t});
|
||||
for (auto& cur : statistic_map) {
|
||||
@@ -301,12 +299,8 @@ public:
|
||||
if (iter != statistic.result_num.end()) {
|
||||
num = iter->second;
|
||||
}
|
||||
double rate = static_cast<double>(num) /
|
||||
static_cast<double>(statistic.total_num) * 100.0;
|
||||
type_result.append({
|
||||
Psc::to_string(result_type),
|
||||
std::format("{} {:.2f}%", num, rate)
|
||||
});
|
||||
double rate = static_cast<double>(num) / static_cast<double>(statistic.total_num) * 100.0;
|
||||
type_result.append({Psc::to_string(result_type), std::format("{} {:.2f}%", num, rate)});
|
||||
}
|
||||
result.append({Psc::to_string(cpr_type), type_result});
|
||||
}
|
||||
@@ -318,11 +312,8 @@ protected:
|
||||
std::map<SSR::CPR_Ret_Type, size_t> result_num;
|
||||
};
|
||||
inline static constexpr std::array statistic_types{
|
||||
SSR::CPR_Ret_Type::Speed_Error,
|
||||
SSR::CPR_Ret_Type::Parse_OK,
|
||||
SSR::CPR_Ret_Type::Inter_Error,
|
||||
SSR::CPR_Ret_Type::Time_Space_Too_Long
|
||||
};
|
||||
SSR::CPR_Ret_Type::Speed_Error, SSR::CPR_Ret_Type::Parse_OK, SSR::CPR_Ret_Type::Inter_Error,
|
||||
SSR::CPR_Ret_Type::Time_Space_Too_Long, SSR::CPR_Ret_Type::Out_of_Maximum_Detection_Range};
|
||||
std::map<SSR::CPR_Type, Statistic_Data> statistic_map;
|
||||
};
|
||||
class Mode_S_Statistic_Data {
|
||||
@@ -336,21 +327,14 @@ public:
|
||||
Ret_J(total_num);
|
||||
std::string t = "null";
|
||||
if (total_num != 0) {
|
||||
t = std::format(
|
||||
"{}%",
|
||||
static_cast<double>(crc_error_num) /
|
||||
static_cast<double>(total_num)
|
||||
);
|
||||
t = std::format("{}%", static_cast<double>(crc_error_num) / static_cast<double>(total_num));
|
||||
}
|
||||
Ret_J(crc_error_num);
|
||||
ret.append({"crc_error_rate", t});
|
||||
Psc::JSON df_sub_type = Psc::JSON::object();
|
||||
for (auto& cur : DF_Statistic_Data_map) {
|
||||
df_sub_type.append({
|
||||
Psc::to_string(cur.first) + " [" +
|
||||
std::to_string(static_cast<int>(cur.first)) + "]",
|
||||
cur.second.to_json()
|
||||
});
|
||||
df_sub_type.append({Psc::to_string(cur.first) + " [" + std::to_string(static_cast<int>(cur.first)) + "]",
|
||||
cur.second.to_json()});
|
||||
}
|
||||
ret.append({"DF子类型", df_sub_type});
|
||||
ret.append({"CPR统计信息", cpr_statistic_data.to_json()});
|
||||
@@ -362,9 +346,7 @@ public:
|
||||
void add_cpr_error(SSR::CPR_Type cpr_type, SSR::CPR_Ret_Type result_type) {
|
||||
cpr_statistic_data.add(cpr_type, result_type);
|
||||
}
|
||||
DF_Statistic_Data* get_create_df_statistic_data(
|
||||
const SSR::Downlink_Format& key
|
||||
) {
|
||||
DF_Statistic_Data* get_create_df_statistic_data(const SSR::Downlink_Format& key) {
|
||||
DF_Statistic_Data* t;
|
||||
auto iter = DF_Statistic_Data_map.find(key);
|
||||
if (iter == DF_Statistic_Data_map.end()) {
|
||||
|
||||
Reference in New Issue
Block a user