* 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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 432 additions and 70 deletions

View File

@ -349,6 +349,8 @@ void qDetectorMain::EnableModes(QAction *action) {
enable = actionExpert->isChecked();
tabs->setTabEnabled(ADVANCED, enable);
actionLoadTrimbits->setVisible(enable && detType != slsDetectorDefs::MOENCH);
actionSaveTrimbits->setVisible(enable && detType != slsDetectorDefs::MOENCH);
FILE_LOG(logINFO) << "Expert Mode: "
<< slsDetectorDefs::stringEnable(enable);
}

View File

@ -78,14 +78,24 @@ void qDrawPlot::Initialization() {
void qDrawPlot::SetupPlots() {
setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
// default image size
nPixelsX = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X);
nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y);
if (detType == slsDetectorDefs::MOENCH) {
npixelsy_jctb = (myDet->setTimer(slsDetectorDefs::ANALOG_SAMPLES, -1) * 2) /
25; // for moench 03
switch(detType) {
case slsDetectorDefs::MOENCH:
npixelsy_jctb = (myDet->setTimer(slsDetectorDefs::ANALOG_SAMPLES, -1) * 2)/25;// for moench 03
nPixelsX = npixelsx_jctb;
nPixelsY = npixelsy_jctb;
break;
case slsDetectorDefs::EIGER:
if (myDet->getQuad()) {
nPixelsX = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X) / 2;
nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y) * 2;
}
break;
default:
break;
}
FILE_LOG(logINFO) << "nPixelsX:" << nPixelsX;
FILE_LOG(logINFO) << "nPixelsY:" << nPixelsY;
@ -625,7 +635,17 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFra
currentFrame = frameIndex;
FILE_LOG(logDEBUG) << "[ Progress:" << progress << ", Frame:" << currentFrame << " ]";
//FIXME: check npixelsx and npixelsY (change to this new val, if it is not, and look out for sideeffects)
// 2d (only image, not gain data, not pedestalvals),
// check if npixelsX and npixelsY is the same (quad is different)
if (!is1d && (static_cast<int>(nPixelsX) != data->nx || static_cast<int>(nPixelsY) != data->ny)) {
nPixelsX = data->nx;
nPixelsY = data->ny;
FILE_LOG(logINFO) << "Change in Detector Shape:\n\tnPixelsX:" << nPixelsX << " nPixelsY:" << nPixelsY;
if (data2d)
delete [] data2d;
data2d = new double[nPixelsY * nPixelsX];
std::fill(data2d, data2d + nPixelsX * nPixelsY, 0);
}
// convert data to double
unsigned int nPixels = nPixelsX * (is1d ? 1 : nPixelsY);

View File

@ -37,6 +37,8 @@ uint32_t Beb_detid = 0;
int Beb_top =0;
uint64_t Beb_deactivatedStartFrameNumber = 0;
int Beb_quadEnable = 0;
int Beb_positions[2] = {0, 0};
void BebInfo_BebInfo(struct BebInfo* bebInfo, unsigned int beb_num) {
@ -1188,6 +1190,16 @@ void Beb_SetDetectorNumber(uint32_t detid) {
FILE_LOG(logINFO, ("Detector id %d set in UDP Header\n\n", detid));
}
void Beb_SetQuad(int value) {
if (value >= 0) {
Beb_quadEnable = (value == 0 ? 0 : 1);
Beb_SetDetectorPosition(Beb_positions);
}
}
int Beb_GetQuad() {
return Beb_quadEnable;
}
int Beb_SetDetectorPosition(int pos[]) {
@ -1195,8 +1207,18 @@ int Beb_SetDetectorPosition(int pos[]) {
return OK;
FILE_LOG(logINFO, ("Got Position values %d %d...\n", pos[0],pos[1]));
pos[0] = Beb_swap_uint16(pos[0]);
//pos[1] = Beb_swap_uint16(pos[1]);
// save positions
Beb_positions[0] = pos[0];
Beb_positions[1] = pos[1];
// get left and right
int posLeft[2] = {pos[0], Beb_top ? pos[1] : pos[1] + 1};
int posRight[2] = {pos[0], Beb_top ? pos[1] + 1 : pos[1]};
if (Beb_quadEnable) {
posRight[0] = 1; // right is next row
posRight[1] = 0; // right same first column
}
int ret = FAIL;
//mapping new memory to read master top module configuration
@ -1210,20 +1232,22 @@ int Beb_SetDetectorPosition(int pos[]) {
uint32_t value = 0;
ret = OK;
// x left
int posval = Beb_swap_uint16(posLeft[0]);
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
value &= UDP_HEADER_ID_MSK; // to keep previous id value
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
if ((value & UDP_HEADER_X_MSK) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) {
if ((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) {
FILE_LOG(logERROR, ("Could not set row position for left port\n"));
ret = FAIL;
}
// x right
posval = Beb_swap_uint16(posRight[0]);
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
value &= UDP_HEADER_ID_MSK; // to keep previous id value
Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
if ((value & UDP_HEADER_X_MSK) != ((pos[0] << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) {
if ((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) {
FILE_LOG(logERROR, ("Could not set row position for right port\n"));
ret = FAIL;
}
@ -1231,7 +1255,7 @@ int Beb_SetDetectorPosition(int pos[]) {
// y left (column)
int posval = Beb_swap_uint16(Beb_top ? pos[1] : (pos[1]+1));
posval = Beb_swap_uint16(posLeft[1]);
value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST);
value &= UDP_HEADER_Z_MSK; // to keep previous z value
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, value | ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
@ -1242,9 +1266,9 @@ int Beb_SetDetectorPosition(int pos[]) {
}
// y right
posval = Beb_swap_uint16(posRight[1]);
value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST);
value &= UDP_HEADER_Z_MSK; // to keep previous z value
posval = Beb_swap_uint16(Beb_top ? (pos[1]+1) : pos[1]);
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, value | ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST);
if ((value & UDP_HEADER_Y_MSK) != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)) {
@ -1260,8 +1284,7 @@ int Beb_SetDetectorPosition(int pos[]) {
FILE_LOG(logINFO, ("Position set to...\n"
"\tLeft: [%d, %d]\n"
"\tRight:[%d, %d]\n",
Beb_swap_uint16(pos[0]), Beb_top ? pos[1] : (pos[1]+1)),
Beb_swap_uint16(pos[0]), Beb_top ? (pos[1]+1) : pos[1]);
posLeft[0], posLeft[1], posRight[0], posRight[1]));
}
return ret;

View File

@ -74,6 +74,8 @@ int Beb_Test(unsigned int beb_number);
int Beb_GetBebFPGATemp();
void Beb_SetDetectorNumber(uint32_t detid);
void Beb_SetQuad(int value);
int Beb_GetQuad();
int Beb_SetDetectorPosition(int pos[]);
int Beb_SetStartingFrameNumber(uint64_t value);
int Beb_GetStartingFrameNumber(uint64_t* retval);

View File

@ -1310,6 +1310,13 @@ int setDetectorPosition(int pos[]) {
#endif
}
void setQuad(int value) {
Beb_SetQuad(value);
}
int getQuad() {
return Beb_GetQuad();
}
int enableTenGigabitEthernet(int val) {
if (val!=-1) {

View File

@ -246,6 +246,10 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32
#if defined(JUNGFRAUD) || defined(EIGERD)
int setDetectorPosition(int pos[]);
#endif
#ifdef EIGERD
void setQuad(int value);
int getQuad();
#endif
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(EIGERD)
int enableTenGigabitEthernet(int val);
#endif

View File

@ -244,6 +244,8 @@ const char* getFunctionName(enum detFuncs func) {
case F_EXTERNAL_SAMPLING: return "F_EXTERNAL_SAMPLING";
case F_SET_STARTING_FRAME_NUMBER: return "F_SET_STARTING_FRAME_NUMBER";
case F_GET_STARTING_FRAME_NUMBER: return "F_GET_STARTING_FRAME_NUMBER";
case F_SET_QUAD: return "F_SET_QUAD";
case F_GET_QUAD: return "F_GET_QUAD";
default: return "Unknown Function";
}
}
@ -328,6 +330,8 @@ void function_table() {
flist[F_EXTERNAL_SAMPLING] = &set_external_sampling;
flist[F_SET_STARTING_FRAME_NUMBER] = &set_starting_frame_number;
flist[F_GET_STARTING_FRAME_NUMBER] = &get_starting_frame_number;
flist[F_SET_QUAD] = &set_quad;
flist[F_GET_QUAD] = &get_quad;
// check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -4074,4 +4078,50 @@ int get_starting_frame_number(int file_des) {
}
#endif
return Server_SendResult(file_des, INT64, UPDATE, &retval, sizeof(retval));
}
int set_quad(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = 0;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
FILE_LOG(logINFO, ("Setting quad: %u\n", arg));
#ifndef EIGERD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
setQuad(arg);
int retval = getQuad();
if (arg != retval) {
ret = FAIL;
sprintf(mess, "Could not set quad. Set %d, but read %d\n", retval, arg);
FILE_LOG(logERROR,(mess));
}
}
#endif
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
}
int get_quad(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
FILE_LOG(logDEBUG1, ("Getting Quad\n"));
#ifndef EIGERD
functionNotImplemented();
#else
// get only
retval = getQuad();
FILE_LOG(logDEBUG1, ("Quad retval: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
}

View File

@ -104,4 +104,6 @@ int get_adc_invert(int);
int set_external_sampling_source(int);
int set_external_sampling(int);
int set_starting_frame_number(int);
int get_starting_frame_number(int);
int get_starting_frame_number(int);
int set_quad(int);
int get_quad(int);

View File

@ -373,6 +373,20 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
int setMaxNumberOfChannelsPerDetector(dimension d, int i);
/**
* Get Quad Type (Only for Eiger Quad detector hardware)
* @param detPos -1 for all detectors in list or specific detector position
* @returns quad type
*/
int getQuad(int detPos = -1);
/**
* Set Quad Type (Only for Eiger Quad detector hardware)
* @param enable true if quad type set, else false
* @param detPos -1 for all detectors in list or specific detector position
*/
void setQuad(const bool enable, int detPos = -1);
/**
* Get Detector offset from shared memory in dimension d
* @param d dimension d

View File

@ -473,6 +473,18 @@ class slsDetector : public virtual slsDetectorDefs{
* @returns number of chips per module in dimension d
*/
int getNChips(dimension d) const;
/**
* Get Quad Type (Only for Eiger Quad detector hardware)
* @returns quad type
*/
int getQuad();
/**
* Set Quad Type (Only for Eiger Quad detector hardware)
* @param enable true if quad type set, else false
*/
void setQuad(const bool enable);
/**
* Get Detector offset from shared memory in dimension d

View File

@ -514,6 +514,22 @@ int multiSlsDetector::setMaxNumberOfChannelsPerDetector(dimension d, int i) {
return multi_shm()->maxNumberOfChannelsPerDetector[d];
}
int multiSlsDetector::getQuad(int detPos) {
int retval = detectors[0]->getQuad();
if (retval && getNumberOfDetectors() > 1) {
throw RuntimeError("Quad type is available only for 1 Eiger Quad Half module, but it Quad is enabled for 1st readout");
}
return retval;
}
void multiSlsDetector::setQuad(const bool enable, int detPos) {
if (enable && getNumberOfDetectors() > 1) {
throw RuntimeError("Cannot set Quad type as it is available only for 1 Eiger Quad Half module.");
}
detectors[0]->setQuad(enable);
}
int multiSlsDetector::getDetectorOffset(dimension d, int detPos) {
return detectors[detPos]->getDetectorOffset(d);
}
@ -3256,18 +3272,13 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy) {
void multiSlsDetector::readFrameFromReceiver() {
int nX = multi_shm()->numberOfDetector[X]; // to copy data in multi module
int nY = multi_shm()->numberOfDetector[Y]; // for eiger, to reverse the data
int nX = 0;
int nY = 0;
int nDetPixelsX = 0;
int nDetPixelsY = 0;
bool gappixelsenable = false;
bool eiger = false;
if (getDetectorTypeAsEnum() == EIGER) {
eiger = true;
nX *= 2;
gappixelsenable = detectors[0]->enableGapPixels(-1) > 0;
}
if (getNumberofUDPInterfaces() == 2) {
nY *= 2;
}
bool numInterfaces = getNumberofUDPInterfaces(); // cannot pick up from zmq
bool runningList[zmqSocket.size()], connectList[zmqSocket.size()];
int numRunning = 0;
@ -3344,14 +3355,29 @@ void multiSlsDetector::readFrameFromReceiver() {
// shape
nPixelsX = doc["shape"][0].GetUint();
nPixelsY = doc["shape"][1].GetUint();
// detector shape
nX = doc["detshape"][0].GetUint();
nY = doc["detshape"][1].GetUint();
nY *= numInterfaces;
nDetPixelsX = nX * nPixelsX;
nDetPixelsY = nY * nPixelsY;
// det type
eiger = (doc["detType"].GetUint() == static_cast<int>(3)) ? true : false; // to be changed to EIGER when firmware updates its header data
// gap pixels enable
gappixelsenable = (doc["gappixels"].GetUint() == 0) ? false : true;
FILE_LOG(logDEBUG1)
<< "One Time Header Info:"
"\n\tsize: "
<< size << "\n\tmultisize: " << multisize
<< "\n\tdynamicRange: " << dynamicRange
<< "\n\tbytesPerPixel: " << bytesPerPixel
<< "\n\tnPixelsX: " << nPixelsX << "\n\tnPixelsY: " << nPixelsY;
<< "\n\tnPixelsX: " << nPixelsX
<< "\n\tnPixelsY: " << nPixelsY
<< "\n\tnX: " << nX
<< "\n\tnY: " << nY
<< "\n\teiger: " << eiger
<< "\n\tgappixelsenable: " << gappixelsenable;
}
// each time, parse rest of header
currentFileName = doc["fname"].GetString();
@ -3414,20 +3440,16 @@ void multiSlsDetector::readFrameFromReceiver() {
// send data to callback
if (data) {
int nCompletePixelsX = multi_shm()->numberOfChannelInclGapPixels[X];
int nCompletePixelsY = multi_shm()->numberOfChannelInclGapPixels[Y];
setCurrentProgress(currentAcquisitionIndex + 1);
// 4bit gap pixels
if (dynamicRange == 4 && gappixelsenable) {
int n = processImageWithGapPixels(multiframe, multigappixels);
thisData =
new detectorData(getCurrentProgress(), currentFileName.c_str(), nCompletePixelsX,
nCompletePixelsY, multigappixels, n, dynamicRange, currentFileIndex);
new detectorData(getCurrentProgress(), currentFileName.c_str(), nDetPixelsX, nDetPixelsY, multigappixels, n, dynamicRange, currentFileIndex);
}
// normal pixels
else {
thisData = new detectorData(getCurrentProgress(), currentFileName.c_str(), nCompletePixelsX,
nCompletePixelsY, multiframe, multisize, dynamicRange,
thisData = new detectorData(getCurrentProgress(), currentFileName.c_str(), nDetPixelsX, nDetPixelsY, multiframe, multisize, dynamicRange,
currentFileIndex);
}
dataReady(thisData, currentFrameIndex,

View File

@ -629,6 +629,28 @@ int slsDetector::getNChips() const { return shm()->nChips; }
int slsDetector::getNChips(dimension d) const { return shm()->nChip[d]; }
int slsDetector::getQuad() {
int retval = -1;
FILE_LOG(logDEBUG1) << "Getting Quad Type";
if (shm()->onlineFlag == ONLINE_FLAG) {
sendToDetector(F_GET_QUAD, nullptr, retval);
FILE_LOG(logDEBUG1) << "Quad Type :" << retval;
}
return retval;
}
void slsDetector::setQuad(const bool enable) {
int value = enable ? 1 : 0;
FILE_LOG(logDEBUG1) << "Setting Quad type to " << value;
if (shm()->onlineFlag == ONLINE_FLAG) {
sendToDetector(F_SET_QUAD, value, nullptr);
}
FILE_LOG(logDEBUG1) << "Setting Quad type to " << value << " in Receiver";
if (shm()->rxOnlineFlag == ONLINE_FLAG) {
sendToReceiver(F_SET_RECEIVER_QUAD, value, nullptr);
}
}
int slsDetector::getDetectorOffset(dimension d) const {
return shm()->offset[d];
}

View File

@ -348,6 +348,14 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdDetectorSize;
++i;
/*! \page config
- <b>quad [i] </b> if 1, sets the detector size to a quad (Specific to an EIGER quad hardware). 0 by default. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName="quad"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDetectorSize;
++i;
/*! \page config
- <b>flippeddatax [i]</b> enables/disables data being flipped across x axis. 1 enables, 0 disables. Used for EIGER only. 1 for bottom half-module, 0 for top-half module. \c Returns \c (int)
*/
@ -3391,7 +3399,7 @@ std::string slsDetectorCommand::cmdDetectorSize(int narg, const char * const arg
myDet->setOnline(ONLINE_FLAG, detPos);
if (cmd == "roi")
if (cmd == "roi" || cmd == "quad")
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
if (action == PUT_ACTION) {
@ -3421,6 +3429,12 @@ std::string slsDetectorCommand::cmdDetectorSize(int narg, const char * const arg
myDet->setMaxNumberOfChannelsPerDetector(Y, val);
}
if(cmd=="quad"){
if (val >=0 ) {
myDet->setQuad(val);
}
}
if (cmd == "flippeddatax") {
if ((!sscanf(args[1], "%d", &val)) || (val != 0 && val != 1))
return std::string("cannot scan flippeddata x mode: must be 0 or 1");
@ -3455,6 +3469,8 @@ std::string slsDetectorCommand::cmdDetectorSize(int narg, const char * const arg
} else if (cmd == "detsizechan") {
sprintf(ans, "%d %d", myDet->getMaxNumberOfChannelsPerDetector(X), myDet->getMaxNumberOfChannelsPerDetector(Y));
return std::string(ans);
} else if (cmd=="quad") {
return std::to_string(myDet->getQuad());
} else if (cmd == "flippeddatax") {
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
ret = myDet->getFlippedData(X, detPos);
@ -3468,6 +3484,7 @@ std::string slsDetectorCommand::cmdDetectorSize(int narg, const char * const arg
return std::string("Cannot execute this command from slsDetector level. Please use multiSlsDetector level.\n");
ret = myDet->enableGapPixels(-1, detPos);
}
else
return std::string("unknown command ") + cmd;
@ -3484,6 +3501,7 @@ std::string slsDetectorCommand::helpDetectorSize(int action) {
os << "dr i \n sets the dynamic range of the detector" << std::endl;
os << "roi i xmin xmax ymin ymax \n sets region of interest where i is number of rois;i=0 to clear rois" << std::endl;
os << "detsizechan x y \n sets the maximum number of channels for complete detector set in both directions; -1 is no limit" << std::endl;
os << "quad i \n if i = 1, sets the detector size to a quad (Specific to an EIGER quad hardware). 0 by default."<< std::endl;
os << "flippeddatax x \n sets if the data should be flipped on the x axis" << std::endl;
os << "flippeddatay y \n sets if the data should be flipped on the y axis" << std::endl;
os << "gappixels i \n enables/disables gap pixels in system (detector & receiver). 1 sets, 0 unsets. Used in EIGER only and multidetector level." << std::endl;
@ -3492,6 +3510,7 @@ std::string slsDetectorCommand::helpDetectorSize(int action) {
os << "dr \n gets the dynamic range of the detector" << std::endl;
os << "roi \n gets region of interest" << std::endl;
os << "detsizechan \n gets the maximum number of channels for complete detector set in both directions; -1 is no limit" << std::endl;
os << "quad \n returns 1 if the detector size is a quad (Specific to an EIGER quad hardware). 0 by default."<< std::endl;
os << "flippeddatax\n gets if the data will be flipped on the x axis" << std::endl;
os << "flippeddatay\n gets if the data will be flipped on the y axis" << std::endl;
os << "gappixels\n gets if gap pixels is enabled in system. Used in EIGER only and multidetector level." << std::endl;

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);
}

View File

@ -240,19 +240,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 flippedDataX if it is flipped across x 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, const 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 flippedDataX = 0,
char* additionalJsonHeader = 0) {
@ -263,6 +286,7 @@ public:
"\"jsonversion\":%u, "
"\"bitmode\":%u, "
"\"fileIndex\":%lu, "
"\"detshape\":[%u, %u], "
"\"shape\":[%u, %u], "
"\"size\":%u, "
"\"acqIndex\":%lu, "
@ -285,12 +309,13 @@ public:
"\"version\":%u, "
//additional stuff
"\"flippedDataX\":%u"
"\"gappixels\":%u, "
"\"flippedDataX\":%u"
;//"}\n";
char buf[MAX_STR_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,
@ -298,7 +323,8 @@ public:
detType, version,
//additional stuff
((flippedData == 0 ) ? 0 :flippedData[0])
gapPixelsEnable,
flippedDataX
);
if (additionalJsonHeader && strlen(additionalJsonHeader)) {

View File

@ -89,6 +89,8 @@ enum detFuncs{
F_EXTERNAL_SAMPLING, /**< enable/disable external sampling for ctb */
F_SET_STARTING_FRAME_NUMBER,
F_GET_STARTING_FRAME_NUMBER,
F_SET_QUAD,
F_GET_QUAD,
NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 128, /**< detector function should not exceed this (detector server should not compile anyway) */
@ -146,6 +148,7 @@ enum detFuncs{
F_SET_RECEIVER_DBIT_LIST, /** < set receiver digital bit list */
F_GET_RECEIVER_DBIT_LIST, /** < get receiver digital bit list */
F_RECEIVER_DBIT_OFFSET, /** < set/get reciever digital bit offset */
F_SET_RECEIVER_QUAD,
NUM_REC_FUNCTIONS
};
@ -231,6 +234,8 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_EXTERNAL_SAMPLING: return "F_EXTERNAL_SAMPLING";
case F_SET_STARTING_FRAME_NUMBER: return "F_SET_STARTING_FRAME_NUMBER";
case F_GET_STARTING_FRAME_NUMBER: return "F_GET_STARTING_FRAME_NUMBER";
case F_SET_QUAD: return "F_SET_QUAD";
case F_GET_QUAD: return "F_GET_QUAD";
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
@ -288,7 +293,8 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SET_RECEIVER_DBIT_LIST: return "F_SET_RECEIVER_DBIT_LIST";
case F_GET_RECEIVER_DBIT_LIST: return "F_GET_RECEIVER_DBIT_LIST";
case F_RECEIVER_DBIT_OFFSET: return "F_RECEIVER_DBIT_OFFSET";
case F_SET_RECEIVER_QUAD: return "F_SET_RECEIVER_QUAD";
case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS";
default: return "Unknown Function";
}

View File

@ -5,6 +5,6 @@
#define APIRECEIVER 0x190604
#define APIGUI 0x190405
#define APICTB 0x190604
#define APIEIGER 0x190712
#define APIGOTTHARD 0x190715
#define APIJUNGFRAU 0x190718
#define APIEIGER 0x190722