11#include "LibCyberRadio/Driver/NDR551/NbddcComponent.h"
12#include "LibCyberRadio/Driver/RadioHandler.h"
13#include <boost/format.hpp>
14#include <boost/lexical_cast.hpp>
38 (boost::format(
"NDR551-NBDDC%02d") % \
61 _rateSet[13] = 1.28e6;
88 ::LibCyberRadio::Driver::NbddcComponent::operator=(other);
102 _config[
"rateIndex"] = _rateIndex;
103 _config[
"udpDestination"] = _udpDestination;
104 _config[
"vitaEnable"] = _vitaEnable;
105 _config[
"streamId"] = _streamId;
106 _config[
"frequency"] = _frequency;
107 _config[
"source"] = _source;
108 _config[
"mode"] = _mode;
109 _config[
"audio" ] =
false;
111 _config[
"cic0" ] = 0;
112 _config[
"cic1" ] = 0;
116 _config[
"datc" ] = 0;
120 _config[
"ddtc" ] = 0;
121 _config[
"demod" ] =
"none";
122 _config[
"dest" ] = 0;
125 _config[
"dmdgain"] = 0;
134 this->
debug(
"[NbddcComponent::updateConfigurationDict] Called\n");
136 if ( _config.hasKey(
"rateIndex") )
138 if ( _config.hasKey(
"udpDestination") )
140 if ( _config.hasKey(
"vitaEnable") )
142 if ( _config.hasKey(
"streamId") )
144 if ( _config.hasKey(
"frequency") )
146 if ( _config.hasKey(
"source") )
148 if ( _config.hasKey(
"mode") ){
151 if ( _selectableDataPort && _config.hasKey(
"dataPort") )
155 this->
debug(
"[NbddcComponent::updateConfigurationDict] Returning\n");
160 this->
debug(
"[NbddcComponent::queryConfiguration] Called\n");
163 command[
"cmd"] =
"qnbddc";
164 command[
"msg"] = _parent->getMessageId();
165 command[
"params"] = Json::objectValue;
166 command[
"params"][
"id"] = _index;
167 Json::FastWriter fastWriter;
168 std::string output = fastWriter.write(command);
171 Json::Value returnVal;
172 std::string t = rsp.at(0);
173 bool parsingSuccessful = reader.parse( t.c_str(), returnVal[
"result"] );
174 _enabled = boost::lexical_cast<bool>(returnVal[
"enable"].asBool());
175 _frequency = boost::lexical_cast<double>(returnVal[
"freq"].asDouble());
176 _source = boost::lexical_cast<int>(returnVal[
"source"].asInt());
177 _udpDestination = boost::lexical_cast<int>(returnVal[
"dest"].asInt());
178 _rateIndex = boost::lexical_cast<int>(returnVal[
"filter"].asInt());
179 _streamId = boost::lexical_cast<int>(returnVal[
"vita"].asUInt());
180 _mode = boost::lexical_cast<std::string>(returnVal[
"mode"].asString());
190 unsigned int& streamId,
195 if ( (_parent != NULL) && (_parent->isConnected()) )
197 Json::Value root(Json::objectValue);
198 root[
"msg"] = _parent->getMessageId();
199 root[
"cmd"] =
"qnbddc";
200 Json::Value params(Json::objectValue);
201 params[
"id"] = index;
202 root[
"params"] = params;
203 Json::FastWriter fastWriter;
204 std::string output = fastWriter.write(root);
207 Json::Value returnVal;
208 std::string t = recv.at(0);
209 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
210 Json::Value result = returnVal[
"result"];
211 rateIndex = boost::lexical_cast<int>(result[
"filter"].asInt());
212 udpDestination = boost::lexical_cast<int>(result[
"dest"].asInt());
213 enabled = boost::lexical_cast<bool>(result[
"enable"].asBool());
214 vitaEnable = boost::lexical_cast<int>(result[
"enable"].asBool());
215 streamId = boost::lexical_cast<unsigned int>(result[
"vita"].asUInt());
225 if ( (_parent != NULL) && (_parent->isConnected()) )
227 Json::Value root(Json::objectValue);
228 root[
"msg"] = m551Parent->getMessageId();
229 root[
"cmd"] =
"nbddc";
230 Json::Value params(Json::objectValue);
231 params[
"id"] = index;
232 params[
"rfch"] = std::to_string(source);
233 root[
"params"] = params;
234 Json::FastWriter fastWriter;
235 std::string output = fastWriter.write(root);
238 Json::Value returnVal;
239 std::string t = recv.at(0);
240 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
241 ret = returnVal[
"success"].asBool();
251 if ( (_parent != NULL) && (_parent->isConnected()) )
253 Json::Value root(Json::objectValue);
254 root[
"msg"] = m551Parent->getMessageId();
255 root[
"cmd"] =
"nbddc";
256 Json::Value params(Json::objectValue);
257 params[
"id"] = index;
258 params[
"offset"] = freq;
259 root[
"params"] = params;
260 Json::FastWriter fastWriter;
261 std::string output = fastWriter.write(root);
264 Json::Value returnVal;
265 std::string t = recv.at(0);
266 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
267 ret = returnVal[
"success"].asBool();
279 unsigned int& streamId,
284 if ( (_parent != NULL) && (_parent->isConnected()) )
286 Json::Value root(Json::objectValue);
287 root[
"msg"] = _parent->getMessageId();
288 root[
"cmd"] =
"nbddc";
289 Json::Value params(Json::objectValue);
290 params[
"id"] = index;
291 params[
"filter"] = rateIndex;
292 params[
"dest"] = udpDestination;
293 params[
"enable"] = boost::lexical_cast<bool>(vitaEnable);
294 params[
"vita"] = streamId;
295 params[
"rfch"] = std::to_string(source);
296 root[
"params"] = params;
297 Json::FastWriter fastWriter;
298 std::string output = fastWriter.write(root);
301 Json::Value returnVal;
302 std::string t = recv.at(0);
303 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
304 ret = returnVal[
"success"].asBool();
virtual int debug(const char *format,...)
Outputs debug information.
virtual bool setConfigurationValue(const std::string &key, const std::string &value)
Sets a named configuration value to a string.
virtual bool setConfigurationValueToUInt(const std::string &key, const unsigned int value)
Sets a named configuration value to an unsigned integer value.
virtual bool setConfigurationValueToInt(const std::string &key, const int value)
Sets a named configuration value to an integer value.
virtual bool setConfigurationValueToDbl(const std::string &key, const double value)
Sets a named configuration value to a double value.
bool executeFreqCommand(int index, double &freq) override
Executes the NBDDC frequency set command.
bool executeNbddcCommand(int index, int &rateIndex, int &udpDestination, bool &enabled, int &vitaEnable, unsigned int &streamId, double &frequency, int &source) override
Executes the NBDDC configuration set command.
NbddcComponent(int index=1, ::LibCyberRadio::Driver::RadioHandler *parent=NULL, bool debug=false, int dataPort=1, int rateIndex=0, int udpDestination=0, int vitaEnable=0, int streamId=0, double frequency=0.0, int source=1)
Constructs a NbddcComponent object.
void queryConfiguration() override
Tells the component to query its hardware configuration in order to create its configuration dictiona...
void initConfigurationDict() override
Setup Config Dict.
bool executeSourceCommand(int index, int &source) override
Executes the NBDDC source set command.
virtual ~NbddcComponent()
Destroys a NbddcComponent object.
bool executeNbddcQuery(int index, int &rateIndex, int &udpDestination, bool &enabled, int &vitaEnable, unsigned int &streamId, double &frequency, int &source) override
Executes the NBDDC configuration query command.
virtual NbddcComponent & operator=(const NbddcComponent &other)
Assignment operator for NbddcComponent objects.
void updateConfigurationDict() override
Updates the configuration dictionary from component settings.
virtual void updateConfigurationDict()
Updates the configuration dictionary from component settings.
virtual void initConfigurationDict()
Initializes the configuration dictionary, defining the allowed keys.
Generic radio handler class.
Provides programming elements for driving NDR551 radios.
Provides programming elements for driving CRS NDR-class radios.
Defines functionality for LibCyberRadio applications.
BASIC_LIST_CONTAINER< std::string > BasicStringList
Type representing a list of strings.