changed clock for jungfrau, maybe other debugging stuff outside this folder

This commit is contained in:
Dhanya Maliakal 2016-11-21 09:21:30 +01:00
parent ebf102b8d9
commit 9d106f6c93
4 changed files with 131 additions and 100 deletions

View File

@ -91,7 +91,7 @@ u_int32_t progressMask=0;
int phase_shift=0;//DEFAULT_PHASE_SHIFT; int phase_shift=0;//DEFAULT_PHASE_SHIFT;
int ipPacketSize=DEFAULT_IP_PACKETSIZE; int ipPacketSize=DEFAULT_IP_PACKETSIZE;
int udpPacketSize=DEFAULT_UDP_PACKETSIZE; int udpPacketSize=DEFAULT_UDP_PACKETSIZE;
int clockdivider = 20; int clockdivider = 40;
/* /*
#ifndef NEW_PLL_RECONFIG #ifndef NEW_PLL_RECONFIG
u_int32_t clkDivider[2]={32,16}; u_int32_t clkDivider[2]={32,16};

View File

@ -5105,16 +5105,15 @@ void multiSlsDetector::startReceivingDataThread(){
//initializations //initializations
int numReadoutPerDetector = 1; int numReadoutPerDetector = 1;
bool jungfrau = false; bool jungfrau = false;
int expectedsize = 1024*256;/**shouldnt work for other bit modes or anythign*/
if(getDetectorsType() == EIGER){ if(getDetectorsType() == EIGER){
numReadoutPerDetector = 2; numReadoutPerDetector = 2;
expectedsize = 1024*256;
}else if(getDetectorsType() == JUNGFRAU){ }else if(getDetectorsType() == JUNGFRAU){
jungfrau = true; jungfrau = true;
expectedsize = 8192*128; //expectedsize = 8192*128;
} }
int singleDatabytes = detectors[ithread/numReadoutPerDetector]->getDataBytes(); int singleDatabytes = detectors[ithread/numReadoutPerDetector]->getDataBytes();
int nel=(singleDatabytes/numReadoutPerDetector)/sizeof(int); int nel=(singleDatabytes/numReadoutPerDetector)/sizeof(int);
int expectedsize = singleDatabytes/numReadoutPerDetector;//8192*128; //1024*256
int* image = new int[nel]; int* image = new int[nel];
int len,idet = 0; int len,idet = 0;
singleframe[ithread]=NULL; singleframe[ithread]=NULL;
@ -5160,8 +5159,9 @@ void multiSlsDetector::startReceivingDataThread(){
//infinite loop, exited only (if gui restarted/ enabledatastreaming called) //infinite loop, exited only (if gui restarted/ enabledatastreaming called)
while(true){ while(true){
//cprintf(GREEN,"%d waiting to copy\n",ithread);
sem_wait(&sem_singlewait[ithread]); //wait for it to be copied sem_wait(&sem_singlewait[ithread]); //wait for it to be copied
//cprintf(GREEN,"%d gonna copy\n",ithread);
//check to exit thread //check to exit thread
if(killAllReceivingDataThreads) if(killAllReceivingDataThreads)
break; break;
@ -5210,8 +5210,14 @@ void multiSlsDetector::startReceivingDataThread(){
#endif #endif
if(currentFrameIndex ==-1) cprintf(RED,"multi frame index -1!!\n"); if(currentFrameIndex ==-1) cprintf(RED,"multi frame index -1!!\n");
} }
if(singleframe[ithread]==NULL){
singleDatabytes = detectors[ithread/numReadoutPerDetector]->getDataBytes();
nel=(singleDatabytes/numReadoutPerDetector)/sizeof(int);
delete [] image;
image = new int[nel];
expectedsize = singleDatabytes/numReadoutPerDetector;
}
singleframe[ithread]=image; singleframe[ithread]=image;
// close the message // close the message
zmq_msg_close(&message); zmq_msg_close(&message);
@ -5236,9 +5242,15 @@ void multiSlsDetector::startReceivingDataThread(){
else{ else{
//actual data //actual data
//cprintf(BLUE,"%d actual dataaa\n",ithread); //cprintf(BLUE,"%d actual dataaa\n",ithread);
//memset((char*)(singleframe[ithread]),0xFF,singleDatabytes/numReadoutPerDetector);
memcpy((char*)(singleframe[ithread]),(char*)zmq_msg_data(&message),singleDatabytes/numReadoutPerDetector); memcpy((char*)(singleframe[ithread]),(char*)zmq_msg_data(&message),singleDatabytes/numReadoutPerDetector);
//cprintf(GREEN,"%d copied data %d\n",ithread,singleDatabytes/numReadoutPerDetector);
if(!ithread){
for(int i=0;i<30;i++)
cprintf(BLUE,"value[%d]:%d\n",i,(short int)singleframe[ithread][i]);
}
//jungfrau masking adcval //jungfrau masking adcval
if(jungfrau){ if(jungfrau){
for(unsigned int i=0;i<nel;i++){ for(unsigned int i=0;i<nel;i++){
@ -5294,8 +5306,11 @@ void multiSlsDetector::readFrameFromReceiver(){
bytesperchannel = slsdatabytes/slsmaxchannels; bytesperchannel = slsdatabytes/slsmaxchannels;
slsmaxX = detectors[0]->getTotalNumberOfChannels(X); slsmaxX = detectors[0]->getTotalNumberOfChannels(X);
slsmaxY = detectors[0]->getTotalNumberOfChannels(Y); slsmaxY = detectors[0]->getTotalNumberOfChannels(Y);
//cprintf(BLUE,"slsdatabytes:%d slsmaxchannels:%d bytesperchannel:%d slsmaxX:%d slsmaxY:%d\n",
// slsdatabytes,slsmaxchannels,bytesperchannel,slsmaxX,slsmaxY);
} }
int nel=(thisMultiDetector->dataBytes)/sizeof(int); int nel=(thisMultiDetector->dataBytes)/sizeof(int);
//cprintf(BLUE,"multi databytes:%d\n",thisMultiDetector->dataBytes);
if(nel <= 0){ if(nel <= 0){
cprintf(RED,"Error: Multislsdetector databytes not valid : %d\n", thisMultiDetector->dataBytes); cprintf(RED,"Error: Multislsdetector databytes not valid : %d\n", thisMultiDetector->dataBytes);
return; return;
@ -5337,7 +5352,8 @@ void multiSlsDetector::readFrameFromReceiver(){
} }
//assemble data //assemble data
if(maxX){ //eiger, so interleaving between ports in one readout itself if(maxX){
//eiger, so interleaving between ports in one readout itself
offsetY = (maxY - (thisMultiDetector->offsetY[idet] + slsmaxY)) * maxX * bytesperchannel; offsetY = (maxY - (thisMultiDetector->offsetY[idet] + slsmaxY)) * maxX * bytesperchannel;
//the left half or right half //the left half or right half
if(!(ireadout%numReadoutPerDetector)) if(!(ireadout%numReadoutPerDetector))
@ -5345,24 +5361,34 @@ void multiSlsDetector::readFrameFromReceiver(){
else else
offsetX = thisMultiDetector->offsetX[idet] + halfreadoutoffset; offsetX = thisMultiDetector->offsetX[idet] + halfreadoutoffset;
offsetX *= bytesperchannel; offsetX *= bytesperchannel;
//cprintf(BLUE,"offsetx:%d offsety:%d maxx:%d slsmaxX:%d slsmaxY:%d bytesperchannel:%d\n", //cprintf(BLUE,"ireadout:%d, offsetx:%d offsety:%d maxx:%d slsmaxX:%d slsmaxY:%d bytesperchannel:%d\n",
// offsetX,offsetY,maxX,slsmaxX,slsmaxY,bytesperchannel); // ireadout, offsetX,offsetY,maxX,slsmaxX,slsmaxY,bytesperchannel);
// cprintf(BLUE,"copying bytes:%d\n", (slsmaxX/numReadoutPerDetector)*bytesperchannel); // cprintf(BLUE,"copying bytes:%d\n", (slsmaxX/numReadoutPerDetector)*bytesperchannel);
//itnerleaving with other detectors
//interleaving with other detectors
//bottom //bottom
if(((idet+1)%2) == 0){ if(((idet+1)%2) == 0){
for(int i=0;i<slsmaxY;++i) for(int i=0;i<slsmaxY;++i){
// cprintf(BLUE,"%d i:%d gonna copy sourceoffset:%d destoffset:%d\n",ireadout,i,
// i*(slsmaxX/numReadoutPerDetector)*bytesperchannel,
// offsetY + offsetX +((slsmaxY-i)*maxX*bytesperchannel));
memcpy(((char*)multiframe) + offsetY + offsetX + ((slsmaxY-i)*maxX*bytesperchannel), memcpy(((char*)multiframe) + offsetY + offsetX + ((slsmaxY-i)*maxX*bytesperchannel),
(char*)singleframe[ireadout]+ i*(slsmaxX/numReadoutPerDetector)*bytesperchannel, (char*)singleframe[ireadout]+ i*(slsmaxX/numReadoutPerDetector)*bytesperchannel,
(slsmaxX/numReadoutPerDetector)*bytesperchannel); (slsmaxX/numReadoutPerDetector)*bytesperchannel);
}
} }
//top //top
else{ else{
for(int i=0;i<slsmaxY;++i) for(int i=0;i<slsmaxY;++i){
//cprintf(BLUE,"%d i:%d gonna copy sourceoffset:%d destoffset:%d \n",ireadout,i,
// i*(slsmaxX/numReadoutPerDetector)*bytesperchannel,
// offsetY + offsetX + (i*maxX*bytesperchannel));
memcpy(((char*)multiframe) + offsetY + offsetX + (i*maxX*bytesperchannel), memcpy(((char*)multiframe) + offsetY + offsetX + (i*maxX*bytesperchannel),
(char*)singleframe[ireadout]+ i*(slsmaxX/numReadoutPerDetector)*bytesperchannel, (char*)singleframe[ireadout]+ i*(slsmaxX/numReadoutPerDetector)*bytesperchannel,
(slsmaxX/numReadoutPerDetector)*bytesperchannel); (slsmaxX/numReadoutPerDetector)*bytesperchannel);
}
} }
} }
//no interleaving, just add to the end //no interleaving, just add to the end

View File

@ -4855,103 +4855,108 @@ int slsDetector::executeTrimming(trimMode mode, int par1, int par2, int imod){
double* slsDetector::decodeData(int *datain, double *fdata) { double* slsDetector::decodeData(int *datain, double *fdata) {
double *dataout; double *dataout;
if (fdata) { if (fdata) {
dataout=fdata; dataout=fdata;
// printf("not allocating fdata!\n"); // printf("not allocating fdata!\n");
}
else {
dataout=new double[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
// printf("allocating fdata!\n");
}
const int bytesize=8;
int ival=0;
char *ptr=(char*)datain;
char iptr;
int nbits=thisDetector->dynamicRange;
int nch=thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;
int ipos=0, ichan=0, ibyte;
if (thisDetector->timerValue[PROBES_NUMBER]==0) {
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
for (ichan=0; ichan<nch; ichan++) {
// dataout[ichan]=0;
ival=0;
// for (ibyte=0; ibyte<2; ibyte++) {
ibyte=0;
iptr=ptr[ichan*2+ibyte];
ival|=((iptr<<(ibyte*bytesize))&(0xff<<(ibyte*bytesize)));
ibyte=1;
iptr=ptr[ichan*2+ibyte];
ival|=((iptr<<(ibyte*bytesize))&(0x3f<<(ibyte*bytesize)));
// }
dataout[ichan]=ival;
}
} else {
switch (nbits) {
case 1:
for (ibyte=0; ibyte<thisDetector->dataBytes; ibyte++) {
iptr=ptr[ibyte]&0x1;
for (ipos=0; ipos<8; ipos++) {
// dataout[ibyte*2+ichan]=((iptr&((0xf)<<ichan))>>ichan)&0xf;
ival=(iptr>>(ipos))&0x1;
dataout[ichan]=ival;
ichan++;
} }
} else {
break; dataout=new double[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
case 4: // printf("allocating fdata!\n");
for (ibyte=0; ibyte<thisDetector->dataBytes; ibyte++) {
iptr=ptr[ibyte]&0xff;
for (ipos=0; ipos<2; ipos++) {
// dataout[ibyte*2+ichan]=((iptr&((0xf)<<ichan))>>ichan)&0xf;
ival=(iptr>>(ipos*4))&0xf;
dataout[ichan]=ival;
ichan++;
} }
} const int bytesize=8;
break;
case 8: int ival=0;
for (ichan=0; ichan<thisDetector->dataBytes; ichan++) { char *ptr=(char*)datain;
ival=ptr[ichan]&0xff; char iptr;
dataout[ichan]=ival;
} int nbits=thisDetector->dynamicRange;
break; int nch=thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;
case 16: int ipos=0, ichan=0, ibyte;
for (ichan=0; ichan<nch; ichan++) {
// dataout[ichan]=0; if (thisDetector->timerValue[PROBES_NUMBER]==0) {
ival=0; if (thisDetector->myDetectorType==JUNGFRAUCTB) {
for (ibyte=0; ibyte<2; ibyte++) {
iptr=ptr[ichan*2+ibyte]; for (ichan=0; ichan<nch; ichan++) {
ival|=((iptr<<(ibyte*bytesize))&(0xff<<(ibyte*bytesize))); // dataout[ichan]=0;
ival=0;
// for (ibyte=0; ibyte<2; ibyte++) {
ibyte=0;
iptr=ptr[ichan*2+ibyte];
ival|=((iptr<<(ibyte*bytesize))&(0xff<<(ibyte*bytesize)));
ibyte=1;
iptr=ptr[ichan*2+ibyte];
ival|=((iptr<<(ibyte*bytesize))&(0x3f<<(ibyte*bytesize)));
// }
dataout[ichan]=ival;
}
} else {
switch (nbits) {
case 1:
for (ibyte=0; ibyte<thisDetector->dataBytes; ibyte++) {
iptr=ptr[ibyte]&0x1;
for (ipos=0; ipos<8; ipos++) {
// dataout[ibyte*2+ichan]=((iptr&((0xf)<<ichan))>>ichan)&0xf;
ival=(iptr>>(ipos))&0x1;
dataout[ichan]=ival;
ichan++;
}
}
break;
case 4:
for (ibyte=0; ibyte<thisDetector->dataBytes; ibyte++) {
iptr=ptr[ibyte]&0xff;
for (ipos=0; ipos<2; ipos++) {
// dataout[ibyte*2+ichan]=((iptr&((0xf)<<ichan))>>ichan)&0xf;
ival=(iptr>>(ipos*4))&0xf;
dataout[ichan]=ival;
ichan++;
}
}
break;
case 8:
for (ichan=0; ichan<thisDetector->dataBytes; ichan++) {
ival=ptr[ichan]&0xff;
dataout[ichan]=ival;
}
break;
case 16:
for (ichan=0; ichan<nch; ichan++) {
// dataout[ichan]=0;
ival=0;
for (ibyte=0; ibyte<2; ibyte++) {
iptr=ptr[ichan*2+ibyte];
ival|=((iptr<<(ibyte*bytesize))&(0xff<<(ibyte*bytesize)));
}
dataout[ichan]=ival;
}
break;
default:
if(thisDetector->myDetectorType == MYTHEN){
for (ichan=0; ichan<nch; ichan++) {
ival=datain[ichan]&0xffffff;
dataout[ichan]=ival;
}
}
for (ichan=0; ichan<nch; ichan++) {
dataout[ichan]=ival;
}
}
}
} else {
for (ichan=0; ichan<nch; ichan++) {
dataout[ichan]=datain[ichan];
}
} }
dataout[ichan]=ival;
}
break;
default:
for (ichan=0; ichan<nch; ichan++) {
ival=datain[ichan]&0xffffff;
dataout[ichan]=ival;
}
}
}
} else {
for (ichan=0; ichan<nch; ichan++) {
dataout[ichan]=datain[ichan];
}
}
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "decoded "<< ichan << " channels" << std::endl; std::cout<< "decoded "<< ichan << " channels" << std::endl;
#endif #endif
return dataout; return dataout;
} }
//Correction //Correction