GNU Radio's CYBERRADIO Package
vita_multifile_iq_source.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /***************************************************************************
3  * \file vita_multifile_iq_source.h
4  *
5  * \brief Generic VITA 49-compatible I/Q data source block that pulls its
6  * source data from a sequence of files.
7  *
8  * \author DA
9  * \copyright Copyright (c) 2015 CyberRadio Solutions, Inc.
10  *
11  * \note This is a re-implementation of GNU Radio's file_source
12  * block. It includes some new features that make it more useful
13  * in a GUI environment.
14  *
15  */
16 
17 #ifndef INCLUDED_CYBERRADIO_VITA_MULTIFILE_IQ_SOURCE_H
18 #define INCLUDED_CYBERRADIO_VITA_MULTIFILE_IQ_SOURCE_H
19 
20 #include <CyberRadio/api.h>
21 #include <gnuradio/sync_block.h>
22 #include <string>
23 #include <vector>
24 
25 
26 /*!
27  * \brief Provides GNU Radio blocks.
28  */
29 namespace gr
30 {
31  /*!
32  * \brief Provides GNU Radio blocks for CyberRadio Solutions products.
33  */
34  namespace CyberRadio
35  {
36  /*!
37  * \ingroup CyberRadioSignals
38  *
39  * \brief Generic VITA 49-compatible I/Q data source block that
40  * pulls its source data from a sequence of files.
41  *
42  * \details
43  * The vita_multifile_iq_source block provides I/Q data from a
44  * sequence of files on disk. The sequence of files can be
45  * explicitly provided by the user, determined by evaluating a
46  * wildcard file specification, or some combination of these.
47  *
48  * The behavior of this block when it has no active files to read
49  * data from depends on the Terminate When Data Ends option. If
50  * this option is True, then the flowgraph will terminate. If it
51  * is not set, then it will output (complex) zeros until it does
52  * have valid data files.
53  *
54  * This block assumes that the data being read from disk is in
55  * a format returned by an NDR-class radio. This will be either
56  * raw I/Q data (16-bit interleaved I and Q) or VITA 49 frame
57  * format. The output from this block is native (32-bit) complex.
58  *
59  * The vita_multifile_iq_source block can also produce stream tags at
60  * the beginning of each received VITA 49 frame. The block generates
61  * the following stream tags, as appropriate for the radio:
62  * \li absolute_sample_num -- The absolute sample number
63  * \li absolute_packet_num -- The absolute packet number
64  * \li filename -- The file name that the data comes from. If the
65  * packet spans files, the file name will be the file that the
66  * last segment of the packet data came from.
67  * \li frame_counter -- The VITA frame counter
68  * \li frame_size -- The VITA frame size
69  * \li packet_type -- The VITA packet type
70  * \li packet_counter -- The VITA packet counter
71  * \li packet_size -- The VITA packet size
72  * \li stream_id -- The VITA stream ID
73  * \li timestamp_int_type -- The VITA timestamp integer (TSI) field type
74  * \li timestamp_int -- The VITA timestamp integer (TSI) field
75  * \li timestamp_frac_type -- The VITA timestamp fractional (TSF) field type
76  * \li timestamp_frac -- The VITA timestamp fractional (TSF) field
77  * \li organizationally_unique_id -- The organizationally unique ID (OUI)
78  * \li information_class_code -- The information class code (ICC)
79  * \li packet_class_code -- The packet class code (PCC)
80  *
81  * In addition, this block provides some features that are useful
82  * in a GUI environment, where the file(s) that the user wants to
83  * use is (are) not necessarily known when the flowgraph starts.
84  * (This is a drawback of the stock file_source object in GNU Radio.)
85  *
86  */
88  virtual public gr::sync_block
89  {
90  public:
91  // gr::CyberRadio::vita_multifile_iq_source::sptr
92  typedef boost::shared_ptr<vita_multifile_iq_source> sptr;
93 
94  /*!
95  * \brief Creates a vita_multifile_iq_source block.
96  *
97  * \param filespecs A list of filenames and/or wildcard file
98  * specifications for the data files to use.
99  * \param alphabetical Whether the block should alphabetically sort
100  * file names during file spec evaluation.
101  * \param vita_type The VITA 49 enable option value. A value of 0
102  * indicates raw I/Q format, and any other value indicates VITA
103  * 49 frame format.
104  * \param payload_size The VITA 49 or I/Q payload size for the radio, in
105  * bytes. If VITA 49 output is disabled, then this parameter provides
106  * the total size of all raw I/Q data transmitted in a single packet.
107  * \param vita_header_size The VITA 49 header size for the radio, in bytes.
108  * If VITA 49 output is disabled, then this parameter is ignored.
109  * \param vita_tail_size The VITA 49 tail size for the radio, in bytes.
110  * If VITA 49 output is disabled, then this parameter is ignored.
111  * \param byte_swapped Whether the bytes in the packet are swapped (with
112  * respect to the endianness employed by the host operating system).
113  * \param iq_swapped Whether I and Q data in the payload are swapped.
114  * \param iq_scale_factor Scale factor for coverting I/Q data from
115  * native sample format to complex output.
116  * \param repeat True if the data should be repeated from the
117  * beginning once the last item is processed, False otherwise.
118  * \param terminate_at_end True if the flowgraph should terminate when the
119  * all of the file data has been processed. This option has no effect
120  * if Repeat is True.
121  * \param tagged Whether the block should produce stream tags. Defaults to
122  * False.
123  * \param debug Whether the block produces debug output.
124  *
125  * \return A boost::shared_ptr<vita_multifile_iq_source> representing
126  * the new block.
127  */
128  static sptr make(const std::vector<std::string>& filespecs = std::vector<std::string>(),
129  bool alphabetical = false,
130  int vita_type = 0,
131  size_t payload_size = 8192,
132  size_t vita_header_size = 0,
133  size_t vita_tail_size = 0,
134  bool byte_swapped = false,
135  bool iq_swapped = false,
136  float iq_scale_factor = 1.0,
137  bool repeat = false,
138  bool terminate_at_end = false,
139  bool tagged = false,
140  bool debug = false);
141 
142  /*!
143  * \brief Opens a new sequence of files.
144  *
145  * Calling this method while this block is already
146  * reading data closes the file being used and abandons
147  * the previous file sequence.
148  *
149  * \param filespecs A list of filenames and/or wildcard file
150  * specifications for the data files to use.
151  * \param alphabetical Whether the block should alphabetically sort
152  * file names during file spec evaluation.
153  * \param repeat True if the data should be repeated from the
154  * beginning once the last item is processed, False otherwise.
155  * \param terminate_at_end True if the flowgraph should terminate when the
156  * all of the file data has been processed. This option has no effect
157  * if Repeat is True.
158  */
159  virtual void open(const std::vector<std::string>& filespecs = std::vector<std::string>(),
160  bool alphabetical = false,
161  bool repeat = false,
162  bool terminate_at_end = false) = 0;
163 
164  /*!
165  * \brief Close the existing file sequence.
166  *
167  * Calling this method causes this block to provide
168  * zero values until provided with a file sequence than
169  * can be opened.
170  *
171  */
172  virtual void close() = 0;
173 
174  /*!
175  * \brief Sets the I/Q scale factor.
176  * \param iq_scale_factor The new I/Q scale factor.
177  */
178  virtual void set_iq_scale_factor(float iq_scale_factor) = 0;
179 
180  /*!
181  * \brief Gets the real-time calculated sample rate for a specific
182  * output.
183  * \return The sample rate (in samples per second).
184  */
185  virtual float get_realtime_sample_rate() = 0;
186  };
187 
188  } /* namespace CyberRadio */
189 } /* namespace gr */
190 
191 #endif /* INCLUDED_CYBERRADIO_VITA_MULTIFILE_IQ_SOURCE_H */
#define CYBERRADIO_API
Definition: api.h:30
Provides GNU Radio blocks.
Definition: NDR651_duc_sink_mk2.h:21
Generic VITA 49-compatible I/Q data source block that pulls its source data from a sequence of files...
Definition: vita_multifile_iq_source.h:87
boost::shared_ptr< vita_multifile_iq_source > sptr
Definition: vita_multifile_iq_source.h:92