Drop old TxGain APIs from parent radioDevice abstract class

All radioDevice subclasses except USRPDevice have already been reworked
to use the new SetPowerAttenuation() methods, hence we can drop the
compatibility layer that was added to transition from the old API to the
new one, and move those functions to USRPDevice.

This way we simplify the parent abstract class with methods not needed
by most devices and not used anymore by external users of those classes.

Change-Id: Ice005cd0a07c49b6e212c06f1228ef93c24db727
This commit is contained in:
Pau Espin 2020-06-19 18:11:54 +02:00
parent f68f19b110
commit 5bd3d4263b
5 changed files with 20 additions and 50 deletions

View File

@ -151,17 +151,8 @@ class RadioDevice {
virtual double getRxFreq(size_t chan = 0) = 0;
virtual double getSampleRate()=0;
/* Default backward-compatible implementation based on TxGain APIs. New
implementations should be based on getNominalTxPower() once implemented for
the specific backend. */
virtual double setPowerAttenuation(int atten, size_t chan) {
double rfGain;
rfGain = setTxGain(maxTxGain() - atten, chan);
return maxTxGain() - rfGain;
}
virtual double getPowerAttenuation(size_t chan=0) {
return maxTxGain() - getTxGain(chan);
}
virtual double setPowerAttenuation(int atten, size_t chan) = 0;
virtual double getPowerAttenuation(size_t chan=0) = 0;
protected:
size_t tx_sps, rx_sps;
@ -171,15 +162,6 @@ class RadioDevice {
std::vector<std::string> tx_paths, rx_paths;
std::vector<struct device_counters> m_ctr;
/** sets the transmit chan gain, returns the gain setting **/
virtual double setTxGain(double dB, size_t chan = 0) = 0;
/** get transmit gain */
virtual double getTxGain(size_t chan = 0) = 0;
/** return maximum Tx Gain **/
virtual double maxTxGain(void) = 0;
RadioDevice(size_t tx_sps, size_t rx_sps, InterfaceType type, size_t chan_num, double offset,
const std::vector<std::string>& tx_paths,
const std::vector<std::string>& rx_paths):

View File

@ -86,10 +86,6 @@ private:
bool do_clock_src_freq(enum ReferenceType ref, double freq);
void get_dev_band_desc(dev_band_desc& desc);
double setTxGain(double db, size_t chan) {OSMO_ASSERT(false); return 0.0f; }
double getTxGain(size_t chan = 0) { OSMO_ASSERT(false); return 0.0f; };
double maxTxGain(void) { OSMO_ASSERT(false); return 0.0f; };
public:
/** Object constructor */

View File

@ -134,10 +134,6 @@ public:
};
private:
double setTxGain(double db, size_t chan) {OSMO_ASSERT(false); return 0.0f; }
double getTxGain(size_t chan = 0) { OSMO_ASSERT(false); return 0.0f; };
double maxTxGain(void) { OSMO_ASSERT(false); return 0.0f; };
uhd::usrp::multi_usrp::sptr usrp_dev;
uhd::tx_streamer::sptr tx_stream;
uhd::rx_streamer::sptr rx_stream;

View File

@ -205,8 +205,8 @@ bool USRPDevice::start()
writeLock.unlock();
// Set gains to midpoint
setTxGain((minTxGain() + maxTxGain()) / 2);
setRxGain((minRxGain() + maxRxGain()) / 2);
setTxGain((m_dbTx->gain_min() + m_dbTx->gain_max()) / 2);
setRxGain((m_dbTx->gain_min() + m_dbTx->gain_max()) / 2);
data = new short[currDataSize];
dataStart = 0;
@ -243,16 +243,6 @@ bool USRPDevice::stop()
#endif
}
double USRPDevice::maxTxGain()
{
return m_dbTx->gain_max();
}
double USRPDevice::minTxGain()
{
return m_dbTx->gain_min();
}
double USRPDevice::maxRxGain()
{
return m_dbRx->gain_max();
@ -271,10 +261,10 @@ double USRPDevice::setTxGain(double dB, size_t chan)
}
writeLock.lock();
if (dB > maxTxGain())
dB = maxTxGain();
if (dB < minTxGain())
dB = minTxGain();
if (dB > m_dbTx->gain_max())
dB = m_dbTx->gain_max();
if (dB < m_dbTx->gain_min())
dB = m_dbTx->gain_min();
LOGC(DDEV, NOTICE) << "Setting TX gain to " << dB << " dB.";
@ -314,6 +304,15 @@ double USRPDevice::setRxGain(double dB, size_t chan)
return rxGain;
}
double USRPDevice::setPowerAttenuation(int atten, size_t chan) {
double rfGain;
rfGain = setTxGain(m_dbTx->gain_max() - atten, chan);
return m_dbTx->gain_max() - rfGain;
}
double USRPDevice::getPowerAttenuation(size_t chan) {
return m_dbTx->gain_max() - getTxGain(chan);
}
int USRPDevice::getNominalTxPower(size_t chan)
{
/* TODO: return value based on some experimentally generated table depending on

View File

@ -91,12 +91,6 @@ private:
/** get transmit gain */
double getTxGain(size_t chan = 0) { return txGain; }
/** return maximum Tx Gain **/
double maxTxGain(void);
/** return minimum Rx Gain **/
double minTxGain(void);
#ifdef SWLOOPBACK
short loopbackBuffer[1000000];
int loopbackBufferSize;
@ -180,6 +174,9 @@ private:
/** return minimum Rx Gain **/
double minRxGain(void);
double setPowerAttenuation(int atten, size_t chan);
double getPowerAttenuation(size_t chan=0);
int getNominalTxPower(size_t chan = 0);
/** sets the RX path to use, returns true if successful and false otherwise */