From 52e649eb399ca5a5522795652b463d17d59d8f3c Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Tue, 11 Mar 2014 12:21:47 +0000
Subject: [PATCH] Task #5555: Gave generateRSP a log_prop file to prevent
 logging from clobbering the output. For the tests, the -o parameter is used
 instead to circumvent the same issue.

---
 RTCP/Cobalt/InputProc/src/CMakeLists.txt      |  1 +
 .../InputProc/src/Station/generateRSP.cc      |  4 +--
 .../src/Station/generateRSP.log_prop          | 31 +++++++++++++++++++
 RTCP/Cobalt/InputProc/test/t_generateRSP.cc   |  2 +-
 4 files changed, 35 insertions(+), 3 deletions(-)
 create mode 100644 RTCP/Cobalt/InputProc/src/Station/generateRSP.log_prop

diff --git a/RTCP/Cobalt/InputProc/src/CMakeLists.txt b/RTCP/Cobalt/InputProc/src/CMakeLists.txt
index ab2fab41462..c208f074e39 100644
--- a/RTCP/Cobalt/InputProc/src/CMakeLists.txt
+++ b/RTCP/Cobalt/InputProc/src/CMakeLists.txt
@@ -47,6 +47,7 @@ lofar_add_bin_program(printDelays Delays/printDelays.cc)
 # install the logprop file
 install(FILES
   Delays/printDelays.log_prop
+  Station/generateRSP.log_prop
   DESTINATION etc)
 
 configure_file(
diff --git a/RTCP/Cobalt/InputProc/src/Station/generateRSP.cc b/RTCP/Cobalt/InputProc/src/Station/generateRSP.cc
index e981c981c28..b11e6f65da2 100644
--- a/RTCP/Cobalt/InputProc/src/Station/generateRSP.cc
+++ b/RTCP/Cobalt/InputProc/src/Station/generateRSP.cc
@@ -152,8 +152,8 @@ int main(int argc, char **argv)
     RSPPacketFactory packetFactory(inStream, boardMode, subbands);
     RSP packet;
 
-    TimeStamp current(TimeStamp::convert(from, clockmode * 1000000));
-    TimeStamp end(TimeStamp::convert(to, clockmode * 1000000));
+    TimeStamp current(TimeStamp::convert(from, boardMode.clockHz()));
+    TimeStamp end(TimeStamp::convert(to, boardMode.clockHz()));
 
     while(current < end && packetFactory.makePacket(packet, current, boardNr)) {
       // Write packet
diff --git a/RTCP/Cobalt/InputProc/src/Station/generateRSP.log_prop b/RTCP/Cobalt/InputProc/src/Station/generateRSP.log_prop
new file mode 100644
index 00000000000..8ee08f727d7
--- /dev/null
+++ b/RTCP/Cobalt/InputProc/src/Station/generateRSP.log_prop
@@ -0,0 +1,31 @@
+# Note: generateRSP needs to log to stderr, to prevent clobbering its regular
+# output on stdout.
+
+# Configure the loggers
+log4cplus.rootLogger=INFO, STDERR
+log4cplus.logger.TRC=INFO
+
+# prevent debug messages: accept >=WARN only, and don't forward messages to the rootLogger
+log4cplus.logger.LCS.ApplCommon=WARN, STDERR
+log4cplus.additivity.LCS.ApplCommon=false
+log4cplus.logger.LCS.MSLofar=WARN, STDERR
+log4cplus.additivity.LCS.MSLofar=false
+
+# Define the appenders
+log4cplus.appender.STDOUT=log4cplus::ConsoleAppender
+log4cplus.appender.STDOUT.layout=log4cplus::PatternLayout
+log4cplus.appender.STDOUT.layout.ConversionPattern=printDelays@%h %D{%d-%m-%y %H:%M:%S.%q} %-5p %c{3} - %m [%b:%L]%n
+
+log4cplus.appender.STDERR=log4cplus::ConsoleAppender
+log4cplus.appender.STDERR.layout=log4cplus::PatternLayout
+log4cplus.appender.STDERR.layout.ConversionPattern=printDelays@%h %D{%d-%m-%y %H:%M:%S.%q} %-5p %c{3} - %m [%b:%L]%n
+log4cplus.appender.STDERR.logToStdErr=true
+
+#log4cplus.appender.FILE=log4cplus::RollingFileAppender
+#log4cplus.appender.FILE.File=${LOG4CPLUS_LOGFILENAME}.log
+#log4cplus.appender.FILE.MaxFileSize=10MB
+#log4cplus.appender.FILE.MaxBackupIndex=2
+#log4cplus.appender.FILE.layout=log4cplus::PatternLayout
+#log4cplus.appender.FILE.layout.ConversionPattern=rtcp:${MPIRANK}@%h %D{%d-%m-%y %H:%M:%S.%q} %-5p %c{3} - %m [%b:%L]%n
+
+log4cplus.appender.DUMP=log4cplus::NullAppender
diff --git a/RTCP/Cobalt/InputProc/test/t_generateRSP.cc b/RTCP/Cobalt/InputProc/test/t_generateRSP.cc
index 0c748d1b9c5..0bbe4525cb6 100644
--- a/RTCP/Cobalt/InputProc/test/t_generateRSP.cc
+++ b/RTCP/Cobalt/InputProc/test/t_generateRSP.cc
@@ -118,7 +118,7 @@ int main()
         ofstream ascStream(ascFile.c_str());
         generate_input(ascStream, bitMode[b], nrPackets[p], nrSubbands[s]);
 
-        command = str(format("../src/generateRSP -b%d -s%d < %s > %s") % 
+        command = str(format("../src/generateRSP -b%d -s%d < %s -o %s") % 
                       bitMode[b] % nrSubbands[s] % ascFile % rspFile);
         cout << "Executing command: " << command << endl;
         ASSERT(system(command.c_str()) == 0);
-- 
GitLab