File Reference radarsimrealtime
File Reference radar_sim_realtime
Path: Project v1/src/radar_sim/realtime.py
1. Purpose
هذا الملف جزء من نواة HDDS ويخدم طبقة وظيفية محددة داخل منظومة Radar/Audio/GUI orchestration.
2. Responsibilities
- احتواء منطق المجال الخاص بهذا الملف.
- توفير API داخلي لباقي الوحدات.
- تنفيذ جزء من Runtime pipeline.
3. Imports Analysis
- 3:from future import annotations
- 5:import argparse
- 6:from dataclasses import dataclass
- 7:from pathlib import Path
- 9:import matplotlib.pyplot as plt
- 10:import numpy as np
- 12:from .channel import simulate_surveillance_matrix
- 13:from .constants import AppConfig, RadarConfig, ScenarioConfig, Target, load_app_config
- 14:from .detection import DetectionResult, ca_cfar_2d
- 15:from .geometry import bistatic_range_to_delay_s, velocity_mps_to_doppler_hz
- 16:from .logging_utils import write_run_log
- 17:from .plotting import detection_power_db
- 18:from .processing import ProcessingResult, process_reference_and_surveillance
- 19:from .runner import default_config_path
- 20:from .waveform import generate_reference_matrix
4. Main Classes
- 24:class MovingTargetSpec:
- 33:class RealtimeScenarioConfig:
5. Main Functions
- 43:def range_at_time_m(target: MovingTargetSpec, elapsed_s: float) -> float:
- 48:def build_instantaneous_scenario(
- 75:def execute_instantaneous_scenario(
- 103:def _prompt_text(prompt: str, default: str | None = None) -> str:
- 115:def _prompt_float(
- 139:def _prompt_yes_no(prompt: str, default: bool = True) -> bool:
- 153:def _prompt_moving_target(index: int) -> MovingTargetSpec:
- 174:def build_realtime_scenario(config_path: Path) -> tuple[AppConfig, RealtimeScenarioConfig]:
- 214:def realtime_summary_text(realtime: RealtimeScenarioConfig) -> str:
- 236:def print_realtime_summary(realtime: RealtimeScenarioConfig) -> None:
- 242:def _build_live_figure(initial_range_extent: float) -> tuple:
- 297:def run_realtime_scenario(
- 477:def build_parser() -> argparse.ArgumentParser:
- 494:def main() -> None:
تحليل الدوال (منهج عام):
- input: معاملات runtime/config/data structures.
- output: dataclasses/arrays/reports/state updates.
- algorithm: يعتمد على نوع الملف (DSP/ML/GUI/control flow).
- side effects: I/O، logging، GUI updates، أو model loading.
- runtime behavior: دوال critical قد تنفذ per-frame أو per-window.
6. Internal Workflow
- تهيئة البيانات أو الإعدادات.
- تطبيق المعالجة الأساسية.
- إعادة النتائج أو تحديث state خارجي.
7. Data Flow
- inbound: من ملفات config أو callers أعلى.
- processing: transformations حسب domain.
- outbound: structures تستخدمها ملفات أخرى أو GUI.
8. Mathematical Concepts
إذا كان الملف Radar/Audio DSP فإنه يستخدم مفاهيم مثل FFT, Doppler Shift, log-Mel, thresholding حسب السياق.
9. Important Variables
10. Integration Points
- Used By: يعتمد على استدعاءات بقية النظام لهذا الملف.
- Calls: وحدات داخلية وخارجية (NumPy/TensorFlow/PyTorch/OpenCV).
11. Runtime Sequence
ينفذ هذا الملف ضمن التسلسل العام الموضح في Runtime Execution Flow.
12. Error Handling
- يعتمد على
raise/exceptions المحلية في الملف. - في GUI يتم غالبًا احتواء الخطأ عبر dialogs أو status messages.
13. Performance Notes
- الملفات التشغيلية per-frame/per-window حساسة للأداء.
- عمليات ML inference وFFT هي الأعلى كلفة عادة.
14. Future Improvements
- إضافة profiling موحد.
- توحيد metrics logging.
- تقليل التكرار بين و عند الإمكان.
15. Related Notes
Metadata
- Source path: Project v1/src/radar_sim/realtime.py
- Lines: 514