GNU Radio Manual and C++ API Reference  3.10.9.1
The Free & Open Software Radio Ecosystem
rfnoc_siggen.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2019 Ettus Research, a National Instruments Brand.
4  * Copyright 2020 Free Software Foundation, Inc.
5  *
6  * SPDX-License-Identifier: GPL-3.0-or-later
7  */
8 
9 #ifndef INCLUDED_GR_UHD_RFNOC_SIGGEN_H
10 #define INCLUDED_GR_UHD_RFNOC_SIGGEN_H
11 
12 #include <gnuradio/uhd/api.h>
14 
15 namespace gr {
16 namespace uhd {
17 
18 /*! RFNoC Signal Generator Block
19  *
20  * \ingroup uhd_blk
21  */
22 class GR_UHD_API rfnoc_siggen : virtual public rfnoc_block
23 {
24 public:
25  typedef std::shared_ptr<rfnoc_siggen> sptr;
26 
27  enum class siggen_waveform { CONSTANT, SINE_WAVE, NOISE };
28 
29  /*!
30  * \param graph Reference to the rfnoc_graph object this block is attached to
31  * \param block_args Additional block arguments
32  * \param device_select Device Selection
33  * \param instance Instance Selection
34  */
35  static sptr make(rfnoc_graph::sptr graph,
36  const ::uhd::device_addr_t& block_args,
37  const int device_select,
38  const int instance);
39 
40  /*! Set the amplitude of the signal
41  *
42  * \param amplitude Amplitude of the signal (double)
43  * \param chan Channel index
44  */
45  virtual void set_amplitude(const double amplitude, const size_t chan) = 0;
46 
47  /*! Get the amplitude of the signal
48  *
49  * \param chan Channel index
50  * \returns Signal amplitude
51  */
52  virtual double get_amplitude(const size_t chan) = 0;
53 
54  /*! Set a complex constant of the signal
55  *
56  * \param constant Constant for the signal (complex double)
57  * \param chan Channel index
58  */
59  virtual void set_constant(const std::complex<double> constant, const size_t chan) = 0;
60 
61  /*! Get the complex constant of the signal
62  *
63  * \param chan Channel index
64  * \returns Complex constant of signal
65  */
66  virtual std::complex<double> get_constant(const size_t chan) = 0;
67 
68  /*! Enable the channel
69  *
70  * \param enable Boolean to enable or disable output
71  * \param chan Channel index
72  */
73  virtual void set_enable(const bool enable, const size_t chan) = 0;
74 
75  /*! Get the channel enable state
76  *
77  * \param chan Channel index
78  * \returns Enable State
79  */
80  virtual bool get_enable(const size_t chan) = 0;
81 
82  /*! Set the sine frequency in terms of the sample_rate
83  *
84  * \param frequency The frequency of the tone being set
85  * \param sample_rate The sample rate of the block
86  * \param chan Channel index
87  */
88  virtual void set_sine_frequency(const double frequency,
89  const double sample_rate,
90  const size_t chan) = 0;
91 
92  /*! Set the sine frequency phase increment
93  *
94  * \param phase_inc The normalized phase increment per sample
95  * \param chan Channel index
96  */
97  virtual void set_sine_phase_increment(const double phase_inc, const size_t chan) = 0;
98 
99  /*! Get the sine frequency phase increment
100  *
101  * \param chan Channel index
102  * \returns The normalized phase increment per sample
103  */
104  virtual double get_sine_phase_increment(const size_t chan) = 0;
105 
106  /*! Set the type of waveform using the siggen_waveform class
107  *
108  * \param type The waveform to choose
109  * \param chan Channel index
110  */
111  virtual void set_waveform(const siggen_waveform type, const size_t chan) = 0;
112 
113  /*! Set the type of waveform using a string
114  *
115  * \param type The waveform to choose ["CONSTANT", "SINE_WAVE", "NOISE"]
116  * \param chan Channel index
117  */
118  virtual void set_waveform(const std::string& type, const size_t chan) = 0;
119 
120  /*! Get the type of waveform as a string
121  *
122  * \param chan Channel index
123  * \returns The current waveform as a string
124  */
125  virtual std::string get_waveform_string(const size_t chan) = 0;
126 
127  /*! Get the waveform
128  *
129  * \param chan Channel index
130  * \returns The current waveform
131  */
132  virtual siggen_waveform get_waveform(const size_t chan) = 0;
133 
134  /*! Set the number of samples per packet
135  *
136  * \param spp The number of samples per packet
137  * \param chan Channel index
138  */
139  virtual void set_samples_per_packet(const size_t spp, const size_t chan) = 0;
140 
141  /*! Get the number of samples per packet
142  *
143  * \param chan Channel index
144  * \returns The number of samples per packet
145  */
146  virtual size_t get_samples_per_packet(const size_t chan) = 0;
147 };
148 
149 } // namespace uhd
150 } // namespace gr
151 
152 #endif /* INCLUDED_GR_UHD_RFNOC_SIGGEN_H */
Definition: rfnoc_block.h:29
std::shared_ptr< rfnoc_block > sptr
Definition: rfnoc_block.h:37
std::shared_ptr< rfnoc_graph > sptr
Definition: rfnoc_graph.h:32
Definition: rfnoc_siggen.h:23
virtual std::string get_waveform_string(const size_t chan)=0
virtual void set_samples_per_packet(const size_t spp, const size_t chan)=0
virtual double get_amplitude(const size_t chan)=0
virtual void set_constant(const std::complex< double > constant, const size_t chan)=0
static sptr make(rfnoc_graph::sptr graph, const ::uhd::device_addr_t &block_args, const int device_select, const int instance)
virtual void set_sine_phase_increment(const double phase_inc, const size_t chan)=0
virtual size_t get_samples_per_packet(const size_t chan)=0
virtual void set_waveform(const std::string &type, const size_t chan)=0
std::shared_ptr< rfnoc_siggen > sptr
Definition: rfnoc_siggen.h:25
siggen_waveform
Definition: rfnoc_siggen.h:27
virtual siggen_waveform get_waveform(const size_t chan)=0
virtual void set_waveform(const siggen_waveform type, const size_t chan)=0
virtual void set_enable(const bool enable, const size_t chan)=0
virtual double get_sine_phase_increment(const size_t chan)=0
virtual std::complex< double > get_constant(const size_t chan)=0
virtual void set_amplitude(const double amplitude, const size_t chan)=0
virtual void set_sine_frequency(const double frequency, const double sample_rate, const size_t chan)=0
virtual bool get_enable(const size_t chan)=0
#define GR_UHD_API
Definition: gr-uhd/include/gnuradio/uhd/api.h:18
GR_RUNTIME_API const pmt::pmt_t sample_rate()
GNU Radio logging wrapper.
Definition: basic_block.h:29