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.
SWGTestSourceSettings.cpp
Go to the documentation of this file.
1 
14 #include "SWGTestSourceSettings.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  frequency_shift = 0;
35  sample_rate = 0;
36  m_sample_rate_isSet = false;
37  log2_decim = 0;
38  m_log2_decim_isSet = false;
39  fc_pos = 0;
40  m_fc_pos_isSet = false;
43  amplitude_bits = 0;
44  m_amplitude_bits_isSet = false;
47  modulation = 0;
48  m_modulation_isSet = false;
49  modulation_tone = 0;
51  am_modulation = 0;
52  m_am_modulation_isSet = false;
53  fm_deviation = 0;
54  m_fm_deviation_isSet = false;
55  dc_factor = 0.0f;
56  m_dc_factor_isSet = false;
57  i_factor = 0.0f;
58  m_i_factor_isSet = false;
59  q_factor = 0.0f;
60  m_q_factor_isSet = false;
61  phase_imbalance = 0.0f;
63  file_record_name = nullptr;
65  use_reverse_api = 0;
67  reverse_api_address = nullptr;
69  reverse_api_port = 0;
73 }
74 
76  this->cleanup();
77 }
78 
79 void
81  center_frequency = 0;
83  frequency_shift = 0;
85  sample_rate = 0;
86  m_sample_rate_isSet = false;
87  log2_decim = 0;
88  m_log2_decim_isSet = false;
89  fc_pos = 0;
90  m_fc_pos_isSet = false;
93  amplitude_bits = 0;
94  m_amplitude_bits_isSet = false;
97  modulation = 0;
98  m_modulation_isSet = false;
99  modulation_tone = 0;
100  m_modulation_tone_isSet = false;
101  am_modulation = 0;
102  m_am_modulation_isSet = false;
103  fm_deviation = 0;
104  m_fm_deviation_isSet = false;
105  dc_factor = 0.0f;
106  m_dc_factor_isSet = false;
107  i_factor = 0.0f;
108  m_i_factor_isSet = false;
109  q_factor = 0.0f;
110  m_q_factor_isSet = false;
111  phase_imbalance = 0.0f;
112  m_phase_imbalance_isSet = false;
113  file_record_name = new QString("");
114  m_file_record_name_isSet = false;
115  use_reverse_api = 0;
116  m_use_reverse_api_isSet = false;
117  reverse_api_address = new QString("");
119  reverse_api_port = 0;
120  m_reverse_api_port_isSet = false;
123 }
124 
125 void
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
137 
138 
139 
140 
141 
142 
143  if(file_record_name != nullptr) {
144  delete file_record_name;
145  }
146 
147  if(reverse_api_address != nullptr) {
148  delete reverse_api_address;
149  }
150 
151 
152 }
153 
156  QByteArray array (json.toStdString().c_str());
157  QJsonDocument doc = QJsonDocument::fromJson(array);
158  QJsonObject jsonObject = doc.object();
159  this->fromJsonObject(jsonObject);
160  return this;
161 }
162 
163 void
165  ::SWGSDRangel::setValue(&center_frequency, pJson["centerFrequency"], "qint32", "");
166 
167  ::SWGSDRangel::setValue(&frequency_shift, pJson["frequencyShift"], "qint32", "");
168 
169  ::SWGSDRangel::setValue(&sample_rate, pJson["sampleRate"], "qint32", "");
170 
171  ::SWGSDRangel::setValue(&log2_decim, pJson["log2Decim"], "qint32", "");
172 
173  ::SWGSDRangel::setValue(&fc_pos, pJson["fcPos"], "qint32", "");
174 
175  ::SWGSDRangel::setValue(&sample_size_index, pJson["sampleSizeIndex"], "qint32", "");
176 
177  ::SWGSDRangel::setValue(&amplitude_bits, pJson["amplitudeBits"], "qint32", "");
178 
179  ::SWGSDRangel::setValue(&auto_corr_options, pJson["autoCorrOptions"], "qint32", "");
180 
181  ::SWGSDRangel::setValue(&modulation, pJson["modulation"], "qint32", "");
182 
183  ::SWGSDRangel::setValue(&modulation_tone, pJson["modulationTone"], "qint32", "");
184 
185  ::SWGSDRangel::setValue(&am_modulation, pJson["amModulation"], "qint32", "");
186 
187  ::SWGSDRangel::setValue(&fm_deviation, pJson["fmDeviation"], "qint32", "");
188 
189  ::SWGSDRangel::setValue(&dc_factor, pJson["dcFactor"], "float", "");
190 
191  ::SWGSDRangel::setValue(&i_factor, pJson["iFactor"], "float", "");
192 
193  ::SWGSDRangel::setValue(&q_factor, pJson["qFactor"], "float", "");
194 
195  ::SWGSDRangel::setValue(&phase_imbalance, pJson["phaseImbalance"], "float", "");
196 
197  ::SWGSDRangel::setValue(&file_record_name, pJson["fileRecordName"], "QString", "QString");
198 
199  ::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", "");
200 
201  ::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString");
202 
203  ::SWGSDRangel::setValue(&reverse_api_port, pJson["reverseAPIPort"], "qint32", "");
204 
205  ::SWGSDRangel::setValue(&reverse_api_device_index, pJson["reverseAPIDeviceIndex"], "qint32", "");
206 
207 }
208 
209 QString
211 {
212  QJsonObject* obj = this->asJsonObject();
213 
214  QJsonDocument doc(*obj);
215  QByteArray bytes = doc.toJson();
216  delete obj;
217  return QString(bytes);
218 }
219 
220 QJsonObject*
222  QJsonObject* obj = new QJsonObject();
224  obj->insert("centerFrequency", QJsonValue(center_frequency));
225  }
227  obj->insert("frequencyShift", QJsonValue(frequency_shift));
228  }
230  obj->insert("sampleRate", QJsonValue(sample_rate));
231  }
232  if(m_log2_decim_isSet){
233  obj->insert("log2Decim", QJsonValue(log2_decim));
234  }
235  if(m_fc_pos_isSet){
236  obj->insert("fcPos", QJsonValue(fc_pos));
237  }
239  obj->insert("sampleSizeIndex", QJsonValue(sample_size_index));
240  }
242  obj->insert("amplitudeBits", QJsonValue(amplitude_bits));
243  }
245  obj->insert("autoCorrOptions", QJsonValue(auto_corr_options));
246  }
247  if(m_modulation_isSet){
248  obj->insert("modulation", QJsonValue(modulation));
249  }
251  obj->insert("modulationTone", QJsonValue(modulation_tone));
252  }
254  obj->insert("amModulation", QJsonValue(am_modulation));
255  }
257  obj->insert("fmDeviation", QJsonValue(fm_deviation));
258  }
259  if(m_dc_factor_isSet){
260  obj->insert("dcFactor", QJsonValue(dc_factor));
261  }
262  if(m_i_factor_isSet){
263  obj->insert("iFactor", QJsonValue(i_factor));
264  }
265  if(m_q_factor_isSet){
266  obj->insert("qFactor", QJsonValue(q_factor));
267  }
269  obj->insert("phaseImbalance", QJsonValue(phase_imbalance));
270  }
271  if(file_record_name != nullptr && *file_record_name != QString("")){
272  toJsonValue(QString("fileRecordName"), file_record_name, obj, QString("QString"));
273  }
275  obj->insert("useReverseAPI", QJsonValue(use_reverse_api));
276  }
277  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){
278  toJsonValue(QString("reverseAPIAddress"), reverse_api_address, obj, QString("QString"));
279  }
281  obj->insert("reverseAPIPort", QJsonValue(reverse_api_port));
282  }
284  obj->insert("reverseAPIDeviceIndex", QJsonValue(reverse_api_device_index));
285  }
286 
287  return obj;
288 }
289 
290 qint32
292  return center_frequency;
293 }
294 void
296  this->center_frequency = center_frequency;
297  this->m_center_frequency_isSet = true;
298 }
299 
300 qint32
302  return frequency_shift;
303 }
304 void
306  this->frequency_shift = frequency_shift;
307  this->m_frequency_shift_isSet = true;
308 }
309 
310 qint32
312  return sample_rate;
313 }
314 void
316  this->sample_rate = sample_rate;
317  this->m_sample_rate_isSet = true;
318 }
319 
320 qint32
322  return log2_decim;
323 }
324 void
326  this->log2_decim = log2_decim;
327  this->m_log2_decim_isSet = true;
328 }
329 
330 qint32
332  return fc_pos;
333 }
334 void
336  this->fc_pos = fc_pos;
337  this->m_fc_pos_isSet = true;
338 }
339 
340 qint32
342  return sample_size_index;
343 }
344 void
346  this->sample_size_index = sample_size_index;
347  this->m_sample_size_index_isSet = true;
348 }
349 
350 qint32
352  return amplitude_bits;
353 }
354 void
356  this->amplitude_bits = amplitude_bits;
357  this->m_amplitude_bits_isSet = true;
358 }
359 
360 qint32
362  return auto_corr_options;
363 }
364 void
366  this->auto_corr_options = auto_corr_options;
367  this->m_auto_corr_options_isSet = true;
368 }
369 
370 qint32
372  return modulation;
373 }
374 void
376  this->modulation = modulation;
377  this->m_modulation_isSet = true;
378 }
379 
380 qint32
382  return modulation_tone;
383 }
384 void
386  this->modulation_tone = modulation_tone;
387  this->m_modulation_tone_isSet = true;
388 }
389 
390 qint32
392  return am_modulation;
393 }
394 void
396  this->am_modulation = am_modulation;
397  this->m_am_modulation_isSet = true;
398 }
399 
400 qint32
402  return fm_deviation;
403 }
404 void
406  this->fm_deviation = fm_deviation;
407  this->m_fm_deviation_isSet = true;
408 }
409 
410 float
412  return dc_factor;
413 }
414 void
416  this->dc_factor = dc_factor;
417  this->m_dc_factor_isSet = true;
418 }
419 
420 float
422  return i_factor;
423 }
424 void
426  this->i_factor = i_factor;
427  this->m_i_factor_isSet = true;
428 }
429 
430 float
432  return q_factor;
433 }
434 void
436  this->q_factor = q_factor;
437  this->m_q_factor_isSet = true;
438 }
439 
440 float
442  return phase_imbalance;
443 }
444 void
446  this->phase_imbalance = phase_imbalance;
447  this->m_phase_imbalance_isSet = true;
448 }
449 
450 QString*
452  return file_record_name;
453 }
454 void
456  this->file_record_name = file_record_name;
457  this->m_file_record_name_isSet = true;
458 }
459 
460 qint32
462  return use_reverse_api;
463 }
464 void
466  this->use_reverse_api = use_reverse_api;
467  this->m_use_reverse_api_isSet = true;
468 }
469 
470 QString*
472  return reverse_api_address;
473 }
474 void
476  this->reverse_api_address = reverse_api_address;
477  this->m_reverse_api_address_isSet = true;
478 }
479 
480 qint32
482  return reverse_api_port;
483 }
484 void
486  this->reverse_api_port = reverse_api_port;
487  this->m_reverse_api_port_isSet = true;
488 }
489 
490 qint32
493 }
494 void
496  this->reverse_api_device_index = reverse_api_device_index;
498 }
499 
500 
501 bool
503  bool isObjectUpdated = false;
504  do{
505  if(m_center_frequency_isSet){ isObjectUpdated = true; break;}
506  if(m_frequency_shift_isSet){ isObjectUpdated = true; break;}
507  if(m_sample_rate_isSet){ isObjectUpdated = true; break;}
508  if(m_log2_decim_isSet){ isObjectUpdated = true; break;}
509  if(m_fc_pos_isSet){ isObjectUpdated = true; break;}
510  if(m_sample_size_index_isSet){ isObjectUpdated = true; break;}
511  if(m_amplitude_bits_isSet){ isObjectUpdated = true; break;}
512  if(m_auto_corr_options_isSet){ isObjectUpdated = true; break;}
513  if(m_modulation_isSet){ isObjectUpdated = true; break;}
514  if(m_modulation_tone_isSet){ isObjectUpdated = true; break;}
515  if(m_am_modulation_isSet){ isObjectUpdated = true; break;}
516  if(m_fm_deviation_isSet){ isObjectUpdated = true; break;}
517  if(m_dc_factor_isSet){ isObjectUpdated = true; break;}
518  if(m_i_factor_isSet){ isObjectUpdated = true; break;}
519  if(m_q_factor_isSet){ isObjectUpdated = true; break;}
520  if(m_phase_imbalance_isSet){ isObjectUpdated = true; break;}
521  if(file_record_name != nullptr && *file_record_name != QString("")){ isObjectUpdated = true; break;}
522  if(m_use_reverse_api_isSet){ isObjectUpdated = true; break;}
523  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){ isObjectUpdated = true; break;}
524  if(m_reverse_api_port_isSet){ isObjectUpdated = true; break;}
525  if(m_reverse_api_device_index_isSet){ isObjectUpdated = true; break;}
526  }while(false);
527  return isObjectUpdated;
528 }
529 }
530 
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setFileRecordName(QString *file_record_name)
void setReverseApiPort(qint32 reverse_api_port)
void setUseReverseApi(qint32 use_reverse_api)
virtual QJsonObject * asJsonObject() override
void setSampleSizeIndex(qint32 sample_size_index)
void setReverseApiAddress(QString *reverse_api_address)
void setAutoCorrOptions(qint32 auto_corr_options)
virtual SWGTestSourceSettings * fromJson(QString &jsonString) override
void setAmplitudeBits(qint32 amplitude_bits)
void setModulationTone(qint32 modulation_tone)
virtual void fromJsonObject(QJsonObject &json) override
void setPhaseImbalance(float phase_imbalance)
void setCenterFrequency(qint32 center_frequency)
void setAmModulation(qint32 am_modulation)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setFrequencyShift(qint32 frequency_shift)