diff --git a/LCS/Stream/include/Stream/FileStream.h b/LCS/Stream/include/Stream/FileStream.h index 9af3c751064f3e14349c18806dbc8187c2bfdd5d..ee2cb7f3eebd57d7724cfba9a046467e5cdaf85c 100644 --- a/LCS/Stream/include/Stream/FileStream.h +++ b/LCS/Stream/include/Stream/FileStream.h @@ -39,6 +39,8 @@ class FileStream : public FileDescriptorBasedStream virtual ~FileStream(); virtual void skip( size_t bytes ); // seek ahead + + virtual size_t size(); // return file size }; } // namespace LOFAR diff --git a/LCS/Stream/src/FileStream.cc b/LCS/Stream/src/FileStream.cc index 55951be3874a77c89cd57fa9ddfb2f7c794133c1..b28d0bf11e9af20c0a7475d30acb07975a898a25 100644 --- a/LCS/Stream/src/FileStream.cc +++ b/LCS/Stream/src/FileStream.cc @@ -68,4 +68,18 @@ void FileStream::skip(size_t bytes) throw SystemCallException("lseek", errno, THROW_ARGS); } +size_t FileStream::size() +{ + // lseek returning -1 can be either an error, or theoretically, + // a valid new file position. To make sure, we need to + // clear and check errno. + errno = 0; + off_t pos = lseek(fd, 0, SEEK_END); + + if (pos == (off_t)-1 && errno) + throw SystemCallException("lseek", errno, THROW_ARGS); + + return pos; +} + } // namespace LOFAR diff --git a/RTCP/Run/src/RTCP.parset b/RTCP/Run/src/RTCP.parset index f5736b4a3ec1afa1207368e2e38f2f054a016d5a..528a67bc22bc12699ff74ca69d4750820b9cd548 100644 --- a/RTCP/Run/src/RTCP.parset +++ b/RTCP/Run/src/RTCP.parset @@ -33,7 +33,7 @@ OLAP.nrTimesInFrame = 16 # [ 3*(0;1;2;3) ] --> [ 0,1,2,3,0,1,2,3,0,1,2,3 ] # [ 3*(300..303) ] --> [ 300,301,302,303,300,301,302,303,300,301,302,303 ] # [ 2*(5*0) ] --> [ 0,0,0,0,0,0,0,0,0,0 ] -Observation.subbandList = [100..159] +Observation.subbandList = [100..110] Observation.sampleClock = 200 Observation.nrBitsPerSample = 16 @@ -68,8 +68,8 @@ Observation.Beam[0].TiedArrayBeam[0].coherent = T OLAP.Storage.hosts = [locus095] OLAP.Storage.targetDirectory = /data # will be appended with dirmask and filenammask -Observation.DataProducts.Output_Beamformed.enabled = T -Observation.DataProducts.Output_Correlated.enabled = F +Observation.DataProducts.Output_Beamformed.enabled = F +Observation.DataProducts.Output_Correlated.enabled = T Observation.DataProducts.Output_Trigger.enabled = F Observation.DataProducts.Output_Correlated.namemask = L${OBSID}_SB${SUBBAND}_uv.MS diff --git a/RTCP/Storage/include/Storage/MSWriter.h b/RTCP/Storage/include/Storage/MSWriter.h index 7325afcd627801b7a57a33da852585813c87935e..dbe0a337c26bafff0b6a6ee9d9d43ed86f96eb81 100644 --- a/RTCP/Storage/include/Storage/MSWriter.h +++ b/RTCP/Storage/include/Storage/MSWriter.h @@ -37,6 +37,8 @@ class MSWriter virtual ~MSWriter(); virtual void write(StreamableData *) = 0; + + virtual size_t getDataSize(); }; diff --git a/RTCP/Storage/include/Storage/MSWriterFile.h b/RTCP/Storage/include/Storage/MSWriterFile.h index 4bb460c40a3218fb11ad0f849f86f926d57f9406..8dab0423c5e435352561ce00d64da5cb667b821c 100644 --- a/RTCP/Storage/include/Storage/MSWriterFile.h +++ b/RTCP/Storage/include/Storage/MSWriterFile.h @@ -43,6 +43,8 @@ class MSWriterFile : public MSWriter virtual void write(StreamableData *data); + virtual size_t getDataSize(); + protected: FastFileStream itsFile; }; diff --git a/RTCP/Storage/src/FastFileStream.cc b/RTCP/Storage/src/FastFileStream.cc index a729625e346b5ced802fe9d9b4a0bae4eb3b7096..690cf3a660b3ec792f97589a0903fd38a872f725 100644 --- a/RTCP/Storage/src/FastFileStream.cc +++ b/RTCP/Storage/src/FastFileStream.cc @@ -199,6 +199,24 @@ void FastFileStream::skip(size_t bytes) } +size_t FastFileStream::size() +{ + // size we might have skip()ed and have some remaining data to write, + // we cannot rely on FileStream::size(), which would report the current + // file size, without skips or remainders in our buffer. + + errno = 0; + + off_t curlen = lseek(fd, 0, SEEK_CUR); // NOT SEEK_END, because skip() might push us beyond the end + + // lseek can return -1 as a valid file position, so check errno as well + if (curlen == (off_t)-1 && errno) + throw SystemCallException("lseek", errno, THROW_ARGS); + + return curlen + remainder; +} + + } // namespace RTCP } // namespace LOFAR diff --git a/RTCP/Storage/src/MSWriter.cc b/RTCP/Storage/src/MSWriter.cc index 5bca78c597bcda6c975c23bccc2b5af5de64370a..040c1926b02572bbd058444197f1ee4852080003 100644 --- a/RTCP/Storage/src/MSWriter.cc +++ b/RTCP/Storage/src/MSWriter.cc @@ -35,6 +35,11 @@ MSWriter::~MSWriter() { } +size_t MSWriter::getDataSize() +{ + return 0; +} + } } diff --git a/RTCP/Storage/src/MSWriterFile.cc b/RTCP/Storage/src/MSWriterFile.cc index fa5bf92aaebd7b60902e7c8e166463cf3f5ee509..ed3a8ee5f627d96ea3782972e26c184610d438f9 100644 --- a/RTCP/Storage/src/MSWriterFile.cc +++ b/RTCP/Storage/src/MSWriterFile.cc @@ -50,6 +50,12 @@ void MSWriterFile::write(StreamableData *data) } +size_t MSWriterFile::getDataSize() +{ + return itsFile.size(); +} + + } // namespace RTCP } // namespace LOFAR diff --git a/RTCP/Storage/src/OutputThread.cc b/RTCP/Storage/src/OutputThread.cc index 4db95d83ab3186674430ae8e21eaef1e8ce02947..2fcf9ea4247f6c6011f35fdbf3e0e171a814576a 100644 --- a/RTCP/Storage/src/OutputThread.cc +++ b/RTCP/Storage/src/OutputThread.cc @@ -321,6 +321,25 @@ void OutputThread::cleanUp() unsigned percent_written = roundedPercentage(itsBlocksWritten, itsNrExpectedBlocks); LOG_INFO_STR(itsLogPrefix << "Finished writing: " << itsBlocksWritten << " blocks written (" << percent_written << "%), " << itsBlocksDropped << " blocks dropped: " << std::setprecision(3) << dropPercent << "% lost" ); + + // log some final characteristics for CEPlogProcessor for feedback to MoM/LTA + switch (itsOutputType) { + case CORRELATED_DATA: + { + LOG_INFO_STR(itsLogPrefix << "Final characteristics: " + << ", duration " << setprecision(8) << itsNextSequenceNumber * itsParset.IONintegrationTime() << " s" + << ", size " << itsWriter->getDataSize() << " bytes" + ); + } + break; + case BEAM_FORMED_DATA: + itsNrExpectedBlocks = itsParset.nrBeamFormedBlocks(); + break; + + default: + break; + } +} }