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.
SWGAMModSettings.cpp
Go to the documentation of this file.
1 
14 #include "SWGAMModSettings.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 
33  rf_bandwidth = 0.0f;
34  m_rf_bandwidth_isSet = false;
35  mod_factor = 0.0f;
36  m_mod_factor_isSet = false;
37  tone_frequency = 0.0f;
38  m_tone_frequency_isSet = false;
39  volume_factor = 0.0f;
40  m_volume_factor_isSet = false;
41  channel_mute = 0;
42  m_channel_mute_isSet = false;
43  play_loop = 0;
44  m_play_loop_isSet = false;
45  rgb_color = 0;
46  m_rgb_color_isSet = false;
47  title = nullptr;
48  m_title_isSet = false;
49  audio_device_name = nullptr;
51  mod_af_input = 0;
52  m_mod_af_input_isSet = false;
53  use_reverse_api = 0;
55  reverse_api_address = nullptr;
57  reverse_api_port = 0;
63  cw_keyer = nullptr;
64  m_cw_keyer_isSet = false;
65 }
66 
68  this->cleanup();
69 }
70 
71 void
75  rf_bandwidth = 0.0f;
76  m_rf_bandwidth_isSet = false;
77  mod_factor = 0.0f;
78  m_mod_factor_isSet = false;
79  tone_frequency = 0.0f;
80  m_tone_frequency_isSet = false;
81  volume_factor = 0.0f;
82  m_volume_factor_isSet = false;
83  channel_mute = 0;
84  m_channel_mute_isSet = false;
85  play_loop = 0;
86  m_play_loop_isSet = false;
87  rgb_color = 0;
88  m_rgb_color_isSet = false;
89  title = new QString("");
90  m_title_isSet = false;
91  audio_device_name = new QString("");
93  mod_af_input = 0;
94  m_mod_af_input_isSet = false;
95  use_reverse_api = 0;
97  reverse_api_address = new QString("");
99  reverse_api_port = 0;
100  m_reverse_api_port_isSet = false;
106  m_cw_keyer_isSet = false;
107 }
108 
109 void
111 
112 
113 
114 
115 
116 
117 
118 
119  if(title != nullptr) {
120  delete title;
121  }
122  if(audio_device_name != nullptr) {
123  delete audio_device_name;
124  }
125 
126 
127  if(reverse_api_address != nullptr) {
128  delete reverse_api_address;
129  }
130 
131 
132 
133  if(cw_keyer != nullptr) {
134  delete cw_keyer;
135  }
136 }
137 
140  QByteArray array (json.toStdString().c_str());
141  QJsonDocument doc = QJsonDocument::fromJson(array);
142  QJsonObject jsonObject = doc.object();
143  this->fromJsonObject(jsonObject);
144  return this;
145 }
146 
147 void
148 SWGAMModSettings::fromJsonObject(QJsonObject &pJson) {
149  ::SWGSDRangel::setValue(&input_frequency_offset, pJson["inputFrequencyOffset"], "qint64", "");
150 
151  ::SWGSDRangel::setValue(&rf_bandwidth, pJson["rfBandwidth"], "float", "");
152 
153  ::SWGSDRangel::setValue(&mod_factor, pJson["modFactor"], "float", "");
154 
155  ::SWGSDRangel::setValue(&tone_frequency, pJson["toneFrequency"], "float", "");
156 
157  ::SWGSDRangel::setValue(&volume_factor, pJson["volumeFactor"], "float", "");
158 
159  ::SWGSDRangel::setValue(&channel_mute, pJson["channelMute"], "qint32", "");
160 
161  ::SWGSDRangel::setValue(&play_loop, pJson["playLoop"], "qint32", "");
162 
163  ::SWGSDRangel::setValue(&rgb_color, pJson["rgbColor"], "qint32", "");
164 
165  ::SWGSDRangel::setValue(&title, pJson["title"], "QString", "QString");
166 
167  ::SWGSDRangel::setValue(&audio_device_name, pJson["audioDeviceName"], "QString", "QString");
168 
169  ::SWGSDRangel::setValue(&mod_af_input, pJson["modAFInput"], "qint32", "");
170 
171  ::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", "");
172 
173  ::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString");
174 
175  ::SWGSDRangel::setValue(&reverse_api_port, pJson["reverseAPIPort"], "qint32", "");
176 
177  ::SWGSDRangel::setValue(&reverse_api_device_index, pJson["reverseAPIDeviceIndex"], "qint32", "");
178 
179  ::SWGSDRangel::setValue(&reverse_api_channel_index, pJson["reverseAPIChannelIndex"], "qint32", "");
180 
181  ::SWGSDRangel::setValue(&cw_keyer, pJson["cwKeyer"], "SWGCWKeyerSettings", "SWGCWKeyerSettings");
182 
183 }
184 
185 QString
187 {
188  QJsonObject* obj = this->asJsonObject();
189 
190  QJsonDocument doc(*obj);
191  QByteArray bytes = doc.toJson();
192  delete obj;
193  return QString(bytes);
194 }
195 
196 QJsonObject*
198  QJsonObject* obj = new QJsonObject();
200  obj->insert("inputFrequencyOffset", QJsonValue(input_frequency_offset));
201  }
203  obj->insert("rfBandwidth", QJsonValue(rf_bandwidth));
204  }
205  if(m_mod_factor_isSet){
206  obj->insert("modFactor", QJsonValue(mod_factor));
207  }
209  obj->insert("toneFrequency", QJsonValue(tone_frequency));
210  }
212  obj->insert("volumeFactor", QJsonValue(volume_factor));
213  }
215  obj->insert("channelMute", QJsonValue(channel_mute));
216  }
217  if(m_play_loop_isSet){
218  obj->insert("playLoop", QJsonValue(play_loop));
219  }
220  if(m_rgb_color_isSet){
221  obj->insert("rgbColor", QJsonValue(rgb_color));
222  }
223  if(title != nullptr && *title != QString("")){
224  toJsonValue(QString("title"), title, obj, QString("QString"));
225  }
226  if(audio_device_name != nullptr && *audio_device_name != QString("")){
227  toJsonValue(QString("audioDeviceName"), audio_device_name, obj, QString("QString"));
228  }
230  obj->insert("modAFInput", QJsonValue(mod_af_input));
231  }
233  obj->insert("useReverseAPI", QJsonValue(use_reverse_api));
234  }
235  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){
236  toJsonValue(QString("reverseAPIAddress"), reverse_api_address, obj, QString("QString"));
237  }
239  obj->insert("reverseAPIPort", QJsonValue(reverse_api_port));
240  }
242  obj->insert("reverseAPIDeviceIndex", QJsonValue(reverse_api_device_index));
243  }
245  obj->insert("reverseAPIChannelIndex", QJsonValue(reverse_api_channel_index));
246  }
247  if((cw_keyer != nullptr) && (cw_keyer->isSet())){
248  toJsonValue(QString("cwKeyer"), cw_keyer, obj, QString("SWGCWKeyerSettings"));
249  }
250 
251  return obj;
252 }
253 
254 qint64
256  return input_frequency_offset;
257 }
258 void
260  this->input_frequency_offset = input_frequency_offset;
261  this->m_input_frequency_offset_isSet = true;
262 }
263 
264 float
266  return rf_bandwidth;
267 }
268 void
270  this->rf_bandwidth = rf_bandwidth;
271  this->m_rf_bandwidth_isSet = true;
272 }
273 
274 float
276  return mod_factor;
277 }
278 void
280  this->mod_factor = mod_factor;
281  this->m_mod_factor_isSet = true;
282 }
283 
284 float
286  return tone_frequency;
287 }
288 void
290  this->tone_frequency = tone_frequency;
291  this->m_tone_frequency_isSet = true;
292 }
293 
294 float
296  return volume_factor;
297 }
298 void
300  this->volume_factor = volume_factor;
301  this->m_volume_factor_isSet = true;
302 }
303 
304 qint32
306  return channel_mute;
307 }
308 void
310  this->channel_mute = channel_mute;
311  this->m_channel_mute_isSet = true;
312 }
313 
314 qint32
316  return play_loop;
317 }
318 void
320  this->play_loop = play_loop;
321  this->m_play_loop_isSet = true;
322 }
323 
324 qint32
326  return rgb_color;
327 }
328 void
330  this->rgb_color = rgb_color;
331  this->m_rgb_color_isSet = true;
332 }
333 
334 QString*
336  return title;
337 }
338 void
340  this->title = title;
341  this->m_title_isSet = true;
342 }
343 
344 QString*
346  return audio_device_name;
347 }
348 void
350  this->audio_device_name = audio_device_name;
351  this->m_audio_device_name_isSet = true;
352 }
353 
354 qint32
356  return mod_af_input;
357 }
358 void
360  this->mod_af_input = mod_af_input;
361  this->m_mod_af_input_isSet = true;
362 }
363 
364 qint32
366  return use_reverse_api;
367 }
368 void
370  this->use_reverse_api = use_reverse_api;
371  this->m_use_reverse_api_isSet = true;
372 }
373 
374 QString*
376  return reverse_api_address;
377 }
378 void
380  this->reverse_api_address = reverse_api_address;
381  this->m_reverse_api_address_isSet = true;
382 }
383 
384 qint32
386  return reverse_api_port;
387 }
388 void
390  this->reverse_api_port = reverse_api_port;
391  this->m_reverse_api_port_isSet = true;
392 }
393 
394 qint32
397 }
398 void
400  this->reverse_api_device_index = reverse_api_device_index;
402 }
403 
404 qint32
407 }
408 void
410  this->reverse_api_channel_index = reverse_api_channel_index;
412 }
413 
416  return cw_keyer;
417 }
418 void
420  this->cw_keyer = cw_keyer;
421  this->m_cw_keyer_isSet = true;
422 }
423 
424 
425 bool
427  bool isObjectUpdated = false;
428  do{
429  if(m_input_frequency_offset_isSet){ isObjectUpdated = true; break;}
430  if(m_rf_bandwidth_isSet){ isObjectUpdated = true; break;}
431  if(m_mod_factor_isSet){ isObjectUpdated = true; break;}
432  if(m_tone_frequency_isSet){ isObjectUpdated = true; break;}
433  if(m_volume_factor_isSet){ isObjectUpdated = true; break;}
434  if(m_channel_mute_isSet){ isObjectUpdated = true; break;}
435  if(m_play_loop_isSet){ isObjectUpdated = true; break;}
436  if(m_rgb_color_isSet){ isObjectUpdated = true; break;}
437  if(title != nullptr && *title != QString("")){ isObjectUpdated = true; break;}
438  if(audio_device_name != nullptr && *audio_device_name != QString("")){ isObjectUpdated = true; break;}
439  if(m_mod_af_input_isSet){ isObjectUpdated = true; break;}
440  if(m_use_reverse_api_isSet){ isObjectUpdated = true; break;}
441  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){ isObjectUpdated = true; break;}
442  if(m_reverse_api_port_isSet){ isObjectUpdated = true; break;}
443  if(m_reverse_api_device_index_isSet){ isObjectUpdated = true; break;}
444  if(m_reverse_api_channel_index_isSet){ isObjectUpdated = true; break;}
445  if(cw_keyer != nullptr && cw_keyer->isSet()){ isObjectUpdated = true; break;}
446  }while(false);
447  return isObjectUpdated;
448 }
449 }
450 
void setModFactor(float mod_factor)
void setAudioDeviceName(QString *audio_device_name)
void setToneFrequency(float tone_frequency)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setVolumeFactor(float volume_factor)
void setModAfInput(qint32 mod_af_input)
void setReverseApiAddress(QString *reverse_api_address)
virtual void fromJsonObject(QJsonObject &json) override
SWGCWKeyerSettings * getCwKeyer()
void setUseReverseApi(qint32 use_reverse_api)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setChannelMute(qint32 channel_mute)
virtual QString asJson() override
void setRgbColor(qint32 rgb_color)
virtual bool isSet() override
void setRfBandwidth(float rf_bandwidth)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
void setInputFrequencyOffset(qint64 input_frequency_offset)
void setCwKeyer(SWGCWKeyerSettings *cw_keyer)
void setPlayLoop(qint32 play_loop)
SWGCWKeyerSettings * cw_keyer
void setReverseApiPort(qint32 reverse_api_port)
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
virtual SWGAMModSettings * fromJson(QString &jsonString) override
virtual QJsonObject * asJsonObject() override