Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
BeamFormerPacket.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/BeamFormerPacket.h"
25 #include <cassert>
26 
27 
28 namespace ska {
29 namespace cheetah {
30 namespace rcpt {
31 
32 template<std::size_t PayloadSize>
34 {
35  return sizeof(Header);
36 }
37 
38 template<std::size_t PayloadSize>
40 {
41  //return sizeof(Footer);
42  return 0;
43 }
44 
45 template<std::size_t PayloadSize>
47 {
48  return _payload_size;
49 }
50 
51 template<std::size_t PayloadSize>
53 {
54  return _number_of_samples;
55 }
56 
57 template<std::size_t PayloadSize>
58 constexpr std::size_t BeamFormerPacket<PayloadSize>::size()
59 {
60  return _size;
61 }
62 
63 template<std::size_t PayloadSize>
65 {
66  return 0xffffffffffffff;
67 }
68 
69 template<std::size_t PayloadSize>
71 {
72 }
73 
74 template<std::size_t PayloadSize>
76 {
77 }
78 
79 template<std::size_t PayloadSize>
81 {
82  return _number_of_samples;
83 }
84 
85 template<std::size_t PayloadSize>
87 {
88  _header._counter = static_cast<boost::endian::little_uint64_t>(packet_count);
89 }
90 
91 template<std::size_t PayloadSize>
92 void BeamFormerPacket<PayloadSize>::packet_type(PacketType const type)
93 {
94  _header._packet_type = static_cast<uint8_t>(type);
95 }
96 
97 template<std::size_t PayloadSize>
99 {
100  return static_cast<PacketType>(_header._packet_type);
101 }
102 
103 template<std::size_t PayloadSize>
105 {
106  return static_cast<uint64_t>(_header._counter);
107  //uint64_t counter = (*((uint64_t *) _header._counter));
108  //return counter;
109 }
110 
111 template<std::size_t PayloadSize>
112 void BeamFormerPacket<PayloadSize>::insert(std::size_t sample_number, Sample s)
113 {
114  assert(sample_number < number_of_samples());
115  _data[sample_number] = std::move(s); // seems to be faster than using std::swap
116 }
117 
118 template<std::size_t PayloadSize>
119 Sample const& BeamFormerPacket<PayloadSize>::sample(std::size_t sample_number) const
120 {
121  return _data[sample_number];
122 }
123 
124 template<std::size_t PayloadSize>
126 {
127  return &_data[0];
128 }
129 
130 template<std::size_t PayloadSize>
132 {
133  return &_data[_payload_size/sizeof(Sample)];
134 }
135 
136 template<std::size_t PayloadSize>
138 {
139  return static_cast<uint16_t>(_header._first_channel_number);
140 }
141 
142 template<std::size_t PayloadSize>
144 {
145  _header._first_channel_number = static_cast<boost::endian::little_uint16_t>(number);
146 }
147 
148 } // namespace rcpt
149 } // namespace cheetah
150 } // namespace ska
static constexpr std::size_t header_size()
the total size of the udp packets header
Sample const & sample(std::size_t sample) const
return the named sample
PacketType packet_type() const
retunr the packet type
uint16_t first_channel_number() const
the number of the fitst channel in the packet
static constexpr std::size_t size()
the total size of the packet (header + payload + footer)
Some limits and constants for FLDO.
Definition: Brdz.h:35
static constexpr std::size_t footer_size()
the total size of the udp packets footer
void insert(std::size_t sample_number, Sample s)
insert a sample
uint64_t packet_count() const
get the counter info from header
THe incoming RF signal sample from the UDP stream.
Definition: Sample.h:41
static std::size_t number_of_channels()
the total number of frequencey channels in the rcpt payload
static constexpr std::size_t payload_size()
the total size in bytes of the channel rcpt
static constexpr std::size_t number_of_samples()
the total number of samples in the rcpt payload
static constexpr uint64_t max_sequence_number()
return the maximum value the packet_count can take