diff --git a/Appl/CEP/CS1/CS1_InputSection/src/WH_RSPInput.cc b/Appl/CEP/CS1/CS1_InputSection/src/WH_RSPInput.cc index 2840e79bd515ce678c295785059a0121ff46992b..98822e0ba17e7d2dc82bef5fbe5792d2874f7e32 100644 --- a/Appl/CEP/CS1/CS1_InputSection/src/WH_RSPInput.cc +++ b/Appl/CEP/CS1/CS1_InputSection/src/WH_RSPInput.cc @@ -150,16 +150,20 @@ namespace LOFAR { // determine starttime double startTime = itsPS.getDouble("Observation.StartTime"); - if (startTime > 0) { - double utc = AMC::Epoch(startTime).utc(); - int sampleFreq = itsPS.getInt32("Observation.SampleRate"); - int seconds = (int)floor(utc); - int samples = (int)((utc - seconds) * sampleFreq); - - itsSyncedStamp = TimeStamp(seconds, samples); + double utc = 0; + if (startTime < 60*60*24*32) { + // if starttime is less than a month after the zero point of MJD, + // it is probably not meant as MJD, so take the literal value + // This is needed for test purposes until the RSP-boards use utc. + utc = startTime; } else { - itsSyncedStamp = TimeStamp(0, 0); + utc = AMC::Epoch(startTime).utc(); } + int sampleFreq = itsPS.getInt32("Observation.SampleRate"); + int seconds = (int)floor(utc); + int samples = (int)((utc - floor(utc)) * sampleFreq); + + itsSyncedStamp = TimeStamp(seconds, samples); cout<<"Starting buffer at "<<itsSyncedStamp<<endl;cout.flush(); itsBBuffer->startBufferRead(itsSyncedStamp); @@ -196,7 +200,7 @@ namespace LOFAR { void WH_RSPInput::process() { - cout<<"begin of WH_RSPInput::process"<<endl;cout.flush(); + //cout<<"begin of WH_RSPInput::process"<<endl;cout.flush(); itsProcessTimer->start(); DH_RSP* rspDHp; DH_Delay* delayDHp; @@ -222,7 +226,7 @@ namespace LOFAR { // get the data from the cyclic buffer itsGetElemTimer->start(); - cout<<"reading from buffer"<<endl;cout.flush(); + //cout<<"reading from buffer"<<endl;cout.flush(); itsBBuffer->getElements(subbandbuffer, &flags, @@ -238,13 +242,30 @@ namespace LOFAR { // fill in the data rspDHp->getFlags() = flags; rspDHp->setStationID(itsStationNr); - rspDHp->setTimeStamp(delayedstamp); + rspDHp->setTimeStamp(delayedstamp - itsNHistorySamples); rspDHp->fillExtraData(); rspDHp->setFineDelayAtBegin((*delayDHp)[itsStationNr].fineDelayAtBegin); rspDHp->setFineDelayAfterEnd((*delayDHp)[itsStationNr].fineDelayAfterEnd); +#if 1 + // print flags + cout<<"WH_RSP out "<<itsStationNr<<" "<<delayedstamp<<" output " << output << " flags: "<< flags <<endl; + // printsamples +#if 0 + RectMatrix<DH_RSP::BufferType>* matrix = &rspDHp->getDataMatrix(); + dimType timeDim = matrix->getDim("Times"); + RectMatrix<DH_RSP::BufferType>::cursorType cursor = matrix->getCursor(0 * timeDim); + cout<<"WH_RSP out "<<itsStationNr<<" "<<delayedstamp<<" output " << output << " : "; + MATRIX_FOR_LOOP_PART(*matrix, timeDim, cursor, 10) { + cout << matrix->getValue(cursor); + } + cout<<endl; +#endif +#endif } + + itsSyncedStamp += itsNSamplesPerSec; itsProcessTimer->stop(); while (theirNoAlarms == 0) diff --git a/Appl/CEP/CS1/CS1_InputSection/src/WH_SBCollect.cc b/Appl/CEP/CS1/CS1_InputSection/src/WH_SBCollect.cc index 3bd1d9f5cb2f3744f87b43e670f59b4302a96871..941614c5b1c66d59de5320246ffc7e10c25f231e 100644 --- a/Appl/CEP/CS1/CS1_InputSection/src/WH_SBCollect.cc +++ b/Appl/CEP/CS1/CS1_InputSection/src/WH_SBCollect.cc @@ -96,7 +96,7 @@ namespace LOFAR } void WH_SBCollect::preprocess() { - sleep(60); + sleep(6); if (!theirTimerSet) { #define USE_TIMER 0 #if USE_TIMER @@ -135,11 +135,33 @@ namespace LOFAR // create cursors to incoming data for (unsigned station = 0; station < itsNStations; station++) { inHolders.push_back(dynamic_cast<DH_RSP *>(getDataManager().getInHolder(station))); + inHolders.back()->fillExtraData(); inMatrices.push_back(&(inHolders.back()->getDataMatrix())); dimType inSubbandDim = inMatrices[0]->getDim("Subbands"); inCursors.push_back(inHolders.back()->getDataMatrix().getCursor(0*inSubbandDim)); +#if 1 + // dump the contents of inDH to stdout + DH_RSP* inh = inHolders.back(); + cout << "WH_SBCollect input station "<<inh->getStationID()<<" " << inh->getTimeStamp() + // print flags + << inh->getFlags() <<endl; + // printsamples +#if 0 + RectMatrix<DH_RSP::BufferType>* matrix = &inHolders.back()->getDataMatrix(); + dimType timeDim = matrix->getDim("Times"); + RectMatrix<DH_RSP::BufferType>::cursorType cursor = matrix->getCursor(0 * timeDim); + cout<<"WH_SBCollect output " << " : "; + MATRIX_FOR_LOOP_PART(*matrix, timeDim, cursor, 10) { + cout << matrix->getValue(cursor); + } + cout<<endl; +#endif + cout << "WH_SBCollect input done " << endl; +#endif } + + // Copy every subband to one BG/L core for (unsigned subband = 0; subband < itsNSubbandsPerCell; subband++) { // ask the round robin selector for the next output @@ -159,7 +181,6 @@ namespace LOFAR DH_Subband::DelayIntervalType theDelay = {inHolders[station]->getFineDelayAtBegin(), inHolders[station]->getFineDelayAfterEnd()}; outHolder->getDelay(station) = theDelay; - inHolders[station]->getExtraData(); outHolder->getFlags(station) = inHolders[station]->getFlags(); } outHolder->fillExtraData(); @@ -170,25 +191,25 @@ namespace LOFAR }; // we handled one alarm, so decrease it theirNoAlarms--; +#if 0 + // dump the contents of outDH to stdout + cout << "WH_SBCollect output : " << endl; + dimType outTimeDim = outMatrix->getDim("Time"); + dimType outPolDim = outMatrix->getDim("Polarisation"); + int matrixSize = itsNinputs * + outMatrix->getNElemInDim(outTimeDim) * + outMatrix->getNElemInDim(outPolDim); + + hexdump(outMatrix->getBlock(outMatrix->getCursor(0), + outStationDim, + itsNinputs, + matrixSize), + matrixSize * sizeof(DH_Subband::SampleType)); + cout << "WH_SBCollect output done " << endl; +#endif getDataManager().readyWithOutHolder(getDataManager().getOutputSelector()->getCurrentSelection()); } -#if 0 - // dump the contents of outDH to stdout - cout << "WH_SBCollect output : " << endl; - dimType outTimeDim = outMatrix->getDim("Time"); - dimType outPolDim = outMatrix->getDim("Polarisation"); - int matrixSize = itsNinputs * - outMatrix->getNElemInDim(outTimeDim) * - outMatrix->getNElemInDim(outPolDim); - - hexdump(outMatrix->getBlock(outMatrix->getCursor(0), - outStationDim, - itsNinputs, - matrixSize), - matrixSize * sizeof(DH_Subband::SampleType)); - cout << "WH_SBCollect output done " << endl; -#endif } @@ -210,7 +231,8 @@ namespace LOFAR #endif } } - sleep(10); + cout<<"Sleeping to enable shutdown of threads"<<endl; + sleep(30); } void WH_SBCollect::timerSignal(int sig)