* making quad work in developer branch

* binary added

* minor changes

* bug fix to set quad to 0 when more than 1 detector
This commit is contained in:
Dhanya Thattil
2019-07-22 16:41:03 +02:00
committed by GitHub
parent 0fa63f8be2
commit e7a76ccea1
23 changed files with 432 additions and 70 deletions

View File

@ -27,11 +27,13 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
* @param dr pointer to dynamic range
* @param r roi
* @param fi pointer to file index
* @param fd flipped data enable for x and y dimensions
* @param fd flipped data enable for x dimension
* @param ajh additional json header
* @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);
uint64_t* fi, int fd, char* ajh, int* nd, bool* gpEnable);
/**
* Destructor
@ -87,6 +89,18 @@ class DataStreamer : private virtual slsDetectorDefs, 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 x dimension
* @param flipped data enable in x dimension
*/
void SetFlippedDataX(int fd);
/**
* Creates Zmq Sockets
* (throws an exception if it couldnt create zmq sockets)
@ -182,8 +196,8 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
/** Pointer to file index */
uint64_t* fileIndex;
/** flipped data across both dimensions enable */
int* flippedData;
/** flipped data across x axis */
int flippedDataX;
/** additional json header */
char* additionJsonHeader;
@ -206,5 +220,11 @@ class DataStreamer : private virtual slsDetectorDefs, 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

@ -74,6 +74,12 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
*/
bool getGapPixelsEnable() const;
/**
* Get Quad type Enable (eiger and hardware specific)
* @return true if quad enabled, else false
*/
bool getQuad() const;
/**
* Get readout flags (Eiger, chiptestboard, moench)
* @return readout flags
@ -390,6 +396,12 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
*/
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 readout flags (eiger, chiptestboard, moench)
* @param f readout flag
@ -868,10 +880,12 @@ class slsReceiverImplementation : private virtual slsDetectorDefs {
bool tengigaEnable;
/** Fifo Depth */
uint32_t fifoDepth;
/** enable for flipping data across both axes */
int flippedData[2];
/** flipped data x across x axis (bottom eiger) */
int flippedDataX;
/** gap pixels enable */
bool gapPixelsEnable;
/** quad type enable */
bool quadEnable;
/** readout flags*/
readOutFlags readoutFlags;

View File

@ -294,6 +294,9 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
/** set dbit offset */
int set_dbit_offset(sls::ServerInterface2 &socket);
/** quad type */
int set_quad_type(sls::ServerInterface2 &socket);
/** detector type */
detectorType myDetectorType;

View File

@ -17,7 +17,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) :
uint64_t* fi, int fd, char* ajh, int* nd, bool* gpEnable) :
ThreadObject(ind),
runningFlag(0),
generalData(nullptr),
@ -27,15 +27,19 @@ DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, std::vector<ROI>* r,
roi(r),
adcConfigured(-1),
fileIndex(fi),
flippedData(fd),
flippedDataX(fd),
additionJsonHeader(ajh),
acquisitionStartedFlag(false),
measurementStartedFlag(false),
firstAcquisitionIndex(0),
firstMeasurementIndex(0),
completeBuffer(nullptr)
completeBuffer(nullptr),
gapPixelsEnable(gpEnable)
{
if(ThreadObject::CreateThread() == FAIL)
numDet[0] = nd[0];
numDet[1] = nd[1];
if(ThreadObject::CreateThread() == FAIL)
throw sls::RuntimeError("Could not create streaming thread");
FILE_LOG(logDEBUG) << "DataStreamer " << ind << " created";
@ -98,7 +102,6 @@ void DataStreamer::ResetParametersforNewMeasurement(const std::string& fname){
}
}
void DataStreamer::RecordFirstIndices(uint64_t fnum) {
measurementStartedFlag = true;
firstMeasurementIndex = fnum;
@ -113,7 +116,6 @@ void DataStreamer::RecordFirstIndices(uint64_t fnum) {
"\tFirst Measurement Index: " << firstMeasurementIndex;
}
void DataStreamer::SetGeneralData(GeneralData* g) {
generalData = g;
generalData->Print();
@ -128,6 +130,14 @@ int DataStreamer::SetThreadPriority(int priority) {
return OK;
}
void DataStreamer::SetNumberofDetectors(int* nd) {
numDet[0] = nd[0];
numDet[1] = nd[1];
}
void DataStreamer::SetFlippedDataX(int fd) {
flippedDataX = fd;
}
void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const char* srcip) {
uint32_t portnum = port + index;
@ -247,13 +257,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.c_str(),
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, flippedDataX,
additionJsonHeader
);
}

View File

@ -67,9 +67,9 @@ void slsReceiverImplementation::InitializeMembers() {
dynamicRange = 16;
tengigaEnable = false;
fifoDepth = 0;
flippedData[0] = 0;
flippedData[1] = 0;
flippedDataX = 0;
gapPixelsEnable = false;
quadEnable = false;
readoutFlags = GET_READOUT_FLAGS;
//*** receiver parameters ***
@ -148,9 +148,14 @@ std::string slsReceiverImplementation::getDetectorHostname() const {
int slsReceiverImplementation::getFlippedData(int axis) const {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
if (axis < 0 || axis > 1)
return -1;
return flippedData[axis];
switch(axis) {
case 0:
return flippedDataX;
case 1:
return 0;
default:
return -1;
}
}
bool slsReceiverImplementation::getGapPixelsEnable() const {
@ -158,6 +163,11 @@ bool slsReceiverImplementation::getGapPixelsEnable() const {
return gapPixelsEnable;
}
bool slsReceiverImplementation::getQuad() const {
FILE_LOG(logDEBUG) << __AT__ << " starting";
return quadEnable;
}
slsDetectorDefs::readOutFlags
slsReceiverImplementation::getReadOutFlags() const {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
@ -452,16 +462,38 @@ void slsReceiverImplementation::setMultiDetectorSize(const int *size) {
log_message += ", ";
}
log_message += ")";
int nd[2] = {numDet[0], numDet[1]};
if (quadEnable) {
nd[0] = 1;
nd[1] = 2;
}
for (const auto &it : dataStreamer) {
it->SetNumberofDetectors(nd);
}
FILE_LOG(logINFO) << log_message;
}
void slsReceiverImplementation::setFlippedData(int axis, int enable) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
if (axis < 0 || axis > 1)
if (axis != 0)
return;
flippedData[axis] = enable == 0 ? 0 : 1;
FILE_LOG(logINFO) << "Flipped Data: " << flippedData[0] << " , "
<< flippedData[1];
flippedDataX = (enable == 0) ? 0 : 1;
if (!quadEnable) {
for (const auto &it : dataStreamer) {
it->SetFlippedDataX(flippedDataX);
}
}
else {
if (dataStreamer.size() == 2) {
dataStreamer[0]->SetFlippedDataX(0);
dataStreamer[1]->SetFlippedDataX(1);
}
}
FILE_LOG(logINFO) << "Flipped Data X: " << flippedDataX;
}
int slsReceiverImplementation::setGapPixelsEnable(const bool b) {
@ -479,6 +511,30 @@ int slsReceiverImplementation::setGapPixelsEnable(const bool b) {
return OK;
}
void slsReceiverImplementation::setQuad(const bool b) {
if (quadEnable != b) {
quadEnable = b;
if (!quadEnable) {
for (const auto &it : dataStreamer) {
it->SetNumberofDetectors(numDet);
it->SetFlippedDataX(flippedDataX);
}
} else {
int size[2] = {1, 2};
for (const auto &it : dataStreamer) {
it->SetNumberofDetectors(size);
}
if (dataStreamer.size() == 2) {
dataStreamer[0]->SetFlippedDataX(0);
dataStreamer[1]->SetFlippedDataX(1);
}
}
}
FILE_LOG(logINFO) << "Quad Enable: " << quadEnable;
}
int slsReceiverImplementation::setReadOutFlags(const readOutFlags f) {
if (readoutFlags != f) {
readoutFlags = f;
@ -708,10 +764,16 @@ int slsReceiverImplementation::setNumberofUDPInterfaces(const int n) {
// streamer threads
if (dataStreamEnable) {
try {
int fd = flippedDataX;
int nd[2] = {numDet[0], numDet[1]};
if (quadEnable) {
fd = i;
nd[0] = 1;
nd[1] = 2;
}
dataStreamer.push_back(sls::make_unique<DataStreamer>(
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex,
flippedData, additionalJsonHeader));
fd, additionalJsonHeader, (int*)nd, &gapPixelsEnable));
dataStreamer[i]->SetGeneralData(generalData);
dataStreamer[i]->CreateZmqSockets(
&numThreads, streamingPort, streamingSrcIP);
@ -884,9 +946,16 @@ int slsReceiverImplementation::setDataStreamEnable(const bool enable) {
if (enable) {
for (int i = 0; i < numThreads; ++i) {
try {
int fd = flippedDataX;
int nd[2] = {numDet[0], numDet[1]};
if (quadEnable) {
fd = i;
nd[0] = 1;
nd[1] = 2;
}
dataStreamer.push_back(sls::make_unique<DataStreamer>(
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex,
flippedData, additionalJsonHeader));
fd, additionalJsonHeader, (int*)nd, &gapPixelsEnable));
dataStreamer[i]->SetGeneralData(generalData);
dataStreamer[i]->CreateZmqSockets(
&numThreads, streamingPort, streamingSrcIP);

View File

@ -200,6 +200,8 @@ int slsReceiverTCPIPInterface::function_table(){
flist[F_SET_RECEIVER_DBIT_LIST] = &slsReceiverTCPIPInterface::set_dbit_list;
flist[F_GET_RECEIVER_DBIT_LIST] = &slsReceiverTCPIPInterface::get_dbit_list;
flist[F_RECEIVER_DBIT_OFFSET] = &slsReceiverTCPIPInterface::set_dbit_offset;
flist[F_SET_RECEIVER_QUAD] = &slsReceiverTCPIPInterface::set_quad_type;
for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) {
FILE_LOG(logDEBUG1) << "function fnum: " << i << " (" <<
@ -1306,3 +1308,16 @@ int slsReceiverTCPIPInterface::set_dbit_offset(Interface &socket) {
FILE_LOG(logDEBUG1) << "Dbit offset retval: " << retval;
return socket.sendResult(retval);
}
int slsReceiverTCPIPInterface::set_quad_type(Interface &socket) {
auto quadEnable = socket.Receive<int>();
if (quadEnable >= 0) {
VerifyIdle(socket);
FILE_LOG(logDEBUG1) << "Setting quad:" << quadEnable;
impl()->setQuad(quadEnable == 0 ? false : true);
}
int retval = impl()->getQuad() ? 1 : 0;
validate(quadEnable, retval, "set quad", DEC);
FILE_LOG(logDEBUG1) << "quad retval:" << retval;
return socket.Send(OK);
}