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.

41 wiersze
1.1KB

  1. package detector
  2. import (
  3. "testing"
  4. "time"
  5. )
  6. func TestDetectorCreatesEvent(t *testing.T) {
  7. d := New(-10, 1000, 10, 1*time.Millisecond, 10*time.Millisecond, 0.2, 3, 1, 10*time.Millisecond, "OFF", 2, 16, 24, 6, true)
  8. center := 0.0
  9. spectrum := []float64{-30, -30, -30, -5, -5, -30, -30, -30, -30, -30}
  10. now := time.Now()
  11. finished, signals := d.Process(now, spectrum, center)
  12. if len(finished) != 0 {
  13. t.Fatalf("expected no finished events yet")
  14. }
  15. if len(signals) != 1 {
  16. t.Fatalf("expected 1 signal, got %d", len(signals))
  17. }
  18. if signals[0].BWHz <= 0 {
  19. t.Fatalf("expected bandwidth > 0")
  20. }
  21. // Extend signal duration.
  22. _, _ = d.Process(now.Add(5*time.Millisecond), spectrum, center)
  23. // Advance beyond hold with no signal to finalize.
  24. now2 := now.Add(30 * time.Millisecond)
  25. noSignal := make([]float64, len(spectrum))
  26. for i := range noSignal {
  27. noSignal[i] = -100
  28. }
  29. finished, _ = d.Process(now2, noSignal, center)
  30. if len(finished) != 1 {
  31. t.Fatalf("expected 1 finished event, got %d", len(finished))
  32. }
  33. if finished[0].Bandwidth <= 0 {
  34. t.Fatalf("event bandwidth not set")
  35. }
  36. }