GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
gnss_sdr_sample_counter.h
Go to the documentation of this file.
1 /*!
2  * \file gnss_sdr_sample_counter.h
3  * \brief Simple block to report the current receiver time based on the output of the tracking or telemetry blocks
4  * \author Javier Arribas 2018. jarribas(at)cttc.es
5  *
6  *
7  * -----------------------------------------------------------------------------
8  *
9  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
10  *
11  * GNSS-SDR is a software defined Global Navigation
12  * Satellite Systems receiver
13  *
14  * This file is part of GNSS-SDR.
15  *
16  * SPDX-License-Identifier: GPL-3.0-or-later
17  *
18  * -----------------------------------------------------------------------------
19  */
20 
21 #ifndef GNSS_SDR_GNSS_SDR_SAMPLE_COUNTER_H
22 #define GNSS_SDR_GNSS_SDR_SAMPLE_COUNTER_H
23 
24 #include <gnuradio/sync_decimator.h>
25 #include <gnuradio/types.h> // for gr_vector_const_void_star
26 #include <cstddef> // for size_t
27 #include <cstdint>
28 #if GNURADIO_USES_STD_POINTERS
29 #include <memory>
30 #else
31 #include <boost/shared_ptr.hpp>
32 #endif
33 
35 
36 #if GNURADIO_USES_STD_POINTERS
37 using gnss_sdr_sample_counter_sptr = std::shared_ptr<gnss_sdr_sample_counter>;
38 #else
39 using gnss_sdr_sample_counter_sptr = boost::shared_ptr<gnss_sdr_sample_counter>;
40 #endif
41 
42 gnss_sdr_sample_counter_sptr gnss_sdr_make_sample_counter(
43  double _fs,
44  int32_t _interval_ms,
45  size_t _size);
46 
47 class gnss_sdr_sample_counter : public gr::sync_decimator
48 {
49 public:
50  ~gnss_sdr_sample_counter() = default;
51  int work(int noutput_items,
52  gr_vector_const_void_star &input_items,
53  gr_vector_void_star &output_items);
54 
55 private:
56  friend gnss_sdr_sample_counter_sptr gnss_sdr_make_sample_counter(
57  double _fs,
58  int32_t _interval_ms,
59  size_t _size);
60 
61  gnss_sdr_sample_counter(double _fs,
62  int32_t _interval_ms,
63  size_t _size);
64 
65  double fs;
66  int64_t current_T_rx_ms; // Receiver time in ms since the beginning of the run
67  uint64_t sample_counter;
68  int32_t interval_ms;
69  int32_t report_interval_ms;
70  uint32_t samples_per_output;
71  uint32_t current_s; // Receiver time in seconds, modulo 60
72  uint32_t current_m; // Receiver time in minutes, modulo 60
73  uint32_t current_h; // Receiver time in hours, modulo 24
74  uint32_t current_days; // Receiver time in days since the beginning of the run
75  bool flag_m; // True if the receiver has been running for at least 1 minute
76  bool flag_h; // True if the receiver has been running for at least 1 hour
77  bool flag_days; // True if the receiver has been running for at least 1 day
78  bool flag_enable_send_msg;
79 };
80 
81 #endif // GNSS_SDR_GNSS_SDR_SAMPLE_COUNTER_H