Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Config.cpp
1 /*
2  * The MIT License (MIT)
3  *
4  * Copyright (c) 2016 The SKA organisation
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #include "cheetah/psrdada/Config.h"
25 #include "panda/Error.h"
26 #include<sstream>
27 
28 namespace ska {
29 namespace cheetah {
30 namespace psrdada {
31 namespace detail {
32 
33 // @brief describing the configuration for sigprocdada stream
34 
35 key_t string_to_key(std::string const& in)
36 {
37  key_t key;
38  std::stringstream converter;
39  converter << std::hex << in;
40  if (converter.fail())
41  {
42  throw panda::Error("Wrong input parameter. The dada key has to be a hexadecimal number.");
43  }
44  converter >> key;
45  return key;
46 }
47 } // naemspace detail
48 
49 Config::Config()
50  : cheetah::utils::Config("psrdada")
51  , _dada_key(0xdada)
52  , _number_of_samples(128)
53 {
54 }
55 
56 Config::~Config()
57 {
58 }
59 
60 
61 #ifdef ENABLE_PSRDADA
62 void Config::add_options(OptionsDescriptionEasyInit& add_options)
63 {
64  add_options
65  ("number_of_threads", boost::program_options::value<unsigned>()->default_value(1U)->notifier([&](unsigned v) { _engine_config = v; }) , "the number of threads to run the engine")
66  ("number_of_samples", boost::program_options::value<int>(&_number_of_samples)->default_value(128), "the number of time samples in each chunk")
67  ("dada_key", boost::program_options::value<std::string>()
68  ->default_value("dada")
69  ->notifier([&](std::string in)
70  {
71 
72  _dada_key = detail::string_to_key(in);
73 
74  }), "DADA buffer key");
75 }
76 
77 key_t Config::dada_key() const { return _dada_key; }
78 
79 void Config::dada_key(key_t const& key){ _dada_key = key; }
80 
81 int Config::number_of_samples() const { return _number_of_samples; }
82 
83 void Config::number_of_samples(int const& samples){ _number_of_samples = samples; }
84 
85 Config::Engine& Config::engine() const
86 {
87  if(!_engine)
88  {
89  _engine.reset(new Engine(_engine_config));
90  }
91  return *_engine;
92 }
93 
94 unsigned Config::number_of_threads() const
95 {
96  return _engine_config.number_of_threads();
97 }
98 #endif // ENABLE_PSRDADA
99 
100 } // namespace psrdada
101 } // namespace cheetah
102 } // namespace ska
Some limits and constants for FLDO.
Definition: Brdz.h:35