mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 03:40:04 +02:00
changes for new chipterboard -now works with reduced dynamic range and analog/digital readout
This commit is contained in:
parent
988426dc96
commit
cb879c61ca
@ -328,20 +328,20 @@ int receiveData(int file_des, void* buf,int length, intType itype){
|
|||||||
int nreceiving;
|
int nreceiving;
|
||||||
int nreceived;
|
int nreceived;
|
||||||
if (file_des<0) return -1;
|
if (file_des<0) return -1;
|
||||||
#ifdef VERY_VERBOSE
|
//#ifdef VERY_VERBOSE
|
||||||
printf("want to receive %d Bytes\n", length);
|
printf("want to receive %d Bytes\n", length);
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
while(length>0){
|
while(length>0){
|
||||||
nreceiving = (length>send_rec_max_size) ? send_rec_max_size:length;
|
nreceiving = (length>send_rec_max_size) ? send_rec_max_size:length;
|
||||||
|
|
||||||
#ifdef VERY_VERBOSE
|
//#ifdef VERY_VERBOSE
|
||||||
printf("want to receive %d Bytes\n", nreceiving);
|
// printf("want to receive %d Bytes\n", nreceiving);
|
||||||
#endif
|
//#endif
|
||||||
nreceived = read(file_des,(char*)buf+total_received,nreceiving);
|
nreceived = read(file_des,(char*)buf+total_received,nreceiving);
|
||||||
#ifdef VERY_VERBOSE
|
//#ifdef VERY_VERBOSE
|
||||||
printf("read %d \n", nreceived);
|
// printf("read %d \n", nreceived);
|
||||||
#endif
|
//#endif
|
||||||
if(!nreceived) break;
|
if(!nreceived) break;
|
||||||
// if(nreceived<0) break;
|
// if(nreceived<0) break;
|
||||||
length-=nreceived;
|
length-=nreceived;
|
||||||
@ -349,9 +349,9 @@ int receiveData(int file_des, void* buf,int length, intType itype){
|
|||||||
// cout<<"nrec: "<<nreceived<<" waiting for ("<<length<<")"<<endl;
|
// cout<<"nrec: "<<nreceived<<" waiting for ("<<length<<")"<<endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VERY_VERBOSE
|
//#ifdef VERY_VERBOSE
|
||||||
printf("received %d Bytes\n", total_received);
|
// printf("received %d Bytes\n", total_received);
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
if (total_received>0)
|
if (total_received>0)
|
||||||
strcpy(thisClientIP,dummyClientIP);
|
strcpy(thisClientIP,dummyClientIP);
|
||||||
|
@ -453,7 +453,9 @@ enum readOutFlags {
|
|||||||
CONTINOUS_RO=0x4000,/**< pump-probe mode */
|
CONTINOUS_RO=0x4000,/**< pump-probe mode */
|
||||||
PARALLEL=0x10000,/**< eiger parallel mode */
|
PARALLEL=0x10000,/**< eiger parallel mode */
|
||||||
NONPARALLEL=0x20000,/**< eiger serial mode */
|
NONPARALLEL=0x20000,/**< eiger serial mode */
|
||||||
SAFE=0x40000/** <eiger safe mode */
|
SAFE=0x40000/**< eiger safe mode */,
|
||||||
|
DIGITAL_ONLY=0x80000, /** chiptest board read only digital bits (not adc values)*/
|
||||||
|
ANALOG_AND_DIGITAL=0x100000 /** chiptest board read adc values and digital bits digital bits */
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
trimming modes
|
trimming modes
|
||||||
|
@ -104,10 +104,16 @@ enum {
|
|||||||
F_GET_RATE_CORRECT, /** < get rate correction tau */
|
F_GET_RATE_CORRECT, /** < get rate correction tau */
|
||||||
|
|
||||||
F_ACTIVATE, /** < activate/deactivate readout */
|
F_ACTIVATE, /** < activate/deactivate readout */
|
||||||
F_SET_NETWORK_PARAMETER /**< set network parameters such as transmission delay, flow control */
|
F_SET_NETWORK_PARAMETER, /**< set network parameters such as transmission delay, flow control */
|
||||||
|
|
||||||
/* Always append functions hereafter!!! */
|
/* Always append functions hereafter!!! */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Always append functions before!!! */
|
||||||
|
TOO_MANY_FUNCTIONS_DEFINED=128 //you should get a compilation error if there are already so many functions defined. It conflicts with sls_receiver_funcs.h
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -131,6 +131,16 @@ extern int N_DAC;
|
|||||||
extern int N_ADC;
|
extern int N_ADC;
|
||||||
extern int N_CHANS;
|
extern int N_CHANS;
|
||||||
|
|
||||||
|
|
||||||
|
int analogEnable=1;
|
||||||
|
int digitalEnable=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int mapCSP0(void) {
|
int mapCSP0(void) {
|
||||||
printf("Mapping memory\n");
|
printf("Mapping memory\n");
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
@ -1002,6 +1012,51 @@ int setToT(int d) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* int setOutputMode(int d) { */
|
||||||
|
/* //int ret=0; */
|
||||||
|
/* int reg; */
|
||||||
|
/* int v; */
|
||||||
|
/* //#ifdef VERBOSE */
|
||||||
|
/* printf("Setting readout flags to to %d\n",d); */
|
||||||
|
/* //#endif */
|
||||||
|
/* reg=bus_r(CONFIG_REG); */
|
||||||
|
/* //#ifdef VERBOSE */
|
||||||
|
/* printf("Before: config reg is %x\n", reg); */
|
||||||
|
/* //#endif */
|
||||||
|
/* if (d>=0) { */
|
||||||
|
/* reg=reg & ~(3<<8); */
|
||||||
|
/* if (d==DIGITAL_ONLY) */
|
||||||
|
/* reg=reg | (3<<8); */
|
||||||
|
/* else if (d==ANALOG_AND_DIGITAL) */
|
||||||
|
/* reg=reg | (2<<8); */
|
||||||
|
|
||||||
|
/* bus_w(CONFIG_REG,reg); */
|
||||||
|
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
/* reg=bus_r(CONFIG_REG); */
|
||||||
|
/* //#ifdef VERBOSE */
|
||||||
|
/* printf("After: config reg is %x\n", reg); */
|
||||||
|
/* //#endif */
|
||||||
|
/* if ((reg&(2<<8))) { */
|
||||||
|
/* if (reg&(1<<8)) { */
|
||||||
|
/* digitalEnable=1; */
|
||||||
|
/* analogEnable=0; */
|
||||||
|
/* return DIGITAL_ONLY; */
|
||||||
|
/* } else { */
|
||||||
|
/* digitalEnable=1; */
|
||||||
|
/* analogEnable=0; */
|
||||||
|
/* return ANALOG_AND_DIGITAL; */
|
||||||
|
/* } */
|
||||||
|
/* } else */
|
||||||
|
/* if (reg&(1<<8)) */
|
||||||
|
/* return -1; */
|
||||||
|
/* else */
|
||||||
|
/* return NORMAL_READOUT; */
|
||||||
|
|
||||||
|
|
||||||
|
/* } */
|
||||||
|
|
||||||
int setContinousReadOut(int d) {
|
int setContinousReadOut(int d) {
|
||||||
//int ret=0;
|
//int ret=0;
|
||||||
int reg;
|
int reg;
|
||||||
@ -1012,6 +1067,9 @@ int setContinousReadOut(int d) {
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Before: Continous readout is %x\n", reg);
|
printf("Before: Continous readout is %x\n", reg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (d>0) {
|
if (d>0) {
|
||||||
bus_w(CONFIG_REG,reg|CONT_RO_ENABLE_BIT);
|
bus_w(CONFIG_REG,reg|CONT_RO_ENABLE_BIT);
|
||||||
} else if (d==0) {
|
} else if (d==0) {
|
||||||
@ -1030,12 +1088,12 @@ int setContinousReadOut(int d) {
|
|||||||
|
|
||||||
int startReceiver(int start) {
|
int startReceiver(int start) {
|
||||||
u_int32_t addr=CONFIG_REG;
|
u_int32_t addr=CONFIG_REG;
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
if(start)
|
if(start)
|
||||||
printf("Setting up detector to send to Receiver\n");
|
printf("Setting up detector to send to Receiver\n");
|
||||||
else
|
else
|
||||||
printf("Setting up detector to send to CPU\n");
|
printf("Setting up detector to send to CPU\n");
|
||||||
#endif
|
//#endif
|
||||||
int reg=bus_r(addr);
|
int reg=bus_r(addr);
|
||||||
//for start recever, write 0 and for stop, write 1
|
//for start recever, write 0 and for stop, write 1
|
||||||
if (!start)
|
if (!start)
|
||||||
@ -1049,10 +1107,13 @@ int startReceiver(int start) {
|
|||||||
//#endif
|
//#endif
|
||||||
int d =reg&GB10_NOT_CPU_BIT;
|
int d =reg&GB10_NOT_CPU_BIT;
|
||||||
if(d!=0) d=1;
|
if(d!=0) d=1;
|
||||||
|
|
||||||
|
printf("Value is %d expected %d\n", d, start);
|
||||||
|
|
||||||
if(d!=start)
|
if(d!=start)
|
||||||
return OK;
|
|
||||||
else
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
else
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1276,11 +1337,24 @@ int64_t setPeriod(int64_t value){
|
|||||||
printf("Period already even is %08llx\n ", value);
|
printf("Period already even is %08llx\n ", value);
|
||||||
|
|
||||||
|
|
||||||
return set64BitReg(value,SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG)/(1E-3*clkDivider[0]);//(1E-9*CLK_FREQ);
|
return set64BitReg(value,SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG)/(1E-3*clkDivider[1]);//(1E-9*CLK_FREQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int64_t getPeriod(){
|
int64_t getPeriod(){
|
||||||
return get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG)/(1E-3*clkDivider[0]);//(1E-9*CLK_FREQ);
|
return get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG)/(1E-3*clkDivider[1]);//(1E-9*CLK_FREQ);
|
||||||
|
}
|
||||||
|
int64_t setSamples(int64_t value){
|
||||||
|
if (value>=0) {
|
||||||
|
nSamples=value;
|
||||||
|
bus_w(NSAMPLES_REG,nSamples);
|
||||||
|
}
|
||||||
|
getDynamicRange();
|
||||||
|
allocateRAM();
|
||||||
|
//printf("Setting dataBytes to %d: dr %d; samples %d\n",dataBytes, dynamicRange, nSamples);
|
||||||
|
return nSamples;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t setDelay(int64_t value){
|
int64_t setDelay(int64_t value){
|
||||||
@ -1362,14 +1436,11 @@ int64_t getFramesFromStart(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ROI *setROI(int nroi,ROI* arg,int *retvalsize, int *ret) {
|
int setROI(int nroi,ROI* arg,int *retvalsize, int *ret) {
|
||||||
|
|
||||||
if(myDetectorType == JUNGFRAU)
|
|
||||||
cprintf(RED,"ROI Not implemented for Jungfrau yet\n");
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
|
|
||||||
ROI retval[MAX_ROIS];
|
|
||||||
|
// ROI retval[MAX_ROIS];
|
||||||
int i, ich;
|
int i, ich;
|
||||||
adcDisableMask=0xfffffffff; /*warning: integer constant is too large for ‘long’ type,warning: large integer implicitly truncated to unsigned type*/
|
adcDisableMask=0xfffffffff; /*warning: integer constant is too large for ‘long’ type,warning: large integer implicitly truncated to unsigned type*/
|
||||||
|
|
||||||
@ -1398,9 +1469,11 @@ ROI *setROI(int nroi,ROI* arg,int *retvalsize, int *ret) {
|
|||||||
|
|
||||||
printf("read adc disable mask %08x\n",adcDisableMask);
|
printf("read adc disable mask %08x\n",adcDisableMask);
|
||||||
*retvalsize=0;
|
*retvalsize=0;
|
||||||
retval[0].xmin=0;
|
if (adcDisableMask==0) return *retvalsize;
|
||||||
retval[0].xmax=0;
|
arg[0].xmin=0;
|
||||||
|
arg[0].xmax=0;
|
||||||
for (ich=0 ; ich<N_CHAN ; ich++) {
|
for (ich=0 ; ich<N_CHAN ; ich++) {
|
||||||
|
|
||||||
if ((~adcDisableMask)&(1<<ich)) {
|
if ((~adcDisableMask)&(1<<ich)) {
|
||||||
if (ich==0) {
|
if (ich==0) {
|
||||||
*retvalsize+=1;
|
*retvalsize+=1;
|
||||||
@ -1408,23 +1481,29 @@ ROI *setROI(int nroi,ROI* arg,int *retvalsize, int *ret) {
|
|||||||
*retvalsize-=1;
|
*retvalsize-=1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
retval[*retvalsize-1].xmin=ich;
|
arg[*retvalsize-1].xmin=ich;
|
||||||
retval[*retvalsize-1].xmax=ich;
|
arg[*retvalsize-1].xmax=ich;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if ((adcDisableMask)&(1<<(ich-1))) {
|
if ((adcDisableMask)&(1<<(ich-1))) {
|
||||||
*retvalsize+=1;
|
*retvalsize+=1;
|
||||||
if (*retvalsize>MAX_ROIS) {
|
if (*retvalsize>MAX_ROIS) {
|
||||||
*retvalsize-=1;
|
*retvalsize-=1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
retval[*retvalsize-1].xmin=ich;
|
arg[*retvalsize-1].xmin=ich;
|
||||||
}
|
}
|
||||||
retval[*retvalsize-1].xmax=ich;
|
arg[*retvalsize-1].xmax=ich;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (ich=0; ich<*retvalsize; ich++) {
|
||||||
|
printf("%d xmin %d xmax %d\n", ich, arg[ich].xmin, arg[ich].xmax);
|
||||||
|
}
|
||||||
|
|
||||||
getDynamicRange();
|
getDynamicRange();
|
||||||
return retval;/*warning: function returns address of local variable*/
|
return *retvalsize;/*warning: function returns address of local variable*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2032,21 +2111,11 @@ u_int32_t fifo_full(void)
|
|||||||
|
|
||||||
u_int16_t* fifo_read_event(int ns)
|
u_int16_t* fifo_read_event(int ns)
|
||||||
{
|
{
|
||||||
int i=0;//, j=0;
|
int i=0, j, mask=1;
|
||||||
/* volatile u_int16_t volatile *dum; */
|
|
||||||
volatile u_int16_t a;
|
volatile u_int16_t a;
|
||||||
/*volatile u_int32_t val;*/
|
bus_w16(DUMMY_REG,0);
|
||||||
// volatile u_int32_t volatile *dum;
|
|
||||||
// volatile u_int32_t a;
|
|
||||||
|
|
||||||
bus_w16(DUMMY_REG,0); //
|
|
||||||
/* #ifdef TIMEDBG */
|
|
||||||
/* gettimeofday(&tse,NULL); */
|
|
||||||
/* #endif */
|
|
||||||
if (ns==0) {
|
if (ns==0) {
|
||||||
a=bus_r16(LOOK_AT_ME_REG);
|
a=bus_r16(LOOK_AT_ME_REG);
|
||||||
// volatile u_int32_t t = bus_r16(LOOK_AT_ME_REG);
|
|
||||||
// bus_w(DUMMY_REG,0);
|
|
||||||
while(a==0) {
|
while(a==0) {
|
||||||
if (runBusy()==0) {
|
if (runBusy()==0) {
|
||||||
a = bus_r(LOOK_AT_ME_REG);
|
a = bus_r(LOOK_AT_ME_REG);
|
||||||
@ -2055,13 +2124,12 @@ u_int16_t* fifo_read_event(int ns)
|
|||||||
printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
// printf("status idle, look at me %x status %x\n", bus_r(LOOK_AT_ME_REG),runState());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a = bus_r(LOOK_AT_ME_REG);
|
a = bus_r(LOOK_AT_ME_REG);
|
||||||
//#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
printf(".");
|
//printf(".");
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
/* #ifdef TIMEDBG */
|
/* #ifdef TIMEDBG */
|
||||||
@ -2073,15 +2141,12 @@ u_int16_t* fifo_read_event(int ns)
|
|||||||
|
|
||||||
// printf("LAM: %08x\n",a);
|
// printf("LAM: %08x\n",a);
|
||||||
}
|
}
|
||||||
// printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
|
||||||
/* dma_memcpy(now_ptr,values ,dataBytes); */
|
|
||||||
/* #else */
|
|
||||||
|
|
||||||
a = bus_r(LOOK_AT_ME_REG);
|
a = bus_r(LOOK_AT_ME_REG);
|
||||||
//#ifdef VERBOSE
|
|
||||||
// printf("%d %08x\n",ns,a);
|
|
||||||
bus_w16(DUMMY_REG,1<<8); // read strobe to all fifos
|
|
||||||
|
|
||||||
|
if (analogEnable) {
|
||||||
|
bus_w16(DUMMY_REG,1<<8); // read strobe to all fifos
|
||||||
bus_w16(DUMMY_REG,0);
|
bus_w16(DUMMY_REG,0);
|
||||||
|
|
||||||
/* for (i=0; i<32; i++) { */
|
/* for (i=0; i<32; i++) { */
|
||||||
@ -2103,22 +2168,16 @@ u_int16_t* fifo_read_event(int ns)
|
|||||||
/* bus_w16(DUMMY_REG,i); */
|
/* bus_w16(DUMMY_REG,i); */
|
||||||
/* } */
|
/* } */
|
||||||
/* val=*values; */
|
/* val=*values; */
|
||||||
|
//printf("sample %d ",ns);
|
||||||
|
|
||||||
// bus_w16(DUMMY_REG,0); //
|
// bus_w16(DUMMY_REG,0); //
|
||||||
for (i=0; i<32; i++) {
|
for (i=0; i<32; i++) {
|
||||||
|
|
||||||
|
|
||||||
// bus_w16(DUMMY_REG,i);
|
|
||||||
// bus_r16(DUMMY_REG);
|
|
||||||
/* dum=(((u_int16_t*)(now_ptr))+i); */
|
|
||||||
/* *dum=bus_r16(FIFO_DATA_REG); */
|
|
||||||
/* a=bus_r16(FIFO_DATA_REG); */
|
|
||||||
//dum=(((u_int32_t*)(now_ptr))+i);
|
|
||||||
|
|
||||||
// a=*values;//bus_r(FIFO_DATA_REG);
|
|
||||||
// if ((adcDisableMask&(3<<(i*2)))==0) {
|
if (~(mask&adcDisableMask)) {
|
||||||
*((u_int16_t*)now_ptr)=bus_r16(FIFO_DATA_REG);//*values;//bus_r(FIFO_DATA_REG);
|
*((u_int16_t*)now_ptr)=*values;//bus_r16(FIFO_DATA_REG);//*values;//bus_r(FIFO_DATA_REG);
|
||||||
|
|
||||||
|
|
||||||
if (i!=0 || ns!=0) {
|
if (i!=0 || ns!=0) {
|
||||||
@ -2126,19 +2185,15 @@ u_int16_t* fifo_read_event(int ns)
|
|||||||
while (*((u_int16_t*)now_ptr)==*((u_int16_t*)(now_ptr)-1) && a++<10) {
|
while (*((u_int16_t*)now_ptr)==*((u_int16_t*)(now_ptr)-1) && a++<10) {
|
||||||
|
|
||||||
// printf("******************** %d: fifo %d: new %08x old %08x\n ",ns, i, *((u_int32_t*)now_ptr),*((u_int32_t*)(now_ptr)-1));
|
// printf("******************** %d: fifo %d: new %08x old %08x\n ",ns, i, *((u_int32_t*)now_ptr),*((u_int32_t*)(now_ptr)-1));
|
||||||
*((u_int16_t*)now_ptr)=bus_r16(FIFO_DATA_REG);//*values;
|
*((u_int16_t*)now_ptr)=*values;
|
||||||
// printf("%d-",i);
|
// printf(".",i);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
now_ptr+=2;//4;
|
now_ptr+=2;
|
||||||
// }
|
}
|
||||||
/* while (((adcDisableMask&(3<<((i+1)*2)))>>((i+1)*2))==3) { */
|
mask=mask<<1;
|
||||||
/* i++; */
|
// if (~(mask&adcDisableMask)
|
||||||
/* } */
|
|
||||||
|
|
||||||
// if (((adcDisableMask&(3<<((i+1)*2)))>>((i+1)*2))!=3) {
|
|
||||||
|
|
||||||
bus_w16(DUMMY_REG,i+1);
|
bus_w16(DUMMY_REG,i+1);
|
||||||
|
|
||||||
// a = bus_r(LOOK_AT_ME_REG);
|
// a = bus_r(LOOK_AT_ME_REG);
|
||||||
@ -2146,6 +2201,15 @@ u_int16_t* fifo_read_event(int ns)
|
|||||||
//#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
// }
|
// }
|
||||||
// *(((u_int16_t*)(now_ptr))+i)=bus_r16(FIFO_DATA_REG);
|
// *(((u_int16_t*)(now_ptr))+i)=bus_r16(FIFO_DATA_REG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (digitalEnable) {
|
||||||
|
|
||||||
|
bus_w16(DUMMY_REG,1<<9); // read strobe to digital fifo
|
||||||
|
bus_w16(DUMMY_REG,0<<9); // read strobe to digital fifo
|
||||||
|
*((u_int64_t*)now_ptr)=get64BitReg(FIFO_DIGITAL_DATA_LSB_REG,FIFO_DIGITAL_DATA_MSB_REG);
|
||||||
|
now_ptr+=8;
|
||||||
|
|
||||||
}
|
}
|
||||||
// bus_w16(DUMMY_REG,0); //
|
// bus_w16(DUMMY_REG,0); //
|
||||||
/* #ifdef TIMEDBG */
|
/* #ifdef TIMEDBG */
|
||||||
@ -2157,6 +2221,7 @@ u_int16_t* fifo_read_event(int ns)
|
|||||||
//#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
// printf("*");
|
// printf("*");
|
||||||
//#endif
|
//#endif
|
||||||
|
// printf("\n");
|
||||||
return ram_values;
|
return ram_values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2302,8 +2367,9 @@ int getDynamicRange() {
|
|||||||
|
|
||||||
nSamples=bus_r(NSAMPLES_REG);
|
nSamples=bus_r(NSAMPLES_REG);
|
||||||
getChannels();
|
getChannels();
|
||||||
dataBytes=nModX*N_CHIP*getChannels()*2;
|
dataBytes=nModX*N_CHIP*getChannels()*2*nSamples;
|
||||||
return dynamicRange*bus_r(NSAMPLES_REG);//nSamples;
|
printf("data bytes is:%d\n",dataBytes);
|
||||||
|
return dynamicRange;//nSamples;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testBus() {
|
int testBus() {
|
||||||
@ -2349,11 +2415,17 @@ int setStoreInRAM(int b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int getChannels() {
|
int getChannels() {
|
||||||
int nch=32;
|
int nch=0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (analogEnable) {
|
||||||
|
nch+=32;
|
||||||
for (i=0; i<N_CHAN; i++) {
|
for (i=0; i<N_CHAN; i++) {
|
||||||
if (adcDisableMask & (1<<i)) nch--;
|
if (adcDisableMask & (1<<i)) nch--;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (digitalEnable)
|
||||||
|
nch+=4;
|
||||||
return nch;
|
return nch;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2362,7 +2434,7 @@ int allocateRAM() {
|
|||||||
getDynamicRange();
|
getDynamicRange();
|
||||||
|
|
||||||
//adcDisableMask
|
//adcDisableMask
|
||||||
size=dataBytes*nSamples;
|
size=dataBytes;//*nSamples
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("\nnmodx=%d nmody=%d dynamicRange=%d dataBytes=%d nFrames=%d nTrains=%d, size=%d\n",nModX,nModY,dynamicRange,dataBytes,nf,nt,(int)size );
|
printf("\nnmodx=%d nmody=%d dynamicRange=%d dataBytes=%d nFrames=%d nTrains=%d, size=%d\n",nModX,nModY,dynamicRange,dataBytes,nf,nt,(int)size );
|
||||||
@ -2460,43 +2532,133 @@ int writeADC(int addr, int val) {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int prepareSlowADC() {
|
int prepareSlowADCSeq() {
|
||||||
|
|
||||||
|
u_int16_t vv=0x3c40;
|
||||||
|
u_int16_t codata=( 1<<13) | (7<<10) | (7<<7) | (1<<6) | (0<<3) | (2<<1) | 1;
|
||||||
u_int16_t vv;
|
|
||||||
u_int16_t codata;
|
|
||||||
|
|
||||||
u_int32_t valw;
|
u_int32_t valw;
|
||||||
int i, j;
|
int i, obit, ibit;
|
||||||
|
|
||||||
int cnv_bit=16, sdi_bit=17, sck_bit=18;
|
int cnv_bit=16, sdi_bit=17, sck_bit=18;
|
||||||
|
|
||||||
for (j=0; j<2; j++) {
|
|
||||||
|
int oval=0;
|
||||||
|
|
||||||
|
|
||||||
valw=(1<<cnv_bit) | (1<<sdi_bit);
|
printf("Codata is %04x\n",codata);
|
||||||
|
|
||||||
|
/* //convert */
|
||||||
|
valw=(1<<cnv_bit);
|
||||||
bus_w(ADC_WRITE_REG,valw);
|
bus_w(ADC_WRITE_REG,valw);
|
||||||
|
|
||||||
usleep(20);
|
usleep(20);
|
||||||
|
|
||||||
valw=(1<<sdi_bit);
|
valw=0;
|
||||||
bus_w(ADC_WRITE_REG,(valw));
|
bus_w(ADC_WRITE_REG,(valw));
|
||||||
|
|
||||||
|
usleep(20);
|
||||||
|
|
||||||
|
for (ibit=0; ibit<14; ibit++) {
|
||||||
|
obit=((codata >> (13-ibit)) & 1);
|
||||||
|
// printf("%d",obit);
|
||||||
|
valw = obit << sdi_bit;
|
||||||
|
|
||||||
|
|
||||||
for (i=0;i<16;i++) {
|
|
||||||
//cldwn
|
|
||||||
valw=0;
|
|
||||||
bus_w(ADC_WRITE_REG,valw);
|
bus_w(ADC_WRITE_REG,valw);
|
||||||
// usleep(0);
|
|
||||||
|
usleep(20);
|
||||||
|
|
||||||
bus_w(ADC_WRITE_REG,valw|(1<<sck_bit));
|
bus_w(ADC_WRITE_REG,valw|(1<<sck_bit));
|
||||||
// usleep(0);
|
|
||||||
|
usleep(20);
|
||||||
|
|
||||||
bus_w(ADC_WRITE_REG,valw);
|
bus_w(ADC_WRITE_REG,valw);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// printf("\n");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bus_w(ADC_WRITE_REG,0);
|
||||||
|
|
||||||
|
/* //convert */
|
||||||
|
valw=(1<<cnv_bit);
|
||||||
|
bus_w(ADC_WRITE_REG,valw);
|
||||||
|
|
||||||
|
usleep(20);
|
||||||
|
|
||||||
|
valw=0;
|
||||||
|
bus_w(ADC_WRITE_REG,(valw));
|
||||||
|
|
||||||
|
usleep(20);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int prepareSlowADC(int ichan) {
|
||||||
|
|
||||||
|
u_int16_t vv=0x3c40;
|
||||||
|
// u_int16_t codata=( 1<<13) | (7<<10) | (7<<7) | (1<<6) | (0<<3) | (2<<1) | 1;
|
||||||
|
|
||||||
|
u_int16_t codata=(1<<13) | (7<<10) | (ichan<<7) | (1<<6) | (0<<3) | (0<<1) | 1; //read single channel
|
||||||
|
if (ichan<0) codata=( 1<<13) | (3<<10) | (7<7) | (1<<6) | (0<<3) | (0<<1) | 1;
|
||||||
|
|
||||||
|
u_int32_t valw;
|
||||||
|
int i, obit, ibit;
|
||||||
|
|
||||||
|
int cnv_bit=16, sdi_bit=17, sck_bit=18;
|
||||||
|
|
||||||
|
|
||||||
|
int oval=0;
|
||||||
|
|
||||||
|
|
||||||
|
printf("Codata is %04x\n",codata);
|
||||||
|
|
||||||
|
/* //convert */
|
||||||
|
valw=(1<<cnv_bit);
|
||||||
|
bus_w(ADC_WRITE_REG,valw);
|
||||||
|
|
||||||
|
usleep(20);
|
||||||
|
|
||||||
|
valw=0;
|
||||||
|
bus_w(ADC_WRITE_REG,(valw));
|
||||||
|
|
||||||
|
usleep(20);
|
||||||
|
|
||||||
|
for (ibit=0; ibit<14; ibit++) {
|
||||||
|
obit=((codata >> (13-ibit)) & 1);
|
||||||
|
// printf("%d",obit);
|
||||||
|
valw = obit << sdi_bit;
|
||||||
|
|
||||||
|
bus_w(ADC_WRITE_REG,valw);
|
||||||
|
|
||||||
|
usleep(20);
|
||||||
|
|
||||||
|
bus_w(ADC_WRITE_REG,valw|(1<<sck_bit));
|
||||||
|
|
||||||
|
usleep(20);
|
||||||
|
|
||||||
|
bus_w(ADC_WRITE_REG,valw);
|
||||||
|
|
||||||
|
}
|
||||||
|
// printf("\n");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bus_w(ADC_WRITE_REG,0);
|
||||||
|
|
||||||
|
/* //convert */
|
||||||
|
valw=(1<<cnv_bit);
|
||||||
|
bus_w(ADC_WRITE_REG,valw);
|
||||||
|
|
||||||
|
usleep(20);
|
||||||
|
|
||||||
|
valw=0;
|
||||||
|
bus_w(ADC_WRITE_REG,(valw));
|
||||||
|
|
||||||
|
usleep(20);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2506,48 +2668,104 @@ int readSlowADC(int ichan) {
|
|||||||
|
|
||||||
|
|
||||||
u_int16_t vv=0x3c40;
|
u_int16_t vv=0x3c40;
|
||||||
u_int16_t codata=vv | (ichan<<7);
|
// u_int16_t codata=( 1<<13) | (7<<10) | (ichan<<7) | (1<<6) | (0<<3) | (0<<1) | 1; //read single channel
|
||||||
|
|
||||||
u_int32_t valw;
|
u_int32_t valw;
|
||||||
int i, obit;
|
int i, obit, ibit;
|
||||||
|
|
||||||
int cnv_bit=16, sdi_bit=17, sck_bit=18;
|
int cnv_bit=16, sdi_bit=17, sck_bit=18;
|
||||||
|
|
||||||
|
|
||||||
|
int oval=0;
|
||||||
|
|
||||||
|
printf("DAC index is %d\n",ichan);
|
||||||
|
|
||||||
|
if (ichan<-1 || ichan>7)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
for (ichan=0; ichan<8; ichan++) {
|
prepareSlowADC(ichan);
|
||||||
|
|
||||||
//convert
|
|
||||||
|
/* printf("Codata is %04x\n",codata); */
|
||||||
|
|
||||||
|
/* /\* //convert *\/ */
|
||||||
|
/* valw=(1<<cnv_bit); */
|
||||||
|
/* bus_w(ADC_WRITE_REG,valw); */
|
||||||
|
|
||||||
|
/* usleep(20); */
|
||||||
|
|
||||||
|
/* valw=0; */
|
||||||
|
/* bus_w(ADC_WRITE_REG,(valw)); */
|
||||||
|
|
||||||
|
/* usleep(20); */
|
||||||
|
|
||||||
|
/* for (ibit=0; ibit<14; ibit++) { */
|
||||||
|
/* obit=((codata >> (13-ibit)) & 1); */
|
||||||
|
/* // printf("%d",obit); */
|
||||||
|
/* valw = obit << sdi_bit; */
|
||||||
|
|
||||||
|
/* bus_w(ADC_WRITE_REG,valw); */
|
||||||
|
|
||||||
|
/* usleep(20); */
|
||||||
|
|
||||||
|
/* bus_w(ADC_WRITE_REG,valw|(1<<sck_bit)); */
|
||||||
|
|
||||||
|
/* usleep(20); */
|
||||||
|
|
||||||
|
/* bus_w(ADC_WRITE_REG,valw); */
|
||||||
|
|
||||||
|
/* } */
|
||||||
|
/* // printf("\n"); */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* bus_w(ADC_WRITE_REG,0); */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (ichan=0; ichan<9; ichan++) {
|
||||||
|
|
||||||
|
|
||||||
|
/* //convert */
|
||||||
valw=(1<<cnv_bit);
|
valw=(1<<cnv_bit);
|
||||||
bus_w(ADC_WRITE_REG,valw);
|
bus_w(ADC_WRITE_REG,valw);
|
||||||
|
|
||||||
usleep(20);
|
usleep(20);
|
||||||
|
|
||||||
valw=(1<<sdi_bit);
|
valw=0;
|
||||||
bus_w(ADC_WRITE_REG,(valw));
|
bus_w(ADC_WRITE_REG,(valw));
|
||||||
|
|
||||||
|
|
||||||
printf("Channel %d ",ichan);
|
usleep(20);
|
||||||
|
// printf("Channel %d ",ichan);
|
||||||
//read
|
//read
|
||||||
|
oval=0;
|
||||||
for (i=0;i<16;i++) {
|
for (i=0;i<16;i++) {
|
||||||
//cldwn
|
//cldwn
|
||||||
valw=0;
|
valw=0;
|
||||||
bus_w(ADC_WRITE_REG,valw);
|
bus_w(ADC_WRITE_REG,valw);
|
||||||
// usleep(0);
|
|
||||||
bus_w(ADC_WRITE_REG,valw|(1<<sck_bit));
|
bus_w(ADC_WRITE_REG,valw|(1<<sck_bit));
|
||||||
|
usleep(20);
|
||||||
bus_w(ADC_WRITE_REG,valw);
|
bus_w(ADC_WRITE_REG,valw);
|
||||||
|
usleep(20);
|
||||||
|
|
||||||
obit=bus_r16(SLOW_ADC_REG)&0x1;
|
obit=bus_r16(SLOW_ADC_REG)&0x1;
|
||||||
printf("%d",obit);
|
// printf("%d",obit);
|
||||||
//write data (i)
|
//write data (i)
|
||||||
// usleep(0);
|
// usleep(0);
|
||||||
|
oval|=obit<<(15-i);
|
||||||
|
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\t");
|
||||||
|
printf("Value %d is %d\n",ichan, oval);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
|
||||||
|
return 2500*oval/65535;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3502,7 +3720,9 @@ int setPower(int ind, int val) {
|
|||||||
if (pwrindex>=0) {
|
if (pwrindex>=0) {
|
||||||
if (bus_r(POWER_ON_REG)&(1<<(16+pwrindex))){
|
if (bus_r(POWER_ON_REG)&(1<<(16+pwrindex))){
|
||||||
vmax=2700-(getDacRegister(19)*1000)/4095-200;
|
vmax=2700-(getDacRegister(19)*1000)/4095-200;
|
||||||
|
printf("Vchip id %d mV\n",vmax+200);
|
||||||
retval1=vmax-(retval*(vmax-vmin))/4095;
|
retval1=vmax-(retval*(vmax-vmin))/4095;
|
||||||
|
printf("Vdac id %d mV\n",retval1);
|
||||||
if (retval1>vmax)
|
if (retval1>vmax)
|
||||||
retval1=vmax;
|
retval1=vmax;
|
||||||
if (retval1<vmin)
|
if (retval1<vmin)
|
||||||
@ -3512,9 +3732,10 @@ int setPower(int ind, int val) {
|
|||||||
} else
|
} else
|
||||||
retval1=0;
|
retval1=0;
|
||||||
} else {
|
} else {
|
||||||
if (retval>=0)
|
if (retval>=0) {
|
||||||
retval1=2700-(retval*1000)/4095;
|
retval1=2700-(retval*1000)/4095;
|
||||||
else
|
printf("Vchip id %d mV\n",vmax);
|
||||||
|
} else
|
||||||
retval1=-1;
|
retval1=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3762,3 +3983,53 @@ int setDac(int dacnum,int dacvalue){
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int setReadOutMode(int arg) {
|
||||||
|
|
||||||
|
//#define ADC_OUTPUT_DISABLE_BIT 0x00100
|
||||||
|
//#define DIGITAL_OUTPUT_ENABLE_BIT 0x00200
|
||||||
|
int v=bus_r(CONFIG_REG)&(~ADC_OUTPUT_DISABLE_BIT)&(~DIGITAL_OUTPUT_ENABLE_BIT);
|
||||||
|
int v1;
|
||||||
|
printf("before: %x %x\n",bus_r(CONFIG_REG),v);
|
||||||
|
switch (arg) {
|
||||||
|
case NORMAL_READOUT:
|
||||||
|
bus_w(CONFIG_REG, v);
|
||||||
|
break;
|
||||||
|
case DIGITAL_ONLY:
|
||||||
|
bus_w(CONFIG_REG,v|ADC_OUTPUT_DISABLE_BIT|DIGITAL_OUTPUT_ENABLE_BIT);
|
||||||
|
break;
|
||||||
|
case ANALOG_AND_DIGITAL:
|
||||||
|
bus_w(CONFIG_REG,v|DIGITAL_OUTPUT_ENABLE_BIT);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("after: %x\n",bus_r(CONFIG_REG));
|
||||||
|
|
||||||
|
switch((bus_r(CONFIG_REG)>>8)&0x3) {
|
||||||
|
case 0:
|
||||||
|
analogEnable=1;
|
||||||
|
digitalEnable=0;
|
||||||
|
v1=NORMAL_READOUT;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
analogEnable=0;
|
||||||
|
digitalEnable=1;
|
||||||
|
v1=DIGITAL_ONLY;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
analogEnable=1;
|
||||||
|
digitalEnable=1;
|
||||||
|
v1=ANALOG_AND_DIGITAL;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("Unknown readout mode for analog and digital fifos %d\n",(bus_r(CONFIG_REG)>>8)&0x3);
|
||||||
|
v1=GET_READOUT_FLAGS;
|
||||||
|
}
|
||||||
|
getDynamicRange();
|
||||||
|
allocateRAM();
|
||||||
|
printf("dataBytes is %d\n",dataBytes);
|
||||||
|
return v1;
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -184,7 +184,7 @@ int setDac(int dacnum,int dacvalue);
|
|||||||
|
|
||||||
int setPower(int ind, int val);
|
int setPower(int ind, int val);
|
||||||
|
|
||||||
ROI *setROI(int nroi,ROI* arg,int *retvalsize, int *ret);
|
int setROI(int nroi,ROI* arg,int *retvalsize, int *ret);
|
||||||
int getChannels();
|
int getChannels();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -211,5 +211,9 @@ int calibration_sensor(int num, int *values, int *dacs) ;
|
|||||||
int calibration_chip(int num, int *values, int *dacs);
|
int calibration_chip(int num, int *values, int *dacs);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
int64_t setSamples(int64_t value);
|
||||||
|
//int setOutputMode(int d);
|
||||||
|
int prepareSlowADCSeq();
|
||||||
|
int readSlowADC(int ichan);
|
||||||
|
int setReadOutMode(int arg);
|
||||||
#endif
|
#endif
|
||||||
|
Binary file not shown.
@ -75,6 +75,9 @@
|
|||||||
#define FIFO_DATA_REG 6<<11
|
#define FIFO_DATA_REG 6<<11
|
||||||
#define FIFO_STATUS_REG 7<<11
|
#define FIFO_STATUS_REG 7<<11
|
||||||
|
|
||||||
|
// constant FifoDigitalInReg_c : integer := 60;
|
||||||
|
#define FIFO_DIGITAL_DATA_LSB_REG 60<<11
|
||||||
|
#define FIFO_DIGITAL_DATA_MSB_REG 61<<11
|
||||||
|
|
||||||
#define FIFO_DATA_REG_OFF 0x50<<11 ///////
|
#define FIFO_DATA_REG_OFF 0x50<<11 ///////
|
||||||
//to read back dac registers
|
//to read back dac registers
|
||||||
@ -94,7 +97,7 @@
|
|||||||
#define GET_ACTUAL_TIME_MSB_REG 17<<11
|
#define GET_ACTUAL_TIME_MSB_REG 17<<11
|
||||||
|
|
||||||
#define GET_MEASUREMENT_TIME_LSB_REG 38<<11
|
#define GET_MEASUREMENT_TIME_LSB_REG 38<<11
|
||||||
#define GET_MEASUREMENT_TIME_MSB_REG 38<<11
|
#define GET_MEASUREMENT_TIME_MSB_REG 39<<11
|
||||||
|
|
||||||
|
|
||||||
#define SET_DELAY_LSB_REG 96<<11 //0x68<<11
|
#define SET_DELAY_LSB_REG 96<<11 //0x68<<11
|
||||||
@ -333,7 +336,8 @@
|
|||||||
#define TIMED_GATE_BIT 0x00000004
|
#define TIMED_GATE_BIT 0x00000004
|
||||||
#define CONT_RO_ENABLE_BIT 0x00080000
|
#define CONT_RO_ENABLE_BIT 0x00080000
|
||||||
#define GB10_NOT_CPU_BIT 0x00001000
|
#define GB10_NOT_CPU_BIT 0x00001000
|
||||||
|
#define ADC_OUTPUT_DISABLE_BIT 0x00100
|
||||||
|
#define DIGITAL_OUTPUT_ENABLE_BIT 0x00200
|
||||||
|
|
||||||
|
|
||||||
/* for speed register */
|
/* for speed register */
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
#define NMAXMODY 1
|
#define NMAXMODY 1
|
||||||
#define NMAXMOD (NMAXMODX*NMAXMODY)
|
#define NMAXMOD (NMAXMODX*NMAXMODY)
|
||||||
|
|
||||||
#define NCHAN 32
|
#define NCHAN 36
|
||||||
#define NCHIP 1
|
#define NCHIP 1
|
||||||
#define NADC 1
|
#define NADC 9 //
|
||||||
|
|
||||||
#ifdef CTB
|
#ifdef CTB
|
||||||
#define NDAC 24
|
#define NDAC 24
|
||||||
|
@ -97,12 +97,13 @@ int init_detector(int b, int checkType) {
|
|||||||
|
|
||||||
case JUNGFRAU_MODULE_ID:
|
case JUNGFRAU_MODULE_ID:
|
||||||
myDetectorType=JUNGFRAU;
|
myDetectorType=JUNGFRAU;
|
||||||
printf("This is a Jungfrau module %d\n", JUNGFRAU);
|
printf("This is a Jungfrau module %d\n Not supported: exiting!", JUNGFRAU);
|
||||||
|
exit(1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JUNGFRAU_CTB_ID:
|
case JUNGFRAU_CTB_ID:
|
||||||
myDetectorType=JUNGFRAUCTB;
|
myDetectorType=JUNGFRAUCTB;
|
||||||
printf("This is a Jungfrau CTB %d\n", JUNGFRAUCTB);
|
printf("This is a CTB %d\n", JUNGFRAUCTB);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -131,7 +132,7 @@ int init_detector(int b, int checkType) {
|
|||||||
//bus_w16(CONTROL_REG, SYNC_RESET); // reset registers
|
//bus_w16(CONTROL_REG, SYNC_RESET); // reset registers
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
prepareSlowADC();
|
prepareSlowADCSeq();
|
||||||
// testFpga();
|
// testFpga();
|
||||||
// testRAM();
|
// testRAM();
|
||||||
// printf("ADC_SYNC_REG:%x\n",bus_r(ADC_SYNC_REG));
|
// printf("ADC_SYNC_REG:%x\n",bus_r(ADC_SYNC_REG));
|
||||||
@ -242,6 +243,7 @@ int init_detector(int b, int checkType) {
|
|||||||
allocateRAM();
|
allocateRAM();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setSamples(1);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1223,7 +1225,6 @@ int get_adc(int file_des) {
|
|||||||
idac=TEMP_ADC;
|
idac=TEMP_ADC;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
readSlowADC(ind);
|
|
||||||
printf("Unknown DAC index %d\n",ind);
|
printf("Unknown DAC index %d\n",ind);
|
||||||
sprintf(mess,"Unknown DAC index %d\n",ind);
|
sprintf(mess,"Unknown DAC index %d\n",ind);
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
@ -1232,6 +1233,15 @@ int get_adc(int file_des) {
|
|||||||
|
|
||||||
if (ret==OK)
|
if (ret==OK)
|
||||||
retval=getTemperatureByModule(idac,imod);
|
retval=getTemperatureByModule(idac,imod);
|
||||||
|
else {
|
||||||
|
retval=readSlowADC(ind-1000);
|
||||||
|
if (retval>=0) {
|
||||||
|
ret=OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -2066,7 +2076,7 @@ int get_run_status(int file_des) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int read_frame(int file_des) {
|
int read_frame(int file_des) {
|
||||||
|
int n;
|
||||||
u_int16_t* p=NULL;
|
u_int16_t* p=NULL;
|
||||||
|
|
||||||
if (differentClients==1 && lockStatus==1) {
|
if (differentClients==1 && lockStatus==1) {
|
||||||
@ -2087,14 +2097,15 @@ int read_frame(int file_des) {
|
|||||||
nframes++;
|
nframes++;
|
||||||
dataretval=(char*)ram_values;
|
dataretval=(char*)ram_values;
|
||||||
dataret=OK;
|
dataret=OK;
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
printf("sending data of %d frames\n",nframes);
|
printf("sending data of %d frames\n",nframes);
|
||||||
#endif
|
//#endif
|
||||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||||
#ifdef VERYVERBOSE
|
//#ifdef VERYVERBOSE
|
||||||
printf("sending pointer %x of size %d\n",(unsigned int)(dataretval),dataBytes*nSamples);
|
printf("sending pointer %x of size %d\n",(unsigned int)(dataretval),dataBytes);
|
||||||
#endif
|
//#endif
|
||||||
sendDataOnly(file_des,dataretval,dataBytes*nSamples);
|
n=sendDataOnly(file_des,dataretval,dataBytes);
|
||||||
|
printf("Sent %d bytes\n",n);
|
||||||
} else {
|
} else {
|
||||||
if (getFrames()>-1) {
|
if (getFrames()>-1) {
|
||||||
dataret=FAIL;
|
dataret=FAIL;
|
||||||
@ -2242,6 +2253,9 @@ int set_timer(int file_des) {
|
|||||||
case CYCLES_NUMBER:
|
case CYCLES_NUMBER:
|
||||||
retval=setTrains(tns);
|
retval=setTrains(tns);
|
||||||
break;
|
break;
|
||||||
|
case SAMPLES_JCTB:
|
||||||
|
retval=setSamples(tns);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess,"timer index unknown %d\n",ind);
|
sprintf(mess,"timer index unknown %d\n",ind);
|
||||||
@ -2343,6 +2357,9 @@ int get_time_left(int file_des) {
|
|||||||
case FRAMES_FROM_START_PG:
|
case FRAMES_FROM_START_PG:
|
||||||
retval=getFramesFromStart();
|
retval=getFramesFromStart();
|
||||||
break;
|
break;
|
||||||
|
case SAMPLES_JCTB:
|
||||||
|
retval=setSamples(-1);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess,"timer index unknown %d\n",ind);
|
sprintf(mess,"timer index unknown %d\n",ind);
|
||||||
@ -2433,7 +2450,7 @@ int set_roi(int file_des) {
|
|||||||
int n=0;
|
int n=0;
|
||||||
int retvalsize=0;
|
int retvalsize=0;
|
||||||
ROI arg[MAX_ROIS];
|
ROI arg[MAX_ROIS];
|
||||||
ROI* retval=0;
|
int retval;
|
||||||
strcpy(mess,"Could not set/get roi\n");
|
strcpy(mess,"Could not set/get roi\n");
|
||||||
// u_int32_t disable_reg=0;
|
// u_int32_t disable_reg=0;
|
||||||
|
|
||||||
@ -2443,13 +2460,6 @@ int set_roi(int file_des) {
|
|||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(myDetectorType == JUNGFRAU){
|
|
||||||
ret = FAIL;
|
|
||||||
strcpy(mess,"Not applicable/implemented for this detector\n");
|
|
||||||
printf("Error:Set ROI-%s",mess);
|
|
||||||
}
|
|
||||||
|
|
||||||
else{
|
|
||||||
|
|
||||||
if(nroi>=0){
|
if(nroi>=0){
|
||||||
n = receiveDataOnly(file_des,arg,nroi*sizeof(ROI));
|
n = receiveDataOnly(file_des,arg,nroi*sizeof(ROI));
|
||||||
@ -2461,24 +2471,21 @@ int set_roi(int file_des) {
|
|||||||
printf("Setting ROI to:");
|
printf("Setting ROI to:");
|
||||||
for( i=0;i<nroi;i++)
|
for( i=0;i<nroi;i++)
|
||||||
printf("%d\t%d\t%d\t%d\n",arg[i].xmin,arg[i].xmax,arg[i].ymin,arg[i].ymax);
|
printf("%d\t%d\t%d\t%d\n",arg[i].xmin,arg[i].xmax,arg[i].ymin,arg[i].ymax);
|
||||||
printf("Error: Function 41 or Setting ROI is not yet implemented in Moench!\n");
|
// printf("Error: Function 41 or Setting ROI is not yet implemented in Moench!\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* execute action if the arguments correctly arrived*/
|
/* execute action if the arguments correctly arrived*/
|
||||||
if (lockStatus==1 && differentClients==1){//necessary???
|
if (lockStatus==1 && differentClients==1 && nroi>=0){//necessary???
|
||||||
sprintf(mess,"Detector locked by %s\n", lastClientIP);
|
sprintf(mess,"Detector locked by %s\n", lastClientIP);
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
}
|
} else{
|
||||||
else{
|
|
||||||
retval=setROI(nroi,arg,&retvalsize,&ret);
|
retval=setROI(nroi,arg,&retvalsize,&ret);
|
||||||
if (ret==FAIL){
|
if (ret==FAIL){
|
||||||
printf("mess:%s\n",mess);
|
printf("mess:%s\n",mess);
|
||||||
sprintf(mess,"Could not set all roi, should have set %d rois, but only set %d rois\n",nroi,retvalsize);
|
sprintf(mess,"Could not set all roi, should have set %d rois, but only set %d rois\n",nroi,retvalsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(ret==OK && differentClients){
|
if(ret==OK && differentClients){
|
||||||
printf("Force update\n");
|
printf("Force update\n");
|
||||||
@ -2491,7 +2498,7 @@ int set_roi(int file_des) {
|
|||||||
n = sendDataOnly(file_des,mess,sizeof(mess));
|
n = sendDataOnly(file_des,mess,sizeof(mess));
|
||||||
else{
|
else{
|
||||||
sendDataOnly(file_des,&retvalsize,sizeof(retvalsize));
|
sendDataOnly(file_des,&retvalsize,sizeof(retvalsize));
|
||||||
sendDataOnly(file_des,retval,retvalsize*sizeof(ROI));
|
sendDataOnly(file_des,arg,retvalsize*sizeof(ROI));
|
||||||
}
|
}
|
||||||
/*return ok/fail*/
|
/*return ok/fail*/
|
||||||
return ret;
|
return ret;
|
||||||
@ -2631,15 +2638,34 @@ int set_speed(int file_des) {
|
|||||||
int set_readout_flags(int file_des) {
|
int set_readout_flags(int file_des) {
|
||||||
|
|
||||||
enum readOutFlags arg;
|
enum readOutFlags arg;
|
||||||
int ret=FAIL;
|
int ret=OK;
|
||||||
|
enum readOutFlags v=-1;
|
||||||
|
|
||||||
receiveDataOnly(file_des,&arg,sizeof(arg));
|
receiveDataOnly(file_des,&arg,sizeof(arg));
|
||||||
|
|
||||||
sprintf(mess,"can't set readout flags for moench\n");
|
switch (arg) {
|
||||||
|
case NORMAL_READOUT:
|
||||||
|
case DIGITAL_ONLY:
|
||||||
|
case ANALOG_AND_DIGITAL:
|
||||||
|
case GET_READOUT_FLAGS:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sprintf(mess,"unknown readout flags for jctb\n");
|
||||||
|
ret=FAIL;
|
||||||
|
}
|
||||||
|
if (ret==OK)
|
||||||
|
v=setReadOutMode(arg);
|
||||||
|
|
||||||
|
if (v<0) {
|
||||||
|
ret=FAIL;
|
||||||
|
sprintf(mess,"found non valid readout mode (neither analog nor digital)\n");
|
||||||
|
}
|
||||||
sendDataOnly(file_des,&ret,sizeof(ret));
|
sendDataOnly(file_des,&ret,sizeof(ret));
|
||||||
|
if (ret==OK)
|
||||||
|
sendDataOnly(file_des,&v,sizeof(v));
|
||||||
|
else
|
||||||
sendDataOnly(file_des,mess,sizeof(mess));
|
sendDataOnly(file_des,mess,sizeof(mess));
|
||||||
|
// sendDataOnly(file_des,mess,sizeof(mess));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -2786,6 +2812,7 @@ int send_update(int file_des) {
|
|||||||
int n;//int thr, n;
|
int n;//int thr, n;
|
||||||
//int it;
|
//int it;
|
||||||
int64_t retval, tns=-1;
|
int64_t retval, tns=-1;
|
||||||
|
enum readOutFlags v=-1;
|
||||||
n = sendDataOnly(file_des,lastClientIP,sizeof(lastClientIP));
|
n = sendDataOnly(file_des,lastClientIP,sizeof(lastClientIP));
|
||||||
n = sendDataOnly(file_des,&nModX,sizeof(nModX));
|
n = sendDataOnly(file_des,&nModX,sizeof(nModX));
|
||||||
n = sendDataOnly(file_des,&nModY,sizeof(nModY));
|
n = sendDataOnly(file_des,&nModY,sizeof(nModY));
|
||||||
@ -2809,6 +2836,11 @@ int send_update(int file_des) {
|
|||||||
n = sendDataOnly(file_des,&retval,sizeof(int64_t));*/
|
n = sendDataOnly(file_des,&retval,sizeof(int64_t));*/
|
||||||
retval=setTrains(tns);
|
retval=setTrains(tns);
|
||||||
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
||||||
|
retval=setSamples(tns);
|
||||||
|
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
||||||
|
|
||||||
|
v=setReadOutMode(-1);
|
||||||
|
sendDataOnly(file_des,&v,sizeof(v));
|
||||||
|
|
||||||
if (lockStatus==0) {
|
if (lockStatus==0) {
|
||||||
strcpy(lastClientIP,thisClientIP);
|
strcpy(lastClientIP,thisClientIP);
|
||||||
@ -3179,13 +3211,14 @@ int reset_counter_block(int file_des) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int start_receiver(int file_des) {
|
int start_receiver(int file_des) {
|
||||||
int ret=OK;
|
int ret=OK;
|
||||||
int n=0;
|
int n=0;
|
||||||
strcpy(mess,"Could not start receiver\n");
|
strcpy(mess,"Could not start receiver\n");
|
||||||
|
|
||||||
/* execute action if the arguments correctly arrived*/
|
/* execute action if the arguments correctly arrived*/
|
||||||
#ifdef MCB_FUNCS
|
//#ifdef MCB_FUNCS
|
||||||
if (lockStatus==1 && differentClients==1){//necessary???
|
if (lockStatus==1 && differentClients==1){//necessary???
|
||||||
sprintf(mess,"Detector locked by %s\n", lastClientIP);
|
sprintf(mess,"Detector locked by %s\n", lastClientIP);
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
@ -3193,7 +3226,7 @@ int start_receiver(int file_des) {
|
|||||||
else
|
else
|
||||||
ret = startReceiver(1);
|
ret = startReceiver(1);
|
||||||
|
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
if(ret==OK && differentClients){
|
if(ret==OK && differentClients){
|
||||||
|
@ -1028,12 +1028,12 @@ int setContinousReadOut(int d) {
|
|||||||
|
|
||||||
int startReceiver(int start) {
|
int startReceiver(int start) {
|
||||||
u_int32_t addr=CONFIG_REG;
|
u_int32_t addr=CONFIG_REG;
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
if(start)
|
if(start)
|
||||||
printf("Setting up detector to send to Receiver\n");
|
printf("Setting up detector to send to Receiver\n");
|
||||||
else
|
else
|
||||||
printf("Setting up detector to send to CPU\n");
|
printf("Setting up detector to send to CPU\n");
|
||||||
#endif
|
//#endif
|
||||||
int reg=bus_r(addr);
|
int reg=bus_r(addr);
|
||||||
//for start recever, write 0 and for stop, write 1
|
//for start recever, write 0 and for stop, write 1
|
||||||
if (!start)
|
if (!start)
|
||||||
@ -1301,6 +1301,17 @@ int64_t getTrains(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int64_t setSamples(int64_t value){
|
||||||
|
if (value>=0)
|
||||||
|
bus_w(NSAMPLES_REG,value);
|
||||||
|
return bus_r(NSAMPLES_REG);
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t getSamples(){
|
||||||
|
return bus_r(NSAMPLES_REG);//get64BitReg(GET_CYCLES_LSB_REG, GET_CYCLES_MSB_REG);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int64_t setProbes(int64_t value){
|
int64_t setProbes(int64_t value){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2089,7 +2100,7 @@ u_int16_t* fifo_read_event(int ns)
|
|||||||
|
|
||||||
|
|
||||||
// bus_w16(DUMMY_REG,0); //
|
// bus_w16(DUMMY_REG,0); //
|
||||||
for (i=0; i<16; i++) {
|
for (i=0; i<32; i++) {
|
||||||
|
|
||||||
|
|
||||||
// bus_w16(DUMMY_REG,i);
|
// bus_w16(DUMMY_REG,i);
|
||||||
@ -2121,7 +2132,7 @@ u_int16_t* fifo_read_event(int ns)
|
|||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
// if (((adcDisableMask&(3<<((i+1)*2)))>>((i+1)*2))!=3) {
|
// if (((adcDisableMask&(3<<((i+1)*2)))>>((i+1)*2))!=3) {
|
||||||
|
printf("sample %d fifo %d status %08x\n",ns,i,bus_r16(FIFO_STATUS_REG));
|
||||||
bus_w16(DUMMY_REG,i+1);
|
bus_w16(DUMMY_REG,i+1);
|
||||||
// }
|
// }
|
||||||
// *(((u_int16_t*)(now_ptr))+i)=bus_r16(FIFO_DATA_REG);
|
// *(((u_int16_t*)(now_ptr))+i)=bus_r16(FIFO_DATA_REG);
|
||||||
@ -2259,8 +2270,8 @@ u_int32_t* decode_data(int *datain)
|
|||||||
int setDynamicRange(int dr) {
|
int setDynamicRange(int dr) {
|
||||||
if (dr%16==0 && dr>0) {
|
if (dr%16==0 && dr>0) {
|
||||||
dynamicRange=16;
|
dynamicRange=16;
|
||||||
nSamples=dr/16;
|
// nSamples=dr/16;
|
||||||
bus_w(NSAMPLES_REG,nSamples);
|
// bus_w(NSAMPLES_REG,nSamples);
|
||||||
}
|
}
|
||||||
getDynamicRange();
|
getDynamicRange();
|
||||||
allocateRAM();
|
allocateRAM();
|
||||||
@ -2281,8 +2292,8 @@ int getDynamicRange() {
|
|||||||
|
|
||||||
nSamples=bus_r(NSAMPLES_REG);
|
nSamples=bus_r(NSAMPLES_REG);
|
||||||
getChannels();
|
getChannels();
|
||||||
dataBytes=nModX*N_CHIP*getChannels()*2;
|
dataBytes=nModX*N_CHIP*getChannels()*2*nSamples;
|
||||||
return dynamicRange*bus_r(NSAMPLES_REG);//nSamples;
|
return dynamicRange;//*bus_r(NSAMPLES_REG);//nSamples;
|
||||||
}
|
}
|
||||||
|
|
||||||
int testBus() {
|
int testBus() {
|
||||||
|
@ -113,9 +113,13 @@ int64_t getPeriod();
|
|||||||
int64_t setTrains(int64_t value);
|
int64_t setTrains(int64_t value);
|
||||||
int64_t getTrains();
|
int64_t getTrains();
|
||||||
|
|
||||||
|
|
||||||
int64_t setProbes(int64_t value);
|
int64_t setProbes(int64_t value);
|
||||||
int64_t getProbes();
|
int64_t getProbes();
|
||||||
|
|
||||||
|
int64_t setSamples(int64_t value);
|
||||||
|
int64_t getSamples();
|
||||||
|
|
||||||
int64_t getProgress();
|
int64_t getProgress();
|
||||||
int64_t setProgress();
|
int64_t setProgress();
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
#define CONTROL_REG 79<<11//0x24<<11
|
#define CONTROL_REG 79<<11//0x24<<11
|
||||||
#define STATUS_REG 2<<11 //0x25<<11
|
#define STATUS_REG 2<<11 //0x25<<11
|
||||||
#define CONFIG_REG 77<<11//0x26<<11
|
#define CONFIG_REG 77<<11//0x26<<11
|
||||||
#define EXT_SIGNAL_REG 78<<11// 0x27<<11
|
#define EXT_SIGNAL_REG 78<<11// 0x4E<<11
|
||||||
#define FPGA_SVN_REG 0x29<<11
|
#define FPGA_SVN_REG 0x29<<11
|
||||||
|
|
||||||
|
|
||||||
|
@ -2180,6 +2180,7 @@ int set_timer(int file_des) {
|
|||||||
int ret=OK;
|
int ret=OK;
|
||||||
|
|
||||||
|
|
||||||
|
printf("set\n");
|
||||||
sprintf(mess,"can't set timer\n");
|
sprintf(mess,"can't set timer\n");
|
||||||
|
|
||||||
n = receiveDataOnly(file_des,&ind,sizeof(ind));
|
n = receiveDataOnly(file_des,&ind,sizeof(ind));
|
||||||
@ -2230,9 +2231,12 @@ int set_timer(int file_des) {
|
|||||||
case CYCLES_NUMBER:
|
case CYCLES_NUMBER:
|
||||||
retval=setTrains(tns);
|
retval=setTrains(tns);
|
||||||
break;
|
break;
|
||||||
|
case SAMPLES_JCTB:
|
||||||
|
retval=setSamples(tns);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess,"timer index unknown %d\n",ind);
|
sprintf(mess,"t timer index unknown %d\n",ind);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2246,10 +2250,10 @@ int set_timer(int file_des) {
|
|||||||
if (ret!=OK) {
|
if (ret!=OK) {
|
||||||
printf(mess);
|
printf(mess);
|
||||||
printf("set timer failed\n");
|
printf("set timer failed\n");
|
||||||
} else if (ind==FRAME_NUMBER) {
|
} else if (ind==SAMPLES_JCTB) {
|
||||||
// ret=allocateRAM();
|
ret=allocateRAM();
|
||||||
// if (ret!=OK)
|
if (ret!=OK)
|
||||||
// sprintf(mess, "could not allocate RAM for %lld frames\n", tns);
|
sprintf(mess, "could not allocate RAM for %lld frames\n", tns);
|
||||||
}
|
}
|
||||||
|
|
||||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||||
@ -2280,7 +2284,7 @@ int get_time_left(int file_des) {
|
|||||||
int n;
|
int n;
|
||||||
int64_t retval;
|
int64_t retval;
|
||||||
int ret=OK;
|
int ret=OK;
|
||||||
|
printf("get\n");
|
||||||
sprintf(mess,"can't get timer\n");
|
sprintf(mess,"can't get timer\n");
|
||||||
n = receiveDataOnly(file_des,&ind,sizeof(ind));
|
n = receiveDataOnly(file_des,&ind,sizeof(ind));
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
@ -2331,9 +2335,12 @@ int get_time_left(int file_des) {
|
|||||||
case FRAMES_FROM_START_PG:
|
case FRAMES_FROM_START_PG:
|
||||||
retval=getFramesFromStart();
|
retval=getFramesFromStart();
|
||||||
break;
|
break;
|
||||||
|
case SAMPLES_JCTB:
|
||||||
|
retval=getSamples();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess,"timer index unknown %d\n",ind);
|
sprintf(mess,"tl timer index unknown %d\n",ind);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1417,6 +1417,7 @@ int* multiSlsDetector::getDataFromDetector() {
|
|||||||
int *retdet, *p=retval;
|
int *retdet, *p=retval;
|
||||||
int nodata=1, nodatadet=-1;;
|
int nodata=1, nodatadet=-1;;
|
||||||
|
|
||||||
|
// cout << "multi: " << thisMultiDetector->dataBytes << endl;
|
||||||
|
|
||||||
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
|
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
|
||||||
if (detectors[id]) {
|
if (detectors[id]) {
|
||||||
@ -1759,6 +1760,8 @@ int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t){
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (index==SAMPLES_JCTB)
|
||||||
|
setDynamicRange();
|
||||||
// check return values!!!
|
// check return values!!!
|
||||||
|
|
||||||
thisMultiDetector->timerValue[index]=ret1;
|
thisMultiDetector->timerValue[index]=ret1;
|
||||||
@ -2224,30 +2227,40 @@ slsDetectorDefs::ROI* multiSlsDetector::getROI(int &n){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
double* multiSlsDetector::decodeData(int *datain, double *fdata) {
|
double* multiSlsDetector::decodeData(int *datain, int &nn, double *fdata) {
|
||||||
double *dataout;
|
double *dataout;
|
||||||
if (fdata)
|
if (fdata)
|
||||||
dataout=fdata;
|
dataout=fdata;
|
||||||
else
|
else {
|
||||||
|
if (detectors[0]->getDetectorsType()==JUNGFRAUCTB) {
|
||||||
|
dataout=new double[thisMultiDetector->dataBytes/2];
|
||||||
|
nn=thisMultiDetector->dataBytes/2;
|
||||||
|
} else {
|
||||||
dataout=new double[thisMultiDetector->numberOfChannels];
|
dataout=new double[thisMultiDetector->numberOfChannels];
|
||||||
|
nn=thisMultiDetector->numberOfChannels;
|
||||||
|
}
|
||||||
|
}
|
||||||
// int ich=0;
|
// int ich=0;
|
||||||
|
int n;
|
||||||
double *detp=dataout;
|
double *detp=dataout;
|
||||||
int *datap=datain;
|
int *datap=datain;
|
||||||
|
|
||||||
|
|
||||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||||
if (detectors[i]) {
|
if (detectors[i]) {
|
||||||
detectors[i]->decodeData(datap, detp);
|
detectors[i]->decodeData(datap, n, detp);
|
||||||
if(detectors[i]->getErrorMask())
|
if(detectors[i]->getErrorMask())
|
||||||
setErrorMask(getErrorMask()|(1<<i));
|
setErrorMask(getErrorMask()|(1<<i));
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "increment pointers " << endl;
|
cout << "increment pointers " << endl;
|
||||||
#endif
|
#endif
|
||||||
datap+=detectors[i]->getDataBytes()/sizeof(int);
|
datap+=detectors[i]->getDataBytes()/sizeof(int);
|
||||||
detp+=detectors[i]->getTotalNumberOfChannels();
|
detp+=n;
|
||||||
|
// if (detectors[0]->getDetectorsType()==JUNGFRAUCTB) {
|
||||||
|
// detp+=detectors[i]->getDataBytes()/2;
|
||||||
|
// } else {
|
||||||
|
// detp+=detectors[i]->getTotalNumberOfChannels();
|
||||||
|
// }
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "done " << endl;
|
cout << "done " << endl;
|
||||||
#endif
|
#endif
|
||||||
@ -3680,6 +3693,7 @@ int multiSlsDetector::setDynamicRange(int p) {
|
|||||||
if(detectors[idet]->getErrorMask())
|
if(detectors[idet]->getErrorMask())
|
||||||
setErrorMask(getErrorMask()|(1<<idet));
|
setErrorMask(getErrorMask()|(1<<idet));
|
||||||
thisMultiDetector->dataBytes+=detectors[idet]->getDataBytes();
|
thisMultiDetector->dataBytes+=detectors[idet]->getDataBytes();
|
||||||
|
// cout << "db " << idet << " " << detectors[idet]->getDataBytes() << endl;
|
||||||
thisMultiDetector->numberOfChannels+=detectors[idet]->getTotalNumberOfChannels();
|
thisMultiDetector->numberOfChannels+=detectors[idet]->getTotalNumberOfChannels();
|
||||||
if (ret==-100)
|
if (ret==-100)
|
||||||
ret=ret1;
|
ret=ret1;
|
||||||
|
@ -807,7 +807,7 @@ class multiSlsDetector : public slsDetectorUtils {
|
|||||||
\param datain data from the detector
|
\param datain data from the detector
|
||||||
\returns pointer to a double array with a data per channel
|
\returns pointer to a double array with a data per channel
|
||||||
*/
|
*/
|
||||||
double* decodeData(int *datain, double *fdata=NULL);
|
double* decodeData(int *datain, int &nn, double *fdata=NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ int slsDetector::initSharedMemory(detectorType type, int id) {
|
|||||||
int sz;
|
int sz;
|
||||||
|
|
||||||
//shmId=-1;
|
//shmId=-1;
|
||||||
|
cout << "init shm"<< endl;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case MYTHEN:
|
case MYTHEN:
|
||||||
nch=128; // complete mythen system
|
nch=128; // complete mythen system
|
||||||
@ -81,7 +81,7 @@ int slsDetector::initSharedMemory(detectorType type, int id) {
|
|||||||
no=0;
|
no=0;
|
||||||
break;
|
break;
|
||||||
case JUNGFRAUCTB:
|
case JUNGFRAUCTB:
|
||||||
nch=32;
|
nch=36; //36? is using digital value as well
|
||||||
nm=1; //modules/detector
|
nm=1; //modules/detector
|
||||||
nc=1; //chips
|
nc=1; //chips
|
||||||
nd=16; //dacs+adcs
|
nd=16; //dacs+adcs
|
||||||
@ -242,6 +242,7 @@ slsDetector::slsDetector(detectorType type, int id,multiSlsDetector *p): slsDete
|
|||||||
|
|
||||||
/**Initializes the detector stucture \sa initializeDetectorSize
|
/**Initializes the detector stucture \sa initializeDetectorSize
|
||||||
*/
|
*/
|
||||||
|
cout << "init det size"<< endl;
|
||||||
initializeDetectorSize(type);
|
initializeDetectorSize(type);
|
||||||
|
|
||||||
|
|
||||||
@ -634,12 +635,12 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
|||||||
thisDetector->dynamicRange=16;
|
thisDetector->dynamicRange=16;
|
||||||
break;
|
break;
|
||||||
case JUNGFRAUCTB:
|
case JUNGFRAUCTB:
|
||||||
thisDetector->nChan[X]=32;
|
thisDetector->nChan[X]=36;
|
||||||
thisDetector->nChan[Y]=1;
|
thisDetector->nChan[Y]=1;
|
||||||
thisDetector->nChip[X]=1;
|
thisDetector->nChip[X]=1;
|
||||||
thisDetector->nChip[Y]=1;
|
thisDetector->nChip[Y]=1;
|
||||||
thisDetector->nDacs=16;
|
thisDetector->nDacs=16;
|
||||||
thisDetector->nAdcs=1;
|
thisDetector->nAdcs=9;
|
||||||
thisDetector->nGain=0;
|
thisDetector->nGain=0;
|
||||||
thisDetector->nOffset=0;
|
thisDetector->nOffset=0;
|
||||||
thisDetector->nModMax[X]=1;
|
thisDetector->nModMax[X]=1;
|
||||||
@ -684,12 +685,14 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
|||||||
thisDetector->timerValue[FRAME_NUMBER]=1;
|
thisDetector->timerValue[FRAME_NUMBER]=1;
|
||||||
thisDetector->timerValue[MEASUREMENTS_NUMBER]=1;
|
thisDetector->timerValue[MEASUREMENTS_NUMBER]=1;
|
||||||
thisDetector->timerValue[CYCLES_NUMBER]=1;
|
thisDetector->timerValue[CYCLES_NUMBER]=1;
|
||||||
|
thisDetector->timerValue[SAMPLES_JCTB]=1;
|
||||||
|
|
||||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*thisDetector->dynamicRange/8;
|
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*thisDetector->dynamicRange/8;
|
||||||
|
|
||||||
if(thisDetector->myDetectorType==JUNGFRAUCTB) {
|
if(thisDetector->myDetectorType==JUNGFRAUCTB) {
|
||||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*thisDetector->dynamicRange/8;
|
cout << "here1" << endl;
|
||||||
|
getTotalNumberOfChannels();
|
||||||
|
// thisDetector->dataBytes=getTotalNumberOfChannels()*thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB];
|
||||||
}
|
}
|
||||||
if(thisDetector->myDetectorType==MYTHEN){
|
if(thisDetector->myDetectorType==MYTHEN){
|
||||||
if (thisDetector->dynamicRange==24 || thisDetector->timerValue[PROBES_NUMBER]>0)
|
if (thisDetector->dynamicRange==24 || thisDetector->timerValue[PROBES_NUMBER]>0)
|
||||||
@ -789,6 +792,15 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
|||||||
|
|
||||||
//update?!?!?!?
|
//update?!?!?!?
|
||||||
|
|
||||||
|
if(thisDetector->myDetectorType==JUNGFRAUCTB) {
|
||||||
|
cout << "here2" << endl;
|
||||||
|
getTotalNumberOfChannels();
|
||||||
|
//thisDetector->nChan[X]=32;
|
||||||
|
//thisDetector->nChans=thisDetector->nChan[X]*thisDetector->nChan[Y];
|
||||||
|
|
||||||
|
//thisDetector->dataBytes=getTotalNumberOfChannels()*thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1012,7 +1024,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType t)
|
|||||||
na=0;
|
na=0;
|
||||||
break;
|
break;
|
||||||
case JUNGFRAUCTB:
|
case JUNGFRAUCTB:
|
||||||
nch=32;//32;
|
nch=36;
|
||||||
nm=1;
|
nm=1;
|
||||||
nc=1;
|
nc=1;
|
||||||
nd=8; // dacs+adcs
|
nd=8; // dacs+adcs
|
||||||
@ -1621,7 +1633,55 @@ slsDetectorDefs::detectorType slsDetector::getDetectorsType(int pos){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// /** number of rois defined */
|
||||||
|
// int nROI;
|
||||||
|
// /** list of rois */
|
||||||
|
// ROI roiLimits[MAX_ROIS];
|
||||||
|
|
||||||
|
// /** readout flags */
|
||||||
|
// readOutFlags roFlags;
|
||||||
|
|
||||||
|
|
||||||
|
int slsDetector::getTotalNumberOfChannels() {
|
||||||
|
cout << "total number of channels" << endl;
|
||||||
|
if(thisDetector->myDetectorType==JUNGFRAUCTB){
|
||||||
|
if (thisDetector->roFlags&DIGITAL_ONLY)
|
||||||
|
thisDetector->nChan[X]=4;
|
||||||
|
else if (thisDetector->roFlags&ANALOG_AND_DIGITAL)
|
||||||
|
thisDetector->nChan[X]=36;
|
||||||
|
else
|
||||||
|
thisDetector->nChan[X]=32;
|
||||||
|
|
||||||
|
if (thisDetector->nChan[X]>=32) {
|
||||||
|
if (thisDetector->nROI>0) {
|
||||||
|
thisDetector->nChan[X]-=32;
|
||||||
|
for (int iroi=0; iroi<thisDetector->nROI; iroi++)
|
||||||
|
thisDetector->nChan[X]+=thisDetector->roiLimits[iroi].xmax-thisDetector->roiLimits[iroi].xmin+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
thisDetector->nChans=thisDetector->nChan[X];
|
||||||
|
thisDetector->dataBytes=thisDetector->nChans*thisDetector->nChips*thisDetector->nMods*2*thisDetector->timerValue[SAMPLES_JCTB];
|
||||||
|
cout << "Total number of channels is "<< thisDetector->nChans*thisDetector->nChips*thisDetector->nMods << " data bytes is " << thisDetector->dataBytes << endl;
|
||||||
|
}
|
||||||
|
return thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;
|
||||||
|
};
|
||||||
|
|
||||||
|
int slsDetector::getTotalNumberOfChannels(dimension d) {
|
||||||
|
getTotalNumberOfChannels();
|
||||||
|
return thisDetector->nChan[d]*thisDetector->nChip[d]*thisDetector->nMod[d];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int slsDetector::getMaxNumberOfChannels(){
|
||||||
|
if(thisDetector->myDetectorType==JUNGFRAUCTB) return 36*thisDetector->nChips*thisDetector->nModsMax;
|
||||||
|
return thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax;
|
||||||
|
};
|
||||||
|
|
||||||
|
int slsDetector::getMaxNumberOfChannels(dimension d){
|
||||||
|
if(thisDetector->myDetectorType==JUNGFRAUCTB) if (d==X) return 36*thisDetector->nChip[d]*thisDetector->nModMax[d]; else return 1*thisDetector->nChip[d]*thisDetector->nModMax[d];
|
||||||
|
return thisDetector->nChan[d]*thisDetector->nChip[d]*thisDetector->nModMax[d];
|
||||||
|
};
|
||||||
|
|
||||||
/* needed to set/get the size of the detector */
|
/* needed to set/get the size of the detector */
|
||||||
// if n=GET_FLAG returns the number of installed modules,
|
// if n=GET_FLAG returns the number of installed modules,
|
||||||
@ -1699,14 +1759,6 @@ int slsDetector::setNumberOfModules(int n, dimension d){
|
|||||||
if (thisDetector->nModMax[Y]<thisDetector->nMod[Y])
|
if (thisDetector->nModMax[Y]<thisDetector->nMod[Y])
|
||||||
thisDetector->nModMax[Y]=thisDetector->nMod[Y];
|
thisDetector->nModMax[Y]=thisDetector->nMod[Y];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int dr=thisDetector->dynamicRange;
|
int dr=thisDetector->dynamicRange;
|
||||||
if (dr==24)
|
if (dr==24)
|
||||||
dr=32;
|
dr=32;
|
||||||
@ -1719,8 +1771,8 @@ int slsDetector::setNumberOfModules(int n, dimension d){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(thisDetector->myDetectorType==JUNGFRAUCTB){
|
if(thisDetector->myDetectorType==JUNGFRAUCTB){
|
||||||
|
getTotalNumberOfChannels();
|
||||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*dr/8;
|
//thisDetector->dataBytes=getTotalNumberOfChannels()*thisDetector->nChans*dr/8*thisDetector->nChips*thisDetector->timerValue[SAMPLES_JCTB];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3461,6 +3513,7 @@ int slsDetector::getChanRegs(double* retval,bool fromDetector){
|
|||||||
|
|
||||||
int slsDetector::updateDetectorNoWait() {
|
int slsDetector::updateDetectorNoWait() {
|
||||||
|
|
||||||
|
enum readOutFlags ro;
|
||||||
// int ret=OK;
|
// int ret=OK;
|
||||||
enum detectorSettings t;
|
enum detectorSettings t;
|
||||||
int thr, n, nm;
|
int thr, n, nm;
|
||||||
@ -3508,7 +3561,7 @@ int slsDetector::updateDetectorNoWait() {
|
|||||||
if((thisDetector->myDetectorType!= GOTTHARD)&&
|
if((thisDetector->myDetectorType!= GOTTHARD)&&
|
||||||
(thisDetector->myDetectorType!= PROPIX)&&
|
(thisDetector->myDetectorType!= PROPIX)&&
|
||||||
(thisDetector->myDetectorType!= JUNGFRAU)&&
|
(thisDetector->myDetectorType!= JUNGFRAU)&&
|
||||||
(thisDetector->myDetectorType!= MOENCH)){
|
(thisDetector->myDetectorType!= MOENCH) && (thisDetector->myDetectorType!= JUNGFRAUCTB)){
|
||||||
//thr=getThresholdEnergy();
|
//thr=getThresholdEnergy();
|
||||||
n = controlSocket->ReceiveDataOnly( &thr,sizeof(thr));
|
n = controlSocket->ReceiveDataOnly( &thr,sizeof(thr));
|
||||||
thisDetector->currentThresholdEV=thr;
|
thisDetector->currentThresholdEV=thr;
|
||||||
@ -3542,10 +3595,26 @@ int slsDetector::updateDetectorNoWait() {
|
|||||||
thisDetector->timerValue[PROBES_NUMBER]=retval;
|
thisDetector->timerValue[PROBES_NUMBER]=retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//retval=setTrains(tns);
|
//retval=setTrains(tns);
|
||||||
n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
|
n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
|
||||||
thisDetector->timerValue[CYCLES_NUMBER]=retval;
|
thisDetector->timerValue[CYCLES_NUMBER]=retval;
|
||||||
|
|
||||||
|
//retval=setProbes(tns);
|
||||||
|
if (thisDetector->myDetectorType == JUNGFRAUCTB){
|
||||||
|
n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
|
||||||
|
if (retval>=0)
|
||||||
|
thisDetector->timerValue[SAMPLES_JCTB]=retval;
|
||||||
|
n = controlSocket->ReceiveDataOnly( &ro,sizeof(ro));
|
||||||
|
|
||||||
|
thisDetector->roFlags=ro;
|
||||||
|
|
||||||
|
//retval=setProbes(tns);
|
||||||
|
getTotalNumberOfChannels();
|
||||||
|
|
||||||
|
// thisDetector->dataBytes=getTotalNumberOfChannels()*thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB];
|
||||||
|
|
||||||
|
}
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -3729,15 +3798,16 @@ int* slsDetector::getDataFromDetector(int *retval){
|
|||||||
|
|
||||||
// int* retval=new int[nel];
|
// int* retval=new int[nel];
|
||||||
|
|
||||||
if (retval==NULL)
|
if (retval==NULL) {
|
||||||
retval=new int[nel];
|
retval=new int[nel];
|
||||||
|
// cout << "*****"<<endl;
|
||||||
|
} //else cout <<"----"<< retval <<endl;
|
||||||
int ret=FAIL;
|
int ret=FAIL;
|
||||||
char mess[MAX_STR_LENGTH]="Nothing";
|
char mess[MAX_STR_LENGTH]="Nothing";
|
||||||
|
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
std::cout<< "getting data "<< thisDetector->dataBytes << " " << nel<< std::endl;
|
std::cout<< "getting data "<< thisDetector->dataBytes << " " << nel<< std::endl;
|
||||||
#endif
|
//#endif
|
||||||
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "ret=" << ret << endl;
|
cout << "ret=" << ret << endl;
|
||||||
@ -3762,9 +3832,9 @@ int* slsDetector::getDataFromDetector(int *retval){
|
|||||||
} else {
|
} else {
|
||||||
n=controlSocket->ReceiveDataOnly(retval,thisDetector->dataBytes);
|
n=controlSocket->ReceiveDataOnly(retval,thisDetector->dataBytes);
|
||||||
|
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
std::cout<< "Received "<< n << " data bytes" << std::endl;
|
std::cout<< "Received "<< n << " data bytes" << std::endl;
|
||||||
#endif
|
//#endif
|
||||||
if (n!=thisDetector->dataBytes) {
|
if (n!=thisDetector->dataBytes) {
|
||||||
std::cout<< "wrong data size received from detector: received " << n << " but expected " << thisDetector->dataBytes << std::endl;
|
std::cout<< "wrong data size received from detector: received " << n << " but expected " << thisDetector->dataBytes << std::endl;
|
||||||
thisDetector->stoppedFlag=1;
|
thisDetector->stoppedFlag=1;
|
||||||
@ -3800,13 +3870,13 @@ int* slsDetector::readAll(){
|
|||||||
|
|
||||||
while ((retval=getDataFromDetector())){
|
while ((retval=getDataFromDetector())){
|
||||||
i++;
|
i++;
|
||||||
//#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< i << std::endl;
|
std::cout<< i << std::endl;
|
||||||
//#else
|
//#else
|
||||||
//std::cout << "-" << flush ;
|
//std::cout << "-" << flush ;
|
||||||
//#endif
|
#endif
|
||||||
dataQueue.push(retval);
|
dataQueue.push(retval);
|
||||||
std::cout<< "pushed" << std::endl;
|
// std::cout<< "pushed" << std::endl;
|
||||||
}
|
}
|
||||||
disconnectControl();
|
disconnectControl();
|
||||||
}
|
}
|
||||||
@ -3849,12 +3919,12 @@ int slsDetector::readAllNoWait(){
|
|||||||
|
|
||||||
|
|
||||||
int* slsDetector::startAndReadAll(){
|
int* slsDetector::startAndReadAll(){
|
||||||
|
//cout << "Start and read all "<< endl;
|
||||||
|
|
||||||
int* retval;
|
int* retval;
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
int i=0;
|
int i=0;
|
||||||
#endif
|
//#endif
|
||||||
startAndReadAllNoWait();
|
startAndReadAllNoWait();
|
||||||
//#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
// std::cout<< "started" << std::endl;
|
// std::cout<< "started" << std::endl;
|
||||||
@ -3867,6 +3937,8 @@ int* slsDetector::startAndReadAll(){
|
|||||||
//std::cout<< "-" << flush;
|
//std::cout<< "-" << flush;
|
||||||
#endif
|
#endif
|
||||||
dataQueue.push(retval);
|
dataQueue.push(retval);
|
||||||
|
|
||||||
|
//std::cout<< "pushed" << std::endl;
|
||||||
}
|
}
|
||||||
disconnectControl();
|
disconnectControl();
|
||||||
|
|
||||||
@ -3990,6 +4062,10 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
|||||||
(thisDetector->myDetectorType==JUNGFRAU)||
|
(thisDetector->myDetectorType==JUNGFRAU)||
|
||||||
(thisDetector->myDetectorType==MOENCH))
|
(thisDetector->myDetectorType==MOENCH))
|
||||||
thisDetector->timerValue[PROBES_NUMBER]=0;
|
thisDetector->timerValue[PROBES_NUMBER]=0;
|
||||||
|
if(thisDetector->myDetectorType==JUNGFRAUCTB && index==SAMPLES_JCTB) {
|
||||||
|
getTotalNumberOfChannels();
|
||||||
|
// thisDetector->dataBytes=getTotalNumberOfChannels()*thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (t>=0)
|
if (t>=0)
|
||||||
@ -4003,6 +4079,10 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
|||||||
setDynamicRange();
|
setDynamicRange();
|
||||||
//cout << "Changing probes: data size = " << thisDetector->dataBytes <<endl;
|
//cout << "Changing probes: data size = " << thisDetector->dataBytes <<endl;
|
||||||
}
|
}
|
||||||
|
if ((thisDetector->myDetectorType==JUNGFRAUCTB) && (index==SAMPLES_JCTB)) {
|
||||||
|
setDynamicRange();
|
||||||
|
cout << "Changing samples: data size = " << thisDetector->dataBytes <<endl;
|
||||||
|
}
|
||||||
|
|
||||||
/* set progress */
|
/* set progress */
|
||||||
if ((index==FRAME_NUMBER) || (index==CYCLES_NUMBER)) {
|
if ((index==FRAME_NUMBER) || (index==CYCLES_NUMBER)) {
|
||||||
@ -4535,7 +4615,7 @@ int slsDetector::setDynamicRange(int n){
|
|||||||
thisDetector->dynamicRange=n;
|
thisDetector->dynamicRange=n;
|
||||||
retval=thisDetector->dynamicRange;
|
retval=thisDetector->dynamicRange;
|
||||||
}
|
}
|
||||||
|
//cout << "detector returned dynamic range " << retval << endl;
|
||||||
if (ret!=FAIL && retval>0) {
|
if (ret!=FAIL && retval>0) {
|
||||||
/* checking the number of probes to chose the data size */
|
/* checking the number of probes to chose the data size */
|
||||||
|
|
||||||
@ -4544,9 +4624,12 @@ int slsDetector::setDynamicRange(int n){
|
|||||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*retval/8;
|
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*retval/8;
|
||||||
|
|
||||||
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
|
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
|
||||||
thisDetector->nChip[X]=retval/16;
|
// thisDetector->nChip[X]=retval/16;
|
||||||
thisDetector->nChips=thisDetector->nChip[X]*thisDetector->nChip[Y];
|
// thisDetector->nChips=thisDetector->nChip[X]*thisDetector->nChip[Y];
|
||||||
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*retval/8;
|
// cout << thisDetector->nMod[X]*thisDetector->nMod[Y] << " " << thisDetector->nChans*thisDetector->nChips << " " << retval<< " ";
|
||||||
|
getTotalNumberOfChannels();
|
||||||
|
//thisDetector->dataBytes=getTotalNumberOfChannels()*retval/8*thisDetector->timerValue[SAMPLES_JCTB];
|
||||||
|
//cout << "data bytes: "<< thisDetector->dataBytes << endl;
|
||||||
}
|
}
|
||||||
if(thisDetector->myDetectorType==MYTHEN){
|
if(thisDetector->myDetectorType==MYTHEN){
|
||||||
if (thisDetector->timerValue[PROBES_NUMBER]!=0)
|
if (thisDetector->timerValue[PROBES_NUMBER]!=0)
|
||||||
@ -4598,28 +4681,39 @@ int slsDetector::setROI(int n,ROI roiLimits[]){
|
|||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
//sort ascending order
|
//sort ascending order
|
||||||
int temp;
|
int temp;
|
||||||
|
|
||||||
for(int i=0;i<n;i++){
|
for(int i=0;i<n;i++){
|
||||||
|
|
||||||
|
// cout << "*** ROI "<< i << " xmin " << roiLimits[i].xmin << " xmax "<< roiLimits[i].xmax << endl;
|
||||||
for(int j=i+1;j<n;j++){
|
for(int j=i+1;j<n;j++){
|
||||||
if(roiLimits[j].xmin<roiLimits[i].xmin){
|
if(roiLimits[j].xmin<roiLimits[i].xmin){
|
||||||
|
|
||||||
temp=roiLimits[i].xmin;roiLimits[i].xmin=roiLimits[j].xmin;roiLimits[j].xmin=temp;
|
temp=roiLimits[i].xmin;roiLimits[i].xmin=roiLimits[j].xmin;roiLimits[j].xmin=temp;
|
||||||
|
|
||||||
temp=roiLimits[i].xmax;roiLimits[i].xmax=roiLimits[j].xmax;roiLimits[j].xmax=temp;
|
temp=roiLimits[i].xmax;roiLimits[i].xmax=roiLimits[j].xmax;roiLimits[j].xmax=temp;
|
||||||
|
|
||||||
temp=roiLimits[i].ymin;roiLimits[i].ymin=roiLimits[j].ymin;roiLimits[j].ymin=temp;
|
temp=roiLimits[i].ymin;roiLimits[i].ymin=roiLimits[j].ymin;roiLimits[j].ymin=temp;
|
||||||
|
|
||||||
temp=roiLimits[i].ymax;roiLimits[i].ymax=roiLimits[j].ymax;roiLimits[j].ymax=temp;
|
temp=roiLimits[i].ymax;roiLimits[i].ymax=roiLimits[j].ymax;roiLimits[j].ymax=temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// cout << "UUU ROI "<< i << " xmin " << roiLimits[i].xmin << " xmax "<< roiLimits[i].xmax << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = sendROI(n,roiLimits);
|
ret = sendROI(n,roiLimits);
|
||||||
if(ret==FAIL)
|
if(ret==FAIL)
|
||||||
setErrorMask((getErrorMask())|(COULDNOT_SET_ROI));
|
setErrorMask((getErrorMask())|(COULDNOT_SET_ROI));
|
||||||
|
|
||||||
|
|
||||||
|
if(thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
slsDetectorDefs::ROI* slsDetector::getROI(int &n){
|
slsDetectorDefs::ROI* slsDetector::getROI(int &n){
|
||||||
sendROI();
|
sendROI(-1,NULL);
|
||||||
n=thisDetector->nROI;
|
n=thisDetector->nROI;
|
||||||
|
if(thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels();
|
||||||
return thisDetector->roiLimits;
|
return thisDetector->roiLimits;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4632,7 +4726,8 @@ int slsDetector::sendROI(int n,ROI roiLimits[]){
|
|||||||
int retvalsize=0;
|
int retvalsize=0;
|
||||||
ROI retval[MAX_ROIS];
|
ROI retval[MAX_ROIS];
|
||||||
int nrec=-1;
|
int nrec=-1;
|
||||||
|
if (roiLimits==NULL)
|
||||||
|
roiLimits=thisDetector->roiLimits;
|
||||||
|
|
||||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
if (connectControl() == OK){
|
if (connectControl() == OK){
|
||||||
@ -4674,10 +4769,10 @@ int slsDetector::sendROI(int n,ROI roiLimits[]){
|
|||||||
thisDetector->nROI = retvalsize;
|
thisDetector->nROI = retvalsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
for(int j=0;j<thisDetector->nROI;j++)
|
for(int j=0;j<thisDetector->nROI;j++)
|
||||||
cout<<roiLimits[j].xmin<<"\t"<<roiLimits[j].xmax<<"\t"<<roiLimits[j].ymin<<"\t"<<roiLimits[j].ymax<<endl;
|
cout<<"get"<< roiLimits[j].xmin<<"\t"<<roiLimits[j].xmax<<"\t"<<roiLimits[j].ymin<<"\t"<<roiLimits[j].ymax<<endl;
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -4720,6 +4815,11 @@ int slsDetector::setReadOutFlags(readOutFlags flag){
|
|||||||
} else {
|
} else {
|
||||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||||
thisDetector->roFlags=retval;
|
thisDetector->roFlags=retval;
|
||||||
|
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
|
||||||
|
|
||||||
|
getTotalNumberOfChannels();
|
||||||
|
//thisDetector->dataBytes=getTotalNumberOfChannels()*thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
disconnectControl();
|
disconnectControl();
|
||||||
if (ret==FORCE_UPDATE)
|
if (ret==FORCE_UPDATE)
|
||||||
@ -4794,7 +4894,7 @@ int slsDetector::executeTrimming(trimMode mode, int par1, int par2, int imod){
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
double* slsDetector::decodeData(int *datain, double *fdata) {
|
double* slsDetector::decodeData(int *datain, int &nn, double *fdata) {
|
||||||
|
|
||||||
double *dataout;
|
double *dataout;
|
||||||
if (fdata) {
|
if (fdata) {
|
||||||
@ -4802,7 +4902,14 @@ double* slsDetector::decodeData(int *datain, double *fdata) {
|
|||||||
// printf("not allocating fdata!\n");
|
// printf("not allocating fdata!\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
|
||||||
|
dataout=new double[thisDetector->dataBytes/2];
|
||||||
|
nn=thisDetector->dataBytes/2;
|
||||||
|
} else {
|
||||||
dataout=new double[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
|
dataout=new double[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
|
||||||
|
nn=thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;
|
||||||
|
}
|
||||||
|
|
||||||
// printf("allocating fdata!\n");
|
// printf("allocating fdata!\n");
|
||||||
}
|
}
|
||||||
const int bytesize=8;
|
const int bytesize=8;
|
||||||
@ -4817,20 +4924,21 @@ double* slsDetector::decodeData(int *datain, double *fdata) {
|
|||||||
|
|
||||||
if (thisDetector->timerValue[PROBES_NUMBER]==0) {
|
if (thisDetector->timerValue[PROBES_NUMBER]==0) {
|
||||||
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
|
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
|
||||||
|
// cout << "nch " << nch << endl;
|
||||||
|
for (ichan=0; ichan<thisDetector->dataBytes/2; 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)));
|
||||||
|
|
||||||
for (ichan=0; ichan<nch; ichan++) {
|
// // }
|
||||||
// dataout[ichan]=0;
|
dataout[ichan]=*((u_int16_t*)ptr);
|
||||||
ival=0;
|
ptr+=2;
|
||||||
// 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 {
|
} else {
|
||||||
switch (nbits) {
|
switch (nbits) {
|
||||||
@ -4980,7 +5088,7 @@ int slsDetector::fillModuleMask(int *mM){
|
|||||||
|
|
||||||
int slsDetector::setFlatFieldCorrection(double *corr, double *ecorr) {
|
int slsDetector::setFlatFieldCorrection(double *corr, double *ecorr) {
|
||||||
if (corr!=NULL) {
|
if (corr!=NULL) {
|
||||||
for (int ichan=0; ichan<thisDetector->nMod[X]*thisDetector->nChans*thisDetector->nChips; ichan++) {
|
for (int ichan=0; ichan<thisDetector->nMod[Y]*thisDetector->nMod[X]*thisDetector->nChans*thisDetector->nChips; ichan++) {
|
||||||
// #ifdef VERBOSE
|
// #ifdef VERBOSE
|
||||||
// std::cout<< ichan << " "<< corr[ichan] << std::endl;
|
// std::cout<< ichan << " "<< corr[ichan] << std::endl;
|
||||||
// #endif
|
// #endif
|
||||||
@ -5944,7 +6052,7 @@ int slsDetector:: writeAngularConversion(ofstream &ofs) {
|
|||||||
int slsDetector::loadImageToDetector(imageType index,string const fname){
|
int slsDetector::loadImageToDetector(imageType index,string const fname){
|
||||||
|
|
||||||
int ret=FAIL;
|
int ret=FAIL;
|
||||||
short int arg[thisDetector->nChans*thisDetector->nChips];
|
short int arg[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< std::endl<< "Loading ";
|
std::cout<< std::endl<< "Loading ";
|
||||||
@ -6025,7 +6133,7 @@ int slsDetector::getCounterBlock(short int arg[],int startACQ){
|
|||||||
int slsDetector::writeCounterBlockFile(string const fname,int startACQ){
|
int slsDetector::writeCounterBlockFile(string const fname,int startACQ){
|
||||||
|
|
||||||
int ret=FAIL;
|
int ret=FAIL;
|
||||||
short int counterVals[thisDetector->nChans*thisDetector->nChips];
|
short int counterVals[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< std::endl<< "Reading Counter to \""<<fname;
|
std::cout<< std::endl<< "Reading Counter to \""<<fname;
|
||||||
@ -6949,9 +7057,11 @@ int slsDetector::startReceiver(){
|
|||||||
if (connectData() == OK)
|
if (connectData() == OK)
|
||||||
ret=thisReceiver->executeFunction(fnum,mess);
|
ret=thisReceiver->executeFunction(fnum,mess);
|
||||||
disconnectData();
|
disconnectData();
|
||||||
if(ret==FORCE_UPDATE)
|
if(ret==FORCE_UPDATE) {
|
||||||
ret=updateReceiver();
|
ret=updateReceiver();
|
||||||
else if (ret == FAIL){
|
// cout<< "FU"<<endl;
|
||||||
|
} else if (ret == FAIL){
|
||||||
|
// cout << mess <<endl;
|
||||||
if(strstr(mess,"UDP")!=NULL)
|
if(strstr(mess,"UDP")!=NULL)
|
||||||
setErrorMask((getErrorMask())|(COULDNOT_CREATE_UDP_SOCKET));
|
setErrorMask((getErrorMask())|(COULDNOT_CREATE_UDP_SOCKET));
|
||||||
else if(strstr(mess,"file")!=NULL)
|
else if(strstr(mess,"file")!=NULL)
|
||||||
|
@ -632,13 +632,24 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
|||||||
int getMaxMods(){return thisDetector->nModsMax;}; //
|
int getMaxMods(){return thisDetector->nModsMax;}; //
|
||||||
|
|
||||||
|
|
||||||
int getTotalNumberOfChannels(){return thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;};
|
/** number of rois defined */
|
||||||
|
int nROI;
|
||||||
|
/** list of rois */
|
||||||
|
ROI roiLimits[MAX_ROIS];
|
||||||
|
|
||||||
int getTotalNumberOfChannels(dimension d){return thisDetector->nChan[d]*thisDetector->nChip[d]*thisDetector->nMod[d];};
|
/** readout flags */
|
||||||
|
readOutFlags roFlags;
|
||||||
|
|
||||||
int getMaxNumberOfChannels(){return thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax;};
|
|
||||||
|
|
||||||
int getMaxNumberOfChannels(dimension d){return thisDetector->nChan[d]*thisDetector->nChip[d]*thisDetector->nModMax[d];};
|
int getTotalNumberOfChannels();
|
||||||
|
//{return thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;};
|
||||||
|
|
||||||
|
int getTotalNumberOfChannels(dimension d);
|
||||||
|
//{return thisDetector->nChan[d]*thisDetector->nChip[d]*thisDetector->nMod[d];};
|
||||||
|
|
||||||
|
int getMaxNumberOfChannels();//{return thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax;};
|
||||||
|
|
||||||
|
int getMaxNumberOfChannels(dimension d);//{return thisDetector->nChan[d]*thisDetector->nChip[d]*thisDetector->nModMax[d];};
|
||||||
|
|
||||||
/** Returns number of rois */
|
/** Returns number of rois */
|
||||||
int getNRoi(){return thisDetector->nROI;};
|
int getNRoi(){return thisDetector->nROI;};
|
||||||
@ -1253,7 +1264,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
|||||||
\param datain data from the detector
|
\param datain data from the detector
|
||||||
\returns pointer to a double array with a data per channel
|
\returns pointer to a double array with a data per channel
|
||||||
*/
|
*/
|
||||||
double* decodeData(int *datain, double *fdata=NULL);
|
double* decodeData(int *datain, int &nn, double *fdata=NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
|
|||||||
virtual int setTotalProgress()=0;
|
virtual int setTotalProgress()=0;
|
||||||
|
|
||||||
|
|
||||||
virtual double* decodeData(int *datain, double *fdata=NULL)=0;
|
virtual double* decodeData(int *datain, int &nn, double *fdata=NULL)=0;
|
||||||
|
|
||||||
|
|
||||||
virtual string getCurrentFileName()=0;
|
virtual string getCurrentFileName()=0;
|
||||||
|
@ -839,6 +839,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
|||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer;
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
descrToFuncMap[i].m_pFuncName="samples"; //
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer;
|
||||||
|
i++;
|
||||||
|
|
||||||
/* read only timers */
|
/* read only timers */
|
||||||
|
|
||||||
descrToFuncMap[i].m_pFuncName="exptimel"; //
|
descrToFuncMap[i].m_pFuncName="exptimel"; //
|
||||||
@ -3992,6 +3996,8 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) {
|
|||||||
index=PROBES_NUMBER;
|
index=PROBES_NUMBER;
|
||||||
else if (cmd=="measurements")
|
else if (cmd=="measurements")
|
||||||
index=MEASUREMENTS_NUMBER;
|
index=MEASUREMENTS_NUMBER;
|
||||||
|
else if (cmd=="samples")
|
||||||
|
index=SAMPLES_JCTB;
|
||||||
else
|
else
|
||||||
return string("could not decode timer ")+cmd;
|
return string("could not decode timer ")+cmd;
|
||||||
|
|
||||||
@ -4044,6 +4050,7 @@ string slsDetectorCommand::helpTimer(int narg, char *args[], int action) {
|
|||||||
os << "frames t \t sets the number of frames per cycle (e.g. after each trigger)" << std::endl;
|
os << "frames t \t sets the number of frames per cycle (e.g. after each trigger)" << std::endl;
|
||||||
os << "cycles t \t sets the number of cycles (e.g. number of triggers)" << std::endl;
|
os << "cycles t \t sets the number of cycles (e.g. number of triggers)" << std::endl;
|
||||||
os << "probes t \t sets the number of probes to accumulate (max 3! cycles should be set to 1, frames to the number of pump-probe events)" << std::endl;
|
os << "probes t \t sets the number of probes to accumulate (max 3! cycles should be set to 1, frames to the number of pump-probe events)" << std::endl;
|
||||||
|
os << "samples t \t sets the number of samples expected from the jctb" << std::endl;
|
||||||
os << std::endl;
|
os << std::endl;
|
||||||
|
|
||||||
|
|
||||||
@ -4057,6 +4064,8 @@ string slsDetectorCommand::helpTimer(int narg, char *args[], int action) {
|
|||||||
os << "frames \t gets the number of frames per cycle (e.g. after each trigger)" << std::endl;
|
os << "frames \t gets the number of frames per cycle (e.g. after each trigger)" << std::endl;
|
||||||
os << "cycles \t gets the number of cycles (e.g. number of triggers)" << std::endl;
|
os << "cycles \t gets the number of cycles (e.g. number of triggers)" << std::endl;
|
||||||
os << "probes \t gets the number of probes to accumulate" << std::endl;
|
os << "probes \t gets the number of probes to accumulate" << std::endl;
|
||||||
|
os << "samples t \t gets the number of samples expected from the jctb" << std::endl;
|
||||||
|
|
||||||
os << std::endl;
|
os << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -4285,6 +4294,10 @@ char answer[1000]="";
|
|||||||
flag=NONPARALLEL;
|
flag=NONPARALLEL;
|
||||||
else if (sval=="safe")
|
else if (sval=="safe")
|
||||||
flag=SAFE;
|
flag=SAFE;
|
||||||
|
else if (sval=="digital")
|
||||||
|
flag=DIGITAL_ONLY;
|
||||||
|
else if (sval=="analog_digital")
|
||||||
|
flag=ANALOG_AND_DIGITAL;
|
||||||
else
|
else
|
||||||
return string("could not scan flag ")+string(args[1]);
|
return string("could not scan flag ")+string(args[1]);
|
||||||
}
|
}
|
||||||
@ -4294,6 +4307,8 @@ char answer[1000]="";
|
|||||||
|
|
||||||
retval = myDet->setReadOutFlags(flag);
|
retval = myDet->setReadOutFlags(flag);
|
||||||
|
|
||||||
|
// cout << hex << flag << " " << retval << endl;
|
||||||
|
|
||||||
if(retval == NORMAL_READOUT)
|
if(retval == NORMAL_READOUT)
|
||||||
return string("none");
|
return string("none");
|
||||||
|
|
||||||
@ -4309,6 +4324,10 @@ char answer[1000]="";
|
|||||||
strcat(answer,"nonparallel ");
|
strcat(answer,"nonparallel ");
|
||||||
if(retval & SAFE)
|
if(retval & SAFE)
|
||||||
strcat(answer,"safe ");
|
strcat(answer,"safe ");
|
||||||
|
if (retval & DIGITAL_ONLY)
|
||||||
|
strcat(answer,"digital " );
|
||||||
|
if (retval & ANALOG_AND_DIGITAL)
|
||||||
|
strcat(answer,"analog_digital ");
|
||||||
if(strlen(answer))
|
if(strlen(answer))
|
||||||
return string(answer);
|
return string(answer);
|
||||||
|
|
||||||
@ -4343,13 +4362,13 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) {
|
|||||||
if (action==PUT_ACTION || action==HELP_ACTION) {
|
if (action==PUT_ACTION || action==HELP_ACTION) {
|
||||||
|
|
||||||
os << "extsig:i mode \t sets the mode of the external signal i. can be \n \t \t \t off, \n \t \t \t gate_in_active_high, \n \t \t \t gate_in_active_low, \n \t \t \t trigger_in_rising_edge, \n \t \t \t trigger_in_falling_edge, \n \t \t \t ro_trigger_in_rising_edge, \n \t \t \t ro_trigger_in_falling_edge, \n \t \t \t gate_out_active_high, \n \t \t \t gate_out_active_low, \n \t \t \t trigger_out_rising_edge, \n \t \t \t trigger_out_falling_edge, \n \t \t \t ro_trigger_out_rising_edge, \n \t \t \t ro_trigger_out_falling_edge" << std::endl;
|
os << "extsig:i mode \t sets the mode of the external signal i. can be \n \t \t \t off, \n \t \t \t gate_in_active_high, \n \t \t \t gate_in_active_low, \n \t \t \t trigger_in_rising_edge, \n \t \t \t trigger_in_falling_edge, \n \t \t \t ro_trigger_in_rising_edge, \n \t \t \t ro_trigger_in_falling_edge, \n \t \t \t gate_out_active_high, \n \t \t \t gate_out_active_low, \n \t \t \t trigger_out_rising_edge, \n \t \t \t trigger_out_falling_edge, \n \t \t \t ro_trigger_out_rising_edge, \n \t \t \t ro_trigger_out_falling_edge" << std::endl;
|
||||||
os << "flags mode \t sets the readout flags to mode. can be none, storeinram, tot, continous, parallel, nonparallel, safe, unknown" << std::endl;
|
os << "flags mode \t sets the readout flags to mode. can be none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, unknown" << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (action==GET_ACTION || action==HELP_ACTION) {
|
if (action==GET_ACTION || action==HELP_ACTION) {
|
||||||
|
|
||||||
os << "extsig:i \t gets the mode of the external signal i. can be \n \t \t \t off, \n \t \t \t gate_in_active_high, \n \t \t \t gate_in_active_low, \n \t \t \t trigger_in_rising_edge, \n \t \t \t trigger_in_falling_edge, \n \t \t \t ro_trigger_in_rising_edge, \n \t \t \t ro_trigger_in_falling_edge, \n \t \t \t gate_out_active_high, \n \t \t \t gate_out_active_low, \n \t \t \t trigger_out_rising_edge, \n \t \t \t trigger_out_falling_edge, \n \t \t \t ro_trigger_out_rising_edge, \n \t \t \t ro_trigger_out_falling_edge" << std::endl;
|
os << "extsig:i \t gets the mode of the external signal i. can be \n \t \t \t off, \n \t \t \t gate_in_active_high, \n \t \t \t gate_in_active_low, \n \t \t \t trigger_in_rising_edge, \n \t \t \t trigger_in_falling_edge, \n \t \t \t ro_trigger_in_rising_edge, \n \t \t \t ro_trigger_in_falling_edge, \n \t \t \t gate_out_active_high, \n \t \t \t gate_out_active_low, \n \t \t \t trigger_out_rising_edge, \n \t \t \t trigger_out_falling_edge, \n \t \t \t ro_trigger_out_rising_edge, \n \t \t \t ro_trigger_out_falling_edge" << std::endl;
|
||||||
os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, unknown" << std::endl;
|
os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, unknown" << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
return os.str();
|
return os.str();
|
||||||
@ -5056,6 +5075,10 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
|
|||||||
os << hex << myDet->readRegister(67) << dec;
|
os << hex << myDet->readRegister(67) << dec;
|
||||||
|
|
||||||
} else if (cmd=="adcdisable") {
|
} else if (cmd=="adcdisable") {
|
||||||
|
|
||||||
|
int nroi=0;
|
||||||
|
ROI roiLimits[MAX_ROIS];
|
||||||
|
|
||||||
if (action==PUT_ACTION) {
|
if (action==PUT_ACTION) {
|
||||||
|
|
||||||
if (sscanf(args[1],"%x",&addr))
|
if (sscanf(args[1],"%x",&addr))
|
||||||
@ -5063,13 +5086,63 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
|
|||||||
else
|
else
|
||||||
return string("Could not scan adcdisable reg ")+string(args[1]);
|
return string("Could not scan adcdisable reg ")+string(args[1]);
|
||||||
|
|
||||||
|
/******USE ROI?!?!?!?*********/
|
||||||
myDet->writeRegister(94,addr);
|
// roiLimits[i].xmin;roiLimits[i].xmax;roiLimits[i].ymin;roiLimits[i].ymin;roiLimits[i].ymax
|
||||||
|
//int mask=1;
|
||||||
|
int ii=0;
|
||||||
|
while (ii<32) {
|
||||||
|
nroi++;
|
||||||
|
roiLimits[nroi-1].xmin=ii;
|
||||||
|
roiLimits[nroi-1].ymin=0;
|
||||||
|
roiLimits[nroi-1].ymax=0;
|
||||||
|
while ((addr&(1<<ii))) {
|
||||||
|
ii++;
|
||||||
|
if (ii>=32)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ii>=32) {
|
||||||
|
break;
|
||||||
|
cout << "ROI "<< nroi << " xmin "<<roiLimits[nroi-1].xmin << " xmax "<< roiLimits[nroi-1].xmax << endl;
|
||||||
|
roiLimits[nroi-1].xmax=31;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
roiLimits[nroi-1].xmin=ii;
|
||||||
|
while ((addr&(1<<ii))==0) {
|
||||||
|
ii++;
|
||||||
|
if (ii>=32)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
roiLimits[nroi-1].xmax=ii-1;
|
||||||
|
if (ii>=32) {
|
||||||
|
cout << "ROI "<< nroi << " xmin "<<roiLimits[nroi-1].xmin << " xmax "<< roiLimits[nroi-1].xmax << endl;
|
||||||
|
nroi++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cout << "ROI "<< nroi << " xmin "<<roiLimits[nroi-1].xmin << " xmax "<< roiLimits[nroi-1].xmax << endl;
|
||||||
|
}
|
||||||
|
cout << "********ROI "<< nroi << endl;
|
||||||
|
myDet->setROI(nroi-1,roiLimits);
|
||||||
|
// myDet->writeRegister(94,addr);
|
||||||
|
// myDet->writeRegister(120,addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ROI *aa=myDet->getROI(nroi);
|
||||||
|
|
||||||
|
int reg=0xffffffff;
|
||||||
|
if (nroi<1)
|
||||||
|
reg=0;
|
||||||
|
else {
|
||||||
|
for (int iroi=0; iroi<nroi; iroi++) {
|
||||||
|
cout << iroi << " xmin "<< (aa+iroi)->xmin<< " xmax "<< (aa+iroi)->xmax<< endl;
|
||||||
|
for (int ich=(aa+iroi)->xmin; ich<=(aa+iroi)->xmax; ich++) {
|
||||||
|
reg&=~(1<<ich);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os << hex << reg << dec;
|
||||||
|
|
||||||
|
|
||||||
os << hex << myDet->readRegister(94) << dec;
|
//os <<" "<< hex << myDet->readRegister(120) << dec;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,9 +22,9 @@ string fileIO::createFileName() {
|
|||||||
detIndex \
|
detIndex \
|
||||||
);
|
);
|
||||||
|
|
||||||
if (getDetectorsType()==JUNGFRAUCTB) {
|
//if (getDetectorsType()==JUNGFRAUCTB) {
|
||||||
nBytes=2*getTotalNumberOfChannels();
|
// nBytes=2*getTotalNumberOfChannels();
|
||||||
} else
|
//} else
|
||||||
nBytes=getDataBytes();
|
nBytes=getDataBytes();
|
||||||
return currentFileName;
|
return currentFileName;
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ int fileIO::writeDataFile(string fname, double *data, double *err, double *ang,
|
|||||||
if (nch==-1)
|
if (nch==-1)
|
||||||
nch=getTotalNumberOfChannels();
|
nch=getTotalNumberOfChannels();
|
||||||
|
|
||||||
cout << "Write filexxx...." << endl;
|
// cout << "Write filexxx...." << endl;
|
||||||
|
|
||||||
return fileIOStatic::writeDataFile(fname, nch, data, err, ang, dataformat);
|
return fileIOStatic::writeDataFile(fname, nch, data, err, ang, dataformat);
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ int fileIO::writeDataFile(ofstream &outfile, double *data, double *err, double *
|
|||||||
if (nch==-1)
|
if (nch==-1)
|
||||||
nch=getTotalNumberOfChannels();
|
nch=getTotalNumberOfChannels();
|
||||||
|
|
||||||
cout << "Write file...." << endl;
|
//cout << "Write file...." << endl;
|
||||||
|
|
||||||
return fileIOStatic::writeDataFile(outfile, nch, data, err, ang, dataformat, offset);
|
return fileIOStatic::writeDataFile(outfile, nch, data, err, ang, dataformat, offset);
|
||||||
|
|
||||||
@ -97,13 +97,14 @@ int fileIO::writeDataFile(void *data, int iframe) {
|
|||||||
if ((*framesPerFile)<2)
|
if ((*framesPerFile)<2)
|
||||||
iframe=-1;
|
iframe=-1;
|
||||||
|
|
||||||
if ((iframe%(*framesPerFile))==0 || (iframe<0)) {
|
if ((iframe%(*framesPerFile))==0 || (iframe<0) || filefd==0) {
|
||||||
createFileName();
|
createFileName();
|
||||||
filefd = fopen((currentFileName+string(".raw")).c_str(), "w");
|
filefd = fopen((currentFileName+string(".raw")).c_str(), "w");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filefd){
|
if (filefd){
|
||||||
// fileIOStatic::writeBinaryDataFile(filefd,getDataBytes(), data);
|
// fileIOStatic::writeBinaryDataFile(filefd,getDataBytes(), data);
|
||||||
|
cout <<"Writing "<< nBytes<< " dataBytes"<< endl;
|
||||||
fileIOStatic::writeBinaryDataFile(filefd,nBytes, data);
|
fileIOStatic::writeBinaryDataFile(filefd,nBytes, data);
|
||||||
iframe++;
|
iframe++;
|
||||||
}
|
}
|
||||||
@ -119,7 +120,7 @@ int fileIO::writeDataFile(void *data, int iframe) {
|
|||||||
|
|
||||||
|
|
||||||
int fileIO::closeDataFile() {
|
int fileIO::closeDataFile() {
|
||||||
cout << "close file...." << endl;
|
// cout << "close file...." << endl;
|
||||||
if (filefd)
|
if (filefd)
|
||||||
fclose(filefd);
|
fclose(filefd);
|
||||||
filefd=NULL;
|
filefd=NULL;
|
||||||
|
@ -71,6 +71,7 @@ postProcessing::~postProcessing(){
|
|||||||
void postProcessing::processFrame(int *myData, int delflag, int jctb) {
|
void postProcessing::processFrame(int *myData, int delflag, int jctb) {
|
||||||
|
|
||||||
string fname;
|
string fname;
|
||||||
|
int nn;
|
||||||
//double *fdata=NULL;
|
//double *fdata=NULL;
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -85,20 +86,22 @@ void postProcessing::processFrame(int *myData, int delflag, int jctb) {
|
|||||||
|
|
||||||
/** decode data */
|
/** decode data */
|
||||||
|
|
||||||
|
// cout << "decode 0"<< endl;
|
||||||
// if (getDetectorsType()==MYTHEN) {
|
// if (getDetectorsType()==MYTHEN) {
|
||||||
fdata=decodeData(myData, fdata);
|
fdata=decodeData(myData,nn, fdata);
|
||||||
|
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
cout << "decode"<< endl;
|
// cout << "decode 1"<< endl;
|
||||||
#endif
|
//#endif
|
||||||
// } else
|
// } else
|
||||||
// fdata=NULL;
|
// fdata=NULL;
|
||||||
|
|
||||||
if (rawDataReady) {
|
if (rawDataReady) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
|
cout << "decoded data size is "<<nn << endl;
|
||||||
cout << "raw data ready..." << endl;
|
cout << "raw data ready..." << endl;
|
||||||
#endif
|
#endif
|
||||||
rawDataReady(fdata,numberOfChannels, pRawDataArg);
|
// rawDataReady(fdata,numberOfChannels, pRawDataArg);
|
||||||
|
rawDataReady(fdata,nn, pRawDataArg);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "done" << endl;
|
cout << "done" << endl;
|
||||||
cout << "NO FILE WRITING AND/OR DATA PROCESSING DONE BY SLS DETECTOR SOFTWARE!!!" << endl;
|
cout << "NO FILE WRITING AND/OR DATA PROCESSING DONE BY SLS DETECTOR SOFTWARE!!!" << endl;
|
||||||
@ -140,7 +143,8 @@ void postProcessing::processFrame(int *myData, int delflag, int jctb) {
|
|||||||
|
|
||||||
// cout << "callback arg "<< getCurrentProgress()<< " " << (fname+string(".raw")).c_str() << " " << getTotalNumberOfChannels() << endl;
|
// cout << "callback arg "<< getCurrentProgress()<< " " << (fname+string(".raw")).c_str() << " " << getTotalNumberOfChannels() << endl;
|
||||||
// cout << "DATAREADY 1" <<endl;
|
// cout << "DATAREADY 1" <<endl;
|
||||||
thisData=new detectorData(fdata,NULL,NULL,getCurrentProgress(),(fname+string(".raw")).c_str(),getTotalNumberOfChannels()); //only 1d detectors
|
// thisData=new detectorData(fdata,NULL,NULL,getCurrentProgress(),(fname+string(".raw")).c_str(),getTotalNumberOfChannels()); //only 1d detectors
|
||||||
|
thisData=new detectorData(fdata,NULL,NULL,getCurrentProgress(),(fname+string(".raw")).c_str(),nn); //only 1d detectors
|
||||||
dataReady(thisData, currentFrameIndex, -1, pCallbackArg);
|
dataReady(thisData, currentFrameIndex, -1, pCallbackArg);
|
||||||
delete thisData;
|
delete thisData;
|
||||||
fdata=NULL;
|
fdata=NULL;
|
||||||
@ -428,14 +432,14 @@ void* postProcessing::processData(int delflag) {
|
|||||||
// cout << "loop" << endl;
|
// cout << "loop" << endl;
|
||||||
while((queuesize=dataQueueSize())>0) {
|
while((queuesize=dataQueueSize())>0) {
|
||||||
/** Pop data queue */
|
/** Pop data queue */
|
||||||
//#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "data found"<< endl<<endl;;
|
cout << "data found"<< endl<<endl;;
|
||||||
//#endif
|
#endif
|
||||||
|
|
||||||
myData=dataQueueFront(); // get the data from the queue
|
myData=dataQueueFront(); // get the data from the queue
|
||||||
#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
cout << "got them"<< endl;
|
// cout << "got them"<< endl;
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
if (myData) {
|
if (myData) {
|
||||||
|
|
||||||
@ -486,7 +490,7 @@ void* postProcessing::processData(int delflag) {
|
|||||||
}
|
}
|
||||||
//receiver
|
//receiver
|
||||||
else{
|
else{
|
||||||
|
int nn;
|
||||||
|
|
||||||
int progress = 0;
|
int progress = 0;
|
||||||
char currentfName[MAX_STR_LENGTH]="";
|
char currentfName[MAX_STR_LENGTH]="";
|
||||||
@ -640,7 +644,7 @@ void* postProcessing::processData(int delflag) {
|
|||||||
#ifdef VERY_VERY_DEBUG
|
#ifdef VERY_VERY_DEBUG
|
||||||
cout << "GOT data" << endl;
|
cout << "GOT data" << endl;
|
||||||
#endif
|
#endif
|
||||||
fdata = decodeData(receiverData);
|
fdata = decodeData(receiverData, nn);
|
||||||
delete [] receiverData;
|
delete [] receiverData;
|
||||||
if ((fdata) && (dataReady)){
|
if ((fdata) && (dataReady)){
|
||||||
// cout << "DATAREADY 3" << endl;
|
// cout << "DATAREADY 3" << endl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user