quad implemented

This commit is contained in:
2019-07-10 17:39:43 +02:00
parent 3e2b471ee1
commit 1189b991e5
32 changed files with 558 additions and 76 deletions

View File

@ -30,9 +30,11 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
* @param fd flipped data enable for x and y dimensions
* @param ajh additional json header
* @param sm pointer to silent mode
* @param nd pointer to number of detectors in each dimension
* @param gpEnable pointer to gap pixels enable
*/
DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI>* r,
uint64_t* fi, int* fd, char* ajh, bool* sm);
uint64_t* fi, int* fd, char* ajh, bool* sm, int* nd, bool* gpEnable);
/**
* Destructor
@ -88,6 +90,18 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
*/
int SetThreadPriority(int priority);
/**
* Set number of detectors
* @param number of detectors in both dimensions
*/
void SetNumberofDetectors(int* nd);
/**
* Set Flipped data enable across both dimensions
* @param flipped data enable in both dimensions
*/
void SetFlippedData(int* fd);
/**
* Creates Zmq Sockets
* (throws an exception if it couldnt create zmq sockets)
@ -184,7 +198,7 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
uint64_t* fileIndex;
/** flipped data across both dimensions enable */
int* flippedData;
int flippedData[2];
/** additional json header */
char* additionJsonHeader;
@ -207,5 +221,11 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
/** Complete buffer used for roi, eg. shortGotthard */
char* completeBuffer;
/** Number of Detectors in X and Y dimension */
int numDet[2];
/** Gap Pixels Enable */
bool* gapPixelsEnable;
};

View File

@ -72,6 +72,12 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
*/
bool getGapPixelsEnable() const;
/**
* Get Quad type Enable (eiger and hardware specific)
* @return true if quad enabled, else false
*/
bool getQuad() const;
//***file parameters***
/**
@ -341,7 +347,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
void setMultiDetectorSize(const int* size);
/*
* Get flipped data across 'axis'
* Set flipped data across 'axis'
* @return if data is flipped across 'axis'
*/
void setFlippedData(int axis=0, int enable=-1);
@ -353,6 +359,12 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
*/
int setGapPixelsEnable(const bool b);
/**
* Set Quad type Enable (eiger and hardware specific)
* @param true if quad enabled, else false
*/
void setQuad(const bool b);
//***file parameters***
/**
@ -739,6 +751,8 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
int flippedData[2];
/** gap pixels enable */
bool gapPixelsEnable;
/** quad type enable */
bool quadEnable;
//***receiver parameters***
/** Maximum Number of Listening Threads/ UDP Ports */

View File

@ -162,6 +162,12 @@ class UDPInterface {
*/
virtual bool getGapPixelsEnable() const = 0;
/**
* Get Quad type Enable (eiger and hardware specific)
* @return true if quad enabled, else false
*/
virtual bool getQuad() const = 0;
//***file parameters***
/**
@ -444,6 +450,12 @@ class UDPInterface {
*/
virtual int setGapPixelsEnable(const bool b) = 0;
/**
* Set Quad type Enable (eiger and hardware specific)
* @param true if quad enabled, else false
*/
virtual void setQuad(const bool b) = 0;
//***file parameters***
/**

View File

@ -53,6 +53,18 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
*/
int64_t getAcquisitionIndex() const;
/*
* Set multi detector size
* @param pointer to array of multi detector size in every dimension
*/
void setMultiDetectorSize(const int* size);
/*
* Set flipped data across 'axis'
* @return if data is flipped across 'axis'
*/
void setFlippedData(int axis=0, int enable=-1);
/**
* Set Gap Pixels Enable (eiger specific)
* @param b true for gap pixels enable, else false
@ -60,6 +72,12 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
*/
int setGapPixelsEnable(const bool b);
/**
* Set Quad type Enable (eiger and hardware specific)
* @param true if quad enabled, else false
*/
void setQuad(const bool b);
/**
* Set File Format
* @param f fileformat binary or hdf5

View File

@ -238,19 +238,42 @@ public:
/**
* Send Message Header
* @param buf message
* @param length length of message
* @param dummy true if end of acquistion else false
* @param index self index for debugging
* @param dummy true if a dummy message for end of acquisition
* @param jsonversion json version
* @param dynamicrange dynamic range
* @param fileIndex file or acquisition index
* @param ndetx number of detectors in x axis
* @param ndety number of detectors in y axis
* @param npixelsx number of pixels/channels in x axis for this zmq socket
* @param npixelsy number of pixels/channels in y axis for this zmq socket
* @param imageSize number of bytes for an image in this socket
* @param frameNumber current frame number
* @param expLength exposure length or subframe index if eiger
* @param packetNumber number of packets caught for this frame
* @param bunchId bunch id
* @param timestamp time stamp
* @param modId module Id
* @param row row index in complete detector
* @param column column index in complete detector
* @param reserved reserved
* @param debug debug
* @param roundRNumber not used yet
* @param detType detector enum
* @param version detector header version
* @param gapPixelsEnable gap pixels enable (exception: if gap pixels enable for 4 bit mode, data is not yet gap pixel enabled in receiver)
* @param flippedData int array of 2 elements for x and y, if it is flipped across x or y axis
* @param additionalJsonHeader additional json header
* @returns 0 if error, else 1
*/
int SendHeaderData ( int index, bool dummy, uint32_t jsonversion, uint32_t dynamicrange = 0, uint64_t fileIndex = 0,
uint32_t npixelsx = 0, uint32_t npixelsy = 0, uint32_t imageSize = 0,
uint32_t ndetx = 0, uint32_t ndety = 0, uint32_t npixelsx = 0, uint32_t npixelsy = 0, uint32_t imageSize = 0,
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 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,
uint8_t detType = 0, uint8_t version = 0, int gapPixelsEnable = 0, int* flippedData = 0,
char* additionalJsonHeader = 0) {
@ -261,6 +284,7 @@ public:
"\"jsonversion\":%u, "
"\"bitmode\":%u, "
"\"fileIndex\":%llu, "
"\"detshape\":[%u, %u], "
"\"shape\":[%u, %u], "
"\"size\":%u, "
"\"acqIndex\":%llu, "
@ -283,11 +307,12 @@ public:
"\"version\":%u, "
//additional stuff
"\"gappixels\":%u, "
"\"flippedDataX\":%u"
;//"}\n";
int length = sprintf(buf, jsonHeaderFormat,
jsonversion, dynamicrange, fileIndex, npixelsx, npixelsy, imageSize,
jsonversion, dynamicrange, fileIndex, ndetx, ndety, npixelsx, npixelsy, imageSize,
acqIndex, fIndex, (fname == NULL)? "":fname, dummy?0:1,
frameNumber, expLength, packetNumber, bunchId, timestamp,
@ -295,6 +320,7 @@ public:
detType, version,
//additional stuff
gapPixelsEnable,
((flippedData == 0 ) ? 0 :flippedData[0])
);
if (additionalJsonHeader && strlen(additionalJsonHeader)) {

View File

@ -284,6 +284,9 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
/** set deactivated receiver padding enable */
int set_deactivated_receiver_padding_enable();
/** set quad type */
int set_quad_type();
/** detector type */
detectorType myDetectorType;

View File

@ -71,6 +71,7 @@ enum recFuncs{
F_RECEIVER_DISCARD_POLICY, /** < frames discard policy */
F_RECEIVER_PADDING_ENABLE, /** < partial frames padding enable */
F_RECEIVER_DEACTIVATED_PADDING_ENABLE, /** < deactivated receiver padding enable */
F_RECEIVER_QUAD,
/* Always append functions hereafter!!! */

View File

@ -16,7 +16,7 @@ const std::string DataStreamer::TypeName = "DataStreamer";
DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI>* r,
uint64_t* fi, int* fd, char* ajh, bool* sm) :
uint64_t* fi, int* fd, char* ajh, bool* sm, int* nd, bool* gpEnable) :
ThreadObject(ind),
runningFlag(0),
generalData(0),
@ -26,14 +26,19 @@ DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI>* r,
roi(r),
adcConfigured(-1),
fileIndex(fi),
flippedData(fd),
additionJsonHeader(ajh),
acquisitionStartedFlag(false),
measurementStartedFlag(false),
firstAcquisitionIndex(0),
firstMeasurementIndex(0),
completeBuffer(0)
completeBuffer(0),
gapPixelsEnable(gpEnable)
{
flippedData[0] = fd[0];
flippedData[1] = fd[1];
numDet[0] = nd[0];
numDet[1] = nd[1];
if(ThreadObject::CreateThread() == FAIL)
throw std::exception();
@ -130,6 +135,16 @@ int DataStreamer::SetThreadPriority(int priority) {
return OK;
}
void DataStreamer::SetNumberofDetectors(int* nd) {
numDet[0] = nd[0];
numDet[1] = nd[1];
}
void DataStreamer::SetFlippedData(int* fd) {
flippedData[0] = fd[0];
flippedData[1] = fd[1];
}
void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const char* srcip) {
uint32_t portnum = port + index;
@ -261,13 +276,13 @@ int DataStreamer::SendHeader(sls_receiver_header* rheader, uint32_t size, uint32
uint64_t acquisitionIndex = header.frameNumber - firstAcquisitionIndex;
return zmqSocket->SendHeaderData(index, dummy, SLS_DETECTOR_JSON_HEADER_VERSION, *dynamicRange, *fileIndex,
nx, ny, size,
numDet[0], numDet[1], nx, ny, size,
acquisitionIndex, frameIndex, fileNametoStream,
header.frameNumber, header.expLength, header.packetNumber, header.bunchId, header.timestamp,
header.modId, header.row, header.column, header.reserved,
header.debug, header.roundRNumber,
header.detType, header.version,
flippedData,
gapPixelsEnable ? 1 : 0, flippedData,
additionJsonHeader
);
}

View File

@ -53,6 +53,7 @@ void UDPBaseImplementation::initializeMembers(){
flippedData[0] = 0;
flippedData[1] = 0;
gapPixelsEnable = false;
quadEnable = false;
//***receiver parameters***
status = IDLE;
@ -137,6 +138,11 @@ bool UDPBaseImplementation::getGapPixelsEnable() const {
return gapPixelsEnable;
}
bool UDPBaseImplementation::getQuad() const {
FILE_LOG(logDEBUG) << __AT__ << " starting";
return quadEnable;
}
/***file parameters***/
slsReceiverDefs::fileFormat UDPBaseImplementation::getFileFormat() const{
FILE_LOG(logDEBUG) << __AT__ << " starting";
@ -392,6 +398,8 @@ void UDPBaseImplementation::setMultiDetectorSize(const int* size) {
}
strcat(message,")");
FILE_LOG(logINFO) << message;
// overridden
}
void UDPBaseImplementation::setFlippedData(int axis, int enable){
@ -399,6 +407,8 @@ void UDPBaseImplementation::setFlippedData(int axis, int enable){
if(axis<0 || axis>1) return;
flippedData[axis] = enable==0?0:1;
FILE_LOG(logINFO) << "Flipped Data: " << flippedData[0] << " , " << flippedData[1];
// overridden
}
int UDPBaseImplementation::setGapPixelsEnable(const bool b) {
@ -410,6 +420,14 @@ int UDPBaseImplementation::setGapPixelsEnable(const bool b) {
return OK;
}
void UDPBaseImplementation::setQuad(const bool b) {
FILE_LOG(logDEBUG) << __AT__ << " starting";
quadEnable = b;
FILE_LOG(logINFO) << "Quad Enable: " << quadEnable;
// overridden
}
/***file parameters***/
void UDPBaseImplementation::setFileFormat(const fileFormat f){
FILE_LOG(logDEBUG) << __AT__ << " starting";

View File

@ -111,6 +111,55 @@ int64_t UDPStandardImplementation::getAcquisitionIndex() const {
}
void UDPStandardImplementation::setMultiDetectorSize(const int* size) {
char message[100];
strcpy(message, "Detector Size: (");
for (int i = 0; i < MAX_DIMENSIONS; ++i) {
if (myDetectorType == EIGER && (!i))
numDet[i] = size[i]*2;
else
numDet[i] = size[i];
sprintf(message,"%s%d",message,numDet[i]);
if (i < MAX_DIMENSIONS-1 )
strcat(message,",");
}
strcat(message,")");
int sz[2] = {numDet[0], numDet[1]};
if (quadEnable) {
sz[0] = 1;
sz[1] = 2;
}
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
(*it)->SetNumberofDetectors(sz);
}
FILE_LOG(logINFO) << message;
}
void UDPStandardImplementation::setFlippedData(int axis, int enable){
if(axis<0 || axis>1) return;
flippedData[axis] = enable==0?0:1;
if (!quadEnable) {
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
(*it)->SetFlippedData(flippedData);
}
}
else {
int fd[2] = {flippedData[0], flippedData[1]};
if (dataStreamer.size() == 2) {
fd[0] = 0;
dataStreamer[0]->SetFlippedData(fd);
fd[0] = 1;
dataStreamer[1]->SetFlippedData(fd);
}
}
FILE_LOG(logINFO) << "Flipped Data: " << flippedData[0] << " , " << flippedData[1];
}
int UDPStandardImplementation::setGapPixelsEnable(const bool b) {
if (gapPixelsEnable != b) {
@ -130,6 +179,32 @@ int UDPStandardImplementation::setGapPixelsEnable(const bool b) {
return OK;
}
void UDPStandardImplementation::setQuad(const bool b) {
if (quadEnable != b) {
quadEnable = b;
if (!quadEnable) {
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
(*it)->SetNumberofDetectors(numDet);
(*it)->SetFlippedData(flippedData);
}
} else {
int size[2] = {1, 2};
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
(*it)->SetNumberofDetectors(size);
}
int fd[2] = {flippedData[0], flippedData[1]};
if (dataStreamer.size() == 2) {
fd[0] = 0;
dataStreamer[0]->SetFlippedData(fd);
fd[0] = 1;
dataStreamer[1]->SetFlippedData(fd);
}
}
}
FILE_LOG(logINFO) << "Quad Enable: " << quadEnable;
}
void UDPStandardImplementation::setFileFormat(const fileFormat f){
switch(f){
@ -252,7 +327,7 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
for ( int i = 0; i < numThreads; ++i ) {
try {
DataStreamer* s = new DataStreamer(i, fifo[i], &dynamicRange,
&roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode);
&roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode, (int*)numDet, &gapPixelsEnable);
dataStreamer.push_back(s);
dataStreamer[i]->SetGeneralData(generalData);
dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP);

View File

@ -246,6 +246,7 @@ const char* slsReceiverTCPIPInterface::getFunctionName(enum recFuncs func) {
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";
case F_RECEIVER_QUAD: return "F_RECEIVER_QUAD";
default: return "Unknown Function";
}
@ -303,7 +304,7 @@ int slsReceiverTCPIPInterface::function_table(){
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;
flist[F_RECEIVER_QUAD] = &slsReceiverTCPIPInterface::set_quad_type;
#ifdef VERYVERBOSE
for (int i = 0; i < NUM_REC_FUNCTIONS ; i++) {
@ -2982,3 +2983,53 @@ int slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable() {
// return ok/fail
return ret;
}
int slsReceiverTCPIPInterface::set_quad_type() {
ret = OK;
memset(mess, 0, sizeof(mess));
int value = -1;
int retval = -1;
// receive arguments
if (mySock->ReceiveDataOnly(&value,sizeof(value)) < 0 )
return printSocketReadError();
// execute action
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
if (receiverBase == NULL)
invalidReceiverObject();
else {
// set
if(value >= 0) {
if (mySock->differentClients && lockStatus)
receiverlocked();
else if (receiverBase->getStatus() != IDLE)
receiverNotIdle();
else {
receiverBase->setQuad(value); // no check required
}
}
//get
retval = (int)receiverBase->getQuad(); // no check required
}
#endif
#ifdef VERYVERBOSE
FILE_LOG(logINFO) << "Quad mode:" << 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;
}