Wideband autonomous SDR analysis engine forked from sdr-visual-suite
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

86 строки
2.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. }
  18. type SpectrumFrame struct {
  19. Timestamp int64 `json:"ts"`
  20. CenterHz float64 `json:"center_hz"`
  21. SampleHz int `json:"sample_rate"`
  22. FFTSize int `json:"fft_size"`
  23. Spectrum []float64 `json:"spectrum_db"`
  24. Signals []detector.Signal `json:"signals"`
  25. Debug *SpectrumDebug `json:"debug,omitempty"`
  26. }
  27. type client struct {
  28. conn *websocket.Conn
  29. send chan []byte
  30. done chan struct{}
  31. closeOnce sync.Once
  32. // Per-client settings (set via initial config message)
  33. binary bool // send binary spectrum frames instead of JSON
  34. maxBins int // target bin count (0 = full resolution)
  35. targetFps int // target frame rate (0 = full rate)
  36. frameSkip int // skip counter: send every N-th frame
  37. frameN int // current frame counter
  38. }
  39. type hub struct {
  40. mu sync.Mutex
  41. clients map[*client]struct{}
  42. frameCnt int64
  43. lastLogTs time.Time
  44. }
  45. type gpuStatus struct {
  46. mu sync.RWMutex
  47. Available bool `json:"available"`
  48. Active bool `json:"active"`
  49. Error string `json:"error"`
  50. }
  51. type signalSnapshot struct {
  52. mu sync.RWMutex
  53. signals []detector.Signal
  54. }
  55. type sourceManager struct {
  56. mu sync.RWMutex
  57. src sdr.Source
  58. newSource func(cfg config.Config) (sdr.Source, error)
  59. }
  60. type extractionManager struct {
  61. mu sync.Mutex
  62. runner *gpudemod.BatchRunner
  63. maxSamples int
  64. }
  65. type dspUpdate struct {
  66. cfg config.Config
  67. det *detector.Detector
  68. window []float64
  69. dcBlock bool
  70. iqBalance bool
  71. useGPUFFT bool
  72. }