From 9939ccd0ded4d8e6483e1468f2aa446366a4f2ac Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 13 Jun 2018 23:21:57 +0200 Subject: radioDevice: better encapsulation in base class It's not good style to have the derived classes initialize members inherited from the base class using "this->foo = bar". Rather, let's make the base class have a constructor, and call that constructor to initialize the members of the base class. While doing this * rename 'offset' to 'lo_offset' to avoid confusion with timestamp offset * move 'InterfaceType' into the base class * move 'chans' into the base class * move 'rx_sps' into the base class * mark base class members as 'protected' Change-Id: Ib885675a7612a392aa7f75fca81269ddcff2f6ab --- Transceiver52M/device/uhd/UHDDevice.cpp | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'Transceiver52M/device/uhd/UHDDevice.cpp') diff --git a/Transceiver52M/device/uhd/UHDDevice.cpp b/Transceiver52M/device/uhd/UHDDevice.cpp index ddcad3a..e8cec68 100644 --- a/Transceiver52M/device/uhd/UHDDevice.cpp +++ b/Transceiver52M/device/uhd/UHDDevice.cpp @@ -287,7 +287,6 @@ private: double tx_gain_min, tx_gain_max; double rx_gain_min, rx_gain_max; - double offset; std::vector tx_gains, rx_gains; std::vector tx_freqs, rx_freqs; @@ -317,7 +316,6 @@ private: bool set_freq(double freq, size_t chan, bool tx); Thread *async_event_thrd; - InterfaceType iface; Mutex tune_lock; }; @@ -364,22 +362,16 @@ static void thread_enable_cancel(bool cancel) } uhd_device::uhd_device(size_t tx_sps, size_t rx_sps, - InterfaceType iface, size_t chans, double offset, + InterfaceType iface, size_t chans, double lo_offset, const std::vector& tx_paths, const std::vector& rx_paths) - : tx_gain_min(0.0), tx_gain_max(0.0), + : RadioDevice(tx_sps, rx_sps, iface, chans, lo_offset, tx_paths, rx_paths), + tx_gain_min(0.0), tx_gain_max(0.0), rx_gain_min(0.0), rx_gain_max(0.0), tx_spp(0), rx_spp(0), started(false), aligned(false), rx_pkt_cnt(0), drop_cnt(0), prev_ts(0,0), ts_initial(0), ts_offset(0), async_event_thrd(NULL) { - this->tx_sps = tx_sps; - this->rx_sps = rx_sps; - this->chans = chans; - this->offset = offset; - this->iface = iface; - this->tx_paths = tx_paths; - this->rx_paths = rx_paths; } uhd_device::~uhd_device() @@ -1057,8 +1049,8 @@ uhd::tune_request_t uhd_device::select_freq(double freq, size_t chan, bool tx) uhd::tune_request_t treq(freq); if (dev_type == UMTRX) { - if (offset != 0.0) - return uhd::tune_request_t(freq, offset); + if (lo_offset != 0.0) + return uhd::tune_request_t(freq, lo_offset); // Don't use DSP tuning, because LMS6002D PLL steps are small enough. // We end up with DSP tuning just for 2-3Hz, which is meaningless and @@ -1070,10 +1062,10 @@ uhd::tune_request_t uhd_device::select_freq(double freq, size_t chan, bool tx) treq.dsp_freq = 0.0; return treq; } else if (chans == 1) { - if (offset == 0.0) + if (lo_offset == 0.0) return treq; - return uhd::tune_request_t(freq, offset); + return uhd::tune_request_t(freq, lo_offset); } else if ((dev_type != B210) || (chans > 2) || (chan > 1)) { LOG(ALERT) << chans << " channels unsupported"; return treq; @@ -1556,9 +1548,9 @@ std::string smpl_buf::str_code(ssize_t code) } RadioDevice *RadioDevice::make(size_t tx_sps, size_t rx_sps, - InterfaceType iface, size_t chans, double offset, + InterfaceType iface, size_t chans, double lo_offset, const std::vector& tx_paths, const std::vector& rx_paths) { - return new uhd_device(tx_sps, rx_sps, iface, chans, offset, tx_paths, rx_paths); + return new uhd_device(tx_sps, rx_sps, iface, chans, lo_offset, tx_paths, rx_paths); } -- cgit v1.2.3