mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
after merging with developer
This commit is contained in:
@ -69,7 +69,7 @@ set(PUBLICHEADERS
|
||||
include/MySocketTCP.h
|
||||
include/genericSocket.h
|
||||
include/logger.h
|
||||
|
||||
include/sls_receiver_exceptions.h
|
||||
)
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ LIBZMQ = -L$(LIBZMQDIR) -Wl,-rpath=$(LIBZMQDIR) -lzmq
|
||||
|
||||
|
||||
SRC_CLNT = MySocketTCP.cpp ThreadObject.cpp Listener.cpp DataProcessor.cpp DataStreamer.cpp Fifo.cpp File.cpp BinaryFile.cpp UDPInterface.cpp UDPBaseImplementation.cpp UDPStandardImplementation.cpp slsReceiverTCPIPInterface.cpp slsReceiver.cpp slsReceiverUsers.cpp utilities.cpp
|
||||
DEPSINCLUDES = $(INCDIR)/ansi.h $(INCDIR)/sls_receiver_defs.h $(INCDIR)/sls_receiver_funcs.h $(INCDIR)/GeneralData.h $(INCDIR)/circularFifo.h $(INCDIR)/genericSocket.h $(INCDIR)/logger.h $(INCDIR)/receiver_defs.h $(INCDIR)/UDPInterface.h $(INCDIR)/utilities.h $(INCDIR)/ZmqSocket.h $(INCDIR)/BinaryFileStatic.h $(INCDIR)/HDF5FileStatic.h
|
||||
DEPSINCLUDES = $(INCDIR)/ansi.h $(INCDIR)/sls_receiver_defs.h $(INCDIR)/sls_receiver_funcs.h $(INCDIR)/GeneralData.h $(INCDIR)/circularFifo.h $(INCDIR)/genericSocket.h $(INCDIR)/logger.h $(INCDIR)/receiver_defs.h $(INCDIR)/UDPInterface.h $(INCDIR)/utilities.h $(INCDIR)/ZmqSocket.h $(INCDIR)/BinaryFileStatic.h $(INCDIR)/HDF5FileStatic.h $(INCDIR)/sls_receiver_exceptions.h
|
||||
|
||||
|
||||
ifeq ($(HDF5),yes)
|
||||
|
@ -1,9 +1,18 @@
|
||||
Path: slsDetectorsPackage/slsReceiverSoftware
|
||||
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
|
||||
<<<<<<< HEAD
|
||||
Repsitory UUID: 83600fcb15c8261173ab15a8ba8d1009693f2d23
|
||||
Revision: 813
|
||||
Branch: anna
|
||||
Last Changed Author: Anna_Bergamaschi
|
||||
Last Changed Rev: 3962
|
||||
Last Changed Date: 2018-09-04 08:41:33.000000002 +0200 ./src/slsReceiverTCPIPInterface.cpp
|
||||
=======
|
||||
Repsitory UUID: d2bce7e372c241cd235977b92be18555bca6a77d
|
||||
Revision: 839
|
||||
Branch: 4.0.0
|
||||
Last Changed Author: Dhanya_Thattil
|
||||
Last Changed Rev: 4020
|
||||
Last Changed Date: 2018-09-27 17:58:04.000000002 +0200 ./src/UDPStandardImplementation.cpp
|
||||
>>>>>>> developer
|
||||
|
@ -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);
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "Fifo.h"
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
FILE* BinaryFile::masterfd = 0;
|
||||
@ -53,7 +52,7 @@ int BinaryFile::CreateFile(uint64_t fnum) {
|
||||
if (BinaryFileStatic::CreateDataFile(filefd, *overWriteEnable, currentFileName, FILE_BUFFER_SIZE) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
if(!silentMode) {
|
||||
if(!(*silentMode)) {
|
||||
FILE_LOG(logINFO) << "[" << *udpPortNumber << "]: Binary File created: " << currentFileName;
|
||||
}
|
||||
return OK;
|
||||
@ -125,7 +124,7 @@ int BinaryFile::CreateMasterFile(bool en, uint32_t size,
|
||||
if (master && (*detIndex==0)) {
|
||||
masterFileName = BinaryFileStatic::CreateMasterFileName(filePath,
|
||||
fileNamePrefix, *fileIndex);
|
||||
if(!silentMode) {
|
||||
if(!(*silentMode)) {
|
||||
FILE_LOG(logINFO) << "Master File: " << masterFileName;
|
||||
}
|
||||
return BinaryFileStatic::CreateMasterDataFile(masterfd, masterFileName,
|
||||
|
@ -18,16 +18,15 @@
|
||||
#include <iostream>
|
||||
#include <errno.h>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
const string DataProcessor::TypeName = "DataProcessor";
|
||||
const std::string DataProcessor::TypeName = "DataProcessor";
|
||||
|
||||
|
||||
DataProcessor::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) :
|
||||
@ -47,7 +46,10 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo*& f,
|
||||
streamingTimerInMs(timer),
|
||||
currentFreqCount(0),
|
||||
tempBuffer(0),
|
||||
xcoordin1D(0),
|
||||
activated(act),
|
||||
deactivatedPaddingEnable(depaden),
|
||||
silentMode(sm),
|
||||
framePadding(fp),
|
||||
acquisitionStartedFlag(false),
|
||||
measurementStartedFlag(false),
|
||||
firstAcquisitionIndex(0),
|
||||
@ -55,8 +57,6 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo*& f,
|
||||
numTotalFramesCaught(0),
|
||||
numFramesCaught(0),
|
||||
currentFrameIndex(0),
|
||||
silentMode(false),
|
||||
framePadding(fp),
|
||||
rawDataReadyCallBack(dataReadycb),
|
||||
rawDataModifyReadyCallBack(dataModifyReadycb),
|
||||
pRawDataReady(pDataReadycb)
|
||||
@ -77,7 +77,7 @@ DataProcessor::~DataProcessor() {
|
||||
}
|
||||
|
||||
/** getters */
|
||||
string DataProcessor::GetType(){
|
||||
std::string DataProcessor::GetType(){
|
||||
return TypeName;
|
||||
}
|
||||
|
||||
@ -222,8 +222,6 @@ void DataProcessor::SetupFileWriter(bool fwe, int* nd, uint32_t* maxf,
|
||||
fileWriteEnable = fwe;
|
||||
if (g)
|
||||
generalData = g;
|
||||
// fix xcoord as detector is not providing it right now
|
||||
xcoordin1D = ((*dindex) * (*nunits)) + index;
|
||||
|
||||
|
||||
if (file) {
|
||||
@ -237,13 +235,13 @@ void DataProcessor::SetupFileWriter(bool fwe, int* nd, uint32_t* maxf,
|
||||
file = new HDF5File(index, maxf,
|
||||
nd, fname, fpath, findex, owenable,
|
||||
dindex, nunits, nf, dr, portno,
|
||||
generalData->nPixelsX, generalData->nPixelsY, &silentMode);
|
||||
generalData->nPixelsX, generalData->nPixelsY, silentMode);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
file = new BinaryFile(index, maxf,
|
||||
nd, fname, fpath, findex, owenable,
|
||||
dindex, nunits, nf, dr, portno, &silentMode);
|
||||
dindex, nunits, nf, dr, portno, silentMode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -364,18 +362,11 @@ void DataProcessor::ProcessAnImage(char* buf) {
|
||||
InsertGapPixels(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
|
||||
*dynamicRange);
|
||||
|
||||
// x coord is 0 for detector in pos [0,0,0]
|
||||
if (xcoordin1D) {
|
||||
// do nothing as detector has correctly send them
|
||||
if (header.xCoord || header.yCoord || header.zCoord)
|
||||
;
|
||||
// detector has send all 0's when there should have been a value greater than 0 in some dimension
|
||||
else
|
||||
header.xCoord = xcoordin1D;
|
||||
}
|
||||
|
||||
// frame padding
|
||||
if (*framePadding && nump < generalData->packetsPerFrame)
|
||||
// deactivated and padding enabled
|
||||
if ((!(*activated) && *deactivatedPaddingEnable) ||
|
||||
// frame padding
|
||||
(*framePadding && nump < generalData->packetsPerFrame))
|
||||
PadMissingPackets(buf);
|
||||
|
||||
// normal call back
|
||||
@ -398,10 +389,11 @@ void DataProcessor::ProcessAnImage(char* buf) {
|
||||
(*((uint32_t*)buf)) = revsize;
|
||||
}
|
||||
|
||||
|
||||
// write to file
|
||||
if (file)
|
||||
file->WriteToFile(buf + FIFO_HEADER_NUMBYTES,
|
||||
sizeof(sls_receiver_header) + (uint32_t)(*((uint32_t*)buf)),
|
||||
sizeof(sls_receiver_header) + (uint32_t)(*((uint32_t*)buf)), //+ size of data (resizable from previous call back
|
||||
fnum-firstMeasurementIndex, nump);
|
||||
|
||||
|
||||
@ -460,9 +452,6 @@ void DataProcessor::SetPixelDimension() {
|
||||
}
|
||||
}
|
||||
|
||||
void DataProcessor::SetSilentMode(bool mode) {
|
||||
silentMode = mode;
|
||||
}
|
||||
|
||||
void DataProcessor::PadMissingPackets(char* buf) {
|
||||
FILE_LOG(logDEBUG) << index << ": Padding Missing Packets";
|
||||
@ -488,7 +477,7 @@ void DataProcessor::PadMissingPackets(char* buf) {
|
||||
if (!nmissing)
|
||||
break;
|
||||
|
||||
FILE_LOG(logDEBUG) << "padding for " << index << " for pnum: " << pnum << endl;
|
||||
FILE_LOG(logDEBUG) << "padding for " << index << " for pnum: " << pnum << std::endl;
|
||||
|
||||
// missing packet
|
||||
switch(myDetectorType) {
|
||||
|
@ -11,28 +11,29 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <errno.h>
|
||||
using namespace std;
|
||||
|
||||
const string DataStreamer::TypeName = "DataStreamer";
|
||||
const std::string DataStreamer::TypeName = "DataStreamer";
|
||||
|
||||
|
||||
DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, int* sEnable, uint64_t* fi, int* fd, char* ajh) :
|
||||
DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI>* r,
|
||||
uint64_t* fi, int* fd, char* ajh, bool* sm) :
|
||||
ThreadObject(ind),
|
||||
runningFlag(0),
|
||||
generalData(0),
|
||||
fifo(f),
|
||||
zmqSocket(0),
|
||||
dynamicRange(dr),
|
||||
shortFrameEnable(sEnable),
|
||||
roi(r),
|
||||
adcConfigured(-1),
|
||||
fileIndex(fi),
|
||||
flippedData(fd),
|
||||
additionJsonHeader(ajh),
|
||||
silentMode(sm),
|
||||
acquisitionStartedFlag(false),
|
||||
measurementStartedFlag(false),
|
||||
firstAcquisitionIndex(0),
|
||||
firstMeasurementIndex(0),
|
||||
completeBuffer(0),
|
||||
flippedData(fd),
|
||||
additionJsonHeader(ajh),
|
||||
silentMode(false)
|
||||
completeBuffer(0)
|
||||
{
|
||||
if(ThreadObject::CreateThread() == FAIL)
|
||||
throw std::exception();
|
||||
@ -50,7 +51,7 @@ DataStreamer::~DataStreamer() {
|
||||
}
|
||||
|
||||
/** getters */
|
||||
string DataStreamer::GetType(){
|
||||
std::string DataStreamer::GetType(){
|
||||
return TypeName;
|
||||
}
|
||||
|
||||
@ -87,7 +88,10 @@ void DataStreamer::ResetParametersforNewMeasurement(char* fname){
|
||||
delete [] completeBuffer;
|
||||
completeBuffer = 0;
|
||||
}
|
||||
if (*shortFrameEnable >= 0) {
|
||||
if (roi->size()) {
|
||||
if (generalData->myDetectorType == GOTTHARD) {
|
||||
adcConfigured = generalData->GetAdcConfigured(index, roi);
|
||||
}
|
||||
completeBuffer = new char[generalData->imageSizeComplete];
|
||||
memset(completeBuffer, 0, generalData->imageSizeComplete);
|
||||
}
|
||||
@ -132,7 +136,7 @@ void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const char* srci
|
||||
uint32_t portnum = port + index;
|
||||
|
||||
try {
|
||||
zmqSocket = new ZmqSocket(portnum, (strlen(srcip)?srcip:NULL));
|
||||
zmqSocket = new ZmqSocket(portnum, (strlen(srcip)?srcip:NULL));
|
||||
} catch (...) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d for Streamer %d\n", portnum, index);
|
||||
throw;
|
||||
@ -211,11 +215,19 @@ void DataStreamer::ProcessAnImage(char* buf) {
|
||||
//shortframe gotthard
|
||||
if (completeBuffer) {
|
||||
|
||||
if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)), generalData->nPixelsXComplete, generalData->nPixelsYComplete, false))
|
||||
//disregarding the size modified from callback (always using imageSizeComplete
|
||||
// instead of buf (32 bit) because gui needs imagesizecomplete and listener
|
||||
//write imagesize
|
||||
|
||||
if (!SendHeader(header, generalData->imageSizeComplete,
|
||||
generalData->nPixelsXComplete, generalData->nPixelsYComplete, false))
|
||||
cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n",
|
||||
(long long int) fnum, index);
|
||||
|
||||
memcpy(completeBuffer + ((generalData->imageSize)**shortFrameEnable), buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), (uint32_t)(*((uint32_t*)buf)) ); // new size possibly from callback
|
||||
memcpy(completeBuffer + ((generalData->imageSize) * adcConfigured),
|
||||
buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
|
||||
(uint32_t)(*((uint32_t*)buf)) );
|
||||
|
||||
if (!zmqSocket->SendData(completeBuffer, generalData->imageSizeComplete))
|
||||
cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n",
|
||||
(long long int) fnum, index);
|
||||
@ -225,11 +237,13 @@ void DataStreamer::ProcessAnImage(char* buf) {
|
||||
//normal
|
||||
else {
|
||||
|
||||
if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)), generalData->nPixelsX, generalData->nPixelsY, false)) // new size possibly from callback
|
||||
if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)),
|
||||
generalData->nPixelsX, generalData->nPixelsY, false)) // new size possibly from callback
|
||||
cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n",
|
||||
(long long int) fnum, index);
|
||||
|
||||
if (!zmqSocket->SendData(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), (uint32_t)(*((uint32_t*)buf)) )) // new size possibly from callback
|
||||
if (!zmqSocket->SendData(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
|
||||
(uint32_t)(*((uint32_t*)buf)) )) // new size possibly from callback
|
||||
cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n",
|
||||
(long long int) fnum, index);
|
||||
}
|
||||
@ -251,7 +265,7 @@ int DataStreamer::SendHeader(sls_receiver_header* rheader, uint32_t size, uint32
|
||||
nx, ny, size,
|
||||
acquisitionIndex, frameIndex, fileNametoStream,
|
||||
header.frameNumber, header.expLength, header.packetNumber, header.bunchId, header.timestamp,
|
||||
header.modId, header.xCoord, header.yCoord, header.zCoord,
|
||||
header.modId, header.row, header.column, header.reserved,
|
||||
header.debug, header.roundRNumber,
|
||||
header.detType, header.version,
|
||||
flippedData,
|
||||
@ -272,7 +286,3 @@ int DataStreamer::RestreamStop() {
|
||||
}
|
||||
|
||||
|
||||
void DataStreamer::SetSilentMode(bool mode) {
|
||||
silentMode = mode;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
|
||||
Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth):
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "File.h"
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
File::File(int ind, uint32_t* maxf,
|
||||
@ -35,29 +34,29 @@ File::File(int ind, uint32_t* maxf,
|
||||
|
||||
File::~File() {}
|
||||
|
||||
string File::GetCurrentFileName() {
|
||||
std::string File::GetCurrentFileName() {
|
||||
return currentFileName;
|
||||
}
|
||||
|
||||
void File::PrintMembers() {
|
||||
FILE_LOG(logINFO) << "\nGeneral Writer Variables:" << endl
|
||||
<< "Index: " << index << endl
|
||||
<< "Max Frames Per File: " << *maxFramesPerFile << endl
|
||||
<< "Number of Detectors in x dir: " << numDetX << endl
|
||||
<< "Number of Detectors in y dir: " << numDetY << endl
|
||||
<< "File Name Prefix: " << fileNamePrefix << endl
|
||||
<< "File Path: " << filePath << endl
|
||||
<< "File Index: " << *fileIndex << endl
|
||||
<< "Over Write Enable: " << *overWriteEnable << endl
|
||||
FILE_LOG(logINFO) << "\nGeneral Writer Variables:" << std::endl
|
||||
<< "Index: " << index << std::endl
|
||||
<< "Max Frames Per File: " << *maxFramesPerFile << std::endl
|
||||
<< "Number of Detectors in x dir: " << numDetX << std::endl
|
||||
<< "Number of Detectors in y dir: " << numDetY << std::endl
|
||||
<< "File Name Prefix: " << fileNamePrefix << std::endl
|
||||
<< "File Path: " << filePath << std::endl
|
||||
<< "File Index: " << *fileIndex << std::endl
|
||||
<< "Over Write Enable: " << *overWriteEnable << std::endl
|
||||
|
||||
<< "Detector Index: " << *detIndex << endl
|
||||
<< "Number of Units Per Detector: " << *numUnitsPerDetector << endl
|
||||
<< "Number of Images in Acquisition: " << *numImages << endl
|
||||
<< "Dynamic Range: " << *dynamicRange << endl
|
||||
<< "UDP Port number: " << *udpPortNumber << endl
|
||||
<< "Master File Name: " << masterFileName << endl
|
||||
<< "Current File Name: " << currentFileName << endl
|
||||
<< "Silent Mode: " << silentMode;
|
||||
<< "Detector Index: " << *detIndex << std::endl
|
||||
<< "Number of Units Per Detector: " << *numUnitsPerDetector << std::endl
|
||||
<< "Number of Images in Acquisition: " << *numImages << std::endl
|
||||
<< "Dynamic Range: " << *dynamicRange << std::endl
|
||||
<< "UDP Port number: " << *udpPortNumber << std::endl
|
||||
<< "Master File Name: " << masterFileName << std::endl
|
||||
<< "Current File Name: " << currentFileName << std::endl
|
||||
<< "Silent Mode: " << *silentMode;
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,8 +11,6 @@
|
||||
#include <iomanip>
|
||||
#include <libgen.h> //basename
|
||||
#include <string.h>
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
pthread_mutex_t HDF5File::Mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
@ -65,13 +63,13 @@ HDF5File::HDF5File(int ind, uint32_t* maxf,
|
||||
parameterNames.push_back("mod id");
|
||||
parameterDataTypes.push_back(PredType::STD_U16LE);
|
||||
|
||||
parameterNames.push_back("x Coord");
|
||||
parameterNames.push_back("row");
|
||||
parameterDataTypes.push_back(PredType::STD_U16LE);
|
||||
|
||||
parameterNames.push_back("y Coord");
|
||||
parameterNames.push_back("column");
|
||||
parameterDataTypes.push_back(PredType::STD_U16LE);
|
||||
|
||||
parameterNames.push_back("z Coord");
|
||||
parameterNames.push_back("reserved");
|
||||
parameterDataTypes.push_back(PredType::STD_U16LE);
|
||||
|
||||
parameterNames.push_back("debug");
|
||||
@ -159,7 +157,7 @@ int HDF5File::CreateFile(uint64_t fnum) {
|
||||
if (dataspace == NULL)
|
||||
cprintf(RED,"Got nothing!\n");
|
||||
|
||||
if(!silentMode) {
|
||||
if(!(*silentMode)) {
|
||||
FILE_LOG(logINFO) << *udpPortNumber << ": HDF5 File created: " << currentFileName;
|
||||
}
|
||||
return OK;
|
||||
@ -170,6 +168,13 @@ void HDF5File::CloseCurrentFile() {
|
||||
pthread_mutex_lock(&Mutex);
|
||||
HDF5FileStatic::CloseDataFile(index, filefd);
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
for (unsigned int i = 0; i < dataset_para.size(); ++i)
|
||||
delete dataset_para[i];
|
||||
dataset_para.clear();
|
||||
if(dataspace_para) {delete dataspace_para;dataspace_para=0;}
|
||||
if(dataset) {delete dataset;dataset=0;}
|
||||
if(dataspace) {delete dataspace;dataspace=0;}
|
||||
if(filefd) {delete filefd;filefd=0;}
|
||||
}
|
||||
|
||||
|
||||
@ -182,10 +187,19 @@ void HDF5File::CloseAllFiles() {
|
||||
HDF5FileStatic::CloseVirtualDataFile(virtualfd);
|
||||
}
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
|
||||
for (unsigned int i = 0; i < dataset_para.size(); ++i)
|
||||
delete dataset_para[i];
|
||||
dataset_para.clear();
|
||||
if(dataspace_para) delete dataspace_para;
|
||||
if(dataset) delete dataset;
|
||||
if(dataspace) delete dataspace;
|
||||
if(filefd) delete filefd;
|
||||
}
|
||||
|
||||
|
||||
int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t nump) {
|
||||
|
||||
// check if maxframesperfile = 0 for infinite
|
||||
if ((*maxFramesPerFile) && (numFramesInFile >= (*maxFramesPerFile))) {
|
||||
CloseCurrentFile();
|
||||
@ -199,7 +213,7 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t
|
||||
if (fnum >= extNumImages) {
|
||||
if (HDF5FileStatic::ExtendDataset(index, dataspace, dataset,
|
||||
dataspace_para, dataset_para, *numImages) == OK) {
|
||||
if (!silentMode) {
|
||||
if (!(*silentMode)) {
|
||||
cprintf(BLUE,"%d Extending HDF5 dataset by %llu, Total x Dimension: %llu\n",
|
||||
index, (long long unsigned int)extNumImages,
|
||||
(long long unsigned int)(extNumImages + *numImages));
|
||||
@ -213,12 +227,12 @@ int HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t
|
||||
((*maxFramesPerFile == 0) ? fnum : fnum%(*maxFramesPerFile)),
|
||||
nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
||||
dataspace, dataset, datatype) == OK) {
|
||||
sls_receiver_header* header = (sls_receiver_header*) (buffer);
|
||||
/*header->xCoord = ((*detIndex) * (*numUnitsPerDetector) + index); */
|
||||
|
||||
if (HDF5FileStatic::WriteParameterDatasets(index, dataspace_para,
|
||||
// infinite then no need for %maxframesperfile
|
||||
((*maxFramesPerFile == 0) ? fnum : fnum%(*maxFramesPerFile)),
|
||||
dataset_para, header, parameterDataTypes) == OK) {
|
||||
dataset_para, (sls_receiver_header*) (buffer),
|
||||
parameterDataTypes) == OK) {
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
return OK;
|
||||
}
|
||||
@ -242,7 +256,7 @@ int HDF5File::CreateMasterFile(bool en, uint32_t size,
|
||||
virtualfd = 0;
|
||||
masterFileName = HDF5FileStatic::CreateMasterFileName(filePath,
|
||||
fileNamePrefix, *fileIndex);
|
||||
if(!silentMode) {
|
||||
if(!(*silentMode)) {
|
||||
FILE_LOG(logINFO) << "Master File: " << masterFileName;
|
||||
}
|
||||
pthread_mutex_lock(&Mutex);
|
||||
@ -262,43 +276,57 @@ void HDF5File::EndofAcquisition(bool anyPacketsCaught, uint64_t numf) {
|
||||
//not created before
|
||||
if (!virtualfd && anyPacketsCaught) {
|
||||
|
||||
//only one file and one sub image (link current file in master)
|
||||
if (((numFilesinAcquisition == 1) && (numDetY*numDetX) == 1)) {
|
||||
//dataset name
|
||||
ostringstream osfn;
|
||||
osfn << "/data";
|
||||
if ((*numImages > 1)) osfn << "_f" << setfill('0') << setw(12) << 0;
|
||||
string dsetname = osfn.str();
|
||||
pthread_mutex_lock(&Mutex);
|
||||
HDF5FileStatic::LinkVirtualInMaster(masterFileName, currentFileName,
|
||||
dsetname, parameterNames);
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
}
|
||||
// called only by the one maser receiver
|
||||
if (master && (*detIndex==0)) {
|
||||
|
||||
//create virutal file
|
||||
else
|
||||
CreateVirtualFile(numf);
|
||||
//only one file and one sub image (link current file in master)
|
||||
if (((numFilesinAcquisition == 1) && (numDetY*numDetX) == 1)) {
|
||||
LinkVirtualFileinMasterFile();
|
||||
}
|
||||
//create virutal file
|
||||
else{
|
||||
CreateVirtualFile(numf);}
|
||||
}
|
||||
}
|
||||
numFilesinAcquisition = 0;
|
||||
}
|
||||
|
||||
|
||||
// called only by the one maser receiver
|
||||
int HDF5File::CreateVirtualFile(uint64_t numf) {
|
||||
if (master && (*detIndex==0)) {
|
||||
pthread_mutex_lock(&Mutex);
|
||||
int ret = HDF5FileStatic::CreateVirtualDataFile(
|
||||
virtualfd, masterFileName,
|
||||
filePath, fileNamePrefix, *fileIndex, (*numImages > 1),
|
||||
*detIndex, *numUnitsPerDetector,
|
||||
// infinite images in 1 file, then maxfrperfile = numf
|
||||
((*maxFramesPerFile == 0) ? numf+1 : *maxFramesPerFile),
|
||||
numf+1,
|
||||
"data", datatype,
|
||||
numDetY, numDetX, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
||||
HDF5_WRITER_VERSION,
|
||||
parameterNames, parameterDataTypes);
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
return ret;
|
||||
pthread_mutex_lock(&Mutex);
|
||||
|
||||
std::string vname = HDF5FileStatic::CreateVirtualFileName(filePath, fileNamePrefix, *fileIndex);
|
||||
if(!(*silentMode)) {
|
||||
FILE_LOG(logINFO) << "Virtual File: " << vname;
|
||||
}
|
||||
return OK;
|
||||
|
||||
int ret = HDF5FileStatic::CreateVirtualDataFile(vname,
|
||||
virtualfd, masterFileName,
|
||||
filePath, fileNamePrefix, *fileIndex, (*numImages > 1),
|
||||
*detIndex, *numUnitsPerDetector,
|
||||
// infinite images in 1 file, then maxfrperfile = numf
|
||||
((*maxFramesPerFile == 0) ? numf+1 : *maxFramesPerFile),
|
||||
numf+1,
|
||||
"data", datatype,
|
||||
numDetY, numDetX, nPixelsY, ((*dynamicRange==4) ? (nPixelsX/2) : nPixelsX),
|
||||
HDF5_WRITER_VERSION,
|
||||
parameterNames, parameterDataTypes);
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// called only by the one maser receiver
|
||||
int HDF5File::LinkVirtualFileinMasterFile() {
|
||||
//dataset name
|
||||
std::ostringstream osfn;
|
||||
osfn << "/data";
|
||||
if ((*numImages > 1)) osfn << "_f" << std::setfill('0') << std::setw(12) << 0;
|
||||
std::string dsetname = osfn.str();
|
||||
|
||||
pthread_mutex_lock(&Mutex);
|
||||
int ret = HDF5FileStatic::LinkVirtualInMaster(masterFileName, currentFileName,
|
||||
dsetname, parameterNames);
|
||||
pthread_mutex_unlock(&Mutex);
|
||||
return ret;
|
||||
}
|
||||
|
@ -14,15 +14,14 @@
|
||||
#include <iostream>
|
||||
#include <errno.h>
|
||||
#include <cstring>
|
||||
using namespace std;
|
||||
|
||||
const string Listener::TypeName = "Listener";
|
||||
const std::string Listener::TypeName = "Listener";
|
||||
|
||||
|
||||
Listener::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) :
|
||||
ThreadObject(ind),
|
||||
runningFlag(0),
|
||||
generalData(0),
|
||||
@ -38,6 +37,11 @@ Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
||||
actualUDPSocketBufferSize(as),
|
||||
framesPerFile(fpf),
|
||||
frameDiscardMode(fdp),
|
||||
activated(act),
|
||||
deactivatedPaddingEnable(depaden),
|
||||
silentMode(sm),
|
||||
row(0),
|
||||
column(0),
|
||||
acquisitionStartedFlag(false),
|
||||
measurementStartedFlag(false),
|
||||
firstAcquisitionIndex(0),
|
||||
@ -50,8 +54,7 @@ Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
||||
listeningPacket(0),
|
||||
udpSocketAlive(0),
|
||||
numPacketsStatistic(0),
|
||||
numFramesStatistic(0),
|
||||
silentMode(false)
|
||||
numFramesStatistic(0)
|
||||
{
|
||||
if(ThreadObject::CreateThread() == FAIL)
|
||||
throw std::exception();
|
||||
@ -70,7 +73,7 @@ Listener::~Listener() {
|
||||
}
|
||||
|
||||
/** getters */
|
||||
string Listener::GetType(){
|
||||
std::string Listener::GetType(){
|
||||
return TypeName;
|
||||
}
|
||||
|
||||
@ -155,7 +158,7 @@ void Listener::RecordFirstIndices(uint64_t fnum) {
|
||||
firstAcquisitionIndex = fnum;
|
||||
}
|
||||
|
||||
if(!silentMode) {
|
||||
if(!(*silentMode)) {
|
||||
if (!index) cprintf(BLUE,"%d First Acquisition Index:%lu\n"
|
||||
"%d First Measurement Index:%lu\n",
|
||||
index, firstAcquisitionIndex,
|
||||
@ -183,6 +186,10 @@ int Listener::SetThreadPriority(int priority) {
|
||||
|
||||
int Listener::CreateUDPSockets() {
|
||||
|
||||
if (!(*activated)) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
//if eth is mistaken with ip address
|
||||
if (strchr(eth,'.') != NULL){
|
||||
memset(eth, 0, MAX_STR_LENGTH);
|
||||
@ -193,16 +200,16 @@ int Listener::CreateUDPSockets() {
|
||||
|
||||
ShutDownUDPSocket();
|
||||
|
||||
udpSocket = new genericSocket(*udpPortNumber, genericSocket::UDP,
|
||||
generalData->packetSize, (strlen(eth)?eth:NULL), generalData->headerPacketSize,
|
||||
*udpSocketBufferSize);
|
||||
int iret = udpSocket->getErrorStatus();
|
||||
if(!iret){
|
||||
try{
|
||||
udpSocket = new genericSocket(*udpPortNumber, genericSocket::UDP,
|
||||
generalData->packetSize, (strlen(eth)?eth:NULL), generalData->headerPacketSize,
|
||||
*udpSocketBufferSize);
|
||||
FILE_LOG(logINFO) << index << ": UDP port opened at port " << *udpPortNumber;
|
||||
}else{
|
||||
FILE_LOG(logERROR) << "Could not create UDP socket on port " << *udpPortNumber << " error: " << iret;
|
||||
} catch (...) {
|
||||
FILE_LOG(logERROR) << "Could not create UDP socket on port " << *udpPortNumber;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
udpSocketAlive = true;
|
||||
sem_init(&semaphore_socket,1,0);
|
||||
|
||||
@ -229,13 +236,14 @@ void Listener::ShutDownUDPSocket() {
|
||||
}
|
||||
|
||||
|
||||
void Listener::SetSilentMode(bool mode) {
|
||||
silentMode = mode;
|
||||
}
|
||||
|
||||
|
||||
int Listener::CreateDummySocketForUDPSocketBufferSize(uint32_t s) {
|
||||
FILE_LOG(logINFO) << "Testing UDP Socket Buffer size with test port " << *udpPortNumber;
|
||||
|
||||
if (!(*activated)) {
|
||||
*actualUDPSocketBufferSize = (s*2);
|
||||
return OK;
|
||||
}
|
||||
|
||||
uint32_t temp = *udpSocketBufferSize;
|
||||
*udpSocketBufferSize = s;
|
||||
|
||||
@ -248,17 +256,20 @@ int Listener::CreateDummySocketForUDPSocketBufferSize(uint32_t s) {
|
||||
if(udpSocket){
|
||||
udpSocket->ShutDownSocket();
|
||||
delete udpSocket;
|
||||
udpSocket = 0;
|
||||
}
|
||||
|
||||
//create dummy socket
|
||||
udpSocket = new genericSocket(*udpPortNumber, genericSocket::UDP,
|
||||
try {
|
||||
udpSocket = new genericSocket(*udpPortNumber, genericSocket::UDP,
|
||||
generalData->packetSize, (strlen(eth)?eth:NULL), generalData->headerPacketSize,
|
||||
*udpSocketBufferSize);
|
||||
int iret = udpSocket->getErrorStatus();
|
||||
if (iret){
|
||||
FILE_LOG(logERROR) << "Could not create a test UDP socket on port " << *udpPortNumber << " error: " << iret;
|
||||
} catch (...) {
|
||||
FILE_LOG(logERROR) << "Could not create a test UDP socket on port " << *udpPortNumber;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
// doubled due to kernel bookkeeping (could also be less due to permissions)
|
||||
*actualUDPSocketBufferSize = udpSocket->getActualUDPSocketBufferSize();
|
||||
if (*actualUDPSocketBufferSize != (s*2)) {
|
||||
@ -277,6 +288,10 @@ int Listener::CreateDummySocketForUDPSocketBufferSize(uint32_t s) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
void Listener::SetHardCodedPosition(uint16_t r, uint16_t c) {
|
||||
row = r;
|
||||
column = c;
|
||||
}
|
||||
|
||||
void Listener::ThreadExecution() {
|
||||
char* buffer;
|
||||
@ -288,7 +303,7 @@ void Listener::ThreadExecution() {
|
||||
#endif
|
||||
|
||||
//udpsocket doesnt exist
|
||||
if (!udpSocketAlive && !carryOverFlag) {
|
||||
if (*activated && !udpSocketAlive && !carryOverFlag) {
|
||||
//FILE_LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not created or shut down earlier";
|
||||
(*((uint32_t*)buffer)) = 0;
|
||||
StopListening(buffer);
|
||||
@ -296,7 +311,7 @@ void Listener::ThreadExecution() {
|
||||
}
|
||||
|
||||
//get data
|
||||
if ((*status != TRANSMITTING && udpSocketAlive) || carryOverFlag) {
|
||||
if ((*status != TRANSMITTING && (!(*activated) || udpSocketAlive)) || carryOverFlag) {
|
||||
rc = ListenToAnImage(buffer);
|
||||
}
|
||||
|
||||
@ -328,7 +343,7 @@ void Listener::ThreadExecution() {
|
||||
fifo->PushAddress(buffer);
|
||||
|
||||
//Statistics
|
||||
if(!silentMode) {
|
||||
if(!(*silentMode)) {
|
||||
numFramesStatistic++;
|
||||
if (numFramesStatistic >=
|
||||
//second condition also for infinite #number of frames
|
||||
@ -354,6 +369,7 @@ void Listener::StopListening(char* buf) {
|
||||
|
||||
/* buf includes the fifo header and packet header */
|
||||
uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
|
||||
int rc = 0;
|
||||
uint64_t fnum = 0, bid = 0;
|
||||
uint32_t pnum = 0, snum = 0;
|
||||
@ -375,6 +391,27 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
/*memset(buf + fifohsize, 0xFF, generalData->imageSize);*/
|
||||
new_header = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES);
|
||||
|
||||
// deactivated (eiger)
|
||||
if (!(*activated)) {
|
||||
// no padding
|
||||
if (!(*deactivatedPaddingEnable))
|
||||
return 0;
|
||||
// padding without setting bitmask (all missing packets padded in dataProcessor)
|
||||
if (currentFrameIndex >= *numImages)
|
||||
return 0;
|
||||
|
||||
//(eiger) first fnum starts at 1
|
||||
if (!currentFrameIndex) {
|
||||
++currentFrameIndex;
|
||||
}
|
||||
new_header->detHeader.frameNumber = currentFrameIndex;
|
||||
new_header->detHeader.row = row;
|
||||
new_header->detHeader.column = column;
|
||||
new_header->detHeader.detType = (uint8_t) generalData->myDetectorType;
|
||||
new_header->detHeader.version = (uint8_t) SLS_DETECTOR_HEADER_VERSION;
|
||||
return generalData->imageSize;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//look for carry over
|
||||
@ -409,6 +446,10 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
break;
|
||||
}
|
||||
new_header->detHeader.packetNumber = numpackets;
|
||||
if(isHeaderEmpty) {
|
||||
new_header->detHeader.row = row;
|
||||
new_header->detHeader.column = column;
|
||||
}
|
||||
return generalData->imageSize;
|
||||
}
|
||||
|
||||
@ -446,6 +487,8 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
// -------------------old header ------------------------------------------------------------------------------
|
||||
else {
|
||||
new_header->detHeader.frameNumber = fnum;
|
||||
new_header->detHeader.row = row;
|
||||
new_header->detHeader.column = column;
|
||||
new_header->detHeader.detType = (uint8_t) generalData->myDetectorType;
|
||||
new_header->detHeader.version = (uint8_t) SLS_DETECTOR_HEADER_VERSION;
|
||||
}
|
||||
@ -480,6 +523,10 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
break;
|
||||
}
|
||||
new_header->detHeader.packetNumber = numpackets; //number of packets caught
|
||||
if(isHeaderEmpty) {
|
||||
new_header->detHeader.row = row;
|
||||
new_header->detHeader.column = column;
|
||||
}
|
||||
return generalData->imageSize; //empty packet now, but not empty image
|
||||
}
|
||||
|
||||
@ -535,6 +582,10 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
break;
|
||||
}
|
||||
new_header->detHeader.packetNumber = numpackets; //number of packets caught
|
||||
if(isHeaderEmpty) {
|
||||
new_header->detHeader.row = row;
|
||||
new_header->detHeader.column = column;
|
||||
}
|
||||
return generalData->imageSize;
|
||||
}
|
||||
|
||||
@ -569,6 +620,8 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
// -------------------old header ------------------------------------------------------------------------------
|
||||
else {
|
||||
new_header->detHeader.frameNumber = fnum;
|
||||
new_header->detHeader.row = row;
|
||||
new_header->detHeader.column = column;
|
||||
new_header->detHeader.detType = (uint8_t) generalData->myDetectorType;
|
||||
new_header->detHeader.version = (uint8_t) SLS_DETECTOR_HEADER_VERSION;
|
||||
}
|
||||
|
@ -7,13 +7,6 @@
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <syscall.h>
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
|
@ -5,13 +5,10 @@
|
||||
***********************************************/
|
||||
|
||||
#include "UDPBaseImplementation.h"
|
||||
#include "genericSocket.h"
|
||||
#include "ZmqSocket.h"
|
||||
|
||||
#include <sys/stat.h> // stat
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
@ -60,6 +57,7 @@ void UDPBaseImplementation::initializeMembers(){
|
||||
//***receiver parameters***
|
||||
status = IDLE;
|
||||
activated = true;
|
||||
deactivatedPaddingEnable = true;
|
||||
frameDiscardMode = NO_DISCARD;
|
||||
framePadding = false;
|
||||
|
||||
@ -83,7 +81,7 @@ void UDPBaseImplementation::initializeMembers(){
|
||||
dataCompressionEnable = false;
|
||||
|
||||
//***acquisition parameters***
|
||||
shortFrameEnable = -1;
|
||||
roi.clear();
|
||||
frameToGuiFrequency = 0;
|
||||
frameToGuiTimerinMS = DEFAULT_STREAMING_TIMER_IN_MS;
|
||||
dataStreamEnable = false;
|
||||
@ -92,7 +90,7 @@ void UDPBaseImplementation::initializeMembers(){
|
||||
memset(additionalJsonHeader, 0, sizeof(additionalJsonHeader));
|
||||
|
||||
//***receiver parameters***
|
||||
silentMode = 0;
|
||||
silentMode = false;
|
||||
|
||||
}
|
||||
|
||||
@ -251,9 +249,9 @@ char *UDPBaseImplementation::getEthernetInterface() const{
|
||||
|
||||
|
||||
/***acquisition parameters***/
|
||||
int UDPBaseImplementation::getShortFrameEnable() const{
|
||||
std::vector<slsReceiverDefs::ROI> UDPBaseImplementation::getROI() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
return shortFrameEnable;
|
||||
return roi;
|
||||
}
|
||||
|
||||
uint32_t UDPBaseImplementation::getFrameToGuiFrequency() const{
|
||||
@ -320,15 +318,20 @@ slsReceiverDefs::runStatus UDPBaseImplementation::getStatus() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
return status;}
|
||||
|
||||
uint32_t UDPBaseImplementation::getSilentMode() const{
|
||||
bool UDPBaseImplementation::getSilentMode() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
return silentMode;}
|
||||
|
||||
int UDPBaseImplementation::getActivate() const{
|
||||
bool UDPBaseImplementation::getActivate() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
return activated;
|
||||
}
|
||||
|
||||
bool UDPBaseImplementation::getDeactivatedPadding() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
return deactivatedPaddingEnable;
|
||||
}
|
||||
|
||||
uint32_t UDPBaseImplementation::getStreamingPort() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
return streamingPort;
|
||||
@ -369,7 +372,7 @@ uint32_t UDPBaseImplementation::getActualUDPSocketBufferSize() const {
|
||||
*************************************************************************/
|
||||
|
||||
/**initial parameters***/
|
||||
void UDPBaseImplementation::configure(map<string, string> config_map){
|
||||
void UDPBaseImplementation::configure(std::map<std::string, std::string> config_map){
|
||||
FILE_LOG(logERROR) << __AT__ << " doing nothing...";
|
||||
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
|
||||
}
|
||||
@ -537,11 +540,27 @@ void UDPBaseImplementation::setEthernetInterface(const char* c){
|
||||
|
||||
|
||||
/***acquisition parameters***/
|
||||
int UDPBaseImplementation::setShortFrameEnable(const int i){
|
||||
int UDPBaseImplementation::setROI(const std::vector<slsReceiverDefs::ROI> i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
shortFrameEnable = i;
|
||||
FILE_LOG(logINFO) << "Short Frame Enable: " << stringEnable(shortFrameEnable);
|
||||
roi = i;
|
||||
|
||||
std::stringstream sstm;
|
||||
sstm << "ROI: ";
|
||||
if (!roi.size())
|
||||
sstm << "0";
|
||||
else {
|
||||
for (unsigned int i = 0; i < roi.size(); ++i) {
|
||||
sstm << "( " <<
|
||||
roi[i].xmin << ", " <<
|
||||
roi[i].xmax << ", " <<
|
||||
roi[i].ymin << ", " <<
|
||||
roi[i].ymax << " )";
|
||||
}
|
||||
}
|
||||
std::string message = sstm.str();
|
||||
FILE_LOG(logINFO) << message;
|
||||
|
||||
//overrridden child classes might return FAIL
|
||||
return OK;
|
||||
}
|
||||
@ -660,7 +679,7 @@ int UDPBaseImplementation::setFifoDepth(const uint32_t i){
|
||||
}
|
||||
|
||||
/***receiver parameters***/
|
||||
void UDPBaseImplementation::setSilentMode(const uint32_t i){
|
||||
void UDPBaseImplementation::setSilentMode(const bool i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
silentMode = i;
|
||||
@ -735,17 +754,20 @@ void UDPBaseImplementation::abort(){
|
||||
}
|
||||
|
||||
|
||||
int UDPBaseImplementation::setActivate(int enable){
|
||||
bool UDPBaseImplementation::setActivate(bool enable){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
if(enable != -1){
|
||||
activated = enable;
|
||||
FILE_LOG(logINFO) << "Activation: " << stringEnable(activated);
|
||||
}
|
||||
|
||||
activated = enable;
|
||||
FILE_LOG(logINFO) << "Activation: " << stringEnable(activated);
|
||||
return activated;
|
||||
}
|
||||
|
||||
bool UDPBaseImplementation::setDeactivatedPadding(bool enable){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
deactivatedPaddingEnable = enable;
|
||||
FILE_LOG(logINFO) << "Deactivated Padding Enable: " << stringEnable(deactivatedPaddingEnable);
|
||||
return deactivatedPaddingEnable;
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::setStreamingPort(const uint32_t i) {
|
||||
streamingPort = i;
|
||||
|
||||
|
@ -7,16 +7,14 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
using namespace std;
|
||||
|
||||
|
||||
#include "UDPInterface.h"
|
||||
#include "UDPBaseImplementation.h"
|
||||
#include "UDPStandardImplementation.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
UDPInterface * UDPInterface::create(string receiver_type){
|
||||
UDPInterface * UDPInterface::create(std::string receiver_type){
|
||||
|
||||
if (receiver_type == "standard"){
|
||||
FILE_LOG(logINFO) << "Starting " << receiver_type;
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include <cstring> //strcpy
|
||||
#include <errno.h> //eperm
|
||||
#include <fstream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
/** cosntructor & destructor */
|
||||
@ -33,16 +32,16 @@ UDPStandardImplementation::~UDPStandardImplementation() {
|
||||
|
||||
void UDPStandardImplementation::DeleteMembers() {
|
||||
if (generalData) { delete generalData; generalData=0;}
|
||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
delete(*it);
|
||||
listener.clear();
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
delete(*it);
|
||||
dataProcessor.clear();
|
||||
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||
delete(*it);
|
||||
dataStreamer.clear();
|
||||
for (vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
|
||||
for (std::vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
|
||||
delete(*it);
|
||||
fifo.clear();
|
||||
}
|
||||
@ -69,8 +68,8 @@ uint64_t UDPStandardImplementation::getTotalFramesCaught() const {
|
||||
uint64_t sum = 0;
|
||||
uint32_t flagsum = 0;
|
||||
|
||||
vector<DataProcessor*>::const_iterator it;
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
||||
std::vector<DataProcessor*>::const_iterator it;
|
||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
||||
flagsum += ((*it)->GetMeasurementStartedFlag() ? 1 : 0);
|
||||
sum += (*it)->GetNumTotalFramesCaught();
|
||||
}
|
||||
@ -85,7 +84,7 @@ uint64_t UDPStandardImplementation::getFramesCaught() const {
|
||||
uint64_t sum = 0;
|
||||
uint32_t flagsum = 0;
|
||||
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
||||
flagsum += ((*it)->GetAcquisitionStartedFlag() ? 1 : 0);
|
||||
sum += (*it)->GetNumFramesCaught();
|
||||
}
|
||||
@ -100,7 +99,7 @@ int64_t UDPStandardImplementation::getAcquisitionIndex() const {
|
||||
uint64_t sum = 0;
|
||||
uint32_t flagsum = 0;
|
||||
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
|
||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
|
||||
flagsum += ((*it)->GetAcquisitionStartedFlag() ? 1 : 0);
|
||||
sum += (*it)->GetActualProcessedAcquisitionIndex();
|
||||
}
|
||||
@ -120,7 +119,7 @@ int UDPStandardImplementation::setGapPixelsEnable(const bool b) {
|
||||
// side effects
|
||||
generalData->SetGapPixelsEnable(b, dynamicRange);
|
||||
// to update npixelsx, npixelsy in file writer
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
(*it)->SetPixelDimension();
|
||||
|
||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
||||
@ -144,7 +143,7 @@ void UDPStandardImplementation::setFileFormat(const fileFormat f){
|
||||
break;
|
||||
}
|
||||
//destroy file writer, set file format and create file writer
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
(*it)->SetFileFormat(f);
|
||||
|
||||
FILE_LOG(logINFO) << "File Format:" << getFileFormatType(fileFormatType);
|
||||
@ -168,35 +167,64 @@ void UDPStandardImplementation::setFileWriteEnable(const bool b){
|
||||
|
||||
|
||||
|
||||
int UDPStandardImplementation::setShortFrameEnable(const int i) {
|
||||
int UDPStandardImplementation::setROI(const std::vector<slsReceiverDefs::ROI> i) {
|
||||
if (myDetectorType != GOTTHARD) {
|
||||
cprintf(RED, "Error: Can not set short frame for this detector\n");
|
||||
cprintf(RED, "Error: Can not set ROI for this detector\n");
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (shortFrameEnable != i) {
|
||||
shortFrameEnable = i;
|
||||
|
||||
if (generalData)
|
||||
delete generalData;
|
||||
if (i != -1)
|
||||
generalData = new ShortGotthardData();
|
||||
else
|
||||
generalData = new GotthardData();
|
||||
bool change = false;
|
||||
if (roi.size() != i.size())
|
||||
change = true;
|
||||
else {
|
||||
for (unsigned int iloop = 0; iloop < i.size(); ++iloop) {
|
||||
if (
|
||||
(roi[iloop].xmin != i[iloop].xmin) ||
|
||||
(roi[iloop].xmax != i[iloop].xmax) ||
|
||||
(roi[iloop].ymin != i[iloop].ymin) ||
|
||||
(roi[iloop].xmax != i[iloop].xmax)) {
|
||||
change = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (change) {
|
||||
|
||||
roi = i;
|
||||
|
||||
generalData->SetROI(i);
|
||||
framesPerFile = generalData->maxFramesPerFile;
|
||||
|
||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
return FAIL;
|
||||
|
||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
(*it)->SetGeneralData(generalData);
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
(*it)->SetGeneralData(generalData);
|
||||
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||
(*it)->SetGeneralData(generalData);
|
||||
}
|
||||
FILE_LOG(logINFO) << "Short Frame Enable: " << shortFrameEnable;
|
||||
|
||||
|
||||
std::stringstream sstm;
|
||||
sstm << "ROI: ";
|
||||
if (!roi.size())
|
||||
sstm << "0";
|
||||
else {
|
||||
for (unsigned int i = 0; i < roi.size(); ++i) {
|
||||
sstm << "( " <<
|
||||
roi[i].xmin << ", " <<
|
||||
roi[i].xmax << ", " <<
|
||||
roi[i].ymin << ", " <<
|
||||
roi[i].ymax << " )";
|
||||
}
|
||||
}
|
||||
std::string message = sstm.str();
|
||||
FILE_LOG(logINFO) << message;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -216,7 +244,7 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
|
||||
dataStreamEnable = enable;
|
||||
|
||||
//data sockets have to be created again as the client ones are
|
||||
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||
delete(*it);
|
||||
dataStreamer.clear();
|
||||
|
||||
@ -224,13 +252,13 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
|
||||
for ( int i = 0; i < numThreads; ++i ) {
|
||||
try {
|
||||
DataStreamer* s = new DataStreamer(i, fifo[i], &dynamicRange,
|
||||
&shortFrameEnable, &fileIndex, flippedData, additionalJsonHeader);
|
||||
&roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode);
|
||||
dataStreamer.push_back(s);
|
||||
dataStreamer[i]->SetGeneralData(generalData);
|
||||
dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP);
|
||||
}
|
||||
catch(...) {
|
||||
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||
delete(*it);
|
||||
dataStreamer.clear();
|
||||
dataStreamEnable = false;
|
||||
@ -269,7 +297,7 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i) {
|
||||
generalData->SetDynamicRange(i,tengigaEnable);
|
||||
generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange);
|
||||
// to update npixelsx, npixelsy in file writer
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
(*it)->SetPixelDimension();
|
||||
|
||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
||||
@ -309,19 +337,6 @@ int UDPStandardImplementation::setFifoDepth(const uint32_t i) {
|
||||
}
|
||||
|
||||
|
||||
void UDPStandardImplementation::setSilentMode(const uint32_t i){
|
||||
silentMode = i;
|
||||
|
||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
(*it)->SetSilentMode(i);
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
(*it)->SetSilentMode(i);
|
||||
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||
(*it)->SetSilentMode(i);
|
||||
|
||||
FILE_LOG(logINFO) << "Silent Mode: " << i;
|
||||
}
|
||||
|
||||
|
||||
int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
||||
FILE_LOG(logDEBUG) << "Setting receiver type";
|
||||
@ -375,22 +390,22 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
||||
Listener* l = new Listener(i, myDetectorType, fifo[i], &status,
|
||||
&udpPortNum[i], eth, &numberOfFrames, &dynamicRange,
|
||||
&udpSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile,
|
||||
&frameDiscardMode);
|
||||
&frameDiscardMode, &activated, &deactivatedPaddingEnable, &silentMode);
|
||||
listener.push_back(l);
|
||||
|
||||
DataProcessor* p = new DataProcessor(i, myDetectorType, fifo[i], &fileFormatType,
|
||||
fileWriteEnable, &dataStreamEnable, &gapPixelsEnable,
|
||||
&dynamicRange, &frameToGuiFrequency, &frameToGuiTimerinMS,
|
||||
&framePadding,
|
||||
&framePadding, &activated, &deactivatedPaddingEnable, &silentMode,
|
||||
rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady);
|
||||
dataProcessor.push_back(p);
|
||||
}
|
||||
catch (...) {
|
||||
FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")";
|
||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
delete(*it);
|
||||
listener.clear();
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
delete(*it);
|
||||
dataProcessor.clear();
|
||||
return FAIL;
|
||||
@ -398,9 +413,9 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
||||
}
|
||||
|
||||
//set up writer and callbacks
|
||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
(*it)->SetGeneralData(generalData);
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
(*it)->SetGeneralData(generalData);
|
||||
|
||||
SetThreadPriorities();
|
||||
@ -424,17 +439,24 @@ void UDPStandardImplementation::setDetectorPositionId(const int i){
|
||||
&detID, &numThreads, &numberOfFrames, &dynamicRange, &udpPortNum[i],
|
||||
generalData);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < listener.size(); ++i) {
|
||||
uint16_t row = 0, col = 0;
|
||||
row = detID % numDet[1]; // row
|
||||
col = (detID / numDet[1]) * ((myDetectorType == EIGER) ? 2 : 1) + i; // col for horiz. udp ports
|
||||
listener[i]->SetHardCodedPosition(row, col);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void UDPStandardImplementation::resetAcquisitionCount() {
|
||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
(*it)->ResetParametersforNewAcquisition();
|
||||
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
(*it)->ResetParametersforNewAcquisition();
|
||||
|
||||
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||
(*it)->ResetParametersforNewAcquisition();
|
||||
|
||||
FILE_LOG(logINFO) << "Acquisition Count has been reset";
|
||||
@ -445,7 +467,6 @@ void UDPStandardImplementation::resetAcquisitionCount() {
|
||||
int UDPStandardImplementation::startReceiver(char *c) {
|
||||
cprintf(RESET,"\n");
|
||||
FILE_LOG(logINFO) << "Starting Receiver";
|
||||
|
||||
ResetParametersforNewMeasurement();
|
||||
|
||||
//listener
|
||||
@ -499,10 +520,10 @@ void UDPStandardImplementation::stopReceiver(){
|
||||
bool running = true;
|
||||
while(running) {
|
||||
running = false;
|
||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
if ((*it)->IsRunning())
|
||||
running = true;
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
if ((*it)->IsRunning())
|
||||
running = true;
|
||||
usleep(5000);
|
||||
@ -513,8 +534,8 @@ void UDPStandardImplementation::stopReceiver(){
|
||||
if (fileWriteEnable && fileFormatType == HDF5) {
|
||||
uint64_t maxIndexCaught = 0;
|
||||
bool anycaught = false;
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
||||
maxIndexCaught = max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
|
||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
||||
maxIndexCaught = std::max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
|
||||
if((*it)->GetMeasurementStartedFlag())
|
||||
anycaught = true;
|
||||
}
|
||||
@ -526,7 +547,7 @@ void UDPStandardImplementation::stopReceiver(){
|
||||
running = true;
|
||||
while(running) {
|
||||
running = false;
|
||||
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||
if ((*it)->IsRunning())
|
||||
running = true;
|
||||
usleep(5000);
|
||||
@ -573,39 +594,37 @@ void UDPStandardImplementation::stopReceiver(){
|
||||
void UDPStandardImplementation::startReadout(){
|
||||
if(status == RUNNING){
|
||||
|
||||
//needs to wait for packets only if activated
|
||||
if(activated){
|
||||
// wait for incoming delayed packets
|
||||
//current packets caught
|
||||
volatile int totalP = 0,prev=-1;
|
||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
totalP += (*it)->GetPacketsCaught();
|
||||
|
||||
//current packets caught
|
||||
volatile int totalP = 0,prev=-1;
|
||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
totalP += (*it)->GetPacketsCaught();
|
||||
//wait for all packets
|
||||
if((unsigned long long int)totalP!=numberOfFrames*generalData->packetsPerFrame*listener.size()){
|
||||
|
||||
//wait for all packets
|
||||
if((unsigned long long int)totalP!=numberOfFrames*generalData->packetsPerFrame*listener.size()){
|
||||
|
||||
//wait as long as there is change from prev totalP,
|
||||
while(prev != totalP){
|
||||
//wait as long as there is change from prev totalP,
|
||||
while(prev != totalP){
|
||||
#ifdef VERY_VERBOSE
|
||||
cprintf(MAGENTA,"waiting for all packets prevP:%d totalP:%d\n",
|
||||
prev,totalP);
|
||||
cprintf(MAGENTA,"waiting for all packets prevP:%d totalP:%d\n",
|
||||
prev,totalP);
|
||||
|
||||
#endif
|
||||
//usleep(1*1000*1000);usleep(1*1000*1000);usleep(1*1000*1000);usleep(1*1000*1000);
|
||||
usleep(5*1000);/* Need to find optimal time **/
|
||||
//usleep(1*1000*1000);usleep(1*1000*1000);usleep(1*1000*1000);usleep(1*1000*1000);
|
||||
usleep(5*1000);/* Need to find optimal time **/
|
||||
|
||||
prev = totalP;
|
||||
totalP = 0;
|
||||
prev = totalP;
|
||||
totalP = 0;
|
||||
|
||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
totalP += (*it)->GetPacketsCaught();
|
||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
totalP += (*it)->GetPacketsCaught();
|
||||
#ifdef VERY_VERBOSE
|
||||
cprintf(MAGENTA,"\tupdated: totalP:%d\n",totalP);
|
||||
cprintf(MAGENTA,"\tupdated: totalP:%d\n",totalP);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//set status
|
||||
status = TRANSMITTING;
|
||||
FILE_LOG(logINFO) << "Status: Transmitting";
|
||||
@ -616,7 +635,7 @@ void UDPStandardImplementation::startReadout(){
|
||||
|
||||
|
||||
void UDPStandardImplementation::shutDownUDPSockets() {
|
||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
(*it)->ShutDownUDPSocket();
|
||||
}
|
||||
|
||||
@ -625,9 +644,9 @@ void UDPStandardImplementation::shutDownUDPSockets() {
|
||||
void UDPStandardImplementation::closeFiles() {
|
||||
uint64_t maxIndexCaught = 0;
|
||||
bool anycaught = false;
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
|
||||
(*it)->CloseFiles();
|
||||
maxIndexCaught = max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
|
||||
maxIndexCaught = std::max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
|
||||
if((*it)->GetMeasurementStartedFlag())
|
||||
anycaught = true;
|
||||
}
|
||||
@ -643,7 +662,7 @@ int UDPStandardImplementation::setUDPSocketBufferSize(const uint32_t s) {
|
||||
|
||||
int UDPStandardImplementation::restreamStop() {
|
||||
bool ret = OK;
|
||||
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) {
|
||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) {
|
||||
if ((*it)->RestreamStop() == FAIL)
|
||||
ret = FAIL;
|
||||
}
|
||||
@ -663,14 +682,14 @@ void UDPStandardImplementation::SetLocalNetworkParameters() {
|
||||
int max_back_log;
|
||||
const char *proc_file_name = "/proc/sys/net/core/netdev_max_backlog";
|
||||
{
|
||||
ifstream proc_file(proc_file_name);
|
||||
std::ifstream proc_file(proc_file_name);
|
||||
proc_file >> max_back_log;
|
||||
}
|
||||
|
||||
if (max_back_log < MAX_SOCKET_INPUT_PACKET_QUEUE) {
|
||||
ofstream proc_file(proc_file_name);
|
||||
std::ofstream proc_file(proc_file_name);
|
||||
if (proc_file.good()) {
|
||||
proc_file << MAX_SOCKET_INPUT_PACKET_QUEUE << endl;
|
||||
proc_file << MAX_SOCKET_INPUT_PACKET_QUEUE << std::endl;
|
||||
cprintf(GREEN, "Max length of input packet queue "
|
||||
"[/proc/sys/net/core/netdev_max_backlog] modified to %d\n",
|
||||
MAX_SOCKET_INPUT_PACKET_QUEUE);
|
||||
@ -686,13 +705,13 @@ void UDPStandardImplementation::SetLocalNetworkParameters() {
|
||||
|
||||
void UDPStandardImplementation::SetThreadPriorities() {
|
||||
|
||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it){
|
||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it){
|
||||
if ((*it)->SetThreadPriority(LISTENER_PRIORITY) == FAIL) {
|
||||
FILE_LOG(logWARNING) << "Could not prioritize listener threads. (No Root Privileges?)";
|
||||
return;
|
||||
}
|
||||
}
|
||||
ostringstream osfn;
|
||||
std::ostringstream osfn;
|
||||
osfn << "Priorities set - "
|
||||
"Listener:" << LISTENER_PRIORITY;
|
||||
|
||||
@ -704,10 +723,10 @@ int UDPStandardImplementation::SetupFifoStructure() {
|
||||
numberofJobs = 1;
|
||||
|
||||
|
||||
for (vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
|
||||
for (std::vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
|
||||
delete(*it);
|
||||
fifo.clear();
|
||||
for ( int i = 0; i < numThreads; i++ ) {
|
||||
for ( int i = 0; i < numThreads; ++i ) {
|
||||
|
||||
//create fifo structure
|
||||
try {
|
||||
@ -717,7 +736,7 @@ int UDPStandardImplementation::SetupFifoStructure() {
|
||||
fifo.push_back(f);
|
||||
} catch (...) {
|
||||
cprintf(RED,"Error: Could not allocate memory for fifo structure of index %d\n", i);
|
||||
for (vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
|
||||
for (std::vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
|
||||
delete(*it);
|
||||
fifo.clear();
|
||||
return FAIL;
|
||||
@ -736,15 +755,15 @@ int UDPStandardImplementation::SetupFifoStructure() {
|
||||
|
||||
|
||||
void UDPStandardImplementation::ResetParametersforNewMeasurement() {
|
||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
(*it)->ResetParametersforNewMeasurement();
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||
(*it)->ResetParametersforNewMeasurement();
|
||||
|
||||
if (dataStreamEnable) {
|
||||
char fnametostream[MAX_STR_LENGTH];
|
||||
snprintf(fnametostream, MAX_STR_LENGTH, "%s/%s", filePath, fileName);
|
||||
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||
(*it)->ResetParametersforNewMeasurement(fnametostream);
|
||||
}
|
||||
}
|
||||
@ -788,15 +807,15 @@ int UDPStandardImplementation::SetupWriter() {
|
||||
|
||||
void UDPStandardImplementation::StartRunning() {
|
||||
//set running mask and post semaphore to start the inner loop in execution thread
|
||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) {
|
||||
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) {
|
||||
(*it)->StartRunning();
|
||||
(*it)->Continue();
|
||||
}
|
||||
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
|
||||
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
|
||||
(*it)->StartRunning();
|
||||
(*it)->Continue();
|
||||
}
|
||||
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
|
||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
|
||||
(*it)->StartRunning();
|
||||
(*it)->Continue();
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include <sys/wait.h> //wait
|
||||
#include <unistd.h> //usleep
|
||||
#include <syscall.h>
|
||||
using namespace std;
|
||||
|
||||
|
||||
bool keeprunning;
|
||||
@ -44,18 +43,18 @@ void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){
|
||||
slsReceiverDefs::sls_receiver_header* header = (slsReceiverDefs::sls_receiver_header*)metadata;
|
||||
slsReceiverDefs::sls_detector_header detectorHeader = header->detHeader;
|
||||
|
||||
PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.xCoord,
|
||||
PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row,
|
||||
"#### %d GetData: ####\n"
|
||||
"frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu"
|
||||
"\t\ttimestamp: %llu\t\tmodId: %u\t\t"
|
||||
"xCoord: %u\t\tyCoord: %u\t\tzCoord: %u\t\tdebug: %u"
|
||||
"xCrow%u\t\tcolumn: %u\t\tcolumn: %u\t\tdebug: %u"
|
||||
"\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u"
|
||||
//"\t\tpacketsMask:%s"
|
||||
"\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n",
|
||||
detectorHeader.xCoord, detectorHeader.frameNumber,
|
||||
detectorHeader.row, detectorHeader.frameNumber,
|
||||
detectorHeader.expLength, detectorHeader.packetNumber, detectorHeader.bunchId,
|
||||
detectorHeader.timestamp, detectorHeader.modId,
|
||||
detectorHeader.xCoord, detectorHeader.yCoord, detectorHeader.zCoord,
|
||||
detectorHeader.row, detectorHeader.column, detectorHeader.column,
|
||||
detectorHeader.debug, detectorHeader.roundRNumber,
|
||||
detectorHeader.detType, detectorHeader.version,
|
||||
//header->packetsMask.to_string().c_str(),
|
||||
|
@ -14,20 +14,16 @@
|
||||
#include "slsReceiver.h"
|
||||
#include "gitInfoReceiver.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
slsReceiver::slsReceiver(int argc, char *argv[], int &success):
|
||||
tcpipInterface (NULL),
|
||||
udp_interface (NULL)
|
||||
{
|
||||
success=OK;
|
||||
slsReceiver::slsReceiver(int argc, char *argv[]):
|
||||
tcpipInterface (0) {
|
||||
|
||||
// options
|
||||
map<string, string> configuration_map;
|
||||
std::map<std::string, std::string> configuration_map;
|
||||
int tcpip_port_no = 1954;
|
||||
string fname = "";
|
||||
std::string fname = "";
|
||||
int64_t tempval = 0;
|
||||
|
||||
//parse command line for config
|
||||
@ -71,42 +67,33 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success):
|
||||
case 'v':
|
||||
tempval = GITREV;
|
||||
tempval = (tempval <<32) | GITDATE;
|
||||
cout << "SLS Receiver " << GITBRANCH << " (0x" << hex << tempval << ")" << endl;
|
||||
success = FAIL; // to exit
|
||||
break;
|
||||
std::cout << "SLS Receiver " << GITBRANCH << " (0x" << std::hex << tempval << ")" << std::endl;
|
||||
throw std::exception();
|
||||
|
||||
case 'h':
|
||||
default:
|
||||
string help_message = "\n"
|
||||
+ string(argv[0]) + "\n"
|
||||
+ "Usage: " + string(argv[0]) + " [arguments]\n"
|
||||
std::string help_message = "\n"
|
||||
+ std::string(argv[0]) + "\n"
|
||||
+ "Usage: " + std::string(argv[0]) + " [arguments]\n"
|
||||
+ "Possible arguments are:\n"
|
||||
+ "\t-f, --config <fname> : Loads config from file\n"
|
||||
+ "\t-t, --rx_tcpport <port> : TCP Communication Port with client. \n"
|
||||
+ "\t Default: 1954. Required for multiple \n"
|
||||
+ "\t receivers\n\n";
|
||||
|
||||
FILE_LOG(logINFO) << help_message << endl;
|
||||
break;
|
||||
FILE_LOG(logINFO) << help_message << std::endl;
|
||||
throw std::exception();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if( !fname.empty() ){
|
||||
try{
|
||||
FILE_LOG(logINFO) << "config file name " << fname;
|
||||
success = read_config_file(fname, &tcpip_port_no, &configuration_map);
|
||||
//VERBOSE_PRINT("Read configuration file of " + iline + " lines");
|
||||
}
|
||||
catch(...){
|
||||
FILE_LOG(logERROR) << "Coult not open configuration file " << fname ;
|
||||
success = FAIL;
|
||||
}
|
||||
if( !fname.empty() && read_config_file(fname, &tcpip_port_no, &configuration_map) == FAIL) {
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
if (success==OK){
|
||||
tcpipInterface = new slsReceiverTCPIPInterface(success, udp_interface, tcpip_port_no);
|
||||
}
|
||||
// might throw an exception
|
||||
tcpipInterface = new slsReceiverTCPIPInterface(tcpip_port_no);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -131,40 +118,26 @@ int64_t slsReceiver::getReceiverVersion(){
|
||||
}
|
||||
|
||||
|
||||
void slsReceiver::registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg){
|
||||
//tcpipInterface
|
||||
if(udp_interface)
|
||||
udp_interface->registerCallBackStartAcquisition(func,arg);
|
||||
else
|
||||
tcpipInterface->registerCallBackStartAcquisition(func,arg);
|
||||
void slsReceiver::registerCallBackStartAcquisition(int (*func)(
|
||||
char*, char*, uint64_t, uint32_t, void*),void *arg){
|
||||
tcpipInterface->registerCallBackStartAcquisition(func,arg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void slsReceiver::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){
|
||||
//tcpipInterface
|
||||
if(udp_interface)
|
||||
udp_interface->registerCallBackAcquisitionFinished(func,arg);
|
||||
else
|
||||
tcpipInterface->registerCallBackAcquisitionFinished(func,arg);
|
||||
void slsReceiver::registerCallBackAcquisitionFinished(
|
||||
void (*func)(uint64_t, void*),void *arg){
|
||||
tcpipInterface->registerCallBackAcquisitionFinished(func,arg);
|
||||
}
|
||||
|
||||
|
||||
void slsReceiver::registerCallBackRawDataReady(void (*func)(char*,
|
||||
char*, uint32_t, void*),void *arg){
|
||||
//tcpipInterface
|
||||
if(udp_interface)
|
||||
udp_interface->registerCallBackRawDataReady(func,arg);
|
||||
else
|
||||
tcpipInterface->registerCallBackRawDataReady(func,arg);
|
||||
tcpipInterface->registerCallBackRawDataReady(func,arg);
|
||||
}
|
||||
|
||||
|
||||
void slsReceiver::registerCallBackRawDataModifyReady(void (*func)(char*,
|
||||
char*, uint32_t &, void*),void *arg){
|
||||
//tcpipInterface
|
||||
if(udp_interface)
|
||||
udp_interface->registerCallBackRawDataModifyReady(func,arg);
|
||||
else
|
||||
tcpipInterface->registerCallBackRawDataModifyReady(func,arg);
|
||||
tcpipInterface->registerCallBackRawDataModifyReady(func,arg);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include <fstream>
|
||||
#include <stdlib.h>
|
||||
#include <syscall.h>
|
||||
using namespace std;
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
||||
@ -31,16 +31,16 @@ slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
|
||||
delete receiverBase;
|
||||
}
|
||||
|
||||
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface* rbase, int pn):
|
||||
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int pn):
|
||||
myDetectorType(GOTTHARD),
|
||||
receiverBase(rbase),
|
||||
receiverBase(0),
|
||||
ret(OK),
|
||||
fnum(-1),
|
||||
lockStatus(0),
|
||||
killTCPServerThread(0),
|
||||
tcpThreadCreated(false),
|
||||
portNumber(DEFAULT_PORTNO+2),
|
||||
mySock(NULL)
|
||||
mySock(0)
|
||||
{
|
||||
//***callback parameters***
|
||||
startAcquisitionCallBack = NULL;
|
||||
@ -51,83 +51,25 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface*
|
||||
rawDataModifyReadyCallBack = NULL;
|
||||
pRawDataReady = NULL;
|
||||
|
||||
unsigned short int port_no=portNumber;
|
||||
if(receiverBase == NULL)
|
||||
receiverBase = 0;
|
||||
// create socket
|
||||
portNumber = (pn > 0 ? pn : DEFAULT_PORTNO + 2);
|
||||
MySocketTCP* m = new MySocketTCP(portNumber);
|
||||
mySock = m;
|
||||
|
||||
if (pn>0)
|
||||
port_no = pn;
|
||||
//initialize variables
|
||||
strcpy(mySock->lastClientIP,"none");
|
||||
strcpy(mySock->thisClientIP,"none1");
|
||||
memset(mess,0,sizeof(mess));
|
||||
strcpy(mess,"dummy message");
|
||||
|
||||
success=OK;
|
||||
|
||||
//create socket
|
||||
if(success == OK){
|
||||
mySock = new MySocketTCP(port_no);
|
||||
if (mySock->getErrorStatus()) {
|
||||
success = FAIL;
|
||||
delete mySock;
|
||||
mySock=NULL;
|
||||
} else {
|
||||
portNumber=port_no;
|
||||
//initialize variables
|
||||
strcpy(mySock->lastClientIP,"none");
|
||||
strcpy(mySock->thisClientIP,"none1");
|
||||
memset(mess,0,sizeof(mess));
|
||||
strcpy(mess,"dummy message");
|
||||
function_table();
|
||||
function_table();
|
||||
#ifdef VERYVERBOSE
|
||||
FILE_LOG(logINFO) << "Function table assigned.";
|
||||
FILE_LOG(logINFO) << "Function table assigned.";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::setPortNumber(int pn){
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int p_number;
|
||||
|
||||
MySocketTCP *oldsocket = NULL;;
|
||||
int sd = 0;
|
||||
|
||||
if (pn > 0) {
|
||||
p_number = pn;
|
||||
|
||||
if (p_number < 1024) {
|
||||
sprintf(mess,"Too low port number %d\n", p_number);
|
||||
FILE_LOG(logERROR) << mess;
|
||||
} else {
|
||||
|
||||
oldsocket=mySock;
|
||||
mySock = new MySocketTCP(p_number);
|
||||
if(mySock){
|
||||
sd = mySock->getErrorStatus();
|
||||
if (!sd){
|
||||
portNumber=p_number;
|
||||
strcpy(mySock->lastClientIP,oldsocket->lastClientIP);
|
||||
delete oldsocket;
|
||||
} else {
|
||||
FILE_LOG(logERROR) << "Could not bind port " << p_number;
|
||||
if (sd == -10) {
|
||||
FILE_LOG(logINFO) << "Port "<< p_number << " already set";
|
||||
} else {
|
||||
delete mySock;
|
||||
mySock=oldsocket;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
mySock=oldsocket;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return portNumber;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::start(){
|
||||
FILE_LOG(logDEBUG) << "Creating TCP Server Thread";
|
||||
killTCPServerThread = 0;
|
||||
@ -198,7 +140,7 @@ void* slsReceiverTCPIPInterface::startTCPServerThread(void *this_pointer){
|
||||
|
||||
void slsReceiverTCPIPInterface::startTCPServer(){
|
||||
cprintf(BLUE,"Created [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid));
|
||||
FILE_LOG(logINFO) << "SLS Receiver starting TCP Server on port " << portNumber << endl;
|
||||
FILE_LOG(logINFO) << "SLS Receiver starting TCP Server on port " << portNumber << std::endl;
|
||||
|
||||
#ifdef VERYVERBOSE
|
||||
FILE_LOG(logDEBUG5) << "Starting Receiver TCP Server";
|
||||
@ -265,7 +207,7 @@ const char* slsReceiverTCPIPInterface::getFunctionName(enum recFuncs func) {
|
||||
case F_GET_RECEIVER_ID: return "F_GET_RECEIVER_ID";
|
||||
case F_GET_RECEIVER_TYPE: return "F_GET_RECEIVER_TYPE";
|
||||
case F_SEND_RECEIVER_DETHOSTNAME: return "F_SEND_RECEIVER_DETHOSTNAME";
|
||||
case F_RECEIVER_SHORT_FRAME: return "F_RECEIVER_SHORT_FRAME";
|
||||
case F_RECEIVER_SET_ROI: return "F_RECEIVER_SET_ROI";
|
||||
case F_SETUP_RECEIVER_UDP: return "F_SETUP_RECEIVER_UDP";
|
||||
case F_SET_RECEIVER_TIMER: return "F_SET_RECEIVER_TIMER";
|
||||
case F_SET_RECEIVER_DYNAMIC_RANGE: return "F_SET_RECEIVER_DYNAMIC_RANGE";
|
||||
@ -304,6 +246,7 @@ const char* slsReceiverTCPIPInterface::getFunctionName(enum recFuncs func) {
|
||||
case F_RECEIVER_CHECK_VERSION: return "F_RECEIVER_CHECK_VERSION";
|
||||
case F_RECEIVER_DISCARD_POLICY: return "F_RECEIVER_DISCARD_POLICY";
|
||||
case F_RECEIVER_PADDING_ENABLE: return "F_RECEIVER_PADDING_ENABLE";
|
||||
case F_RECEIVER_DEACTIVATED_PADDING_ENABLE: return "F_RECEIVER_DEACTIVATED_PADDING_ENABLE";
|
||||
|
||||
default: return "Unknown Function";
|
||||
}
|
||||
@ -321,7 +264,7 @@ int slsReceiverTCPIPInterface::function_table(){
|
||||
flist[F_GET_RECEIVER_ID] = &slsReceiverTCPIPInterface::get_id;
|
||||
flist[F_GET_RECEIVER_TYPE] = &slsReceiverTCPIPInterface::set_detector_type;
|
||||
flist[F_SEND_RECEIVER_DETHOSTNAME] = &slsReceiverTCPIPInterface::set_detector_hostname;
|
||||
flist[F_RECEIVER_SHORT_FRAME] = &slsReceiverTCPIPInterface::set_short_frame;
|
||||
flist[F_RECEIVER_SET_ROI] = &slsReceiverTCPIPInterface::set_roi;
|
||||
flist[F_SETUP_RECEIVER_UDP] = &slsReceiverTCPIPInterface::setup_udp;
|
||||
flist[F_SET_RECEIVER_TIMER] = &slsReceiverTCPIPInterface::set_timer;
|
||||
flist[F_SET_RECEIVER_DYNAMIC_RANGE] = &slsReceiverTCPIPInterface::set_dynamic_range;
|
||||
@ -360,6 +303,8 @@ int slsReceiverTCPIPInterface::function_table(){
|
||||
flist[F_RECEIVER_CHECK_VERSION] = &slsReceiverTCPIPInterface::check_version_compatibility;
|
||||
flist[F_RECEIVER_DISCARD_POLICY] = &slsReceiverTCPIPInterface::set_discard_policy;
|
||||
flist[F_RECEIVER_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_padding_enable;
|
||||
flist[F_RECEIVER_DEACTIVATED_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable;
|
||||
|
||||
|
||||
#ifdef VERYVERBOSE
|
||||
for (int i = 0; i < NUM_REC_FUNCTIONS ; i++) {
|
||||
@ -567,15 +512,14 @@ int slsReceiverTCPIPInterface::get_last_client_ip() {
|
||||
int slsReceiverTCPIPInterface::set_port() {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int unused = 0;
|
||||
int p_type = 0;
|
||||
int p_number = -1;
|
||||
MySocketTCP* mySocket = NULL;
|
||||
MySocketTCP* mySocket = 0;
|
||||
char oldLastClientIP[INET_ADDRSTRLEN];
|
||||
memset(oldLastClientIP, 0, sizeof(oldLastClientIP));
|
||||
int sd = -1;
|
||||
|
||||
// receive arguments
|
||||
if (mySock->ReceiveDataOnly(&unused,sizeof(unused)) < 0 )
|
||||
if (mySock->ReceiveDataOnly(&p_type,sizeof(p_type)) < 0 )
|
||||
return printSocketReadError();
|
||||
if (mySock->ReceiveDataOnly(&p_number,sizeof(p_number)) < 0 )
|
||||
return printSocketReadError();
|
||||
@ -587,29 +531,26 @@ int slsReceiverTCPIPInterface::set_port() {
|
||||
FILE_LOG(logERROR) << mess;
|
||||
}
|
||||
else {
|
||||
if (p_number<1024) {
|
||||
if (p_number < 1024) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Port Number (%d) too low\n", p_number);
|
||||
FILE_LOG(logERROR) << mess;
|
||||
}
|
||||
FILE_LOG(logINFO) << "set port to " << p_number <<endl;
|
||||
strcpy(oldLastClientIP, mySock->lastClientIP);
|
||||
mySocket = new MySocketTCP(p_number);
|
||||
} else {
|
||||
FILE_LOG(logINFO) << "set port to " << p_number <<std::endl;
|
||||
strcpy(oldLastClientIP, mySock->lastClientIP);
|
||||
|
||||
if(mySocket){
|
||||
sd = mySocket->getErrorStatus();
|
||||
if (sd < 0) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Could not bind port %d\n", p_number);
|
||||
FILE_LOG(logERROR) << mess;
|
||||
if (sd == -10) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Port %d already set\n", p_number);
|
||||
FILE_LOG(logERROR) << mess;
|
||||
}
|
||||
}
|
||||
else
|
||||
try {
|
||||
mySocket = new MySocketTCP(p_number);
|
||||
strcpy(mySock->lastClientIP,oldLastClientIP);
|
||||
} catch(SamePortSocketException e) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not bind port %d. It is already set\n", p_number);
|
||||
FILE_LOG(logERROR) << mess;
|
||||
} catch (...) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not bind port %d.\n", p_number);
|
||||
FILE_LOG(logERROR) << mess;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -622,7 +563,7 @@ int slsReceiverTCPIPInterface::set_port() {
|
||||
mySock->SendDataOnly(mess,sizeof(mess));
|
||||
else {
|
||||
mySock->SendDataOnly(&p_number,sizeof(p_number));
|
||||
if(sd>=0){
|
||||
if(ret != FAIL){
|
||||
mySock->Disconnect();
|
||||
delete mySock;
|
||||
mySock = mySocket;
|
||||
@ -769,6 +710,24 @@ int slsReceiverTCPIPInterface::send_update() {
|
||||
#endif
|
||||
n += mySock->SendDataOnly(&ind,sizeof(ind));
|
||||
|
||||
// activate
|
||||
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
||||
ind=(int)receiverBase->getActivate();
|
||||
#endif
|
||||
n += mySock->SendDataOnly(&ind,sizeof(ind));
|
||||
|
||||
// deactivated padding enable
|
||||
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
||||
ind=(int)receiverBase->getDeactivatedPadding();
|
||||
#endif
|
||||
n += mySock->SendDataOnly(&ind,sizeof(ind));
|
||||
|
||||
// silent mode
|
||||
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
||||
ind=(int)receiverBase->getSilentMode();
|
||||
#endif
|
||||
n += mySock->SendDataOnly(&ind,sizeof(ind));
|
||||
|
||||
if (!lockStatus)
|
||||
strcpy(mySock->lastClientIP,mySock->thisClientIP);
|
||||
|
||||
@ -921,16 +880,24 @@ int slsReceiverTCPIPInterface::set_detector_hostname() {
|
||||
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::set_short_frame() {
|
||||
int slsReceiverTCPIPInterface::set_roi() {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int index = 0;
|
||||
int retval = -100;
|
||||
int nroi = 0;
|
||||
|
||||
// receive arguments
|
||||
if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 )
|
||||
if (mySock->ReceiveDataOnly(&nroi,sizeof(nroi)) < 0 )
|
||||
return printSocketReadError();
|
||||
|
||||
std::vector <ROI> roiLimits;
|
||||
int iloop = 0;
|
||||
for (iloop = 0; iloop < nroi; iloop++) {
|
||||
ROI temp;
|
||||
if ( mySock->ReceiveDataOnly(&temp,sizeof(ROI)) < 0 )
|
||||
return printSocketReadError();
|
||||
roiLimits.push_back(temp);
|
||||
}
|
||||
|
||||
//does not exist
|
||||
if (myDetectorType != GOTTHARD)
|
||||
functionNotImplemented();
|
||||
@ -946,8 +913,8 @@ int slsReceiverTCPIPInterface::set_short_frame() {
|
||||
else if (receiverBase->getStatus() != IDLE)
|
||||
receiverNotIdle();
|
||||
else {
|
||||
receiverBase->setShortFrameEnable(index);
|
||||
retval = receiverBase->getShortFrameEnable();
|
||||
ret = receiverBase->setROI(roiLimits);
|
||||
//retval = receiverBase->getROI();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -958,7 +925,8 @@ int slsReceiverTCPIPInterface::set_short_frame() {
|
||||
mySock->SendDataOnly(&ret,sizeof(ret));
|
||||
if (ret == FAIL)
|
||||
mySock->SendDataOnly(mess,sizeof(mess));
|
||||
mySock->SendDataOnly(&retval,sizeof(retval));
|
||||
|
||||
roiLimits.clear();
|
||||
|
||||
// return ok/fail
|
||||
return ret;
|
||||
@ -999,7 +967,7 @@ int slsReceiverTCPIPInterface::setup_udp(){
|
||||
//setup udpip
|
||||
//get ethernet interface or IP to listen to
|
||||
FILE_LOG(logINFO) << "Receiver UDP IP: " << args[0];
|
||||
string temp = genericSocket::ipToName(args[0]);
|
||||
std::string temp = genericSocket::ipToName(args[0]);
|
||||
if (temp == "none"){
|
||||
ret = FAIL;
|
||||
strcpy(mess, "Failed to get ethernet interface or IP\n");
|
||||
@ -1086,8 +1054,8 @@ int slsReceiverTCPIPInterface::set_timer() {
|
||||
case SUBFRAME_ACQUISITION_TIME:
|
||||
receiverBase->setSubExpTime(index[1]);
|
||||
break;
|
||||
case SUBFRAME_PERIOD:
|
||||
receiverBase->setSubPeriod(index[1]);
|
||||
case SUBFRAME_DEADTIME:
|
||||
receiverBase->setSubPeriod(index[1] + receiverBase->getSubExpTime());
|
||||
break;
|
||||
case SAMPLES_JCTB:
|
||||
if (myDetectorType != JUNGFRAUCTB) {
|
||||
@ -1121,8 +1089,8 @@ int slsReceiverTCPIPInterface::set_timer() {
|
||||
case SUBFRAME_ACQUISITION_TIME:
|
||||
retval=receiverBase->getSubExpTime();
|
||||
break;
|
||||
case SUBFRAME_PERIOD:
|
||||
retval=receiverBase->getSubPeriod();
|
||||
case SUBFRAME_DEADTIME:
|
||||
retval=(receiverBase->getSubPeriod() - receiverBase->getSubExpTime());
|
||||
break;
|
||||
case SAMPLES_JCTB:
|
||||
if (myDetectorType != JUNGFRAUCTB) {
|
||||
@ -1994,11 +1962,11 @@ int slsReceiverTCPIPInterface::set_activate() {
|
||||
else if (receiverBase->getStatus() != IDLE)
|
||||
receiverNotIdle();
|
||||
else {
|
||||
receiverBase->setActivate(enable);
|
||||
receiverBase->setActivate(enable > 0 ? true : false);
|
||||
}
|
||||
}
|
||||
//get
|
||||
retval = receiverBase->getActivate();
|
||||
retval = (int)receiverBase->getActivate();
|
||||
if(enable >= 0 && retval != enable){
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Could not set activate to %d, returned %d\n",enable,retval);
|
||||
@ -2484,7 +2452,7 @@ int slsReceiverTCPIPInterface::set_silent_mode() {
|
||||
}
|
||||
}
|
||||
//get
|
||||
retval = receiverBase->getSilentMode(); // no check required
|
||||
retval = (int)receiverBase->getSilentMode(); // no check required
|
||||
}
|
||||
#endif
|
||||
#ifdef VERYVERBOSE
|
||||
@ -2548,7 +2516,7 @@ int slsReceiverTCPIPInterface::enable_gap_pixels() {
|
||||
}
|
||||
#endif
|
||||
#ifdef VERYVERBOSE
|
||||
FILE_LOG(logDEBUG1) << "Activate: " << retval;
|
||||
FILE_LOG(logDEBUG1) << "Gap Pixels Enable: " << retval;
|
||||
#endif
|
||||
|
||||
if (ret == OK && mySock->differentClients)
|
||||
@ -2959,3 +2927,59 @@ int slsReceiverTCPIPInterface::set_padding_enable() {
|
||||
|
||||
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable() {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int enable = -1;
|
||||
int retval = -1;
|
||||
|
||||
// receive arguments
|
||||
if (mySock->ReceiveDataOnly(&enable,sizeof(enable)) < 0 )
|
||||
return printSocketReadError();
|
||||
|
||||
if (myDetectorType != EIGER)
|
||||
functionNotImplemented();
|
||||
|
||||
// execute action
|
||||
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
||||
else {
|
||||
if (receiverBase == NULL)
|
||||
invalidReceiverObject();
|
||||
else {
|
||||
// set
|
||||
if(enable >= 0) {
|
||||
if (mySock->differentClients && lockStatus)
|
||||
receiverlocked();
|
||||
else if (receiverBase->getStatus() != IDLE)
|
||||
receiverNotIdle();
|
||||
else {
|
||||
receiverBase->setDeactivatedPadding(enable > 0 ? true : false);
|
||||
}
|
||||
}
|
||||
//get
|
||||
retval = (int)receiverBase->getDeactivatedPadding();
|
||||
if(enable >= 0 && retval != enable){
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Could not set deactivated padding enable to %d, returned %d\n",enable,retval);
|
||||
FILE_LOG(logERROR) << mess;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef VERYVERBOSE
|
||||
FILE_LOG(logDEBUG1) << "Deactivated Padding Enable: " << retval;
|
||||
#endif
|
||||
|
||||
if (ret == OK && mySock->differentClients)
|
||||
ret = FORCE_UPDATE;
|
||||
|
||||
// send answer
|
||||
mySock->SendDataOnly(&ret,sizeof(ret));
|
||||
if (ret == FAIL)
|
||||
mySock->SendDataOnly(mess,sizeof(mess));
|
||||
mySock->SendDataOnly(&retval,sizeof(retval));
|
||||
|
||||
// return ok/fail
|
||||
return ret;
|
||||
}
|
||||
|
@ -2,11 +2,18 @@
|
||||
#include "slsReceiver.h"
|
||||
|
||||
slsReceiverUsers::slsReceiverUsers(int argc, char *argv[], int &success) {
|
||||
receiver=new slsReceiver(argc, argv, success);
|
||||
// catch the exception here to limit it to within the library (for current version)
|
||||
try {
|
||||
slsReceiver* r = new slsReceiver(argc, argv);
|
||||
receiver = r;
|
||||
success = slsReceiverDefs::OK;
|
||||
} catch (...) {
|
||||
success = slsReceiverDefs::FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
slsReceiverUsers::~slsReceiverUsers() {
|
||||
delete receiver;
|
||||
delete receiver;
|
||||
}
|
||||
|
||||
int slsReceiverUsers::start() {
|
||||
@ -28,13 +35,13 @@ void slsReceiverUsers::registerCallBackStartAcquisition(int (*func)(char*, char*
|
||||
void slsReceiverUsers::registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg){
|
||||
receiver->registerCallBackAcquisitionFinished(func,arg);
|
||||
}
|
||||
|
||||
|
||||
void slsReceiverUsers::registerCallBackRawDataReady(void (*func)(char* header,
|
||||
char* datapointer, uint32_t datasize, void*), void *arg){
|
||||
receiver->registerCallBackRawDataReady(func,arg);
|
||||
}
|
||||
|
||||
void slsReceiverUsers::registerCallBackRawDataModifyReady(void (*func)(char* header,
|
||||
char* datapointer, uint32_t& revDatasize, void*), void *arg){
|
||||
receiver->registerCallBackRawDataModifyReady(func,arg);
|
||||
char* datapointer, uint32_t& revDatasize, void*), void *arg){
|
||||
receiver->registerCallBackRawDataModifyReady(func,arg);
|
||||
}
|
||||
|
@ -8,36 +8,42 @@
|
||||
#include <map>
|
||||
|
||||
#include "utilities.h"
|
||||
#include "logger.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
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 ){
|
||||
|
||||
ifstream infile;
|
||||
string sLine,sargname, sargvalue;
|
||||
std::ifstream infile;
|
||||
std::string sLine,sargname, sargvalue;
|
||||
int iline = 0;
|
||||
int success = slsReceiverDefs::OK;
|
||||
|
||||
|
||||
FILE_LOG(logINFO) << "config file name " << fname;
|
||||
try {
|
||||
infile.open(fname.c_str(), std::ios_base::in);
|
||||
} catch(...) {
|
||||
FILE_LOG(logERROR) << "Could not open configuration file " << fname ;
|
||||
success = slsReceiverDefs::FAIL;
|
||||
}
|
||||
|
||||
infile.open(fname.c_str(), ios_base::in);
|
||||
if (infile.is_open()) {
|
||||
if (success == slsReceiverDefs::OK && infile.is_open()) {
|
||||
while(infile.good()){
|
||||
getline(infile,sLine);
|
||||
iline++;
|
||||
|
||||
//VERBOSE_PRINT(sLine);
|
||||
|
||||
if(sLine.find('#') != string::npos)
|
||||
if(sLine.find('#') != std::string::npos)
|
||||
continue;
|
||||
|
||||
else if(sLine.length()<2)
|
||||
continue;
|
||||
|
||||
else{
|
||||
istringstream sstr(sLine);
|
||||
std::istringstream sstr(sLine);
|
||||
|
||||
//parameter name
|
||||
if(sstr.good()){
|
||||
|
Reference in New Issue
Block a user