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.
SWGUDPSinkReport.cpp
Go to the documentation of this file.
1 
14 #include "SWGUDPSinkReport.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  output_power_db = 0.0f;
33  channel_power_db = 0.0f;
35  squelch = 0;
36  m_squelch_isSet = false;
39 }
40 
42  this->cleanup();
43 }
44 
45 void
47  output_power_db = 0.0f;
49  channel_power_db = 0.0f;
51  squelch = 0;
52  m_squelch_isSet = false;
55 }
56 
57 void
59 
60 
61 
62 
63 }
64 
67  QByteArray array (json.toStdString().c_str());
68  QJsonDocument doc = QJsonDocument::fromJson(array);
69  QJsonObject jsonObject = doc.object();
70  this->fromJsonObject(jsonObject);
71  return this;
72 }
73 
74 void
75 SWGUDPSinkReport::fromJsonObject(QJsonObject &pJson) {
76  ::SWGSDRangel::setValue(&output_power_db, pJson["outputPowerDB"], "float", "");
77 
78  ::SWGSDRangel::setValue(&channel_power_db, pJson["channelPowerDB"], "float", "");
79 
80  ::SWGSDRangel::setValue(&squelch, pJson["squelch"], "qint32", "");
81 
82  ::SWGSDRangel::setValue(&input_sample_rate, pJson["inputSampleRate"], "qint32", "");
83 
84 }
85 
86 QString
88 {
89  QJsonObject* obj = this->asJsonObject();
90 
91  QJsonDocument doc(*obj);
92  QByteArray bytes = doc.toJson();
93  delete obj;
94  return QString(bytes);
95 }
96 
97 QJsonObject*
99  QJsonObject* obj = new QJsonObject();
101  obj->insert("outputPowerDB", QJsonValue(output_power_db));
102  }
104  obj->insert("channelPowerDB", QJsonValue(channel_power_db));
105  }
106  if(m_squelch_isSet){
107  obj->insert("squelch", QJsonValue(squelch));
108  }
110  obj->insert("inputSampleRate", QJsonValue(input_sample_rate));
111  }
112 
113  return obj;
114 }
115 
116 float
118  return output_power_db;
119 }
120 void
122  this->output_power_db = output_power_db;
123  this->m_output_power_db_isSet = true;
124 }
125 
126 float
128  return channel_power_db;
129 }
130 void
132  this->channel_power_db = channel_power_db;
133  this->m_channel_power_db_isSet = true;
134 }
135 
136 qint32
138  return squelch;
139 }
140 void
142  this->squelch = squelch;
143  this->m_squelch_isSet = true;
144 }
145 
146 qint32
148  return input_sample_rate;
149 }
150 void
152  this->input_sample_rate = input_sample_rate;
153  this->m_input_sample_rate_isSet = true;
154 }
155 
156 
157 bool
159  bool isObjectUpdated = false;
160  do{
161  if(m_output_power_db_isSet){ isObjectUpdated = true; break;}
162  if(m_channel_power_db_isSet){ isObjectUpdated = true; break;}
163  if(m_squelch_isSet){ isObjectUpdated = true; break;}
164  if(m_input_sample_rate_isSet){ isObjectUpdated = true; break;}
165  }while(false);
166  return isObjectUpdated;
167 }
168 }
169 
virtual QString asJson() override
virtual QJsonObject * asJsonObject() override
virtual void fromJsonObject(QJsonObject &json) override
virtual bool isSet() override
virtual SWGUDPSinkReport * fromJson(QString &jsonString) override
void setInputSampleRate(qint32 input_sample_rate)
void setOutputPowerDb(float output_power_db)
void setChannelPowerDb(float channel_power_db)
void setValue(void *value, QJsonValue obj, QString type, QString complexType)
Definition: SWGHelpers.cpp:25