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.
SWGSoapySDRReport.cpp
Go to the documentation of this file.
1 
14 #include "SWGSoapySDRReport.h"
15 
16 #include "SWGHelpers.h"
17 
18 #include <QJsonDocument>
19 #include <QJsonArray>
20 #include <QObject>
21 #include <QDebug>
22 
23 namespace SWGSDRangel {
24 
26  init();
27  this->fromJson(*json);
28 }
29 
31  device_settings_args = nullptr;
33  stream_settings_args = nullptr;
43  antennas = nullptr;
44  m_antennas_isSet = false;
45  has_agc = 0;
46  m_has_agc_isSet = false;
47  gain_range = nullptr;
48  m_gain_range_isSet = false;
49  gain_settings = nullptr;
50  m_gain_settings_isSet = false;
51  frequency_settings = nullptr;
53  frequency_settings_args = nullptr;
55  rates_ranges = nullptr;
56  m_rates_ranges_isSet = false;
57  bandwidths_ranges = nullptr;
59 }
60 
62  this->cleanup();
63 }
64 
65 void
67  device_settings_args = new QList<SWGArgInfo*>();
69  stream_settings_args = new QList<SWGArgInfo*>();
79  antennas = new QList<QString*>();
80  m_antennas_isSet = false;
81  has_agc = 0;
82  m_has_agc_isSet = false;
83  gain_range = new SWGRangeFloat();
84  m_gain_range_isSet = false;
85  gain_settings = new QList<SWGSoapySDRGainSetting*>();
86  m_gain_settings_isSet = false;
87  frequency_settings = new QList<SWGSoapySDRFrequencySetting*>();
89  frequency_settings_args = new QList<SWGArgInfo*>();
91  rates_ranges = new QList<SWGRangeFloat*>();
92  m_rates_ranges_isSet = false;
93  bandwidths_ranges = new QList<SWGRangeFloat*>();
95 }
96 
97 void
99  if(device_settings_args != nullptr) {
100  auto arr = device_settings_args;
101  for(auto o: *arr) {
102  delete o;
103  }
104  delete device_settings_args;
105  }
106  if(stream_settings_args != nullptr) {
107  auto arr = stream_settings_args;
108  for(auto o: *arr) {
109  delete o;
110  }
111  delete stream_settings_args;
112  }
113 
114 
115 
116 
117  if(antennas != nullptr) {
118  auto arr = antennas;
119  for(auto o: *arr) {
120  delete o;
121  }
122  delete antennas;
123  }
124 
125  if(gain_range != nullptr) {
126  delete gain_range;
127  }
128  if(gain_settings != nullptr) {
129  auto arr = gain_settings;
130  for(auto o: *arr) {
131  delete o;
132  }
133  delete gain_settings;
134  }
135  if(frequency_settings != nullptr) {
136  auto arr = frequency_settings;
137  for(auto o: *arr) {
138  delete o;
139  }
140  delete frequency_settings;
141  }
142  if(frequency_settings_args != nullptr) {
143  auto arr = frequency_settings_args;
144  for(auto o: *arr) {
145  delete o;
146  }
148  }
149  if(rates_ranges != nullptr) {
150  auto arr = rates_ranges;
151  for(auto o: *arr) {
152  delete o;
153  }
154  delete rates_ranges;
155  }
156  if(bandwidths_ranges != nullptr) {
157  auto arr = bandwidths_ranges;
158  for(auto o: *arr) {
159  delete o;
160  }
161  delete bandwidths_ranges;
162  }
163 }
164 
167  QByteArray array (json.toStdString().c_str());
168  QJsonDocument doc = QJsonDocument::fromJson(array);
169  QJsonObject jsonObject = doc.object();
170  this->fromJsonObject(jsonObject);
171  return this;
172 }
173 
174 void
176 
177  ::SWGSDRangel::setValue(&device_settings_args, pJson["deviceSettingsArgs"], "QList", "SWGArgInfo");
178 
179  ::SWGSDRangel::setValue(&stream_settings_args, pJson["streamSettingsArgs"], "QList", "SWGArgInfo");
180  ::SWGSDRangel::setValue(&has_dc_auto_correction, pJson["hasDCAutoCorrection"], "qint32", "");
181 
182  ::SWGSDRangel::setValue(&has_dc_offset_value, pJson["hasDCOffsetValue"], "qint32", "");
183 
184  ::SWGSDRangel::setValue(&has_iq_balance_value, pJson["hasIQBalanceValue"], "qint32", "");
185 
186  ::SWGSDRangel::setValue(&has_frequency_correction_value, pJson["hasFrequencyCorrectionValue"], "qint32", "");
187 
188 
189  ::SWGSDRangel::setValue(&antennas, pJson["antennas"], "QList", "QString");
190  ::SWGSDRangel::setValue(&has_agc, pJson["hasAGC"], "qint32", "");
191 
192  ::SWGSDRangel::setValue(&gain_range, pJson["gainRange"], "SWGRangeFloat", "SWGRangeFloat");
193 
194 
195  ::SWGSDRangel::setValue(&gain_settings, pJson["gainSettings"], "QList", "SWGSoapySDRGainSetting");
196 
197  ::SWGSDRangel::setValue(&frequency_settings, pJson["frequencySettings"], "QList", "SWGSoapySDRFrequencySetting");
198 
199  ::SWGSDRangel::setValue(&frequency_settings_args, pJson["frequencySettingsArgs"], "QList", "SWGArgInfo");
200 
201  ::SWGSDRangel::setValue(&rates_ranges, pJson["ratesRanges"], "QList", "SWGRangeFloat");
202 
203  ::SWGSDRangel::setValue(&bandwidths_ranges, pJson["bandwidthsRanges"], "QList", "SWGRangeFloat");
204 }
205 
206 QString
208 {
209  QJsonObject* obj = this->asJsonObject();
210 
211  QJsonDocument doc(*obj);
212  QByteArray bytes = doc.toJson();
213  delete obj;
214  return QString(bytes);
215 }
216 
217 QJsonObject*
219  QJsonObject* obj = new QJsonObject();
220  if(device_settings_args->size() > 0){
221  toJsonArray((QList<void*>*)device_settings_args, obj, "deviceSettingsArgs", "SWGArgInfo");
222  }
223  if(stream_settings_args->size() > 0){
224  toJsonArray((QList<void*>*)stream_settings_args, obj, "streamSettingsArgs", "SWGArgInfo");
225  }
227  obj->insert("hasDCAutoCorrection", QJsonValue(has_dc_auto_correction));
228  }
230  obj->insert("hasDCOffsetValue", QJsonValue(has_dc_offset_value));
231  }
233  obj->insert("hasIQBalanceValue", QJsonValue(has_iq_balance_value));
234  }
236  obj->insert("hasFrequencyCorrectionValue", QJsonValue(has_frequency_correction_value));
237  }
238  if(antennas->size() > 0){
239  toJsonArray((QList<void*>*)antennas, obj, "antennas", "QString");
240  }
241  if(m_has_agc_isSet){
242  obj->insert("hasAGC", QJsonValue(has_agc));
243  }
244  if((gain_range != nullptr) && (gain_range->isSet())){
245  toJsonValue(QString("gainRange"), gain_range, obj, QString("SWGRangeFloat"));
246  }
247  if(gain_settings->size() > 0){
248  toJsonArray((QList<void*>*)gain_settings, obj, "gainSettings", "SWGSoapySDRGainSetting");
249  }
250  if(frequency_settings->size() > 0){
251  toJsonArray((QList<void*>*)frequency_settings, obj, "frequencySettings", "SWGSoapySDRFrequencySetting");
252  }
253  if(frequency_settings_args->size() > 0){
254  toJsonArray((QList<void*>*)frequency_settings_args, obj, "frequencySettingsArgs", "SWGArgInfo");
255  }
256  if(rates_ranges->size() > 0){
257  toJsonArray((QList<void*>*)rates_ranges, obj, "ratesRanges", "SWGRangeFloat");
258  }
259  if(bandwidths_ranges->size() > 0){
260  toJsonArray((QList<void*>*)bandwidths_ranges, obj, "bandwidthsRanges", "SWGRangeFloat");
261  }
262 
263  return obj;
264 }
265 
266 QList<SWGArgInfo*>*
268  return device_settings_args;
269 }
270 void
272  this->device_settings_args = device_settings_args;
273  this->m_device_settings_args_isSet = true;
274 }
275 
276 QList<SWGArgInfo*>*
278  return stream_settings_args;
279 }
280 void
282  this->stream_settings_args = stream_settings_args;
283  this->m_stream_settings_args_isSet = true;
284 }
285 
286 qint32
288  return has_dc_auto_correction;
289 }
290 void
292  this->has_dc_auto_correction = has_dc_auto_correction;
293  this->m_has_dc_auto_correction_isSet = true;
294 }
295 
296 qint32
298  return has_dc_offset_value;
299 }
300 void
302  this->has_dc_offset_value = has_dc_offset_value;
303  this->m_has_dc_offset_value_isSet = true;
304 }
305 
306 qint32
308  return has_iq_balance_value;
309 }
310 void
312  this->has_iq_balance_value = has_iq_balance_value;
313  this->m_has_iq_balance_value_isSet = true;
314 }
315 
316 qint32
319 }
320 void
322  this->has_frequency_correction_value = has_frequency_correction_value;
324 }
325 
326 QList<QString*>*
328  return antennas;
329 }
330 void
332  this->antennas = antennas;
333  this->m_antennas_isSet = true;
334 }
335 
336 qint32
338  return has_agc;
339 }
340 void
342  this->has_agc = has_agc;
343  this->m_has_agc_isSet = true;
344 }
345 
348  return gain_range;
349 }
350 void
352  this->gain_range = gain_range;
353  this->m_gain_range_isSet = true;
354 }
355 
356 QList<SWGSoapySDRGainSetting*>*
358  return gain_settings;
359 }
360 void
361 SWGSoapySDRReport::setGainSettings(QList<SWGSoapySDRGainSetting*>* gain_settings) {
362  this->gain_settings = gain_settings;
363  this->m_gain_settings_isSet = true;
364 }
365 
366 QList<SWGSoapySDRFrequencySetting*>*
368  return frequency_settings;
369 }
370 void
371 SWGSoapySDRReport::setFrequencySettings(QList<SWGSoapySDRFrequencySetting*>* frequency_settings) {
372  this->frequency_settings = frequency_settings;
373  this->m_frequency_settings_isSet = true;
374 }
375 
376 QList<SWGArgInfo*>*
379 }
380 void
382  this->frequency_settings_args = frequency_settings_args;
383  this->m_frequency_settings_args_isSet = true;
384 }
385 
386 QList<SWGRangeFloat*>*
388  return rates_ranges;
389 }
390 void
392  this->rates_ranges = rates_ranges;
393  this->m_rates_ranges_isSet = true;
394 }
395 
396 QList<SWGRangeFloat*>*
398  return bandwidths_ranges;
399 }
400 void
402  this->bandwidths_ranges = bandwidths_ranges;
403  this->m_bandwidths_ranges_isSet = true;
404 }
405 
406 
407 bool
409  bool isObjectUpdated = false;
410  do{
411  if(device_settings_args->size() > 0){ isObjectUpdated = true; break;}
412  if(stream_settings_args->size() > 0){ isObjectUpdated = true; break;}
413  if(m_has_dc_auto_correction_isSet){ isObjectUpdated = true; break;}
414  if(m_has_dc_offset_value_isSet){ isObjectUpdated = true; break;}
415  if(m_has_iq_balance_value_isSet){ isObjectUpdated = true; break;}
416  if(m_has_frequency_correction_value_isSet){ isObjectUpdated = true; break;}
417  if(antennas->size() > 0){ isObjectUpdated = true; break;}
418  if(m_has_agc_isSet){ isObjectUpdated = true; break;}
419  if(gain_range != nullptr && gain_range->isSet()){ isObjectUpdated = true; break;}
420  if(gain_settings->size() > 0){ isObjectUpdated = true; break;}
421  if(frequency_settings->size() > 0){ isObjectUpdated = true; break;}
422  if(frequency_settings_args->size() > 0){ isObjectUpdated = true; break;}
423  if(rates_ranges->size() > 0){ isObjectUpdated = true; break;}
424  if(bandwidths_ranges->size() > 0){ isObjectUpdated = true; break;}
425  }while(false);
426  return isObjectUpdated;
427 }
428 }
429 
QList< SWGArgInfo * > * device_settings_args
QList< SWGRangeFloat * > * rates_ranges
void setHasFrequencyCorrectionValue(qint32 has_frequency_correction_value)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
QList< SWGArgInfo * > * stream_settings_args
virtual void fromJsonObject(QJsonObject &json) override
void setFrequencySettingsArgs(QList< SWGArgInfo *> *frequency_settings_args)
QList< SWGSoapySDRGainSetting * > * getGainSettings()
void setDeviceSettingsArgs(QList< SWGArgInfo *> *device_settings_args)
virtual QJsonObject * asJsonObject() override
QList< SWGArgInfo * > * getStreamSettingsArgs()
void setStreamSettingsArgs(QList< SWGArgInfo *> *stream_settings_args)
void setGainRange(SWGRangeFloat *gain_range)
void setHasDcAutoCorrection(qint32 has_dc_auto_correction)
QList< SWGArgInfo * > * getDeviceSettingsArgs()
virtual SWGSoapySDRReport * fromJson(QString &jsonString) override
void setRatesRanges(QList< SWGRangeFloat *> *rates_ranges)
void setGainSettings(QList< SWGSoapySDRGainSetting *> *gain_settings)
QList< SWGArgInfo * > * frequency_settings_args
void setBandwidthsRanges(QList< SWGRangeFloat *> *bandwidths_ranges)
QList< SWGArgInfo * > * getFrequencySettingsArgs()
QList< SWGRangeFloat * > * getBandwidthsRanges()
QList< SWGSoapySDRFrequencySetting * > * getFrequencySettings()
QList< SWGSoapySDRGainSetting * > * gain_settings
void setFrequencySettings(QList< SWGSoapySDRFrequencySetting *> *frequency_settings)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void toJsonArray(QList< void *> *value, QJsonObject *output, QString innerName, QString innerType)
Definition: SWGHelpers.cpp:445
void setHasIqBalanceValue(qint32 has_iq_balance_value)
QList< SWGSoapySDRFrequencySetting * > * frequency_settings
QList< SWGRangeFloat * > * bandwidths_ranges
QList< QString * > * getAntennas()
QList< SWGRangeFloat * > * getRatesRanges()
virtual QString asJson() override
void setAntennas(QList< QString *> *antennas)
void setHasDcOffsetValue(qint32 has_dc_offset_value)
virtual bool isSet() override