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/rcpt_low/Config.h"
25 #include <iostream>
26 
27 namespace ska {
28 namespace cheetah {
29 namespace rcpt_low {
30 
31 
32 Config::Config()
33  : utils::Config("udp_low")
34  , _engine_config(2)
35  , _spectra_per_chunk(128U)
36  , _endpoint_config("listen")
37 {
38  _endpoint_config.address(ska::panda::IpAddress(34345, "127.0.0.1"));
39  add(_endpoint_config);
40 }
41 
42 Config::~Config()
43 {
44 }
45 
46 void Config::add_options(OptionsDescriptionEasyInit& add_options)
47 {
48  add_options
49  ("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")
50  ("spectra_per_chunk", boost::program_options::value<unsigned>(&_spectra_per_chunk)->default_value(_spectra_per_chunk), "the number of time slices in each chunk (time_slices x no_of_channels = total data samples)")
51  ("number_of_channels", boost::program_options::value<unsigned>(&_number_of_channels)->default_value(8U), "the number of frequency channels in each time sample")
52  ("max_buffers", boost::program_options::value<std::size_t>(&_max_buffer_count)->default_value(10U), "the max number of udp packet buffers to use");
53 }
54 
55 Config::Engine& Config::engine() const
56 {
57  if(!_engine) {
58  _engine.reset(new Engine(_engine_config));
59  }
60  return *_engine;
61 }
62 
63 boost::asio::ip::udp::endpoint Config::remote_end_point() const
64 {
65  return _endpoint_config.address().end_point<boost::asio::ip::udp::endpoint>();;
66 }
67 
68 void Config::remote_end_point(boost::asio::ip::udp::endpoint const& endpoint)
69 {
70  _endpoint_config.address(ska::panda::IpAddress(endpoint));
71 }
72 
73 unsigned Config::spectra_per_chunk() const
74 {
75  return _spectra_per_chunk;
76 }
77 
78 void Config::spectra_per_chunk(unsigned num)
79 {
80  _spectra_per_chunk = num;
81 }
82 
84 {
85  return _number_of_channels;
86 }
87 
88 void Config::number_of_channels(unsigned num)
89 {
90  _number_of_channels = num;
91 }
92 
93 std::size_t Config::max_buffers() const
94 {
95  return _max_buffer_count;
96 }
97 
98 } // namespace rcpt_low
99 } // namespace cheetah
100 } // namespace ska
unsigned number_of_channels() const
return the number of channels in a chunk
Definition: Config.cpp:83
Some limits and constants for FLDO.
Definition: Brdz.h:35
boost::asio::ip::udp::endpoint remote_end_point() const
geters and setters for the UDP connection (IP address and port or remote peer)
Definition: Config.cpp:63
std::size_t max_buffers() const
return the maximum number of UDP packet buffers to use
Definition: Config.cpp:93