Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
BeamFormerDataTraitsTest.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_low/test/BeamFormerDataTraitsTest.h"
25 #include "cheetah/rcpt_low/BeamFormerPacket.h"
26 #include "cheetah/rcpt_low/BeamFormerDataTraits.h"
27 #include "panda/concepts/ChunkerContextDataTraitsConcept.h"
28 #include <vector>
29 
30 
31 namespace ska {
32 namespace cheetah {
33 namespace rcpt_low {
34 namespace test {
35 
36 
37 BeamFormerDataTraitsTest::BeamFormerDataTraitsTest()
38  : ::testing::Test()
39 {
40 }
41 
42 BeamFormerDataTraitsTest::~BeamFormerDataTraitsTest()
43 {
44 }
45 
46 void BeamFormerDataTraitsTest::SetUp()
47 {
48 }
49 
50 void BeamFormerDataTraitsTest::TearDown()
51 {
52 }
53 
54 TEST_F(BeamFormerDataTraitsTest, test_packets_per_chunk)
55 {
56  BOOST_CONCEPT_ASSERT((panda::ChunkerContextDataTraitsConcept<BeamFormerDataTraits<int8_t,128,9>>));
57 
58  typedef BeamFormerDataTraitsLow::DataType DataType;
59  //std::size_t samples_per_packet = BeamFormerDataTraits<int8_t,128,8>::PacketInspector::Packet::number_of_samples();
60  BeamFormerDataTraitsLow traits;
61  {
62  // number_of_channels == payload size
63  data::DimensionSize<data::Frequency> number_of_channels(9);
64  data::DimensionSize<data::Time> number_of_time_samples(128);
65 
66  DataType data(number_of_time_samples, number_of_channels);
67  unsigned packets_per_chunk = (4*traits.chunk_size(data))/(traits.data_size());
68  ASSERT_EQ(1, packets_per_chunk);
69  }
70 }
71 
72 struct TestContext {
73  public:
74  TestContext()
75  : _data(new data::TimeFrequency<Cpu, uint8_t>(data::DimensionSize<data::Time>(128), data::DimensionSize<data::Frequency>(9)))
76  {}
77 
78  std::size_t offset() const { return 0; }
79  std::size_t packet_offset() const { return 0; }
80  data::TimeFrequency<Cpu, uint8_t>& chunk() { return *_data; }
81  //TestContext& next() { _next.reset(new TestContext()); return *_next; }
82  std::size_t size() const { return 2; }
83 
84  uint64_t sequence_number(BeamFormerDataTraits<int8_t,128,8>::PacketInspector const& packet) const { return packet.sequence_number();}
85 
86  private:
87  std::shared_ptr<data::TimeFrequency<Cpu, uint8_t>> _data;
88  std::shared_ptr<TestContext> _next;
89 };
90 
91 std::ostream& operator<<(std::ostream& os, TestContext const&) { return os; }
92 
93 TEST_F(BeamFormerDataTraitsTest, test_deserialise)
94 {
95  // basic compile test
96  BeamFormerPacketLow packet;
97  packet.packet_count(0);
98  packet.packet_type(BeamFormerPacketLow::PacketType::PssLow);
100  TestContext context;
101  dt.deserialise_packet(context, packet);
102 }
103 
104 
105 } // namespace test
106 } // namespace rcpt_low
107 } // namespace cheetah
108 } // namespace ska
Interface to packing/unpacking rcpt from the BeamFormer rcpt stream UDP packet.
void packet_count(PacketNumberType)
set the counter in the header
PacketNumberType sequence_number() const
return the sequence number embedded in the packet
Some limits and constants for FLDO.
Definition: Brdz.h:35
void packet_type(PacketType const)
set the type of packet
Traits describing the BeamFormer Data Stream to the panda::PacketSream system.
static void deserialise_packet(ContextType &context, PacketInspector const &)
function responsible for transfering data from the packet in to the data structure ...
BeamFormerPacket inspection and data extraction.