11 #include "LibCyberRadio/Driver/NDR551/WbddcComponent.h" 12 #include "LibCyberRadio/Driver/RadioHandler.h" 13 #include <boost/format.hpp> 14 #include <json/json.h> 15 #include <boost/lexical_cast.hpp> 37 (boost::format(
"NDR551-WBDDC%02d") % \
58 this->
debug(
"[NDR551::WbddcComponent] index - %d\n", index);
62 _rateSet[40] = 128.0e6;
63 _rateSet[39] = 64.0e6;
64 _rateSet[38] = 32.0e6;
65 _rateSet[37] = 32.0e6;
66 _rateSet[36] = 16.0e6;
67 _rateSet[35] = 16.0e6;
68 _rateSet[34] = 16.0e6;
84 ::LibCyberRadio::Driver::WbddcComponent::operator=(other);
98 _config[
"filter"] = 40;
100 _config[
"enable"] =
false;
102 _config[
"type"] =
"auto";
103 _config[
"decimation"] = _decimation;
105 _config[
"mode"] = _mode;
106 _config[
"dgv"] = _dgv;
107 _config[
"dul"] = _dul;
108 _config[
"dll"] = _dll;
109 _config[
"dtl"] = _dtl;
110 _config[
"dal"] = _dal;
111 _config[
"ddl"] = _ddl;
112 _config[
"dao"] = _dao;
113 _config[
"ddo"] = _ddo;
114 _config[
"datc"] = _datc;
115 _config[
"ddtc"] = _ddtc;
119 _config[
"offset"] = 0.0f;
121 if ( _selectableSource )
123 _config[
"rfch"] =
"0";
125 if ( _selectableDataPort )
135 this->
debug(
"[NDR551WbddcComponent::setConfiguration] Called\n");
139 command[
"cmd"] =
"wbddc";
141 command[
"params"] = Json::objectValue;
142 command[
"params"][
"id"] = _index;
144 for( ConfigurationDict::const_iterator it = cfg.begin();
145 it != cfg.end(); ++it)
147 if ( (it->first ==
"mode") ||
148 (it->first ==
"rfch") ||
149 (it->first ==
"type") )
151 command[
"params"][it->first.c_str()] = it->second.c_str();
153 else if ( (it->first ==
"enable") )
155 command[
"params"][it->first.c_str()] = it->second.asBool();
159 command[
"params"][it->first.c_str()] = it->second.asInt();
162 Json::FastWriter fastWriter;
163 std::string output = fastWriter.write(command);
164 std::cout << output << std::endl;
167 Json::Value returnVal;
168 std::string t = rsp.at(0);
169 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
170 ret = returnVal[
"success"].asBool();
176 this->
debug(
"[NDR551WbddcComponent::updateConfigurationDict] Called\n");
178 if ( _config.
hasKey(
"filter") )
180 if ( _config.
hasKey(
"dest") )
182 if ( _config.
hasKey(
"enable") )
184 if ( _config.
hasKey(
"vita") )
186 if ( _tunable && _config.
hasKey(
"offset") )
190 if ( _selectableSource && _config.
hasKey(
"rfch") )
194 if ( _selectableDataPort && _config.
hasKey(
"link") )
198 if ( _config.
hasKey(
"mode") )
202 if ( _config.
hasKey(
"decimation") )
206 if ( _config.
hasKey(
"dgv" ) )
210 if ( _config.
hasKey(
"dul" ) )
214 if ( _config.
hasKey(
"dll" ) )
218 if ( _config.
hasKey(
"dtl" ) )
222 if ( _config.
hasKey(
"dal" ) )
226 if ( _config.
hasKey(
"ddl" ) )
230 if ( _config.
hasKey(
"dao" ) )
234 if ( _config.
hasKey(
"ddo" ) )
238 if ( _config.
hasKey(
"datc") )
242 if ( _config.
hasKey(
"ddtc") )
246 if ( _config.
hasKey(
"ddt" ) )
250 if ( _config.
hasKey(
"type") )
258 this->
debug(
"[WbddcComponent::queryConfiguration] Called\n");
261 command[
"cmd"] =
"qwbddc";
263 command[
"params"] = Json::objectValue;
264 command[
"params"][
"id"] = _index;
265 Json::FastWriter fastWriter;
266 std::string output = fastWriter.write(command);
269 Json::Value returnVal;
270 std::string t = rsp.at(0);
271 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
272 if( parsingSuccessful && returnVal.isMember(
"result") ) {
273 _enabled = boost::lexical_cast<
bool>(returnVal[
"result"][
"enable"].asBool());
274 _frequency = boost::lexical_cast<
double>(returnVal[
"result"][
"offset"].asDouble());
275 _source = boost::lexical_cast<
int>(returnVal[
"result"][
"rfch"].asString());
276 _dataPort = boost::lexical_cast<
int>(returnVal[
"result"][
"link"].asInt());
277 _udpDestination = boost::lexical_cast<
int>(returnVal[
"result"][
"dest"].asInt());
278 _rateIndex = boost::lexical_cast<
int>(returnVal[
"result"][
"filter"].asInt());
279 _streamId = boost::lexical_cast<
int>(returnVal[
"result"][
"vita"].asUInt());
280 _ovs = boost::lexical_cast<
int>(returnVal[
"result"][
"ovs"].asInt());
281 _decimation = boost::lexical_cast<
int>(returnVal[
"result"][
"decimation"].asInt());
282 _type = boost::lexical_cast<std::string>(returnVal[
"result"][
"type"].asString());
283 _mode = boost::lexical_cast<std::string>(returnVal[
"result"][
"mode"].asString());
284 _dgv = boost::lexical_cast<
int>(returnVal[
"result"][
"dgv"].asInt());
285 _dul = boost::lexical_cast<
int>(returnVal[
"result"][
"dul"].asInt());
286 _dll = boost::lexical_cast<
int>(returnVal[
"result"][
"dll"].asInt());
287 _dtl = boost::lexical_cast<
int>(returnVal[
"result"][
"dtl"].asInt());
288 _dal = boost::lexical_cast<
int>(returnVal[
"result"][
"dal"].asInt());
289 _ddl = boost::lexical_cast<
int>(returnVal[
"result"][
"ddl"].asInt());
290 _dao = boost::lexical_cast<
int>(returnVal[
"result"][
"dao"].asInt());
291 _ddo = boost::lexical_cast<
int>(returnVal[
"result"][
"ddo"].asInt());
292 _datc = boost::lexical_cast<
int>(returnVal[
"result"][
"datc"].asInt());
293 _ddtc = boost::lexical_cast<
int>(returnVal[
"result"][
"ddtc"].asInt());
294 _dat = boost::lexical_cast<
int>(returnVal[
"result"][
"dat"].asInt());
295 _ddt = boost::lexical_cast<
int>(returnVal[
"result"][
"ddt"].asInt());
298 this->
debug(
"[WbddcComponent::queryConfiguration] Returning\n");
306 int& udpDestination,
bool& enabled,
int& vitaEnable,
307 unsigned int& streamId)
310 if ( (_parent != NULL) && (_parent->
isConnected()) )
312 Json::Value root(Json::objectValue);
314 Json::Value params(Json::objectValue);
315 params[
"id"] = index;
316 root[
"params"] = params;
317 Json::FastWriter fastWriter;
318 std::string output = fastWriter.write(root);
321 Json::Value returnVal;
322 std::string t = recv.at(0);
323 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
324 Json::Value result = returnVal[
"result"];
325 rateIndex = boost::lexical_cast<
int>(result[
"filter"].asInt());
326 udpDestination = boost::lexical_cast<
int>(result[
"dest"].asInt());
327 enabled = boost::lexical_cast<
int>(result[
"enable"].asBool());
328 vitaEnable = boost::lexical_cast<
int>(result[
"enable"].asBool());
329 streamId = boost::lexical_cast<
unsigned int>(result[
"vita"].asUInt());
337 if ( (_parent != NULL) && (_parent->
isConnected()) )
339 Json::Value root(Json::objectValue);
341 root[
"cmd"] =
"wbddc";
342 Json::Value params(Json::objectValue);
343 params[
"id"] = index;
344 params[
"link"] = dataPort;
345 root[
"params"] = params;
346 Json::FastWriter fastWriter;
347 std::string output = fastWriter.write(root);
350 Json::Value returnVal;
351 std::string t = recv.at(0);
352 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
353 ret = returnVal[
"success"].asBool();
363 if ( (_parent != NULL) && (_parent->
isConnected()) )
365 Json::Value root(Json::objectValue);
367 root[
"cmd"] =
"wbddc";
368 Json::Value params(Json::objectValue);
369 params[
"id"] = index;
371 params[
"rfch"] = std::to_string(source);
372 root[
"params"] = params;
373 Json::FastWriter fastWriter;
374 std::string output = fastWriter.write(root);
377 Json::Value returnVal;
378 std::string t = recv.at(0);
379 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
380 ret = returnVal[
"success"].asBool();
389 if ( (_parent != NULL) && (_parent->
isConnected()) )
391 Json::Value root(Json::objectValue);
393 root[
"cmd"] =
"wbddc";
394 Json::Value params(Json::objectValue);
395 params[
"id"] = index;
396 params[
"offset"] = freq;
397 root[
"params"] = params;
398 Json::FastWriter fastWriter;
399 std::string output = fastWriter.write(root);
402 Json::Value returnVal;
403 std::string t = recv.at(0);
404 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
405 ret = returnVal[
"success"].asBool();
413 int& udpDestination,
bool& enabled,
int& vitaEnable,
414 unsigned int& streamId)
417 if ( (_parent != NULL) && (_parent->
isConnected()) )
419 Json::Value root(Json::objectValue);
421 root[
"cmd"] =
"wbddc";
422 Json::Value params(Json::objectValue);
423 params[
"id"] = index;
424 params[
"filter"] = rateIndex;
425 params[
"dest"] = udpDestination;
426 params[
"enable"] = boost::lexical_cast<
bool>(enabled);
427 params[
"vita"] = streamId;
428 root[
"params"] = params;
429 Json::FastWriter fastWriter;
430 std::string output = fastWriter.write(root);
433 Json::Value returnVal;
434 std::string t = recv.at(0);
435 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
436 ret = returnVal[
"success"].asBool();
444 if ( _config.
hasKey(
"filter") )
446 int adjRateIndex = index;
447 int adjUdpDest = _udpDestination;
448 int adjVita = _vitaEnable;
449 unsigned int adjStream = _streamId;
450 bool adjEnabled = _enabled;
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 void updateConfigurationDict()
Updates the configuration dictionary from component settings.
virtual void updateConfigurationDict() override
Updates the configuration dictionary from component settings.
virtual WbddcComponent & operator=(const WbddcComponent &other)
Assignment operator for WbddcComponent objects.
virtual bool setConfigurationValueToDbl(const std::string &key, const double value)
Sets a named configuration value to a double value.
bool setUdpDestination(int dest) override
Sets the WBDDC's UDP destination.
bool executeFreqCommand(int index, double &freq) override
Executes the WBDDC frequency set command.
virtual bool hasKey(const std::string &key) const
Determines if the dictionary has the given key.
bool executeSourceCommand(int index, int &source) override
Executes the WBDDC source set command.
void initConfigurationDict() override
Setup Config Dict.
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.
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).
virtual bool isConnected() const
Gets whether or not the handler is connected.
virtual bool setConfigurationValueToUInt(const std::string &key, const unsigned int value)
Sets a named configuration value to an unsigned integer value.
bool executeWbddcCommand(int index, int &rateIndex, int &udpDestination, bool &enabled, int &vitaEnable, unsigned int &streamId) override
Executes the WBDDC configuration set command.
Generic radio handler class.
virtual int debug(const char *format,...)
Outputs debug information.
BASIC_LIST_CONTAINER< std::string > BasicStringList
Type representing a list of strings.
WBDDC component class for the NDR551.
virtual void initConfigurationDict()
Initializes the configuration dictionary, defining the allowed keys.
bool setRateIndex(int index) override
Sets the WBDDC's rate index.
Defines functionality for LibCyberRadio applications.
A configuration dictionary.
virtual ~WbddcComponent()
Destroys a WbddcComponent object.
void queryConfiguration() override
Tells the component to query its hardware configuration in order to create its configuration dictiona...
bool executeDataPortCommand(int index, int &dataPort) override
Executes the WBDDC data port set command.
virtual BasicStringList sendCommand(const std::string &cmdString, double timeout=-1)
Sends a command to the radio.
bool executeWbddcQuery(int index, int &rateIndex, int &udpDestination, bool &enabled, int &vitaEnable, unsigned int &streamId)
Execute a JSON wbddc Query.
virtual bool setConfigurationValue(const std::string &key, const std::string &value)
Sets a named configuration value to a string.
bool setFrequency(double freq) override
Sets the WBDDC tuned frequency.
virtual uint32_t getMessageId(void)
Get a json Message ID.
virtual bool setConfigurationValueToInt(const std::string &key, const int value)
Sets a named configuration value to an integer value.