Wideband autonomous SDR analysis engine forked from sdr-visual-suite
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

111 řádky
3.1KB

  1. package main
  2. import (
  3. "sync"
  4. "time"
  5. "github.com/gorilla/websocket"
  6. "sdr-wideband-suite/internal/config"
  7. "sdr-wideband-suite/internal/demod/gpudemod"
  8. "sdr-wideband-suite/internal/detector"
  9. "sdr-wideband-suite/internal/pipeline"
  10. "sdr-wideband-suite/internal/sdr"
  11. )
  12. type SpectrumDebug struct {
  13. Thresholds []float64 `json:"thresholds,omitempty"`
  14. NoiseFloor float64 `json:"noise_floor,omitempty"`
  15. Scores []map[string]any `json:"scores,omitempty"`
  16. RefinementPlan *pipeline.RefinementPlan `json:"refinement_plan,omitempty"`
  17. Windows *RefinementWindowStats `json:"refinement_windows,omitempty"`
  18. Refinement *RefinementDebug `json:"refinement,omitempty"`
  19. Decisions *DecisionDebug `json:"decisions,omitempty"`
  20. }
  21. type RefinementWindowStats struct {
  22. Count int `json:"count"`
  23. MinSpan float64 `json:"min_span_hz"`
  24. MaxSpan float64 `json:"max_span_hz"`
  25. AvgSpan float64 `json:"avg_span_hz"`
  26. Sources map[string]int `json:"sources,omitempty"`
  27. }
  28. type RefinementDebug struct {
  29. Plan *pipeline.RefinementPlan `json:"plan,omitempty"`
  30. Request *pipeline.RefinementRequest `json:"request,omitempty"`
  31. WorkItems []pipeline.RefinementWorkItem `json:"work_items,omitempty"`
  32. Windows *RefinementWindowStats `json:"windows,omitempty"`
  33. Queue decisionQueueStats `json:"queue,omitempty"`
  34. Budgets *pipeline.BudgetModel `json:"budgets,omitempty"`
  35. }
  36. type DecisionDebug struct {
  37. Summary decisionSummary `json:"summary"`
  38. Items []compactDecision `json:"items,omitempty"`
  39. }
  40. type SpectrumFrame struct {
  41. Timestamp int64 `json:"ts"`
  42. CenterHz float64 `json:"center_hz"`
  43. SampleHz int `json:"sample_rate"`
  44. FFTSize int `json:"fft_size"`
  45. Spectrum []float64 `json:"spectrum_db"`
  46. Signals []detector.Signal `json:"signals"`
  47. Debug *SpectrumDebug `json:"debug,omitempty"`
  48. }
  49. type client struct {
  50. conn *websocket.Conn
  51. send chan []byte
  52. done chan struct{}
  53. closeOnce sync.Once
  54. // Per-client settings (set via initial config message)
  55. binary bool // send binary spectrum frames instead of JSON
  56. maxBins int // target bin count (0 = full resolution)
  57. targetFps int // target frame rate (0 = full rate)
  58. frameSkip int // skip counter: send every N-th frame
  59. frameN int // current frame counter
  60. }
  61. type hub struct {
  62. mu sync.Mutex
  63. clients map[*client]struct{}
  64. frameCnt int64
  65. lastLogTs time.Time
  66. }
  67. type gpuStatus struct {
  68. mu sync.RWMutex
  69. Available bool `json:"available"`
  70. Active bool `json:"active"`
  71. Error string `json:"error"`
  72. }
  73. type signalSnapshot struct {
  74. mu sync.RWMutex
  75. signals []detector.Signal
  76. }
  77. type sourceManager struct {
  78. mu sync.RWMutex
  79. src sdr.Source
  80. newSource func(cfg config.Config) (sdr.Source, error)
  81. }
  82. type extractionManager struct {
  83. mu sync.Mutex
  84. runner *gpudemod.BatchRunner
  85. maxSamples int
  86. }
  87. type dspUpdate struct {
  88. cfg config.Config
  89. det *detector.Detector
  90. window []float64
  91. dcBlock bool
  92. iqBalance bool
  93. useGPUFFT bool
  94. }