GNU Radio's SATNOGS Package
noaa_apt_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,2018 Libre Space Foundation <http://librespacefoundation.org/>
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_NOAA_APT_SINK_IMPL_H
22#define INCLUDED_SATNOGS_NOAA_APT_SINK_IMPL_H
23
25#define PNG_DEBUG 3
26#include <png++/png.hpp>
27#include <chrono>
28
29
30namespace gr {
31namespace satnogs {
33
35{
36private:
37 // Factor exponential smoothing average,
38 // which is used for sync pattern detection
39 const float f_average_alpha;
40 static const bool synca_seq[];
41 static const bool syncb_seq[];
42
43 std::string d_filename_png;
44 size_t d_width;
45 size_t d_height;
46 bool d_synchronize_opt;
47 bool d_flip;
48 size_t d_history_length;
49 bool d_has_sync;
50 bool d_image_received;
51
52 png::image<png::gray_pixel> d_full_image;
53 png::image<png::gray_pixel> d_left_image;
54 png::image<png::gray_pixel> d_right_image;
55 std::string d_full_filename;
56 std::string d_left_filename;
57 std::string d_right_filename;
58
59 size_t d_current_x;
60 size_t d_current_y;
61 size_t d_num_images;
62
63 float f_max_level;
64 float f_min_level;
65 float f_average;
66
67public:
69 const char* filename_png, size_t width, size_t height, bool sync, bool flip);
71
72 // Where all the action really happens
73 int work(int noutput_items,
74 gr_vector_const_void_star& input_items,
75 gr_vector_void_star& output_items);
76
77 bool stop();
78
79private:
80 /*
81 * Checks if the history portion of the input contains a sync marker.
82 * Matches the 40 samples before pos against the patterns.
83 */
84 noaa_apt_sync_marker is_marker(size_t pos, const float* samples);
85
86 // Sets the pixel indicated by coordinates in the images (both full and split)
87 void set_pixel(size_t x, size_t y, float sample);
88
89 /*
90 * Updates d_current_x to new_x,
91 * while using historical samples to fill any resulting gaps in the images.
92 */
93 void skip_to(size_t new_x, size_t pos, const float* samples);
94
95 // Writes a single image to disk, also takes care of flipping
96 void write_image(png::image<png::gray_pixel> image, std::string filename);
97};
98
99} // namespace satnogs
100} // namespace gr
101
102#endif /* INCLUDED_SATNOGS_NOAA_APT_SINK_IMPL_H */
Definition: noaa_apt_sink_impl.h:35
noaa_apt_sink_impl(const char *filename_png, size_t width, size_t height, bool sync, bool flip)
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
Definition: noaa_apt_sink.h:36
noaa_apt_sync_marker
Definition: noaa_apt_sink_impl.h:32
Definition: amsat_duv_decoder.h:29