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.
SWGRtlSdrSettings.cpp
Go to the documentation of this file.
1 
14 #include "SWGRtlSdrSettings.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  dev_sample_rate = 0;
33  low_sample_rate = 0;
35  center_frequency = 0L;
37  gain = 0;
38  m_gain_isSet = false;
41  log2_decim = 0;
42  m_log2_decim_isSet = false;
43  fc_pos = 0;
44  m_fc_pos_isSet = false;
45  dc_block = 0;
46  m_dc_block_isSet = false;
47  iq_imbalance = 0;
48  m_iq_imbalance_isSet = false;
49  agc = 0;
50  m_agc_isSet = false;
51  no_mod_mode = 0;
52  m_no_mod_mode_isSet = false;
53  offset_tuning = 0;
54  m_offset_tuning_isSet = false;
55  transverter_mode = 0;
59  rf_bandwidth = 0;
60  m_rf_bandwidth_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  dev_sample_rate = 0;
81  low_sample_rate = 0;
83  center_frequency = 0L;
85  gain = 0;
86  m_gain_isSet = false;
89  log2_decim = 0;
90  m_log2_decim_isSet = false;
91  fc_pos = 0;
92  m_fc_pos_isSet = false;
93  dc_block = 0;
94  m_dc_block_isSet = false;
95  iq_imbalance = 0;
96  m_iq_imbalance_isSet = false;
97  agc = 0;
98  m_agc_isSet = false;
99  no_mod_mode = 0;
100  m_no_mod_mode_isSet = false;
101  offset_tuning = 0;
102  m_offset_tuning_isSet = false;
103  transverter_mode = 0;
104  m_transverter_mode_isSet = false;
107  rf_bandwidth = 0;
108  m_rf_bandwidth_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(&dev_sample_rate, pJson["devSampleRate"], "qint32", "");
161 
162  ::SWGSDRangel::setValue(&low_sample_rate, pJson["lowSampleRate"], "qint32", "");
163 
164  ::SWGSDRangel::setValue(&center_frequency, pJson["centerFrequency"], "qint64", "");
165 
166  ::SWGSDRangel::setValue(&gain, pJson["gain"], "qint32", "");
167 
168  ::SWGSDRangel::setValue(&lo_ppm_correction, pJson["loPpmCorrection"], "qint32", "");
169 
170  ::SWGSDRangel::setValue(&log2_decim, pJson["log2Decim"], "qint32", "");
171 
172  ::SWGSDRangel::setValue(&fc_pos, pJson["fcPos"], "qint32", "");
173 
174  ::SWGSDRangel::setValue(&dc_block, pJson["dcBlock"], "qint32", "");
175 
176  ::SWGSDRangel::setValue(&iq_imbalance, pJson["iqImbalance"], "qint32", "");
177 
178  ::SWGSDRangel::setValue(&agc, pJson["agc"], "qint32", "");
179 
180  ::SWGSDRangel::setValue(&no_mod_mode, pJson["noModMode"], "qint32", "");
181 
182  ::SWGSDRangel::setValue(&offset_tuning, pJson["offsetTuning"], "qint32", "");
183 
184  ::SWGSDRangel::setValue(&transverter_mode, pJson["transverterMode"], "qint32", "");
185 
186  ::SWGSDRangel::setValue(&transverter_delta_frequency, pJson["transverterDeltaFrequency"], "qint64", "");
187 
188  ::SWGSDRangel::setValue(&rf_bandwidth, pJson["rfBandwidth"], "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("devSampleRate", QJsonValue(dev_sample_rate));
218  }
220  obj->insert("lowSampleRate", QJsonValue(low_sample_rate));
221  }
223  obj->insert("centerFrequency", QJsonValue(center_frequency));
224  }
225  if(m_gain_isSet){
226  obj->insert("gain", QJsonValue(gain));
227  }
229  obj->insert("loPpmCorrection", QJsonValue(lo_ppm_correction));
230  }
231  if(m_log2_decim_isSet){
232  obj->insert("log2Decim", QJsonValue(log2_decim));
233  }
234  if(m_fc_pos_isSet){
235  obj->insert("fcPos", QJsonValue(fc_pos));
236  }
237  if(m_dc_block_isSet){
238  obj->insert("dcBlock", QJsonValue(dc_block));
239  }
241  obj->insert("iqImbalance", QJsonValue(iq_imbalance));
242  }
243  if(m_agc_isSet){
244  obj->insert("agc", QJsonValue(agc));
245  }
247  obj->insert("noModMode", QJsonValue(no_mod_mode));
248  }
250  obj->insert("offsetTuning", QJsonValue(offset_tuning));
251  }
253  obj->insert("transverterMode", QJsonValue(transverter_mode));
254  }
256  obj->insert("transverterDeltaFrequency", QJsonValue(transverter_delta_frequency));
257  }
259  obj->insert("rfBandwidth", QJsonValue(rf_bandwidth));
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 dev_sample_rate;
283 }
284 void
286  this->dev_sample_rate = dev_sample_rate;
287  this->m_dev_sample_rate_isSet = true;
288 }
289 
290 qint32
292  return low_sample_rate;
293 }
294 void
296  this->low_sample_rate = low_sample_rate;
297  this->m_low_sample_rate_isSet = true;
298 }
299 
300 qint64
302  return center_frequency;
303 }
304 void
306  this->center_frequency = center_frequency;
307  this->m_center_frequency_isSet = true;
308 }
309 
310 qint32
312  return gain;
313 }
314 void
316  this->gain = gain;
317  this->m_gain_isSet = true;
318 }
319 
320 qint32
322  return lo_ppm_correction;
323 }
324 void
326  this->lo_ppm_correction = lo_ppm_correction;
327  this->m_lo_ppm_correction_isSet = true;
328 }
329 
330 qint32
332  return log2_decim;
333 }
334 void
336  this->log2_decim = log2_decim;
337  this->m_log2_decim_isSet = true;
338 }
339 
340 qint32
342  return fc_pos;
343 }
344 void
346  this->fc_pos = fc_pos;
347  this->m_fc_pos_isSet = true;
348 }
349 
350 qint32
352  return dc_block;
353 }
354 void
356  this->dc_block = dc_block;
357  this->m_dc_block_isSet = true;
358 }
359 
360 qint32
362  return iq_imbalance;
363 }
364 void
366  this->iq_imbalance = iq_imbalance;
367  this->m_iq_imbalance_isSet = true;
368 }
369 
370 qint32
372  return agc;
373 }
374 void
376  this->agc = agc;
377  this->m_agc_isSet = true;
378 }
379 
380 qint32
382  return no_mod_mode;
383 }
384 void
386  this->no_mod_mode = no_mod_mode;
387  this->m_no_mod_mode_isSet = true;
388 }
389 
390 qint32
392  return offset_tuning;
393 }
394 void
396  this->offset_tuning = offset_tuning;
397  this->m_offset_tuning_isSet = true;
398 }
399 
400 qint32
402  return transverter_mode;
403 }
404 void
406  this->transverter_mode = transverter_mode;
407  this->m_transverter_mode_isSet = true;
408 }
409 
410 qint64
413 }
414 void
416  this->transverter_delta_frequency = transverter_delta_frequency;
418 }
419 
420 qint32
422  return rf_bandwidth;
423 }
424 void
426  this->rf_bandwidth = rf_bandwidth;
427  this->m_rf_bandwidth_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_dev_sample_rate_isSet){ isObjectUpdated = true; break;}
486  if(m_low_sample_rate_isSet){ isObjectUpdated = true; break;}
487  if(m_center_frequency_isSet){ isObjectUpdated = true; break;}
488  if(m_gain_isSet){ isObjectUpdated = true; break;}
489  if(m_lo_ppm_correction_isSet){ isObjectUpdated = true; break;}
490  if(m_log2_decim_isSet){ isObjectUpdated = true; break;}
491  if(m_fc_pos_isSet){ isObjectUpdated = true; break;}
492  if(m_dc_block_isSet){ isObjectUpdated = true; break;}
493  if(m_iq_imbalance_isSet){ isObjectUpdated = true; break;}
494  if(m_agc_isSet){ isObjectUpdated = true; break;}
495  if(m_no_mod_mode_isSet){ isObjectUpdated = true; break;}
496  if(m_offset_tuning_isSet){ isObjectUpdated = true; break;}
497  if(m_transverter_mode_isSet){ isObjectUpdated = true; break;}
498  if(m_transverter_delta_frequency_isSet){ isObjectUpdated = true; break;}
499  if(m_rf_bandwidth_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 
virtual QString asJson() override
void setLowSampleRate(qint32 low_sample_rate)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setDevSampleRate(qint32 dev_sample_rate)
void setOffsetTuning(qint32 offset_tuning)
void setTransverterDeltaFrequency(qint64 transverter_delta_frequency)
virtual SWGRtlSdrSettings * fromJson(QString &jsonString) override
void setIqImbalance(qint32 iq_imbalance)
virtual void fromJsonObject(QJsonObject &json) override
void setNoModMode(qint32 no_mod_mode)
void setReverseApiAddress(QString *reverse_api_address)
virtual QJsonObject * asJsonObject() override
void setReverseApiPort(qint32 reverse_api_port)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void setCenterFrequency(qint64 center_frequency)
void setUseReverseApi(qint32 use_reverse_api)
void setFileRecordName(QString *file_record_name)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setTransverterMode(qint32 transverter_mode)
void setRfBandwidth(qint32 rf_bandwidth)
void setLoPpmCorrection(qint32 lo_ppm_correction)
void setLog2Decim(qint32 log2_decim)