16 #include "LibCyberRadio/NDR651/DUCSink.h" 17 #include "LibCyberRadio/NDR651/TransmitPacketizer.h" 28 const std::string& name,
29 const std::string& radio_host_name,
30 unsigned int radio_tcp_port,
31 unsigned int tengig_iface_index,
32 float iq_scale_factor,
33 unsigned int duc_channel,
34 const std::string& duc_iface_string,
35 unsigned int duc_rate_index,
37 float duc_attenuation,
38 unsigned int duc_tx_channels,
39 double duc_tx_frequency,
40 unsigned int duc_tx_attenuation,
41 unsigned int duc_stream_id,
44 unsigned int fc_update_rate,
47 unsigned int duchsPfThresh,
48 unsigned int duchsPeThresh,
49 unsigned int duchsPeriod,
54 d_radio_host_name(radio_host_name),
55 d_radio_tcp_port(radio_tcp_port),
56 d_duc_iface_index(tengig_iface_index),
57 d_iq_scale_factor(iq_scale_factor),
58 d_duc_channel(duc_channel),
59 d_duc_iface_string(duc_iface_string),
60 d_duc_rate_index(duc_rate_index),
61 d_duc_frequency(duc_frequency),
62 d_duc_attenuation(duc_attenuation),
63 d_duc_tx_channels(duc_tx_channels),
64 d_duc_tx_frequency(duc_tx_frequency),
65 d_duc_tx_attenuation(duc_tx_attenuation),
66 d_duc_stream_id(duc_stream_id),
67 d_config_tx(config_tx),
68 d_fc_update_rate(fc_update_rate),
70 d_use_ring_buffer(use_ring_buffer),
72 d_duchsPfThresh(duchsPfThresh),
73 d_duchsPeThresh(duchsPeThresh),
74 d_duchsPeriod(duchsPeriod),
76 d_duc_txinv_mode(txinv_mode)
78 this->
debug(
"construction\n");
79 memset(d_sample_buffer, 0, SAMPLES_PER_FRAME * 2 *
sizeof(
short));
83 d_radio_host_name, d_radio_tcp_port,
84 d_duc_channel, d_duc_iface_string,
85 d_duc_iface_index, -1, d_duc_rate_index,
86 d_duc_tx_channels, d_duc_frequency,
87 d_duc_attenuation, d_duc_tx_frequency,
88 d_duc_tx_attenuation, d_duc_stream_id,
90 d_tx->setDuchsParameters(d_duchsPfThresh, d_duchsPeThresh, d_duchsPeriod, d_updatePE);
99 this->
debug(
"destruction\n");
106 return d_radio_host_name;
111 return d_radio_tcp_port;
116 return d_tengig_iface_list;
121 return d_iq_scale_factor;
126 d_iq_scale_factor = iq_scale_factor;
131 return d_duc_channel;
136 d_duc_channel = duc_channel;
143 return d_duc_iface_string;
148 return d_duc_iface_index;
153 d_duc_iface_string = duc_iface_string;
161 return d_duc_rate_index;
166 d_duc_rate_index = duc_rate_index;
173 return d_duc_frequency;
178 d_duc_frequency = duc_frequency;
185 d_duc_txinv_mode = duc_txinv_mode;
192 return d_duc_attenuation;
197 d_duc_attenuation = duc_attenuation;
204 return d_duc_tx_channels;
209 d_duc_tx_channels = duc_tx_channels;
216 return d_duc_tx_frequency;
221 d_duc_tx_frequency = duc_tx_frequency;
222 if ( (d_tx != NULL)&&d_config_tx )
228 return d_duc_tx_attenuation;
233 d_duc_tx_attenuation = duc_tx_attenuation;
234 if ( (d_tx != NULL)&&d_config_tx )
240 return d_duc_stream_id;
245 d_duc_stream_id = duc_stream_id;
253 if ( d_duc_rate_index == 16 )
256 ret = (long)(102.4e6 / pow(2, d_duc_rate_index));
260 void DUCSink::set_duchs_pf_threshold(
unsigned int duchsPfThresh) {
261 d_duchsPfThresh = duchsPfThresh;
263 d_tx->setDuchsParameters(d_duchsPfThresh, d_duchsPeThresh, d_duchsPeriod, d_updatePE);
266 void DUCSink::set_duchs_pe_threshold(
unsigned int duchsPeThresh) {
267 d_duchsPeThresh = duchsPeThresh;
269 d_tx->setDuchsParameters(d_duchsPfThresh, d_duchsPeThresh, d_duchsPeriod, d_updatePE);
272 void DUCSink::set_duchs_period(
unsigned int duchsPeriod) {
273 d_duchsPeriod = duchsPeriod;
275 d_tx->setDuchsParameters(d_duchsPfThresh, d_duchsPeThresh, d_duchsPeriod, d_updatePE);
278 void DUCSink::set_duchs_update_pe(
bool updatePE) {
279 d_updatePE = updatePE;
281 d_tx->setDuchsParameters(d_duchsPfThresh, d_duchsPeThresh, d_duchsPeriod, d_updatePE);
303 int noutput_items_processed = 0;
305 int sample_input_item;
314 (noutput_items_processed < noutput_items) )
318 for (sample = 0; sample < SAMPLES_PER_FRAME; sample++)
320 sample_input_item = noutput_items_processed * SAMPLES_PER_FRAME + sample;
321 d_sample_buffer[sample * 2] = (short)(input_items[sample_input_item].imag() * d_iq_scale_factor);
322 d_sample_buffer[sample * 2 + 1] = (short)(input_items[sample_input_item].real() * d_iq_scale_factor);
325 int samplesSent = d_tx->
sendFrame(d_sample_buffer);
326 if ( samplesSent > 0 )
327 noutput_items_processed++;
337 noutput_items_processed = noutput_items;
339 return noutput_items_processed;
343 const std::string& radio_host_name,
345 const std::vector<std::string>& tengig_iface_list)
347 this->
debug(
"setting radio parameters\n");
348 d_radio_host_name = radio_host_name;
349 d_radio_tcp_port = radio_tcp_port;
350 d_tengig_iface_list = tengig_iface_list;
351 set_duc_iface_index_from_string();
357 d_duc_tx_channels, d_duc_frequency,
358 d_duc_attenuation, d_duc_tx_frequency,
359 d_duc_attenuation, d_duc_stream_id);
363 void DUCSink::set_duc_iface_index_from_string()
365 d_duc_iface_index = 0;
366 for (
int idx = 1; idx <= (int)d_tengig_iface_list.size(); idx++)
368 if ( d_tengig_iface_list[idx-1] == d_duc_iface_string )
370 d_duc_iface_index = idx;
float get_iq_scale_factor() const
Gets the I/Q scale factor used for the radio.
bool setDucChannel(unsigned int ducChannel)
Sets the DUC channel number.
~DUCSink()
Destroys a DUCSink object.
void stop()
Stops the packetizer.
void set_duc_tx_frequency(double duc_tx_frequency)
Sets the transmit center frequency (in MHz) for the DUC in use.
void set_iq_scale_factor(float iq_scale_factor)
Sets the I/Q scale factor used for the radio.
void set_duc_attenuation(float duc_attenuation)
Sets the attenuation for the DUC in use.
void set_duc_tx_attenuation(unsigned int duc_tx_attenuation)
Sets the transmit attenuation (in dB) for the DUC in use.
void set_duc_frequency(long duc_frequency)
Sets the frequency offset for the DUC in use.
bool setDucTxChannels(unsigned int ducTxChannels)
Sets the DUC transmit channel bitmap.
unsigned int get_duc_tx_attenuation() const
Gets the transmit attenuation (in dB) for the DUC in use.
Transmit packetizer class.
bool setDucTxinvMode(unsigned int txinvMode)
Sets the DUC TX Inversion Mode.
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.
bool setRadioParameters(const std::string &radioHostName, int radioTcpPort)
Sets the radio parameters.
Class that supports debug output.
void set_duc_tx_channels(unsigned int duc_tx_channels)
Sets the transmit channel mask for the DUC in use.
int get_duc_rate_index() const
Gets the rate index (zero-based) for the DUC in use.
bool setDucRate(unsigned int ducRate)
Sets the DUC rate index.
int get_duc_iface_index() const
Gets the interface index (one-based) for the DUC in use.
unsigned int get_duc_stream_id() const
Gets the VITA stream ID for the DUC.
void start()
Starts the packetizer.
void set_duc_txinv_mode(int duc_txinv_mode)
Sets the TX inversion mode for the DUC in use.
bool setDucInterface(const std::string &ifname, unsigned int tenGigIndex)
Sets the DUC interface parameters.
std::vector< std::string > get_tengig_iface_list() const
Gets the 10GigE interface list for the radio.
virtual int debug(const char *format,...)
Outputs debug information.
bool setTxFreq(double txFreq)
Sets the transmitter frequency.
unsigned int get_duc_tx_channels() const
Gets the transmit channel mask for the DUC in use.
void set_duc_channel(int duc_channel)
Sets the channel number for the DUC in use.
bool isReadyToReceive(void)
Gets whether or not the packetizer is ready to receive data.
int get_duc_channel() const
Gets the channel number for the DUC in use.
Defines functionality for LibCyberRadio applications.
bool setDucFreq(float ducFreq)
Sets the DUC frequency.
float get_duc_attenuation() const
Gets the attenuation for the DUC in use.
std::string get_duc_iface_string() const
Gets the interface name for the DUC in use.
std::string get_radio_host_name() const
Gets the radio host name.
int sendFrames(int noutput_items, std::complex< float > *input_items)
Sends a number of VITA 49 frames.
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.
long get_duc_sample_rate() const
Gets the sample rate (in Hz) for the DUC in use, based on the rate index.
bool stop()
Stops the sink.
void set_duc_iface_string(const std::string &duc_iface_string)
Sets the interface name for the DUC in use.
bool setDucParameters(unsigned int tenGigIndex, unsigned int ducRate, unsigned int ducTxChannels, float ducFreq, float ducAtten, double txFreq, float txAtten, unsigned int streamId)
Sets the DUC parameters.
bool setTxAtten(float txAtten)
Sets the transmitter attenuation.
bool setDucAtten(float ducAtten)
Sets the DUC attenuation.
void set_duc_stream_id(unsigned int duc_stream_id)
Sets the VITA stream ID for the DUC.
long get_duc_frequency() const
Gets the frequency offset for the DUC in use.
bool setStreamId(unsigned int streamId)
Sets the stream ID.
double get_duc_tx_frequency() const
Gets the transmit center frequency (in MHz) for the DUC in use.
unsigned int sendFrame(short *samples)
Sends a number of samples as a VITA 49 frame.
int get_radio_tcp_port() const
Gets the radio TCP port.
bool start()
Starts the sink.
void set_duc_rate_index(int duc_rate_index)
Sets the rate index (zero-based) for the DUC in use.