@@ -87,11 +87,8 @@ mRunning = false;
8787void StfInputInterface::StfReceiverThread ()
8888{
8989 using namespace std ::chrono_literals;
90- constexpr std::uint32_t cInvalidStfId = ~0 ;
9190 std::vector<FairMQMessagePtr> lReadoutMsgs;
9291 lReadoutMsgs.reserve (4096 );
93- // current TF Id
94- std::uint32_t lCurrentStfId = cInvalidStfId;
9592
9693 // Reference to the input channel
9794 auto & lInputChan = mDevice .GetChannel (mDevice .getInputChannelName ());
@@ -104,19 +101,18 @@ void StfInputInterface::StfReceiverThread()
104101 lReadoutMsgs.clear ();
105102
106103 // receive readout messages
107- const std::int64_t lRet = lInputChan.Receive (lReadoutMsgs);
104+ const std::int64_t lRet = lInputChan.Receive (lReadoutMsgs, 100 );
108105
109106 // timeout ok
110107 if (lRet == static_cast <int64_t >(fair::mq::TransferCode::timeout)) {
111108 continue ;
112109 }
113-
114110 // interrupted
115111 if (lRet == static_cast <int64_t >(fair::mq::TransferCode::interrupted)) {
116112 if (mAcceptingData ) {
117113 IDDLOG_RL (1000 , " READOUT INTERFACE: Receive failed. FMQ state interrupted." );
118114 }
119- std::this_thread::sleep_for (10ms );
115+ std::this_thread::sleep_for (100ms );
120116 continue ;
121117 }
122118
@@ -160,37 +156,22 @@ void StfInputInterface::StfReceiverThread()
160156
161157 // check for backward/forward tf jumps
162158 if (mBuildStf ) {
163- if (lCurrentStfId != cInvalidStfId) {
164- static std::uint64_t sNumNonContIncStfs = 0 ;
165- static std::uint64_t sNumNonContDecStfs = 0 ;
166-
167- // backward jump
168- if (lReadoutHdr.mTimeFrameId < lCurrentStfId) {
169- sNumNonContIncStfs ++;
170- std::stringstream lErrMsg;
171- lErrMsg << " READOUT INTERFACE: "
172- " TF ID decreased! (" << lCurrentStfId << " ) -> (" << lReadoutHdr.mTimeFrameId << " ) "
173- " o2-readout-exe sent messages with non-monotonic TF id! SubTimeFrames will be incomplete! "
174- " Total occurrences: " << sNumNonContIncStfs ;
175-
176- EDDLOG_RL (200 , lErrMsg.str ());
177- DDDLOG (lErrMsg.str ());
178-
179- // TODO: accout for lost data
180- continue ;
181- }
182-
183- // forward jump
184- if (lReadoutHdr.mTimeFrameId > (lCurrentStfId + 1 )) {
185- sNumNonContDecStfs ++;
186- WDDLOG_RL (200 , " READOUT INTERFACE: TF ID non-contiguous increase! ({}) -> ({}). Total occurrences: {}" ,
187- lCurrentStfId, lReadoutHdr.mTimeFrameId , sNumNonContDecStfs );
188- }
159+ // backward jump
160+ if (lReadoutHdr.mTimeFrameId < mStfIdReceiving ) {
161+ EDDLOG_RL (1000 , " READOUT INTERFACE: STF ID decreased, data cannot be aggregated! {} -> {}" ,
162+ mStfIdReceiving , lReadoutHdr.mTimeFrameId );
163+ continue ;
164+ }
165+
166+ // forward jump
167+ if (lReadoutHdr.mTimeFrameId > (mStfIdReceiving + 1 )) {
168+ WDDLOG_RL (1000 , " READOUT INTERFACE: Non-contiguous increase of STF ID! {} -> {}" ,
169+ mStfIdReceiving , lReadoutHdr.mTimeFrameId );
189170 // we keep the data since this might be a legitimate jump
190171 }
191172
192173 // get the current TF id
193- lCurrentStfId = lReadoutHdr.mTimeFrameId ;
174+ mStfIdReceiving = lReadoutHdr.mTimeFrameId ;
194175 }
195176
196177 mBuilderInputQueue ->push (std::move (lReadoutMsgs));
@@ -210,9 +191,6 @@ void StfInputInterface::StfBuilderThread()
210191 using namespace std ::chrono_literals;
211192
212193 static constexpr bool cBuildOnTimeout = false ;
213- // current TF Id
214- constexpr std::uint32_t cInvalidStfId = ~0 ;
215- std::uint32_t lCurrentStfId = cInvalidStfId;
216194 bool lStarted = false ;
217195 std::vector<FairMQMessagePtr> lReadoutMsgs;
218196 lReadoutMsgs.reserve (1U << 20 );
@@ -344,17 +322,17 @@ void StfInputInterface::StfBuilderThread()
344322 }
345323
346324 const auto lIdInBuilding = lStfBuilder.getCurrentStfId ();
347- lCurrentStfId = lIdInBuilding ? *lIdInBuilding : lReadoutHdr.mTimeFrameId ;
325+ mStfIdBuilding = lIdInBuilding ? *lIdInBuilding : lReadoutHdr.mTimeFrameId ;
348326
349327 // check for the new TF marker
350- if (lReadoutHdr.mTimeFrameId != lCurrentStfId ) {
328+ if (lReadoutHdr.mTimeFrameId != mStfIdBuilding ) {
351329 // we expect to be notified about new TFs
352330 if (lIdInBuilding) {
353331 EDDLOG_RL (1000 , " READOUT INTERFACE: Update with a new STF ID but the Stop flag was not set for the current STF."
354- " current_id={} new_id={}" , lCurrentStfId , lReadoutHdr.mTimeFrameId );
332+ " current_id={} new_id={}" , mStfIdBuilding , lReadoutHdr.mTimeFrameId );
355333 finishBuildingCurrentStf ();
356334 }
357- lCurrentStfId = lReadoutHdr.mTimeFrameId ;
335+ mStfIdBuilding = lReadoutHdr.mTimeFrameId ;
358336 }
359337
360338 const bool lFinishStf = lReadoutHdr.mFlags .mLastTFMessage ;
0 commit comments