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,2022 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 <gnuradio/fft/fft.h>
26#include <volk/volk.h>
27#include <chrono>
28#include <fstream>
29#include <iostream>
30
31namespace gr {
32namespace satnogs {
33
35{
36private:
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
44 format */
45 uint32_t samp_rate; /**< The sampling rate of the waterfall */
46 uint32_t fft_size; /**< The FFT size of the flowgraph */
47 uint32_t nfft_per_row; /**< The number of FFTs performed to plot one row */
48 float center_freq; /**< The center frequency of the observation. Just for
49 viasualization purposes */
50 uint32_t endianness; /**< The endianness of the rest of the file. Should be 0 for
51 big endian */
52 } header_t;
53
54 /**
55 * The different types of operation of the waterfall
56 */
57 typedef enum {
58 WATERFALL_MODE_DECIMATION = 0, //!< WATERFALL_MODE_DECIMATION Performs just a
59 //!< decimation and computes the energy only
60 WATERFALL_MODE_MAX_HOLD =
61 1, //!< WATERFALL_MODE_MAX_HOLD compute the max hold energy of all the FFT
62 //!< snapshots between two consecutive pixel rows
63 WATERFALL_MODE_MEAN = 2 //!< WATERFALL_MODE_MEAN compute the mean energy of all
64 //!< the FFT snapshots between two consecutive pixel rows
65 } wf_mode_t;
66
67 const float d_samp_rate;
68 const float d_center_freq;
69 const size_t d_fft_size;
70 wf_mode_t d_mode;
71 size_t d_refresh;
72 size_t d_fft_cnt;
73 size_t d_fft_shift;
74 size_t d_samples_cnt;
75 fft::fft<gr_complex, true> d_fft;
76 volk::vector<gr_complex> d_shift_buffer;
77 volk::vector<float> d_hold_buffer;
78 volk::vector<float> d_tmp_buffer;
79 std::ofstream d_fos;
80 std::chrono::system_clock::time_point d_start;
81
82 void apply_header();
83
84 void write_timestamp();
85
86public:
87 waterfall_sink_impl(float samp_rate,
88 float center_freq,
89 float rps,
90 size_t fft_size,
91 const std::string& filename,
92 int mode);
94
95 bool start();
96
97 int work(int noutput_items,
98 gr_vector_const_void_star& input_items,
99 gr_vector_void_star& output_items);
100
101 void compute_decimation(const gr_complex* in, size_t n_fft);
102
103 void compute_max_hold(const gr_complex* in, size_t n_fft);
104
105 void compute_mean(const gr_complex* in, size_t n_fft);
106};
107
108} // namespace satnogs
109} // namespace gr
110
111#endif /* INCLUDED_SATNOGS_WATERFALL_SINK_IMPL_H */
Definition: waterfall_sink_impl.h:35
void compute_mean(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)
void compute_max_hold(const gr_complex *in, size_t n_fft)
void compute_decimation(const gr_complex *in, size_t n_fft)
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
This block computes the waterfall of the incoming signal and stores the result to a file.
Definition: waterfall_sink.h:41
Definition: amsat_duv_decoder.h:29