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_PACKETGENERATOR_H
25 #define SKA_CHEETAH_RCPT_PACKETGENERATOR_H
26 #include "cheetah/rcpt/BeamFormerPacket.h"
27 #include "cheetah/rcpt/BeamFormerDataTraits.h"
28 #include "panda/Buffer.h"
29 #include "panda/Engine.h"
30 #include <type_traits>
31 #include <vector>
32 
33 namespace ska {
34 namespace cheetah {
35 namespace rcpt {
36 
45 template<class DataGenerator>
47 {
48  public:
49  typedef BeamFormerDataTraits::DataType::NumericalRep SampleDataType;
50 
51  public:
52  PacketGenerator(DataGenerator& model
53  ,data::DimensionSize<data::Frequency> number_of_channels
54  ,data::DimensionSize<data::Time> number_of_time_samples = data::DimensionSize<data::Time>(100U)
55  );
56  ~PacketGenerator();
57 
62  template<typename Handler>
63  void send_one(Handler&&);
64 
65  ska::panda::Buffer<char> next();
66  long interval() const;
67  void abort();
68 
69  private:
71  typedef decltype(std::declval<Packet>().packet_count()) CounterType;
72 
73  DataGenerator& _model; // The data generation model
74  typename BeamFormerDataTraits::DataType _data;
75  typename BeamFormerDataTraits::DataType::ConstIterator _data_iterator;
76  CounterType _counter; // (6-Byte) packet counter.
77  long _interval; // The interval between packets in microsec.
78 
79  const std::size_t _max_buffers;
80  std::size_t _buffer_index;
81  std::vector<ska::panda::Buffer<char>> _buffers;
82  ska::panda::Engine _engine;
83 };
84 
85 
86 } // namespace rcpt
87 } // namespace cheetah
88 } // namespace ska
89 #include "cheetah/rcpt/detail/PacketGenerator.cpp"
90 
91 #endif // SKA_CHEETAH_RCPT_PACKETGENERATOR_H
Packs data into a UDP stream Packet Header format of the BeamFormer.
void send_one(Handler &&)
send out a single packet
Some limits and constants for FLDO.
Definition: Brdz.h:35
PacketGenerator(DataGenerator &model, data::DimensionSize< data::Frequency > number_of_channels, data::DimensionSize< data::Time > number_of_time_samples=data::DimensionSize< data::Time >(100U))