Skip to content

Commit

Permalink
COSYLAB-8 Added support for per-record timestamping, currently the ti…
Browse files Browse the repository at this point in the history
…mestamp is packed into unsigned 64bit int. To retreive the timestamp in python client the following snippet can be used:

                ##Note that the timestamp needs to be received as two unsigned 32 bit integers
                ## instead of a single 64bit int. This due to the fact the rshift on 64bit int doesn't
                ## work on numpy [numpy/numpy#2524]
                raw_data=socket.recv()
                value = numpy.fromstring(raw_data, dtype='u4')
                secPastEpich = value[1]
                nsec = value[0]
  • Loading branch information
tslejko-csl committed Feb 17, 2015
1 parent 7c9b0a2 commit 724d9db
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/bsread.cc
Expand Up @@ -11,6 +11,8 @@
#include <epicsGuard.h>
#include <errlog.h>
#include <recSup.h>
#include <epicsTime.h>
#include <epicsTypes.h>


#include "md5.h"
Expand Down Expand Up @@ -194,6 +196,21 @@ void BSRead::read(long pulse_id)
if (bytes_sent == 0) {
Debug("ZMQ message [data header] NOT send.\n");
}

//Add timestamp binary blob
//Current timestamp is packed into a single 64bit unsigned integer where:
// [63:32] = seconds past EPICS epoch (00:00 1/1/1990)
// [31:0] = nanoseconds
//Note: structure is packed into 64bit int to avoid any problems with structure bit packing
// and to avoid potential alingment issues
uint64_t rtimestamp = (channel_config->address.precord->time.secPastEpoch);
rtimestamp = rtimestamp << 32;
rtimestamp |= channel_config->address.precord->time.nsec;

bytes_sent = zmq_socket_->send(&rtimestamp, sizeof(rtimestamp), ZMQ_NOBLOCK|ZMQ_SNDMORE);
if (bytes_sent == 0) {
Debug("ZMQ message [data header] NOT send.\n");
}
}

// Send closing message
Expand Down

0 comments on commit 724d9db

Please sign in to comment.