GNU Radio's SATNOGS Package
waterfall_sink_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
4  *
5  * Copyright (C) 2017,2019 Libre Space Foundation <http://libre.space>
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef INCLUDED_SATNOGS_WATERFALL_SINK_IMPL_H
22 #define INCLUDED_SATNOGS_WATERFALL_SINK_IMPL_H
23 
24 #include <satnogs/waterfall_sink.h>
25 #include <volk/volk.h>
26 #include <gnuradio/fft/fft.h>
27 #include <iostream>
28 #include <fstream>
29 #include <chrono>
30 
31 namespace gr {
32 namespace satnogs {
33 
35 private:
36 
37  /**
38  * Waterfall header data.
39  * This structure is only for readability purposes and make more clear to
40  * possible users the structure of the header.
41  */
42  typedef struct {
43  char start_time[32]; /**< String with the start of the waterfall in ISO-8601 format */
44  uint32_t samp_rate; /**< The sampling rate of the waterfall */
45  uint32_t fft_size; /**< The FFT size of the flowgraph */
46  uint32_t nfft_per_row; /**< The number of FFTs performed to plot one row */
47  float center_freq; /**< The center frequency of the observation. Just for viasualization purposes */
48  uint32_t endianness; /**< The endianness of the rest of the file. Should be 0 for big endian */
49  } header_t;
50 
51  /**
52  * The different types of operation of the waterfall
53  */
54  typedef enum {
55  WATERFALL_MODE_DECIMATION = 0,//!< WATERFALL_MODE_DECIMATION Performs just a decimation and computes the energy only
56  WATERFALL_MODE_MAX_HOLD = 1, //!< WATERFALL_MODE_MAX_HOLD compute the max hold energy of all the FFT snapshots between two consecutive pixel rows
57  WATERFALL_MODE_MEAN = 2 //!< WATERFALL_MODE_MEAN compute the mean energy of all the FFT snapshots between two consecutive pixel rows
58  } wf_mode_t;
59 
60  const float d_samp_rate;
61  const float d_center_freq;
62  const size_t d_fft_size;
63  wf_mode_t d_mode;
64  size_t d_refresh;
65  size_t d_fft_cnt;
66  size_t d_fft_shift;
67  size_t d_samples_cnt;
68  fft::fft_complex d_fft;
69  gr_complex *d_shift_buffer;
70  float *d_hold_buffer;
71  float *d_tmp_buffer;
72  std::ofstream d_fos;
73  std::chrono::system_clock::time_point d_start;
74 
75  void
76  apply_header();
77 
78  void
79  write_timestamp();
80 
81 public:
82  waterfall_sink_impl(float samp_rate, float center_freq, float rps,
83  size_t fft_size, const std::string &filename, int mode);
85 
86  bool
87  start();
88 
89  int
90  work(int noutput_items, gr_vector_const_void_star &input_items,
91  gr_vector_void_star &output_items);
92 
93  void
94  compute_decimation(const gr_complex *in, size_t n_fft);
95 
96  void
97  compute_max_hold(const gr_complex *in, size_t n_fft);
98 
99  void
100  compute_mean(const gr_complex *in, size_t n_fft);
101 };
102 
103 } // namespace satnogs
104 } // namespace gr
105 
106 #endif /* INCLUDED_SATNOGS_WATERFALL_SINK_IMPL_H */
107 
This block computes the waterfall of the incoming signal and stores the result to a file...
Definition: waterfall_sink.h:40
Definition: waterfall_sink_impl.h:34
Definition: amsat_duv_decoder.h:29
void compute_max_hold(const gr_complex *in, size_t n_fft)
waterfall_sink_impl(float samp_rate, float center_freq, float rps, size_t fft_size, const std::string &filename, int mode)
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
void compute_decimation(const gr_complex *in, size_t n_fft)
void compute_mean(const gr_complex *in, size_t n_fft)