SoDaRadio-5.0.3-master:8901fb5
Params.hxx
Go to the documentation of this file.
1 /*
2 Copyright (c) 2013,2014 Matthew H. Reilly (kb1vc)
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
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 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 #ifndef PARAMS_HDR
30 #define PARAMS_HDR
31 
32 #include <boost/format.hpp>
33 #include <boost/program_options.hpp>
34 #include <string>
35 #include <algorithm>
36 #include <iostream>
37 
38 namespace SoDa {
42  class Params {
43  public:
50  Params(int argc, char * argv[]);
51 
56  std::string getRadioArgs() const { return radio_args; }
57 
58 
59 
64  std::string getClockSource() const { return clock_source; }
65 
66 
71  std::string getRXAnt() const { return rx_ant; }
76  std::string getTXAnt() const { return tx_ant; }
77 
81  void readConfigFile(std::string &cf_name );
85  void saveConfigFile(std::string &cf_name );
86 
98  double getRXRate() const { return 625000; }
102  double getTXRate() const { return 625000; }
103 
104  double getAudioSampleRate() const { return 48000.0 ; }
105  unsigned int getRFBufferSize() const { return (unsigned int) 30000; }
106  unsigned int getAFBufferSize() const { return (unsigned int) 2304; }
107 
108  std::string getServerSocketBasename() const { return server_sock_basename; }
109 
110  std::string getAudioPortName() const { return audio_portname; }
111 
114 
115  unsigned int getDebugLevel() const { return debug_level; }
116 
117  std::string getRadioType() const { return radio_type; }
118 
119  std::string getGPSHostName() const { return gps_hostname; }
120 
121  std::string getGPSPortName() const { return gps_portname; }
122 
123  std::string getLockFileName() const { return lock_file_name; }
124 
125  bool reportMemInfo() const { return report_mem_info; }
126  std::string getReportFileName() const { return report_file_name; }
127 
128  bool isRadioType(const std::string & rtype) {
129  std::string rt = rtype;
130 
131  std::transform(rt.begin(), rt.end(), rt.begin(), ::toupper);
132  std::transform(radio_type.begin(), radio_type.end(), radio_type.begin(), ::toupper);
133  bool res = (rt == radio_type);
134 
135  return res;
136  }
137  private:
138 
139  boost::program_options::variables_map pmap;
140 
142  std::string report_file_name;
143 
144  std::string gps_hostname;
145  std::string gps_portname;
146  std::string radio_type;
147  std::string radio_args;
148  std::string config_filename;
149 
150  std::string lock_file_name;
151 
152  std::string clock_source;
153  double rx_rate, tx_rate;
154  std::string rx_ant, tx_ant;
155 
156  // message socket parameters
157  std::string server_sock_basename;
158 
159  // audio port/device name
160  std::string audio_portname;
161 
162  // synthesizer mode switches (over-rides local determination)
165 
166  unsigned int debug_level;
167  };
168 }
169 #endif
bool isRadioType(const std::string &rtype)
Definition: Params.hxx:128
std::string report_file_name
Definition: Params.hxx:142
std::string server_sock_basename
Definition: Params.hxx:157
std::string rx_ant
Definition: Params.hxx:154
std::string getLockFileName() const
Definition: Params.hxx:123
void saveConfigFile(std::string &cf_name)
save config data to a configuration file (for now, do nothing.)
Definition: Params.cxx:90
double getAudioSampleRate() const
Definition: Params.hxx:104
bool reportMemInfo() const
Definition: Params.hxx:125
std::string getGPSHostName() const
Definition: Params.hxx:119
This class handles command line parameters and built-ins.
Definition: Params.hxx:42
std::string getGPSPortName() const
Definition: Params.hxx:121
std::string getTXAnt() const
which port is the TX channel?
Definition: Params.hxx:76
std::string config_filename
Definition: Params.hxx:148
double getRXRate() const
Sample rates and all that other stuff are fixed.
Definition: Params.hxx:98
double rx_rate
Definition: Params.hxx:153
boost::program_options::variables_map pmap
Definition: Params.hxx:139
std::string tx_ant
Definition: Params.hxx:154
unsigned int getRFBufferSize() const
Definition: Params.hxx:105
Params(int argc, char *argv[])
Constructor.
Definition: Params.cxx:32
std::string lock_file_name
Definition: Params.hxx:150
unsigned int debug_level
Definition: Params.hxx:166
unsigned int getDebugLevel() const
Definition: Params.hxx:115
unsigned int getAFBufferSize() const
Definition: Params.hxx:106
std::string getAudioPortName() const
Definition: Params.hxx:110
bool forceIntN()
Definition: Params.hxx:113
double getTXRate() const
TX rate will always be 625K.
Definition: Params.hxx:102
std::string gps_hostname
Definition: Params.hxx:144
std::string getRXAnt() const
which port is the RX channel?
Definition: Params.hxx:71
std::string getRadioType() const
Definition: Params.hxx:117
std::string getRadioArgs() const
return args that point to a particular USRP unit
Definition: Params.hxx:56
bool forceFracN()
Definition: Params.hxx:112
std::string radio_args
Definition: Params.hxx:147
std::string radio_type
Definition: Params.hxx:146
std::string audio_portname
Definition: Params.hxx:160
bool report_mem_info
Definition: Params.hxx:141
std::string getReportFileName() const
Definition: Params.hxx:126
std::string clock_source
Definition: Params.hxx:152
bool force_frac_N_mode
Definition: Params.hxx:163
std::string getClockSource() const
where does the reference come from?
Definition: Params.hxx:64
std::string getServerSocketBasename() const
Definition: Params.hxx:108
std::string gps_portname
Definition: Params.hxx:145
void readConfigFile(std::string &cf_name)
read a configuration file (for now, just setup the default config.)
Definition: Params.cxx:79
double tx_rate
Definition: Params.hxx:153
bool force_integer_N_mode
Definition: Params.hxx:164