Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
PacketGenerator.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_RCPT_LOW_PACKETGENERATOR_H
25 #define SKA_CHEETAH_RCPT_LOW_PACKETGENERATOR_H
26 #include "cheetah/rcpt_low/BeamFormerPacket.h"
27 #include "cheetah/rcpt_low/PacketGeneratorConfig.h"
28 #include "cheetah/data/TimeFrequency.h"
29 #include "panda/Buffer.h"
30 #include "panda/Engine.h"
31 #include <type_traits>
32 #include <vector>
33 
34 namespace ska {
35 namespace cheetah {
36 namespace rcpt_low {
37 
46 template<class DataGenerator>
48 {
49  public:
50  typedef int8_t SampleDataType;
53  typedef boost::units::quantity<ska::cheetah::data::Seconds, double> TimeType;
54  typedef boost::units::quantity<ska::cheetah::data::MegaHertz, double> FrequencyType;
55 
56  public:
57  PacketGenerator(DataGenerator& model, PacketGeneratorConfig const& config);
58 
59  ~PacketGenerator();
60 
65  template<typename Handler>
66  void send_one(Handler&&);
67 
68  ska::panda::Buffer<char> next();
69 
71  std::chrono::microseconds interval() const;
72 
73  void abort();
74 
75  private:
77  typedef decltype(std::declval<Packet>().packet_count()) CounterType;
78 
79  DataGenerator& _model; // The data generation model
80  DataType _data;
81  DataType::ConstIterator _data_iterator;
82  CounterType _counter;
83  std::chrono::microseconds _interval; // The interval between packets in microsec.
84 
85  const std::size_t _max_buffers;
86  std::size_t _buffer_index;
87  std::vector<ska::panda::Buffer<char>> _buffers;
88  ska::panda::Engine _engine;
89  ska::cheetah::utils::ModifiedJulianClock::time_point _timestamp;
90  TimeType _tsamp;
91  std::size_t _number_of_samples_per_packet;
92  std::size_t _number_of_channels_per_packet;
93  FrequencyType _bandwidth;
94  FrequencyType _fch1;
95 
96 };
97 
98 } // namespace rcpt_low
99 } // namespace cheetah
100 } // namespace ska
101 #include "cheetah/rcpt_low/detail/PacketGenerator.cpp"
102 
103 #endif // SKA_CHEETAH_RCPT_LOW_PACKETGENERATOR_H
Interface to packing/unpacking rcpt from the BeamFormer rcpt stream UDP packet.
std::chrono::microseconds interval() const
The interval between packets in microsec.
void send_one(Handler &&)
send out a single packet
The incoming RF signal sample from the UDP stream.
Definition: PacketSample.h:42
Packs data into a UDP stream Packet Header format of the BeamFormer.
Some limits and constants for FLDO.
Definition: Brdz.h:35
Configuration for the packet generator to the time seperation of the packets.