mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57:13 +02:00
somewere stuck with virtual template overloading
This commit is contained in:
@ -46,6 +46,12 @@ class BinaryFile : private virtual slsReceiverDefs, public File, public BinaryFi
|
||||
*/
|
||||
void PrintMembers();
|
||||
|
||||
/**
|
||||
* Get File Handle pointer
|
||||
* @returns file handle pointer
|
||||
*/
|
||||
FILE* GetFileHandle();
|
||||
|
||||
/**
|
||||
* Create file
|
||||
* @param fnum current frame index to include in file name
|
||||
|
@ -34,7 +34,8 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
*/
|
||||
DataProcessor(Fifo*& f, fileFormat* ftype, bool* fwenable, bool* dsEnable,
|
||||
int* cbaction,
|
||||
void (*dataReadycb)(int, char*, int, FILE*, char*, void*),
|
||||
void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, FILE*, void*),
|
||||
void *pDataReadycb);
|
||||
|
||||
/**
|
||||
@ -293,19 +294,32 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
int* callbackAction;
|
||||
|
||||
/**
|
||||
* function being called back for raw data
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
* framenum
|
||||
* datapointer
|
||||
* datasize in bytes
|
||||
* file descriptor
|
||||
* guidatapointer (NULL, no data required)
|
||||
* frameNumber is the frame number
|
||||
* expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
* packetNumber is the packet number
|
||||
* bunchId is the bunch id from beamline
|
||||
* timestamp is the time stamp with 10 MHz clock
|
||||
* modId is the unique module id (unique even for left, right, top, bottom)
|
||||
* xCoord is the x coordinate in the complete detector system
|
||||
* yCoord is the y coordinate in the complete detector system
|
||||
* zCoord is the z coordinate in the complete detector system
|
||||
* debug is for debugging purposes
|
||||
* roundRNumber is the round robin set number
|
||||
* detType is the detector type see :: detectorType
|
||||
* version is the version number of this structure format
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes
|
||||
* fileDescriptor is the file descriptor
|
||||
*/
|
||||
void (*rawDataReadyCallBack)(int, char*, int, FILE*, char*, void*);
|
||||
void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, FILE*, void*);
|
||||
void *pRawDataReady;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
@ -125,11 +125,6 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
*/
|
||||
bool IsRunning();
|
||||
|
||||
/**
|
||||
* Create Part1 of Json Header which includes common attributes in an acquisition
|
||||
*/
|
||||
void CreateHeaderPart1();
|
||||
|
||||
/**
|
||||
* Record First Indices (firstAcquisitionIndex, firstMeasurementIndex)
|
||||
* @param fnum frame index to record
|
||||
@ -172,12 +167,11 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
|
||||
/**
|
||||
* Create and send Json Header
|
||||
* @param fnum frame number
|
||||
* @param snum sub frame number
|
||||
* @param header header of image
|
||||
* @param dummy true if its a dummy header
|
||||
* @returns 0 if error, else 1
|
||||
*/
|
||||
int SendHeader(uint64_t fnum, uint32_t snum, bool dummy = false);
|
||||
int SendHeader(sls_detector_header* header, bool dummy = false);
|
||||
|
||||
/** type of thread */
|
||||
static const std::string TypeName;
|
||||
@ -227,9 +221,6 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/** timer beginning stamp for random streaming */
|
||||
struct timespec timerBegin;
|
||||
|
||||
/** Current Json Header prefix*/
|
||||
char* currentHeader;
|
||||
|
||||
/** Aquisition Started flag */
|
||||
bool acquisitionStartedFlag;
|
||||
|
||||
|
@ -11,6 +11,15 @@
|
||||
#include "sls_receiver_defs.h"
|
||||
#include "logger.h"
|
||||
|
||||
#ifdef HDF5C
|
||||
//#ifndef HDF5DEFINED
|
||||
//#define HDF5DEFINED
|
||||
#include "H5Cpp.h"
|
||||
#ifndef H5_NO_NAMESPACE
|
||||
using namespace H5;
|
||||
#endif
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -58,6 +67,15 @@ class File : private virtual slsReceiverDefs {
|
||||
*/
|
||||
virtual fileFormat GetFileType() = 0;
|
||||
|
||||
/**
|
||||
* Get File Handle pointer
|
||||
* @returns file handle pointer
|
||||
*/
|
||||
virtual FILE* GetBinaryFileHandle() {return NULL;};
|
||||
#ifdef HDF5C
|
||||
virtual H5File* GetHDF5FileHandle() {return NULL;};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get Member Pointer Values before the object is destroyed
|
||||
* @param nd pointer to number of detectors in each dimension
|
||||
|
@ -230,7 +230,7 @@ class GotthardData : public GeneralData {
|
||||
packetIndexMask = 1;
|
||||
maxFramesPerFile = MAX_FRAMES_PER_FILE;
|
||||
fifoBufferSize = imageSize;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_detector_header);
|
||||
defaultFifoDepth = 25000;
|
||||
nPixelsX_Streamer = nPixelsX;
|
||||
nPixelsY_Streamer = nPixelsY;
|
||||
@ -256,7 +256,7 @@ class ShortGotthardData : public GeneralData {
|
||||
frameIndexMask = 0xFFFFFFFF;
|
||||
maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE;
|
||||
fifoBufferSize = imageSize;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_detector_header);
|
||||
defaultFifoDepth = 25000;
|
||||
nPixelsX_Streamer = 1280;
|
||||
nPixelsY_Streamer = 1;
|
||||
@ -321,7 +321,7 @@ class PropixData : public GeneralData {
|
||||
packetIndexMask = 1;
|
||||
maxFramesPerFile = MAX_FRAMES_PER_FILE;
|
||||
fifoBufferSize = imageSize;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_detector_header);
|
||||
defaultFifoDepth = 25000;
|
||||
nPixelsX_Streamer = nPixelsX;
|
||||
nPixelsY_Streamer = nPixelsY;
|
||||
@ -352,7 +352,7 @@ class Moench02Data : public GeneralData {
|
||||
packetIndexMask = 0xFF;
|
||||
maxFramesPerFile = MOENCH_MAX_FRAMES_PER_FILE;
|
||||
fifoBufferSize = imageSize;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_detector_header);
|
||||
defaultFifoDepth = 2500;
|
||||
nPixelsX_Streamer = nPixelsX;
|
||||
nPixelsY_Streamer = nPixelsY;
|
||||
@ -388,7 +388,7 @@ class Moench03Data : public GeneralData {
|
||||
packetIndexMask = 0xFFFFFFFF;
|
||||
maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE;
|
||||
fifoBufferSize = imageSize;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_detector_header);
|
||||
defaultFifoDepth = 2500;
|
||||
nPixelsX_Streamer = nPixelsX;
|
||||
nPixelsY_Streamer = nPixelsY;
|
||||
@ -416,7 +416,7 @@ class JCTBData : public GeneralData {
|
||||
imageSize = dataSize*packetsPerFrame;
|
||||
maxFramesPerFile = JFCTB_MAX_FRAMES_PER_FILE;
|
||||
fifoBufferSize = imageSize;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_detector_header);
|
||||
defaultFifoDepth = 2500;
|
||||
nPixelsX_Streamer = nPixelsX;
|
||||
nPixelsY_Streamer = nPixelsY;
|
||||
@ -463,7 +463,7 @@ private:
|
||||
imageSize = dataSize*packetsPerFrame;
|
||||
maxFramesPerFile = JFRAU_MAX_FRAMES_PER_FILE;
|
||||
fifoBufferSize = imageSize;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_detector_header);
|
||||
defaultFifoDepth = 2500;
|
||||
nPixelsX_Streamer = nPixelsX;
|
||||
nPixelsY_Streamer = nPixelsY;
|
||||
@ -553,7 +553,7 @@ private:
|
||||
frameIndexMask = 0xffffff;
|
||||
maxFramesPerFile = EIGER_MAX_FRAMES_PER_FILE;
|
||||
fifoBufferSize = imageSize;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + FILE_FRAME_HEADER_SIZE;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_detector_header);
|
||||
defaultFifoDepth = 100;
|
||||
footerOffset = headerSizeinPacket + dataSize;
|
||||
threadsPerReceiver = 2;
|
||||
|
@ -12,10 +12,14 @@
|
||||
|
||||
#include "File.h"
|
||||
#include "HDF5FileStatic.h"
|
||||
|
||||
//#ifndef HDF5DEFINED
|
||||
//#define HDF5DEFINED
|
||||
#include "H5Cpp.h"
|
||||
#ifndef H5_NO_NAMESPACE
|
||||
using namespace H5;
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -54,6 +58,12 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
|
||||
*/
|
||||
void PrintMembers();
|
||||
|
||||
/**
|
||||
* Get File Handle pointer
|
||||
* @returns file handle pointer
|
||||
*/
|
||||
H5File* GetHDF5FileHandle();
|
||||
|
||||
/**
|
||||
* Set Number of pixels
|
||||
* @param nx number of pixels in x direction
|
||||
|
@ -518,31 +518,42 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
* fileindex
|
||||
* datasize
|
||||
*
|
||||
* return value is the action which decides what the user and default responsibilities to save data are
|
||||
* return value is
|
||||
* 0 callback takes care of open,close,wrie file
|
||||
* 1 callback writes file, we have to open, close it
|
||||
* 2 we open, close, write file, callback does not do anything
|
||||
*/
|
||||
void registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg);
|
||||
void registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg);
|
||||
|
||||
/**
|
||||
* Call back for acquisition finished
|
||||
* callback argument is
|
||||
* total frames caught
|
||||
*/
|
||||
void registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg);
|
||||
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg);
|
||||
|
||||
/**
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
* framenum
|
||||
* datapointer
|
||||
* datasize in bytes
|
||||
* file descriptor
|
||||
* guidatapointer (NULL, no data required)
|
||||
* frameNumber is the frame number
|
||||
* expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
* packetNumber is the packet number
|
||||
* bunchId is the bunch id from beamline
|
||||
* timestamp is the time stamp with 10 MHz clock
|
||||
* modId is the unique module id (unique even for left, right, top, bottom)
|
||||
* xCoord is the x coordinate in the complete detector system
|
||||
* yCoord is the y coordinate in the complete detector system
|
||||
* zCoord is the z coordinate in the complete detector system
|
||||
* debug is for debugging purposes
|
||||
* roundRNumber is the round robin set number
|
||||
* detType is the detector type see :: detectorType
|
||||
* version is the version number of this structure format
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes
|
||||
* fileDescriptor is the file descriptor
|
||||
*/
|
||||
void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg);
|
||||
|
||||
void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, FILE*, void*),void *arg);
|
||||
|
||||
|
||||
|
||||
@ -623,7 +634,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
|
||||
//***callback parameters***
|
||||
/**
|
||||
* function being called back for start acquisition
|
||||
* Call back for start acquisition
|
||||
* callback arguments are
|
||||
* filepath
|
||||
* filename
|
||||
@ -635,31 +646,42 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
* 1 callback writes file, we have to open, close it
|
||||
* 2 we open, close, write file, callback does not do anything
|
||||
*/
|
||||
int (*startAcquisitionCallBack)(char*, char*,int, int, void*);
|
||||
int (*startAcquisitionCallBack)(char*, char*, uint64_t, uint32_t, void*);
|
||||
void *pStartAcquisition;
|
||||
|
||||
/**
|
||||
* function being called back for acquisition finished
|
||||
* Call back for acquisition finished
|
||||
* callback argument is
|
||||
* total frames caught
|
||||
*/
|
||||
void (*acquisitionFinishedCallBack)(int, void*);
|
||||
void (*acquisitionFinishedCallBack)(uint64_t, void*);
|
||||
void *pAcquisitionFinished;
|
||||
|
||||
|
||||
/**
|
||||
* function being called back for raw data
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
* framenum
|
||||
* datapointer
|
||||
* datasize in bytes
|
||||
* file descriptor
|
||||
* guidatapointer (NULL, no data required)
|
||||
* frameNumber is the frame number
|
||||
* expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
* packetNumber is the packet number
|
||||
* bunchId is the bunch id from beamline
|
||||
* timestamp is the time stamp with 10 MHz clock
|
||||
* modId is the unique module id (unique even for left, right, top, bottom)
|
||||
* xCoord is the x coordinate in the complete detector system
|
||||
* yCoord is the y coordinate in the complete detector system
|
||||
* zCoord is the z coordinate in the complete detector system
|
||||
* debug is for debugging purposes
|
||||
* roundRNumber is the round robin set number
|
||||
* detType is the detector type see :: detectorType
|
||||
* version is the version number of this structure format
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes
|
||||
* fileDescriptor is the file descriptor
|
||||
*/
|
||||
void (*rawDataReadyCallBack)(int, char*, int, FILE*, char*, void*);
|
||||
void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, FILE*, void*);
|
||||
void *pRawDataReady;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
@ -582,25 +582,37 @@ class UDPInterface {
|
||||
* 1 callback writes file, we have to open, close it
|
||||
* 2 we open, close, write file, callback does not do anything
|
||||
*/
|
||||
virtual void registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg) = 0;
|
||||
virtual void registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg) = 0;
|
||||
|
||||
/**
|
||||
* Call back for acquisition finished
|
||||
* callback argument is
|
||||
* total frames caught
|
||||
*/
|
||||
virtual void registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg) = 0;
|
||||
virtual void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg) = 0;
|
||||
|
||||
/**
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
* framenum
|
||||
* datapointer
|
||||
* datasize in bytes
|
||||
* file descriptor
|
||||
* guidatapointer (NULL, no data required)
|
||||
* frameNumber is the frame number
|
||||
* expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
* packetNumber is the packet number
|
||||
* bunchId is the bunch id from beamline
|
||||
* timestamp is the time stamp with 10 MHz clock
|
||||
* modId is the unique module id (unique even for left, right, top, bottom)
|
||||
* xCoord is the x coordinate in the complete detector system
|
||||
* yCoord is the y coordinate in the complete detector system
|
||||
* zCoord is the z coordinate in the complete detector system
|
||||
* debug is for debugging purposes
|
||||
* roundRNumber is the round robin set number
|
||||
* detType is the detector type see :: detectorType
|
||||
* version is the version number of this structure format
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes
|
||||
* fileDescriptor is the file descriptor
|
||||
*/
|
||||
virtual void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg) = 0;
|
||||
virtual void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, FILE*, void*),void *arg) = 0;
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -59,13 +59,6 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
||||
*/
|
||||
void setFileFormat(slsReceiverDefs::fileFormat f);
|
||||
|
||||
/**
|
||||
* Set File Name Prefix (without frame index, file index and extension (_f000000000000_8.raw))
|
||||
* Does not check for file existence since it is created only at startReceiver
|
||||
* @param c file name (max of 1000 characters)
|
||||
*/
|
||||
void setFileName(const char c[]);
|
||||
|
||||
/**
|
||||
* Set Short Frame Enabled, later will be moved to getROI (so far only for gotthard)
|
||||
* @param i index of adc enabled, else -1 if all enabled
|
||||
|
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "ansi.h"
|
||||
//#include "sls_receiver_defs.h"
|
||||
|
||||
#include <zmq.h>
|
||||
#include <errno.h>
|
||||
@ -306,23 +307,13 @@ public:
|
||||
cprintf (RED,"Error: Could not parse header for socket %d\n",index);
|
||||
return 0;
|
||||
}
|
||||
#ifdef VERYVERBOSE
|
||||
printf("version:%.1f\n", d["version"].GetDouble());
|
||||
|
||||
// shape is an array of ints
|
||||
rapidjson::Value::Array shape = d["shape"].GetArray();
|
||||
printf("%d: shape: ", index);
|
||||
for (int i = 0; i < shape.Size(); i++)
|
||||
printf("%d: %d ", index, shape[i].GetInt());
|
||||
printf("\n");
|
||||
|
||||
printf("%d: type: %s\n", index, d["type"].GetString());
|
||||
#endif
|
||||
|
||||
if(d["acqIndex"].GetUint64()!=-1){
|
||||
if(d["acqIndex"].GetUint64()!=(uint64_t)-1) {
|
||||
acqIndex = d["acqIndex"].GetUint64();
|
||||
frameIndex = d["fIndex"].GetUint64();
|
||||
subframeIndex = d["subfnum"].GetUint();
|
||||
subframeIndex = -1;
|
||||
if(d["bitmode"].GetInt()==32 && d["detType"].GetUint() == slsReceiverDefs::EIGER) {
|
||||
subframeIndex = d["expLength"].GetUint();
|
||||
}
|
||||
filename = d["fname"].GetString();
|
||||
#ifdef VERYVERBOSE
|
||||
cout << "Acquisition index: " << acqIndex << endl;
|
||||
|
@ -15,10 +15,12 @@
|
||||
#define DO_EVERYTHING 2
|
||||
|
||||
//binary file/ fifo
|
||||
#define FILE_FRAME_HDR_FNUM_SIZE 8
|
||||
#define FILE_FRAME_HDR_SNUM_SIZE 4
|
||||
#define FILE_FRAME_HDR_BID_SIZE 8
|
||||
#define FILE_FRAME_HEADER_SIZE (FILE_FRAME_HDR_FNUM_SIZE + FILE_FRAME_HDR_SNUM_SIZE + FILE_FRAME_HDR_BID_SIZE)
|
||||
|
||||
//#define FILE_FRAME_HDR_FNUM_SIZE 8
|
||||
//#define FILE_FRAME_HDR_SNUM_SIZE 8
|
||||
//#define FILE_FRAME_HDR_BID_SIZE 8
|
||||
//#define FILE_FRAME_HEADER_SIZE (FILE_FRAME_HDR_FNUM_SIZE + FILE_FRAME_HDR_SNUM_SIZE + FILE_FRAME_HDR_BID_SIZE)
|
||||
|
||||
#define FIFO_HEADER_NUMBYTES 4
|
||||
#define FILE_BUFFER_SIZE (16*1024*1024) //16mb
|
||||
|
||||
@ -26,10 +28,10 @@
|
||||
#define MAX_CHUNKED_IMAGES 1
|
||||
|
||||
//versions
|
||||
#define STREAMER_VERSION 1.0
|
||||
#define HDF5_WRITER_VERSION 1.0
|
||||
#define HDF5_WRITER_VERSION 1.0 //1 decimal places
|
||||
#define BINARY_WRITER_VERSION 1.0 //1 decimal places
|
||||
|
||||
#define SLS_DETECTOR_HEADER_VERSION 0x1
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
//parameters to calculate fifo depth
|
||||
#define SAMPLE_TIME_IN_NS 100000000//100ms
|
||||
|
@ -58,28 +58,49 @@ class slsReceiver : private virtual slsReceiverDefs {
|
||||
int64_t getReceiverVersion();
|
||||
|
||||
/**
|
||||
@sort register calbback for starting the acquisition
|
||||
@param func callback to be called when starting the acquisition. Its arguments are filepath filename fileindex data size
|
||||
\returns 0 callback takes care of open,close,write file; 1 callback writes file, we have to open, close it; 2 we open, close, write file, callback does not do anything
|
||||
* Call back for start acquisition
|
||||
* callback arguments are
|
||||
* filepath
|
||||
* filename
|
||||
* fileindex
|
||||
* datasize
|
||||
*
|
||||
* return value is
|
||||
* 0 callback takes care of open,close,wrie file
|
||||
* 1 callback writes file, we have to open, close it
|
||||
* 2 we open, close, write file, callback does not do anything
|
||||
*/
|
||||
void registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg);
|
||||
|
||||
void registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg);
|
||||
|
||||
/**
|
||||
callback argument is
|
||||
toatal farmes caught
|
||||
* Call back for acquisition finished
|
||||
* callback argument is
|
||||
* total frames caught
|
||||
*/
|
||||
void registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg);
|
||||
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg);
|
||||
|
||||
/**
|
||||
args to raw data ready callback are
|
||||
framenum
|
||||
datapointer
|
||||
datasize in bytes
|
||||
file descriptor
|
||||
guidatapointer (NULL, no data required)
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
* frameNumber is the frame number
|
||||
* expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
* packetNumber is the packet number
|
||||
* bunchId is the bunch id from beamline
|
||||
* timestamp is the time stamp with 10 MHz clock
|
||||
* modId is the unique module id (unique even for left, right, top, bottom)
|
||||
* xCoord is the x coordinate in the complete detector system
|
||||
* yCoord is the y coordinate in the complete detector system
|
||||
* zCoord is the z coordinate in the complete detector system
|
||||
* debug is for debugging purposes
|
||||
* roundRNumber is the round robin set number
|
||||
* detType is the detector type see :: detectorType
|
||||
* version is the version number of this structure format
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes
|
||||
* fileDescriptor is the file descriptor
|
||||
*/
|
||||
void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg);
|
||||
void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, FILE*, void*),void *arg);
|
||||
|
||||
|
||||
private:
|
||||
|
@ -64,30 +64,42 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
||||
* fileindex
|
||||
* datasize
|
||||
*
|
||||
* return value is the action which decides what the user and default responsibilities to save data are
|
||||
* return value is
|
||||
* 0 callback takes care of open,close,wrie file
|
||||
* 1 callback writes file, we have to open, close it
|
||||
* 2 we open, close, write file, callback does not do anything
|
||||
*/
|
||||
void registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg);
|
||||
void registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg);
|
||||
|
||||
/**
|
||||
* Call back for acquisition finished
|
||||
* callback argument is
|
||||
* total frames caught
|
||||
*/
|
||||
void registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg);
|
||||
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg);
|
||||
|
||||
/**
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
* framenum
|
||||
* datapointer
|
||||
* datasize in bytes
|
||||
* file descriptor
|
||||
* guidatapointer (NULL, no data required)
|
||||
* frameNumber is the frame number
|
||||
* expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
* packetNumber is the packet number
|
||||
* bunchId is the bunch id from beamline
|
||||
* timestamp is the time stamp with 10 MHz clock
|
||||
* modId is the unique module id (unique even for left, right, top, bottom)
|
||||
* xCoord is the x coordinate in the complete detector system
|
||||
* yCoord is the y coordinate in the complete detector system
|
||||
* zCoord is the z coordinate in the complete detector system
|
||||
* debug is for debugging purposes
|
||||
* roundRNumber is the round robin set number
|
||||
* detType is the detector type see :: detectorType
|
||||
* version is the version number of this structure format
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes
|
||||
* fileDescriptor is the file descriptor
|
||||
*/
|
||||
void registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg);
|
||||
void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, FILE*, void*),void *arg);
|
||||
|
||||
private:
|
||||
|
||||
@ -290,7 +302,7 @@ private:
|
||||
|
||||
//***callback parameters***
|
||||
/**
|
||||
* function being called back for start acquisition
|
||||
* Call back for start acquisition
|
||||
* callback arguments are
|
||||
* filepath
|
||||
* filename
|
||||
@ -302,31 +314,44 @@ private:
|
||||
* 1 callback writes file, we have to open, close it
|
||||
* 2 we open, close, write file, callback does not do anything
|
||||
*/
|
||||
int (*startAcquisitionCallBack)(char*, char*,int, int, void*);
|
||||
int (*startAcquisitionCallBack)(char*, char*, uint64_t, uint32_t, void*);
|
||||
void *pStartAcquisition;
|
||||
|
||||
/**
|
||||
* function being called back for acquisition finished
|
||||
* Call back for acquisition finished
|
||||
* callback argument is
|
||||
* total frames caught
|
||||
*/
|
||||
void (*acquisitionFinishedCallBack)(int, void*);
|
||||
void (*acquisitionFinishedCallBack)(uint64_t, void*);
|
||||
void *pAcquisitionFinished;
|
||||
|
||||
|
||||
/**
|
||||
* function being called back for raw data
|
||||
* Call back for raw data
|
||||
* args to raw data ready callback are
|
||||
* framenum
|
||||
* datapointer
|
||||
* datasize in bytes
|
||||
* file descriptor
|
||||
* guidatapointer (NULL, no data required)
|
||||
* frameNumber is the frame number
|
||||
* expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
* packetNumber is the packet number
|
||||
* bunchId is the bunch id from beamline
|
||||
* timestamp is the time stamp with 10 MHz clock
|
||||
* modId is the unique module id (unique even for left, right, top, bottom)
|
||||
* xCoord is the x coordinate in the complete detector system
|
||||
* yCoord is the y coordinate in the complete detector system
|
||||
* zCoord is the z coordinate in the complete detector system
|
||||
* debug is for debugging purposes
|
||||
* roundRNumber is the round robin set number
|
||||
* detType is the detector type see :: detectorType
|
||||
* version is the version number of this structure format
|
||||
* dataPointer is the pointer to the data
|
||||
* dataSize in bytes is the size of the data in bytes
|
||||
* fileDescriptor is the file descriptor
|
||||
*/
|
||||
void (*rawDataReadyCallBack)(int, char*, int, FILE*, char*, void*);
|
||||
void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, FILE*, void*);
|
||||
void *pRawDataReady;
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
/** Socket */
|
||||
MySocketTCP* mySock;
|
||||
|
@ -50,13 +50,10 @@ public:
|
||||
/**
|
||||
|
||||
@sort register calbback for starting the acquisition
|
||||
\param func callback to be called when starting the acquisition. Its arguments are filepath filename fileindex data size
|
||||
|
||||
\param func callback to be called when starting the acquisition. Its arguments are filepath, filename, fileindex, datasize
|
||||
\returns 0 callback takes care of open,close,write file; 1 callback writes file, we have to open, close it; 2 we open, close, write file, callback does not do anything
|
||||
|
||||
*/
|
||||
|
||||
void registerCallBackStartAcquisition(int (*func)(char* filepath, char* filename,int fileindex, int datasize, void*),void *arg);
|
||||
void registerCallBackStartAcquisition(int (*func)(char* filepath, char* filename, uint64_t fileindex, uint32_t datasize, void*),void *arg);
|
||||
|
||||
|
||||
/**
|
||||
@ -64,19 +61,18 @@ public:
|
||||
\param func end of acquisition callback. Argument nf is total frames caught
|
||||
\returns nothing
|
||||
*/
|
||||
|
||||
|
||||
void registerCallBackAcquisitionFinished(void (*func)(int nf, void*),void *arg);
|
||||
void registerCallBackAcquisitionFinished(void (*func)(uint64_t nf, void*),void *arg);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@sort register callback to be called when data are available (to process and/or save the data).
|
||||
\param func raw data ready callback. arguments are framenum datapointer datasize file descriptor guidatapointer (NULL, no data required)
|
||||
\param func raw data ready callback. arguments are frameNumber, expLength, packetNumber, bunchId, timestamp, modId, xCoord, yCoord, zCoord, debug, roundRNumber, detType, version, dataPointer, dataSize, fileDescriptor
|
||||
\returns nothing
|
||||
*/
|
||||
|
||||
void registerCallBackRawDataReady(void (*func)(int framenumber, char* datapointer, int datasize, FILE* filedescriptor, char* guidatapointer, void*),void *arg);
|
||||
void registerCallBackRawDataReady(void (*func)(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp,
|
||||
uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version,
|
||||
char* datapointer, uint32_t datasize, FILE* filedescriptor, void*),void *arg);
|
||||
|
||||
//receiver object
|
||||
slsReceiver* receiver;
|
||||
|
@ -115,6 +115,40 @@ public:
|
||||
STOPPED /**< acquisition stopped externally */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@short structure for a Detector Packet or Image Header
|
||||
@li frameNumber is the frame number
|
||||
@li expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
@li packetNumber is the packet number
|
||||
@li bunchId is the bunch id from beamline
|
||||
@li timestamp is the time stamp with 10 MHz clock
|
||||
@li modId is the unique module id (unique even for left, right, top, bottom)
|
||||
@li xCoord is the x coordinate in the complete detector system
|
||||
@li yCoord is the y coordinate in the complete detector system
|
||||
@li zCoord is the z coordinate in the complete detector system
|
||||
@li debug is for debugging purposes
|
||||
@li roundRNumber is the round robin set number
|
||||
@li detType is the detector type see :: detectorType
|
||||
@li version is the version number of this structure format
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t frameNumber; /**< is the frame number */
|
||||
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
|
||||
uint32_t packetNumber; /**< is the packet number */
|
||||
uint64_t bunchId; /**< is the bunch id from beamline */
|
||||
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
|
||||
uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */
|
||||
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
|
||||
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
|
||||
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
|
||||
uint32_t debug; /**< is for debugging purposes */
|
||||
uint16_t roundRNumber; /**< is the round robin set number */
|
||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
uint8_t version; /**< is the version number of this structure format */
|
||||
} sls_detector_header;
|
||||
|
||||
|
||||
/**
|
||||
format
|
||||
*/
|
||||
|
@ -35,6 +35,10 @@ void BinaryFile::PrintMembers() {
|
||||
printf("Number of Frames in File: %d\n",numFramesInFile);
|
||||
}
|
||||
|
||||
FILE* BinaryFile::GetFileHandle() {
|
||||
return filefd;
|
||||
}
|
||||
|
||||
slsReceiverDefs::fileFormat BinaryFile::GetFileType() {
|
||||
return BINARY;
|
||||
}
|
||||
|
@ -33,7 +33,8 @@ pthread_mutex_t DataProcessor::Mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool* fwenable, bool* dsEnable,
|
||||
int* cbaction,
|
||||
void (*dataReadycb)(int, char*, int, FILE*, char*, void*),
|
||||
void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, FILE*, void*),
|
||||
void *pDataReadycb) :
|
||||
|
||||
ThreadObject(NumberofDataProcessors),
|
||||
@ -300,8 +301,8 @@ void DataProcessor::ProcessAnImage(char* buf) {
|
||||
numFramesCaught++;
|
||||
numTotalFramesCaught++;
|
||||
|
||||
|
||||
uint64_t fnum = (*((uint64_t*)buf));
|
||||
sls_detector_header* header = (sls_detector_header*) (buf);
|
||||
uint64_t fnum = header->frameNumber;
|
||||
#ifdef VERBOSE
|
||||
if (!index) cprintf(BLUE,"DataProcessing %d: fnum:%lld\n", index, (long long int)fnum);
|
||||
#endif
|
||||
@ -315,11 +316,30 @@ void DataProcessor::ProcessAnImage(char* buf) {
|
||||
|
||||
if (*callbackAction == DO_EVERYTHING) {
|
||||
if (*fileWriteEnable)
|
||||
file->WriteToFile(buf, generalData->fifoBufferSize + FILE_FRAME_HEADER_SIZE, fnum-firstMeasurementIndex);
|
||||
file->WriteToFile(buf, generalData->fifoBufferSize + sizeof(sls_detector_header), fnum-firstMeasurementIndex);
|
||||
} else {
|
||||
/*
|
||||
if (rawDataReadyCallBack)
|
||||
rawDataReadyCallBack((int)fnum, buf + FILE_FRAME_HEADER_SIZE, generalData->fifoBufferSize,
|
||||
NULL, NULL, pRawDataReady);
|
||||
rawDataReadyCallBack(
|
||||
header->frameNumber,
|
||||
header->expLength,
|
||||
header->packetNumber,
|
||||
header->bunchId,
|
||||
header->timestamp,
|
||||
header->modId,
|
||||
header->xCoord,
|
||||
header->yCoord,
|
||||
header->zCoord,
|
||||
header->debug,
|
||||
header->roundRNumber,
|
||||
header->detType,
|
||||
header->version,
|
||||
buf + sizeof(sls_detector_header),
|
||||
generalData->imageSize,
|
||||
file->GetFileHandle(), pRawDataReady);
|
||||
*/
|
||||
file->GetBinaryFileHandle();
|
||||
//GetHDF5FileHandle
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,18 +23,29 @@ uint64_t DataStreamer::RunningMask(0x0);
|
||||
|
||||
pthread_mutex_t DataStreamer::Mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
const char* DataStreamer::jsonHeaderFormat_part1 =
|
||||
"{"
|
||||
"\"version\":%.1f, "
|
||||
"\"type\":\"%s\", "
|
||||
"\"shape\":[%d, %d], ";
|
||||
|
||||
const char* DataStreamer::jsonHeaderFormat =
|
||||
"%s"
|
||||
"{"
|
||||
"\"jsonversion\":%u, "
|
||||
"\"bitmode\":%d, "
|
||||
"\"shape\":[%d, %d], "
|
||||
"\"acqIndex\":%llu, "
|
||||
"\"fIndex\":%llu, "
|
||||
"\"subfnum\":%u, "
|
||||
"\"fname\":\"%s\"}";
|
||||
"\"fname\":\"%s\", "
|
||||
|
||||
"\"frameNumber\":%llu, "
|
||||
"\"expLength\":%u, "
|
||||
"\"packetNumber\":%u, "
|
||||
"\"bunchId\":%llu, "
|
||||
"\"timestamp\":%llu, "
|
||||
"\"modId\":%u, "
|
||||
"\"xCoord\":%u, "
|
||||
"\"yCoord\":%u, "
|
||||
"\"zCoord\":%u, "
|
||||
"\"debug\":%u, "
|
||||
"\"roundRNumber\":%u, "
|
||||
"\"detType\":%u, "
|
||||
"\"version\":%u"
|
||||
"}";
|
||||
|
||||
|
||||
DataStreamer::DataStreamer(Fifo*& f, uint32_t* dr, uint32_t* freq, uint32_t* timer, int* sEnable) :
|
||||
@ -47,7 +58,6 @@ DataStreamer::DataStreamer(Fifo*& f, uint32_t* dr, uint32_t* freq, uint32_t* tim
|
||||
streamingFrequency(freq),
|
||||
streamingTimerInMs(timer),
|
||||
currentFreqCount(0),
|
||||
currentHeader(0),
|
||||
acquisitionStartedFlag(false),
|
||||
measurementStartedFlag(false),
|
||||
firstAcquisitionIndex(0),
|
||||
@ -64,14 +74,12 @@ DataStreamer::DataStreamer(Fifo*& f, uint32_t* dr, uint32_t* freq, uint32_t* tim
|
||||
FILE_LOG (logDEBUG) << "Number of DataStreamers: " << NumberofDataStreamers;
|
||||
|
||||
memset((void*)&timerBegin, 0, sizeof(timespec));
|
||||
currentHeader = new char[255];
|
||||
strcpy(fileNametoStream, "");
|
||||
}
|
||||
|
||||
|
||||
DataStreamer::~DataStreamer() {
|
||||
CloseZmqSocket();
|
||||
if (currentHeader) delete currentHeader;
|
||||
if (completeBuffer) delete completeBuffer;
|
||||
ThreadObject::DestroyThread();
|
||||
NumberofDataStreamers--;
|
||||
@ -137,27 +145,6 @@ void DataStreamer::ResetParametersforNewMeasurement(char* fname){
|
||||
completeBuffer = new char[generalData->imageSize_Streamer];
|
||||
memset(completeBuffer, 0, generalData->imageSize_Streamer);
|
||||
}
|
||||
CreateHeaderPart1();
|
||||
}
|
||||
|
||||
void DataStreamer::CreateHeaderPart1() {
|
||||
char type[10] = "";
|
||||
switch (*dynamicRange) {
|
||||
case 4: strcpy(type, "uint4"); break;
|
||||
case 8: strcpy(type, "uint8"); break;
|
||||
case 16: strcpy(type, "uint16"); break;
|
||||
case 32: strcpy(type, "uint32"); break;
|
||||
default:
|
||||
strcpy(type, "unknown");
|
||||
cprintf(RED," Unknown datatype in json format %d\n", *dynamicRange);
|
||||
break;
|
||||
}
|
||||
|
||||
sprintf(currentHeader, jsonHeaderFormat_part1,
|
||||
STREAMER_VERSION, type, generalData->nPixelsX_Streamer, generalData->nPixelsY_Streamer);
|
||||
#ifdef VERBOSE
|
||||
cprintf(BLUE, "%d currentheader: %s\n", index, currentHeader);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -240,8 +227,9 @@ void DataStreamer::ThreadExecution() {
|
||||
|
||||
void DataStreamer::StopProcessing(char* buf) {
|
||||
|
||||
sls_detector_header* header = (sls_detector_header*) (buf);
|
||||
//send dummy header and data
|
||||
if (!SendHeader(0, true))
|
||||
if (!SendHeader(header, true))
|
||||
cprintf(RED,"Error: Could not send zmq dummy header for streamer %d\n", index);
|
||||
|
||||
if (!zmqSocket->SendData((char*)DUMMY_MSG, DUMMY_MSG_SIZE))
|
||||
@ -256,8 +244,9 @@ void DataStreamer::StopProcessing(char* buf) {
|
||||
|
||||
|
||||
void DataStreamer::ProcessAnImage(char* buf) {
|
||||
uint64_t fnum = (*((uint64_t*)buf));
|
||||
uint32_t snum = (*((uint32_t*)(buf + FILE_FRAME_HDR_FNUM_SIZE)));
|
||||
|
||||
sls_detector_header* header = (sls_detector_header*) (buf);
|
||||
uint64_t fnum = header->frameNumber;
|
||||
#ifdef VERBOSE
|
||||
if (!index) cprintf(MAGENTA,"DataStreamer %d: fnum:%lld\n", index, (long long int)fnum);
|
||||
#endif
|
||||
@ -282,20 +271,20 @@ void DataStreamer::ProcessAnImage(char* buf) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SendHeader(fnum, snum))
|
||||
if (!SendHeader(header))
|
||||
cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n",
|
||||
(long long int) fnum, index);
|
||||
|
||||
//shortframe gotthard - data sending
|
||||
if (completeBuffer) {
|
||||
memcpy(completeBuffer + ((generalData->imageSize)**shortFrameEnable), buf + FILE_FRAME_HEADER_SIZE, generalData->imageSize);
|
||||
memcpy(completeBuffer + ((generalData->imageSize)**shortFrameEnable), buf + sizeof(sls_detector_header), generalData->imageSize);
|
||||
if (!zmqSocket->SendData(completeBuffer, generalData->imageSize_Streamer))
|
||||
cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n",
|
||||
(long long int) fnum, index);
|
||||
}
|
||||
//normal - data sending
|
||||
else {
|
||||
if (!zmqSocket->SendData(buf + FILE_FRAME_HEADER_SIZE, generalData->imageSize))
|
||||
if (!zmqSocket->SendData(buf + sizeof(sls_detector_header), generalData->imageSize))
|
||||
cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n",
|
||||
(long long int) fnum, index);
|
||||
}
|
||||
@ -329,19 +318,24 @@ bool DataStreamer::CheckCount() {
|
||||
}
|
||||
|
||||
|
||||
int DataStreamer::SendHeader(uint64_t fnum, uint32_t snum, bool dummy) {
|
||||
uint64_t frameIndex = -1;
|
||||
uint64_t acquisitionIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
int DataStreamer::SendHeader(sls_detector_header* header, bool dummy) {
|
||||
|
||||
uint64_t frameIndex = header->frameNumber - firstMeasurementIndex;
|
||||
uint64_t acquisitionIndex = header->frameNumber - firstAcquisitionIndex;
|
||||
uint32_t subframeIndex = header->expLength;
|
||||
|
||||
char buf[1000] = "";
|
||||
|
||||
if (!dummy) {
|
||||
frameIndex = fnum - firstMeasurementIndex;
|
||||
acquisitionIndex = fnum - firstAcquisitionIndex;
|
||||
subframeIndex = snum;
|
||||
if (dummy) {
|
||||
frameIndex = -1;
|
||||
acquisitionIndex = -1;
|
||||
subframeIndex = -1;
|
||||
}
|
||||
|
||||
int len = sprintf(buf, jsonHeaderFormat, currentHeader, acquisitionIndex, frameIndex, subframeIndex, fileNametoStream);
|
||||
int len = sprintf(buf, jsonHeaderFormat,
|
||||
SLS_DETECTOR_JSON_HEADER_VERSION, *dynamicRange, generalData->nPixelsX_Streamer, generalData->nPixelsY_Streamer, acquisitionIndex, frameIndex, fileNametoStream,
|
||||
header->frameNumber, header->expLength, header->packetNumber, header->bunchId, header->timestamp,
|
||||
header->modId, header->xCoord, header->yCoord, header->zCoord, header->debug, header->roundRNumber, header->detType, header->version);
|
||||
#ifdef VERBOSE
|
||||
printf("%d Streamer: buf:%s\n", index, buf);
|
||||
#endif
|
||||
|
@ -66,6 +66,10 @@ void HDF5File::PrintMembers() {
|
||||
}
|
||||
|
||||
|
||||
H5File* HDF5File::GetHDF5FileHandle() {
|
||||
return filefd;
|
||||
}
|
||||
|
||||
void HDF5File::SetNumberofPixels(uint32_t nx, uint32_t ny) {
|
||||
nPixelsX = nx;
|
||||
nPixelsY = ny;
|
||||
@ -139,19 +143,20 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum) {
|
||||
}
|
||||
numFramesInFile++;
|
||||
|
||||
uint32_t snum = (*((uint32_t*)(buffer + FILE_FRAME_HDR_FNUM_SIZE)));
|
||||
uint64_t bid = (*((uint64_t*)(buffer + FILE_FRAME_HDR_FNUM_SIZE + FILE_FRAME_HDR_SNUM_SIZE)));
|
||||
sls_detector_header* header = (sls_detector_header*) (buffer);
|
||||
//uint32_t snum = header->expLength;
|
||||
// uint64_t bid = header->expLength
|
||||
pthread_mutex_lock(&Mutex);
|
||||
if (HDF5FileStatic::WriteDataFile(index, buffer + FILE_FRAME_HEADER_SIZE,
|
||||
if (HDF5FileStatic::WriteDataFile(index, buffer + sizeof(sls_detector_header),
|
||||
fnum%maxFramesPerFile, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
||||
dataspace, dataset, datatype) == OK) {
|
||||
if (HDF5FileStatic::WriteParameterDatasets(index, dataspace_para,
|
||||
/*if (HDF5FileStatic::WriteParameterDatasets(index, dataspace_para,
|
||||
fnum%maxFramesPerFile,
|
||||
dataset_para1, datatype_para1, &snum,
|
||||
dataset_para2, datatype_para2, &bid) == OK) {
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
return OK;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
cprintf(RED,"%d Error: Write to file failed\n", index);
|
||||
|
@ -248,7 +248,7 @@ void Listener::ThreadExecution() {
|
||||
//get data
|
||||
if (*status != TRANSMITTING) {
|
||||
if (*activated)
|
||||
rc = ListenToAnImage(buffer + generalData->fifoBufferHeaderSize);
|
||||
rc = ListenToAnImage(buffer);
|
||||
else
|
||||
rc = CreateAnImage(buffer + generalData->fifoBufferHeaderSize);
|
||||
}
|
||||
@ -306,7 +306,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
|
||||
|
||||
//reset to -1
|
||||
memset(buf,0xFF,dsize);
|
||||
memset(buf + generalData->fifoBufferHeaderSize, 0xFF, dsize);
|
||||
|
||||
|
||||
//look for carry over
|
||||
@ -319,11 +319,28 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
return generalData->imageSize;
|
||||
}
|
||||
carryOverFlag = false;
|
||||
memcpy(buf + (pnum * dsize), carryOverPacket + generalData->headerSizeinPacket, dsize);
|
||||
memcpy(buf + generalData->fifoBufferHeaderSize + (pnum * dsize), carryOverPacket + generalData->headerSizeinPacket, dsize);
|
||||
//writer header
|
||||
if(isHeaderEmpty) {
|
||||
(*((uint64_t*)(buf - FILE_FRAME_HEADER_SIZE))) = fnum;
|
||||
(*((uint64_t*)(buf - FILE_FRAME_HEADER_SIZE + FILE_FRAME_HDR_FNUM_SIZE))) = snum;
|
||||
(*((uint64_t*)(buf - FILE_FRAME_HEADER_SIZE + FILE_FRAME_HDR_FNUM_SIZE + FILE_FRAME_HDR_SNUM_SIZE))) = bid;
|
||||
sls_detector_header* header = (sls_detector_header*) (buf);
|
||||
memset(header, 0, sizeof(sls_detector_header));
|
||||
header->frameNumber = fnum;
|
||||
if (generalData->myDetectorType == EIGER && *dynamicRange == 32)
|
||||
header->expLength = snum;
|
||||
header->packetNumber = generalData->packetsPerFrame; /*in the end..*/
|
||||
if (generalData->myDetectorType == JUNGFRAU)
|
||||
header->bunchId = bid;
|
||||
/*header->xCoord = index; given by det packet, also for ycoord, zcoord */
|
||||
/*header->detType = (uint8_t) generalData->myDetectorType; given by det packet */
|
||||
header->version = (uint8_t) SLS_DETECTOR_HEADER_VERSION;
|
||||
|
||||
#ifdef VERBOSE
|
||||
if(!ithread)
|
||||
cprintf(BLUE,
|
||||
"framenumber:%llu\tsubfnum:%u\tpnum:%u\tbunchid:%llu\txcoord:%u\tdettype:%u\tversion:%u\n",
|
||||
header->frameNumber, header->expLength, header->packetNumber,
|
||||
header->bunchId, header->xCoord, header->detType, header->version);
|
||||
#endif
|
||||
isHeaderEmpty = false;
|
||||
}
|
||||
expectpnum = pnum+1; //for jungfrau
|
||||
@ -374,11 +391,19 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
}
|
||||
|
||||
//copy packet
|
||||
memcpy(buf + (pnum * dsize), listeningPacket + generalData->headerSizeinPacket, dsize);
|
||||
memcpy(buf + generalData->fifoBufferHeaderSize + (pnum * dsize), listeningPacket + generalData->headerSizeinPacket, dsize);
|
||||
if(isHeaderEmpty) {
|
||||
(*((uint64_t*)(buf - FILE_FRAME_HEADER_SIZE))) = fnum;
|
||||
(*((uint64_t*)(buf - FILE_FRAME_HEADER_SIZE + FILE_FRAME_HDR_FNUM_SIZE))) = snum;
|
||||
(*((uint64_t*)(buf - FILE_FRAME_HEADER_SIZE + FILE_FRAME_HDR_FNUM_SIZE + FILE_FRAME_HDR_SNUM_SIZE))) = bid;
|
||||
sls_detector_header* header = (sls_detector_header*) (buf);
|
||||
memset(header, 0, sizeof(sls_detector_header));
|
||||
header->frameNumber = fnum;
|
||||
if (generalData->myDetectorType == EIGER && *dynamicRange == 32)
|
||||
header->expLength = snum;
|
||||
header->packetNumber = generalData->packetsPerFrame; /*in the end..*/
|
||||
if (generalData->myDetectorType == JUNGFRAU)
|
||||
header->bunchId = bid;
|
||||
/*header->xCoord = index; given by det packet, also for ycoord, zcoord */
|
||||
/*header->detType = (uint8_t) generalData->myDetectorType; given by det packet */
|
||||
header->version = (uint8_t) SLS_DETECTOR_HEADER_VERSION;
|
||||
isHeaderEmpty = false;
|
||||
}
|
||||
expectpnum = pnum+1; //for jungfrau
|
||||
|
@ -541,20 +541,20 @@ int UDPBaseImplementation::setActivate(int enable){
|
||||
}
|
||||
|
||||
/***callback functions***/
|
||||
void UDPBaseImplementation::registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg){
|
||||
void UDPBaseImplementation::registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg){
|
||||
startAcquisitionCallBack=func;
|
||||
pStartAcquisition=arg;
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg){
|
||||
void UDPBaseImplementation::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){
|
||||
acquisitionFinishedCallBack=func;
|
||||
pAcquisitionFinished=arg;
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){
|
||||
void UDPBaseImplementation::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, FILE*, void*),void *arg){
|
||||
rawDataReadyCallBack=func;
|
||||
pRawDataReady=arg;
|
||||
}
|
||||
|
||||
|
||||
//#endif
|
||||
|
@ -132,26 +132,6 @@ void UDPStandardImplementation::setFileFormat(const fileFormat f){
|
||||
|
||||
|
||||
|
||||
void UDPStandardImplementation::setFileName(const char c[]) {
|
||||
if (strlen(c)) {
|
||||
strcpy(fileName, c); //automatically update fileName in Filewriter (pointer)
|
||||
/*int detindex = -1;
|
||||
string tempname(fileName);
|
||||
size_t uscore=tempname.rfind("_");
|
||||
if (uscore!=string::npos) {
|
||||
if (sscanf(tempname.substr(uscore+1, tempname.size()-uscore-1).c_str(), "d%d", &detindex)) {
|
||||
detID = detindex;
|
||||
tempname=tempname.substr(0,uscore);
|
||||
strcpy(fileName, tempname.c_str());
|
||||
}
|
||||
}
|
||||
if (detindex == -1)
|
||||
detID = 0;*/
|
||||
}
|
||||
FILE_LOG (logINFO) << "File name:" << fileName;
|
||||
}
|
||||
|
||||
|
||||
int UDPStandardImplementation::setShortFrameEnable(const int i) {
|
||||
if (myDetectorType != GOTTHARD) {
|
||||
cprintf(RED, "Error: Can not set short frame for this detector\n");
|
||||
@ -556,7 +536,7 @@ void UDPStandardImplementation::stopReceiver(){
|
||||
|
||||
|
||||
{ //statistics
|
||||
int tot = 0;
|
||||
uint64_t tot = 0;
|
||||
for (int i = 0; i < numThreads; i++) {
|
||||
tot += dataProcessor[i]->GetNumFramesCaught();
|
||||
|
||||
@ -577,7 +557,7 @@ void UDPStandardImplementation::stopReceiver(){
|
||||
cprintf(RED,"Note: Deactivated Receiver\n");
|
||||
//callback
|
||||
if (acquisitionFinishedCallBack)
|
||||
acquisitionFinishedCallBack((int)(tot/numThreads), pAcquisitionFinished);
|
||||
acquisitionFinishedCallBack((tot/numThreads), pAcquisitionFinished);
|
||||
}
|
||||
|
||||
//change status
|
||||
|
@ -160,7 +160,7 @@ int64_t slsReceiver::getReceiverVersion(){
|
||||
}
|
||||
|
||||
|
||||
void slsReceiver::registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg){
|
||||
void slsReceiver::registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg){
|
||||
//tcpipInterface
|
||||
if(udp_interface)
|
||||
udp_interface->registerCallBackStartAcquisition(func,arg);
|
||||
@ -170,7 +170,7 @@ void slsReceiver::registerCallBackStartAcquisition(int (*func)(char*, char*,int,
|
||||
|
||||
|
||||
|
||||
void slsReceiver::registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg){
|
||||
void slsReceiver::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){
|
||||
//tcpipInterface
|
||||
if(udp_interface)
|
||||
udp_interface->registerCallBackAcquisitionFinished(func,arg);
|
||||
@ -179,7 +179,8 @@ void slsReceiver::registerCallBackAcquisitionFinished(void (*func)(int, void*),v
|
||||
}
|
||||
|
||||
|
||||
void slsReceiver::registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){
|
||||
void slsReceiver::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, FILE*, void*),void *arg){
|
||||
//tcpipInterface
|
||||
if(udp_interface)
|
||||
udp_interface->registerCallBackRawDataReady(func,arg);
|
||||
|
@ -2680,17 +2680,18 @@ int slsReceiverTCPIPInterface::exec_command() {
|
||||
|
||||
|
||||
/***callback functions***/
|
||||
void slsReceiverTCPIPInterface::registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg){
|
||||
void slsReceiverTCPIPInterface::registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg){
|
||||
startAcquisitionCallBack=func;
|
||||
pStartAcquisition=arg;
|
||||
}
|
||||
|
||||
void slsReceiverTCPIPInterface::registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg){
|
||||
void slsReceiverTCPIPInterface::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){
|
||||
acquisitionFinishedCallBack=func;
|
||||
pAcquisitionFinished=arg;
|
||||
}
|
||||
|
||||
void slsReceiverTCPIPInterface::registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){
|
||||
void slsReceiverTCPIPInterface::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t,
|
||||
char*, uint32_t, FILE*, void*),void *arg){
|
||||
rawDataReadyCallBack=func;
|
||||
pRawDataReady=arg;
|
||||
}
|
||||
|
@ -27,19 +27,17 @@ int64_t slsReceiverUsers::getReceiverVersion(){
|
||||
}
|
||||
|
||||
|
||||
void slsReceiverUsers::registerCallBackStartAcquisition(int (*func)(char*, char*,int, int, void*),void *arg){
|
||||
void slsReceiverUsers::registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg){
|
||||
receiver->registerCallBackStartAcquisition(func,arg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void slsReceiverUsers::registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg){
|
||||
void slsReceiverUsers::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){
|
||||
receiver->registerCallBackAcquisitionFinished(func,arg);
|
||||
}
|
||||
|
||||
|
||||
void slsReceiverUsers::registerCallBackRawDataReady(void (*func)(int, char*, int, FILE*, char*, void*),void *arg){
|
||||
void slsReceiverUsers::registerCallBackRawDataReady(void (*func)(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp,
|
||||
uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version,
|
||||
char* datapointer, uint32_t datasize, FILE* filedescriptor, void*), void *arg){
|
||||
receiver->registerCallBackRawDataReady(func,arg);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user