From cf17c454a91fb9940f9d36916dc1b30dee9a5fe8 Mon Sep 17 00:00:00 2001 From: wyc <1104749580@qq.com> Date: Wed, 5 Aug 2026 14:37:55 +0800 Subject: [PATCH] =?UTF-8?q?cmake=E5=BA=93=E6=94=B9=E9=80=A0=E5=89=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/linux/config.json | 757 ++++++++++++++++++ main.cmake | 135 +--- module/Local_Server/Aircraft/Flight_VTO.cpp | 30 +- module/Local_Server/Aircraft/global.h | 4 +- module/Local_Server/Crawler/Crawler.h | 125 ++- module/Local_Server/DSP/DSP_Config.cpp | 2 +- module/Local_Server/DSP/DSP_Config.h | 2 +- module/Local_Server/DSP/global.h | 21 +- module/Local_Server/Data_Feed/global.h | 10 +- .../Data_Source/Data_Source_Handler.h | 10 +- module/Local_Server/Data_Source/global.h | 40 +- .../External_Database/External_Database.cpp | 2 +- .../Local_Server/External_Database/global.h | 2 +- module/Local_Server/global_include.h | 4 +- module/Local_Server/server/Config.cpp | 4 +- module/Local_Server/server/Config.h | 2 +- module/Local_Server/server/Global.h | 27 +- module/Local_Server/server/MLAT.h | 4 +- .../server/Source_Feed_Relation.h | 2 +- .../Local_Server/server/WebSocket_Manager.h | 4 +- module/Local_Server/server/With_Loop_Coro.h | 4 +- module/Local_Server/server/io_coro.cpp | 2 +- module/Local_Server/server/io_coro.h | 65 +- module/Local_Server/server/libarchive.h | 60 +- module/Local_Server/server/tiles.cpp | 1 - module/Radarcape_Core/main.cpp | 2 +- module/dll_source/Dll_Global.cpp | 4 +- module/dll_source/Dll_Global.h | 110 ++- module/dll_source/main.cpp | 14 +- 29 files changed, 1034 insertions(+), 415 deletions(-) create mode 100644 config/linux/config.json diff --git a/config/linux/config.json b/config/linux/config.json new file mode 100644 index 0000000..6ef0949 --- /dev/null +++ b/config/linux/config.json @@ -0,0 +1,757 @@ +{ + "version": "v1.0.4", + "dsp": { + "library_path": "@/lib9002/lib9002.so", + "center_freq": 16000000, + "band_width": 6000, + "sample_rate": 60000, + "fft_point_number": 2048, + "fft_period_ms": 50, + "fft_win_type": "blkmc", + "url": "0.0.0.0", + "port": 6000, + "power_min": -380, + "power_max": 120, + "power_offset": -166, + "frame_rate": 60, + "debug": false, + "demod_mode": "LSB", + "audio_gain": 30, + "color_gain": 120 + }, + "drogon": { + "app": { + "threads_num": 0, + "client_max_body_size": "1000M", + "client_max_memory_body_size": "1000M" + } + }, + "http_monitor": { + "access_log": false, + "slow_request_threshold_ms": 3000, + "slow_scope_threshold_ms": 1000 + }, + "mlat": { + "enable": false, + "merge": false, + "library_path": "@/mlat_source.dll", + "function_name": "adsb_read" + }, + "web_server": { + "webapp": "@/wwwroot" + }, + "map_resources": { + "current_imagery_key": "mixed_imagery", + "tile_sources": [ + { + "key": "mixed_imagery", + "name": "本地混合图", + "tile_type": "imagery", + "request_method": "GET", + "resource": { + "file_format": "mbtiles", + "directories": [ + ], + "files": [ + "/home/heco/tiles/混合图-世界-0-8.mbtiles", + "/home/heco/tiles/混合图-中国-9-10.mbtiles", + "/home/heco/tiles/混合图-中国-11.mbtiles" + ], + "path_layout": "z/x/y", + "y_axis": "tms", + "projection": "web_mercator", + "extension": ".png", + "tile_size": 256, + "minimum_level": 0, + "maximum_level": 11 + } + }, + { + "key": "height_terrain", + "name": "本地高程", + "tile_type": "terrain", + "request_method": "GET", + "resource": { + "file_format": "mbtiles", + "directories": [ + ], + "files": [ + "/home/heco/tiles/高程-世界-0-8.mbtiles", + "/home/heco/tiles/高程-中国-9-10.mbtiles", + "/home/heco/tiles/高程-中国-11.mbtiles" + ], + "path_layout": "z/x/y", + "y_axis": "tms", + "projection": "web_mercator", + "extension": ".png", + "tile_size": 256, + "minimum_level": 0, + "maximum_level": 11, + "encoding": "terrarium" + } + }, + { + "key": "osm_online", + "name": "OpenStreetMap在线", + "tile_type": "imagery", + "request_method": "GET", + "url": "https://tile.openstreetmap.org/{z}/{x}/{y}.png", + "resource": { + "file_format": "online", + "directories": [ + ], + "files": [ + ], + "path_layout": "z/x/y", + "y_axis": "xyz", + "projection": "web_mercator", + "extension": ".png", + "tile_size": 256, + "minimum_level": 0, + "maximum_level": 19 + } + }, + { + "key": "osm_hot_online", + "name": "OpenStreetMap HOT在线", + "tile_type": "imagery", + "request_method": "GET", + "url": "https://a.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png", + "resource": { + "file_format": "online", + "directories": [ + ], + "files": [ + ], + "path_layout": "z/x/y", + "y_axis": "xyz", + "projection": "web_mercator", + "extension": ".png", + "tile_size": 256, + "minimum_level": 0, + "maximum_level": 19 + } + }, + { + "key": "cyclosm_online", + "name": "CyclOSM在线", + "tile_type": "imagery", + "request_method": "GET", + "url": "https://a.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png", + "resource": { + "file_format": "online", + "directories": [ + ], + "files": [ + ], + "path_layout": "z/x/y", + "y_axis": "xyz", + "projection": "web_mercator", + "extension": ".png", + "tile_size": 256, + "minimum_level": 0, + "maximum_level": 20 + } + }, + { + "key": "carto_light_online", + "name": "Carto Light在线", + "tile_type": "imagery", + "request_method": "GET", + "url": "https://a.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png", + "resource": { + "file_format": "online", + "directories": [ + ], + "files": [ + ], + "path_layout": "z/x/y", + "y_axis": "xyz", + "projection": "web_mercator", + "extension": ".png", + "tile_size": 256, + "minimum_level": 0, + "maximum_level": 20 + } + }, + { + "key": "carto_dark_online", + "name": "Carto Dark在线", + "tile_type": "imagery", + "request_method": "GET", + "url": "https://a.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png", + "resource": { + "file_format": "online", + "directories": [ + ], + "files": [ + ], + "path_layout": "z/x/y", + "y_axis": "xyz", + "projection": "web_mercator", + "extension": ".png", + "tile_size": 256, + "minimum_level": 0, + "maximum_level": 20 + } + }, + { + "key": "carto_voyager_online", + "name": "Carto Voyager在线", + "tile_type": "imagery", + "request_method": "GET", + "url": "https://a.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}.png", + "resource": { + "file_format": "online", + "directories": [ + ], + "files": [ + ], + "path_layout": "z/x/y", + "y_axis": "xyz", + "projection": "web_mercator", + "extension": ".png", + "tile_size": 256, + "minimum_level": 0, + "maximum_level": 20 + } + }, + { + "key": "carto_dark_nolabels_online", + "name": "Carto Dark无标注在线", + "tile_type": "imagery", + "request_method": "GET", + "url": "https://a.basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}.png", + "resource": { + "file_format": "online", + "directories": [ + ], + "files": [ + ], + "path_layout": "z/x/y", + "y_axis": "xyz", + "projection": "web_mercator", + "extension": ".png", + "tile_size": 256, + "minimum_level": 0, + "maximum_level": 20 + } + }, + { + "key": "opentopomap_online", + "name": "OpenTopoMap在线", + "tile_type": "imagery", + "request_method": "GET", + "url": "https://a.tile.opentopomap.org/{z}/{x}/{y}.png", + "resource": { + "file_format": "online", + "directories": [ + ], + "files": [ + ], + "path_layout": "z/x/y", + "y_axis": "xyz", + "projection": "web_mercator", + "extension": ".png", + "tile_size": 256, + "minimum_level": 0, + "maximum_level": 17 + } + } + ] + }, + "map_view": { + "scene_mode": "3d", + "map2d": { + "current_imagery_key": "mixed_imagery", + "tile_zoom_mode": "native", + "tile_display_maximum_level": 8 + }, + "map3d": { + "current_imagery_key": "mixed_imagery", + "tile_zoom_mode": "native", + "tile_display_maximum_level": 19 + }, + "camera": { + "longitude": 122.014707, + "latitude": 35.714108, + "height": 241660.031820, + "heading": 347.582854, + "pitch": -54.917211, + "roll": 359.999884 + }, + "baseStationFlyToHeightOffsetMeters": 8000.000000 + }, + "map_models": { + "aircraft_model": { + "url": "/ui/model/aircraft.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "aircraft_models": { + "glider": { + "url": "/ui/model/aircraft-glider.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "ground_obstruction_4": { + "url": "/ui/model/aircraft-ground-obstruction-4.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "ground_obstruction_5": { + "url": "/ui/model/aircraft-ground-obstruction-5.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "ground_obstruction_6": { + "url": "/ui/model/aircraft-ground-obstruction-6.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "ground_obstruction_7": { + "url": "/ui/model/aircraft-ground-obstruction-7.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "heavy_aircraft": { + "url": "/ui/model/aircraft-heavy-aircraft.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "high_performance_aircraft": { + "url": "/ui/model/aircraft-high-performance-aircraft.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "high_vortex_aircraft": { + "url": "/ui/model/aircraft-high-vortex-aircraft.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "light_aircraft": { + "url": "/ui/model/aircraft-light-aircraft.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "lighter_than_air": { + "url": "/ui/model/aircraft-lighter-than-air.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "medium_1_aircraft": { + "url": "/ui/model/aircraft-medium-1-aircraft.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "medium_2_aircraft": { + "url": "/ui/model/aircraft-medium-2-aircraft.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "no_category_information": { + "url": "/ui/model/aircraft-no-category-information.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "parachutist": { + "url": "/ui/model/aircraft-parachutist.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "reserved_3_5": { + "url": "/ui/model/aircraft-reserved-3-5.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "rotorcraft": { + "url": "/ui/model/aircraft-rotorcraft.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "space_transatmospheric_vehicle": { + "url": "/ui/model/aircraft-space-transatmospheric-vehicle.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "surface_emergency_vehicle": { + "url": "/ui/model/aircraft-surface-emergency-vehicle.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "surface_service_vehicle": { + "url": "/ui/model/aircraft-surface-service-vehicle.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "ultralight_hangglider_paraglider": { + "url": "/ui/model/aircraft-ultralight-hangglider-paraglider.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "unmanned_aerial_vehicle": { + "url": "/ui/model/aircraft-unmanned-aerial-vehicle.glb", + "built_in_size": 50.000000, + "heading_offset_degrees": -90.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + } + }, + "base_station_model": { + "url": "/ui/model/base-station.glb", + "built_in_size": 16.635522, + "heading_offset_degrees": 0.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + }, + "device_model": { + "url": "/ui/model/device.glb", + "built_in_size": 80.000000, + "heading_offset_degrees": 0.000000, + "pitch_offset_degrees": 0.000000, + "roll_offset_degrees": 0.000000 + } + }, + "device": { + "net": [ + { + "key": "device", + "ip": "0.0.0.0", + "port": 9081, + "netmask": "255.255.255.0", + "gateway": "192.168.1.1" + }, + { + "key": "wifi", + "ip": "192.168.10.193", + "port": 80, + "netmask": "255.255.255.0", + "gateway": "192.168.10.1" + } + ] + }, + "mode_acs": { + "timeout_seconds": 160, + "max_speed_m_s": 1000.000000, + "air_pos_timeout": 8.000000, + "surface_pos_timeout": 32.000000, + "read_milliseconds": 100, + "wait_process_msg": true, + "time_space_filter": true, + "speed_filter": true, + "max_track_point_size": 20000, + "mode_s_max_num": 700000, + "mode_other_max_num": 10000, + "report_data_feed_msg_mum": 10000, + "default_min_aircraft_list_num": 10, + "aircraft_change_list_min_position_points": 2, + "aircraft_change_list_adsb_range_filter": true, + "aircraft_change_list_adsb_range_factor": 1.200000, + "adsb_theoretical_target_altitude_meters": 10000.000000, + "ignore_df_11": true, + "monitor_msg_live": false, + "data_feed": { + "empty_wait_milliseconds": 30, + "packet_byte_size": 0, + "tcp_server_default_connect_user_buffer_size": 409600, + "tcp_server_default_connect_system_buffer_size": 409600, + "list": [ + { + "type": "Data_Feed_TCP_Server", + "key": "Port_10003", + "enable": true, + "output_format": { + "type": "BIN", + "use_status": true, + "mode_s_output_type": "ALL_Mode_S", + "use_mode_ac": true, + "sbs_only_pos": true + }, + "port": 10003, + "connect_user_buffer_size": 409600, + "connect_system_buffer_size": 409600 + }, + { + "type": "Data_Feed_UDP_Server", + "key": "22333", + "enable": false, + "output_format": { + "type": "BIN", + "use_status": false, + "mode_s_output_type": "ALL_Mode_S", + "use_mode_ac": false, + "sbs_only_pos": false + }, + "port": 50001 + }, + { + "type": "Data_Feed_UDP_Client", + "key": "Port_10004", + "enable": false, + "output_format": { + "type": "AVR", + "use_status": false, + "mode_s_output_type": "DF_11_17_18", + "use_mode_ac": false, + "sbs_only_pos": true + }, + "port": 30004, + "url": "192.168.1.75" + }, + { + "type": "Data_Feed_TCP_Client", + "key": "Port_10005", + "enable": false, + "output_format": { + "type": "BIN", + "use_status": true, + "mode_s_output_type": "NO_POS_Mode_S", + "use_mode_ac": true, + "sbs_only_pos": true + }, + "url": "192.168.1.167", + "port": 10005 + }, + { + "type": "Data_Feed_TCP_Server", + "key": "Port_30003", + "enable": false, + "output_format": { + "type": "SBS", + "use_status": false, + "mode_s_output_type": "ALL_Mode_S", + "use_mode_ac": true, + "sbs_only_pos": true + }, + "port": 30003, + "connect_user_buffer_size": 0, + "connect_system_buffer_size": 0 + } + ] + }, + "data_source": { + "list": [ + { + "type": "Dll_Data_Source", + "key": "lzy_dll", + "enable": true, + "base_station_has_valid_position": true, + "map_display": { + "map2d": { + "base_station_show": true, + "aircraft_show": true, + "constant_screen_size": true, + "color": "#454641", + "track_point_color": "#ffff00", + "base_station_color": "#1677ff", + "aircraft_pixel_size": 34, + "base_station_pixel_size": 30, + "aircraft_scale": 2.000000, + "base_station_scale": 0.440000, + "show_icao": true, + "show_call_sign": false, + "show_fly_status": false + }, + "map3d": { + "base_station_show": true, + "aircraft_show": true, + "constant_screen_size": true, + "color": "#454641", + "track_point_color": "#ffff00", + "base_station_color": "#1677ff", + "aircraft_pixel_size": 50, + "base_station_pixel_size": 100, + "aircraft_scale": 1.000000, + "base_station_scale": 0.440000, + "show_icao": true, + "show_call_sign": false, + "show_fly_status": false + } + }, + "lat": 37.433547, + "lon": 121.408730, + "alt": 2300.000000, + "ignore_msg_time": true, + "update_form_gps": false, + "keep_mode": true, + "library_path": "@/lib9002/lib9002.so", + "function_name": "adsb_read", + "data_type": "BIN_Blank_Text", + "buffer_size": 200000 + } + ] + }, + "source_feed_relation": { + "list": [ + { + "key": "key_10003", + "enable": true, + "type": "First_Source_To_All_Feed_Relation" + } + ] + } + }, + "log": { + "open_mode": "Delete", + "piece_num": 10, + "size_MB": 10 + }, + "console": { + "record_playback": false, + "mode_s_console": false, + "post_request": false, + "mlat_server": true + }, + "external_database": { + "ecap_sqlite_path": "@/../ecap.sqlite", + "list": [ + { + "name": "tar1090_db_aircraft", + "download_url": "https://raw.githubusercontent.com/wiedehopf/tar1090-db/refs/heads/csv/aircraft.csv.gz", + "description": "wiedehopf/tar1090-db 发布的轻量 ICAO24 飞机静态库,提供注册号、机型、年份和运营方备注。", + "update_interval_seconds": 604800, + "last_updated_at": 1780388281 + }, + { + "name": "wiedehopf_tar1090_db_aircraft", + "download_url": "https://raw.githubusercontent.com/wiedehopf/tar1090-db/refs/heads/csv/aircraft.csv.gz", + "description": "wiedehopf/tar1090-db 项目发布的飞机静态数据库镜像,供 tar1090 本地识别飞机。", + "update_interval_seconds": 604800, + "last_updated_at": 1780381804 + }, + { + "name": "mictronics_aircraft_database", + "download_url": "https://raw.githubusercontent.com/wiedehopf/tar1090-db/refs/heads/csv/aircraft.csv.gz", + "description": "Mictronics 社区飞机数据库的 tar1090 汇总镜像,可按 ICAO24 查询注册号、机型和运营方。", + "update_interval_seconds": 604800, + "last_updated_at": 1780381804 + }, + { + "name": "opensky_aircraft_database", + "download_url": "https://opensky-network.org/datasets/metadata/aircraftDatabase.csv", + "description": "OpenSky Network 飞机元数据 CSV,包含制造商、型号、注册号和运营方等字段。", + "update_interval_seconds": 604800, + "last_updated_at": 1780381804 + }, + { + "name": "faa_aircraft_registry", + "download_url": "https://registry.faa.gov/database/ReleasableAircraft.zip", + "description": "FAA 官方可公开下载的美国飞机注册库,MASTER.txt 包含 Mode-S Hex 注册信息。", + "update_interval_seconds": 86400, + "last_updated_at": 1780381804 + }, + { + "name": "icao_doc_8643_aircraft_type_designators", + "download_url": "", + "description": "ICAO Doc 8643 机型代码表,用于将 A320、B738 等 designator 映射为制造商、型号和类别。", + "update_interval_seconds": 2419200, + "last_updated_at": 1780381804 + }, + { + "name": "vrs_routes", + "download_url": "https://vrs-standing-data.adsb.lol/routes.csv", + "description": "VRS 航线表,以 callsign 查询机场代码序列,用于推断起飞机场、经停机场和目的机场。", + "update_interval_seconds": 3600, + "last_updated_at": 1780381804 + }, + { + "name": "vrs_airports", + "download_url": "https://vrs-standing-data.adsb.lol/airports.csv", + "description": "VRS 机场字典,提供机场代码、名称、国家、经纬度和高度。", + "update_interval_seconds": 3600, + "last_updated_at": 1780381804 + }, + { + "name": "adsblol_vrs_standing_data_routes", + "download_url": "https://vrs-standing-data.adsb.lol/routes.csv", + "description": "ADSB.lol 发布的 VRS standing-data 航线镜像,以 callsign 查询机场代码序列。", + "update_interval_seconds": 3600, + "last_updated_at": 1780381804 + }, + { + "name": "vradarserver_standing_data_routes", + "download_url": "https://vrs-standing-data.adsb.lol/routes.csv", + "description": "Virtual Radar Server standing-data 的航线适配表;当前在线更新使用 ADSB.lol 公共镜像。", + "update_interval_seconds": 3600, + "last_updated_at": 1780381804 + }, + { + "name": "opensky_flightdata_api_cache", + "download_url": "", + "description": "OpenSky FlightData API 查询缓存,按 ICAO24 和时间范围保存历史航班起降机场结果。", + "update_interval_seconds": 0, + "last_updated_at": 1780381804 + } + ] + }, + "cesium_graphics": { + "debug_show_frames_per_second": true, + "target_frame_rate": 30, + "use_browser_recommended_resolution": true, + "resolution_scale": 1.000000, + "msaa_samples": 1, + "fxaa": true, + "shadows": true, + "enable_lighting": true, + "solar_lighting": true, + "solar_light_intensity": 1.500000, + "maximum_screen_space_error": 4, + "terrain_enabled_in_3d": true, + "terrain_exaggeration": 5.000000, + "terrain_limit_maximum_level": true, + "terrain_maximum_level": 15, + "terrain_cache_tiles": 128, + "terrain_occlusion_enabled": false, + "surface_navigation_reference_visible": true, + "view_axes_visible": true, + "performance_panel_x": 12.000000, + "performance_panel_y": 92.000000, + "view_axes_panel_x": 3.000000, + "view_axes_panel_y": 337.000000, + "view_axes_panel_size": 184.000000, + "occlusion_sample_spacing_meters": 250.000000, + "occlusion_clearance_margin_meters": 10.000000 + } +} diff --git a/main.cmake b/main.cmake index 5a141d8..18a152f 100644 --- a/main.cmake +++ b/main.cmake @@ -2,12 +2,10 @@ set(rely global::drogon global::libarchive global::SQLiteCpp) rcl_load_dependency_environment(${rely}) -#message("222222222 LibArchive_SUB_LIBRARIES {${LibArchive_SUB_LIBRARIES}}") - find_package(Drogon) find_package(SQLiteCpp CONFIG REQUIRED) -set(Core Core_Static) +set(Core Psc_Core_Static) if (1) set(md "${CMAKE_CURRENT_LIST_DIR}/module") if (WIN32) @@ -16,36 +14,38 @@ if (1) set(cfg_dir ${CMAKE_CURRENT_LIST_DIR}/config) endif () set(data_dir ${CMAKE_CURRENT_LIST_DIR}/data) - _create("dll" dll_source) - _create("exe" data_process) - _attach_include_dir(dll_source "${md}") - _attach_source_dir(dll_source "${md}/dll_source") - _attach_include_dir(data_process "${md}") - _attach_source_dir(data_process "${md}/dll_source") - _depend(dll_source ${Core}) - _depend(data_process ${Core}) + + + append_glob_source(dll_source_srcs "${md}/dll_source") + add_library(dll_source SHARED ${dll_source_srcs}) + add_executable(data_process "${dll_source_srcs}") + target_include_directories(dll_source PUBLIC "${md}") + target_link_libraries(dll_source PUBLIC ${Core}) + target_link_libraries(data_process PUBLIC ${Core}) + _attach_post_build_file(dll_source ${cfg_dir}/data_progress_config.json ${data_dir}/BIN_Blank_Text/ADS-B_195_0205.txt # "${CMAKE_CURRENT_LIST_DIR}/data/BIN_Blank_Text/ADS-B_195_0205.txt" ) - _create("dll" mlat_source) - _attach_include_dir(mlat_source "${md}") - _attach_source_dir(mlat_source "${md}/mlat_source") - _depend(mlat_source ${Core}) - _create("exe" mlat_source_exe) - _attach_include_dir(mlat_source_exe "${md}") - _attach_source_dir(mlat_source_exe "${md}/mlat_source") - _depend(mlat_source_exe ${Core}) - _create("exe" ecap_server) - _depend(ecap_server SSR) - _attach_include_dir(ecap_server "${md}") - _attach_source_dir(ecap_server "${md}/Local_Server") - target_include_directories(ecap_server PRIVATE "${CMAKE_CURRENT_LIST_DIR}/../../core_library/Core/3rd/ucoro/include") + + append_glob_source(mlat_source_srcs "${md}/mlat_source") + add_library(mlat_source SHARED ${mlat_source_srcs}) + target_include_directories(mlat_source PUBLIC "${md}") + target_link_libraries(mlat_source PUBLIC ${Core}) + + + append_glob_source(ecap_server_srcs "${md}/Local_Server") + add_executable(ecap_server "${md}/Local_Server_main.cpp" ${ecap_server_srcs}) + target_include_directories(ecap_server PUBLIC "${md}") + target_include_directories(ecap_server PRIVATE ${ZLIB_INCLUDE_DIR}) + + target_link_libraries(ecap_server PUBLIC SSR) + target_link_libraries(ecap_server PUBLIC ${Core}) target_link_libraries(ecap_server PRIVATE Drogon::Drogon) target_link_libraries(ecap_server PRIVATE SQLiteCpp) target_link_libraries(ecap_server PRIVATE ${ZLIB_LIBRARY}) - target_include_directories(ecap_server PRIVATE ${ZLIB_INCLUDE_DIR}) + message("LibArchive_SUB_LIBRARIES {${LibArchive_SUB_LIBRARIES}}") target_link_libraries(ecap_server PRIVATE LibArchive::LibArchive @@ -53,98 +53,21 @@ if (1) ) target_compile_definitions(ecap_server PRIVATE LIBARCHIVE_STATIC) + target_compile_definitions(ecap_server PRIVATE NOMINMAX) + target_compile_definitions(ecap_server PRIVATE INCL_EXTRA_HTON_FUNCTIONS) # drogon用 - _attach_source_file(ecap_server "${md}/Local_Server_main.cpp") _attach_post_build_file(ecap_server ${cfg_dir}/config.json) - # if (MSVC) - # - # target_compile_options(ecap_server PRIVATE /fsanitize=address /Zi) - # - # target_link_options(ecap_server PRIVATE /INCREMENTAL:NO /DEBUG) - # get_filename_component(_msvc_bin_dir "${CMAKE_CXX_COMPILER}" DIRECTORY) - # find_file(ASAN_RUNTIME_DLL - # NAMES clang_rt.asan_dbg_dynamic-x86_64.dll - # PATHS "${_msvc_bin_dir}" - # NO_DEFAULT_PATH - # REQUIRED - # ) - # if (NOT ASAN_RUNTIME_DLL) - # message(FATAL_ERROR "找不到 ASan 运行库: clang_rt.asan_dbg_dynamic-x86_64.dll,搜索目录: ${_msvc_bin_dir}") - # endif () - # add_custom_command(TARGET ecap_server POST_BUILD - # COMMAND "${CMAKE_COMMAND}" -E copy_if_different - # "${ASAN_RUNTIME_DLL}" - # "$" - # VERBATIM - # ) - # else () - # - # # target_compile_options(ecap_server PRIVATE -fsanitize=address -fno-omit-frame-pointer -g) - # # - # # target_link_options(ecap_server PRIVATE -fsanitize=address) - # - # endif () - - if (UNIX AND NOT APPLE) - - - # 添加进程间通信系统库 - target_compile_options(ecap_server PRIVATE -g -gstrict-dwarf -gdwarf-4 -fvar-tracking-assignments) - # set(CMAKE_FOLDER "lzy") - # add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/lzy ${CMAKE_BINARY_DIR}/lzy) - # unset(CMAKE_FOLDER) - set(ver v1.0.4) - set(WEB_DIR "${CMAKE_CURRENT_LIST_DIR}/webapp") - set(publish_root_dir "${CMAKE_CURRENT_LIST_DIR}/ver") - set(publish_dir "${publish_root_dir}/${ver}") - set(WEB_OUT_DIR "${publish_dir}/wwwroot") - set(PACKAGE_ZIP "${publish_dir}.zip") - set(NODE_DIR "C:/Users/wyc/AppData/Roaming/JetBrains/WebStorm2026.1/node/versions/24.15.0") - set(NPM_EXECUTABLE "${NODE_DIR}/npm.cmd") - if (NOT EXISTS "${NODE_DIR}/node.exe") - message(FATAL_ERROR "node.exe not found: ${NODE_DIR}/node.exe") - endif () - add_custom_target(ecap_server_package - COMMAND ${CMAKE_COMMAND} -E make_directory "${publish_dir}" - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${publish_dir} - COMMAND ${CMAKE_COMMAND} -E remove_directory "${WEB_OUT_DIR}" - COMMAND ${CMAKE_COMMAND} -E env - "PATH=${NODE_DIR};$ENV{PATH}" - ${CMAKE_COMMAND} -E chdir "${WEB_DIR}" - "${NPM_EXECUTABLE}" run build -- --outDir "${WEB_OUT_DIR}" --emptyOutDir - COMMAND ${CMAKE_COMMAND} -E remove -f "${PACKAGE_ZIP}" - COMMAND ${CMAKE_COMMAND} -E chdir "${publish_dir}" - ${CMAKE_COMMAND} -E tar cf "${PACKAGE_ZIP}" --format=zip -- . - COMMENT "Build frontend" - USES_TERMINAL - VERBATIM - ) - add_dependencies(ecap_server_package ecap_server) - endif () if (MSVC) target_compile_definitions(ecap_server PRIVATE _CRTDBG_MAP_ALLOC ) endif () add_dependencies(ecap_server dll_source) - if (WIN32) - endif () - _create("exe" test_drogon) - _attach_include_dir(test_drogon "${md}") - _attach_source_dir(test_drogon "${md}/test_drogon") - target_link_libraries(test_drogon PRIVATE Drogon::Drogon) + + endif () rcl_unload_dependency_environment(${rely}) -#include("${CMAKE_SOURCE_DIR}/0_cmake_library/ninja_build_analyze/export.cmake") -# -#register_ninja_build_analyze_target( -# ninja_build_analyze_ctx # 分析上下文 target 名,自己起名 -# "Core_Static" # 要分析的构建目标;空字符串表示 all -# "${CMAKE_BINARY_DIR}/analyze" # 分析输出目录;空字符串表示 build/build_analysis -# "ON" # 是否先 clean:ON/OFF -# "30" # top 数量;空字符串表示 30 -#) diff --git a/module/Local_Server/Aircraft/Flight_VTO.cpp b/module/Local_Server/Aircraft/Flight_VTO.cpp index e47273c..a870553 100644 --- a/module/Local_Server/Aircraft/Flight_VTO.cpp +++ b/module/Local_Server/Aircraft/Flight_VTO.cpp @@ -1,46 +1,38 @@ -#include "../Aircraft/Flight_VTO.h" +#include "Flight_VTO.h" #include #include namespace { double to_radians(double degrees) { return degrees * 3.14159265358979323846 / 180.0; } -double track_heading_from_points(const SSR::Position_Info& first, - const SSR::Position_Info& second) { +double track_heading_from_points(const SSR::Position_Info& first, const SSR::Position_Info& second) { auto lat1 = to_radians(first.lat); auto lat2 = to_radians(second.lat); auto dlon = to_radians(second.lon - first.lon); auto y = std::sin(dlon) * std::cos(lat2); - auto x = std::cos(lat1) * std::sin(lat2) - - std::sin(lat1) * std::cos(lat2) * std::cos(dlon); + auto x = std::cos(lat1) * std::sin(lat2) - std::sin(lat1) * std::cos(lat2) * std::cos(dlon); auto angle = std::atan2(y, x) * 180.0 / 3.14159265358979323846; return angle < 0 ? angle + 360.0 : angle; } -double ground_distance_meters(const SSR::Position_Info& first, - const SSR::Position_Info& second) { +double ground_distance_meters(const SSR::Position_Info& first, const SSR::Position_Info& second) { auto dlat = to_radians(second.lat - first.lat); auto dlon = to_radians(second.lon - first.lon); auto lat1 = to_radians(first.lat); auto lat2 = to_radians(second.lat); - auto a = std::sin(dlat / 2) * std::sin(dlat / 2) + - std::cos(lat1) * std::cos(lat2) * std::sin(dlon / 2) * - std::sin(dlon / 2); + auto a = + std::sin(dlat / 2) * std::sin(dlat / 2) + std::cos(lat1) * std::cos(lat2) * std::sin(dlon / 2) * std::sin(dlon / 2); auto safe_a = std::min(1.0, std::max(0.0, a)); - return 6371000.0 * 2 * - std::atan2(std::sqrt(safe_a), std::sqrt(1 - safe_a)); + return 6371000.0 * 2 * std::atan2(std::sqrt(safe_a), std::sqrt(1 - safe_a)); } -double track_pitch_from_points(const SSR::Position_Info& first, - const SSR::Position_Info& second) { +double track_pitch_from_points(const SSR::Position_Info& first, const SSR::Position_Info& second) { auto distance = ground_distance_meters(first, second); - return std::atan2(second.alt - first.alt, distance) * 180.0 / - 3.14159265358979323846; + return std::atan2(second.alt - first.alt, distance) * 180.0 / 3.14159265358979323846; } Flight_Track_Orientation track_orientation_from_points(const SSR::Position_Info& first, const SSR::Position_Info& second) { - return {track_heading_from_points(first, second), - track_pitch_from_points(first, second), 0.0}; -} + return {track_heading_from_points(first, second), track_pitch_from_points(first, second), 0.0}; } +} // namespace Psc::JSON Flight_Track_Orientation::to_json() const { auto ret = Psc::JSON::object(); ret.append({"heading", heading}); diff --git a/module/Local_Server/Aircraft/global.h b/module/Local_Server/Aircraft/global.h index 07ff518..bb21258 100644 --- a/module/Local_Server/Aircraft/global.h +++ b/module/Local_Server/Aircraft/global.h @@ -1,6 +1,6 @@ #pragma once -#include "Core/Base/JSON.h" -#include "Core/socket/export.h" +#include "Psc_Cpp_Core/Base/JSON.h" +#include "Psc_Cpp_Core/socket/export.h" #include "SSR/export.h" #include #include diff --git a/module/Local_Server/Crawler/Crawler.h b/module/Local_Server/Crawler/Crawler.h index 1773cbe..e4b12f8 100644 --- a/module/Local_Server/Crawler/Crawler.h +++ b/module/Local_Server/Crawler/Crawler.h @@ -1,96 +1,83 @@ #pragma once #include - -#include "Core/Base/JSON.h" -#include "Core/Statistics/Frequency_Limit.h" - +#include "Psc_Cpp_Core/Base/JSON.h" +#include "Psc_Cpp_Core/Statistics/Frequency_Limit.h" #include #include #include #include #include #include - class Crawler { public: - using Call_back = std::function; - - explicit Crawler(std::string_view db_path) - : db_(std::string(db_path), SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE) { - aircraft_json_table_create_if_not_exists(); - // 可选:性能更好(仍然是同步) - db_.exec("PRAGMA journal_mode=WAL;"); - db_.exec("PRAGMA synchronous=NORMAL;"); - } - - void aircraft_json_table_create_if_not_exists() { - db_.exec(R"sql( + using Call_back = std::function; + explicit Crawler(std::string_view db_path) : + db_(std::string(db_path), SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE) { + aircraft_json_table_create_if_not_exists(); + // 可选:性能更好(仍然是同步) + db_.exec("PRAGMA journal_mode=WAL;"); + db_.exec("PRAGMA synchronous=NORMAL;"); + } + void aircraft_json_table_create_if_not_exists() { + db_.exec(R"sql( CREATE TABLE IF NOT EXISTS aircraft_json ( icao TEXT PRIMARY KEY, json TEXT ); )sql"); - } - - bool check_aircraft_exists(SQLite::Database &db, std::string_view icao) { - // 查询是否存在该icao - static auto stmt_check_ = SQLite::Statement(db, R"sql( + } + bool check_aircraft_exists(SQLite::Database& db, std::string_view icao) { + // 查询是否存在该icao + static auto stmt_check_ = SQLite::Statement(db, R"sql( SELECT COUNT(*) FROM aircraft_json WHERE icao = ?; )sql"); - - stmt_check_.reset(); - stmt_check_.clearBindings(); - stmt_check_.bind(1, std::string(icao)); - - int count = 0; - if (stmt_check_.executeStep()) { - count = stmt_check_.getColumn(0).getInt(); + stmt_check_.reset(); + stmt_check_.clearBindings(); + stmt_check_.bind(1, std::string(icao)); + int count = 0; + if (stmt_check_.executeStep()) { + count = stmt_check_.getColumn(0).getInt(); + } + // 如果存在记录,返回 true + return count > 0; } - - // 如果存在记录,返回 true - return count > 0; - } - - void insert_aircraft_json(std::string_view icao, const Psc::JSON &j) { - static auto stmt_upsert_ = SQLite::Statement(db_, R"sql( + void insert_aircraft_json(std::string_view icao, const Psc::JSON& j) { + static auto stmt_upsert_ = SQLite::Statement(db_, R"sql( INSERT INTO aircraft_json(icao, json) VALUES(?, ?) ON CONFLICT(icao) DO UPDATE SET json = excluded.json; )sql"); - const std::string json_str = j.to_json_string(); - std::lock_guard g(mtx); - SQLite::Transaction tx(db_); // BEGIN - stmt_upsert_.reset(); - stmt_upsert_.clearBindings(); - stmt_upsert_.bind(1, std::string(icao)); - stmt_upsert_.bind(2, json_str); - stmt_upsert_.exec(); - tx.commit(); - } - - void req_all_insert_aircraft_json() { - std::atomic idx = 0; - handle( - [this, &idx](std::string_view hex, std::string_view icaoType, Psc::JSON &json) { - // 直接同步写库(最简单) - try { - static Frequency_Limit fl; - idx++; - if (fl.test()) { - std::cout << idx << "/618325 条数据处理成功! " << std::endl; + const std::string json_str = j.to_json_string(); + std::lock_guard g(mtx); + SQLite::Transaction tx(db_); // BEGIN + stmt_upsert_.reset(); + stmt_upsert_.clearBindings(); + stmt_upsert_.bind(1, std::string(icao)); + stmt_upsert_.bind(2, json_str); + stmt_upsert_.exec(); + tx.commit(); + } + void req_all_insert_aircraft_json() { + std::atomic idx = 0; + handle([this, &idx](std::string_view hex, std::string_view icaoType, Psc::JSON& json) { + // 直接同步写库(最简单) + try { + static Frequency_Limit fl; + idx++; + if (fl.test()) { + std::cout << idx << "/618325 条数据处理成功! " << std::endl; + } + insert_aircraft_json(hex, json); + } + catch (const std::exception& e) { + // 用你自己的 LOG_ERROR + std::cerr << "sqlite insert failed: " << e.what() << "\n"; } - insert_aircraft_json(hex, json); - } catch (const std::exception &e) { - // 用你自己的 LOG_ERROR - std::cerr << "sqlite insert failed: " << e.what() << "\n"; - } }); - } - + } private: - SQLite::Database db_; - std::mutex mtx; - void handle(Call_back cb); // 你自己实现/已有 + SQLite::Database db_; + std::mutex mtx; + void handle(Call_back cb); // 你自己实现/已有 }; diff --git a/module/Local_Server/DSP/DSP_Config.cpp b/module/Local_Server/DSP/DSP_Config.cpp index ae320b5..77fa546 100644 --- a/module/Local_Server/DSP/DSP_Config.cpp +++ b/module/Local_Server/DSP/DSP_Config.cpp @@ -1,7 +1,7 @@ #include "Local_Server/DSP/DSP_Config.h" #include "../server/Global.h" -#include "Core/socket/ByteOrder.h" +#include "Psc_Cpp_Core/socket/ByteOrder.h" #include #include #include diff --git a/module/Local_Server/DSP/DSP_Config.h b/module/Local_Server/DSP/DSP_Config.h index 5d0d8b0..e5207ee 100644 --- a/module/Local_Server/DSP/DSP_Config.h +++ b/module/Local_Server/DSP/DSP_Config.h @@ -5,7 +5,7 @@ class Global; #define USE_PROCESS 0 #ifdef USE_PROCESS -#include "Core/Shared_Memory/Shared_Memory.h" +#include "Psc_Cpp_Core/Shared_Memory/Shared_Memory.h" #endif // #ifdef WIN32 // #define USE_PROCESS 1 diff --git a/module/Local_Server/DSP/global.h b/module/Local_Server/DSP/global.h index 8f58ed2..88659ff 100644 --- a/module/Local_Server/DSP/global.h +++ b/module/Local_Server/DSP/global.h @@ -1,16 +1,15 @@ #pragma once #include "../../dll_source/main.h" -#include "Core/Base/JSON.h" -#include "Core/spdlog/export.h" - +#include "Psc_Cpp_Core/Base/JSON.h" +#include "Psc_Cpp_Core/spdlog/export.h" class Base_DSP { public: - std::string library_path; - std::uint64_t center_freq{}; - std::uint64_t band_width{}; - std::uint64_t sample_rate{}; - Psc::Copyable_Atomic fft_point_number = 1024; - int fft_period_ms; - UHD_FFTWin fft_win_type; - PSC_USE_JSON + std::string library_path; + std::uint64_t center_freq{}; + std::uint64_t band_width{}; + std::uint64_t sample_rate{}; + Psc::Copyable_Atomic fft_point_number = 1024; + int fft_period_ms; + UHD_FFTWin fft_win_type; + PSC_USE_JSON }; diff --git a/module/Local_Server/Data_Feed/global.h b/module/Local_Server/Data_Feed/global.h index 41d5ecd..44204f9 100644 --- a/module/Local_Server/Data_Feed/global.h +++ b/module/Local_Server/Data_Feed/global.h @@ -1,7 +1,7 @@ #pragma once -#include "../server/Mode_Msg_Buffer.h" -#include "Core/Serial/Serial.h" -#include "Core/Statistics/Frequency_Limit.h" -#include "Core/socket/TCP_Server.h" -#include "Core/socket/export.h" #include +#include "../server/Mode_Msg_Buffer.h" +#include "Psc_Cpp_Core/Serial/Serial.h" +#include "Psc_Cpp_Core/Statistics/Frequency_Limit.h" +#include "Psc_Cpp_Core/socket/TCP_Server.h" +#include "Psc_Cpp_Core/socket/export.h" diff --git a/module/Local_Server/Data_Source/Data_Source_Handler.h b/module/Local_Server/Data_Source/Data_Source_Handler.h index 63bceb3..909c05a 100644 --- a/module/Local_Server/Data_Source/Data_Source_Handler.h +++ b/module/Local_Server/Data_Source/Data_Source_Handler.h @@ -1,14 +1,14 @@ #pragma once #include #include -#include "Core/Base/SM_RingBuffer.h" -#include "Core/Serial/Serial_Coro.h" -#include "Core/Statistics/Frequency_Limit.h" -#include "Core/Statistics/Statistics.h" -#include "Core/transmit_protocol/core/statistics.h" #include "Database.h" #include "Local_Server/global_include.h" #include "PlayBack.h" +#include "Psc_Cpp_Core/Base/SM_RingBuffer.h" +#include "Psc_Cpp_Core/Serial/Serial_Coro.h" +#include "Psc_Cpp_Core/Statistics/Frequency_Limit.h" +#include "Psc_Cpp_Core/Statistics/Statistics.h" +#include "Psc_Cpp_Core/transmit_protocol/core/statistics.h" #include "global.h" // 这个函数专门装cpu密集函数 放到线程池去处理 class Data_Source_Handler : public DataBase { diff --git a/module/Local_Server/Data_Source/global.h b/module/Local_Server/Data_Source/global.h index 07ff518..1dcc51c 100644 --- a/module/Local_Server/Data_Source/global.h +++ b/module/Local_Server/Data_Source/global.h @@ -1,7 +1,4 @@ #pragma once -#include "Core/Base/JSON.h" -#include "Core/socket/export.h" -#include "SSR/export.h" #include #include #include @@ -9,30 +6,29 @@ #include #include #include - +#include "Psc_Cpp_Core/Base/JSON.h" +#include "Psc_Cpp_Core/socket/export.h" +#include "SSR/export.h" // 用于debug 散乱的飞机从何而来 // #define Cache_Some_Mode_S #ifdef Cache_Some_Mode_S - #define Cache_Some_Mode_S_Num 20 +#define Cache_Some_Mode_S_Num 20 #endif - - - #define Parse(t, Field) \ -auto& _##t = info.Field.value; \ -info.Field.time = info.timestamp; \ -if (!_##t.has_value()) _##t = std::remove_reference_t::ValueType(); \ -_##t.value().parse(msg); \ -auto& t = _##t.value(); -// ret.append(NAME.value.has_value()? Psc::Json(STRINGIFY(NAME##_time), NAME.time) : Psc::Json(STRINGIFY(NAME##_time), nullptr)); + auto& _##t = info.Field.value; \ + info.Field.time = info.timestamp; \ + if (!_##t.has_value()) \ + _##t = std::remove_reference_t::ValueType(); \ + _##t.value().parse(msg); \ + auto& t = _##t.value(); +// ret.append(NAME.value.has_value()? Psc::Json(STRINGIFY(NAME##_time), NAME.time) : Psc::Json(STRINGIFY(NAME##_time), +// nullptr)); #define STRINGIFY(x) #x #define ADD_Json(NAME) ret.children.emplace_back(STRINGIFY(NAME), NAME); #define ADD_Json_RET(NAME) \ -if (NAME.has_value()) \ -{ \ -ret.children.emplace_back(STRINGIFY(NAME), NAME.value()); \ -} else \ -{ \ -ret.children.emplace_back(STRINGIFY(NAME), nullptr); \ -} - + if (NAME.has_value()) { \ + ret.children.emplace_back(STRINGIFY(NAME), NAME.value()); \ + } \ + else { \ + ret.children.emplace_back(STRINGIFY(NAME), nullptr); \ + } diff --git a/module/Local_Server/External_Database/External_Database.cpp b/module/Local_Server/External_Database/External_Database.cpp index 5afb5bb..68ab245 100644 --- a/module/Local_Server/External_Database/External_Database.cpp +++ b/module/Local_Server/External_Database/External_Database.cpp @@ -11,7 +11,7 @@ #include #include "../server/Global.h" #include "../server/Performance_Monitor.h" -#include "Core/Base/Coro_Result.h" +#include "Psc_Cpp_Core/Base/Coro_Result.h" #include "Resource_Utils.h" #include "Resources.h" #include "global.h" diff --git a/module/Local_Server/External_Database/global.h b/module/Local_Server/External_Database/global.h index 2efa231..d9060ca 100644 --- a/module/Local_Server/External_Database/global.h +++ b/module/Local_Server/External_Database/global.h @@ -14,7 +14,7 @@ #include #include #include -#include "Core/Base/JSON.h" +#include "Psc_Cpp_Core/Base/JSON.h" class Global; struct External_Database_Row { std::map> columns; diff --git a/module/Local_Server/global_include.h b/module/Local_Server/global_include.h index eb4841d..4add305 100644 --- a/module/Local_Server/global_include.h +++ b/module/Local_Server/global_include.h @@ -12,8 +12,8 @@ #include #include #include -#include "Core/Statistics/Statistics.h" -#include "Core/socket/ByteOrder.h" +#include "Psc_Cpp_Core/Statistics/Statistics.h" +#include "Psc_Cpp_Core/socket/ByteOrder.h" #include "SSR/export.h" class Global; class Invalid_Http_Param final : public std::runtime_error { diff --git a/module/Local_Server/server/Config.cpp b/module/Local_Server/server/Config.cpp index fc56ffe..6d7d66a 100644 --- a/module/Local_Server/server/Config.cpp +++ b/module/Local_Server/server/Config.cpp @@ -3,9 +3,9 @@ #include #include #include -#include "Core/Base/Check.h" -#include "Core/Net_Adapter/Net_Adapter.h" #include "Global.h" +#include "Psc_Cpp_Core/Base/Check.h" +#include "Psc_Cpp_Core/Net_Adapter/Net_Adapter.h" #undef interface std::string default_config_path; std::string get_config_path() { diff --git a/module/Local_Server/server/Config.h b/module/Local_Server/server/Config.h index 3093fba..98e2eeb 100644 --- a/module/Local_Server/server/Config.h +++ b/module/Local_Server/server/Config.h @@ -6,8 +6,8 @@ #include "../DSP/export.h" #include "../Data_Feed/export.h" #include "../Data_Source/export.h" -#include "Core/spdlog/export.h" #include "MLAT.h" +#include "Psc_Cpp_Core/spdlog/export.h" #include "Source_Feed_Relation.h" inline bool delete_log = false; extern std::string default_config_path; diff --git a/module/Local_Server/server/Global.h b/module/Local_Server/server/Global.h index a2887c2..df7ba1b 100644 --- a/module/Local_Server/server/Global.h +++ b/module/Local_Server/server/Global.h @@ -1,20 +1,18 @@ #pragma once +#include +#include +#include #include -#include "Core/Base/ThreadManager.h" +#include +#include "../../Radarcape_Core/cpp-httplib/httplib.h" #include "../Data_Source/export.h" #include "../State_Report/State_Report.h" #include "../global_include.h" +#include "Config.h" +#include "Psc_Cpp_Core/Base/ThreadManager.h" +#include "Psc_Cpp_Core/Net_Adapter/Net_Adapter.h" #include "Ucoro_Drogon_Glue.h" -#include "Config.h" -#include -#include "Config.h" -#include "../../Radarcape_Core/cpp-httplib/httplib.h" -#include "../Data_Source/export.h" -#include "Core/Net_Adapter/Net_Adapter.h" #include "libarchive.h" -#include -#include -#include // 集中 管理日志 using namespace Psc; extern BaseLogger* server_logger; @@ -50,7 +48,7 @@ inline JSON warp(const JSON& data) { // return ret; return data; } -#define HTTP_Param const drogon::HttpRequestPtr& req, const drogon::HttpResponsePtr& res +#define HTTP_Param const drogon::HttpRequestPtr &req, const drogon::HttpResponsePtr &res class Web_Server { public: std::string update = "update_"; @@ -110,7 +108,8 @@ class Mlat_Handler { public: std::list get_all() { std::lock_guard gg(ok_mtx); - if (ok_list.empty()) return {}; + if (ok_list.empty()) + return {}; std::list ret; std::swap(ok_list, ret); return ret; @@ -157,7 +156,8 @@ public: } std::shared_ptr total_source() { for (auto i : mode_acs.data_source_config.map.list()) { - if (i->enable) return i; + if (i->enable) + return i; } return mode_acs.data_source_config.map.list().at(0); } @@ -174,4 +174,3 @@ void handle_buffer_muti_start(std::string& buffer, std::string_view data, const const std::function& callback); void handle_buffer_head_tail(std::string& buffer, std::string_view data, std::string_view prefix, std::string_view suffix, const std::function& callback); - diff --git a/module/Local_Server/server/MLAT.h b/module/Local_Server/server/MLAT.h index 8c52198..7dd530d 100644 --- a/module/Local_Server/server/MLAT.h +++ b/module/Local_Server/server/MLAT.h @@ -3,8 +3,8 @@ #include #include #include "../global_include.h" -#include "Core/Base/JSON.h" -#include "Core/system/export.h" +#include "Psc_Cpp_Core/Base/JSON.h" +#include "Psc_Cpp_Core/system/export.h" class Global; #pragma pack(push, 8) extern "C" { diff --git a/module/Local_Server/server/Source_Feed_Relation.h b/module/Local_Server/server/Source_Feed_Relation.h index 89a07a0..e226617 100644 --- a/module/Local_Server/server/Source_Feed_Relation.h +++ b/module/Local_Server/server/Source_Feed_Relation.h @@ -2,7 +2,7 @@ #define SOURCE_FEED_RELATION_H #include #include "../global_include.h" -#include "Core/Serial/Serial.h" +#include "Psc_Cpp_Core/Serial/Serial.h" struct Source_Feed_Relation { std::string key; std::string type; diff --git a/module/Local_Server/server/WebSocket_Manager.h b/module/Local_Server/server/WebSocket_Manager.h index a2fc852..cbd80de 100644 --- a/module/Local_Server/server/WebSocket_Manager.h +++ b/module/Local_Server/server/WebSocket_Manager.h @@ -1,8 +1,8 @@ #pragma once #include -#include "Core/Base/global_include.h" -#include "Core/socket/ByteOrder.h" +#include "Psc_Cpp_Core/Base/global_include.h" +#include "Psc_Cpp_Core/socket/ByteOrder.h" #include #include diff --git a/module/Local_Server/server/With_Loop_Coro.h b/module/Local_Server/server/With_Loop_Coro.h index a9f2e9f..813a033 100644 --- a/module/Local_Server/server/With_Loop_Coro.h +++ b/module/Local_Server/server/With_Loop_Coro.h @@ -12,8 +12,8 @@ #include #include #include -#include "Core/Base/JSON.h" -#include "Core/Statistics/Frequency_Limit.h" +#include "Psc_Cpp_Core/Base/JSON.h" +#include "Psc_Cpp_Core/Statistics/Frequency_Limit.h" class With_Loop_Coro_Data { public: std::string type; diff --git a/module/Local_Server/server/io_coro.cpp b/module/Local_Server/server/io_coro.cpp index ebeb3dd..c9e1b4c 100644 --- a/module/Local_Server/server/io_coro.cpp +++ b/module/Local_Server/server/io_coro.cpp @@ -1,7 +1,7 @@ #include "io_coro.h" #include "../server/Global.h" #include "../server/Mode_Msg_Buffer.h" -#include "Core/Statistics/Frequency_Limit.h" +#include "Psc_Cpp_Core/Statistics/Frequency_Limit.h" #include "Local_Server/Data_Feed/Data_Feed.h" #include "Local_Server/Data_Source/Data_Source.h" #include diff --git a/module/Local_Server/server/io_coro.h b/module/Local_Server/server/io_coro.h index ac65954..da6a183 100644 --- a/module/Local_Server/server/io_coro.h +++ b/module/Local_Server/server/io_coro.h @@ -12,49 +12,38 @@ #include #include #include "asio/bind_executor.hpp" -#include "psc_global_include/Singleton.hpp" - +#include "private_psc_global_include/Singleton.hpp" class Coro : public Psc::Singleton { public: - void start(); - - void stop(); - - asio::awaitable sleep_for(std::chrono::milliseconds ms); - - asio::io_context io; - std::unique_ptr process_data; - - template - std::shared_ptr > spawn(Awaitable &&awaitable) { - auto future = asio::co_spawn(io, std::forward(awaitable), asio::use_future); - return std::make_shared >(std::move(future)); - } - - // template - // void spawn(Awaitable &&awaitable) { - // asio::co_spawn(io, std::forward(awaitable), [](std::exception_ptr exception) { - // if (exception) { - // std::rethrow_exception(exception); - // } - // }); - // } - + void start(); + void stop(); + asio::awaitable sleep_for(std::chrono::milliseconds ms); + asio::io_context io; + std::unique_ptr process_data; + template + std::shared_ptr> spawn(Awaitable&& awaitable) { + auto future = asio::co_spawn(io, std::forward(awaitable), asio::use_future); + return std::make_shared>(std::move(future)); + } + // template + // void spawn(Awaitable &&awaitable) { + // asio::co_spawn(io, std::forward(awaitable), [](std::exception_ptr exception) { + // if (exception) { + // std::rethrow_exception(exception); + // } + // }); + // } private: - asio::awaitable coro_thread(); - - bool has_running_loop_tasks(); - - std::unique_ptr > io_work; - std::thread io_thread; - std::unique_ptr > loop_task; - std::atomic running = false; + asio::awaitable coro_thread(); + bool has_running_loop_tasks(); + std::unique_ptr> io_work; + std::thread io_thread; + std::unique_ptr> loop_task; + std::atomic running = false; }; - inline asio::awaitable resume_on(asio::any_io_executor ex) { - co_await asio::post(asio::bind_executor(ex, asio::deferred)); + co_await asio::post(asio::bind_executor(ex, asio::deferred)); } - inline asio::awaitable dispatch_on(asio::any_io_executor ex) { - co_await asio::dispatch(asio::bind_executor(ex, asio::deferred)); + co_await asio::dispatch(asio::bind_executor(ex, asio::deferred)); } diff --git a/module/Local_Server/server/libarchive.h b/module/Local_Server/server/libarchive.h index c5c3753..0d92382 100644 --- a/module/Local_Server/server/libarchive.h +++ b/module/Local_Server/server/libarchive.h @@ -1,58 +1,46 @@ #ifndef PLANTSUNCAT_ZIP_H #define PLANTSUNCAT_ZIP_H -#include "Core/Base/global_include.h" #include #include #include #include #include #include - +#include "Psc_Cpp_Core/Base/global_include.h" class Invalid_Archive_Error final : public std::runtime_error { public: - using std::runtime_error::runtime_error; + using std::runtime_error::runtime_error; }; - struct Archive_Directory_Layout_Rule { - std::string directory; - std::vector required_files; - std::vector required_directories; - std::vector optional_files; - std::vector optional_directories; + std::string directory; + std::vector required_files; + std::vector required_directories; + std::vector optional_files; + std::vector optional_directories; }; - struct Archive_Layout_Rules { - std::vector directories; - std::size_t max_archive_size = 128 * 1024 * 1024; - std::size_t max_entry_count = 16 * 1024; - std::uint64_t max_entry_uncompressed_size = 256ULL * 1024 * 1024; - std::uint64_t max_total_uncompressed_size = 512ULL * 1024 * 1024; + std::vector directories; + std::size_t max_archive_size = 128 * 1024 * 1024; + std::size_t max_entry_count = 16 * 1024; + std::uint64_t max_entry_uncompressed_size = 256ULL * 1024 * 1024; + std::uint64_t max_total_uncompressed_size = 512ULL * 1024 * 1024; }; - struct Archive_Write_Options { - std::string format = "zip"; - std::string filter; - std::string extension = "zip"; + std::string format = "zip"; + std::string filter; + std::string extension = "zip"; }; - -Psc::expected -validate_archive_layout_from_memory(const char *data, std::size_t size, - const Archive_Layout_Rules &rules); - -void unarchive_file(const std::filesystem::path &zipPath, - const std::filesystem::path &outDir); -void unarchive_from_memory(const char *data, size_t size, - const std::filesystem::path &outDir); -void archive_directory(const std::filesystem::path &dirPath, - const std::filesystem::path &archive_path, - const Archive_Write_Options &options = {}); +Psc::expected validate_archive_layout_from_memory(const char* data, std::size_t size, + const Archive_Layout_Rules& rules); +void unarchive_file(const std::filesystem::path& zipPath, const std::filesystem::path& outDir); +void unarchive_from_memory(const char* data, size_t size, const std::filesystem::path& outDir); +void archive_directory(const std::filesystem::path& dirPath, const std::filesystem::path& archive_path, + const Archive_Write_Options& options = {}); // std::string zip_directory_to_memory(const std::filesystem::path& dirPath, // const // std::vector& // ignoreDirs); - -std::string -archive_directory_to_memory(const std::filesystem::path &dirPath, - const std::vector &ignorePatterns, - const Archive_Write_Options &options = {}); +std::string archive_directory_to_memory(const std::filesystem::path& dirPath, + const std::vector& ignorePatterns, + const Archive_Write_Options& options = {}); #endif diff --git a/module/Local_Server/server/tiles.cpp b/module/Local_Server/server/tiles.cpp index 136f7dd..eaeb812 100644 --- a/module/Local_Server/server/tiles.cpp +++ b/module/Local_Server/server/tiles.cpp @@ -6,7 +6,6 @@ #include #include "Global.h" #include "Performance_Monitor.h" -#include "psc_global_include/codec.h" #if defined(ASIO_HAS_FILE) #include #include diff --git a/module/Radarcape_Core/main.cpp b/module/Radarcape_Core/main.cpp index 64ab62b..4347097 100644 --- a/module/Radarcape_Core/main.cpp +++ b/module/Radarcape_Core/main.cpp @@ -1,5 +1,5 @@ #include "../../../../core_library/Core/Core/ThreadManager.h" -#include "Core/JSON.h" +#include "Psc_Cpp_Core/JSON.h" #ifdef _build_exe // int main(){ // return 0; diff --git a/module/dll_source/Dll_Global.cpp b/module/dll_source/Dll_Global.cpp index 2ca5718..b93eb70 100644 --- a/module/dll_source/Dll_Global.cpp +++ b/module/dll_source/Dll_Global.cpp @@ -1,6 +1,6 @@ #include "Dll_Global.h" -#include "Core/Base/JSON.h" -#include "Core/Base/SM_RingBuffer.h" +#include "Psc_Cpp_Core/Base/JSON.h" +#include "Psc_Cpp_Core/Base/SM_RingBuffer.h" Dll_Global* dg = new Dll_Global(); std::string Dll_Global::get_config_path() { return get_exe_dir() + "/" + "data_progress_config.json"; diff --git a/module/dll_source/Dll_Global.h b/module/dll_source/Dll_Global.h index 1f05d95..2d774c2 100644 --- a/module/dll_source/Dll_Global.h +++ b/module/dll_source/Dll_Global.h @@ -1,6 +1,5 @@ #ifndef PLANTSUNCAT_DLL_GLOBAL_H #define PLANTSUNCAT_DLL_GLOBAL_H -#include "main.h" #include #include #include @@ -13,77 +12,68 @@ #include #include #include - +#include "main.h" #include "../Local_Server/DSP/global.h" -#include "Core/Base/JSON.h" -#include "Core/Base/ThreadManager.h" -#include "Core/Base/global_include.h" -#include "Core/Shared_Memory/Shared_Memory.h" -#include "Core/spdlog/export.h" -#include "Core/system/export.h" - +#include "Psc_Cpp_Core/Base/JSON.h" +#include "Psc_Cpp_Core/Base/ThreadManager.h" +#include "Psc_Cpp_Core/Base/global_include.h" +#include "Psc_Cpp_Core/Shared_Memory/Shared_Memory.h" +#include "Psc_Cpp_Core/spdlog/export.h" +#include "Psc_Cpp_Core/system/export.h" namespace Psc { class SM_RingBuffer; } using namespace Psc; - struct Memory_Buffer { - std::vector get_all() { - std::lock_guard lock(m); - std::swap(cache, data_list); - return data_list; - } - void push(void *pdata, uint64_t length) { - auto buf = pool.get(); - buf->resize(length); - std::memcpy(buf->data(), pdata, length); - { - std::lock_guard lock(m); - cache.push_back(buf); + std::vector get_all() { + std::lock_guard lock(m); + std::swap(cache, data_list); + return data_list; } - } - String_Pool pool = String_Pool(2112, 8 * 1024); - + void push(void* pdata, uint64_t length) { + auto buf = pool.get(); + buf->resize(length); + std::memcpy(buf->data(), pdata, length); + { + std::lock_guard lock(m); + cache.push_back(buf); + } + } + String_Pool pool = String_Pool(2112, 8 * 1024); protected: - std::vector data; - std::vector cache; - std::vector data_list; - Psc::Spin_Lock m; + std::vector data; + std::vector cache; + std::vector data_list; + Psc::Spin_Lock m; }; - struct BB : Base_DSP { - BB() {} + BB() { + } }; #define freq 0.1 - struct Dll_Global : BB, public Singleton { - SM_RingBuffer *rb{}; - SM_RingBuffer *json_func_call{}; - SM_RingBuffer *mode_acs{}; - // Pure_Share_Memory psm = Pure_Share_Memory("fft_data", 65536); - std::uint8_t *psm; - - Memory_Buffer iq_memory_buffer; - Detach_Thread_Manager dtm; - adsb_set_iq_cbk_t set_iq_cbk; - adsb_set_less_30Mhz_ddc_param_t set_less_30Mhz_ddc_param; - adsb_set_less_30Mhz_fft_param_t set_less_30Mhz_fft_param; - static std::string get_config_path(); - void init_when_exe(); - void init_when_dll(); - Dll_Global(); - ~Dll_Global(); - - void save(); - void handle_json_call(); - iq_cbk_t recv_cbk{}; - void *puser{}; - void give_call_back(std::uint8_t *data, size_t len); - - void handle_2112(void *data); - void handle_2112_pure(void *data); - - void handle_2112_test(void *data); + SM_RingBuffer* rb{}; + SM_RingBuffer* json_func_call{}; + SM_RingBuffer* mode_acs{}; + // Pure_Share_Memory psm = Pure_Share_Memory("fft_data", 65536); + std::uint8_t* psm; + Memory_Buffer iq_memory_buffer; + Detach_Thread_Manager dtm; + adsb_set_iq_cbk_t set_iq_cbk; + adsb_set_less_30Mhz_ddc_param_t set_less_30Mhz_ddc_param; + adsb_set_less_30Mhz_fft_param_t set_less_30Mhz_fft_param; + static std::string get_config_path(); + void init_when_exe(); + void init_when_dll(); + Dll_Global(); + ~Dll_Global(); + void save(); + void handle_json_call(); + iq_cbk_t recv_cbk{}; + void* puser{}; + void give_call_back(std::uint8_t* data, size_t len); + void handle_2112(void* data); + void handle_2112_pure(void* data); + void handle_2112_test(void* data); }; - #endif diff --git a/module/dll_source/main.cpp b/module/dll_source/main.cpp index bd3e4de..68537e2 100644 --- a/module/dll_source/main.cpp +++ b/module/dll_source/main.cpp @@ -13,13 +13,13 @@ #include #include #include -#include "Core/Base/JSON.h" -#include "Core/Base/ThreadManager.h" -#include "Core/Base/global_include.h" -#include "Core/Shared_Memory/Shared_Memory.h" -#include "Core/system/export.h" -#include "Core/spdlog/export.h" -#include "Core/Base/SM_RingBuffer.h" +#include "Psc_Cpp_Core/Base/JSON.h" +#include "Psc_Cpp_Core/Base/ThreadManager.h" +#include "Psc_Cpp_Core/Base/global_include.h" +#include "Psc_Cpp_Core/Shared_Memory/Shared_Memory.h" +#include "Psc_Cpp_Core/system/export.h" +#include "Psc_Cpp_Core/spdlog/export.h" +#include "Psc_Cpp_Core/Base/SM_RingBuffer.h" #include "Dll_Global.h" #include #ifndef ECAP_ADSB_PLAYBACK_SPEED_RATE