bottom is defined as flippeddatax in config file, not anymore as argument for receiver

This commit is contained in:
Dhanya Maliakal 2016-11-30 10:36:34 +01:00
parent 52dbb7f9fc
commit 466f1506a5
9 changed files with 179 additions and 22 deletions

View File

@ -75,6 +75,7 @@ using namespace std;
#define POWER_CHIP 0x0000000004000000ULL
#define RECEIVER_READ_TIMER 0x0000000008000000ULL
#define RECEIVER_ACQ_TIME_NOT_SET 0x0000000010000000ULL
#define RECEIVER_FLIPPED_DATA_NOT_SET 0x0000000020000000ULL
// 0x00000000FFFFFFFFULL
/** @short class returning all error messages for error mask */
@ -232,6 +233,9 @@ public:
if(slsErrorMask&RECEIVER_READ_TIMER)
retval.append("Could not set receiver read timer\n");
if(slsErrorMask&RECEIVER_FLIPPED_DATA_NOT_SET)
retval.append("Could not set receiver flipped data/bottom\n");
//------------------------------------------------------ length of message

View File

@ -1120,6 +1120,8 @@ int configureMAC(int ipad, long long int macad, long long int detectormacadd, in
int beb_num = BEB_NUM;//Feb_Control_GetModuleNumber();
int header_number = 0;
int dst_port = udpport;
if(!top)
dst_port = udpport2;
printf("dst_port:%d\n\n",dst_port);
@ -1133,6 +1135,8 @@ int configureMAC(int ipad, long long int macad, long long int detectormacadd, in
header_number = 32;
dst_port = udpport2;
if(!top)
dst_port = udpport;
printf("dst_port:%d\n\n",dst_port);
/*for(i=0;i<32;i++){*//** modified for Aldo*/

View File

@ -3794,6 +3794,20 @@ int multiSlsDetector::getMaxNumberOfModules(dimension d) {
}
int multiSlsDetector::getFlippedData(dimension d){
int ret=-100,ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++)
if (detectors[idet]){
ret1=detectors[idet]->getFlippedData(d);
if(ret==-100)
ret=ret1;
else if (ret!=ret1)
ret=-1;
}
return ret;
}
int multiSlsDetector::setNumberOfModules(int p, dimension d) {
int ret=0;//, ret1;
@ -3833,6 +3847,24 @@ int multiSlsDetector::setNumberOfModules(int p, dimension d) {
}
int multiSlsDetector::setFlippedData(dimension d, int value){
int ret=-100,ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++)
if (detectors[idet]){
ret1=detectors[idet]->setFlippedData(d,value);
if(ret==-100)
ret=ret1;
else if (ret!=ret1)
ret=-1;
}
return ret;
}
int multiSlsDetector::decodeNMod(int i, int &id, int &im) {
#ifdef VERBOSE
cout << " Module " << i << " belongs to detector " << id << endl;;
@ -5240,6 +5272,7 @@ void multiSlsDetector::readFrameFromReceiver(){
ny = getTotalNumberOfChannels(slsDetectorDefs::Y);
//calculating offsets (for eiger interleaving ports)
int offsetX[numSockets]; int offsetY[numSockets];
bool bottom[numSockets];
if(maxX){
for(int i=0; i<numSockets; ++i){
offsetY[i] = (maxY - (thisMultiDetector->offsetY[i/numSocketsPerSLSDetector] + slsmaxY)) * maxX * bytesperchannel;
@ -5249,6 +5282,7 @@ void multiSlsDetector::readFrameFromReceiver(){
else
offsetX[i] = thisMultiDetector->offsetX[i/numSocketsPerSLSDetector] + (slsmaxX/numSocketsPerSLSDetector);
offsetX[i] *= bytesperchannel;
bottom[i] = detectors[i/numSocketsPerSLSDetector]->getFlippedData(X);/*only for eiger*/
}
}
@ -5286,7 +5320,8 @@ void multiSlsDetector::readFrameFromReceiver(){
if(maxX){
//bottom
if((((isocket/numSocketsPerSLSDetector)+1)%2) == 0){
if(bottom[isocket]){
//if((((isocket/numSocketsPerSLSDetector)+1)%2) == 0){
for(int i=0;i<slsmaxY;++i){
memcpy(((char*)multiframe) + offsetY[isocket] + offsetX[isocket] + ((slsmaxY-1-i)*maxX*bytesperchannel),
(char*)image+ i*(slsmaxX/numSocketsPerSLSDetector)*bytesperchannel,

View File

@ -340,6 +340,12 @@ class multiSlsDetector : public slsDetectorUtils {
int getMaxNumberOfChannelsPerDetector(dimension d){return thisMultiDetector->maxNumberOfChannelsPerDetector[d];};
/** returns the enable if data will be flipped across x or y axis
* \param d axis across which data is flipped
* returns 1 or 0
*/
int getFlippedData(dimension d=X);
int setMaxNumberOfChannelsPerDetector(dimension d,int i){thisMultiDetector->maxNumberOfChannelsPerDetector[d]=i; return thisMultiDetector->maxNumberOfChannelsPerDetector[d];};
double getScanStep(int index, int istep){return thisMultiDetector->scanSteps[index][istep];};
@ -979,6 +985,14 @@ class multiSlsDetector : public slsDetectorUtils {
int configureMAC();
int setNumberOfModules(int i=-1, dimension d=X);
/** sets the enable which determines if data will be flipped across x or y axis
* \param d axis across which data is flipped
* \param value 0 or 1 to reset/set or -1 to get value
* \return enable flipped data across x or y axis
*/
int setFlippedData(dimension d=X, int value=-1);
int getMaxNumberOfModules(dimension d=X);
int setDynamicRange(int i=-1);

View File

@ -1826,6 +1826,57 @@ int slsDetector::getMaxNumberOfModules(dimension d){
int slsDetector::setFlippedData(dimension d, int value){
int retval=-1;
int fnum=F_SET_FLIPPED_DATA_RECEIVER;
int ret=FAIL;
char mess[MAX_STR_LENGTH]="";
int args[2]={X,-1};
if(thisDetector->myDetectorType!= EIGER){
std::cout << "Flipped Data is not implemented in this detector" << std::endl;
setErrorMask((getErrorMask())|(RECEIVER_FLIPPED_DATA_NOT_SET));
return -1;
}
#ifdef VERBOSE
std::cout << std::endl;
std::cout << "Setting/Getting flipped data across axis " << d <<" with value " << value << std::endl;
#endif
if(value > -1){
thisDetector->flippedData[d] = value;
args[1] = value;
}else
args[1] = thisDetector->flippedData[d];
args[0] = d;
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
if (connectData() == OK){
ret=thisReceiver->sendIntArray(fnum,retval,args);
disconnectData();
}
if((args[1] != retval && args[1]>=0) || (ret==FAIL)){
ret = FAIL;
setErrorMask((getErrorMask())|(RECEIVER_FLIPPED_DATA_NOT_SET));
}
if(ret==FORCE_UPDATE)
updateReceiver();
}
return thisDetector->flippedData[d];
}
/*
This function is used to set the polarity and meaning of the digital I/O signals (signal index)
@ -5601,8 +5652,10 @@ char* slsDetector::setReceiver(string receiverIP){
setTimer(FRAME_NUMBER,thisDetector->timerValue[FRAME_NUMBER]);
setTimer(ACQUISITION_TIME,thisDetector->timerValue[ACQUISITION_TIME]);
setDynamicRange(thisDetector->dynamicRange);
if(thisDetector->myDetectorType == EIGER)
if(thisDetector->myDetectorType == EIGER){
setFlippedData(X,-1);
activate(-1);
}
//std::cout << "***********************************dataStreaming:" << parentDet->enableDataStreamingFromReceiver(-1) << endl << endl;
//parentDet->enableDataStreamingFromReceiver(parentDet->enableDataStreamingFromReceiver(-1));
//set scan tag

View File

@ -267,6 +267,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
/** flag for acquiring */
bool acquiringFlag;
/** flipped data across x or y axis */
bool flippedData[2];
} sharedSlsDetector;
@ -657,6 +659,12 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
int getMaxNumberOfChannels(dimension d){return thisDetector->nChan[d]*thisDetector->nChip[d]*thisDetector->nModMax[d];};
/** returns the enable if data will be flipped across x or y axis
* \param d axis across which data is flipped
* returns 1 or 0
*/
int getFlippedData(dimension d=X){return thisDetector->flippedData[d];};
/** Returns number of rois */
int getNRoi(){return thisDetector->nROI;};
@ -722,6 +730,12 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
int setNumberOfModules(int n=GET_FLAG, dimension d=X); // if n=GET_FLAG returns the number of installed modules
/** sets the enable which determines if data will be flipped across x or y axis
* \param d axis across which data is flipped
* \param value 0 or 1 to reset/set or -1 to get value
* \return enable flipped data across x or y axis
*/
int setFlippedData(dimension d=X, int value=-1);
/*
@ -1585,18 +1599,6 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/
int resetFramesCaught();
/**
* Create Receiving Data Sockets
* @param destroy is true to destroy all the sockets
* @return OK or FAIL
*/
int createReceivingDataSockets(const bool destroy = false){return 0;};
/** Reads frames from receiver through a constant socket
*/
void readFrameFromReceiver(){};
/** Locks/Unlocks the connection to the receiver
/param lock sets (1), usets (0), gets (-1) the lock
/returns lock status of the receiver

View File

@ -432,7 +432,13 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDetectorSize;
i++;
descrToFuncMap[i].m_pFuncName="flippeddatax"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDetectorSize;
i++;
descrToFuncMap[i].m_pFuncName="flippeddatay"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDetectorSize;
i++;
/* flags */
@ -3136,7 +3142,7 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) {
if (action==HELP_ACTION)
return helpDetectorSize(narg,args,action);
int ret, val=-1, pos=-1,i;
char ans[1000], temp[100];
char ans[1000];
myDet->setOnline(ONLINE_FLAG);
@ -3173,6 +3179,21 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) {
myDet->setMaxNumberOfChannelsPerDetector(Y,val);
}
if(cmd=="flippeddatax"){
if ((!sscanf(args[1],"%d",&val)) || (val!=0 && val != 1))
return string ("cannot scan flippeddata x mode: must be 0 or 1");
myDet->setReceiverOnline(ONLINE_FLAG);
myDet->setFlippedData(X,val);
}
if(cmd=="flippeddatay"){
return string("Not required for this detector\n");
if ((!sscanf(args[1],"%d",&val)) || (val!=0 && val != 1))
return string ("cannot scan flippeddata y mode: must be 0 or 1");
myDet->setReceiverOnline(ONLINE_FLAG);
myDet->setFlippedData(Y,val);
}
}
if (cmd=="nmod" || cmd=="roimask") {
@ -3185,10 +3206,18 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) {
} else if (cmd=="roi") {
myDet->getROI(ret);
} else if (cmd=="detsizechan") {
sprintf(ans,"%d",myDet->getMaxNumberOfChannelsPerDetector(X));
sprintf(temp,"%d",myDet->getMaxNumberOfChannelsPerDetector(Y));
strcat(ans," ");
strcat(ans,temp);
sprintf(ans,"%d %d",myDet->getMaxNumberOfChannelsPerDetector(X),myDet->getMaxNumberOfChannelsPerDetector(Y));
return string(ans);
}
else if(cmd=="flippeddatax"){
myDet->setReceiverOnline(ONLINE_FLAG);
sprintf(ans,"%d",myDet->getFlippedData(X));
return string(ans);
}
else if(cmd=="flippeddatay"){
return string("Not required for this detector\n");
myDet->setReceiverOnline(ONLINE_FLAG);
sprintf(ans,"%d",myDet->getFlippedData(Y));
return string(ans);
}
else
@ -3212,6 +3241,8 @@ string slsDetectorCommand::helpDetectorSize(int narg, char *args[], 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 << "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;
}
if (action==GET_ACTION || action==HELP_ACTION) {
os << "nmod \n gets the number of modules of the detector"<< std::endl;
@ -3219,7 +3250,8 @@ string slsDetectorCommand::helpDetectorSize(int narg, char *args[], 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 << "flippeddatax\n gets if the data will be flipped on the x axis respectively"<< std::endl;
os << "flippeddatay\n gets if the data will be flipped on the y axis respectively"<< std::endl;
}
return os.str();

View File

@ -70,6 +70,13 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
virtual int setMaxNumberOfChannelsPerDetector(dimension d,int i){return -1;};
/** sets the enable which determines if data will be flipped across x or y axis
* \param d axis across which data is flipped
* \param value 0 or 1 to reset/set or -1 to get value
* \return enable flipped data across x or y axis
*/
virtual int setFlippedData(dimension d=X, int value=-1)=0;
//int setPositions(int nPos, double *pos){return angularConversion::setPositions(nPos, pos);};
// int getPositions(double *pos=NULL){return angularConversion::getPositions(pos);};
@ -425,6 +432,12 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
virtual int getMaxNumberOfChannels()=0;
virtual int getMaxNumberOfChannels(dimension d)=0;
/** returns the enable if data will be flipped across x or y axis
* \param d axis across which data is flipped
* returns 1 or 0
*/
virtual int getFlippedData(dimension d=X)=0;
// virtual int getParameters();
@ -660,12 +673,12 @@ virtual int resetFramesCaught()=0;
* @param destroy is true to destroy all the sockets
* @return OK or FAIL
*/
virtual int createReceivingDataSockets(const bool destroy = false)=0;
virtual int createReceivingDataSockets(const bool destroy = false){return -1;};
/** Reads frames from receiver through a constant socket
*/
virtual void readFrameFromReceiver()=0;
virtual void readFrameFromReceiver(){};
/**
Turns off the receiver server!