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.
SWGPlutoSdrOutputReport.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  dac_rate = 0;
32  m_dac_rate_isSet = false;
33  rssi = nullptr;
34  m_rssi_isSet = false;
35  temperature = 0.0f;
36  m_temperature_isSet = false;
37 }
38 
40  this->cleanup();
41 }
42 
43 void
45  dac_rate = 0;
46  m_dac_rate_isSet = false;
47  rssi = new QString("");
48  m_rssi_isSet = false;
49  temperature = 0.0f;
50  m_temperature_isSet = false;
51 }
52 
53 void
55 
56  if(rssi != nullptr) {
57  delete rssi;
58  }
59 
60 }
61 
64  QByteArray array (json.toStdString().c_str());
65  QJsonDocument doc = QJsonDocument::fromJson(array);
66  QJsonObject jsonObject = doc.object();
67  this->fromJsonObject(jsonObject);
68  return this;
69 }
70 
71 void
73  ::SWGSDRangel::setValue(&dac_rate, pJson["dacRate"], "qint32", "");
74 
75  ::SWGSDRangel::setValue(&rssi, pJson["rssi"], "QString", "QString");
76 
77  ::SWGSDRangel::setValue(&temperature, pJson["temperature"], "float", "");
78 
79 }
80 
81 QString
83 {
84  QJsonObject* obj = this->asJsonObject();
85 
86  QJsonDocument doc(*obj);
87  QByteArray bytes = doc.toJson();
88  delete obj;
89  return QString(bytes);
90 }
91 
92 QJsonObject*
94  QJsonObject* obj = new QJsonObject();
95  if(m_dac_rate_isSet){
96  obj->insert("dacRate", QJsonValue(dac_rate));
97  }
98  if(rssi != nullptr && *rssi != QString("")){
99  toJsonValue(QString("rssi"), rssi, obj, QString("QString"));
100  }
102  obj->insert("temperature", QJsonValue(temperature));
103  }
104 
105  return obj;
106 }
107 
108 qint32
110  return dac_rate;
111 }
112 void
114  this->dac_rate = dac_rate;
115  this->m_dac_rate_isSet = true;
116 }
117 
118 QString*
120  return rssi;
121 }
122 void
124  this->rssi = rssi;
125  this->m_rssi_isSet = true;
126 }
127 
128 float
130  return temperature;
131 }
132 void
134  this->temperature = temperature;
135  this->m_temperature_isSet = true;
136 }
137 
138 
139 bool
141  bool isObjectUpdated = false;
142  do{
143  if(m_dac_rate_isSet){ isObjectUpdated = true; break;}
144  if(rssi != nullptr && *rssi != QString("")){ isObjectUpdated = true; break;}
145  if(m_temperature_isSet){ isObjectUpdated = true; break;}
146  }while(false);
147  return isObjectUpdated;
148 }
149 }
150 
void toJsonValue(QString name, void *value, QJsonObject *output, QString type)
Definition: SWGHelpers.cpp:383
virtual QJsonObject * asJsonObject() override
virtual SWGPlutoSdrOutputReport * fromJson(QString &jsonString) override
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25
virtual void fromJsonObject(QJsonObject &json) override