GNU Radio's SATNOGS Package
metadata.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) 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 INCLUDE_SATNOGS_METADATA_H_
22#define INCLUDE_SATNOGS_METADATA_H_
23
26#include <nlohmann/json.hpp>
27#include <pmt/pmt.h>
28#include <cstdint>
29#include <string>
30
31namespace gr {
32
33namespace satnogs {
34
36{
37public:
38 typedef std::shared_ptr<metadata> metadata_sptr;
39
40 typedef enum key {
41 PDU = 0,
60 KEYS_NUM
61 } key_t;
62
63 static std::string value(const key_t& k);
64
65 static std::string keys();
66
67 static std::string time_iso8601();
68
69 static void add_time_iso8601(pmt::pmt_t& m);
70
71 static void add_pdu(pmt::pmt_t& m, const uint8_t* in, size_t len);
72
73 static void add_crc_valid(pmt::pmt_t& m, bool valid);
74
75 static void add_sample_start(pmt::pmt_t& m, uint64_t idx);
76
77 static void add_sample_cnt(pmt::pmt_t& m, uint64_t cnt);
78
79 static void add_symbol_erasures(pmt::pmt_t& m, uint32_t cnt);
80
81 static void add_corrected_bits(pmt::pmt_t& m, uint32_t cnt);
82
83 static void add_center_freq(pmt::pmt_t& m, double offset);
84
85 static void add_freq_offset(pmt::pmt_t& m, double offset);
86
87 static void add_snr(pmt::pmt_t& m, float snr);
88
89 static void
90 add_decoder(pmt::pmt_t& m, const std::string& name, const std::string& version);
91
92 static void add_decoder(pmt::pmt_t& m, const decoder* dec);
93
94 static void add_antenna_azimuth(pmt::pmt_t& m, double azimuth);
95
96 static void add_antenna_elevation(pmt::pmt_t& m, double elevation);
97
98 static void add_antenna_polarization(pmt::pmt_t& m, std::string polarization);
99
100 static void add_phase_delay(pmt::pmt_t& m, uint64_t phase);
101
102 static void add_resampling_ratio(pmt::pmt_t& m, float ratio);
103
104 static void add_symbol_timing_error(pmt::pmt_t& m, double error);
105
106 static nlohmann::json to_json(const pmt::pmt_t& m);
107
108 /*!
109 * Transforms the PMT metadata message of gr-satnogs to the appropriate form.
110 * The form and the storage is implementation specific
111 *
112 * @param m the message containing a dictionary of gr-satnogs matadata
113 */
114 virtual void transform(pmt::pmt_t& m) = 0;
115
116 /*!
117 * Stores to file the metadata. The form of the data depends on the
118 * implementation
119 *
120 * @param filename the full path to the metadata file
121 */
122 virtual void to_file(const std::string& filename) = 0;
123
124 /*!
125 *
126 * @return string representation of the processed metadata
127 */
128 virtual const std::string to_sting() = 0;
129
130 virtual ~metadata();
131};
132
133} // namespace satnogs
134
135} // namespace gr
136
137
138#endif /* INCLUDE_SATNOGS_METADATA_H_ */
#define SATNOGS_API
Definition: api.h:19
Abstract class that provided the API for the c decoders.
Definition: decoder.h:71
Definition: metadata.h:36
static void add_antenna_polarization(pmt::pmt_t &m, std::string polarization)
static void add_center_freq(pmt::pmt_t &m, double offset)
static void add_freq_offset(pmt::pmt_t &m, double offset)
static nlohmann::json to_json(const pmt::pmt_t &m)
static void add_antenna_elevation(pmt::pmt_t &m, double elevation)
static void add_decoder(pmt::pmt_t &m, const std::string &name, const std::string &version)
static void add_phase_delay(pmt::pmt_t &m, uint64_t phase)
static void add_time_iso8601(pmt::pmt_t &m)
static std::string value(const key_t &k)
static void add_symbol_timing_error(pmt::pmt_t &m, double error)
static void add_resampling_ratio(pmt::pmt_t &m, float ratio)
static void add_antenna_azimuth(pmt::pmt_t &m, double azimuth)
virtual void to_file(const std::string &filename)=0
static std::string time_iso8601()
static void add_sample_cnt(pmt::pmt_t &m, uint64_t cnt)
static std::string keys()
static void add_symbol_erasures(pmt::pmt_t &m, uint32_t cnt)
static void add_crc_valid(pmt::pmt_t &m, bool valid)
static void add_pdu(pmt::pmt_t &m, const uint8_t *in, size_t len)
static void add_snr(pmt::pmt_t &m, float snr)
static void add_decoder(pmt::pmt_t &m, const decoder *dec)
virtual const std::string to_sting()=0
enum gr::satnogs::metadata::key key_t
virtual void transform(pmt::pmt_t &m)=0
static void add_sample_start(pmt::pmt_t &m, uint64_t idx)
static void add_corrected_bits(pmt::pmt_t &m, uint32_t cnt)
key
Definition: metadata.h:40
@ ANTENNA_ELEVATION
Definition: metadata.h:57
@ SAMPLE_START
Definition: metadata.h:50
@ DECODER_CRC_VALID
Definition: metadata.h:42
@ DECODER_NAME
Definition: metadata.h:54
@ DECODER_SYMBOL_ERASURES
Definition: metadata.h:52
@ SNR
Definition: metadata.h:53
@ DECODER_RESAMPLING_RATIO
Definition: metadata.h:45
@ FREQ_OFFSET
Definition: metadata.h:47
@ TIME
Definition: metadata.h:49
@ CENTER_FREQ
Definition: metadata.h:43
@ ANTENNA_POLARIZATION
Definition: metadata.h:58
@ SYMBOL_TIMING_ERROR
Definition: metadata.h:59
@ DECODER_VERSION
Definition: metadata.h:55
@ ANTENNA_AZIMUTH
Definition: metadata.h:56
@ SAMPLE_CNT
Definition: metadata.h:51
@ DECODER_PHASE_DELAY
Definition: metadata.h:44
@ DECODER_CORRECTED_BITS
Definition: metadata.h:48
@ CRC_VALID
Definition: metadata.h:46
int k
Definition: decode_rs.h:73
CONSTDATA date::month dec
Definition: date.h:1831
Definition: amsat_duv_decoder.h:29