mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-16 08:09:21 +01:00
after merging with developer
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <string.h>
|
||||
using namespace std;
|
||||
|
||||
#define MAX_MASTER_FILE_LENGTH 2000
|
||||
|
||||
@@ -44,10 +43,10 @@ class BinaryFileStatic {
|
||||
static std::string CreateFileName(char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable,
|
||||
uint64_t fnum = 0, int dindex = -1, int numunits = 1, int unitindex = 0)
|
||||
{
|
||||
ostringstream osfn;
|
||||
std::ostringstream osfn;
|
||||
osfn << fpath << "/" << fnameprefix;
|
||||
if (dindex >= 0) osfn << "_d" << (dindex * numunits + unitindex);
|
||||
if (frindexenable) osfn << "_f" << setfill('0') << setw(12) << fnum;
|
||||
if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << fnum;
|
||||
osfn << "_" << findex;
|
||||
osfn << ".raw";
|
||||
return osfn.str();
|
||||
@@ -60,9 +59,9 @@ class BinaryFileStatic {
|
||||
* @param findex file index
|
||||
* @returns master file name
|
||||
*/
|
||||
string CreateMasterFileName(char* fpath, char* fnameprefix, uint64_t findex)
|
||||
std::string CreateMasterFileName(char* fpath, char* fnameprefix, uint64_t findex)
|
||||
{
|
||||
ostringstream osfn;
|
||||
std::ostringstream osfn;
|
||||
osfn << fpath << "/" << fnameprefix;
|
||||
osfn << "_master";
|
||||
osfn << "_" << findex;
|
||||
@@ -115,7 +114,7 @@ class BinaryFileStatic {
|
||||
* @param version version of software for binary writing
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
static int CreateMasterDataFile(FILE*& fd, string fname, bool owenable,
|
||||
static int CreateMasterDataFile(FILE*& fd, std::string fname, bool owenable,
|
||||
uint32_t dr, bool tenE, uint32_t size,
|
||||
uint32_t nPixelsX, uint32_t nPixelsY, uint64_t nf,
|
||||
uint32_t maxf,
|
||||
@@ -140,8 +139,8 @@ class BinaryFileStatic {
|
||||
"Dynamic Range : %d\n"
|
||||
"Ten Giga : %d\n"
|
||||
"Image Size : %d bytes\n"
|
||||
"x : %d pixels\n"
|
||||
"y : %d pixels\n"
|
||||
"row : %d pixels\n"
|
||||
"col : %d pixels\n"
|
||||
"Max. Frames Per File : %u\n"
|
||||
"Total Frames : %lld\n"
|
||||
"Exptime (ns) : %lld\n"
|
||||
@@ -157,9 +156,9 @@ class BinaryFileStatic {
|
||||
"Bunch ID : 8 bytes\n"
|
||||
"Timestamp : 8 bytes\n"
|
||||
"Module Id : 2 bytes\n"
|
||||
"X Coordinate : 2 bytes\n"
|
||||
"Y Coordinate : 2 bytes\n"
|
||||
"Z Coordinate : 2 bytes\n"
|
||||
"Row : 2 bytes\n"
|
||||
"Column : 2 bytes\n"
|
||||
"Reserved : 2 bytes\n"
|
||||
"Debug : 4 bytes\n"
|
||||
"Round Robin Number : 2 bytes\n"
|
||||
"Detector Type : 1 byte\n"
|
||||
|
||||
@@ -35,6 +35,9 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
* @param freq pointer to streaming frequency
|
||||
* @param timer pointer to timer if streaming frequency is random
|
||||
* @param fp pointer to frame padding enable
|
||||
* @param act pointer to activated
|
||||
* @param depaden pointer to deactivated padding enable
|
||||
* @param sm pointer to silent mode
|
||||
* @param dataReadycb pointer to data ready call back function
|
||||
* @param dataModifyReadycb pointer to data ready call back function with modified
|
||||
* @param pDataReadycb pointer to arguments of data ready call back function. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
|
||||
@@ -42,7 +45,7 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
DataProcessor(int ind, detectorType dtype, Fifo*& f, fileFormat* ftype,
|
||||
bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
||||
uint32_t* freq, uint32_t* timer,
|
||||
bool* fp,
|
||||
bool* fp, bool* act, bool* depaden, bool* sm,
|
||||
void (*dataReadycb)(char*, char*, uint32_t, void*),
|
||||
void (*dataModifyReadycb)(char*, char*, uint32_t &, void*),
|
||||
void *pDataReadycb);
|
||||
@@ -200,11 +203,7 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
*/
|
||||
void SetPixelDimension();
|
||||
|
||||
/**
|
||||
* Set Silent Mode
|
||||
* @param mode 1 sets 0 unsets
|
||||
*/
|
||||
void SetSilentMode(bool mode);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
@@ -333,10 +332,17 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/** temporary buffer for processing */
|
||||
char* tempBuffer;
|
||||
|
||||
/** x coord hardcoded ad 1D, if detector does not send them yet **/
|
||||
uint16_t xcoordin1D;
|
||||
/** Activated/Deactivated */
|
||||
bool* activated;
|
||||
|
||||
/** Deactivated padding enable */
|
||||
bool* deactivatedPaddingEnable;
|
||||
|
||||
/** Silent Mode */
|
||||
bool* silentMode;
|
||||
|
||||
/** frame padding */
|
||||
bool* framePadding;
|
||||
|
||||
//acquisition start
|
||||
/** Aquisition Started flag */
|
||||
@@ -363,12 +369,6 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
uint64_t currentFrameIndex;
|
||||
|
||||
|
||||
/** Silent Mode */
|
||||
bool silentMode;
|
||||
|
||||
/** frame padding */
|
||||
bool* framePadding;
|
||||
|
||||
//call back
|
||||
/**
|
||||
* Call back for raw data
|
||||
@@ -380,7 +380,6 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
void (*rawDataReadyCallBack)(char*,
|
||||
char*, uint32_t, void*);
|
||||
|
||||
|
||||
/**
|
||||
* Call back for raw data (modified)
|
||||
* args to raw data ready callback are
|
||||
|
||||
@@ -14,6 +14,8 @@ class Fifo;
|
||||
class DataStreamer;
|
||||
class ZmqSocket;
|
||||
|
||||
#include <vector>
|
||||
|
||||
class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
|
||||
public:
|
||||
@@ -23,12 +25,14 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
* @param ind self index
|
||||
* @param f address of Fifo pointer
|
||||
* @param dr pointer to dynamic range
|
||||
* @param sEnable pointer to short frame enable
|
||||
* @param r roi
|
||||
* @param fi pointer to file index
|
||||
* @param fd flipped data enable for x and y dimensions
|
||||
* @param ajh additional json header
|
||||
* @param sm pointer to silent mode
|
||||
*/
|
||||
DataStreamer(int ind, Fifo*& f, uint32_t* dr, int* sEnable, uint64_t* fi, int* fd, char* ajh);
|
||||
DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI>* r,
|
||||
uint64_t* fi, int* fd, char* ajh, bool* sm);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@@ -104,11 +108,6 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
*/
|
||||
int RestreamStop();
|
||||
|
||||
/**
|
||||
* Set Silent Mode
|
||||
* @param mode 1 sets 0 unsets
|
||||
*/
|
||||
void SetSilentMode(bool mode);
|
||||
|
||||
private:
|
||||
|
||||
@@ -175,12 +174,25 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/** Pointer to dynamic range */
|
||||
uint32_t* dynamicRange;
|
||||
|
||||
/** Pointer to short frame enable */
|
||||
int* shortFrameEnable;
|
||||
/** ROI */
|
||||
std::vector<ROI>* roi;
|
||||
|
||||
/** adc Configured */
|
||||
int adcConfigured;
|
||||
|
||||
/** Pointer to file index */
|
||||
uint64_t* fileIndex;
|
||||
|
||||
/** flipped data across both dimensions enable */
|
||||
int* flippedData;
|
||||
|
||||
/** additional json header */
|
||||
char* additionJsonHeader;
|
||||
|
||||
/** Silent Mode */
|
||||
bool* silentMode;
|
||||
|
||||
|
||||
/** Aquisition Started flag */
|
||||
bool acquisitionStartedFlag;
|
||||
|
||||
@@ -199,13 +211,5 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/** Complete buffer used for roi, eg. shortGotthard */
|
||||
char* completeBuffer;
|
||||
|
||||
/** flipped data across both dimensions enable */
|
||||
int* flippedData;
|
||||
|
||||
/** additional json header */
|
||||
char* additionJsonHeader;
|
||||
|
||||
/** Silent Mode */
|
||||
bool silentMode;
|
||||
};
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ class File : private virtual slsReceiverDefs {
|
||||
uint32_t* udpPortNumber;
|
||||
|
||||
/** Silent Mode */
|
||||
bool silentMode;
|
||||
bool* silentMode;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "receiver_defs.h"
|
||||
|
||||
#include <math.h> //ceil
|
||||
#include <vector>
|
||||
|
||||
|
||||
class GeneralData {
|
||||
@@ -155,6 +156,25 @@ public:
|
||||
frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ROI
|
||||
* @param i ROI
|
||||
*/
|
||||
virtual void SetROI(std::vector<slsReceiverDefs::ROI> i) {
|
||||
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Adc configured
|
||||
* @param index thread index for debugging purposes
|
||||
* @param i pointer to a vector of ROI pointers
|
||||
* @returns adc configured
|
||||
*/
|
||||
virtual const int GetAdcConfigured(int index, std::vector<slsReceiverDefs::ROI>* i) const{
|
||||
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Setting dynamic range changes member variables
|
||||
* @param dr dynamic range
|
||||
@@ -225,6 +245,10 @@ public:
|
||||
|
||||
class GotthardData : public GeneralData {
|
||||
|
||||
private:
|
||||
const static int nChip = 10;
|
||||
const static int nChan = 128;
|
||||
const static int nChipsPerAdc = 2;
|
||||
public:
|
||||
|
||||
/** Constructor */
|
||||
@@ -244,32 +268,8 @@ class GotthardData : public GeneralData {
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header);
|
||||
defaultFifoDepth = 50000;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
class ShortGotthardData : public GeneralData {
|
||||
|
||||
public:
|
||||
|
||||
/** Constructor */
|
||||
ShortGotthardData(){
|
||||
myDetectorType = slsReceiverDefs::GOTTHARD;
|
||||
nPixelsX = 256;
|
||||
nPixelsY = 1;
|
||||
headerSizeinPacket = 4;
|
||||
dataSize = 512;
|
||||
packetSize = 518;
|
||||
packetsPerFrame = 1;
|
||||
imageSize = dataSize*packetsPerFrame;
|
||||
frameIndexMask = 0xFFFFFFFF;
|
||||
maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header);
|
||||
defaultFifoDepth = 50000;
|
||||
nPixelsXComplete = 1280;
|
||||
nPixelsYComplete = 1;
|
||||
imageSizeComplete = 1280 * 2;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Header Infomation (frame number, packet number)
|
||||
* @param index thread index for debugging purposes
|
||||
@@ -279,8 +279,15 @@ class ShortGotthardData : public GeneralData {
|
||||
*/
|
||||
virtual void GetHeaderInfo(int index, char* packetData, uint64_t& frameNumber, uint32_t& packetNumber) const
|
||||
{
|
||||
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
|
||||
packetNumber = 0;
|
||||
if (nPixelsX == 1280) {
|
||||
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
|
||||
frameNumber++;
|
||||
packetNumber = frameNumber&packetIndexMask;
|
||||
frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset;
|
||||
} else {
|
||||
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
|
||||
packetNumber = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,11 +303,96 @@ class ShortGotthardData : public GeneralData {
|
||||
virtual void GetHeaderInfo(int index, char* packetData, uint32_t dynamicRange,
|
||||
uint64_t& frameNumber, uint32_t& packetNumber, uint32_t& subFrameNumber, uint64_t& bunchId) const
|
||||
{
|
||||
subFrameNumber = -1;
|
||||
bunchId = -1;
|
||||
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
|
||||
packetNumber = 0;
|
||||
if (nPixelsX == 1280) {
|
||||
subFrameNumber = -1;
|
||||
bunchId = -1;
|
||||
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
|
||||
frameNumber++;
|
||||
packetNumber = frameNumber&packetIndexMask;
|
||||
frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset;
|
||||
} else {
|
||||
subFrameNumber = -1;
|
||||
bunchId = -1;
|
||||
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
|
||||
packetNumber = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set ROI
|
||||
* @param i ROI
|
||||
*/
|
||||
virtual void SetROI(std::vector<slsReceiverDefs::ROI> i) {
|
||||
// all adcs
|
||||
if(!i.size()) {
|
||||
nPixelsX = 1280;
|
||||
dataSize = 1280;
|
||||
packetSize = GOTTHARD_PACKET_SIZE;
|
||||
packetsPerFrame = 2;
|
||||
imageSize = dataSize*packetsPerFrame;
|
||||
frameIndexMask = 0xFFFFFFFE;
|
||||
frameIndexOffset = 1;
|
||||
packetIndexMask = 1;
|
||||
maxFramesPerFile = MAX_FRAMES_PER_FILE;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header);
|
||||
defaultFifoDepth = 50000;
|
||||
nPixelsXComplete = 0;
|
||||
nPixelsYComplete = 0;
|
||||
imageSizeComplete = 0;
|
||||
}
|
||||
|
||||
// single adc
|
||||
else {
|
||||
nPixelsX = 256;
|
||||
dataSize = 512;
|
||||
packetSize = 518;
|
||||
packetsPerFrame = 1;
|
||||
imageSize = dataSize*packetsPerFrame;
|
||||
frameIndexMask = 0xFFFFFFFF;
|
||||
frameIndexOffset = 0;
|
||||
packetIndexMask = 0;
|
||||
maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header);
|
||||
defaultFifoDepth = 25000;
|
||||
nPixelsXComplete = 1280;
|
||||
nPixelsYComplete = 1;
|
||||
imageSizeComplete = 1280 * 2;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Adc configured
|
||||
* @param index thread index for debugging purposes
|
||||
* @param i pointer to a vector of ROI
|
||||
* @returns adc configured
|
||||
*/
|
||||
virtual const int GetAdcConfigured(int index, std::vector<slsReceiverDefs::ROI>* i) const{
|
||||
int adc = -1;
|
||||
// single adc
|
||||
if(i->size()) {
|
||||
// gotthard can have only one adc per detector enabled (or all)
|
||||
// so just looking at the first roi is enough (more not possible at the moment)
|
||||
|
||||
//if its for 1 adc or general
|
||||
if ((i->at(0).xmin == 0) && (i->at(0).xmax == nChip * nChan))
|
||||
adc = -1;
|
||||
else {
|
||||
//adc = mid value/numchans also for only 1 roi
|
||||
adc = ((((i->at(0).xmax) + (i->at(0).xmin))/2)/
|
||||
(nChan * nChipsPerAdc));
|
||||
if((adc < 0) || (adc > 4)) {
|
||||
FILE_LOG(logWARNING) << index << ": Deleting ROI. "
|
||||
"Adc value should be between 0 and 4";
|
||||
adc = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO) << "Adc Configured: " << adc;
|
||||
return adc;
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -114,6 +114,9 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
|
||||
*/
|
||||
void EndofAcquisition(bool anyPacketsCaught, uint64_t numf);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Create Virtual File
|
||||
* @param numf number of images caught
|
||||
@@ -121,8 +124,12 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
|
||||
*/
|
||||
int CreateVirtualFile(uint64_t numf);
|
||||
|
||||
|
||||
private:
|
||||
/**
|
||||
* Link virtual file in master file
|
||||
* Only for Jungfrau at the moment for 1 module and 1 data file
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int LinkVirtualFileinMasterFile();
|
||||
|
||||
/**
|
||||
* Get Type
|
||||
@@ -174,16 +181,16 @@ class HDF5File : private virtual slsReceiverDefs, public File, public HDF5FileSt
|
||||
int numFilesinAcquisition;
|
||||
|
||||
/** parameter names */
|
||||
vector <const char*> parameterNames;
|
||||
std::vector <const char*> parameterNames;
|
||||
|
||||
/** parameter data types */
|
||||
vector <DataType> parameterDataTypes;
|
||||
std::vector <DataType> parameterDataTypes;
|
||||
|
||||
/** Dataspace of parameters */
|
||||
DataSpace* dataspace_para;
|
||||
|
||||
/** Dataset array for parameters */
|
||||
vector <DataSet*> dataset_para;
|
||||
std::vector <DataSet*> dataset_para;
|
||||
|
||||
/** Number of Images (including extended during acquisition) */
|
||||
uint64_t extNumImages;
|
||||
|
||||
@@ -23,7 +23,6 @@ using namespace H5;
|
||||
#include <stdlib.h> //malloc
|
||||
#include <sstream>
|
||||
#include <cstring> //memset
|
||||
using namespace std;
|
||||
|
||||
class HDF5FileStatic: public virtual slsReceiverDefs {
|
||||
|
||||
@@ -48,13 +47,13 @@ public:
|
||||
* @param unitindex unit index
|
||||
* @returns complete file name created
|
||||
*/
|
||||
static string CreateFileName(char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable,
|
||||
static std::string CreateFileName(char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable,
|
||||
uint64_t fnum = 0, int dindex = -1, int numunits = 1, int unitindex = 0)
|
||||
{
|
||||
ostringstream osfn;
|
||||
std::ostringstream osfn;
|
||||
osfn << fpath << "/" << fnameprefix;
|
||||
if (dindex >= 0) osfn << "_d" << (dindex * numunits + unitindex);
|
||||
if (frindexenable) osfn << "_f" << setfill('0') << setw(12) << fnum;
|
||||
if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << fnum;
|
||||
osfn << "_" << findex;
|
||||
osfn << ".h5";
|
||||
return osfn.str();
|
||||
@@ -67,9 +66,9 @@ public:
|
||||
* @param findex file index
|
||||
* @returns master file name
|
||||
*/
|
||||
static string CreateMasterFileName(char* fpath, char* fnameprefix, uint64_t findex)
|
||||
static std::string CreateMasterFileName(char* fpath, char* fnameprefix, uint64_t findex)
|
||||
{
|
||||
ostringstream osfn;
|
||||
std::ostringstream osfn;
|
||||
osfn << fpath << "/" << fnameprefix;
|
||||
osfn << "_master";
|
||||
osfn << "_" << findex;
|
||||
@@ -85,9 +84,9 @@ public:
|
||||
* @param findex file index
|
||||
* @returns virtual file name
|
||||
*/
|
||||
static string CreateVirtualFileName(char* fpath, char* fnameprefix, uint64_t findex)
|
||||
static std::string CreateVirtualFileName(char* fpath, char* fnameprefix, uint64_t findex)
|
||||
{
|
||||
ostringstream osfn;
|
||||
std::ostringstream osfn;
|
||||
osfn << fpath << "/" << fnameprefix;
|
||||
osfn << "_virtual";
|
||||
osfn << "_" << findex;
|
||||
@@ -197,29 +196,30 @@ public:
|
||||
* @param parameterDataTypes parameter datatypes
|
||||
*/
|
||||
static int WriteParameterDatasets(int ind, DataSpace* dspace_para, uint64_t fnum,
|
||||
vector <DataSet*> dset_para,sls_receiver_header* rheader,
|
||||
vector <DataType> parameterDataTypes)
|
||||
std::vector <DataSet*> dset_para,sls_receiver_header* rheader,
|
||||
std::vector <DataType> parameterDataTypes)
|
||||
{
|
||||
sls_detector_header header = rheader->detHeader;
|
||||
hsize_t count[1] = {1};
|
||||
hsize_t start[1] = {fnum};
|
||||
int i = 0;
|
||||
try{
|
||||
Exception::dontPrint(); //to handle errors
|
||||
dspace_para->selectHyperslab( H5S_SELECT_SET, count, start);
|
||||
DataSpace memspace(H5S_SCALAR);
|
||||
dset_para[0]->write(&header.frameNumber, parameterDataTypes[0], memspace, *dspace_para);
|
||||
dset_para[1]->write(&header.expLength, parameterDataTypes[1], memspace, *dspace_para);
|
||||
dset_para[2]->write(&header.packetNumber, parameterDataTypes[2], memspace, *dspace_para);
|
||||
dset_para[3]->write(&header.bunchId, parameterDataTypes[3], memspace, *dspace_para);
|
||||
dset_para[4]->write(&header.timestamp, parameterDataTypes[4], memspace, *dspace_para);
|
||||
dset_para[5]->write(&header.modId, parameterDataTypes[5], memspace, *dspace_para);
|
||||
dset_para[6]->write(&header.xCoord, parameterDataTypes[6], memspace, *dspace_para);
|
||||
dset_para[7]->write(&header.yCoord, parameterDataTypes[7], memspace, *dspace_para);
|
||||
dset_para[8]->write(&header.zCoord, parameterDataTypes[8], memspace, *dspace_para);
|
||||
dset_para[9]->write(&header.debug, parameterDataTypes[9], memspace, *dspace_para);
|
||||
dset_para[10]->write(&header.roundRNumber, parameterDataTypes[10], memspace, *dspace_para);
|
||||
dset_para[11]->write(&header.detType, parameterDataTypes[11], memspace, *dspace_para);
|
||||
dset_para[12]->write(&header.version, parameterDataTypes[12], memspace, *dspace_para);
|
||||
dset_para[0]->write(&header.frameNumber, parameterDataTypes[0], memspace, *dspace_para);i=1;
|
||||
dset_para[1]->write(&header.expLength, parameterDataTypes[1], memspace, *dspace_para);i=2;
|
||||
dset_para[2]->write(&header.packetNumber, parameterDataTypes[2], memspace, *dspace_para);i=3;
|
||||
dset_para[3]->write(&header.bunchId, parameterDataTypes[3], memspace, *dspace_para);i=4;
|
||||
dset_para[4]->write(&header.timestamp, parameterDataTypes[4], memspace, *dspace_para);i=5;
|
||||
dset_para[5]->write(&header.modId, parameterDataTypes[5], memspace, *dspace_para);i=6;
|
||||
dset_para[6]->write(&header.row, parameterDataTypes[6], memspace, *dspace_para);i=7;
|
||||
dset_para[7]->write(&header.column, parameterDataTypes[7], memspace, *dspace_para);i=8;
|
||||
dset_para[8]->write(&header.reserved, parameterDataTypes[8], memspace, *dspace_para);i=9;
|
||||
dset_para[9]->write(&header.debug, parameterDataTypes[9], memspace, *dspace_para);i=10;
|
||||
dset_para[10]->write(&header.roundRNumber, parameterDataTypes[10], memspace, *dspace_para);i=11;
|
||||
dset_para[11]->write(&header.detType, parameterDataTypes[11], memspace, *dspace_para);i=12;
|
||||
dset_para[12]->write(&header.version, parameterDataTypes[12], memspace, *dspace_para);i=13;
|
||||
|
||||
// contiguous bitset
|
||||
if (sizeof(sls_bitset) == sizeof(bitset_storage)) {
|
||||
@@ -236,10 +236,10 @@ public:
|
||||
storage[i >> 3] |= (bits[i] << (i & 7));
|
||||
// write bitmask
|
||||
dset_para[13]->write((char*)storage, parameterDataTypes[13], memspace, *dspace_para);
|
||||
}
|
||||
}i=14;
|
||||
}
|
||||
catch(Exception error){
|
||||
cprintf(RED,"Error in writing parameters to file in object %d\n",ind);
|
||||
cprintf(RED,"Error in writing parameters (index:%d) to file in object %d\n", i, ind);
|
||||
error.printErrorStack();
|
||||
return 1;
|
||||
}
|
||||
@@ -259,7 +259,7 @@ public:
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
static int ExtendDataset(int ind, DataSpace*& dspace, DataSet* dset,
|
||||
DataSpace*& dspace_para, vector <DataSet*> dset_para,
|
||||
DataSpace*& dspace_para, std::vector <DataSet*> dset_para,
|
||||
uint64_t initialNumImages) {
|
||||
try{
|
||||
Exception::dontPrint(); //to handle errors
|
||||
@@ -270,12 +270,14 @@ public:
|
||||
|
||||
dset->extend(dims);
|
||||
delete dspace;
|
||||
dspace = 0;
|
||||
dspace = new DataSpace(dset->getSpace());
|
||||
|
||||
hsize_t dims_para[1] = {dims[0]};
|
||||
for (unsigned int i = 0; i < dset_para.size(); ++i)
|
||||
dset_para[i]->extend(dims_para);
|
||||
delete dspace_para;
|
||||
dspace_para = 0;
|
||||
dspace_para = new DataSpace(dset_para[0]->getSpace());
|
||||
|
||||
}
|
||||
@@ -306,7 +308,7 @@ public:
|
||||
* @param version version of software for hdf5 writing
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
static int CreateMasterDataFile(H5File*& fd, string fname, bool owenable,
|
||||
static int CreateMasterDataFile(H5File*& fd, std::string fname, bool owenable,
|
||||
uint32_t dr, bool tenE, uint32_t size,
|
||||
uint32_t nPixelsx, uint32_t nPixelsy, uint64_t nf,
|
||||
uint32_t maxf,
|
||||
@@ -318,6 +320,7 @@ public:
|
||||
|
||||
FileAccPropList flist;
|
||||
flist.setFcloseDegree(H5F_CLOSE_STRONG);
|
||||
fd = 0;
|
||||
if(!owenable)
|
||||
fd = new H5File( fname.c_str(), H5F_ACC_EXCL,
|
||||
FileCreatPropList::DEFAULT,
|
||||
@@ -353,7 +356,7 @@ public:
|
||||
dataset = group5.createDataSet ( "dynamic range", PredType::NATIVE_INT, dataspace );
|
||||
dataset.write ( &dr, PredType::NATIVE_INT);
|
||||
attribute = dataset.createAttribute("unit",strdatatype, dataspace);
|
||||
attribute.write(strdatatype, string("bits"));
|
||||
attribute.write(strdatatype, std::string("bits"));
|
||||
|
||||
//Ten Giga
|
||||
iValue = tenE;
|
||||
@@ -364,7 +367,7 @@ public:
|
||||
dataset = group5.createDataSet ( "image size", PredType::NATIVE_INT, dataspace );
|
||||
dataset.write ( &size, PredType::NATIVE_INT);
|
||||
attribute = dataset.createAttribute("unit",strdatatype, dataspace);
|
||||
attribute.write(strdatatype, string("bytes"));
|
||||
attribute.write(strdatatype, std::string("bytes"));
|
||||
|
||||
//x
|
||||
dataset = group5.createDataSet ( "number of pixels in x axis", PredType::NATIVE_INT, dataspace );
|
||||
@@ -386,36 +389,37 @@ public:
|
||||
dataset = group5.createDataSet ( "exposure time", PredType::STD_U64LE, dataspace );
|
||||
dataset.write ( &acquisitionTime, PredType::STD_U64LE);
|
||||
attribute = dataset.createAttribute("unit",strdatatype, dataspace);
|
||||
attribute.write(strdatatype, string("ns"));
|
||||
attribute.write(strdatatype, std::string("ns"));
|
||||
|
||||
//SubExptime
|
||||
dataset = group5.createDataSet ( "sub exposure time", PredType::STD_U64LE, dataspace );
|
||||
dataset.write ( &subexposuretime, PredType::STD_U64LE);
|
||||
attribute = dataset.createAttribute("unit",strdatatype, dataspace);
|
||||
attribute.write(strdatatype, string("ns"));
|
||||
attribute.write(strdatatype, std::string("ns"));
|
||||
|
||||
//SubPeriod
|
||||
dataset = group5.createDataSet ( "sub period", PredType::STD_U64LE, dataspace );
|
||||
dataset.write ( &subperiod, PredType::STD_U64LE);
|
||||
attribute = dataset.createAttribute("unit",strdatatype, dataspace);
|
||||
attribute.write(strdatatype, string("ns"));
|
||||
attribute.write(strdatatype, std::string("ns"));
|
||||
|
||||
//Period
|
||||
dataset = group5.createDataSet ( "acquisition period", PredType::STD_U64LE, dataspace );
|
||||
dataset.write ( &acquisitionPeriod, PredType::STD_U64LE);
|
||||
attribute = dataset.createAttribute("unit",strdatatype, dataspace);
|
||||
attribute.write(strdatatype, string("ns"));
|
||||
attribute.write(strdatatype, std::string("ns"));
|
||||
|
||||
//Timestamp
|
||||
time_t t = time(0);
|
||||
dataset = group5.createDataSet ( "timestamp", strdatatype, dataspace );
|
||||
dataset.write ( string(ctime(&t)), strdatatype );
|
||||
dataset.write ( std::string(ctime(&t)), strdatatype );
|
||||
|
||||
fd->close();
|
||||
|
||||
} catch(Exception error) {
|
||||
cprintf(RED,"Error in creating master HDF5 handles\n");
|
||||
error.printErrorStack();
|
||||
if (fd) fd->close();
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -445,13 +449,13 @@ public:
|
||||
* @param parameterDataTypes parameter datatypes
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
static int CreateDataFile(int ind, bool owenable, string fname, bool frindexenable,
|
||||
static int CreateDataFile(int ind, bool owenable, std::string fname, bool frindexenable,
|
||||
uint64_t fnum, uint64_t nDimx, uint32_t nDimy, uint32_t nDimz,
|
||||
DataType dtype, H5File*& fd, DataSpace*& dspace, DataSet*& dset,
|
||||
double version, uint64_t maxchunkedimages,
|
||||
DataSpace*& dspace_para, vector<DataSet*>& dset_para,
|
||||
vector <const char*> parameterNames,
|
||||
vector <DataType> parameterDataTypes)
|
||||
DataSpace*& dspace_para, std::vector<DataSet*>& dset_para,
|
||||
std::vector <const char*> parameterNames,
|
||||
std::vector <DataType> parameterDataTypes)
|
||||
{
|
||||
try {
|
||||
Exception::dontPrint(); //to handle errors
|
||||
@@ -459,6 +463,7 @@ public:
|
||||
//file
|
||||
FileAccPropList fapl;
|
||||
fapl.setFcloseDegree(H5F_CLOSE_STRONG);
|
||||
fd = 0;
|
||||
if(!owenable)
|
||||
fd = new H5File( fname.c_str(), H5F_ACC_EXCL,
|
||||
FileCreatPropList::DEFAULT,
|
||||
@@ -477,14 +482,15 @@ public:
|
||||
//dataspace
|
||||
hsize_t srcdims[3] = {nDimx, nDimy, nDimz};
|
||||
hsize_t srcdimsmax[3] = {H5S_UNLIMITED, nDimy, nDimz};
|
||||
dspace = 0;
|
||||
dspace = new DataSpace (3,srcdims,srcdimsmax);
|
||||
|
||||
|
||||
//dataset name
|
||||
ostringstream osfn;
|
||||
std::ostringstream osfn;
|
||||
osfn << "/data";
|
||||
if (frindexenable) osfn << "_f" << setfill('0') << setw(12) << fnum;
|
||||
string dsetname = osfn.str();
|
||||
if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << fnum;
|
||||
std::string dsetname = osfn.str();
|
||||
|
||||
//dataset
|
||||
//fill value
|
||||
@@ -494,11 +500,13 @@ public:
|
||||
// always create chunked dataset as unlimited is only supported with chunked layout
|
||||
hsize_t chunk_dims[3] ={maxchunkedimages, nDimy, nDimz};
|
||||
plist.setChunk(3, chunk_dims);
|
||||
dset = 0;
|
||||
dset = new DataSet (fd->createDataSet(dsetname.c_str(), dtype, *dspace, plist));
|
||||
|
||||
//create parameter datasets
|
||||
hsize_t dims[1] = {nDimx};
|
||||
hsize_t dimsmax[1] = {H5S_UNLIMITED};
|
||||
dspace_para = 0;
|
||||
dspace_para = new DataSpace (1,dims,dimsmax);
|
||||
|
||||
// always create chunked dataset as unlimited is only supported with chunked layout
|
||||
@@ -515,7 +523,7 @@ public:
|
||||
catch(Exception error){
|
||||
cprintf(RED,"Error in creating HDF5 handles in object %d\n",ind);
|
||||
error.printErrorStack();
|
||||
fd->close();
|
||||
if (fd) fd->close();
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -525,6 +533,7 @@ public:
|
||||
/**
|
||||
* Create virtual file
|
||||
* (in C because H5Pset_virtual doesnt exist yet in C++)
|
||||
* @param virtualFileName virtual file name
|
||||
* @param fd virtual file handle
|
||||
* @param masterFileName master file name
|
||||
* @param fpath file path
|
||||
@@ -547,55 +556,52 @@ public:
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
static int CreateVirtualDataFile(
|
||||
hid_t& fd, string masterFileName,
|
||||
std::string virtualFileName,
|
||||
hid_t& fd, std::string masterFileName,
|
||||
char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable,
|
||||
int dindex, int numunits,
|
||||
uint32_t maxFramesPerFile, uint64_t numf,
|
||||
string srcDataseName, DataType dataType,
|
||||
std::string srcDataseName, DataType dataType,
|
||||
int numDety, int numDetz, uint32_t nDimy, uint32_t nDimz,
|
||||
double version,
|
||||
vector <const char*> parameterNames,
|
||||
vector <DataType> parameterDataTypes)
|
||||
std::vector <const char*> parameterNames,
|
||||
std::vector <DataType> parameterDataTypes)
|
||||
{
|
||||
//virtual names
|
||||
string virtualFileName = CreateVirtualFileName(fpath, fnameprefix, findex);
|
||||
FILE_LOG(logINFO) << "Virtual File: " << virtualFileName;
|
||||
|
||||
//file
|
||||
hid_t dfal = H5Pcreate (H5P_FILE_ACCESS);
|
||||
if (dfal < 0)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in creating file access property for virtual file ")
|
||||
+ virtualFileName + string("\n"));
|
||||
std::string("Error in creating file access property for virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
if (H5Pset_fclose_degree (dfal, H5F_CLOSE_STRONG) < 0)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in setting strong file close degree for virtual file ")
|
||||
+ virtualFileName + string("\n"));
|
||||
std::string("Error in setting strong file close degree for virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
fd = H5Fcreate( virtualFileName.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, dfal);
|
||||
if (fd < 0)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in creating virtual file ") + virtualFileName + string("\n"));
|
||||
std::string("Error in creating virtual file ") + virtualFileName + std::string("\n"));
|
||||
|
||||
//attributes - version
|
||||
hid_t dataspace_attr = H5Screate (H5S_SCALAR);
|
||||
if (dataspace_attr < 0)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in creating dataspace for attribute in virtual file ")
|
||||
+ virtualFileName + string("\n"));
|
||||
std::string("Error in creating dataspace for attribute in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
hid_t attrid = H5Acreate2 (fd, "version", H5T_NATIVE_DOUBLE, dataspace_attr, H5P_DEFAULT, H5P_DEFAULT);
|
||||
if (attrid < 0)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in creating attribute in virtual file ")
|
||||
+ virtualFileName + string("\n"));
|
||||
std::string("Error in creating attribute in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
double attr_data = version;
|
||||
if (H5Awrite (attrid, H5T_NATIVE_DOUBLE, &attr_data) < 0)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in writing attribute in virtual file ")
|
||||
+ virtualFileName + string("\n"));
|
||||
std::string("Error in writing attribute in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
if (H5Aclose (attrid) < 0)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in closing attribute in virtual file ")
|
||||
+ virtualFileName + string("\n"));
|
||||
std::string("Error in closing attribute in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
|
||||
|
||||
//virtual dataspace
|
||||
@@ -603,38 +609,38 @@ public:
|
||||
hid_t vdsDataspace = H5Screate_simple(3, vdsdims ,NULL);
|
||||
if (vdsDataspace < 0)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in creating virtual dataspace in virtual file ")
|
||||
+ virtualFileName + string("\n"));
|
||||
std::string("Error in creating virtual dataspace in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
hsize_t vdsdims_para[2] = {numf, (unsigned int) numDety * numDetz};
|
||||
hid_t vdsDataspace_para = H5Screate_simple(2, vdsdims_para, NULL);
|
||||
if (vdsDataspace_para < 0)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in creating virtual dataspace (parameters) in virtual file ")
|
||||
+ virtualFileName + string("\n"));
|
||||
std::string("Error in creating virtual dataspace (parameters) in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
|
||||
|
||||
//fill values
|
||||
hid_t dcpl = H5Pcreate (H5P_DATASET_CREATE);
|
||||
if (dcpl < 0)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in creating file creation properties in virtual file ")
|
||||
+ virtualFileName + string("\n"));
|
||||
std::string("Error in creating file creation properties in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
int fill_value = -1;
|
||||
if (H5Pset_fill_value (dcpl, GetDataTypeinC(dataType), &fill_value) < 0)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in creating fill value in virtual file ")
|
||||
+ virtualFileName + string("\n"));
|
||||
std::string("Error in creating fill value in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
hid_t dcpl_para[parameterNames.size()];
|
||||
for (unsigned int i = 0; i < parameterNames.size(); ++i) {
|
||||
dcpl_para[i] = H5Pcreate (H5P_DATASET_CREATE);
|
||||
if (dcpl_para[i] < 0)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in creating file creation properties (parameters) in virtual file ")
|
||||
+ virtualFileName + string("\n"));
|
||||
std::string("Error in creating file creation properties (parameters) in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
if (H5Pset_fill_value (dcpl_para[i], GetDataTypeinC(parameterDataTypes[i]), &fill_value) < 0)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in creating fill value (parameters) in virtual file ")
|
||||
+ virtualFileName + string("\n"));
|
||||
std::string("Error in creating fill value (parameters) in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
}
|
||||
|
||||
//hyperslab
|
||||
@@ -667,22 +673,22 @@ public:
|
||||
}
|
||||
|
||||
//source file name
|
||||
string srcFileName = HDF5FileStatic::CreateFileName(fpath, fnameprefix, findex,
|
||||
std::string srcFileName = HDF5FileStatic::CreateFileName(fpath, fnameprefix, findex,
|
||||
frindexenable, framesSaved, dindex, numunits, i);
|
||||
|
||||
// find relative path
|
||||
string relative_srcFileName = srcFileName;
|
||||
std::string relative_srcFileName = srcFileName;
|
||||
{
|
||||
size_t i = srcFileName.rfind('/', srcFileName.length());
|
||||
if (i != string::npos)
|
||||
if (i != std::string::npos)
|
||||
relative_srcFileName = (srcFileName.substr(i+1, srcFileName.length() - i));
|
||||
}
|
||||
|
||||
//source dataset name
|
||||
ostringstream osfn;
|
||||
std::ostringstream osfn;
|
||||
osfn << "/data";
|
||||
if (frindexenable) osfn << "_f" << setfill('0') << setw(12) << framesSaved;
|
||||
string srcDatasetName = osfn.str();
|
||||
if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << framesSaved;
|
||||
std::string srcDatasetName = osfn.str();
|
||||
|
||||
//source dataspace
|
||||
hsize_t srcdims[3] = {nDimx, nDimy, nDimz};
|
||||
@@ -690,15 +696,15 @@ public:
|
||||
hid_t srcDataspace = H5Screate_simple(3, srcdims, srcdimsmax);
|
||||
if (srcDataspace < 0)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in creating source dataspace in virtual file ")
|
||||
+ virtualFileName + string("\n"));
|
||||
std::string("Error in creating source dataspace in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
hsize_t srcdims_para[1] = {nDimx};
|
||||
hsize_t srcdimsmax_para[1] = {H5S_UNLIMITED};
|
||||
hid_t srcDataspace_para = H5Screate_simple(1, srcdims_para, srcdimsmax_para);
|
||||
if (srcDataspace_para < 0)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in creating source dataspace (parameters) in virtual file ")
|
||||
+ virtualFileName + string("\n"));
|
||||
std::string("Error in creating source dataspace (parameters) in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
|
||||
//mapping
|
||||
if (H5Pset_virtual(dcpl, vdsDataspace, relative_srcFileName.c_str(),
|
||||
@@ -730,17 +736,17 @@ public:
|
||||
}
|
||||
if (error)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in mapping files in virtual file ")
|
||||
+ virtualFileName + string("\n"));
|
||||
std::string("Error in mapping files in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
|
||||
//dataset
|
||||
string virtualDatasetName = srcDataseName;
|
||||
std::string virtualDatasetName = srcDataseName;
|
||||
hid_t vdsdataset = H5Dcreate2 (fd, virtualDatasetName.c_str(),
|
||||
GetDataTypeinC(dataType), vdsDataspace, H5P_DEFAULT, dcpl, H5P_DEFAULT);
|
||||
if (vdsdataset < 0)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in creating virutal dataset in virtual file ")
|
||||
+ virtualFileName + string("\n"));
|
||||
std::string("Error in creating virutal dataset in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
|
||||
|
||||
//virtual parameter dataset
|
||||
@@ -751,8 +757,8 @@ public:
|
||||
H5P_DEFAULT, dcpl_para[i], H5P_DEFAULT);
|
||||
if (vdsdataset_para < 0)
|
||||
return CloseFileOnError(fd,
|
||||
string("Error in creating virutal dataset (parameters) in virtual file ")
|
||||
+ virtualFileName + string("\n"));
|
||||
std::string("Error in creating virutal dataset (parameters) in virtual file ")
|
||||
+ virtualFileName + std::string("\n"));
|
||||
}
|
||||
|
||||
//close
|
||||
@@ -779,8 +785,8 @@ public:
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
template <typename T>
|
||||
static int CopyVirtualFile(T datatype, bool owenable, string oldFileName, string oldDatasetName,
|
||||
string newFileName, string newDatasetName, int rank,
|
||||
static int CopyVirtualFile(T datatype, bool owenable, std::string oldFileName, std::string oldDatasetName,
|
||||
std::string newFileName, std::string newDatasetName, int rank,
|
||||
uint64_t nDimx, uint32_t nDimy, uint32_t nDimz=0)
|
||||
{
|
||||
T *data_out;
|
||||
@@ -807,14 +813,14 @@ public:
|
||||
FILE_LOG(logERROR) << "unknown datatype";
|
||||
return 1;
|
||||
}
|
||||
FILE_LOG(logINFO) << "owenable:" << (owenable?1:0) << endl
|
||||
<< "oldFileName:" << oldFileName << endl
|
||||
<< "oldDatasetName:" << oldDatasetName << endl
|
||||
<< "newFileName:" << newFileName << endl
|
||||
<< "newDatasetName:" << newDatasetName << endl
|
||||
<< "rank:" << rank << endl
|
||||
<< "nDimx:" << nDimx << endl
|
||||
<< "nDimy:" << nDimy << endl
|
||||
FILE_LOG(logINFO) << "owenable:" << (owenable?1:0) << std::endl
|
||||
<< "oldFileName:" << oldFileName << std::endl
|
||||
<< "oldDatasetName:" << oldDatasetName << std::endl
|
||||
<< "newFileName:" << newFileName << std::endl
|
||||
<< "newDatasetName:" << newDatasetName << std::endl
|
||||
<< "rank:" << rank << std::endl
|
||||
<< "nDimx:" << nDimx << std::endl
|
||||
<< "nDimy:" << nDimy << std::endl
|
||||
<< "nDimz:" << nDimz;
|
||||
|
||||
H5File* oldfd;
|
||||
@@ -830,6 +836,7 @@ public:
|
||||
//new file
|
||||
FileAccPropList fapl;
|
||||
fapl.setFcloseDegree(H5F_CLOSE_STRONG);
|
||||
newfd = 0;
|
||||
if(!owenable)
|
||||
newfd = new H5File( newFileName.c_str(), H5F_ACC_EXCL,
|
||||
FileCreatPropList::DEFAULT,
|
||||
@@ -839,7 +846,7 @@ public:
|
||||
FileCreatPropList::DEFAULT,
|
||||
fapl );
|
||||
//dataspace and dataset
|
||||
DataSpace* newDataspace;
|
||||
DataSpace* newDataspace = 0;
|
||||
if (rank == 3) {
|
||||
hsize_t dims[3] = {nDimx, nDimy, nDimz};
|
||||
newDataspace = new DataSpace (3,dims);
|
||||
@@ -847,7 +854,8 @@ public:
|
||||
hsize_t dims[2] = {nDimx, nDimy};
|
||||
newDataspace = new DataSpace (2,dims);
|
||||
}
|
||||
DataSet* newDataset = new DataSet( newfd->createDataSet(newDatasetName.c_str(), datatype, *newDataspace));
|
||||
DataSet* newDataset = 0;
|
||||
newDataset = new DataSet( newfd->createDataSet(newDatasetName.c_str(), datatype, *newDataspace));
|
||||
//write and close
|
||||
newDataset->write(data_out,datatype);
|
||||
newfd->close();
|
||||
@@ -875,34 +883,34 @@ public:
|
||||
* @param parameterNames parameter names
|
||||
* @returns 0 for success and 1 for fail
|
||||
*/
|
||||
static int LinkVirtualInMaster(string masterFileName, string virtualfname,
|
||||
string virtualDatasetname, vector <const char*> parameterNames) {
|
||||
static int LinkVirtualInMaster(std::string masterFileName, std::string virtualfname,
|
||||
std::string virtualDatasetname, std::vector <const char*> parameterNames) {
|
||||
char linkname[100];
|
||||
hid_t vfd = 0;
|
||||
|
||||
hid_t dfal = H5Pcreate (H5P_FILE_ACCESS);
|
||||
if (dfal < 0)
|
||||
return CloseFileOnError( vfd, string("Error in creating file access property for link\n"));
|
||||
return CloseFileOnError( vfd, std::string("Error in creating file access property for link\n"));
|
||||
if (H5Pset_fclose_degree (dfal, H5F_CLOSE_STRONG) < 0)
|
||||
return CloseFileOnError( vfd, string("Error in setting strong file close degree for link\n"));
|
||||
return CloseFileOnError( vfd, std::string("Error in setting strong file close degree for link\n"));
|
||||
|
||||
//open master file
|
||||
hid_t mfd = H5Fopen( masterFileName.c_str(), H5F_ACC_RDWR, dfal);
|
||||
if (mfd < 0)
|
||||
return CloseFileOnError( vfd, string("Error in opening master file\n"));
|
||||
return CloseFileOnError( vfd, std::string("Error in opening master file\n"));
|
||||
|
||||
//open virtual file
|
||||
vfd = H5Fopen( virtualfname.c_str(), H5F_ACC_RDWR, dfal);
|
||||
if (vfd < 0) {
|
||||
H5Fclose(mfd); mfd = 0;
|
||||
return CloseFileOnError( vfd, string("Error in opening virtual file\n"));
|
||||
return CloseFileOnError( vfd, std::string("Error in opening virtual file\n"));
|
||||
}
|
||||
|
||||
// find relative path
|
||||
string relative_virtualfname = virtualfname;
|
||||
std::string relative_virtualfname = virtualfname;
|
||||
{
|
||||
size_t i = virtualfname.rfind('/', virtualfname.length());
|
||||
if (i != string::npos)
|
||||
if (i != std::string::npos)
|
||||
relative_virtualfname = (virtualfname.substr(i+1, virtualfname.length() - i));
|
||||
}
|
||||
|
||||
@@ -910,29 +918,29 @@ public:
|
||||
hid_t vdset = H5Dopen2( vfd, virtualDatasetname.c_str(), H5P_DEFAULT);
|
||||
if (vdset < 0) {
|
||||
H5Fclose(mfd);
|
||||
return CloseFileOnError( vfd, string("Error in opening virtual data dataset\n"));
|
||||
return CloseFileOnError( vfd, std::string("Error in opening virtual data dataset\n"));
|
||||
}
|
||||
sprintf(linkname, "/entry/data/%s",virtualDatasetname.c_str());
|
||||
if(H5Lcreate_external( relative_virtualfname.c_str(), virtualDatasetname.c_str(),
|
||||
mfd, linkname, H5P_DEFAULT, H5P_DEFAULT) < 0) {
|
||||
H5Fclose(mfd); mfd = 0;
|
||||
return CloseFileOnError( vfd, string("Error in creating link to data dataset\n"));
|
||||
return CloseFileOnError( vfd, std::string("Error in creating link to data dataset\n"));
|
||||
}
|
||||
H5Dclose(vdset);
|
||||
|
||||
//**paramter datasets**
|
||||
for (unsigned int i = 0; i < parameterNames.size(); ++i){
|
||||
hid_t vdset_para = H5Dopen2( vfd, (string (parameterNames[i])).c_str(), H5P_DEFAULT);
|
||||
hid_t vdset_para = H5Dopen2( vfd, (std::string (parameterNames[i])).c_str(), H5P_DEFAULT);
|
||||
if (vdset_para < 0) {
|
||||
H5Fclose(mfd); mfd = 0;
|
||||
return CloseFileOnError( vfd, string("Error in opening virtual parameter dataset to create link\n"));
|
||||
return CloseFileOnError( vfd, std::string("Error in opening virtual parameter dataset to create link\n"));
|
||||
}
|
||||
sprintf(linkname, "/entry/data/%s",(string (parameterNames[i])).c_str());
|
||||
sprintf(linkname, "/entry/data/%s",(std::string (parameterNames[i])).c_str());
|
||||
|
||||
if(H5Lcreate_external( relative_virtualfname.c_str(), (string (parameterNames[i])).c_str(),
|
||||
if(H5Lcreate_external( relative_virtualfname.c_str(), (std::string (parameterNames[i])).c_str(),
|
||||
mfd, linkname, H5P_DEFAULT, H5P_DEFAULT) < 0) {
|
||||
H5Fclose(mfd); mfd = 0;
|
||||
return CloseFileOnError( vfd, string("Error in creating link to virtual parameter dataset\n"));
|
||||
return CloseFileOnError( vfd, std::string("Error in creating link to virtual parameter dataset\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -947,7 +955,7 @@ public:
|
||||
* Print Error msg and Close File and called on error
|
||||
* @returns 1 for fail
|
||||
*/
|
||||
static int CloseFileOnError(hid_t& fd, const string msg) {
|
||||
static int CloseFileOnError(hid_t& fd, const std::string msg) {
|
||||
cprintf(RED, "%s", msg.c_str());
|
||||
if(fd > 0)
|
||||
H5Fclose(fd);
|
||||
|
||||
@@ -33,11 +33,14 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
* @param as pointer to actual udp socket buffer size
|
||||
* @param fpf pointer to frames per file
|
||||
* @param fdp frame discard policy
|
||||
* @param act pointer to activated
|
||||
* @param depaden pointer to deactivated padding enable
|
||||
* @param sm pointer to silent mode
|
||||
*/
|
||||
Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
||||
uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr,
|
||||
uint32_t* us, uint32_t* as, uint32_t* fpf,
|
||||
frameDiscardPolicy* fdp);
|
||||
frameDiscardPolicy* fdp, bool* act, bool* depaden, bool* sm);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@@ -129,12 +132,6 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
*/
|
||||
void ShutDownUDPSocket();
|
||||
|
||||
/**
|
||||
* Set Silent Mode
|
||||
* @param mode 1 sets 0 unsets
|
||||
*/
|
||||
void SetSilentMode(bool mode);
|
||||
|
||||
/**
|
||||
* Create & closes a dummy UDP socket
|
||||
* to set & get actual buffer size
|
||||
@@ -143,6 +140,15 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
*/
|
||||
int CreateDummySocketForUDPSocketBufferSize(uint32_t s);
|
||||
|
||||
/**
|
||||
* Set hard coded (calculated but not from detector) row and column
|
||||
* r is in row index if detector has not send them yet in firmware,
|
||||
* c is in col index for jungfrau and eiger (for missing packets/deactivated eiger)
|
||||
* c when used is in 2d
|
||||
*/
|
||||
void SetHardCodedPosition(uint16_t r, uint16_t c);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -236,6 +242,24 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/** frame discard policy */
|
||||
frameDiscardPolicy* frameDiscardMode;
|
||||
|
||||
/** Activated/Deactivated */
|
||||
bool* activated;
|
||||
|
||||
/** Deactivated padding enable */
|
||||
bool* deactivatedPaddingEnable;
|
||||
|
||||
/** Silent Mode */
|
||||
bool* silentMode;
|
||||
|
||||
/** row hardcoded as 1D or 2d,
|
||||
* if detector does not send them yet or
|
||||
* missing packets/deactivated (eiger/jungfrau sends 2d pos) **/
|
||||
uint16_t row;
|
||||
|
||||
/** column hardcoded as 2D,
|
||||
* deactivated eiger/missing packets (eiger/jungfrau sends 2d pos) **/
|
||||
uint16_t column;
|
||||
|
||||
|
||||
// acquisition start
|
||||
/** Aquisition Started flag */
|
||||
@@ -287,8 +311,5 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
|
||||
/** number of images for statistic */
|
||||
uint32_t numFramesStatistic;
|
||||
|
||||
/** Silent Mode */
|
||||
bool silentMode;
|
||||
};
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class MySocketTCP: public genericSocket {
|
||||
public:
|
||||
MySocketTCP(const char* const host_ip_or_name, unsigned short int const port_number): genericSocket(host_ip_or_name, port_number,TCP), last_keep_connection_open_action_was_a_send(0){setPacketSize(TCP_PACKET_SIZE);}; // sender (client): where to? ip
|
||||
MySocketTCP(unsigned short int const port_number):genericSocket(port_number,TCP), last_keep_connection_open_action_was_a_send(0) {setPacketSize(TCP_PACKET_SIZE);}; // receiver (server) local no need for ip
|
||||
|
||||
virtual ~MySocketTCP(){};
|
||||
|
||||
//The following two functions will connectioned->send/receive->disconnect
|
||||
int SendData(void* buf,int length);//length in characters
|
||||
|
||||
@@ -182,10 +182,10 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
|
||||
//***acquisition parameters***
|
||||
/**
|
||||
* Get Short Frame Enabled, later will be moved to getROI (so far only for gotthard)
|
||||
* Get ROI
|
||||
* @return index of adc enabled, else -1 if all enabled
|
||||
*/
|
||||
int getShortFrameEnable() const;
|
||||
std::vector<ROI> getROI() const;
|
||||
|
||||
/**
|
||||
* Get the Frequency of Frames Sent to GUI
|
||||
@@ -273,15 +273,23 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
* Get Silent Mode
|
||||
* @return silent mode
|
||||
*/
|
||||
uint32_t getSilentMode() const;
|
||||
bool getSilentMode() const;
|
||||
|
||||
/**
|
||||
* Get activate
|
||||
* If deactivated, receiver will write dummy packets 0xFF
|
||||
* If deactivated, receiver will create dummy data if deactivated padding is enabled
|
||||
* (as it will receive nothing from detector)
|
||||
* @return 0 for deactivated, 1 for activated
|
||||
* @return false for deactivated, true for activated
|
||||
*/
|
||||
int getActivate() const;
|
||||
bool getActivate() const;
|
||||
|
||||
/**
|
||||
* Get deactivated padding enable
|
||||
* If enabled, receiver will create dummy packets (0xFF), else it will create nothing
|
||||
* (as it will receive nothing from detector)
|
||||
* @return 0 for disabled, 1 for enabled
|
||||
*/
|
||||
bool getDeactivatedPadding() const;
|
||||
|
||||
/**
|
||||
* Get Streaming Port
|
||||
@@ -324,7 +332,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
* Configure command line parameters
|
||||
* @param config_map mapping of config parameters passed from command line arguments
|
||||
*/
|
||||
void configure(map<string, string> config_map);
|
||||
void configure(std::map<std::string, std::string> config_map);
|
||||
|
||||
/*
|
||||
* Set multi detector size
|
||||
@@ -440,11 +448,11 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
|
||||
//***acquisition parameters***
|
||||
/**
|
||||
* 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
|
||||
* Set ROI
|
||||
* @param i ROI
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setShortFrameEnable(const int i);
|
||||
int setROI(const std::vector<ROI> i);
|
||||
|
||||
/**
|
||||
* Set the Frequency of Frames Sent to GUI
|
||||
@@ -532,9 +540,9 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
//***receiver parameters***
|
||||
/**
|
||||
* Set Silent Mode
|
||||
* @param i silent mode. 1 sets, 0 unsets
|
||||
* @param i silent mode. true sets, false unsets
|
||||
*/
|
||||
void setSilentMode(const uint32_t i);
|
||||
void setSilentMode(const bool i);
|
||||
|
||||
/*************************************************************************
|
||||
* Behavioral functions***************************************************
|
||||
@@ -605,10 +613,21 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
|
||||
/**
|
||||
* Activate / Deactivate Receiver
|
||||
* If deactivated, receiver will write dummy packets 0xFF
|
||||
* If deactivated, receiver will create dummy data if deactivated padding is enabled
|
||||
* (as it will receive nothing from detector)
|
||||
* @param enable enable
|
||||
* @return false for disabled, true for enabled
|
||||
*/
|
||||
int setActivate(int enable = -1);
|
||||
bool setActivate(const bool enable);
|
||||
|
||||
/**
|
||||
* Set deactivated padding enable
|
||||
* If enabled, receiver will create dummy packets (0xFF), else it will create nothing
|
||||
* (as it will receive nothing from detector)
|
||||
* @param enable enable
|
||||
* @return false for disabled, true for enabled
|
||||
*/
|
||||
bool setDeactivatedPadding(const bool enable);
|
||||
|
||||
/**
|
||||
* Set streaming port
|
||||
@@ -727,7 +746,9 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
/** Receiver Status */
|
||||
runStatus status;
|
||||
/** Activated/Deactivated */
|
||||
int activated;
|
||||
bool activated;
|
||||
/** Deactivated padding enable */
|
||||
bool deactivatedPaddingEnable;
|
||||
/** frame discard policy */
|
||||
frameDiscardPolicy frameDiscardMode;
|
||||
/** frame padding */
|
||||
@@ -764,8 +785,8 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
bool dataCompressionEnable;
|
||||
|
||||
//***acquisition parameters***
|
||||
/* Short Frame Enable or index of adc enabled, else -1 if all enabled (gotthard specific) TODO: move to setROI */
|
||||
int shortFrameEnable;
|
||||
/* ROI */
|
||||
std::vector<ROI> roi;
|
||||
/** Frequency of Frames sent to GUI */
|
||||
uint32_t frameToGuiFrequency;
|
||||
/** Timer of Frames sent to GUI when frequency is 0 */
|
||||
@@ -780,7 +801,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
char additionalJsonHeader[MAX_STR_LENGTH];
|
||||
|
||||
//***receiver parameters***
|
||||
uint32_t silentMode;
|
||||
bool silentMode;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
* @short Base class with all the functions for the UDP inteface of the receiver
|
||||
*/
|
||||
|
||||
#include <exception>
|
||||
|
||||
#include "sls_receiver_defs.h"
|
||||
#include "receiver_defs.h"
|
||||
#include "utilities.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <exception>
|
||||
#include <vector>
|
||||
|
||||
class UDPInterface {
|
||||
|
||||
@@ -47,12 +47,15 @@ class UDPInterface {
|
||||
* -setDynamicRange
|
||||
* -setFlippedData (if eiger)
|
||||
* -setActivate (if eiger)
|
||||
* -setDeactivatedPadding (if eiger)
|
||||
* -setTenGigaEnable (if eiger)
|
||||
* -setGapPixelsEnable
|
||||
* -setStreamingPort
|
||||
* -setStreamingSourceIP
|
||||
* -setAdditionalJsonHeader
|
||||
* -setDataStreamEnable
|
||||
* -setROI
|
||||
*
|
||||
*
|
||||
*
|
||||
* supported sequence of method-calls:
|
||||
@@ -113,7 +116,7 @@ class UDPInterface {
|
||||
* @param [in] receiver_type type can be standard or custom (must be derived from base class)
|
||||
* @return a UDPInterface reference to object depending on receiver type
|
||||
*/
|
||||
static UDPInterface *create(string receiver_type = "standard");
|
||||
static UDPInterface *create(std::string receiver_type = "standard");
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@@ -270,10 +273,10 @@ class UDPInterface {
|
||||
|
||||
//***acquisition parameters***
|
||||
/**
|
||||
* Get Short Frame Enabled, later will be moved to getROI (so far only for gotthard)
|
||||
* Get ROI
|
||||
* @return index of adc enabled, else -1 if all enabled
|
||||
*/
|
||||
virtual int getShortFrameEnable() const = 0;
|
||||
virtual std::vector<slsReceiverDefs::ROI> getROI() const = 0;
|
||||
|
||||
/**
|
||||
* Get the Frequency of Frames Sent to GUI
|
||||
@@ -360,15 +363,23 @@ class UDPInterface {
|
||||
* Get Silent Mode
|
||||
* @return silent mode
|
||||
*/
|
||||
virtual uint32_t getSilentMode() const = 0;
|
||||
virtual bool getSilentMode() const = 0;
|
||||
|
||||
/**
|
||||
* Get activate
|
||||
* If deactivated, receiver will write dummy packets 0xFF
|
||||
* If deactivated, receiver will create dummy data if deactivated padding is enabled
|
||||
* (as it will receive nothing from detector)
|
||||
* @return 0 for deactivated, 1 for activated
|
||||
* @return false for deactivated, true for activated
|
||||
*/
|
||||
virtual int getActivate() const = 0;
|
||||
virtual bool getActivate() const = 0;
|
||||
|
||||
/**
|
||||
* Get deactivated padding enable
|
||||
* If enabled, receiver will create dummy packets (0xFF), else it will create nothing
|
||||
* (as it will receive nothing from detector)
|
||||
* @return false for disabled, true for enabled
|
||||
*/
|
||||
virtual bool getDeactivatedPadding() const = 0;
|
||||
|
||||
/**
|
||||
* Get Streaming Port
|
||||
@@ -411,7 +422,7 @@ class UDPInterface {
|
||||
* Configure command line parameters
|
||||
* @param config_map mapping of config parameters passed from command line arguments
|
||||
*/
|
||||
virtual void configure(map<string, string> config_map) = 0;
|
||||
virtual void configure(std::map<std::string, std::string> config_map) = 0;
|
||||
|
||||
/*
|
||||
* Set multi detector size
|
||||
@@ -526,11 +537,11 @@ class UDPInterface {
|
||||
|
||||
//***acquisition parameters***
|
||||
/**
|
||||
* 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
|
||||
* Set ROI
|
||||
* @param i ROI
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int setShortFrameEnable(const int i) = 0;
|
||||
virtual int setROI(const std::vector<slsReceiverDefs::ROI> i) = 0;
|
||||
|
||||
/**
|
||||
* Set the Frequency of Frames Sent to GUI
|
||||
@@ -620,9 +631,9 @@ class UDPInterface {
|
||||
//***receiver parameters***
|
||||
/**
|
||||
* Set Silent Mode
|
||||
* @param i silent mode. 1 sets, 0 unsets
|
||||
* @param i silent mode. true sets, false unsets
|
||||
*/
|
||||
virtual void setSilentMode(const uint32_t i) = 0;
|
||||
virtual void setSilentMode(const bool i) = 0;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
@@ -694,10 +705,21 @@ class UDPInterface {
|
||||
|
||||
/**
|
||||
* Activate / Deactivate Receiver
|
||||
* If deactivated, receiver will write dummy packets 0xFF
|
||||
* If deactivated, receiver will create dummy data if deactivated padding is enabled
|
||||
* (as it will receive nothing from detector)
|
||||
* @param enable enable
|
||||
* @return false for disabled, true for enabled
|
||||
*/
|
||||
virtual int setActivate(int enable = -1) = 0;
|
||||
virtual bool setActivate(const bool enable) = 0;
|
||||
|
||||
/**
|
||||
* Set deactivated padding enable
|
||||
* If enabled, receiver will create dummy packets (0xFF), else it will create nothing
|
||||
* (as it will receive nothing from detector)
|
||||
* @param enable enable
|
||||
* @return false for disabled, true for enabled
|
||||
*/
|
||||
virtual bool setDeactivatedPadding(const bool enable) = 0;
|
||||
|
||||
/**
|
||||
* Set streaming port
|
||||
|
||||
@@ -14,7 +14,6 @@ class DataProcessor;
|
||||
class DataStreamer;
|
||||
class Fifo;
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBaseImplementation {
|
||||
@@ -74,11 +73,11 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
||||
void setFileWriteEnable(const bool b);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* Set ROI
|
||||
* @param i ROI
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setShortFrameEnable(const int i);
|
||||
int setROI(const std::vector<ROI> i);
|
||||
|
||||
/**
|
||||
* Set the Frequency of Frames Sent to GUI
|
||||
@@ -122,11 +121,6 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
||||
*/
|
||||
int setFifoDepth(const uint32_t i);
|
||||
|
||||
/**
|
||||
* Set Silent Mode
|
||||
* @param i silent mode. 1 sets, 0 unsets
|
||||
*/
|
||||
void setSilentMode(const uint32_t i);
|
||||
|
||||
/**
|
||||
* Set receiver type (and corresponding detector variables in derived STANDARD class)
|
||||
|
||||
@@ -18,12 +18,13 @@
|
||||
#include <rapidjson/document.h> //json header in zmq stream
|
||||
#include <string.h>
|
||||
#include <unistd.h> //usleep in some machines
|
||||
#include <vector>
|
||||
using namespace rapidjson;
|
||||
|
||||
|
||||
#define MAX_STR_LENGTH 1000
|
||||
|
||||
//#define ZMQ_DETAIL
|
||||
// #define ZMQ_DETAIL
|
||||
#define ROIVERBOSITY
|
||||
|
||||
class ZmqSocket {
|
||||
@@ -36,8 +37,6 @@ public:
|
||||
// eg. int value = -1;
|
||||
// if (zmq_setsockopt(socketDescriptor, ZMQ_LINGER, &value,sizeof(value))) {
|
||||
// Close();
|
||||
// }
|
||||
|
||||
/**
|
||||
* Constructor for a client
|
||||
* Creates socket, context and connects to server
|
||||
@@ -45,11 +44,8 @@ public:
|
||||
* @param portnumber port number
|
||||
*/
|
||||
ZmqSocket (const char* const hostname_or_ip, const uint32_t portnumber):
|
||||
portno (portnumber),
|
||||
server (false),
|
||||
contextDescriptor (NULL),
|
||||
socketDescriptor (NULL),
|
||||
headerMessage(0)
|
||||
portno (portnumber)
|
||||
// headerMessage(0)
|
||||
{
|
||||
char ip[MAX_STR_LENGTH] = "";
|
||||
memset(ip, 0, MAX_STR_LENGTH);
|
||||
@@ -61,19 +57,19 @@ public:
|
||||
throw std::exception();
|
||||
|
||||
// construct address
|
||||
sprintf (serverAddress, "tcp://%s:%d", ip, portno);
|
||||
sprintf (sockfd.serverAddress, "tcp://%s:%d", ip, portno);
|
||||
#ifdef VERBOSE
|
||||
cprintf(BLUE,"address:%s\n",serverAddress);
|
||||
cprintf(BLUE,"address:%s\n",sockfd.serverAddress);
|
||||
#endif
|
||||
|
||||
// create context
|
||||
contextDescriptor = zmq_ctx_new();
|
||||
if (contextDescriptor == NULL)
|
||||
sockfd.contextDescriptor = zmq_ctx_new();
|
||||
if (sockfd.contextDescriptor == 0)
|
||||
throw std::exception();
|
||||
|
||||
// create publisher
|
||||
socketDescriptor = zmq_socket (contextDescriptor, ZMQ_SUB);
|
||||
if (socketDescriptor == NULL) {
|
||||
sockfd.socketDescriptor = zmq_socket (sockfd.contextDescriptor, ZMQ_SUB);
|
||||
if (sockfd.socketDescriptor == 0) {
|
||||
PrintError ();
|
||||
Close ();
|
||||
throw std::exception();
|
||||
@@ -81,7 +77,7 @@ public:
|
||||
|
||||
//Socket Options provided above
|
||||
// an empty string implies receiving any messages
|
||||
if ( zmq_setsockopt(socketDescriptor, ZMQ_SUBSCRIBE, "", 0)) {
|
||||
if ( zmq_setsockopt(sockfd.socketDescriptor, ZMQ_SUBSCRIBE, "", 0)) {
|
||||
PrintError ();
|
||||
Close();
|
||||
throw std::exception();
|
||||
@@ -90,7 +86,7 @@ public:
|
||||
//ZMQ_SNDHWM default is 0 means no limit. use this to optimize if optimizing required
|
||||
// eg. int value = -1;
|
||||
int value = 0;
|
||||
if (zmq_setsockopt(socketDescriptor, ZMQ_LINGER, &value,sizeof(value))) {
|
||||
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_LINGER, &value,sizeof(value))) {
|
||||
PrintError ();
|
||||
Close();
|
||||
throw std::exception();
|
||||
@@ -105,19 +101,19 @@ public:
|
||||
* @param ethip is the ip of the ethernet interface to stream zmq from
|
||||
*/
|
||||
ZmqSocket (const uint32_t portnumber, const char *ethip):
|
||||
portno (portnumber),
|
||||
server (true),
|
||||
contextDescriptor (NULL),
|
||||
socketDescriptor (NULL),
|
||||
headerMessage(0)
|
||||
|
||||
portno (portnumber)
|
||||
// headerMessage(0)
|
||||
{
|
||||
sockfd.server = true;
|
||||
|
||||
// create context
|
||||
contextDescriptor = zmq_ctx_new();
|
||||
if (contextDescriptor == NULL)
|
||||
sockfd.contextDescriptor = zmq_ctx_new();
|
||||
if (sockfd.contextDescriptor == 0)
|
||||
throw std::exception();
|
||||
// create publisher
|
||||
socketDescriptor = zmq_socket (contextDescriptor, ZMQ_PUB);
|
||||
if (socketDescriptor == NULL) {
|
||||
sockfd.socketDescriptor = zmq_socket (sockfd.contextDescriptor, ZMQ_PUB);
|
||||
if (sockfd.socketDescriptor == 0) {
|
||||
PrintError ();
|
||||
Close ();
|
||||
throw std::exception();
|
||||
@@ -126,12 +122,12 @@ public:
|
||||
//Socket Options provided above
|
||||
|
||||
// construct addresss
|
||||
sprintf (serverAddress,"tcp://%s:%d", ethip, portno);
|
||||
sprintf (sockfd.serverAddress,"tcp://%s:%d", ethip, portno);
|
||||
#ifdef VERBOSE
|
||||
cprintf(BLUE,"address:%s\n",serverAddress);
|
||||
cprintf(BLUE,"address:%s\n",sockfd.serverAddress);
|
||||
#endif
|
||||
// bind address
|
||||
if (zmq_bind (socketDescriptor, serverAddress) < 0) {
|
||||
if (zmq_bind (sockfd.socketDescriptor, sockfd.serverAddress) < 0) {
|
||||
PrintError ();
|
||||
Close ();
|
||||
throw std::exception();
|
||||
@@ -145,69 +141,49 @@ public:
|
||||
* Destructor
|
||||
*/
|
||||
~ZmqSocket () {
|
||||
Disconnect();
|
||||
Close();
|
||||
//mySocketDescriptor destructor also gets called
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns Server Address
|
||||
* @returns Server Address
|
||||
*/
|
||||
char* GetZmqServerAddress () { return serverAddress; };
|
||||
|
||||
/**
|
||||
* Returns Port Number
|
||||
* @returns Port Number
|
||||
*/
|
||||
uint32_t GetPortNumber () { return portno; };
|
||||
|
||||
/**
|
||||
* Returns Server Address
|
||||
* @returns Server Address
|
||||
*/
|
||||
char* GetZmqServerAddress () { return sockfd.serverAddress; };
|
||||
|
||||
/**
|
||||
* Returns Socket Descriptor
|
||||
* @reutns Socket descriptor
|
||||
*/
|
||||
|
||||
void* GetsocketDescriptor () { return socketDescriptor; };
|
||||
void* GetsocketDescriptor () { return sockfd.socketDescriptor; };
|
||||
|
||||
/**
|
||||
* Connect client socket to server socket
|
||||
* @returns 1 for fail, 0 for success
|
||||
*/
|
||||
int Connect() {
|
||||
if (zmq_connect(socketDescriptor, serverAddress) < 0) {
|
||||
if (zmq_connect(sockfd.socketDescriptor, sockfd.serverAddress) < 0) {
|
||||
PrintError ();
|
||||
Close ();
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unbinds the Socket
|
||||
*/
|
||||
void Disconnect () {
|
||||
if (server)
|
||||
zmq_unbind (socketDescriptor, serverAddress);
|
||||
else
|
||||
zmq_disconnect (socketDescriptor, serverAddress);
|
||||
};
|
||||
void Disconnect () {sockfd.Disconnect();};
|
||||
|
||||
/**
|
||||
* Close Socket and destroy Context
|
||||
*/
|
||||
void Close () {
|
||||
if (socketDescriptor != NULL) {
|
||||
zmq_close (socketDescriptor);
|
||||
socketDescriptor = NULL;
|
||||
}
|
||||
|
||||
if (contextDescriptor != NULL) {
|
||||
zmq_ctx_destroy (contextDescriptor);
|
||||
contextDescriptor = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
void Close () { sockfd.Close(); };
|
||||
|
||||
/**
|
||||
* Convert Hostname to Internet address info structure
|
||||
@@ -272,7 +248,7 @@ public:
|
||||
uint64_t acqIndex = 0, uint64_t fIndex = 0, char* fname = NULL,
|
||||
uint64_t frameNumber = 0, uint32_t expLength = 0, uint32_t packetNumber = 0,
|
||||
uint64_t bunchId = 0, uint64_t timestamp = 0,
|
||||
uint16_t modId = 0, uint16_t xCoord = 0, uint16_t yCoord = 0, uint16_t zCoord = 0,
|
||||
uint16_t modId = 0, uint16_t row = 0, uint16_t column = 0, uint16_t reserved = 0,
|
||||
uint32_t debug = 0, uint16_t roundRNumber = 0,
|
||||
uint8_t detType = 0, uint8_t version = 0, int* flippedData = 0,
|
||||
char* additionalJsonHeader = 0) {
|
||||
@@ -298,9 +274,9 @@ public:
|
||||
"\"bunchId\":%llu, "
|
||||
"\"timestamp\":%llu, "
|
||||
"\"modId\":%u, "
|
||||
"\"xCoord\":%u, "
|
||||
"\"yCoord\":%u, "
|
||||
"\"zCoord\":%u, "
|
||||
"\"row\":%u, "
|
||||
"\"column\":%u, "
|
||||
"\"reserved\":%u, "
|
||||
"\"debug\":%u, "
|
||||
"\"roundRNumber\":%u, "
|
||||
"\"detType\":%u, "
|
||||
@@ -309,22 +285,22 @@ public:
|
||||
//additional stuff
|
||||
"\"flippedDataX\":%u"
|
||||
|
||||
;//"}\n\0";
|
||||
;//"}\n";
|
||||
int length = sprintf(buf, jsonHeaderFormat,
|
||||
jsonversion, dynamicrange, fileIndex, npixelsx, npixelsy, imageSize,
|
||||
acqIndex, fIndex, (fname == NULL)? "":fname, dummy?0:1,
|
||||
|
||||
frameNumber, expLength, packetNumber, bunchId, timestamp,
|
||||
modId, xCoord, yCoord, zCoord, debug, roundRNumber,
|
||||
modId, row, column, reserved, debug, roundRNumber,
|
||||
detType, version,
|
||||
|
||||
//additional stuff
|
||||
((flippedData == 0 ) ? 0 :flippedData[0])
|
||||
);
|
||||
if (additionalJsonHeader && strlen(additionalJsonHeader)) {
|
||||
length = sprintf(buf, "%s, %s}\n%c", buf, additionalJsonHeader, '\0');
|
||||
length = sprintf(buf, "%s, %s}\n", buf, additionalJsonHeader);
|
||||
} else {
|
||||
length = sprintf(buf, "%s}\n%c", buf, '\0');
|
||||
length = sprintf(buf, "%s}\n", buf);
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
@@ -332,7 +308,7 @@ public:
|
||||
cprintf(BLUE,"%d : Streamer: buf: %s\n", index, buf);
|
||||
#endif
|
||||
|
||||
if(zmq_send (socketDescriptor, buf, length, dummy?0:ZMQ_SNDMORE) < 0) {
|
||||
if(zmq_send (sockfd.socketDescriptor, buf, length, dummy?0:ZMQ_SNDMORE) < 0) {
|
||||
PrintError ();
|
||||
return 0;
|
||||
}
|
||||
@@ -349,7 +325,7 @@ public:
|
||||
* @returns 0 if error, else 1
|
||||
*/
|
||||
int SendData (char* buf, int length) {
|
||||
if(zmq_send (socketDescriptor, buf, length, 0) < 0) {
|
||||
if(zmq_send (sockfd.socketDescriptor, buf, length, 0) < 0) {
|
||||
PrintError ();
|
||||
return 0;
|
||||
}
|
||||
@@ -367,7 +343,7 @@ public:
|
||||
* @returns length of message, -1 if error
|
||||
*/
|
||||
int ReceiveMessage(const int index, zmq_msg_t& message) {
|
||||
int length = zmq_msg_recv (&message, socketDescriptor, 0);
|
||||
int length = zmq_msg_recv (&message, sockfd.socketDescriptor, 0);
|
||||
if (length == -1) {
|
||||
PrintError ();
|
||||
cprintf (BG_RED,"Error: Could not read header for socket %d\n",index);
|
||||
@@ -389,18 +365,16 @@ public:
|
||||
*/
|
||||
int ReceiveHeader(const int index, Document& document, uint32_t version)
|
||||
{
|
||||
zmq_msg_t message;
|
||||
headerMessage= &message;
|
||||
zmq_msg_init (&message);
|
||||
int len = ReceiveMessage(index, message);
|
||||
std::vector<char>buffer(MAX_STR_LENGTH);
|
||||
int len = zmq_recv(sockfd.socketDescriptor, buffer.data(), buffer.size(),0);
|
||||
if ( len > 0 ) {
|
||||
bool dummy = false;
|
||||
#ifdef ZMQ_DETAIL
|
||||
cprintf( BLUE,"Header %d [%d] Length: %d Header:%s \n", index, portno, len, (char*) zmq_msg_data (&message) );
|
||||
cprintf( BLUE,"Header %d [%d] Length: %d Header:%s \n", index, portno, len, buffer.data());
|
||||
#endif
|
||||
if ( ParseHeader (index, len, message, document, dummy, version)) {
|
||||
if ( ParseHeader (index, len, buffer.data(), document, dummy, version)) {
|
||||
#ifdef ZMQ_DETAIL
|
||||
cprintf( RED,"Parsed Header %d [%d] Length: %d Header:%s \n", index, portno, len, (char*) zmq_msg_data (&message) );
|
||||
cprintf( RED,"Parsed Header %d [%d] Length: %d Header:%s \n", index, portno, len, buffer.data() );
|
||||
#endif
|
||||
if (dummy) {
|
||||
#ifdef ZMQ_DETAIL
|
||||
@@ -421,11 +395,11 @@ public:
|
||||
/**
|
||||
* Close Header Message. Call this function if ReceiveHeader returned 1
|
||||
*/
|
||||
void CloseHeaderMessage() {
|
||||
if (headerMessage)
|
||||
zmq_msg_close(headerMessage);
|
||||
headerMessage = 0;
|
||||
};
|
||||
// void CloseHeaderMessage() {
|
||||
// if (headerMessage)
|
||||
// zmq_msg_close(headerMessage);
|
||||
// headerMessage = 0;
|
||||
// };
|
||||
/**
|
||||
* Parse Header
|
||||
* @param index self index for debugging
|
||||
@@ -436,15 +410,15 @@ public:
|
||||
* @param version version that has to match, -1 to not care
|
||||
* @returns true if successful else false
|
||||
*/
|
||||
int ParseHeader(const int index, int length, zmq_msg_t& message,
|
||||
int ParseHeader(const int index, int length, char* buff,
|
||||
Document& document, bool& dummy, uint32_t version)
|
||||
{
|
||||
if ( document.Parse( (char*) zmq_msg_data (&message), zmq_msg_size (&message)).HasParseError() ) {
|
||||
cprintf( RED,"%d Could not parse. len:%d: Message:%s \n", index, length, (char*) zmq_msg_data (&message) );
|
||||
if ( document.Parse( buff, length).HasParseError() ) {
|
||||
cprintf( RED,"%d Could not parse. len:%d: Message:%s \n", index, length, buff );
|
||||
fflush ( stdout );
|
||||
char* buf = (char*) zmq_msg_data (&message);
|
||||
// char* buf = (char*) zmq_msg_data (&message);
|
||||
for ( int i= 0; i < length; ++i ) {
|
||||
cprintf(RED,"%02x ",buf[i]);
|
||||
cprintf(RED,"%02x ",buff[i]);
|
||||
}
|
||||
printf("\n");
|
||||
fflush( stdout );
|
||||
@@ -461,29 +435,6 @@ public:
|
||||
dummy = temp ? false : true;
|
||||
|
||||
return 1;
|
||||
/*
|
||||
int temp = d["data"].GetUint();
|
||||
dummy = temp ? false : true;
|
||||
if (!dummy) {
|
||||
acqIndex = d["acqIndex"].GetUint64();
|
||||
frameIndex = d["fIndex"].GetUint64();
|
||||
fileIndex = d["fileIndex"].GetUint64();
|
||||
subframeIndex = d["expLength"].GetUint();
|
||||
filename = d["fname"].GetString();
|
||||
}
|
||||
#ifdef VERYVERBOSE
|
||||
cprintf(BLUE,"%d Dummy:%d\n"
|
||||
"\tAcqIndex:%lu\n"
|
||||
"\tFrameIndex:%lu\n"
|
||||
"\tSubIndex:%u\n"
|
||||
"\tFileIndex:%lu\n"
|
||||
"\tBitMode:%u\n"
|
||||
"\tDetType:%u\n",
|
||||
index, (int)dummy, acqIndex, frameIndex, subframeIndex, fileIndex,
|
||||
d["bitmode"].GetUint(),d["detType"].GetUint());
|
||||
#endif
|
||||
return 1;
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
@@ -585,24 +536,57 @@ public:
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Class to close socket descriptors automatically
|
||||
* upon encountering exceptions in the ZmqSocket constructor
|
||||
*/
|
||||
class mySocketDescriptors {
|
||||
public:
|
||||
/** Constructor */
|
||||
mySocketDescriptors():
|
||||
server(false),
|
||||
contextDescriptor(0),
|
||||
socketDescriptor(0) {};
|
||||
/** Destructor */
|
||||
~mySocketDescriptors() {
|
||||
Disconnect();
|
||||
Close();
|
||||
}
|
||||
/** Unbinds the Socket */
|
||||
void Disconnect () {
|
||||
if (server)
|
||||
zmq_unbind (socketDescriptor, serverAddress);
|
||||
else
|
||||
zmq_disconnect (socketDescriptor, serverAddress);
|
||||
};
|
||||
/** Close Socket and destroy Context */
|
||||
void Close () {
|
||||
if (socketDescriptor != NULL) {
|
||||
zmq_close (socketDescriptor);
|
||||
socketDescriptor = NULL;
|
||||
}
|
||||
|
||||
if (contextDescriptor != NULL) {
|
||||
zmq_ctx_destroy (contextDescriptor);
|
||||
contextDescriptor = NULL;
|
||||
}
|
||||
};
|
||||
/** true if server, else false */
|
||||
bool server;
|
||||
/** Server Address */
|
||||
char serverAddress[1000];
|
||||
/** Context Descriptor */
|
||||
void* contextDescriptor;
|
||||
/** Socket Descriptor */
|
||||
void* socketDescriptor;
|
||||
};
|
||||
|
||||
private:
|
||||
/** Port Number */
|
||||
uint32_t portno;
|
||||
|
||||
/** true if server, else false */
|
||||
bool server;
|
||||
|
||||
/** Context Descriptor */
|
||||
void* contextDescriptor;
|
||||
|
||||
/** Socket Descriptor */
|
||||
void* socketDescriptor;
|
||||
|
||||
/** Server Address */
|
||||
char serverAddress[1000];
|
||||
|
||||
/** Header Message pointer */
|
||||
zmq_msg_t* headerMessage;
|
||||
|
||||
/** Socket descriptor */
|
||||
mySocketDescriptors sockfd;
|
||||
};
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <semaphore.h>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
@@ -46,7 +45,7 @@ public:
|
||||
int getFreeValue() const;
|
||||
|
||||
private:
|
||||
vector <Element*> array;
|
||||
std::vector <Element*> array;
|
||||
unsigned int tail; // input index
|
||||
unsigned int head; // output index
|
||||
unsigned int Capacity;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||
#define GITREPUUID "83600fcb15c8261173ab15a8ba8d1009693f2d23"
|
||||
#define GITAUTH "Anna_Bergamaschi"
|
||||
#define GITREV 0x3962
|
||||
#define GITDATE 0x20180904
|
||||
#define GITBRANCH "anna"
|
||||
|
||||
#define GITREPUUID "d2bce7e372c241cd235977b92be18555bca6a77d"
|
||||
#define GITAUTH "Dhanya_Thattil"
|
||||
#define GITREV 0x4020
|
||||
#define GITDATE 0x20180927
|
||||
#define GITBRANCH "4.0.0"
|
||||
|
||||
@@ -24,13 +24,13 @@
|
||||
#define STRINGIFY(x) #x
|
||||
#define TOSTRING(x) STRINGIFY(x)
|
||||
#define MYCONCAT(x,y)
|
||||
#define __AT__ string(__FILE__) + string("::") + string(__func__) + string("(): ")
|
||||
#define __AT__ std::string(__FILE__) + std::string("::") + std::string(__func__) + std::string("(): ")
|
||||
#define __SHORT_FORM_OF_FILE__ \
|
||||
(strrchr(__FILE__,'/') \
|
||||
? strrchr(__FILE__,'/')+1 \
|
||||
: __FILE__ \
|
||||
)
|
||||
#define __SHORT_AT__ string(__SHORT_FORM_OF_FILE__) + string("::") + string(__func__) + string("(): ")
|
||||
#define __SHORT_AT__ std::string(__SHORT_FORM_OF_FILE__) + std::string("::") + std::string(__func__) + std::string("(): ")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#define MAX_CHUNKED_IMAGES 1
|
||||
|
||||
//versions
|
||||
#define HDF5_WRITER_VERSION 2.0 //1 decimal places
|
||||
#define BINARY_WRITER_VERSION 2.0 //1 decimal places
|
||||
#define HDF5_WRITER_VERSION 3.0 //1 decimal places
|
||||
#define BINARY_WRITER_VERSION 3.0 //1 decimal places
|
||||
|
||||
|
||||
//parameters to calculate fifo depth
|
||||
|
||||
@@ -25,11 +25,11 @@ class slsReceiver : private virtual slsReceiverDefs {
|
||||
* Constructor
|
||||
* Starts up a Receiver server. Reads configuration file, options, and
|
||||
* assembles a Receiver using TCP and UDP detector interfaces
|
||||
* throws an exception in case of failure
|
||||
* @param argc from command line
|
||||
* @param argv from command line
|
||||
* @param succecc socket creation was successfull
|
||||
*/
|
||||
slsReceiver(int argc, char *argv[], int &success);
|
||||
slsReceiver(int argc, char *argv[]);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@@ -99,6 +99,5 @@ class slsReceiver : private virtual slsReceiverDefs {
|
||||
|
||||
private:
|
||||
slsReceiverTCPIPInterface* tcpipInterface;
|
||||
UDPInterface* udp_interface;
|
||||
};
|
||||
|
||||
|
||||
@@ -26,21 +26,12 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
||||
/**
|
||||
* Constructor
|
||||
* reads config file, creates socket, assigns function table
|
||||
* @param succecc socket creation was successfull
|
||||
* @param rbase pointer to the receiver base
|
||||
* throws an exception in case of failure to construct
|
||||
* @param pn port number (defaults to default port number)
|
||||
*/
|
||||
|
||||
slsReceiverTCPIPInterface(int &success, UDPInterface* rbase, int pn=-1);
|
||||
slsReceiverTCPIPInterface(int pn=-1);
|
||||
|
||||
/**
|
||||
* Sets the port number to listen to.
|
||||
Take care that the client must know to whcih port it has to listen to, so normally it is better to use a fixes port from the instatiation or change it from the client.
|
||||
@param pn port number (-1 only get)
|
||||
\returns actual port number
|
||||
*/
|
||||
int setPortNumber(int pn=-1);
|
||||
|
||||
/**
|
||||
* Starts listening on the TCP port for client comminication
|
||||
\returns OK or FAIL
|
||||
@@ -172,8 +163,8 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
||||
/** set detector hostname */
|
||||
int set_detector_hostname();
|
||||
|
||||
/** set short frame */
|
||||
int set_short_frame();
|
||||
/** set roi */
|
||||
int set_roi();
|
||||
|
||||
/** Set up UDP Details */
|
||||
int setup_udp();
|
||||
@@ -290,6 +281,9 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
||||
/** set partial frame padding enable*/
|
||||
int set_padding_enable();
|
||||
|
||||
/** set deactivated receiver padding enable */
|
||||
int set_deactivated_receiver_padding_enable();
|
||||
|
||||
|
||||
/** detector type */
|
||||
detectorType myDetectorType;
|
||||
|
||||
@@ -8,9 +8,8 @@ class slsReceiver;
|
||||
|
||||
/**
|
||||
@short Class for implementing the SLS data receiver in the users application. Callbacks can be defined for processing and/or saving data
|
||||
*/
|
||||
/**
|
||||
@libdoc slsReceiverUsers is a class that can be instantiated in the users software to receive the data from the detectors. Callbacks can be defined for processing and/or saving data
|
||||
|
||||
slsReceiverUsers is a class that can be instantiated in the users software to receive the data from the detectors. Callbacks can be defined for processing and/or saving data
|
||||
***********************************************/
|
||||
|
||||
class slsReceiverUsers {
|
||||
@@ -21,7 +20,7 @@ public:
|
||||
* reads config file, creates socket, assigns function table
|
||||
* @param argc from command line
|
||||
* @param argv from command line
|
||||
* @param succecc socket creation was successfull
|
||||
* @param success socket creation was successfull
|
||||
*/
|
||||
slsReceiverUsers(int argc, char *argv[], int &success);
|
||||
|
||||
@@ -46,16 +45,18 @@ public:
|
||||
|
||||
/**
|
||||
|
||||
@sort register calbback for starting the acquisition
|
||||
@short register calbback for starting the acquisition
|
||||
\param func callback to be called when starting the acquisition. Its arguments are filepath, filename, fileindex, datasize
|
||||
\param arg argument
|
||||
\return value is insignificant at the moment, we write depending on file write enable, users get data to write depending on call backs registered
|
||||
*/
|
||||
void registerCallBackStartAcquisition(int (*func)(char* filepath, char* filename, uint64_t fileindex, uint32_t datasize, void*),void *arg);
|
||||
|
||||
|
||||
/**
|
||||
@sort register callback for end of acquisition
|
||||
@short register callback for end of acquisition
|
||||
\param func end of acquisition callback. Argument nf is total frames caught
|
||||
\param arg argument
|
||||
\returns nothing
|
||||
*/
|
||||
void registerCallBackAcquisitionFinished(void (*func)(uint64_t nf, void*),void *arg);
|
||||
@@ -63,8 +64,9 @@ public:
|
||||
|
||||
|
||||
/**
|
||||
@sort register callback to be called when data are available (to process and/or save the data).
|
||||
@short register callback to be called when data are available (to process and/or save the data).
|
||||
\param func raw data ready callback. arguments are sls_receiver_header, dataPointer, dataSize
|
||||
\param arg argument
|
||||
\returns nothing
|
||||
*/
|
||||
void registerCallBackRawDataReady(void (*func)(char* header,
|
||||
@@ -72,8 +74,9 @@ public:
|
||||
|
||||
|
||||
/**
|
||||
@sort register callback to be called when data are available (to process and/or save the data).
|
||||
@short register callback to be called when data are available (to process and/or save the data).
|
||||
\param func raw data ready callback. arguments are sls_receiver_header, dataPointer, revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value).
|
||||
\param arg argument
|
||||
\returns nothing
|
||||
*/
|
||||
void registerCallBackRawDataModifyReady(void (*func)(char* header,
|
||||
|
||||
@@ -37,8 +37,8 @@ typedef int int32_t;
|
||||
#define DEFAULT_ZMQ_CL_PORTNO 30001
|
||||
#define DEFAULT_ZMQ_RX_PORTNO 30001
|
||||
|
||||
#define SLS_DETECTOR_HEADER_VERSION 0x1
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
#define SLS_DETECTOR_HEADER_VERSION 0x2
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x3
|
||||
|
||||
/**
|
||||
\file sls_receiver_defs.h
|
||||
@@ -113,7 +113,9 @@ public:
|
||||
SAMPLES_JCTB,
|
||||
SUBFRAME_ACQUISITION_TIME, /**< subframe exposure time */
|
||||
STORAGE_CELL_NUMBER, /**<number of storage cells */
|
||||
SUBFRAME_PERIOD, /**< subframe period */
|
||||
SUBFRAME_DEADTIME, /**< subframe deadtime */
|
||||
MEASURED_PERIOD, /**< measured period */
|
||||
MEASURED_SUBPERIOD, /**< measured subperiod */
|
||||
MAX_TIMERS
|
||||
};
|
||||
|
||||
@@ -141,9 +143,9 @@ public:
|
||||
@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 row is the row index in the complete detector system
|
||||
@li column is the column index in the complete detector system
|
||||
@li reserved is reserved
|
||||
@li debug is for debugging purposes
|
||||
@li roundRNumber is the round robin set number
|
||||
@li detType is the detector type see :: detectorType
|
||||
@@ -157,9 +159,9 @@ public:
|
||||
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 */
|
||||
uint16_t row; /**< is the row index in the complete detector system */
|
||||
uint16_t column; /**< is the column index in the complete detector system */
|
||||
uint16_t reserved; /**< is reserved */
|
||||
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 */
|
||||
@@ -203,6 +205,19 @@ public:
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@short structure for a region of interest
|
||||
xmin,xmax,ymin,ymax define the limits of the region
|
||||
*/
|
||||
typedef struct {
|
||||
int xmin; /**< is the roi xmin (in channel number) */
|
||||
int xmax; /**< is the roi xmax (in channel number)*/
|
||||
int ymin; /**< is the roi ymin (in channel number)*/
|
||||
int ymax; /**< is the roi ymax (in channel number)*/
|
||||
} ROI ;
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
/** returns string from enabled/disabled
|
||||
\param b true or false
|
||||
|
||||
42
slsReceiverSoftware/include/sls_receiver_exceptions.h
Normal file
42
slsReceiverSoftware/include/sls_receiver_exceptions.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
/************************************************
|
||||
* @file sls_receiver_exceptions.h
|
||||
* @short exceptions defined
|
||||
***********************************************/
|
||||
/**
|
||||
*@short exceptions defined
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
struct SlsDetectorPackageExceptions : public std::exception {
|
||||
public:
|
||||
SlsDetectorPackageExceptions() {}
|
||||
std::string GetMessage() const { return "SLS Detector Package Failed";};
|
||||
};
|
||||
|
||||
struct SharedMemoryException : public SlsDetectorPackageExceptions {
|
||||
public:
|
||||
SharedMemoryException() {}
|
||||
std::string GetMessage() const { return "Shared Memory Failed";};
|
||||
};
|
||||
|
||||
struct ThreadpoolException : public SlsDetectorPackageExceptions {
|
||||
public:
|
||||
ThreadpoolException() {}
|
||||
std::string GetMessage() const { return "Threadpool Failed";};
|
||||
};
|
||||
|
||||
struct SocketException : public SlsDetectorPackageExceptions {
|
||||
public:
|
||||
SocketException() {}
|
||||
std::string GetMessage() const { return "Socket Failed";};
|
||||
};
|
||||
|
||||
struct SamePortSocketException : public SocketException {
|
||||
public:
|
||||
SamePortSocketException() {}
|
||||
std::string GetMessage() const { return "Socket Failed";};
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@ enum recFuncs{
|
||||
F_SEND_RECEIVER_DETHOSTNAME, /**< set detector hostname to receiver */
|
||||
|
||||
//network functions
|
||||
F_RECEIVER_SHORT_FRAME, /**< Sets receiver to receive short frames */
|
||||
F_RECEIVER_SET_ROI, /**< Sets receiver ROI */
|
||||
F_SETUP_RECEIVER_UDP, /**< sets the receiver udp connection and returns receiver mac address */
|
||||
|
||||
//Acquisition setup functions
|
||||
@@ -70,6 +70,7 @@ enum recFuncs{
|
||||
F_RECEIVER_CHECK_VERSION, /** < check receiver version compatibility */
|
||||
F_RECEIVER_DISCARD_POLICY, /** < frames discard policy */
|
||||
F_RECEIVER_PADDING_ENABLE, /** < partial frames padding enable */
|
||||
F_RECEIVER_DEACTIVATED_PADDING_ENABLE, /** < deactivated receiver padding enable */
|
||||
/* Always append functions hereafter!!! */
|
||||
|
||||
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
using namespace std;
|
||||
#include "sls_receiver_defs.h"
|
||||
|
||||
/* uncomment next line to enable debug output */
|
||||
//#define EIGER_DEBUG
|
||||
|
||||
|
||||
int read_config_file(string fname, int *tcpip_port_no, map<string, string> * configuration_map);
|
||||
int read_config_file(std::string fname, int *tcpip_port_no, std::map<std::string, std::string> * configuration_map);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user