From eda405d1e9f9d341a8534558518967489bbbc971 Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Thu, 6 Dec 2012 13:03:23 +0000
Subject: [PATCH] Task #3696: Added tSampleBuffer

---
 .gitattributes                       |  1 +
 RTCP/InputProc/test/CMakeLists.txt   |  1 +
 RTCP/InputProc/test/tSampleBuffer.cc | 64 ++++++++++++++++++++++++++++
 3 files changed, 66 insertions(+)
 create mode 100644 RTCP/InputProc/test/tSampleBuffer.cc

diff --git a/.gitattributes b/.gitattributes
index 4b9e62c211c..68bbd525094 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -3653,6 +3653,7 @@ RTCP/InputProc/test/CMakeLists.txt -text
 RTCP/InputProc/test/tGenerator.cc -text
 RTCP/InputProc/test/tRSPTimeStamp2.cc -text
 RTCP/InputProc/test/tRanges.cc -text
+RTCP/InputProc/test/tSampleBuffer.cc -text
 RTCP/InputProc/test/tSharedMemory.cc -text
 RTCP/Interface/include/Interface/BGPAsm.h -text
 RTCP/Interface/include/Interface/BeamCoordinates.h -text
diff --git a/RTCP/InputProc/test/CMakeLists.txt b/RTCP/InputProc/test/CMakeLists.txt
index fd7cf58f1b1..557f5d27feb 100644
--- a/RTCP/InputProc/test/CMakeLists.txt
+++ b/RTCP/InputProc/test/CMakeLists.txt
@@ -8,4 +8,5 @@ include_directories(${PACKAGE_SOURCE_DIR}/src)
 lofar_add_test(tGenerator tGenerator.cc)
 lofar_add_test(tRSPTimeStamp2 tRSPTimeStamp2.cc)
 lofar_add_test(tRanges tRanges.cc)
+lofar_add_test(tSampleBuffer tSampleBuffer.cc)
 lofar_add_test(tSharedMemory tSharedMemory.cc)
diff --git a/RTCP/InputProc/test/tSampleBuffer.cc b/RTCP/InputProc/test/tSampleBuffer.cc
new file mode 100644
index 00000000000..ad254869c12
--- /dev/null
+++ b/RTCP/InputProc/test/tSampleBuffer.cc
@@ -0,0 +1,64 @@
+#include <lofar_config.h>
+#include "SampleBuffer.h"
+#include "SampleType.h"
+#include "OMPThread.h"
+#include <Common/LofarLogger.h>
+#include <vector>
+#include <string>
+#include "omp.h"
+
+using namespace LOFAR;
+using namespace RTCP;
+using namespace std;
+
+// Duration of the test (seconds)
+#define DURATION 2
+
+// The number of packets to transmit (note: there are 16 time samples/packet)
+#define NUMPACKETS (200000000/1024/16)
+
+template<typename T> void test( struct BufferSettings &settings )
+{
+  SampleBuffer< SampleType<T> > buffer_create(settings, true);
+
+  SampleBuffer< SampleType<T> > buffer_read(settings, false);
+}
+
+
+int main( int, char **argv ) {
+  INIT_LOGGER( argv[0] );
+
+  // Don't run forever if communication fails for some reason
+  alarm(10);
+
+  omp_set_nested(true);
+  omp_set_num_threads(16);
+
+  OMPThread::init();
+
+  unsigned clock = 200 * 1000 * 1000;
+  struct StationID stationID("RS106", "LBA", clock, 16);
+  struct BufferSettings settings;
+
+  settings.station = stationID;
+  settings.nrBeamlets = 61;
+  settings.nrBoards = 1;
+
+  settings.nrSamples = (2 * stationID.clock / 1024);// & ~0xFL;
+  settings.nrFlagRanges = 64;
+
+  settings.dataKey = 0x12345678;
+
+  LOG_INFO("Test 16-bit complex");
+  test<i16complex>(settings);
+
+  LOG_INFO("Test 8-bit complex");
+  test<i8complex>(settings);
+
+  LOG_INFO("Test 4-bit complex");
+  test<i4complex>(settings);
+
+
+  return 0;
+}
+
-- 
GitLab