11#include "LibCyberRadio/Driver/NDR472/RadioHandler.h"
12#include "LibCyberRadio/Driver/NDR472/SimpleIpSetup.h"
13#include "LibCyberRadio/Driver/NDR472/TunerComponent.h"
14#include "LibCyberRadio/Driver/NDR472/VitaIfSpec.h"
15#include "LibCyberRadio/Driver/NDR472/WbddcComponent.h"
16#include "LibCyberRadio/Driver/NDR472/WbddcGroupComponent.h"
17#include "LibCyberRadio/Common/Pythonesque.h"
18#include <boost/lexical_cast.hpp>
32 RadioHandler::RadioHandler(
bool debug) :
60 initConfigurationDict();
61 _connModesSupported.push_back(
"tty");
62 _defaultDeviceInfo = 921600;
64 for (
int tuner = _tunerIndexBase;
65 tuner < (_tunerIndexBase + _numTuner); tuner++)
68 _tuners[tuner] =
new NDR472::TunerComponent(
77 for (
int wbddc = _wbddcIndexBase;
78 wbddc < (_wbddcIndexBase + _numWbddc); wbddc++)
80 _wbddcs[wbddc] =
new NDR472::WbddcComponent(
92 for (
int group = _wbddcGroupIndexBase;
93 group < (_wbddcGroupIndexBase + _numWbddcGroups); group++)
95 _wbddcGroups[group] =
new NDR472::WbddcGroupComponent(
103 _simpleIpSetups[0] =
new NDR472::SimpleIpSetup(
108 "00:00:00:00:00:00");
122 ::LibCyberRadio::Driver::RadioHandler::operator=(other);
135 _config[
"configMode"] = _configMode;
136 _config[
"referenceMode"] = _referenceMode;
137 _config[
"freqNormalization"] = _freqNormalization;
138 _config[
"gpsEnable"] = _gpsEnabled;
139 _config[
"referenceTuningVoltage"] = _referenceTuningVoltage;
146 this->
debug(
"[NDR472::RadioHandler::queryConfiguration] Called\n");
150 this->
debug(
"[NDR472::RadioHandler::queryConfiguration] Returning\n");
154 bool RadioHandler::queryVersionInfo()
156 this->
debug(
"[NDR472::RadioHandler::queryVersionInfo] Called\n");
158 bool ret = ::LibCyberRadio::Driver::RadioHandler::queryVersionInfo();
166 for (BasicStringStringDict::iterator it = _versionInfo.begin(); it != _versionInfo.end(); it++)
168 this->
debug(
"[NDR472::RadioHandler::queryVersionInfo] %s = \"%s\"\n", it->first.c_str(), it->second.c_str());
171 this->
debug(
"[NDR472::RadioHandler::queryVersionInfo] Returning %s\n",
181 bool RadioHandler::executeQueryIDN(std::string& model,
182 std::string& serialNumber)
189 BasicStringList::iterator it;
190 for (it = rsp.begin(); it != rsp.end(); it++)
192 if ( it->find(
"NDR") != std::string::npos )
194 if ( it->find(
"S/N ") != std::string::npos )
211 bool RadioHandler::executeQueryVER(std::string& softwareVersion,
212 std::string& firmwareVersion,
213 std::string& referenceVersion,
214 std::string& firmwareDate)
221 BasicStringList::iterator it;
222 bool parsingAppCode =
false;
223 bool parsingFpga =
false;
224 for (it = rsp.begin(); it != rsp.end(); it++)
226 if ( it->find(
"Application code") != std::string::npos )
228 parsingAppCode =
true;
231 if ( it->find(
"FPGA") != std::string::npos )
233 parsingAppCode =
false;
236 if ( parsingAppCode )
238 if ( it->find(
" REV: ") != std::string::npos )
241 else if ( parsingFpga )
243 if ( it->find(
"Loaded Image") != std::string::npos )
272 bool RadioHandler::executeQueryHREV(std::string& hardwareInfo)
279 std::ostringstream oss;
280 BasicStringList::iterator it;
281 bool parsingUnitModel =
false;
282 for (it = rsp.begin(); it != rsp.end(); it++)
284 if ( (*it !=
"OK") && (*it !=
"HREV?") )
288 parsingUnitModel =
true;
293 parsingUnitModel =
false;
295 if ( !parsingUnitModel )
297 if ( oss.str() !=
"" )
304 hardwareInfo = oss.str();
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 NDR472.
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 NDR472.
Generic radio handler class.
virtual std::string getLastCommandErrorInfo() const
Gets the error message from the last command attempted.
virtual RadioHandler & operator=(const RadioHandler &other)
Assignment operator for RadioHandler objects.
virtual void queryConfiguration()
Tells the radio to query its hardware configuration in order to create its configuration dictionary (...
virtual BasicStringList sendCommand(const std::string &cmdString, double timeout=-1)
Sends a command to the radio.
static std::string Strip(const std::string &str, const std::string &chars=" \r\n\t\v\f")
Strips both leading and trailing 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 bool Startswith(const std::string &str, const std::string &prefix, int start=0, int end=INT_MAX)
Determines if the given string starts with the specified prefix.
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 NDR472 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.