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.
SWGSoapySDROutputSettings.cpp
Go to the documentation of this file.
1 
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  center_frequency = 0L;
33  l_oppm_tenths = 0;
34  m_l_oppm_tenths_isSet = false;
35  dev_sample_rate = 0;
37  log2_interp = 0;
38  m_log2_interp_isSet = false;
39  transverter_mode = 0;
43  antenna = nullptr;
44  m_antenna_isSet = false;
45  bandwidth = 0;
46  m_bandwidth_isSet = false;
47  tunable_elements = nullptr;
49  global_gain = 0;
50  m_global_gain_isSet = false;
51  individual_gains = nullptr;
53  auto_gain = 0;
54  m_auto_gain_isSet = false;
59  dc_correction = nullptr;
60  m_dc_correction_isSet = false;
61  iq_correction = nullptr;
62  m_iq_correction_isSet = false;
63  stream_arg_settings = nullptr;
65  device_arg_settings = nullptr;
67  use_reverse_api = 0;
69  reverse_api_address = nullptr;
71  reverse_api_port = 0;
75 }
76 
78  this->cleanup();
79 }
80 
81 void
83  center_frequency = 0L;
85  l_oppm_tenths = 0;
86  m_l_oppm_tenths_isSet = false;
87  dev_sample_rate = 0;
89  log2_interp = 0;
90  m_log2_interp_isSet = false;
91  transverter_mode = 0;
95  antenna = new QString("");
96  m_antenna_isSet = false;
97  bandwidth = 0;
98  m_bandwidth_isSet = false;
99  tunable_elements = new QList<SWGArgValue*>();
100  m_tunable_elements_isSet = false;
101  global_gain = 0;
102  m_global_gain_isSet = false;
103  individual_gains = new QList<SWGArgValue*>();
104  m_individual_gains_isSet = false;
105  auto_gain = 0;
106  m_auto_gain_isSet = false;
107  auto_dc_correction = 0;
109  auto_iq_correction = 0;
111  dc_correction = new SWGComplex();
112  m_dc_correction_isSet = false;
113  iq_correction = new SWGComplex();
114  m_iq_correction_isSet = false;
115  stream_arg_settings = new QList<SWGArgValue*>();
117  device_arg_settings = new QList<SWGArgValue*>();
119  use_reverse_api = 0;
120  m_use_reverse_api_isSet = false;
121  reverse_api_address = new QString("");
123  reverse_api_port = 0;
124  m_reverse_api_port_isSet = false;
127 }
128 
129 void
131 
132 
133 
134 
135 
136 
137  if(antenna != nullptr) {
138  delete antenna;
139  }
140 
141  if(tunable_elements != nullptr) {
142  auto arr = tunable_elements;
143  for(auto o: *arr) {
144  delete o;
145  }
146  delete tunable_elements;
147  }
148 
149  if(individual_gains != nullptr) {
150  auto arr = individual_gains;
151  for(auto o: *arr) {
152  delete o;
153  }
154  delete individual_gains;
155  }
156 
157 
158 
159  if(dc_correction != nullptr) {
160  delete dc_correction;
161  }
162  if(iq_correction != nullptr) {
163  delete iq_correction;
164  }
165  if(stream_arg_settings != nullptr) {
166  auto arr = stream_arg_settings;
167  for(auto o: *arr) {
168  delete o;
169  }
170  delete stream_arg_settings;
171  }
172  if(device_arg_settings != nullptr) {
173  auto arr = device_arg_settings;
174  for(auto o: *arr) {
175  delete o;
176  }
177  delete device_arg_settings;
178  }
179 
180  if(reverse_api_address != nullptr) {
181  delete reverse_api_address;
182  }
183 
184 
185 }
186 
189  QByteArray array (json.toStdString().c_str());
190  QJsonDocument doc = QJsonDocument::fromJson(array);
191  QJsonObject jsonObject = doc.object();
192  this->fromJsonObject(jsonObject);
193  return this;
194 }
195 
196 void
198  ::SWGSDRangel::setValue(&center_frequency, pJson["centerFrequency"], "qint64", "");
199 
200  ::SWGSDRangel::setValue(&l_oppm_tenths, pJson["LOppmTenths"], "qint32", "");
201 
202  ::SWGSDRangel::setValue(&dev_sample_rate, pJson["devSampleRate"], "qint32", "");
203 
204  ::SWGSDRangel::setValue(&log2_interp, pJson["log2Interp"], "qint32", "");
205 
206  ::SWGSDRangel::setValue(&transverter_mode, pJson["transverterMode"], "qint32", "");
207 
208  ::SWGSDRangel::setValue(&transverter_delta_frequency, pJson["transverterDeltaFrequency"], "qint64", "");
209 
210  ::SWGSDRangel::setValue(&antenna, pJson["antenna"], "QString", "QString");
211 
212  ::SWGSDRangel::setValue(&bandwidth, pJson["bandwidth"], "qint32", "");
213 
214 
215  ::SWGSDRangel::setValue(&tunable_elements, pJson["tunableElements"], "QList", "SWGArgValue");
216  ::SWGSDRangel::setValue(&global_gain, pJson["globalGain"], "qint32", "");
217 
218 
219  ::SWGSDRangel::setValue(&individual_gains, pJson["individualGains"], "QList", "SWGArgValue");
220  ::SWGSDRangel::setValue(&auto_gain, pJson["autoGain"], "qint32", "");
221 
222  ::SWGSDRangel::setValue(&auto_dc_correction, pJson["autoDCCorrection"], "qint32", "");
223 
224  ::SWGSDRangel::setValue(&auto_iq_correction, pJson["autoIQCorrection"], "qint32", "");
225 
226  ::SWGSDRangel::setValue(&dc_correction, pJson["dcCorrection"], "SWGComplex", "SWGComplex");
227 
228  ::SWGSDRangel::setValue(&iq_correction, pJson["iqCorrection"], "SWGComplex", "SWGComplex");
229 
230 
231  ::SWGSDRangel::setValue(&stream_arg_settings, pJson["streamArgSettings"], "QList", "SWGArgValue");
232 
233  ::SWGSDRangel::setValue(&device_arg_settings, pJson["deviceArgSettings"], "QList", "SWGArgValue");
234  ::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", "");
235 
236  ::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString");
237 
238  ::SWGSDRangel::setValue(&reverse_api_port, pJson["reverseAPIPort"], "qint32", "");
239 
240  ::SWGSDRangel::setValue(&reverse_api_device_index, pJson["reverseAPIDeviceIndex"], "qint32", "");
241 
242 }
243 
244 QString
246 {
247  QJsonObject* obj = this->asJsonObject();
248 
249  QJsonDocument doc(*obj);
250  QByteArray bytes = doc.toJson();
251  delete obj;
252  return QString(bytes);
253 }
254 
255 QJsonObject*
257  QJsonObject* obj = new QJsonObject();
259  obj->insert("centerFrequency", QJsonValue(center_frequency));
260  }
262  obj->insert("LOppmTenths", QJsonValue(l_oppm_tenths));
263  }
265  obj->insert("devSampleRate", QJsonValue(dev_sample_rate));
266  }
268  obj->insert("log2Interp", QJsonValue(log2_interp));
269  }
271  obj->insert("transverterMode", QJsonValue(transverter_mode));
272  }
274  obj->insert("transverterDeltaFrequency", QJsonValue(transverter_delta_frequency));
275  }
276  if(antenna != nullptr && *antenna != QString("")){
277  toJsonValue(QString("antenna"), antenna, obj, QString("QString"));
278  }
279  if(m_bandwidth_isSet){
280  obj->insert("bandwidth", QJsonValue(bandwidth));
281  }
282  if(tunable_elements->size() > 0){
283  toJsonArray((QList<void*>*)tunable_elements, obj, "tunableElements", "SWGArgValue");
284  }
286  obj->insert("globalGain", QJsonValue(global_gain));
287  }
288  if(individual_gains->size() > 0){
289  toJsonArray((QList<void*>*)individual_gains, obj, "individualGains", "SWGArgValue");
290  }
291  if(m_auto_gain_isSet){
292  obj->insert("autoGain", QJsonValue(auto_gain));
293  }
295  obj->insert("autoDCCorrection", QJsonValue(auto_dc_correction));
296  }
298  obj->insert("autoIQCorrection", QJsonValue(auto_iq_correction));
299  }
300  if((dc_correction != nullptr) && (dc_correction->isSet())){
301  toJsonValue(QString("dcCorrection"), dc_correction, obj, QString("SWGComplex"));
302  }
303  if((iq_correction != nullptr) && (iq_correction->isSet())){
304  toJsonValue(QString("iqCorrection"), iq_correction, obj, QString("SWGComplex"));
305  }
306  if(stream_arg_settings->size() > 0){
307  toJsonArray((QList<void*>*)stream_arg_settings, obj, "streamArgSettings", "SWGArgValue");
308  }
309  if(device_arg_settings->size() > 0){
310  toJsonArray((QList<void*>*)device_arg_settings, obj, "deviceArgSettings", "SWGArgValue");
311  }
313  obj->insert("useReverseAPI", QJsonValue(use_reverse_api));
314  }
315  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){
316  toJsonValue(QString("reverseAPIAddress"), reverse_api_address, obj, QString("QString"));
317  }
319  obj->insert("reverseAPIPort", QJsonValue(reverse_api_port));
320  }
322  obj->insert("reverseAPIDeviceIndex", QJsonValue(reverse_api_device_index));
323  }
324 
325  return obj;
326 }
327 
328 qint64
330  return center_frequency;
331 }
332 void
334  this->center_frequency = center_frequency;
335  this->m_center_frequency_isSet = true;
336 }
337 
338 qint32
340  return l_oppm_tenths;
341 }
342 void
344  this->l_oppm_tenths = l_oppm_tenths;
345  this->m_l_oppm_tenths_isSet = true;
346 }
347 
348 qint32
350  return dev_sample_rate;
351 }
352 void
354  this->dev_sample_rate = dev_sample_rate;
355  this->m_dev_sample_rate_isSet = true;
356 }
357 
358 qint32
360  return log2_interp;
361 }
362 void
364  this->log2_interp = log2_interp;
365  this->m_log2_interp_isSet = true;
366 }
367 
368 qint32
370  return transverter_mode;
371 }
372 void
374  this->transverter_mode = transverter_mode;
375  this->m_transverter_mode_isSet = true;
376 }
377 
378 qint64
381 }
382 void
384  this->transverter_delta_frequency = transverter_delta_frequency;
386 }
387 
388 QString*
390  return antenna;
391 }
392 void
394  this->antenna = antenna;
395  this->m_antenna_isSet = true;
396 }
397 
398 qint32
400  return bandwidth;
401 }
402 void
404  this->bandwidth = bandwidth;
405  this->m_bandwidth_isSet = true;
406 }
407 
408 QList<SWGArgValue*>*
410  return tunable_elements;
411 }
412 void
414  this->tunable_elements = tunable_elements;
415  this->m_tunable_elements_isSet = true;
416 }
417 
418 qint32
420  return global_gain;
421 }
422 void
424  this->global_gain = global_gain;
425  this->m_global_gain_isSet = true;
426 }
427 
428 QList<SWGArgValue*>*
430  return individual_gains;
431 }
432 void
434  this->individual_gains = individual_gains;
435  this->m_individual_gains_isSet = true;
436 }
437 
438 qint32
440  return auto_gain;
441 }
442 void
444  this->auto_gain = auto_gain;
445  this->m_auto_gain_isSet = true;
446 }
447 
448 qint32
450  return auto_dc_correction;
451 }
452 void
454  this->auto_dc_correction = auto_dc_correction;
455  this->m_auto_dc_correction_isSet = true;
456 }
457 
458 qint32
460  return auto_iq_correction;
461 }
462 void
464  this->auto_iq_correction = auto_iq_correction;
465  this->m_auto_iq_correction_isSet = true;
466 }
467 
468 SWGComplex*
470  return dc_correction;
471 }
472 void
474  this->dc_correction = dc_correction;
475  this->m_dc_correction_isSet = true;
476 }
477 
478 SWGComplex*
480  return iq_correction;
481 }
482 void
484  this->iq_correction = iq_correction;
485  this->m_iq_correction_isSet = true;
486 }
487 
488 QList<SWGArgValue*>*
490  return stream_arg_settings;
491 }
492 void
494  this->stream_arg_settings = stream_arg_settings;
495  this->m_stream_arg_settings_isSet = true;
496 }
497 
498 QList<SWGArgValue*>*
500  return device_arg_settings;
501 }
502 void
504  this->device_arg_settings = device_arg_settings;
505  this->m_device_arg_settings_isSet = true;
506 }
507 
508 qint32
510  return use_reverse_api;
511 }
512 void
514  this->use_reverse_api = use_reverse_api;
515  this->m_use_reverse_api_isSet = true;
516 }
517 
518 QString*
520  return reverse_api_address;
521 }
522 void
524  this->reverse_api_address = reverse_api_address;
525  this->m_reverse_api_address_isSet = true;
526 }
527 
528 qint32
530  return reverse_api_port;
531 }
532 void
534  this->reverse_api_port = reverse_api_port;
535  this->m_reverse_api_port_isSet = true;
536 }
537 
538 qint32
541 }
542 void
544  this->reverse_api_device_index = reverse_api_device_index;
546 }
547 
548 
549 bool
551  bool isObjectUpdated = false;
552  do{
553  if(m_center_frequency_isSet){ isObjectUpdated = true; break;}
554  if(m_l_oppm_tenths_isSet){ isObjectUpdated = true; break;}
555  if(m_dev_sample_rate_isSet){ isObjectUpdated = true; break;}
556  if(m_log2_interp_isSet){ isObjectUpdated = true; break;}
557  if(m_transverter_mode_isSet){ isObjectUpdated = true; break;}
558  if(m_transverter_delta_frequency_isSet){ isObjectUpdated = true; break;}
559  if(antenna != nullptr && *antenna != QString("")){ isObjectUpdated = true; break;}
560  if(m_bandwidth_isSet){ isObjectUpdated = true; break;}
561  if(tunable_elements->size() > 0){ isObjectUpdated = true; break;}
562  if(m_global_gain_isSet){ isObjectUpdated = true; break;}
563  if(individual_gains->size() > 0){ isObjectUpdated = true; break;}
564  if(m_auto_gain_isSet){ isObjectUpdated = true; break;}
565  if(m_auto_dc_correction_isSet){ isObjectUpdated = true; break;}
566  if(m_auto_iq_correction_isSet){ isObjectUpdated = true; break;}
567  if(dc_correction != nullptr && dc_correction->isSet()){ isObjectUpdated = true; break;}
568  if(iq_correction != nullptr && iq_correction->isSet()){ isObjectUpdated = true; break;}
569  if(stream_arg_settings->size() > 0){ isObjectUpdated = true; break;}
570  if(device_arg_settings->size() > 0){ isObjectUpdated = true; break;}
571  if(m_use_reverse_api_isSet){ isObjectUpdated = true; break;}
572  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){ isObjectUpdated = true; break;}
573  if(m_reverse_api_port_isSet){ isObjectUpdated = true; break;}
574  if(m_reverse_api_device_index_isSet){ isObjectUpdated = true; break;}
575  }while(false);
576  return isObjectUpdated;
577 }
578 }
579 
void setAutoIqCorrection(qint32 auto_iq_correction)
virtual SWGSoapySDROutputSettings * fromJson(QString &jsonString) override
void setAutoDcCorrection(qint32 auto_dc_correction)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setTunableElements(QList< SWGArgValue *> *tunable_elements)
virtual void fromJsonObject(QJsonObject &json) override
void setIndividualGains(QList< SWGArgValue *> *individual_gains)
virtual bool isSet() override
Definition: SWGComplex.cpp:118
void setIqCorrection(SWGComplex *iq_correction)
void setDcCorrection(SWGComplex *dc_correction)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setReverseApiAddress(QString *reverse_api_address)
void setTransverterDeltaFrequency(qint64 transverter_delta_frequency)
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 setDeviceArgSettings(QList< SWGArgValue *> *device_arg_settings)
virtual QJsonObject * asJsonObject() override
void setStreamArgSettings(QList< SWGArgValue *> *stream_arg_settings)