Did that originally, but when I tested a scenario with disconnecting the antenna, the GPS receiver started drifting slowly, and with it the RunAvg value. After reconnecting the antenna and after the receiver found its satellite lock again the 1PPS pulse jumped back to its locking point - and with it there was a sudden average frequency jump. So, I needed an exit point where the software just simply starts all over again. The last section is not done within the collector. The collector just collects the data and does an online data quality check of what it can handle synchronously.
All data is passed to the anti-sorter and the alignment is done there, independently.
The collector is not designed to handle asynchronous data and it needs keep up with collecting the data from the VME modules. I'm using some of the spare words in the GPS header for exactly this purpose, though. Find closest match of 1PPS rollover LTC timestamp in temporary GPS headers with a LTC time just before the TRG LTC timestamp. Place both timestamps in final GPS header for this TRG event, and copy remaining data of current 1PPS rollover from temporaray GPS header to final GPS header, too. Get difference of both timestamps.