1111#include " Framework/DataProcessingHeader.h"
1212#include " Framework/InputSpec.h"
1313#include " Framework/LifetimeHelpers.h"
14+ #include " Framework/DataDescriptorMatcher.h"
1415#include " Framework/Logger.h"
1516#include " Framework/RawDeviceService.h"
1617#include " Framework/ServiceRegistry.h"
@@ -143,7 +144,7 @@ ExpirationHandler::Checker LifetimeHelpers::expireTimed(std::chrono::microsecond
143144// / expires via this mechanism).
144145ExpirationHandler::Handler LifetimeHelpers::doNothing ()
145146{
146- return [](ServiceRegistry&, PartRef& ref, uint64_t ) -> void { return ; };
147+ return [](ServiceRegistry&, PartRef& ref, uint64_t , data_matcher::VariableContext& ) -> void { return ; };
147148}
148149
149150// We simply put everything in a stringstream and read it afterwards.
@@ -188,7 +189,7 @@ ExpirationHandler::Handler
188189 if (matcher == nullptr ) {
189190 throw runtime_error (" InputSpec for Conditions must be fully qualified" );
190191 }
191- return [spec, matcher, sourceChannel, serverUrl = prefix, overrideTimestampMilliseconds](ServiceRegistry& services, PartRef& ref, uint64_t timestamp) -> void {
192+ return [spec, matcher, sourceChannel, serverUrl = prefix, overrideTimestampMilliseconds](ServiceRegistry& services, PartRef& ref, uint64_t timestamp, data_matcher::VariableContext& ) -> void {
192193 // We should invoke the handler only once.
193194 assert (!ref.header );
194195 assert (!ref.payload );
@@ -265,7 +266,7 @@ ExpirationHandler::Handler
265266// / FIXME: provide a way to customise the histogram from the configuration.
266267ExpirationHandler::Handler LifetimeHelpers::fetchFromQARegistry ()
267268{
268- return [](ServiceRegistry&, PartRef& ref, uint64_t ) -> void {
269+ return [](ServiceRegistry&, PartRef& ref, uint64_t , data_matcher::VariableContext& ) -> void {
269270 throw runtime_error (" fetchFromQARegistry: Not yet implemented" );
270271 return ;
271272 };
@@ -276,18 +277,19 @@ ExpirationHandler::Handler LifetimeHelpers::fetchFromQARegistry()
276277// / FIXME: provide a way to customise the histogram from the configuration.
277278ExpirationHandler::Handler LifetimeHelpers::fetchFromObjectRegistry ()
278279{
279- return [](ServiceRegistry&, PartRef& ref, uint64_t ) -> void {
280+ return [](ServiceRegistry&, PartRef& ref, uint64_t , data_matcher::VariableContext& ) -> void {
280281 throw runtime_error (" fetchFromObjectRegistry: Not yet implemented" );
281282 return ;
282283 };
283284}
284285
285286// / Enumerate entries on every invokation.
286- ExpirationHandler::Handler LifetimeHelpers::enumerate (ConcreteDataMatcher const & matcher, std::string const & sourceChannel)
287+ ExpirationHandler::Handler LifetimeHelpers::enumerate (ConcreteDataMatcher const & matcher, std::string const & sourceChannel,
288+ int64_t orbitOffset, int64_t orbitMultiplier)
287289{
288290 using counter_t = int64_t ;
289291 auto counter = std::make_shared<counter_t >(0 );
290- auto f = [matcher, counter, sourceChannel](ServiceRegistry& services, PartRef& ref, uint64_t timestamp) -> void {
292+ return [matcher, counter, sourceChannel, orbitOffset, orbitMultiplier ](ServiceRegistry& services, PartRef& ref, uint64_t timestamp, data_matcher::VariableContext& variables ) -> void {
291293 // We should invoke the handler only once.
292294 assert (!ref.header );
293295 assert (!ref.payload );
@@ -299,6 +301,10 @@ ExpirationHandler::Handler LifetimeHelpers::enumerate(ConcreteDataMatcher const&
299301 dh.subSpecification = matcher.subSpec ;
300302 dh.payloadSize = sizeof (counter_t );
301303 dh.payloadSerializationMethod = gSerializationMethodNone ;
304+ dh.tfCounter = timestamp;
305+ dh.firstTForbit = timestamp * orbitMultiplier + orbitOffset;
306+ variables.put ({data_matcher::FIRSTTFORBIT_POS, dh.firstTForbit });
307+ variables.put ({data_matcher::TFCOUNTER_POS, dh.tfCounter });
302308
303309 DataProcessingHeader dph{timestamp, 1 };
304310
@@ -312,15 +318,14 @@ ExpirationHandler::Handler LifetimeHelpers::enumerate(ConcreteDataMatcher const&
312318 ref.payload = std::move (payload);
313319 (*counter)++;
314320 };
315- return f;
316321}
317322
318323// / Create a dummy message with the provided ConcreteDataMatcher
319324ExpirationHandler::Handler LifetimeHelpers::dummy (ConcreteDataMatcher const & matcher, std::string const & sourceChannel)
320325{
321326 using counter_t = int64_t ;
322327 auto counter = std::make_shared<counter_t >(0 );
323- auto f = [matcher, counter, sourceChannel](ServiceRegistry& services, PartRef& ref, uint64_t timestamp) -> void {
328+ auto f = [matcher, counter, sourceChannel](ServiceRegistry& services, PartRef& ref, uint64_t timestamp, data_matcher::VariableContext& variables ) -> void {
324329 // We should invoke the handler only once.
325330 assert (!ref.header );
326331 assert (!ref.payload );
@@ -332,7 +337,23 @@ ExpirationHandler::Handler LifetimeHelpers::dummy(ConcreteDataMatcher const& mat
332337 dh.subSpecification = matcher.subSpec ;
333338 dh.payloadSize = 0 ;
334339 dh.payloadSerializationMethod = gSerializationMethodNone ;
335- dh.tfCounter = timestamp;
340+
341+ {
342+ auto pval = std::get_if<uint32_t >(&variables.get (data_matcher::FIRSTTFORBIT_POS));
343+ if (pval == nullptr ) {
344+ dh.firstTForbit = -1 ;
345+ } else {
346+ dh.firstTForbit = *pval;
347+ }
348+ }
349+ {
350+ auto pval = std::get_if<uint32_t >(&variables.get (data_matcher::TFCOUNTER_POS));
351+ if (pval == nullptr ) {
352+ dh.tfCounter = timestamp;
353+ } else {
354+ dh.tfCounter = *pval;
355+ }
356+ }
336357
337358 DataProcessingHeader dph{timestamp, 1 };
338359
0 commit comments