Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
BeamFormerPacket.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_DATA_BEAMFORMERPACKET_H
25 #define SKA_CHEETAH_DATA_BEAMFORMERPACKET_H
26 
27 #include "cheetah/rcpt/Sample.h"
28 #include <boost/endian/arithmetic.hpp>
29 #include <cstdlib>
30 #include <cstdint>
31 
32 namespace ska {
33 namespace cheetah {
34 namespace rcpt {
35 
44 enum class PacketType { StokesI = 1U, StokesQ, StokesRe, StokesIm, AntennaCount };
45 
46 template<std::size_t PayloadSize=8192>
48 {
49  private:
50  static constexpr std::size_t _payload_size = PayloadSize;
51 
52  public:
55 
56 
60  constexpr static std::size_t header_size();
61 
65  constexpr static std::size_t footer_size();
66 
70  constexpr static std::size_t payload_size();
71 
75  constexpr static std::size_t number_of_samples();
76 
80  static std::size_t number_of_channels();
81 
85  constexpr static std::size_t size();
86 
92  void packet_count(uint64_t);
93 
97  void packet_type(PacketType const);
98 
102  PacketType packet_type() const;
103 
107  uint64_t packet_count() const;
108 
112  void insert(std::size_t sample_number, Sample s);
113 
117  Sample const& sample(std::size_t sample) const;
118 
119  const Sample* begin() const;
120  const Sample* end() const;
121 
125  static constexpr uint64_t max_sequence_number();
126 
130  uint16_t first_channel_number() const;
131  void first_channel_number(uint16_t number);
132 
133  private:
134  struct Header {
135  boost::endian::little_uint64_t _counter; // little endian counter of 8 bytes
136  boost::endian::little_uint32_t _timestamp_seconds; // seconds counter of 4 bytes
137  boost::endian::little_uint32_t _timestamp_nanoseconds; // nanaoseconds counter of 4 bytes
138  boost::endian::little_uint16_t _beam_number;
139  boost::endian::little_uint16_t _first_channel_number;
140  boost::endian::little_uint16_t _number_of_channels;
141  uint8_t _beamformer_version;
142  boost::endian::little_uint16_t _sample_count_type_5;
143  uint8_t _integration_time; // in number of samples
144  uint8_t _band_number;
145  uint8_t _packet_type; // 0 = invalid,, 1-4 stokes parameters, 5 = antennna count
146  uint8_t _reserved[4];
147  } _header;
148 
149  Sample _data[_payload_size/sizeof(Sample)];
150 
151 /*
152  struct Footer {
153  }; // _footer;
154 */
155  static const std::size_t _number_of_samples= _payload_size/sizeof(Sample);
156  static const std::size_t _size = _payload_size + sizeof(Header);
157  //static const std::size_t _size = _payload_size + sizeof(Header) + sizeof(Footer); // use if Footer exists
158 };
159 
160 static constexpr unsigned low_payload_size = 8192;
161 static constexpr unsigned mid_payload_size = 4096;
164 
165 
166 } // namespace rcpt
167 } // namespace cheetah
168 } // namespace ska
169 #include "cheetah/rcpt/detail/BeamFormerPacket.cpp"
170 
171 #endif // SKA_CHEETAH_DATA_BEAMFORMERPACKET_H
Some limits and constants for FLDO.
Definition: Brdz.h:35
THe incoming RF signal sample from the UDP stream.
Definition: Sample.h:41