Skip to content

Commit 724d9db

Browse files
committed
COSYLAB-8 Added support for per-record timestamping, currently the timestamp 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]
1 parent 7c9b0a2 commit 724d9db

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎src/bsread.cc‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include <epicsGuard.h>
1212
#include <errlog.h>
1313
#include <recSup.h>
14+
#include <epicsTime.h>
15+
#include <epicsTypes.h>
1416

1517

1618
#include "md5.h"
@@ -194,6 +196,21 @@ void BSRead::read(long pulse_id)
194196
if (bytes_sent == 0) {
195197
Debug("ZMQ message [data header] NOT send.\n");
196198
}
199+
200+
//Add timestamp binary blob
201+
//Current timestamp is packed into a single 64bit unsigned integer where:
202+
// [63:32] = seconds past EPICS epoch (00:00 1/1/1990)
203+
// [31:0] = nanoseconds
204+
//Note: structure is packed into 64bit int to avoid any problems with structure bit packing
205+
// and to avoid potential alingment issues
206+
uint64_t rtimestamp = (channel_config->address.precord->time.secPastEpoch);
207+
rtimestamp = rtimestamp << 32;
208+
rtimestamp |= channel_config->address.precord->time.nsec;
209+
210+
bytes_sent = zmq_socket_->send(&rtimestamp, sizeof(rtimestamp), ZMQ_NOBLOCK|ZMQ_SNDMORE);
211+
if (bytes_sent == 0) {
212+
Debug("ZMQ message [data header] NOT send.\n");
213+
}
197214
}
198215

199216
// Send closing message

0 commit comments

Comments
 (0)