From bae7b5c68d27609f72f9139db5b8353a559c3f3d Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Fri, 19 Apr 2013 14:10:34 +0000 Subject: [PATCH] Task #3696: Added generate/capture programs for performance testing --- RTCP/Cobalt/InputProc/src/Station/capture.cc | 70 +++++++++++++++++++ RTCP/Cobalt/InputProc/src/Station/generate.cc | 68 ++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 RTCP/Cobalt/InputProc/src/Station/capture.cc create mode 100644 RTCP/Cobalt/InputProc/src/Station/generate.cc diff --git a/RTCP/Cobalt/InputProc/src/Station/capture.cc b/RTCP/Cobalt/InputProc/src/Station/capture.cc new file mode 100644 index 00000000000..aad8c5145bf --- /dev/null +++ b/RTCP/Cobalt/InputProc/src/Station/capture.cc @@ -0,0 +1,70 @@ +//# capture.cc: Capture data from a single station. +//# Copyright (C) 2012-2013 ASTRON (Netherlands Institute for Radio Astronomy) +//# P.O. Box 2, 7990 AA Dwingeloo, The Netherlands +//# +//# This file is part of the LOFAR software suite. +//# The LOFAR software suite is free software: you can redistribute it and/or +//# modify it under the terms of the GNU General Public License as published +//# by the Free Software Foundation, either version 3 of the License, or +//# (at your option) any later version. +//# +//# The LOFAR software suite is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License along +//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. +//# +//# $Id$ + +#include <lofar_config.h> + +#include <string> +#include <vector> +#include <omp.h> + +#include <Common/LofarLogger.h> +#include <CoInterface/Stream.h> + +#include <InputProc/Station/PacketsToBuffer.h> + +using namespace LOFAR; +using namespace Cobalt; +using namespace std; + +int main( int argc, char **argv ) +{ + INIT_LOGGER( "capture" ); + + omp_set_nested(true); + omp_set_num_threads(16); + + if (argc < 3) { + cerr << "Syntax: capture stationname stream [stream] ..." << endl; + exit(1); + } + + const string stationName = argv[1]; + + vector< SmartPtr<Stream> > inputStreams; + for (int i = 2; i < argc; ++i) { + const string desc = argv[i]; + + LOG_INFO_STR("Connecting to " << desc); + inputStreams.push_back(createStream(desc, true)); + LOG_INFO_STR("Connected."); + } + + // Fill a BufferSettings object + struct StationID stationID(stationName, "LBA", 200, 16); + struct BufferSettings settings(stationID, false); + + MultiPacketsToBuffer mpb(settings, inputStreams); + + mpb.process(); + + return 0; +} + + diff --git a/RTCP/Cobalt/InputProc/src/Station/generate.cc b/RTCP/Cobalt/InputProc/src/Station/generate.cc new file mode 100644 index 00000000000..0e42a9e81af --- /dev/null +++ b/RTCP/Cobalt/InputProc/src/Station/generate.cc @@ -0,0 +1,68 @@ +//# generator.cc: Generates fake data resembling a single station. +//# Copyright (C) 2012-2013 ASTRON (Netherlands Institute for Radio Astronomy) +//# P.O. Box 2, 7990 AA Dwingeloo, The Netherlands +//# +//# This file is part of the LOFAR software suite. +//# The LOFAR software suite is free software: you can redistribute it and/or +//# modify it under the terms of the GNU General Public License as published +//# by the Free Software Foundation, either version 3 of the License, or +//# (at your option) any later version. +//# +//# The LOFAR software suite is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License along +//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. +//# +//# $Id$ + +#include <lofar_config.h> + +#include <string> +#include <vector> +#include <omp.h> + +#include <Common/LofarLogger.h> +#include <CoInterface/Stream.h> + +#include <InputProc/Station/PacketFactory.h> +#include <InputProc/Station/Generator.h> + +using namespace LOFAR; +using namespace Cobalt; +using namespace std; + +int main( int argc, char **argv ) +{ + INIT_LOGGER( "generator" ); + + omp_set_nested(true); + omp_set_num_threads(16); + + if (argc < 3) { + cerr << "Syntax: generator stationname stream [stream] ..." << endl; + exit(1); + } + + const string stationName = argv[1]; + vector< SmartPtr<Stream> > outputStreams; + for (int i = 2; i < argc; ++i) { + const string desc = argv[i]; + + LOG_INFO_STR("Connecting to " << desc); + outputStreams.push_back(createStream(desc, false)); + LOG_INFO_STR("Connected."); + } + + struct StationID stationID(stationName, "LBA", 200, 16); + struct BufferSettings settings(stationID, false); + + PacketFactory factory(settings); + Generator g(settings, outputStreams, factory); + + // Generate packets + g.process(); +} + -- GitLab