Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Emulator.h
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 #ifndef SKA_CHEETAH_EMULATOR_EMULATOR_H
25 #define SKA_CHEETAH_EMULATOR_EMULATOR_H
26 
27 #include "cheetah/generators/TimeFrequencyGenerator.h"
28 #include "panda/Connection.h"
29 #include "panda/Server.h"
30 #include "panda/ServerSettings.h"
31 #include "panda/StreamerApp.h"
32 #include <memory>
33 
34 
35 namespace ska {
36 namespace cheetah {
37 namespace emulator {
38 class Config;
39 
48 template<typename StreamType, typename T>
49 class Emulator
50 {
51  public:
53 
54  public:
59  template<typename... StreamConstructorArgs>
60  Emulator(Config const&, ModelType* model, StreamConstructorArgs&& ...);
61 
62  ~Emulator();
63 
64  int run();
65  void stop();
66  bool is_running() const;
67 
71  boost::asio::ip::udp::endpoint const end_point() const;
72 
77  boost::asio::ip::udp::endpoint const subscriber_end_point() const;
78 
82  ModelType const& model() const;
83 
84  private:
85  typedef ska::panda::TimedConnection<ska::panda::ConnectionTraits<ska::panda::Udp>> ConnectionType;
86 
87  private:
88  //typedef rcpt::PacketGenerator<ModelType> StreamType;
89 
90  ModelType* _model; // owner
91  StreamType _stream;
92  std::shared_ptr<ConnectionType> _connection;
93  ska::panda::StreamerApp<StreamType> _emulator_app;
94  ska::panda::Server<ska::panda::ServerTraits<ska::panda::Udp>, decltype(_emulator_app)> _server;
95 };
96 
97 
98 } // namespace emulator
99 } // namespace cheetah
100 } // namespace ska
101 #include "detail/Emulator.cpp"
102 
103 #endif // SKA_CHEETAH_EMULATOR_EMULATOR_H
boost::asio::ip::udp::endpoint const end_point() const
the port to where the udp data stream is being directed
Definition: Emulator.cpp:78
Emulator(Config const &, ModelType *model, StreamConstructorArgs &&...)
Construct an Emulator utilisiing the provided model.
Some limits and constants for FLDO.
Definition: Brdz.h:35
Configuration options for the Emulator.
Definition: Config.h:50
boost::asio::ip::udp::endpoint const subscriber_end_point() const
the subscription service listening address
Definition: Emulator.cpp:84
Emulate UDP stream using a data madel generator.
Definition: Emulator.h:49
ModelType const & model() const
return a reference to the model object
Definition: Emulator.cpp:90