SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
DeviceSoapySDRParams Class Reference

#include <devicesoapysdrparams.h>

Classes

struct  ChannelSettings
 
struct  FrequencySetting
 
struct  GainSetting
 

Public Member Functions

 DeviceSoapySDRParams (SoapySDR::Device *device)
 
 ~DeviceSoapySDRParams ()
 
const SoapySDR::ArgInfoList & getDeviceArgs () const
 
const ChannelSettingsgetRxChannelSettings (uint32_t index)
 
const ChannelSettingsgetTxChannelSettings (uint32_t index)
 
std::string getRxChannelMainTunableElementName (uint32_t index)
 
std::string getTxChannelMainTunableElementName (uint32_t index)
 

Private Member Functions

void fillParams ()
 
void fillChannelParams (std::vector< ChannelSettings > &channelSettings, int direction, unsigned int ichan)
 
void printParams ()
 
void printChannelParams (const ChannelSettings &channelSetting)
 
std::string argInfoToString (const SoapySDR::ArgInfo &argInfo, const std::string indent=" ")
 
std::string argInfoListToString (const SoapySDR::ArgInfoList &argInfos)
 
std::string rangeToString (const SoapySDR::Range &range)
 
std::string rangeListToString (const SoapySDR::RangeList &range, const double scale)
 
template<typename Type >
std::string vectorToString (const std::vector< Type > &options)
 

Private Attributes

SoapySDR::Device * m_device
 
SoapySDR::ArgInfoList m_deviceSettingsArgs
 list (vector) of device settings arguments More...
 
uint32_t m_nbRx
 number of Rx channels More...
 
uint32_t m_nbTx
 number of Tx channels More...
 
std::vector< ChannelSettingsm_RxChannelsSettings
 
std::vector< ChannelSettingsm_TxChannelsSettings
 

Detailed Description

This structure refers to one physical device shared among parties (logical devices represented by the DeviceAPI with single Rx or Tx stream type). It allows storing information on the common resources in one place and is shared among participants. There is only one copy that is constructed by the first participant and destroyed by the last. A participant knows it is the first or last by checking the lists of buddies (Rx + Tx).

Definition at line 37 of file devicesoapysdrparams.h.

Constructor & Destructor Documentation

◆ DeviceSoapySDRParams()

DeviceSoapySDRParams::DeviceSoapySDRParams ( SoapySDR::Device *  device)

Definition at line 25 of file devicesoapysdrparams.cpp.

References fillParams(), and printParams().

25  :
26  m_device(device)
27 {
28  fillParams();
29  printParams();
30 }
SoapySDR::Device * m_device
+ Here is the call graph for this function:

◆ ~DeviceSoapySDRParams()

DeviceSoapySDRParams::~DeviceSoapySDRParams ( )

Definition at line 32 of file devicesoapysdrparams.cpp.

33 {}

Member Function Documentation

◆ argInfoListToString()

std::string DeviceSoapySDRParams::argInfoListToString ( const SoapySDR::ArgInfoList &  argInfos)
private

Definition at line 248 of file devicesoapysdrparams.cpp.

References argInfoToString(), and i.

Referenced by printChannelParams(), and printParams().

249 {
250  std::stringstream ss;
251 
252  for (std::size_t i = 0; i < argInfos.size(); i++) {
253  ss << argInfoToString(argInfos[i]) << std::endl;
254  }
255 
256  return ss.str();
257 }
std::string argInfoToString(const SoapySDR::ArgInfo &argInfo, const std::string indent=" ")
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ argInfoToString()

std::string DeviceSoapySDRParams::argInfoToString ( const SoapySDR::ArgInfo &  argInfo,
const std::string  indent = "    " 
)
private

Definition at line 185 of file devicesoapysdrparams.cpp.

References rangeToString(), and vectorToString().

Referenced by argInfoListToString().

186 {
187  std::stringstream ss;
188 
189  //name, or use key if missing
190  std::string name = argInfo.name;
191  if (argInfo.name.empty()) name = argInfo.key;
192  ss << indent << " * " << name;
193 
194  //optional description
195  std::string desc = argInfo.description;
196  const std::string replace("\n"+indent+" ");
197 
198  for (std::size_t pos = 0; (pos=desc.find("\n", pos)) != std::string::npos; pos+=replace.size()) {
199  desc.replace(pos, 1, replace);
200  }
201 
202  if (not desc.empty()) {
203  ss << " - " << desc << std::endl << indent << " ";
204  }
205 
206  //other fields
207  ss << " [key=" << argInfo.key;
208 
209  if (not argInfo.units.empty()) {
210  ss << ", units=" << argInfo.units;
211  }
212 
213  if (not argInfo.value.empty()) {
214  ss << ", default=" << argInfo.value;
215  }
216 
217  //type
218  switch (argInfo.type)
219  {
221  ss << ", type=bool";
222  break;
223  case SoapySDR::ArgInfo::INT:
224  ss << ", type=int";
225  break;
226  case SoapySDR::ArgInfo::FLOAT:
227  ss << ", type=float";
228  break;
229  case SoapySDR::ArgInfo::STRING:
230  ss << ", type=string";
231  break;
232  }
233 
234  //optional range/enumeration
235  if (argInfo.range.minimum() < argInfo.range.maximum()) {
236  ss << ", range=" << rangeToString(argInfo.range);
237  }
238 
239  if (not argInfo.options.empty()) {
240  ss << ", options=(" << vectorToString(argInfo.options) << ")";
241  }
242 
243  ss << "]";
244 
245  return ss.str();
246 }
int BOOL
Definition: fcdhid.h:37
std::string rangeToString(const SoapySDR::Range &range)
std::string vectorToString(const std::vector< Type > &options)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fillChannelParams()

void DeviceSoapySDRParams::fillChannelParams ( std::vector< ChannelSettings > &  channelSettings,
int  direction,
unsigned int  ichan 
)
private

Definition at line 86 of file devicesoapysdrparams.cpp.

References m_device.

Referenced by fillParams().

87 {
88  channelSettings.push_back(ChannelSettings());
89 
90  channelSettings.back().m_streamSettingsArgs = m_device->getStreamArgsInfo(direction, ichan);
91  channelSettings.back().m_antennas = m_device->listAntennas(direction, ichan);
92  channelSettings.back().m_hasDCAutoCorrection = m_device->hasDCOffsetMode(direction, ichan);
93  channelSettings.back().m_hasDCOffsetValue = m_device->hasDCOffset(direction, ichan);
94  channelSettings.back().m_hasIQBalanceValue = m_device->hasIQBalance(direction, ichan);
95  channelSettings.back().m_hasFrequencyCorrectionValue = m_device->hasFrequencyCorrection(direction, ichan);
96 
97  // gains
98 
99  channelSettings.back().m_hasAGC = m_device->hasGainMode(direction, ichan);
100  channelSettings.back().m_gainRange = m_device->getGainRange(direction, ichan);
101  std::vector<std::string> gainsList = m_device->listGains(direction, ichan);
102 
103  for (const auto &it : gainsList)
104  {
105  channelSettings.back().m_gainSettings.push_back(GainSetting());
106  channelSettings.back().m_gainSettings.back().m_name = it;
107  channelSettings.back().m_gainSettings.back().m_range = m_device->getGainRange(direction, ichan, it);
108  }
109 
110  // frequencies
111 
112  std::vector<std::string> freqsList = m_device->listFrequencies(direction, ichan);
113 
114  for (const auto &it : freqsList)
115  {
116  channelSettings.back().m_frequencySettings.push_back(FrequencySetting());
117  channelSettings.back().m_frequencySettings.back().m_name = it;
118  channelSettings.back().m_frequencySettings.back().m_ranges = m_device->getFrequencyRange(direction, ichan, it);
119  }
120 
121  channelSettings.back().m_frequencySettingsArgs = m_device->getFrequencyArgsInfo(direction, ichan);
122 
123  // sample rates
124  channelSettings.back().m_ratesRanges = m_device->getSampleRateRange(direction, ichan);
125 
126  // bandwidths
127  channelSettings.back().m_bandwidthsRanges = m_device->getBandwidthRange(direction, ichan);
128 }
SoapySDR::Device * m_device
+ Here is the caller graph for this function:

◆ fillParams()

void DeviceSoapySDRParams::fillParams ( )
private

Definition at line 71 of file devicesoapysdrparams.cpp.

References fillChannelParams(), m_device, m_deviceSettingsArgs, m_nbRx, m_nbTx, m_RxChannelsSettings, and m_TxChannelsSettings.

Referenced by DeviceSoapySDRParams().

72 {
73  m_deviceSettingsArgs = m_device->getSettingInfo();
74  m_nbRx = m_device->getNumChannels(SOAPY_SDR_RX);
75  m_nbTx = m_device->getNumChannels(SOAPY_SDR_TX);
76 
77  for (unsigned int ichan = 0; ichan < m_nbRx; ichan++) {
78  fillChannelParams(m_RxChannelsSettings, SOAPY_SDR_RX, ichan);
79  }
80 
81  for (unsigned int ichan = 0; ichan < m_nbTx; ichan++) {
82  fillChannelParams(m_TxChannelsSettings, SOAPY_SDR_TX, ichan);
83  }
84 }
SoapySDR::Device * m_device
std::vector< ChannelSettings > m_RxChannelsSettings
uint32_t m_nbRx
number of Rx channels
SoapySDR::ArgInfoList m_deviceSettingsArgs
list (vector) of device settings arguments
uint32_t m_nbTx
number of Tx channels
std::vector< ChannelSettings > m_TxChannelsSettings
void fillChannelParams(std::vector< ChannelSettings > &channelSettings, int direction, unsigned int ichan)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDeviceArgs()

const SoapySDR::ArgInfoList& DeviceSoapySDRParams::getDeviceArgs ( ) const
inline

◆ getRxChannelMainTunableElementName()

std::string DeviceSoapySDRParams::getRxChannelMainTunableElementName ( uint32_t  index)

Definition at line 35 of file devicesoapysdrparams.cpp.

References DeviceSoapySDRParams::ChannelSettings::m_frequencySettings, m_nbRx, and m_RxChannelsSettings.

Referenced by SoapySDRInput::handleMessage(), and SoapySDRInput::setDeviceCenterFrequency().

36 {
37  if (index < m_nbRx)
38  {
39  return std::string("RF");
40  }
41  else
42  {
43  const ChannelSettings& channelSettings = m_RxChannelsSettings[index];
44 
45  if (channelSettings.m_frequencySettings.size() > 0) {
46  return channelSettings.m_frequencySettings.front().m_name;
47  } else {
48  return std::string("RF");
49  }
50  }
51 }
std::vector< ChannelSettings > m_RxChannelsSettings
uint32_t m_nbRx
number of Rx channels
+ Here is the caller graph for this function:

◆ getRxChannelSettings()

const ChannelSettings* DeviceSoapySDRParams::getRxChannelSettings ( uint32_t  index)
inline

◆ getTxChannelMainTunableElementName()

std::string DeviceSoapySDRParams::getTxChannelMainTunableElementName ( uint32_t  index)

Definition at line 53 of file devicesoapysdrparams.cpp.

References DeviceSoapySDRParams::ChannelSettings::m_frequencySettings, m_nbRx, and m_RxChannelsSettings.

Referenced by SoapySDROutput::handleMessage(), and SoapySDROutput::setDeviceCenterFrequency().

54 {
55  if (index < m_nbRx)
56  {
57  return std::string("RF");
58  }
59  else
60  {
61  const ChannelSettings& channelSettings = m_RxChannelsSettings[index];
62 
63  if (channelSettings.m_frequencySettings.size() > 0) {
64  return channelSettings.m_frequencySettings.front().m_name;
65  } else {
66  return std::string("RF");
67  }
68  }
69 }
std::vector< ChannelSettings > m_RxChannelsSettings
uint32_t m_nbRx
number of Rx channels
+ Here is the caller graph for this function:

◆ getTxChannelSettings()

const ChannelSettings* DeviceSoapySDRParams::getTxChannelSettings ( uint32_t  index)
inline

◆ printChannelParams()

void DeviceSoapySDRParams::printChannelParams ( const ChannelSettings channelSetting)
private

Definition at line 152 of file devicesoapysdrparams.cpp.

References argInfoListToString(), DeviceSoapySDRParams::ChannelSettings::m_antennas, DeviceSoapySDRParams::ChannelSettings::m_bandwidthsRanges, DeviceSoapySDRParams::ChannelSettings::m_frequencySettings, DeviceSoapySDRParams::ChannelSettings::m_frequencySettingsArgs, DeviceSoapySDRParams::ChannelSettings::m_gainRange, DeviceSoapySDRParams::ChannelSettings::m_gainSettings, DeviceSoapySDRParams::ChannelSettings::m_hasAGC, DeviceSoapySDRParams::ChannelSettings::m_hasDCAutoCorrection, DeviceSoapySDRParams::ChannelSettings::m_hasDCOffsetValue, DeviceSoapySDRParams::ChannelSettings::m_hasFrequencyCorrectionValue, DeviceSoapySDRParams::ChannelSettings::m_hasIQBalanceValue, DeviceSoapySDRParams::ChannelSettings::m_ratesRanges, DeviceSoapySDRParams::ChannelSettings::m_streamSettingsArgs, rangeListToString(), rangeToString(), and vectorToString().

Referenced by printParams().

153 {
154  qDebug() << "DeviceSoapySDRParams::printParams: m_streamSettingsArgs:\n" << argInfoListToString(channelSetting.m_streamSettingsArgs).c_str();
155  qDebug() << "DeviceSoapySDRParams::printParams:"
156  << " m_hasDCAutoCorrection: " << channelSetting.m_hasDCAutoCorrection
157  << " m_hasDCOffsetValue: " << channelSetting.m_hasDCOffsetValue
158  << " m_hasIQBalanceValue: " << channelSetting.m_hasIQBalanceValue
159  << " m_hasFrequencyCorrectionValue: " << channelSetting.m_hasFrequencyCorrectionValue
160  << " m_hasAGC: " << channelSetting.m_hasAGC;
161  qDebug() << "DeviceSoapySDRParams::printParams: m_antennas: " << vectorToString(channelSetting.m_antennas).c_str();
162  qDebug() << "DeviceSoapySDRParams::printParams: m_gainRange: " << rangeToString(channelSetting.m_gainRange).c_str();
163 
164  qDebug() << "DeviceSoapySDRParams::printParams: individual gains...";
165 
166  for (const auto &gainIt : channelSetting.m_gainSettings)
167  {
168  qDebug() << "DeviceSoapySDRParams::printParams: m_name: " << gainIt.m_name.c_str();
169  qDebug() << "DeviceSoapySDRParams::printParams: m_range: " << rangeToString(gainIt.m_range).c_str();
170  }
171 
172  qDebug() << "DeviceSoapySDRParams::printParams: tunable elements...";
173 
174  for (const auto &freqIt : channelSetting.m_frequencySettings)
175  {
176  qDebug() << "DeviceSoapySDRParams::printParams: m_name: " << freqIt.m_name.c_str();
177  qDebug() << "DeviceSoapySDRParams::printParams: m_range (kHz): " << rangeListToString(freqIt.m_ranges, 1e3).c_str();
178  }
179 
180  qDebug() << "DeviceSoapySDRParams::printParams: m_frequencySettingsArgs:\n" << argInfoListToString(channelSetting.m_frequencySettingsArgs).c_str();
181  qDebug() << "DeviceSoapySDRParams::printParams: m_ratesRanges (kHz): " << rangeListToString(channelSetting.m_ratesRanges, 1e3).c_str();
182  qDebug() << "DeviceSoapySDRParams::printParams: m_bandwidthsRanges (kHz): " << rangeListToString(channelSetting.m_bandwidthsRanges, 1e3).c_str();
183 }
std::string rangeListToString(const SoapySDR::RangeList &range, const double scale)
std::string argInfoListToString(const SoapySDR::ArgInfoList &argInfos)
std::string rangeToString(const SoapySDR::Range &range)
std::string vectorToString(const std::vector< Type > &options)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ printParams()

void DeviceSoapySDRParams::printParams ( )
private

Definition at line 130 of file devicesoapysdrparams.cpp.

References argInfoListToString(), m_deviceSettingsArgs, m_RxChannelsSettings, m_TxChannelsSettings, and printChannelParams().

Referenced by DeviceSoapySDRParams().

131 {
132  qDebug() << "DeviceSoapySDRParams::printParams: m_deviceSettingsArgs:\n" << argInfoListToString(m_deviceSettingsArgs).c_str();
133  int ichan = 0;
134 
135  for (const auto &it : m_RxChannelsSettings)
136  {
137  qDebug() << "DeviceSoapySDRParams::printParams: Rx channel " << ichan;
138  printChannelParams(it);
139  ichan++;
140  }
141 
142  ichan = 0;
143 
144  for (const auto &it : m_TxChannelsSettings)
145  {
146  qDebug() << "DeviceSoapySDRParams::printParams: Tx channel " << ichan;
147  printChannelParams(it);
148  ichan++;
149  }
150 }
std::vector< ChannelSettings > m_RxChannelsSettings
SoapySDR::ArgInfoList m_deviceSettingsArgs
list (vector) of device settings arguments
std::vector< ChannelSettings > m_TxChannelsSettings
void printChannelParams(const ChannelSettings &channelSetting)
std::string argInfoListToString(const SoapySDR::ArgInfoList &argInfos)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rangeListToString()

std::string DeviceSoapySDRParams::rangeListToString ( const SoapySDR::RangeList &  range,
const double  scale 
)
private

Definition at line 272 of file devicesoapysdrparams.cpp.

References i.

Referenced by printChannelParams().

273 {
274  std::stringstream ss;
275 
276  for (std::size_t i = 0; i < range.size(); i++)
277  {
278  if (not ss.str().empty()) {
279  ss << ", ";
280  }
281 
282  if (range[i].minimum() == range[i].maximum())
283  {
284  ss << (range[i].minimum()/scale);
285  }
286  else
287  {
288  ss << "[" << (range[i].minimum()/scale) << ", " << (range[i].maximum()/scale);
289 
290  if (range[i].step() != 0.0) {
291  ss << ", " << (range[i].step()/scale);
292  }
293 
294  ss << "]";
295  }
296  }
297 
298  return ss.str();
299 }
int32_t i
Definition: decimators.h:244
+ Here is the caller graph for this function:

◆ rangeToString()

std::string DeviceSoapySDRParams::rangeToString ( const SoapySDR::Range &  range)
private

Definition at line 259 of file devicesoapysdrparams.cpp.

Referenced by argInfoToString(), and printChannelParams().

260 {
261  std::stringstream ss;
262  ss << "[" << range.minimum() << ", " << range.maximum();
263 
264  if (range.step() != 0.0) {
265  ss << ", " << range.step();
266  }
267 
268  ss << "]";
269  return ss.str();
270 }
+ Here is the caller graph for this function:

◆ vectorToString()

template<typename Type >
std::string DeviceSoapySDRParams::vectorToString ( const std::vector< Type > &  options)
inlineprivate

Definition at line 108 of file devicesoapysdrparams.h.

References i.

Referenced by argInfoToString(), and printChannelParams().

109  {
110  std::stringstream ss;
111 
112  if (options.empty()) {
113  return "";
114  }
115 
116  for (std::size_t i = 0; i < options.size(); i++)
117  {
118  if (not ss.str().empty()) {
119  ss << ", ";
120  }
121 
122  ss << options[i];
123  }
124 
125  return ss.str();
126  }
int32_t i
Definition: decimators.h:244
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_device

SoapySDR::Device* DeviceSoapySDRParams::m_device
private

Definition at line 128 of file devicesoapysdrparams.h.

Referenced by fillChannelParams(), and fillParams().

◆ m_deviceSettingsArgs

SoapySDR::ArgInfoList DeviceSoapySDRParams::m_deviceSettingsArgs
private

list (vector) of device settings arguments

Definition at line 129 of file devicesoapysdrparams.h.

Referenced by fillParams(), and printParams().

◆ m_nbRx

uint32_t DeviceSoapySDRParams::m_nbRx
private

number of Rx channels

Definition at line 130 of file devicesoapysdrparams.h.

Referenced by fillParams(), getRxChannelMainTunableElementName(), and getTxChannelMainTunableElementName().

◆ m_nbTx

uint32_t DeviceSoapySDRParams::m_nbTx
private

number of Tx channels

Definition at line 131 of file devicesoapysdrparams.h.

Referenced by fillParams().

◆ m_RxChannelsSettings

std::vector<ChannelSettings> DeviceSoapySDRParams::m_RxChannelsSettings
private

◆ m_TxChannelsSettings

std::vector<ChannelSettings> DeviceSoapySDRParams::m_TxChannelsSettings
private

Definition at line 133 of file devicesoapysdrparams.h.

Referenced by fillParams(), and printParams().


The documentation for this class was generated from the following files: