11#include "LibCyberRadio/Driver/NDR324/RadioHandler.h"
12#include "LibCyberRadio/Driver/NDR551/DataPort.h"
13#include "LibCyberRadio/Driver/NDR551/NbddcComponent.h"
14#include "LibCyberRadio/Driver/NDR324/TunerComponent.h"
15#include "LibCyberRadio/Driver/NDR324/VitaIfSpec.h"
16#include "LibCyberRadio/Driver/NDR324/WbddcComponent.h"
19#include "LibCyberRadio/Common/Pythonesque.h"
26static uint32_t msgCounter = 1;
36 RadioHandler::RadioHandler(
bool debug) :
64 initConfigurationDict();
65 _connModesSupported.push_back(
"udp");
66 _defaultDeviceInfo = 19091;
67 _transport.setJson(
true);
71 for (
int tuner = _tunerIndexBase;
72 tuner < (_tunerIndexBase + _numTuner); tuner++)
75 _tuners[tuner] =
new NDR324::TunerComponent(
84 for (
int wbddc = _wbddcIndexBase;
85 wbddc < (_wbddcIndexBase + _numWbddc); wbddc++)
87 _wbddcs[wbddc] =
new NDR324::WbddcComponent(
99 for (
int nbddc = _nbddcIndexBase;
100 nbddc < (_nbddcIndexBase + _numNbddc); nbddc++)
102 _nbddcs[nbddc] =
new NDR551::NbddcComponent(
116 for (
int group = _wbddcGroupIndexBase;
117 group < (_wbddcGroupIndexBase + _numWbddcGroups); group++)
119 _wbddcGroups[group] =
new NDR551::WbddcGroupComponent(
125 for (
int group = _nbddcGroupIndexBase;
126 group < (_nbddcGroupIndexBase + _numNbddcGroups); group++)
128 _nbddcGroups[group] =
new NDR551::NbddcGroupComponent(
135 for (
int dataPort = _dataPortIndexBase;
136 dataPort < (_dataPortIndexBase + _numDataPorts); dataPort++)
138 _dataPorts[dataPort] =
new NDR551::DataPort(
159 _config[
"referenceMode"] = _referenceMode;
165 ::LibCyberRadio::Driver::RadioHandler::operator=(other);
175 this->
debug(
"[NDR324]::RadioHandler::queryConfiguration] Called\n");
180 Json::Value root(Json::objectValue);
182 root[
"cmd"] =
"qstatus";
183 Json::Value params(Json::objectValue);
184 root[
"params"] = params;
185 Json::FastWriter fastWriter;
186 std::string output = fastWriter.write(root);
188 if ( _config.hasKey(
"referenceMode") )
190 this->executeReferenceModeQuery(_referenceMode);
192 this->
debug(
"[NDR324::RadioHandler::queryConfiguration] Returning\n");
194 for ( TunerComponentDict::iterator it = _tuners.begin();
195 it != _tuners.end(); it++)
197 it->second->queryConfiguration();
199 for ( WbddcComponentDict::iterator it = _wbddcs.begin();
200 it != _wbddcs.end(); it++)
202 it->second->queryConfiguration();
204 for ( DataPortDict::iterator it = _dataPorts.begin();
205 it != _dataPorts.end(); it++)
207 it->second->queryConfiguration();
209 this->queryVersionInfo();
212 bool RadioHandler::query324Specifics()
214 Json::Value root(Json::objectValue);
217 Json::Value params(Json::objectValue);
218 params[
"input"] =
"version";
219 root[
"params"] = params;
220 Json::FastWriter fastWriter;
221 std::string output = fastWriter.write(root);
224 Json::Value returnVal;
225 std::string t = rsp.at(0);
226 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
227 if( parsingSuccessful ){
228 std::string result = returnVal[
"result"].asString();
230 for(
int i = 0; i < l.size(); i++)
232 std::string temp = l.at(i);
235 const char *unitsn =
"UnitSN";
236 if ( std::strstr(temp.c_str(), unitsn) !=
nullptr )
238 _versionInfo[
"serialNumber"] = J.at(1).c_str();
245 bool RadioHandler::queryVersionInfo()
247 this->
debug(
"[RadioHandler::queryVersionInfo] Called\n");
250 Json::Value root(Json::objectValue);
252 root[
"cmd"] =
"qstatus";
253 Json::Value params(Json::objectValue);
254 root[
"params"] = params;
255 Json::FastWriter fastWriter;
256 std::string output = fastWriter.write(root);
259 Json::Value returnVal;
260 std::string t = rsp.at(0);
261 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
262 if( parsingSuccessful ){
263 _versionInfo[
"model"] = returnVal[
"result"][
"model"].asString();
264 _versionInfo[
"softwareVersion"] = returnVal[
"result"][
"sw"].asString();
265 _versionInfo[
"firmwareVersion"] = returnVal[
"result"][
"fw"].asString();
266 _versionInfo[
"unitRevision"] = returnVal[
"result"][
"unit"].asString();
267 _versionInfo[
"hardwareVersion"] = returnVal[
"result"][
"unit"].asString();
268 _versionInfo[
"serialNumber"] = returnVal[
"result"][
"sn"].asString();
271 this->
debug(
"[NDR324::RadioHandler::queryVersionInfo] Returning %s\n",
debugBool(ret));
277 bool RadioHandler::executeQueryIDN(std::string& model,
278 std::string& serialNumber)
280 return ::LibCyberRadio::Driver::RadioHandler::executeQueryIDN(model, serialNumber);
285 bool RadioHandler::executeQueryVER(std::string& softwareVersion,
286 std::string& firmwareVersion,
287 std::string& referenceVersion,
288 std::string& firmwareDate)
291 return ::LibCyberRadio::Driver::RadioHandler::executeQueryVER(softwareVersion,
299 bool RadioHandler::executeQueryHREV(std::string& hardwareInfo)
301 return ::LibCyberRadio::Driver::RadioHandler::executeQueryHREV(hardwareInfo);
309 bool RadioHandler::executeReferenceModeQuery(
int& refMode)
311 this->
debug(
"[NDR324::RadioHandler::queryVersionInfo] Called\n");
314 Json::Value root(Json::objectValue);
316 root[
"cmd"] =
"qref";
317 Json::Value params(Json::objectValue);
318 root[
"params"] = params;
319 Json::FastWriter fastWriter;
320 std::string output = fastWriter.write(root);
323 Json::Value returnVal;
324 std::string t = rsp.at(0);
325 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
326 if( parsingSuccessful ){
327 refMode = boost::lexical_cast<int>(returnVal[
"result"][
"cfg10m"].asInt());
333 bool RadioHandler::executeReferenceModeCommand(
int& refMode)
335 this->
debug(
"[NDR324::RadioHandler::queryVersionInfo] Called\n");
338 Json::Value root(Json::objectValue);
341 Json::Value params(Json::objectValue);
342 params[
"cfg10m"] = refMode;
343 root[
"params"] = params;
344 Json::FastWriter fastWriter;
345 std::string output = fastWriter.write(root);
348 Json::Value returnVal;
349 std::string t = rsp.at(0);
350 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
351 if( parsingSuccessful ){
352 ret = boost::lexical_cast<bool>(returnVal[
"success"].asBool());
virtual const char * debugBool(bool x)
Gets a debug output string for a Boolean value.
virtual int debug(const char *format,...)
Outputs debug information.
Radio handler class for the NDR551.
uint32_t getMessageId(void)
Returns a Time for the msg parameter.
virtual void queryConfiguration()
Tells the radio to query its hardware configuration in order to create its configuration dictionary (...
virtual void initConfigurationDict()
Initializes the configuration dictionary, defining the allowed keys.
virtual ~RadioHandler()
Destroys a RadioHandler object.
VITA interface specification for the NDR308.
virtual BasicStringList sendCommand(const std::string &cmdString, double timeout=-1)
Sends a command to the radio.
static std::string Lstrip(const std::string &str, const std::string &chars=" \r\n\t\v\f")
Strips leading whitespace from the given string.
static BasicStringList Split(const std::string &str, const std::string &sep, int maxsplit=INT_MAX)
Splits the given string into a list of string tokens.
static std::string Replace(const std::string &str, const std::string &oldstr, const std::string &newstr, int count=INT_MAX)
Replaces occurrences of one substring with another within the given string.
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.