11#include "LibCyberRadio/Driver/NDR324/WbddcComponent.h"
12#include "LibCyberRadio/Driver/RadioHandler.h"
13#include <boost/format.hpp>
15#include <boost/lexical_cast.hpp>
37 (boost::format(
"NDR324-WBDDC%02d") % \
58 this->
debug(
"[NDR324::WbddcComponent] index - %d\n", index);
62 _rateSet[0] = 225.28e6;
63 _rateSet[1] = 168.96e6;
64 _rateSet[2] = 42.24e6;
65 _rateSet[3] = 21.12e6;
66 _rateSet[4] = 10.56e6;
82 ::LibCyberRadio::Driver::WbddcComponent::operator=(other);
96 _config[
"filter"] = 40;
98 _config[
"enable"] =
false;
100 _config[
"type"] =
"auto";
101 _config[
"decimation"] = _decimation;
103 _config[
"mode"] = _mode;
104 _config[
"dgv"] = _dgv;
105 _config[
"dul"] = _dul;
106 _config[
"dll"] = _dll;
107 _config[
"dtl"] = _dtl;
108 _config[
"dal"] = _dal;
109 _config[
"ddl"] = _ddl;
110 _config[
"dao"] = _dao;
111 _config[
"ddo"] = _ddo;
112 _config[
"datc"] = _datc;
113 _config[
"ddtc"] = _ddtc;
117 _config[
"offset"] = 0.0f;
119 if ( _selectableSource )
121 _config[
"rfch"] =
"0";
123 if ( _selectableDataPort )
133 this->
debug(
"[NDR324WbddcComponent::setConfiguration] Called\n");
137 command[
"cmd"] =
"wbddc";
138 command[
"msg"] = _parent->getMessageId();
139 command[
"params"] = Json::objectValue;
140 command[
"params"][
"id"] = _index;
142 for( ConfigurationDict::const_iterator it = cfg.begin();
143 it != cfg.end(); ++it)
145 if ( (it->first ==
"mode") ||
146 (it->first ==
"rfch") ||
147 (it->first ==
"type") )
149 command[
"params"][it->first.c_str()] = it->second.c_str();
151 else if ( (it->first ==
"enable") )
153 command[
"params"][it->first.c_str()] = it->second.asBool();
157 command[
"params"][it->first.c_str()] = it->second.asInt();
160 Json::FastWriter fastWriter;
161 std::string output = fastWriter.write(command);
162 std::cout << output << std::endl;
165 Json::Value returnVal;
166 std::string t = rsp.at(0);
167 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
168 ret = returnVal[
"success"].asBool();
174 this->
debug(
"[NDR324WbddcComponent::updateConfigurationDict] Called\n");
176 if ( _config.hasKey(
"filter") )
178 if ( _config.hasKey(
"dest") )
180 if ( _config.hasKey(
"enable") )
182 if ( _config.hasKey(
"vita") )
184 if ( _tunable && _config.hasKey(
"offset") )
188 if ( _selectableSource && _config.hasKey(
"rfch") )
192 if ( _selectableDataPort && _config.hasKey(
"link") )
196 if ( _config.hasKey(
"mode") )
200 if ( _config.hasKey(
"decimation") )
204 if ( _config.hasKey(
"dgv" ) )
208 if ( _config.hasKey(
"dul" ) )
212 if ( _config.hasKey(
"dll" ) )
216 if ( _config.hasKey(
"dtl" ) )
220 if ( _config.hasKey(
"dal" ) )
224 if ( _config.hasKey(
"ddl" ) )
228 if ( _config.hasKey(
"dao" ) )
232 if ( _config.hasKey(
"ddo" ) )
236 if ( _config.hasKey(
"datc") )
240 if ( _config.hasKey(
"ddtc") )
244 if ( _config.hasKey(
"ddt" ) )
248 if ( _config.hasKey(
"type") )
256 this->
debug(
"[WbddcComponent::queryConfiguration] Called\n");
259 command[
"cmd"] =
"qwbddc";
260 command[
"msg"] = _parent->getMessageId();
261 command[
"params"] = Json::objectValue;
262 command[
"params"][
"id"] = _index;
263 Json::FastWriter fastWriter;
264 std::string output = fastWriter.write(command);
267 Json::Value returnVal;
268 std::string t = rsp.at(0);
269 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
270 _enabled = boost::lexical_cast<bool>(returnVal[
"result"][
"enable"].asBool());
271 _frequency = boost::lexical_cast<double>(returnVal[
"result"][
"offset"].asDouble());
272 _source = boost::lexical_cast<int>(returnVal[
"result"][
"rfch"].asInt());
273 _dataPort = boost::lexical_cast<int>(returnVal[
"result"][
"link"].asInt());
274 _udpDestination = boost::lexical_cast<int>(returnVal[
"result"][
"dest"].asInt());
275 _rateIndex = boost::lexical_cast<int>(returnVal[
"result"][
"filter"].asInt());
276 _streamId = boost::lexical_cast<int>(returnVal[
"result"][
"vita"].asUInt());
277 _ovs = boost::lexical_cast<int>(returnVal[
"result"][
"ovs"].asInt());
278 _decimation = boost::lexical_cast<int>(returnVal[
"result"][
"decimation"].asInt());
279 _type = boost::lexical_cast<std::string>(returnVal[
"result"][
"type"].asString());
280 _mode = boost::lexical_cast<std::string>(returnVal[
"result"][
"mode"].asString());
281 _dgv = boost::lexical_cast<int>(returnVal[
"result"][
"dgv"].asInt());
282 _dul = boost::lexical_cast<int>(returnVal[
"result"][
"dul"].asInt());
283 _dll = boost::lexical_cast<int>(returnVal[
"result"][
"dll"].asInt());
284 _dtl = boost::lexical_cast<int>(returnVal[
"result"][
"dtl"].asInt());
285 _dal = boost::lexical_cast<int>(returnVal[
"result"][
"dal"].asInt());
286 _ddl = boost::lexical_cast<int>(returnVal[
"result"][
"ddl"].asInt());
287 _dao = boost::lexical_cast<int>(returnVal[
"result"][
"dao"].asInt());
288 _ddo = boost::lexical_cast<int>(returnVal[
"result"][
"ddo"].asInt());
289 _datc = boost::lexical_cast<int>(returnVal[
"result"][
"datc"].asInt());
290 _ddtc = boost::lexical_cast<int>(returnVal[
"result"][
"ddtc"].asInt());
291 _dat = boost::lexical_cast<int>(returnVal[
"result"][
"dat"].asInt());
292 _ddt = boost::lexical_cast<int>(returnVal[
"result"][
"ddt"].asInt());
294 this->
debug(
"[WbddcComponent::queryConfiguration] Returning\n");
302 int& udpDestination,
bool& enabled,
int& vitaEnable,
303 unsigned int& streamId)
306 if ( (_parent != NULL) && (_parent->isConnected()) )
308 Json::Value root(Json::objectValue);
309 root[
"msg"] = m324Parent->getMessageId();
310 root[
"cmd"] =
"qwbddc";
311 Json::Value params(Json::objectValue);
312 params[
"id"] = index;
313 root[
"params"] = params;
314 Json::FastWriter fastWriter;
315 std::string output = fastWriter.write(root);
318 Json::Value returnVal;
319 std::string t = recv.at(0);
320 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
321 Json::Value result = returnVal[
"result"];
322 rateIndex = boost::lexical_cast<int>(result[
"filter"].asInt());
323 udpDestination = boost::lexical_cast<int>(result[
"dest"].asInt());
324 enabled = boost::lexical_cast<int>(result[
"enable"].asBool());
325 vitaEnable = boost::lexical_cast<int>(result[
"enable"].asBool());
326 streamId = boost::lexical_cast<unsigned int>(result[
"vita"].asUInt());
334 if ( (_parent != NULL) && (_parent->isConnected()) )
336 Json::Value root(Json::objectValue);
337 root[
"msg"] = m324Parent->getMessageId();
338 root[
"cmd"] =
"wbddc";
339 Json::Value params(Json::objectValue);
340 params[
"id"] = index;
341 params[
"link"] = dataPort;
342 root[
"params"] = params;
343 Json::FastWriter fastWriter;
344 std::string output = fastWriter.write(root);
347 Json::Value returnVal;
348 std::string t = recv.at(0);
349 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
350 ret = returnVal[
"success"].asBool();
360 if ( (_parent != NULL) && (_parent->isConnected()) )
362 Json::Value root(Json::objectValue);
363 root[
"msg"] = m324Parent->getMessageId();
364 root[
"cmd"] =
"wbddc";
365 Json::Value params(Json::objectValue);
366 params[
"id"] = index;
368 params[
"rfch"] = source;
369 root[
"params"] = params;
370 Json::FastWriter fastWriter;
371 std::string output = fastWriter.write(root);
374 Json::Value returnVal;
375 std::string t = recv.at(0);
376 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
377 ret = returnVal[
"success"].asBool();
386 if ( (_parent != NULL) && (_parent->isConnected()) )
388 Json::Value root(Json::objectValue);
389 root[
"msg"] = m324Parent->getMessageId();
390 root[
"cmd"] =
"wbddc";
391 Json::Value params(Json::objectValue);
392 params[
"id"] = index;
393 params[
"offset"] = freq;
394 root[
"params"] = params;
395 Json::FastWriter fastWriter;
396 std::string output = fastWriter.write(root);
399 Json::Value returnVal;
400 std::string t = recv.at(0);
401 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
402 ret = returnVal[
"success"].asBool();
410 int& udpDestination,
bool& enabled,
int& vitaEnable,
411 unsigned int& streamId)
414 if ( (_parent != NULL) && (_parent->isConnected()) )
416 Json::Value root(Json::objectValue);
417 root[
"msg"] = m324Parent->getMessageId();
418 root[
"cmd"] =
"wbddc";
419 Json::Value params(Json::objectValue);
420 params[
"id"] = index;
421 params[
"filter"] = rateIndex;
422 params[
"dest"] = udpDestination;
423 params[
"enable"] = boost::lexical_cast<bool>(enabled);
424 params[
"vita"] = streamId;
425 root[
"params"] = params;
426 Json::FastWriter fastWriter;
427 std::string output = fastWriter.write(root);
428 this->
debug(
"CMD: %s\n", output.c_str());
431 Json::Value returnVal;
432 std::string t = recv.at(0);
433 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
434 ret = returnVal[
"success"].asBool();
441 this->
debug(
"Index: %d\n", index);
443 if ( _config.hasKey(
"filter") )
445 int adjRateIndex = index;
446 int adjUdpDest = _udpDestination;
447 int adjVita = _vitaEnable;
448 unsigned int adjStream = _streamId;
449 bool adjEnabled = _enabled;
450 this->
debug(
"Index: %d\n", index);
451 ret =
executeWbddcCommand(_index, adjRateIndex, adjUdpDest, adjEnabled, adjVita, adjStream);
454 _rateIndex = adjRateIndex;
464 if ( _tunable && _config.hasKey(
"offset") )
466 double adjFreq = freq;
470 _frequency = adjFreq;
480 if ( _config.hasKey(
"rfch") )
482 int adjSource = source;
496 if ( _config.hasKey(
"dest") )
498 int adjRateIndex = _rateIndex;
499 int adjUdpDest = dest;
500 int adjVita = _vitaEnable;
501 unsigned int adjStream = _streamId;
502 bool adjEnabled = _enabled;
503 ret =
executeWbddcCommand(_index, adjRateIndex, adjUdpDest, adjEnabled, adjVita, adjStream);
506 _udpDestination = adjUdpDest;
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.
A configuration dictionary.
bool executeFreqCommand(int index, double &freq) override
Executes the WBDDC frequency set command.
bool setRateIndex(int index) override
Sets the WBDDC's rate index.
bool executeWbddcCommand(int index, int &rateIndex, int &udpDestination, bool &enabled, int &vitaEnable, unsigned int &streamId) override
Executes the WBDDC configuration set command.
virtual WbddcComponent & operator=(const WbddcComponent &other)
Assignment operator for WbddcComponent objects.
virtual bool setConfiguration(ConfigurationDict &cfg) override
Sets the configuration dictionary for this component.
bool setSource(int source) override
Sets the WBDDC's source (which tuner is supplying the signal).
bool setUdpDestination(int dest) override
Sets the WBDDC's UDP destination.
bool executeWbddcQuery(int index, int &rateIndex, int &udpDestination, bool &enabled, int &vitaEnable, unsigned int &streamId)
Execute a JSON wbddc Query.
void queryConfiguration() override
Tells the component to query its hardware configuration in order to create its configuration dictiona...
bool setFrequency(double freq) override
Sets the WBDDC tuned frequency.
WbddcComponent(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)
Constructs a WbddcComponent object.
void initConfigurationDict() override
Setup Config Dict.
bool executeSourceCommand(int index, int &source) override
Executes the WBDDC source set command.
bool executeDataPortCommand(int index, int &dataPort) override
Executes the WBDDC data port set command.
virtual ~WbddcComponent()
Destroys a WbddcComponent object.
virtual 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.