libcyberradio  22.01.24
DUCSink.h
1 /* -*- c++ -*- */
2 /***************************************************************************
3  * \file DUCSink.h
4  *
5  * \brief Implementation of the digital upconverter (DUC) transmission
6  * sink block for the NDR651.
7  *
8  * \author DA
9  * \copyright 2015 CyberRadio Solutions, Inc.
10  */
11 
12 #ifndef INCLUDED_LIBCYBERRADIO_NDR651_DUC_SINK_H
13 #define INCLUDED_LIBCYBERRADIO_NDR651_DUC_SINK_H
14 
15 #include "LibCyberRadio/Common/Debuggable.h"
16 #include "LibCyberRadio/NDR651/TransmitPacketizer.h"
17 #include <stdio.h>
18 #include <time.h>
19 #include <sys/types.h>
20 #include <vector>
21 #include <complex>
22 #include <string>
23 
24 
28 namespace LibCyberRadio
29 {
34  namespace NDR651
35  {
39  class DUCSink : public Debuggable
40  {
41  public:
73  DUCSink(
74  const std::string& name = "DUCSink",
75  /* For the radio in general */
76  const std::string& radio_host_name = "",
77  unsigned int radio_tcp_port = 8617,
78  unsigned int tengig_iface_index = 1,
79  float iq_scale_factor = 1.0,
80  /* For an individual DUC on the radio */
81  unsigned int duc_channel = 1,
82  const std::string& duc_iface_string = "eth0",
83  unsigned int duc_rate_index = 0,
84  long duc_frequency = 0,
85  float duc_attenuation = 0,
86  unsigned int duc_tx_channels = 0,
87  double duc_tx_frequency = 900,
88  unsigned int duc_tx_attenuation = 0,
89  unsigned int duc_stream_id = 40001,
90  bool config_tx = false,
91  bool debug = false,
92  unsigned int fc_update_rate = 20,
93  bool use_udp = false,
94  bool use_ring_buffer = false,
95  unsigned int duchsPfThresh = 25,
96  unsigned int duchsPeThresh = 24,
97  unsigned int duchsPeriod = 10,
98  bool updatePE = false,
99  int txinv_mode = 0);
103  ~DUCSink();
108  std::string get_radio_host_name() const;
113  int get_radio_tcp_port() const;
118  std::vector<std::string> get_tengig_iface_list() const;
125  void set_radio_params(const std::string& radio_host_name,
126  int radio_tcp_port,
127  const std::vector<std::string>& tengig_iface_list);
132  float get_iq_scale_factor() const;
137  void set_iq_scale_factor(float iq_scale_factor);
143  int get_duc_channel() const;
149  void set_duc_channel(int duc_channel);
154  std::string get_duc_iface_string() const;
160  int get_duc_iface_index() const;
165  void set_duc_iface_string(const std::string& duc_iface_string);
171  int get_duc_rate_index() const;
177  void set_duc_rate_index(int duc_rate_index);
183  long get_duc_frequency() const;
189  void set_duc_frequency(long duc_frequency);
195  void set_duc_txinv_mode(int duc_txinv_mode);
201  float get_duc_attenuation() const;
207  void set_duc_attenuation(float duc_attenuation);
213  unsigned int get_duc_tx_channels() const;
219  void set_duc_tx_channels(unsigned int duc_tx_channels);
225  double get_duc_tx_frequency() const;
231  void set_duc_tx_frequency(double duc_tx_frequency);
236  unsigned int get_duc_tx_attenuation() const;
242  void set_duc_tx_attenuation(unsigned int duc_tx_attenuation);
247  unsigned int get_duc_stream_id() const;
252  void set_duc_stream_id(unsigned int duc_stream_id);
258  long get_duc_sample_rate() const;
259 
260  void set_duchs_pf_threshold(unsigned int duchsPfThresh);
261  void set_duchs_pe_threshold(unsigned int duchsPeThresh);
262  void set_duchs_period(unsigned int duchsPeriod);
263  void set_duchs_update_pe(bool updatePE);
264 
268  bool start();
272  bool stop();
281  int sendFrames(int noutput_items,
282  std::complex<float>* input_items);
283 
284  protected:
285  // Get the DUC interface index number from the interface
286  // string
287  void set_duc_iface_index_from_string();
288 
289  protected:
290  std::string d_name;
291  std::string d_radio_host_name;
292  unsigned int d_radio_tcp_port;
293  std::vector<std::string> d_tengig_iface_list;
294  float d_iq_scale_factor;
295  unsigned int d_duc_channel;
296  std::string d_duc_iface_string;
297  unsigned int d_duc_iface_index;
298  unsigned int d_duc_rate_index;
299  long d_duc_frequency;
300  float d_duc_attenuation;
301  unsigned int d_duc_tx_channels;
302  double d_duc_tx_frequency;
303  unsigned int d_duc_tx_attenuation;
304  unsigned int d_duc_stream_id;
305  int d_duc_txinv_mode;
306  bool d_config_tx;
307  unsigned int d_fc_update_rate;
308  bool d_use_udp;
309  bool d_use_ring_buffer;
310  TransmitPacketizer* d_tx;
311  short d_sample_buffer[SAMPLES_PER_FRAME * 2];
312  unsigned int d_duchsPfThresh, d_duchsPeThresh, d_duchsPeriod;
313  bool d_updatePE;
314  };
315 
316  } // namespace NDR651
317 
318 } // namespace LibCyberRadio
319 
320 #endif /* INCLUDED_LIBCYBERRADIO_NDR651_DUC_SINK_H */
321 
float get_iq_scale_factor() const
Gets the I/Q scale factor used for the radio.
Definition: DUCSink.cpp:119
~DUCSink()
Destroys a DUCSink object.
Definition: DUCSink.cpp:97
void set_duc_tx_frequency(double duc_tx_frequency)
Sets the transmit center frequency (in MHz) for the DUC in use.
Definition: DUCSink.cpp:219
void set_iq_scale_factor(float iq_scale_factor)
Sets the I/Q scale factor used for the radio.
Definition: DUCSink.cpp:124
void set_duc_attenuation(float duc_attenuation)
Sets the attenuation for the DUC in use.
Definition: DUCSink.cpp:195
void set_duc_tx_attenuation(unsigned int duc_tx_attenuation)
Sets the transmit attenuation (in dB) for the DUC in use.
Definition: DUCSink.cpp:231
void set_duc_frequency(long duc_frequency)
Sets the frequency offset for the DUC in use.
Definition: DUCSink.cpp:176
unsigned int get_duc_tx_attenuation() const
Gets the transmit attenuation (in dB) for the DUC in use.
Definition: DUCSink.cpp:226
DUCSink(const std::string &name="DUCSink", const std::string &radio_host_name="", unsigned int radio_tcp_port=8617, unsigned int tengig_iface_index=1, float iq_scale_factor=1.0, unsigned int duc_channel=1, const std::string &duc_iface_string="eth0", unsigned int duc_rate_index=0, long duc_frequency=0, float duc_attenuation=0, unsigned int duc_tx_channels=0, double duc_tx_frequency=900, unsigned int duc_tx_attenuation=0, unsigned int duc_stream_id=40001, bool config_tx=false, bool debug=false, unsigned int fc_update_rate=20, bool use_udp=false, bool use_ring_buffer=false, unsigned int duchsPfThresh=25, unsigned int duchsPeThresh=24, unsigned int duchsPeriod=10, bool updatePE=false, int txinv_mode=0)
Creates a DUCSink object.
Definition: DUCSink.cpp:27
Class that supports debug output.
Definition: Debuggable.h:38
void set_duc_tx_channels(unsigned int duc_tx_channels)
Sets the transmit channel mask for the DUC in use.
Definition: DUCSink.cpp:207
int get_duc_rate_index() const
Gets the rate index (zero-based) for the DUC in use.
Definition: DUCSink.cpp:159
int get_duc_iface_index() const
Gets the interface index (one-based) for the DUC in use.
Definition: DUCSink.cpp:146
unsigned int get_duc_stream_id() const
Gets the VITA stream ID for the DUC.
Definition: DUCSink.cpp:238
void set_duc_txinv_mode(int duc_txinv_mode)
Sets the TX inversion mode for the DUC in use.
Definition: DUCSink.cpp:183
std::vector< std::string > get_tengig_iface_list() const
Gets the 10GigE interface list for the radio.
Definition: DUCSink.cpp:114
virtual int debug(const char *format,...)
Outputs debug information.
Definition: Debuggable.cpp:95
unsigned int get_duc_tx_channels() const
Gets the transmit channel mask for the DUC in use.
Definition: DUCSink.cpp:202
void set_duc_channel(int duc_channel)
Sets the channel number for the DUC in use.
Definition: DUCSink.cpp:134
int get_duc_channel() const
Gets the channel number for the DUC in use.
Definition: DUCSink.cpp:129
Defines functionality for LibCyberRadio applications.
Definition: App.h:23
float get_duc_attenuation() const
Gets the attenuation for the DUC in use.
Definition: DUCSink.cpp:190
std::string get_duc_iface_string() const
Gets the interface name for the DUC in use.
Definition: DUCSink.cpp:141
std::string get_radio_host_name() const
Gets the radio host name.
Definition: DUCSink.cpp:104
int sendFrames(int noutput_items, std::complex< float > *input_items)
Sends a number of VITA 49 frames.
Definition: DUCSink.cpp:298
void set_radio_params(const std::string &radio_host_name, int radio_tcp_port, const std::vector< std::string > &tengig_iface_list)
Sets the radio parameters.
Definition: DUCSink.cpp:342
long get_duc_sample_rate() const
Gets the sample rate (in Hz) for the DUC in use, based on the rate index.
Definition: DUCSink.cpp:250
bool stop()
Stops the sink.
Definition: DUCSink.cpp:291
void set_duc_iface_string(const std::string &duc_iface_string)
Sets the interface name for the DUC in use.
Definition: DUCSink.cpp:151
void set_duc_stream_id(unsigned int duc_stream_id)
Sets the VITA stream ID for the DUC.
Definition: DUCSink.cpp:243
long get_duc_frequency() const
Gets the frequency offset for the DUC in use.
Definition: DUCSink.cpp:171
double get_duc_tx_frequency() const
Gets the transmit center frequency (in MHz) for the DUC in use.
Definition: DUCSink.cpp:214
DUC sink class.
Definition: DUCSink.h:39
int get_radio_tcp_port() const
Gets the radio TCP port.
Definition: DUCSink.cpp:109
bool start()
Starts the sink.
Definition: DUCSink.cpp:285
void set_duc_rate_index(int duc_rate_index)
Sets the rate index (zero-based) for the DUC in use.
Definition: DUCSink.cpp:164