24 #include "cheetah/pipeline/CheetahConfig.h" 25 #include "cheetah/version.h" 26 #include "panda/ConfigFile.h" 27 #include "panda/Log.h" 28 #include "panda/PropertyTreeUtils.h" 29 #include <boost/filesystem.hpp> 30 #include <boost/property_tree/xml_parser.hpp> 37 template<
typename NumericalRep>
38 CheetahConfig<NumericalRep>::CheetahConfig(std::string
const& app_name)
40 , _desc(
"Generic Options")
42 , _system(utils::system())
43 , _stream_name(
"sigproc")
44 , _handler_timing(false)
45 , _pool_manager(_system, _pool_manager_config)
46 , _acceleration_search_config(_pool_manager)
47 , _fldo_config(_pool_manager)
48 , _rfim_config(_pool_manager)
49 , _sift_config(_pool_manager)
50 , _sps_config(_pool_manager)
55 (
"help,h",
"this help message")
56 (
"help-config-file",
"information about the configuration file and its format")
57 (
"help-module", boost::program_options::value<std::vector<std::string>>(),
"display help message for the specified modules (see --list-modules)")
58 (
"timer",
"record execution time for each invocation of the computation part of the pipeline")
59 (
"input-stream,s", boost::program_options::value<std::string>()->default_value(
"sigproc")->required(),
"select the input stream for the pipeline (see list-sources)")
60 (
"log-level", boost::program_options::value<std::vector<std::string>>()->notifier(
61 [](std::vector<std::string>
const& levels) {
62 for(
auto const& level : levels) {
63 if(level ==
"debug") {
64 panda::log_debug.enable(
true);
66 else if(level ==
"error") {
67 panda::log_error.enable(
true);
68 panda::log_warn.enable(
false);
69 panda::log.enable(
false);
71 else if(level ==
"warn") {
72 panda::log_warn.enable(
true);
73 panda::log.enable(
false);
75 else if(level ==
"log") {
76 panda::log_error.enable(
true);
77 panda::log_warn.enable(
true);
78 panda::log.enable(
true);
82 ),
"set the level of logging (error, warn, log,debug)")
83 (
"list-sources",
"list the available input streams for the pipeline and exit")
84 (
"list-pipelines",
"list the available computational pipelines and exit")
85 (
"list-modules",
"a list of the configurable modules (see --help-module)")
86 (
"pipeline,p", boost::program_options::value<std::string>(&_pipeline_name),
"specify the computational pipeline to run (see list-pipelines)")
87 (
"config", boost::program_options::value<std::string>(),
"specify a configuration file (see --help-configuration-file)")
88 (
"version",
"print out the program version and exit")
91 _options_pod.add(
"config", 1);
94 add(_pool_manager_config);
95 add(_acceleration_search_config);
97 add(_channel_mask_config);
105 add(_sps_clustering_config);
107 _all_desc.add(_desc);
108 _all_desc.add(command_line_options());
111 panda::ProcessingEngineConfig engine_config;
112 engine_config.number_of_threads(2);
113 _switch_config.set_engine_config(engine_config);
116 template<
typename NumericalRep>
117 CheetahConfig<NumericalRep>::~CheetahConfig()
121 template<
typename NumericalRep>
122 void CheetahConfig<NumericalRep>::add_options(OptionsDescriptionEasyInit& )
126 template<
typename NumericalRep>
129 return cheetah::version;
132 template<
typename NumericalRep>
138 template<
typename NumericalRep>
141 return _pipeline_name;
144 template<
typename NumericalRep>
147 return _handler_timing;
150 template<
typename NumericalRep>
153 _pipeline_handler_names = handler_names;
156 template<
typename NumericalRep>
159 if(argc > 0) _app_name= boost::filesystem::basename(argv[0]);
162 boost::program_options::variables_map vm;
163 boost::program_options::store(boost::program_options::command_line_parser(argc, argv)
165 .positional(_options_pod)
168 if( vm.count(
"version") ) {
169 std::cout << version() <<
"\n";
172 if( vm.count(
"help") ) {
173 std::cout <<
"Name\n\t" << _app_name <<
" - cheetah pipeline launcher\n\n";
174 std::cout <<
"Synopsis\n\t" << _app_name <<
" [OPTIONS] [config_file]\n\n";
175 std::cout <<
"\tA source and a pipeline must be specfied as a minimum, either through the" <<
"\n";
176 std::cout <<
"\toptions or through the config file (--help-config-file).\n" <<
"\n";
177 std::cout <<
"\tModule specific help can be accessed via the --help-module flag.\n" <<
"\n";
178 std::cout << _desc <<
"\n";
181 if( vm.count(
"help-config-file") ) {
182 std::cout <<
"Name\n\t" << _app_name <<
" - cheetah pipeline launcher config files\n\n";
183 std::cout <<
"Description\n\tconfig files should be in XML format and the filename should have the .xml extension." <<
"\n";
184 std::cout <<
"\tAny command line option can be set in the config file using the long name of the option as a tag." <<
"\n";
185 std::cout <<
"\tAll tags must be enclosed in the <cheetah> tag scope.\n" <<
"\n";
186 boost::property_tree::ptree cheetah_config_pt;
187 cheetah_config_pt.put_child(
"cheetah", config_tree());
188 #if BOOST_VERSION < 105600 189 boost::property_tree::write_xml(std::cout, cheetah_config_pt,boost::property_tree::xml_writer_make_settings(
' ', 2));
191 boost::property_tree::write_xml(std::cout, cheetah_config_pt,boost::property_tree::xml_writer_make_settings<std::string>(
' ', 2));
196 if( vm.count(
"list-modules") ) {
197 for(
auto const& mod : subsections() ) {
198 std::cout << mod <<
"\n";
202 if( vm.count(
"list-sources") ) {
204 std::vector<std::string> s {
"sigproc",
"udp",
"udp_low"};
205 #ifdef ENABLE_PSRDADA 206 s.push_back(
"psrdada");
207 #endif // ENABLE_PSRDADA 208 for(
auto stream : s ) {
209 std::cout << stream <<
"\n";
213 if( vm.count(
"list-pipelines") ) {
215 for(
auto pipeline : _pipeline_handler_names ) {
216 std::cout << pipeline <<
"\n";
220 if( vm.count(
"config") ) {
222 panda::ConfigFile config_file(vm[
"config"].as<std::string>());
225 }
catch(std::exception
const& e) {
226 PANDA_LOG_ERROR <<
"exception parsing config file: " << vm[
"config"].as<std::string>() <<
" " << e.what();;
229 PANDA_LOG_ERROR <<
"exception parsing config file: " << vm[
"config"].as<std::string>();
233 auto top_it = config_file.property_tree().find(
"cheetah");
234 if(top_it != config_file.property_tree().not_found() ) {
235 boost::program_options::store(panda::parse_property_tree<char>(top_it->second, _desc), vm);
236 parse_property_tree(top_it->second, vm);
240 if( vm.count(
"help-module") ) {
241 for(
auto const& module : vm[
"help-module"].as<std::vector<std::string>>() ) {
242 std::cout <<
"Name\n\t" << _app_name <<
" - cheetah pipeline launcher module : " << module <<
"\n\n";
243 std::cout << help(module) <<
"\n";
247 if( vm.count(
"input-stream") ) {
248 _stream_name = vm[
"input-stream"].as<std::string>();
250 if( vm.count(
"timer") ) {
251 _handler_timing =
true;
254 boost::program_options::notify(vm);
259 template<
typename NumericalRep>
266 template<
typename NumericalRep>
269 return _acceleration_search_config;
273 template<
typename NumericalRep>
276 return _acceleration_search_config;
279 template<
typename NumericalRep>
282 return _channel_mask_config;
285 template<
typename NumericalRep>
288 return _channel_mask_config;
291 template<
typename NumericalRep>
297 template<
typename NumericalRep>
303 template<
typename NumericalRep>
309 template<
typename NumericalRep>
315 template<
typename NumericalRep>
321 template<
typename NumericalRep>
327 template<
typename NumericalRep>
333 template<
typename NumericalRep>
336 return _spsift_config;
339 template<
typename NumericalRep>
342 return _sps_clustering_config;
344 template<
typename NumericalRep>
350 template<
typename NumericalRep>
356 template<
typename NumericalRep>
359 return _switch_config;
362 template<
typename NumericalRep>
365 return _pool_manager_config;
368 template<
typename NumericalRep>
371 return _pool_manager;
374 template<
typename NumericalRep>
377 return _pool_manager;
380 template<
typename NumericalRep>
383 return _empty_config;
sift::ConfigType const & sift_config() const
return the sift module specific configuration parameters
Parse configuration parameters for a cheetah pipeline application.
MultiBeamConfig< NumericalRep > const & beams_config() const
return the configuration node with beam configurations
bool time_handler_invocation() const
wether to activte timing between each invocation of the runtime computational pipeline ...
panda::DataSwitchConfig & switch_config() const
return the data switch configuration parameters
rfim::ConfigType< PoolManagerType > const & rfim_config() const
return the rfim module specific configuration parameters
Configuration for the Configurable ChannelMask module.
Configuration parameters for the available acceleration searches.
psbc::Config const & psbc_config() const
return the psbc module specific configuration parameters
int parse(int argc, char **argv)
parse the command line options/config file
AccelerationSearchAlgoConfig & acceleration_search_config()
return the templated acceleration search configuration
Some limits and constants for FLDO.
panda::PoolManagerConfig< utils::Config::SystemType > const & pool_manager_config() const
return the data switch configuration parameters
PoolManagerType const & pool_manager() const
return the pool manager object
sps::ConfigType< PoolManagerType > const & sps_config() const
return the sps module specific configuration parameters
EmptyConfig const & empty_config() const
return the empty module specific configuration parameters
fldo::ConfigType const & fldo_config() const
return the fldo module specific configuration parameters
std::string const & pipeline_name() const
return the selected pipeline name
std::string version() const
return the cheetah version as a string
void set_pipeline_handlers(std::vector< std::string > const &handler_names)
set the computational unit names available
std::string const & stream_name() const
return the selected stream name
Configuration for the data collection buffer.
channel_mask::ConfigurableChannelMaskConfig< NumericalRep > const & channel_mask_config() const
return the channel_mask configuration