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.
SWGSDRPlaySettings.cpp
Go to the documentation of this file.
1 
14 #include "SWGSDRPlaySettings.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  center_frequency = 0;
33  tuner_gain = 0;
34  m_tuner_gain_isSet = false;
35  l_oppm_tenths = 0;
36  m_l_oppm_tenths_isSet = false;
41  bandwidth_index = 0;
45  log2_decim = 0;
46  m_log2_decim_isSet = false;
47  fc_pos = 0;
48  m_fc_pos_isSet = false;
49  dc_block = 0;
50  m_dc_block_isSet = false;
51  iq_correction = 0;
52  m_iq_correction_isSet = false;
53  tuner_gain_mode = 0;
55  lna_on = 0;
56  m_lna_on_isSet = false;
57  mixer_amp_on = 0;
58  m_mixer_amp_on_isSet = false;
59  baseband_gain = 0;
60  m_baseband_gain_isSet = false;
61  file_record_name = nullptr;
63  use_reverse_api = 0;
65  reverse_api_address = nullptr;
67  reverse_api_port = 0;
71 }
72 
74  this->cleanup();
75 }
76 
77 void
79  center_frequency = 0;
81  tuner_gain = 0;
82  m_tuner_gain_isSet = false;
83  l_oppm_tenths = 0;
84  m_l_oppm_tenths_isSet = false;
89  bandwidth_index = 0;
93  log2_decim = 0;
94  m_log2_decim_isSet = false;
95  fc_pos = 0;
96  m_fc_pos_isSet = false;
97  dc_block = 0;
98  m_dc_block_isSet = false;
99  iq_correction = 0;
100  m_iq_correction_isSet = false;
101  tuner_gain_mode = 0;
102  m_tuner_gain_mode_isSet = false;
103  lna_on = 0;
104  m_lna_on_isSet = false;
105  mixer_amp_on = 0;
106  m_mixer_amp_on_isSet = false;
107  baseband_gain = 0;
108  m_baseband_gain_isSet = false;
109  file_record_name = new QString("");
110  m_file_record_name_isSet = false;
111  use_reverse_api = 0;
112  m_use_reverse_api_isSet = false;
113  reverse_api_address = new QString("");
115  reverse_api_port = 0;
116  m_reverse_api_port_isSet = false;
119 }
120 
121 void
123 
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
137 
138  if(file_record_name != nullptr) {
139  delete file_record_name;
140  }
141 
142  if(reverse_api_address != nullptr) {
143  delete reverse_api_address;
144  }
145 
146 
147 }
148 
151  QByteArray array (json.toStdString().c_str());
152  QJsonDocument doc = QJsonDocument::fromJson(array);
153  QJsonObject jsonObject = doc.object();
154  this->fromJsonObject(jsonObject);
155  return this;
156 }
157 
158 void
160  ::SWGSDRangel::setValue(&center_frequency, pJson["centerFrequency"], "qint32", "");
161 
162  ::SWGSDRangel::setValue(&tuner_gain, pJson["tunerGain"], "qint32", "");
163 
164  ::SWGSDRangel::setValue(&l_oppm_tenths, pJson["LOppmTenths"], "qint32", "");
165 
166  ::SWGSDRangel::setValue(&frequency_band_index, pJson["frequencyBandIndex"], "qint32", "");
167 
168  ::SWGSDRangel::setValue(&if_frequency_index, pJson["ifFrequencyIndex"], "qint32", "");
169 
170  ::SWGSDRangel::setValue(&bandwidth_index, pJson["bandwidthIndex"], "qint32", "");
171 
172  ::SWGSDRangel::setValue(&dev_sample_rate_index, pJson["devSampleRateIndex"], "qint32", "");
173 
174  ::SWGSDRangel::setValue(&log2_decim, pJson["log2Decim"], "qint32", "");
175 
176  ::SWGSDRangel::setValue(&fc_pos, pJson["fcPos"], "qint32", "");
177 
178  ::SWGSDRangel::setValue(&dc_block, pJson["dcBlock"], "qint32", "");
179 
180  ::SWGSDRangel::setValue(&iq_correction, pJson["iqCorrection"], "qint32", "");
181 
182  ::SWGSDRangel::setValue(&tuner_gain_mode, pJson["tunerGainMode"], "qint32", "");
183 
184  ::SWGSDRangel::setValue(&lna_on, pJson["lnaOn"], "qint32", "");
185 
186  ::SWGSDRangel::setValue(&mixer_amp_on, pJson["mixerAmpOn"], "qint32", "");
187 
188  ::SWGSDRangel::setValue(&baseband_gain, pJson["basebandGain"], "qint32", "");
189 
190  ::SWGSDRangel::setValue(&file_record_name, pJson["fileRecordName"], "QString", "QString");
191 
192  ::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", "");
193 
194  ::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString");
195 
196  ::SWGSDRangel::setValue(&reverse_api_port, pJson["reverseAPIPort"], "qint32", "");
197 
198  ::SWGSDRangel::setValue(&reverse_api_device_index, pJson["reverseAPIDeviceIndex"], "qint32", "");
199 
200 }
201 
202 QString
204 {
205  QJsonObject* obj = this->asJsonObject();
206 
207  QJsonDocument doc(*obj);
208  QByteArray bytes = doc.toJson();
209  delete obj;
210  return QString(bytes);
211 }
212 
213 QJsonObject*
215  QJsonObject* obj = new QJsonObject();
217  obj->insert("centerFrequency", QJsonValue(center_frequency));
218  }
219  if(m_tuner_gain_isSet){
220  obj->insert("tunerGain", QJsonValue(tuner_gain));
221  }
223  obj->insert("LOppmTenths", QJsonValue(l_oppm_tenths));
224  }
226  obj->insert("frequencyBandIndex", QJsonValue(frequency_band_index));
227  }
229  obj->insert("ifFrequencyIndex", QJsonValue(if_frequency_index));
230  }
232  obj->insert("bandwidthIndex", QJsonValue(bandwidth_index));
233  }
235  obj->insert("devSampleRateIndex", QJsonValue(dev_sample_rate_index));
236  }
237  if(m_log2_decim_isSet){
238  obj->insert("log2Decim", QJsonValue(log2_decim));
239  }
240  if(m_fc_pos_isSet){
241  obj->insert("fcPos", QJsonValue(fc_pos));
242  }
243  if(m_dc_block_isSet){
244  obj->insert("dcBlock", QJsonValue(dc_block));
245  }
247  obj->insert("iqCorrection", QJsonValue(iq_correction));
248  }
250  obj->insert("tunerGainMode", QJsonValue(tuner_gain_mode));
251  }
252  if(m_lna_on_isSet){
253  obj->insert("lnaOn", QJsonValue(lna_on));
254  }
256  obj->insert("mixerAmpOn", QJsonValue(mixer_amp_on));
257  }
259  obj->insert("basebandGain", QJsonValue(baseband_gain));
260  }
261  if(file_record_name != nullptr && *file_record_name != QString("")){
262  toJsonValue(QString("fileRecordName"), file_record_name, obj, QString("QString"));
263  }
265  obj->insert("useReverseAPI", QJsonValue(use_reverse_api));
266  }
267  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){
268  toJsonValue(QString("reverseAPIAddress"), reverse_api_address, obj, QString("QString"));
269  }
271  obj->insert("reverseAPIPort", QJsonValue(reverse_api_port));
272  }
274  obj->insert("reverseAPIDeviceIndex", QJsonValue(reverse_api_device_index));
275  }
276 
277  return obj;
278 }
279 
280 qint32
282  return center_frequency;
283 }
284 void
286  this->center_frequency = center_frequency;
287  this->m_center_frequency_isSet = true;
288 }
289 
290 qint32
292  return tuner_gain;
293 }
294 void
296  this->tuner_gain = tuner_gain;
297  this->m_tuner_gain_isSet = true;
298 }
299 
300 qint32
302  return l_oppm_tenths;
303 }
304 void
306  this->l_oppm_tenths = l_oppm_tenths;
307  this->m_l_oppm_tenths_isSet = true;
308 }
309 
310 qint32
312  return frequency_band_index;
313 }
314 void
316  this->frequency_band_index = frequency_band_index;
317  this->m_frequency_band_index_isSet = true;
318 }
319 
320 qint32
322  return if_frequency_index;
323 }
324 void
326  this->if_frequency_index = if_frequency_index;
327  this->m_if_frequency_index_isSet = true;
328 }
329 
330 qint32
332  return bandwidth_index;
333 }
334 void
336  this->bandwidth_index = bandwidth_index;
337  this->m_bandwidth_index_isSet = true;
338 }
339 
340 qint32
342  return dev_sample_rate_index;
343 }
344 void
346  this->dev_sample_rate_index = dev_sample_rate_index;
347  this->m_dev_sample_rate_index_isSet = true;
348 }
349 
350 qint32
352  return log2_decim;
353 }
354 void
356  this->log2_decim = log2_decim;
357  this->m_log2_decim_isSet = true;
358 }
359 
360 qint32
362  return fc_pos;
363 }
364 void
366  this->fc_pos = fc_pos;
367  this->m_fc_pos_isSet = true;
368 }
369 
370 qint32
372  return dc_block;
373 }
374 void
376  this->dc_block = dc_block;
377  this->m_dc_block_isSet = true;
378 }
379 
380 qint32
382  return iq_correction;
383 }
384 void
386  this->iq_correction = iq_correction;
387  this->m_iq_correction_isSet = true;
388 }
389 
390 qint32
392  return tuner_gain_mode;
393 }
394 void
396  this->tuner_gain_mode = tuner_gain_mode;
397  this->m_tuner_gain_mode_isSet = true;
398 }
399 
400 qint32
402  return lna_on;
403 }
404 void
406  this->lna_on = lna_on;
407  this->m_lna_on_isSet = true;
408 }
409 
410 qint32
412  return mixer_amp_on;
413 }
414 void
416  this->mixer_amp_on = mixer_amp_on;
417  this->m_mixer_amp_on_isSet = true;
418 }
419 
420 qint32
422  return baseband_gain;
423 }
424 void
426  this->baseband_gain = baseband_gain;
427  this->m_baseband_gain_isSet = true;
428 }
429 
430 QString*
432  return file_record_name;
433 }
434 void
436  this->file_record_name = file_record_name;
437  this->m_file_record_name_isSet = true;
438 }
439 
440 qint32
442  return use_reverse_api;
443 }
444 void
446  this->use_reverse_api = use_reverse_api;
447  this->m_use_reverse_api_isSet = true;
448 }
449 
450 QString*
452  return reverse_api_address;
453 }
454 void
456  this->reverse_api_address = reverse_api_address;
457  this->m_reverse_api_address_isSet = true;
458 }
459 
460 qint32
462  return reverse_api_port;
463 }
464 void
466  this->reverse_api_port = reverse_api_port;
467  this->m_reverse_api_port_isSet = true;
468 }
469 
470 qint32
473 }
474 void
476  this->reverse_api_device_index = reverse_api_device_index;
478 }
479 
480 
481 bool
483  bool isObjectUpdated = false;
484  do{
485  if(m_center_frequency_isSet){ isObjectUpdated = true; break;}
486  if(m_tuner_gain_isSet){ isObjectUpdated = true; break;}
487  if(m_l_oppm_tenths_isSet){ isObjectUpdated = true; break;}
488  if(m_frequency_band_index_isSet){ isObjectUpdated = true; break;}
489  if(m_if_frequency_index_isSet){ isObjectUpdated = true; break;}
490  if(m_bandwidth_index_isSet){ isObjectUpdated = true; break;}
491  if(m_dev_sample_rate_index_isSet){ isObjectUpdated = true; break;}
492  if(m_log2_decim_isSet){ isObjectUpdated = true; break;}
493  if(m_fc_pos_isSet){ isObjectUpdated = true; break;}
494  if(m_dc_block_isSet){ isObjectUpdated = true; break;}
495  if(m_iq_correction_isSet){ isObjectUpdated = true; break;}
496  if(m_tuner_gain_mode_isSet){ isObjectUpdated = true; break;}
497  if(m_lna_on_isSet){ isObjectUpdated = true; break;}
498  if(m_mixer_amp_on_isSet){ isObjectUpdated = true; break;}
499  if(m_baseband_gain_isSet){ isObjectUpdated = true; break;}
500  if(file_record_name != nullptr && *file_record_name != QString("")){ isObjectUpdated = true; break;}
501  if(m_use_reverse_api_isSet){ isObjectUpdated = true; break;}
502  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){ isObjectUpdated = true; break;}
503  if(m_reverse_api_port_isSet){ isObjectUpdated = true; break;}
504  if(m_reverse_api_device_index_isSet){ isObjectUpdated = true; break;}
505  }while(false);
506  return isObjectUpdated;
507 }
508 }
509 
void setFileRecordName(QString *file_record_name)
virtual SWGSDRPlaySettings * fromJson(QString &jsonString) override
void setReverseApiPort(qint32 reverse_api_port)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setIqCorrection(qint32 iq_correction)
void setTunerGain(qint32 tuner_gain)
void setBasebandGain(qint32 baseband_gain)
void setIfFrequencyIndex(qint32 if_frequency_index)
void setUseReverseApi(qint32 use_reverse_api)
void setTunerGainMode(qint32 tuner_gain_mode)
virtual QJsonObject * asJsonObject() override
virtual QString asJson() override
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setLog2Decim(qint32 log2_decim)
void setFrequencyBandIndex(qint32 frequency_band_index)
void setCenterFrequency(qint32 center_frequency)
virtual void fromJsonObject(QJsonObject &json) override
void setBandwidthIndex(qint32 bandwidth_index)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void setLOppmTenths(qint32 l_oppm_tenths)
void setDevSampleRateIndex(qint32 dev_sample_rate_index)
void setMixerAmpOn(qint32 mixer_amp_on)
void setReverseApiAddress(QString *reverse_api_address)