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.
SWGUDPSourceSettings.cpp
Go to the documentation of this file.
1 
14 #include "SWGUDPSourceSettings.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  sample_format = 0;
32  m_sample_format_isSet = false;
33  input_sample_rate = 0.0f;
37  rf_bandwidth = 0.0f;
38  m_rf_bandwidth_isSet = false;
39  low_cutoff = 0.0f;
40  m_low_cutoff_isSet = false;
41  fm_deviation = 0;
42  m_fm_deviation_isSet = false;
43  am_mod_factor = 0.0f;
44  m_am_mod_factor_isSet = false;
45  channel_mute = 0;
46  m_channel_mute_isSet = false;
47  gain_in = 0.0f;
48  m_gain_in_isSet = false;
49  gain_out = 0.0f;
50  m_gain_out_isSet = false;
51  squelch = 0.0f;
52  m_squelch_isSet = false;
53  squelch_gate = 0.0f;
54  m_squelch_gate_isSet = false;
55  squelch_enabled = 0;
57  auto_rw_balance = 0;
59  stereo_input = 0;
60  m_stereo_input_isSet = false;
61  rgb_color = 0;
62  m_rgb_color_isSet = false;
63  udp_address = nullptr;
64  m_udp_address_isSet = false;
65  udp_port = 0;
66  m_udp_port_isSet = false;
67  title = nullptr;
68  m_title_isSet = false;
69  use_reverse_api = 0;
71  reverse_api_address = nullptr;
73  reverse_api_port = 0;
79 }
80 
82  this->cleanup();
83 }
84 
85 void
87  sample_format = 0;
88  m_sample_format_isSet = false;
89  input_sample_rate = 0.0f;
93  rf_bandwidth = 0.0f;
94  m_rf_bandwidth_isSet = false;
95  low_cutoff = 0.0f;
96  m_low_cutoff_isSet = false;
97  fm_deviation = 0;
98  m_fm_deviation_isSet = false;
99  am_mod_factor = 0.0f;
100  m_am_mod_factor_isSet = false;
101  channel_mute = 0;
102  m_channel_mute_isSet = false;
103  gain_in = 0.0f;
104  m_gain_in_isSet = false;
105  gain_out = 0.0f;
106  m_gain_out_isSet = false;
107  squelch = 0.0f;
108  m_squelch_isSet = false;
109  squelch_gate = 0.0f;
110  m_squelch_gate_isSet = false;
111  squelch_enabled = 0;
112  m_squelch_enabled_isSet = false;
113  auto_rw_balance = 0;
114  m_auto_rw_balance_isSet = false;
115  stereo_input = 0;
116  m_stereo_input_isSet = false;
117  rgb_color = 0;
118  m_rgb_color_isSet = false;
119  udp_address = new QString("");
120  m_udp_address_isSet = false;
121  udp_port = 0;
122  m_udp_port_isSet = false;
123  title = new QString("");
124  m_title_isSet = false;
125  use_reverse_api = 0;
126  m_use_reverse_api_isSet = false;
127  reverse_api_address = new QString("");
129  reverse_api_port = 0;
130  m_reverse_api_port_isSet = false;
135 }
136 
137 void
139 
140 
141 
142 
143 
144 
145 
146 
147 
148 
149 
150 
151 
152 
153 
154 
155  if(udp_address != nullptr) {
156  delete udp_address;
157  }
158 
159  if(title != nullptr) {
160  delete title;
161  }
162 
163  if(reverse_api_address != nullptr) {
164  delete reverse_api_address;
165  }
166 
167 
168 
169 }
170 
173  QByteArray array (json.toStdString().c_str());
174  QJsonDocument doc = QJsonDocument::fromJson(array);
175  QJsonObject jsonObject = doc.object();
176  this->fromJsonObject(jsonObject);
177  return this;
178 }
179 
180 void
182  ::SWGSDRangel::setValue(&sample_format, pJson["sampleFormat"], "qint32", "");
183 
184  ::SWGSDRangel::setValue(&input_sample_rate, pJson["inputSampleRate"], "float", "");
185 
186  ::SWGSDRangel::setValue(&input_frequency_offset, pJson["inputFrequencyOffset"], "qint64", "");
187 
188  ::SWGSDRangel::setValue(&rf_bandwidth, pJson["rfBandwidth"], "float", "");
189 
190  ::SWGSDRangel::setValue(&low_cutoff, pJson["lowCutoff"], "float", "");
191 
192  ::SWGSDRangel::setValue(&fm_deviation, pJson["fmDeviation"], "qint32", "");
193 
194  ::SWGSDRangel::setValue(&am_mod_factor, pJson["amModFactor"], "float", "");
195 
196  ::SWGSDRangel::setValue(&channel_mute, pJson["channelMute"], "qint32", "");
197 
198  ::SWGSDRangel::setValue(&gain_in, pJson["gainIn"], "float", "");
199 
200  ::SWGSDRangel::setValue(&gain_out, pJson["gainOut"], "float", "");
201 
202  ::SWGSDRangel::setValue(&squelch, pJson["squelch"], "float", "");
203 
204  ::SWGSDRangel::setValue(&squelch_gate, pJson["squelchGate"], "float", "");
205 
206  ::SWGSDRangel::setValue(&squelch_enabled, pJson["squelchEnabled"], "qint32", "");
207 
208  ::SWGSDRangel::setValue(&auto_rw_balance, pJson["autoRWBalance"], "qint32", "");
209 
210  ::SWGSDRangel::setValue(&stereo_input, pJson["stereoInput"], "qint32", "");
211 
212  ::SWGSDRangel::setValue(&rgb_color, pJson["rgbColor"], "qint32", "");
213 
214  ::SWGSDRangel::setValue(&udp_address, pJson["udpAddress"], "QString", "QString");
215 
216  ::SWGSDRangel::setValue(&udp_port, pJson["udpPort"], "qint32", "");
217 
218  ::SWGSDRangel::setValue(&title, pJson["title"], "QString", "QString");
219 
220  ::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", "");
221 
222  ::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString");
223 
224  ::SWGSDRangel::setValue(&reverse_api_port, pJson["reverseAPIPort"], "qint32", "");
225 
226  ::SWGSDRangel::setValue(&reverse_api_device_index, pJson["reverseAPIDeviceIndex"], "qint32", "");
227 
228  ::SWGSDRangel::setValue(&reverse_api_channel_index, pJson["reverseAPIChannelIndex"], "qint32", "");
229 
230 }
231 
232 QString
234 {
235  QJsonObject* obj = this->asJsonObject();
236 
237  QJsonDocument doc(*obj);
238  QByteArray bytes = doc.toJson();
239  delete obj;
240  return QString(bytes);
241 }
242 
243 QJsonObject*
245  QJsonObject* obj = new QJsonObject();
247  obj->insert("sampleFormat", QJsonValue(sample_format));
248  }
250  obj->insert("inputSampleRate", QJsonValue(input_sample_rate));
251  }
253  obj->insert("inputFrequencyOffset", QJsonValue(input_frequency_offset));
254  }
256  obj->insert("rfBandwidth", QJsonValue(rf_bandwidth));
257  }
258  if(m_low_cutoff_isSet){
259  obj->insert("lowCutoff", QJsonValue(low_cutoff));
260  }
262  obj->insert("fmDeviation", QJsonValue(fm_deviation));
263  }
265  obj->insert("amModFactor", QJsonValue(am_mod_factor));
266  }
268  obj->insert("channelMute", QJsonValue(channel_mute));
269  }
270  if(m_gain_in_isSet){
271  obj->insert("gainIn", QJsonValue(gain_in));
272  }
273  if(m_gain_out_isSet){
274  obj->insert("gainOut", QJsonValue(gain_out));
275  }
276  if(m_squelch_isSet){
277  obj->insert("squelch", QJsonValue(squelch));
278  }
280  obj->insert("squelchGate", QJsonValue(squelch_gate));
281  }
283  obj->insert("squelchEnabled", QJsonValue(squelch_enabled));
284  }
286  obj->insert("autoRWBalance", QJsonValue(auto_rw_balance));
287  }
289  obj->insert("stereoInput", QJsonValue(stereo_input));
290  }
291  if(m_rgb_color_isSet){
292  obj->insert("rgbColor", QJsonValue(rgb_color));
293  }
294  if(udp_address != nullptr && *udp_address != QString("")){
295  toJsonValue(QString("udpAddress"), udp_address, obj, QString("QString"));
296  }
297  if(m_udp_port_isSet){
298  obj->insert("udpPort", QJsonValue(udp_port));
299  }
300  if(title != nullptr && *title != QString("")){
301  toJsonValue(QString("title"), title, obj, QString("QString"));
302  }
304  obj->insert("useReverseAPI", QJsonValue(use_reverse_api));
305  }
306  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){
307  toJsonValue(QString("reverseAPIAddress"), reverse_api_address, obj, QString("QString"));
308  }
310  obj->insert("reverseAPIPort", QJsonValue(reverse_api_port));
311  }
313  obj->insert("reverseAPIDeviceIndex", QJsonValue(reverse_api_device_index));
314  }
316  obj->insert("reverseAPIChannelIndex", QJsonValue(reverse_api_channel_index));
317  }
318 
319  return obj;
320 }
321 
322 qint32
324  return sample_format;
325 }
326 void
328  this->sample_format = sample_format;
329  this->m_sample_format_isSet = true;
330 }
331 
332 float
334  return input_sample_rate;
335 }
336 void
338  this->input_sample_rate = input_sample_rate;
339  this->m_input_sample_rate_isSet = true;
340 }
341 
342 qint64
344  return input_frequency_offset;
345 }
346 void
348  this->input_frequency_offset = input_frequency_offset;
349  this->m_input_frequency_offset_isSet = true;
350 }
351 
352 float
354  return rf_bandwidth;
355 }
356 void
358  this->rf_bandwidth = rf_bandwidth;
359  this->m_rf_bandwidth_isSet = true;
360 }
361 
362 float
364  return low_cutoff;
365 }
366 void
368  this->low_cutoff = low_cutoff;
369  this->m_low_cutoff_isSet = true;
370 }
371 
372 qint32
374  return fm_deviation;
375 }
376 void
378  this->fm_deviation = fm_deviation;
379  this->m_fm_deviation_isSet = true;
380 }
381 
382 float
384  return am_mod_factor;
385 }
386 void
388  this->am_mod_factor = am_mod_factor;
389  this->m_am_mod_factor_isSet = true;
390 }
391 
392 qint32
394  return channel_mute;
395 }
396 void
398  this->channel_mute = channel_mute;
399  this->m_channel_mute_isSet = true;
400 }
401 
402 float
404  return gain_in;
405 }
406 void
408  this->gain_in = gain_in;
409  this->m_gain_in_isSet = true;
410 }
411 
412 float
414  return gain_out;
415 }
416 void
418  this->gain_out = gain_out;
419  this->m_gain_out_isSet = true;
420 }
421 
422 float
424  return squelch;
425 }
426 void
428  this->squelch = squelch;
429  this->m_squelch_isSet = true;
430 }
431 
432 float
434  return squelch_gate;
435 }
436 void
438  this->squelch_gate = squelch_gate;
439  this->m_squelch_gate_isSet = true;
440 }
441 
442 qint32
444  return squelch_enabled;
445 }
446 void
448  this->squelch_enabled = squelch_enabled;
449  this->m_squelch_enabled_isSet = true;
450 }
451 
452 qint32
454  return auto_rw_balance;
455 }
456 void
458  this->auto_rw_balance = auto_rw_balance;
459  this->m_auto_rw_balance_isSet = true;
460 }
461 
462 qint32
464  return stereo_input;
465 }
466 void
468  this->stereo_input = stereo_input;
469  this->m_stereo_input_isSet = true;
470 }
471 
472 qint32
474  return rgb_color;
475 }
476 void
478  this->rgb_color = rgb_color;
479  this->m_rgb_color_isSet = true;
480 }
481 
482 QString*
484  return udp_address;
485 }
486 void
488  this->udp_address = udp_address;
489  this->m_udp_address_isSet = true;
490 }
491 
492 qint32
494  return udp_port;
495 }
496 void
498  this->udp_port = udp_port;
499  this->m_udp_port_isSet = true;
500 }
501 
502 QString*
504  return title;
505 }
506 void
508  this->title = title;
509  this->m_title_isSet = true;
510 }
511 
512 qint32
514  return use_reverse_api;
515 }
516 void
518  this->use_reverse_api = use_reverse_api;
519  this->m_use_reverse_api_isSet = true;
520 }
521 
522 QString*
524  return reverse_api_address;
525 }
526 void
528  this->reverse_api_address = reverse_api_address;
529  this->m_reverse_api_address_isSet = true;
530 }
531 
532 qint32
534  return reverse_api_port;
535 }
536 void
538  this->reverse_api_port = reverse_api_port;
539  this->m_reverse_api_port_isSet = true;
540 }
541 
542 qint32
545 }
546 void
548  this->reverse_api_device_index = reverse_api_device_index;
550 }
551 
552 qint32
555 }
556 void
558  this->reverse_api_channel_index = reverse_api_channel_index;
560 }
561 
562 
563 bool
565  bool isObjectUpdated = false;
566  do{
567  if(m_sample_format_isSet){ isObjectUpdated = true; break;}
568  if(m_input_sample_rate_isSet){ isObjectUpdated = true; break;}
569  if(m_input_frequency_offset_isSet){ isObjectUpdated = true; break;}
570  if(m_rf_bandwidth_isSet){ isObjectUpdated = true; break;}
571  if(m_low_cutoff_isSet){ isObjectUpdated = true; break;}
572  if(m_fm_deviation_isSet){ isObjectUpdated = true; break;}
573  if(m_am_mod_factor_isSet){ isObjectUpdated = true; break;}
574  if(m_channel_mute_isSet){ isObjectUpdated = true; break;}
575  if(m_gain_in_isSet){ isObjectUpdated = true; break;}
576  if(m_gain_out_isSet){ isObjectUpdated = true; break;}
577  if(m_squelch_isSet){ isObjectUpdated = true; break;}
578  if(m_squelch_gate_isSet){ isObjectUpdated = true; break;}
579  if(m_squelch_enabled_isSet){ isObjectUpdated = true; break;}
580  if(m_auto_rw_balance_isSet){ isObjectUpdated = true; break;}
581  if(m_stereo_input_isSet){ isObjectUpdated = true; break;}
582  if(m_rgb_color_isSet){ isObjectUpdated = true; break;}
583  if(udp_address != nullptr && *udp_address != QString("")){ isObjectUpdated = true; break;}
584  if(m_udp_port_isSet){ isObjectUpdated = true; break;}
585  if(title != nullptr && *title != QString("")){ isObjectUpdated = true; break;}
586  if(m_use_reverse_api_isSet){ isObjectUpdated = true; break;}
587  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){ isObjectUpdated = true; break;}
588  if(m_reverse_api_port_isSet){ isObjectUpdated = true; break;}
589  if(m_reverse_api_device_index_isSet){ isObjectUpdated = true; break;}
590  if(m_reverse_api_channel_index_isSet){ isObjectUpdated = true; break;}
591  }while(false);
592  return isObjectUpdated;
593 }
594 }
595 
virtual SWGUDPSourceSettings * fromJson(QString &jsonString) override
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
void setFmDeviation(qint32 fm_deviation)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setReverseApiAddress(QString *reverse_api_address)
void setSampleFormat(qint32 sample_format)
void setReverseApiPort(qint32 reverse_api_port)
void setUdpAddress(QString *udp_address)
void setStereoInput(qint32 stereo_input)
virtual void fromJsonObject(QJsonObject &json) override
void setAmModFactor(float am_mod_factor)
void setInputSampleRate(float input_sample_rate)
void setUseReverseApi(qint32 use_reverse_api)
void setSquelchEnabled(qint32 squelch_enabled)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void setInputFrequencyOffset(qint64 input_frequency_offset)
void setAutoRwBalance(qint32 auto_rw_balance)
virtual QJsonObject * asJsonObject() override
void setChannelMute(qint32 channel_mute)