libcyberradio 22.01.24
WbddcComponent.cpp
1/***************************************************************************
2 * \file WbddcComponent.cpp
3 * \brief Defines the WBDDC interface for the NDR472.
4 * \author DA
5 * \author NH
6 * \author MN
7 * \copyright (c) 2017 CyberRadio Solutions, Inc. All rights reserved.
8 *
9 ***************************************************************************/
10
11#include "LibCyberRadio/Driver/NDR472/WbddcComponent.h"
12#include "LibCyberRadio/Driver/RadioHandler.h"
13#include "LibCyberRadio/Common/Pythonesque.h"
14#include <boost/lexical_cast.hpp>
15#include <boost/format.hpp>
16
17
18namespace LibCyberRadio
19{
20 namespace Driver
21 {
22
23 namespace NDR472
24 {
25
28 bool debug,
29 int dataPort,
30 int rateIndex,
31 int udpDestination,
32 int vitaEnable,
33 int streamId) :
35 /* const std::string& name */ (boost::format("NDR472-WBDDC%02d") % \
36 index).str(),
37 /* int index */ index,
38 /* ::LibCyberRadio::Driver::RadioHandler* parent */ parent,
39 /* bool debug */ debug,
40 /* bool tunable */ false,
41 /* bool selectableSource */ false,
42 /* bool selectableDataPort */ false,
43 /* bool agc */ false,
44 /* double freqRangeMin */ 0.0,
45 /* double freqRangeMax */ 0.0,
46 /* double freqRes */ 1e6,
47 /* double freqUnits */ 1e6,
48 /* int source */ index,
49 /* int dataPort */ dataPort,
50 /* double frequency */ 0.0,
51 /* int rateIndex */ rateIndex,
52 /* int udpDestination */ udpDestination,
53 /* int vitaEnable */ vitaEnable,
54 /* unsigned int streamId */ streamId)
55 {
57 // Set rate set
58 _rateSet[0] = 12.8e6;
59 }
60
64
69
71 {
72 ::LibCyberRadio::Driver::WbddcComponent::operator=(other);
73 if ( this != &other )
74 {
75 }
76 return *this;
77 }
78
79 // OVERRIDE
80 // This radio uses spaces to delimit command paramters rather than commas.
81 bool WbddcComponent::executeWbddcQuery(int index, int& rateIndex,
82 int& udpDestination, bool& enabled, int& vitaEnable,
83 unsigned int& streamId)
84 {
85 bool ret = false;
86 if ( (_parent != NULL) && (_parent->isConnected()) )
87 {
88 std::ostringstream oss;
89 oss << "WBDDC? " << index << "\n";
90 BasicStringList rsp = _parent->sendCommand(oss.str(), 2.0);
91 if ( _parent->getLastCommandErrorInfo() == "" )
92 {
94 Pythonesque::Replace(rsp.front(), "WBDDC ", ""),
95 " ");
96 // vec[0] = Index
97 // vec[1] = Rate index
98 rateIndex = boost::lexical_cast<int>(vec[1]);
99 udpDestination = boost::lexical_cast<int>(vec[2]);
100 enabled = (boost::lexical_cast<int>(vec[3]) == 1);
101 vitaEnable = boost::lexical_cast<int>(vec[4]);
102 streamId = boost::lexical_cast<unsigned int>(vec[5]);
103 ret = true;
104 }
105 }
106 return ret;
107 }
108
109 // OVERRIDE
110 // This radio doesn't have data ports.
111 bool WbddcComponent::executeDataPortQuery(int index, int& dataPort)
112 {
113 bool ret = false;
114 return ret;
115 }
116
117 // OVERRIDE
118 // This radio doesn't have data ports.
119 bool WbddcComponent::executeDataPortCommand(int index, int& dataPort)
120 {
121 bool ret = false;
122 return ret;
123 }
124
125 } /* namespace NDR472 */
126
127 } // namespace Driver
128
129} // namespace LibCyberRadio
130
virtual int debug(const char *format,...)
Outputs debug information.
virtual WbddcComponent & operator=(const WbddcComponent &other)
Assignment operator for WbddcComponent objects.
virtual bool executeWbddcQuery(int index, int &rateIndex, int &udpDestination, bool &enabled, int &vitaEnable, unsigned int &streamId)
Executes the WBDDC configuration query command.
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 ~WbddcComponent()
Destroys a WbddcComponent object.
virtual bool executeDataPortQuery(int index, int &dataPort)
Executes the WBDDC data port query command.
virtual bool executeDataPortCommand(int index, int &dataPort)
Executes the WBDDC data port set command.
Generic radio handler class.
virtual void initConfigurationDict()
Initializes the configuration dictionary, defining the allowed keys.
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 NDR472 radios.
Provides programming elements for driving CRS NDR-class radios.
Defines functionality for LibCyberRadio applications.
Definition App.h:24
BASIC_LIST_CONTAINER< std::string > BasicStringList
Type representing a list of strings.
Definition BasicList.h:25