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.
SWGRemoteOutputSettings.cpp
Go to the documentation of this file.
1 
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  sample_rate = 0;
34  m_sample_rate_isSet = false;
35  tx_delay = 0.0f;
36  m_tx_delay_isSet = false;
37  nb_fec_blocks = 0;
38  m_nb_fec_blocks_isSet = false;
39  api_address = nullptr;
40  m_api_address_isSet = false;
41  api_port = 0;
42  m_api_port_isSet = false;
43  data_address = nullptr;
44  m_data_address_isSet = false;
45  data_port = 0;
46  m_data_port_isSet = false;
47  device_index = 0;
48  m_device_index_isSet = false;
49  channel_index = 0;
50  m_channel_index_isSet = false;
51  use_reverse_api = 0;
53  reverse_api_address = nullptr;
55  reverse_api_port = 0;
59 }
60 
62  this->cleanup();
63 }
64 
65 void
67  center_frequency = 0;
69  sample_rate = 0;
70  m_sample_rate_isSet = false;
71  tx_delay = 0.0f;
72  m_tx_delay_isSet = false;
73  nb_fec_blocks = 0;
74  m_nb_fec_blocks_isSet = false;
75  api_address = new QString("");
76  m_api_address_isSet = false;
77  api_port = 0;
78  m_api_port_isSet = false;
79  data_address = new QString("");
80  m_data_address_isSet = false;
81  data_port = 0;
82  m_data_port_isSet = false;
83  device_index = 0;
84  m_device_index_isSet = false;
85  channel_index = 0;
86  m_channel_index_isSet = false;
87  use_reverse_api = 0;
89  reverse_api_address = new QString("");
91  reverse_api_port = 0;
95 }
96 
97 void
99 
100 
101 
102 
103  if(api_address != nullptr) {
104  delete api_address;
105  }
106 
107  if(data_address != nullptr) {
108  delete data_address;
109  }
110 
111 
112 
113 
114  if(reverse_api_address != nullptr) {
115  delete reverse_api_address;
116  }
117 
118 
119 }
120 
123  QByteArray array (json.toStdString().c_str());
124  QJsonDocument doc = QJsonDocument::fromJson(array);
125  QJsonObject jsonObject = doc.object();
126  this->fromJsonObject(jsonObject);
127  return this;
128 }
129 
130 void
132  ::SWGSDRangel::setValue(&center_frequency, pJson["centerFrequency"], "qint32", "");
133 
134  ::SWGSDRangel::setValue(&sample_rate, pJson["sampleRate"], "qint32", "");
135 
136  ::SWGSDRangel::setValue(&tx_delay, pJson["txDelay"], "float", "");
137 
138  ::SWGSDRangel::setValue(&nb_fec_blocks, pJson["nbFECBlocks"], "qint32", "");
139 
140  ::SWGSDRangel::setValue(&api_address, pJson["apiAddress"], "QString", "QString");
141 
142  ::SWGSDRangel::setValue(&api_port, pJson["apiPort"], "qint32", "");
143 
144  ::SWGSDRangel::setValue(&data_address, pJson["dataAddress"], "QString", "QString");
145 
146  ::SWGSDRangel::setValue(&data_port, pJson["dataPort"], "qint32", "");
147 
148  ::SWGSDRangel::setValue(&device_index, pJson["deviceIndex"], "qint32", "");
149 
150  ::SWGSDRangel::setValue(&channel_index, pJson["channelIndex"], "qint32", "");
151 
152  ::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", "");
153 
154  ::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString");
155 
156  ::SWGSDRangel::setValue(&reverse_api_port, pJson["reverseAPIPort"], "qint32", "");
157 
158  ::SWGSDRangel::setValue(&reverse_api_device_index, pJson["reverseAPIDeviceIndex"], "qint32", "");
159 
160 }
161 
162 QString
164 {
165  QJsonObject* obj = this->asJsonObject();
166 
167  QJsonDocument doc(*obj);
168  QByteArray bytes = doc.toJson();
169  delete obj;
170  return QString(bytes);
171 }
172 
173 QJsonObject*
175  QJsonObject* obj = new QJsonObject();
177  obj->insert("centerFrequency", QJsonValue(center_frequency));
178  }
180  obj->insert("sampleRate", QJsonValue(sample_rate));
181  }
182  if(m_tx_delay_isSet){
183  obj->insert("txDelay", QJsonValue(tx_delay));
184  }
186  obj->insert("nbFECBlocks", QJsonValue(nb_fec_blocks));
187  }
188  if(api_address != nullptr && *api_address != QString("")){
189  toJsonValue(QString("apiAddress"), api_address, obj, QString("QString"));
190  }
191  if(m_api_port_isSet){
192  obj->insert("apiPort", QJsonValue(api_port));
193  }
194  if(data_address != nullptr && *data_address != QString("")){
195  toJsonValue(QString("dataAddress"), data_address, obj, QString("QString"));
196  }
197  if(m_data_port_isSet){
198  obj->insert("dataPort", QJsonValue(data_port));
199  }
201  obj->insert("deviceIndex", QJsonValue(device_index));
202  }
204  obj->insert("channelIndex", QJsonValue(channel_index));
205  }
207  obj->insert("useReverseAPI", QJsonValue(use_reverse_api));
208  }
209  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){
210  toJsonValue(QString("reverseAPIAddress"), reverse_api_address, obj, QString("QString"));
211  }
213  obj->insert("reverseAPIPort", QJsonValue(reverse_api_port));
214  }
216  obj->insert("reverseAPIDeviceIndex", QJsonValue(reverse_api_device_index));
217  }
218 
219  return obj;
220 }
221 
222 qint32
224  return center_frequency;
225 }
226 void
228  this->center_frequency = center_frequency;
229  this->m_center_frequency_isSet = true;
230 }
231 
232 qint32
234  return sample_rate;
235 }
236 void
238  this->sample_rate = sample_rate;
239  this->m_sample_rate_isSet = true;
240 }
241 
242 float
244  return tx_delay;
245 }
246 void
248  this->tx_delay = tx_delay;
249  this->m_tx_delay_isSet = true;
250 }
251 
252 qint32
254  return nb_fec_blocks;
255 }
256 void
258  this->nb_fec_blocks = nb_fec_blocks;
259  this->m_nb_fec_blocks_isSet = true;
260 }
261 
262 QString*
264  return api_address;
265 }
266 void
268  this->api_address = api_address;
269  this->m_api_address_isSet = true;
270 }
271 
272 qint32
274  return api_port;
275 }
276 void
278  this->api_port = api_port;
279  this->m_api_port_isSet = true;
280 }
281 
282 QString*
284  return data_address;
285 }
286 void
288  this->data_address = data_address;
289  this->m_data_address_isSet = true;
290 }
291 
292 qint32
294  return data_port;
295 }
296 void
298  this->data_port = data_port;
299  this->m_data_port_isSet = true;
300 }
301 
302 qint32
304  return device_index;
305 }
306 void
308  this->device_index = device_index;
309  this->m_device_index_isSet = true;
310 }
311 
312 qint32
314  return channel_index;
315 }
316 void
318  this->channel_index = channel_index;
319  this->m_channel_index_isSet = true;
320 }
321 
322 qint32
324  return use_reverse_api;
325 }
326 void
328  this->use_reverse_api = use_reverse_api;
329  this->m_use_reverse_api_isSet = true;
330 }
331 
332 QString*
334  return reverse_api_address;
335 }
336 void
338  this->reverse_api_address = reverse_api_address;
339  this->m_reverse_api_address_isSet = true;
340 }
341 
342 qint32
344  return reverse_api_port;
345 }
346 void
348  this->reverse_api_port = reverse_api_port;
349  this->m_reverse_api_port_isSet = true;
350 }
351 
352 qint32
355 }
356 void
358  this->reverse_api_device_index = reverse_api_device_index;
360 }
361 
362 
363 bool
365  bool isObjectUpdated = false;
366  do{
367  if(m_center_frequency_isSet){ isObjectUpdated = true; break;}
368  if(m_sample_rate_isSet){ isObjectUpdated = true; break;}
369  if(m_tx_delay_isSet){ isObjectUpdated = true; break;}
370  if(m_nb_fec_blocks_isSet){ isObjectUpdated = true; break;}
371  if(api_address != nullptr && *api_address != QString("")){ isObjectUpdated = true; break;}
372  if(m_api_port_isSet){ isObjectUpdated = true; break;}
373  if(data_address != nullptr && *data_address != QString("")){ isObjectUpdated = true; break;}
374  if(m_data_port_isSet){ isObjectUpdated = true; break;}
375  if(m_device_index_isSet){ isObjectUpdated = true; break;}
376  if(m_channel_index_isSet){ isObjectUpdated = true; break;}
377  if(m_use_reverse_api_isSet){ isObjectUpdated = true; break;}
378  if(reverse_api_address != nullptr && *reverse_api_address != QString("")){ isObjectUpdated = true; break;}
379  if(m_reverse_api_port_isSet){ isObjectUpdated = true; break;}
380  if(m_reverse_api_device_index_isSet){ isObjectUpdated = true; break;}
381  }while(false);
382  return isObjectUpdated;
383 }
384 }
385 
void setReverseApiPort(qint32 reverse_api_port)
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
void setCenterFrequency(qint32 center_frequency)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setReverseApiAddress(QString *reverse_api_address)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
virtual void fromJsonObject(QJsonObject &json) override
virtual QJsonObject * asJsonObject() override
void setUseReverseApi(qint32 use_reverse_api)
virtual SWGRemoteOutputSettings * fromJson(QString &jsonString) override