Wideband autonomous SDR analysis engine forked from sdr-visual-suite
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

84 wiersze
1.9KB

  1. package main
  2. import (
  3. "sync"
  4. "time"
  5. "github.com/gorilla/websocket"
  6. "sdr-visual-suite/internal/config"
  7. "sdr-visual-suite/internal/demod/gpudemod"
  8. "sdr-visual-suite/internal/detector"
  9. "sdr-visual-suite/internal/sdr"
  10. )
  11. type SpectrumDebug struct {
  12. Thresholds []float64 `json:"thresholds,omitempty"`
  13. NoiseFloor float64 `json:"noise_floor,omitempty"`
  14. Scores []map[string]any `json:"scores,omitempty"`
  15. }
  16. type SpectrumFrame struct {
  17. Timestamp int64 `json:"ts"`
  18. CenterHz float64 `json:"center_hz"`
  19. SampleHz int `json:"sample_rate"`
  20. FFTSize int `json:"fft_size"`
  21. Spectrum []float64 `json:"spectrum_db"`
  22. Signals []detector.Signal `json:"signals"`
  23. Debug *SpectrumDebug `json:"debug,omitempty"`
  24. }
  25. type client struct {
  26. conn *websocket.Conn
  27. send chan []byte
  28. done chan struct{}
  29. closeOnce sync.Once
  30. // Per-client settings (set via initial config message)
  31. binary bool // send binary spectrum frames instead of JSON
  32. maxBins int // target bin count (0 = full resolution)
  33. targetFps int // target frame rate (0 = full rate)
  34. frameSkip int // skip counter: send every N-th frame
  35. frameN int // current frame counter
  36. }
  37. type hub struct {
  38. mu sync.Mutex
  39. clients map[*client]struct{}
  40. frameCnt int64
  41. lastLogTs time.Time
  42. }
  43. type gpuStatus struct {
  44. mu sync.RWMutex
  45. Available bool `json:"available"`
  46. Active bool `json:"active"`
  47. Error string `json:"error"`
  48. }
  49. type signalSnapshot struct {
  50. mu sync.RWMutex
  51. signals []detector.Signal
  52. }
  53. type sourceManager struct {
  54. mu sync.RWMutex
  55. src sdr.Source
  56. newSource func(cfg config.Config) (sdr.Source, error)
  57. }
  58. type extractionManager struct {
  59. mu sync.Mutex
  60. runner *gpudemod.BatchRunner
  61. maxSamples int
  62. }
  63. type dspUpdate struct {
  64. cfg config.Config
  65. det *detector.Detector
  66. window []float64
  67. dcBlock bool
  68. iqBalance bool
  69. useGPUFFT bool
  70. }