diff --git a/RTCP/Cobalt/OutputProc/src/TBB_Dipole.cc b/RTCP/Cobalt/OutputProc/src/TBB_Dipole.cc index 22fb36254128a5ed91d95a9e366ac900b5102cd6..ea381619d6d4b2467236ebd07f9f4e5d9ed5d9b2 100644 --- a/RTCP/Cobalt/OutputProc/src/TBB_Dipole.cc +++ b/RTCP/Cobalt/OutputProc/src/TBB_Dipole.cc @@ -469,6 +469,50 @@ namespace LOFAR << sliceNr << ", " << itsDumpInfo.itsSliceNr0); + /** + * Now check for even/odd seconds. Why? Because + * sampling frequency / (N * 1024) does not result in an integer without + * rest. So one 1024 slice has to be moved to either ever odd or to + * every even second: + * + * slice #195312 slice #195313 slice #0 + * | | | + * v v v + * 1024 ---------|--------- 1024 --------- |--------- 1024 + * ^ + * | + * A new odd second begins here. + * + * slice #195312 slice #0 slice #1 + * | | | + * v v v + * 1024 ---------|--------- 1024 --------- |--------- 1024 + * ^ + * | + * A new even second begins here. + * + * What does this all mean? + * ------------------------ + * If the time-stamp of the second of the first frame is even then + * the last frame had slice numbers up to #195313. + * The following slice numbers for the next second will only go up to + * #195312. + * - Check if the frame #0's second is even, then + * - check if the second of the current frame is odd. + * - Both yes: means that we have to add one sample to the offset. + */ + if((itsDumpInfo.itsTime0 % 2 == 0) && (frame.header.time % 2 == 1)) + { + offset += 1; + LOG_INFO_STR("TBB: Added one sample to the offset because t0 is " + "even and t_now is odd: itsDumpInfo.itsTime0 = " + << itsDumpInfo.itsTime0 + << ", frame.header.time = " + << frame.header.time + << ", offset = " + << offset); + } + /** * Flag lost frame(s) (assumes no out-of-order). * Assumes all frames (except maybe the last) have the same nr of samples (fine).