Skip to content
Snippets Groups Projects
Commit d17ea1c6 authored by Tobias Winchen's avatar Tobias Winchen
Browse files

Added logging output for vdif header timestamp check

parent 597621e6
No related branches found
No related tags found
No related merge requests found
...@@ -134,14 +134,24 @@ void VDIFHeader::setStationId(uint32_t value) { ...@@ -134,14 +134,24 @@ void VDIFHeader::setStationId(uint32_t value) {
} }
void VDIFHeader::setTimeReferencesFromTimestamp(size_t sync_time) { void VDIFHeader::setTimeReferencesFromTimestamp(size_t sync_time) {
BOOST_LOG_TRIVIAL(debug) << "Setting time reference from timestamp: " << sync_time;
boost::posix_time::ptime pt = boost::posix_time::from_time_t(sync_time); boost::posix_time::ptime pt = boost::posix_time::from_time_t(sync_time);
BOOST_LOG_TRIVIAL(debug) << " - posix_time: " << pt;
boost::gregorian::date epochBegin(pt.date().year(), boost::gregorian::date epochBegin(pt.date().year(),
((pt.date().month() <= 6) ? 1 : 7), 1); ((pt.date().month() <= 6) ? 1 : 7), 1);
setReferenceEpoch((epochBegin.year() - 2000) * 2 + (epochBegin.month() >= 7)); BOOST_LOG_TRIVIAL(debug) << " - epochBegin: " << epochBegin;
int refEpoch = (epochBegin.year() - 2000) * 2 + (epochBegin.month() >= 7);
if (refEpoch < 0)
{
BOOST_LOG_TRIVIAL(error) << "Cannot encode time before 1 Jan 2000 - received " << pt;
}
BOOST_LOG_TRIVIAL(debug) << " - reference epoch: " << refEpoch;
setReferenceEpoch(refEpoch);
boost::posix_time::time_duration delta = boost::posix_time::time_duration delta =
pt - boost::posix_time::ptime(epochBegin); pt - boost::posix_time::ptime(epochBegin);
BOOST_LOG_TRIVIAL(debug) << " - time delta since epoch begin: " << delta << " = " << delta.total_seconds();
setSecondsFromReferenceEpoch(delta.total_seconds()); setSecondsFromReferenceEpoch(delta.total_seconds());
BOOST_LOG_TRIVIAL(debug) << " Time stamp: " << sync_time BOOST_LOG_TRIVIAL(debug) << " Time stamp: " << sync_time
......
...@@ -133,7 +133,7 @@ int main(int argc, char **argv) { ...@@ -133,7 +133,7 @@ int main(int argc, char **argv) {
DadaOutputStream sink(output_key, log); DadaOutputStream sink(output_key, log);
char header[4096]; char header[4096];
std::strcpy(header, "HEADER DADA\nHDR_VERSION 1.0\nHDR_SIZE 4096\nDADA_VERSION 1.0\nFILE_SIZE 2013265920\nNBIT 32\nNDIM 2\nNPOL 1\nNCHAN 4096\nRESOLUTION 1\nDSB 1\nSYNC_TIME 123456789\nSAMPLE_CLOCK_START 175671842316288\n"); std::strcpy(header, "HEADER DADA\nHDR_VERSION 1.0\nHDR_SIZE 4096\nDADA_VERSION 1.0\nFILE_SIZE 2013265920\nNBIT 32\nNDIM 2\nNPOL 1\nNCHAN 4096\nRESOLUTION 1\nDSB 1\nSYNC_TIME 1234567890\nSAMPLE_CLOCK_START 175671842316288\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment