SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
Params.hxx
Go to the documentation of this file.
1/*
2Copyright (c) 2013,2014,2025 Matthew H. Reilly (kb1vc)
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are
7met:
8
9 Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in
13 the documentation and/or other materials provided with the
14 distribution.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
29#pragma once
30
31#include <SoDa/Options.hxx>
32#include <string>
33#include <algorithm>
34#include <iostream>
35#include <vector>
36
37namespace SoDa {
41 class Params;
42 typedef std::shared_ptr<Params> ParamsPtr;
43
44
45 class Params {
46
47 protected:
54 Params(int argc, char * argv[]);
55 public:
56 static ParamsPtr make(int argc, char * argv[]) {
57 return std::shared_ptr<Params>(new Params(argc, argv));
58 }
59
60
65 std::string getRadioArgs() const { return radio_args; }
66
71 std::string getRadioType() const { return radio_type; }
72
73
74
79 int getClockSource() const { return clock_source_internal ? 0 : 1; }
80
81
86 std::string getRXAnt() const { return rx_ant; }
91 std::string getTXAnt() const { return tx_ant; }
92
104 double getRXRate() const { return 625000; }
108 double getTXRate() const { return 625000; }
109
110 double getHWSampleRate() const { return hw_sample_rate; }
111 void setHWSampleRate(double r) { hw_sample_rate = r; }
112
113 double getAudioSampleRate() const { return 48000.0 ; }
114 unsigned int getRFBufferSize() const { return (unsigned int) 30000; }
115 unsigned int getAFBufferSize() const { return (unsigned int) 2304; }
116
117 std::string getServerSocketBasename() const { return server_sock_basename; }
118
119 std::string getAudioPortName() const { return audio_portname; }
120
123
124 const std::vector<std::string> & getLibs();
125
126 unsigned int getDebugLevel() const { return debug_level; }
127
128 std::string getLockFileName() const { return lock_file_name; }
129
130
131 bool isRadioType(const std::string & rtype) {
132 std::string rt = rtype;
133
134 std::transform(rt.begin(), rt.end(), rt.begin(), ::toupper);
135 std::transform(radio_type.begin(), radio_type.end(), radio_type.begin(), ::toupper);
136 bool res = (rt == radio_type);
137
138 return res;
139 }
140
141 private:
142
143 SoDa::Options cmd;
144
145 std::string radio_type;
146 std::string radio_args;
147 std::string config_filename;
148 std::vector<std::string> load_list;
150
151 std::string lock_file_name;
152
155 std::string rx_ant, tx_ant;
156
157 // message socket parameters
159
160 // audio port/device name
161 std::string audio_portname;
162
163 // synthesizer mode switches (over-rides local determination)
166
167 unsigned int debug_level;
168
170 };
171}
bool force_integer_N_mode
Definition Params.hxx:165
Params(int argc, char *argv[])
Constructor.
bool forceIntN()
Definition Params.hxx:122
double getRXRate() const
Sample rates and all that other stuff are fixed.
Definition Params.hxx:104
std::string getRadioType() const
what radio are we trying to configure
Definition Params.hxx:71
std::string getRXAnt() const
which port is the RX channel?
Definition Params.hxx:86
SoDa::Options cmd
Definition Params.hxx:143
bool force_frac_N_mode
Definition Params.hxx:164
std::string getAudioPortName() const
Definition Params.hxx:119
double hw_sample_rate
actual hardware wire rate (may be 2.5 MS/s when 625 kS/s unsupported)
Definition Params.hxx:169
std::string rx_ant
Definition Params.hxx:155
bool load_list_env_appended
Definition Params.hxx:149
double getHWSampleRate() const
Definition Params.hxx:110
std::string getTXAnt() const
which port is the TX channel?
Definition Params.hxx:91
int getClockSource() const
where does the reference come from?
Definition Params.hxx:79
unsigned int getDebugLevel() const
Definition Params.hxx:126
std::string getServerSocketBasename() const
Definition Params.hxx:117
std::string radio_type
Definition Params.hxx:145
unsigned int getAFBufferSize() const
Definition Params.hxx:115
double rx_rate
Definition Params.hxx:154
double getTXRate() const
TX rate will always be 625K.
Definition Params.hxx:108
bool clock_source_internal
Definition Params.hxx:153
void setHWSampleRate(double r)
Definition Params.hxx:111
std::string getRadioArgs() const
return args that point to a particular USRP unit
Definition Params.hxx:65
unsigned int getRFBufferSize() const
Definition Params.hxx:114
std::string config_filename
Definition Params.hxx:147
std::string tx_ant
Definition Params.hxx:155
const std::vector< std::string > & getLibs()
std::string server_sock_basename
Definition Params.hxx:158
double tx_rate
Definition Params.hxx:154
std::string radio_args
Definition Params.hxx:146
std::string lock_file_name
Definition Params.hxx:151
bool forceFracN()
Definition Params.hxx:121
bool isRadioType(const std::string &rtype)
Definition Params.hxx:131
std::vector< std::string > load_list
Definition Params.hxx:148
std::string audio_portname
Definition Params.hxx:161
double getAudioSampleRate() const
Definition Params.hxx:113
unsigned int debug_level
Definition Params.hxx:167
static ParamsPtr make(int argc, char *argv[])
Definition Params.hxx:56
std::string getLockFileName() const
Definition Params.hxx:128
std::shared_ptr< Params > ParamsPtr
Definition Params.hxx:42