mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-25 07:40:03 +02:00
Merge branch 'developer' into cmake
This commit is contained in:
commit
a80da4f677
@ -1212,6 +1212,7 @@ int64_t set64BitReg(int64_t value, int aLSB, int aMSB){
|
||||
v64=value>> 32;
|
||||
vMSB=v64&(0xffffffff);
|
||||
bus_w(aMSB,vMSB);
|
||||
printf("Wreg64(%x,%x) %08x %08x %016llx\n", aLSB>>11, aMSB>>11, vLSB, vMSB, value);
|
||||
}
|
||||
return get64BitReg(aLSB, aMSB);
|
||||
|
||||
@ -1295,6 +1296,7 @@ int64_t getDelay(){
|
||||
}
|
||||
|
||||
int64_t setTrains(int64_t value){
|
||||
printf("Set cycles %lld\n",value);
|
||||
return set64BitReg(value, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
||||
}
|
||||
|
||||
@ -2075,12 +2077,21 @@ u_int16_t* fifo_read_event(int ns)
|
||||
/* dma_memcpy(now_ptr,values ,dataBytes); */
|
||||
/* #else */
|
||||
|
||||
a = bus_r(LOOK_AT_ME_REG);
|
||||
a = bus_r(LOOK_AT_ME_REG);
|
||||
//#ifdef VERBOSE
|
||||
printf("%08x\n",a);
|
||||
// printf("%d %08x\n",ns,a);
|
||||
bus_w16(DUMMY_REG,1<<8); // read strobe to all fifos
|
||||
bus_w16(DUMMY_REG,0);
|
||||
// i=0;//
|
||||
|
||||
bus_w16(DUMMY_REG,0);
|
||||
|
||||
/* for (i=0; i<32; i++) { */
|
||||
/* bus_w16(DUMMY_REG,i); */
|
||||
/* printf("%04x ",bus_r16(FIFO_STATUS_REG)); */
|
||||
/* // a = bus_r(LOOK_AT_ME_REG); */
|
||||
/* // printf("%d %08x\n",i,a); */
|
||||
/* } */
|
||||
/* printf("\n"); */
|
||||
// i=0;//
|
||||
/* for (i=0; i<32; i++) { */
|
||||
|
||||
/* /\* while (((adcDisableMask&(3<<((i)*2)))>>((i)*2))==3) { *\/ */
|
||||
@ -2110,13 +2121,13 @@ u_int16_t* fifo_read_event(int ns)
|
||||
*((u_int16_t*)now_ptr)=bus_r16(FIFO_DATA_REG);//*values;//bus_r(FIFO_DATA_REG);
|
||||
|
||||
|
||||
if (i!=0 || ns!=0) {
|
||||
if (i!=0 || ns!=0) {
|
||||
a=0;
|
||||
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));
|
||||
*((u_int16_t*)now_ptr)=bus_r16(FIFO_DATA_REG);//*values;
|
||||
// printf("%d-",i);
|
||||
// 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;
|
||||
// printf("%d-",i);
|
||||
|
||||
}
|
||||
}
|
||||
@ -2130,9 +2141,9 @@ u_int16_t* fifo_read_event(int ns)
|
||||
|
||||
bus_w16(DUMMY_REG,i+1);
|
||||
|
||||
a = bus_r(LOOK_AT_ME_REG);
|
||||
// a = bus_r(LOOK_AT_ME_REG);
|
||||
// printf("%d %08x\n",i,a);
|
||||
//#ifdef VERBOSE
|
||||
printf("%d %08x\n",i,a);
|
||||
// }
|
||||
// *(((u_int16_t*)(now_ptr))+i)=bus_r16(FIFO_DATA_REG);
|
||||
}
|
||||
@ -2449,6 +2460,95 @@ int writeADC(int addr, int val) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int prepareSlowADC() {
|
||||
|
||||
|
||||
|
||||
u_int16_t vv;
|
||||
u_int16_t codata;
|
||||
|
||||
u_int32_t valw;
|
||||
int i, j;
|
||||
|
||||
int cnv_bit=16, sdi_bit=17, sck_bit=18;
|
||||
|
||||
for (j=0; j<2; j++) {
|
||||
|
||||
|
||||
valw=(1<<cnv_bit) | (1<<sdi_bit);
|
||||
bus_w(ADC_WRITE_REG,valw);
|
||||
|
||||
usleep(20);
|
||||
|
||||
valw=(1<<sdi_bit);
|
||||
bus_w(ADC_WRITE_REG,(valw));
|
||||
|
||||
|
||||
|
||||
|
||||
for (i=0;i<16;i++) {
|
||||
//cldwn
|
||||
valw=0;
|
||||
bus_w(ADC_WRITE_REG,valw);
|
||||
// usleep(0);
|
||||
bus_w(ADC_WRITE_REG,valw|(1<<sck_bit));
|
||||
// usleep(0);
|
||||
bus_w(ADC_WRITE_REG,valw);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int readSlowADC(int ichan) {
|
||||
|
||||
|
||||
u_int16_t vv=0x3c40;
|
||||
u_int16_t codata=vv | (ichan<<7);
|
||||
|
||||
u_int32_t valw;
|
||||
int i, obit;
|
||||
|
||||
int cnv_bit=16, sdi_bit=17, sck_bit=18;
|
||||
|
||||
|
||||
|
||||
|
||||
for (ichan=0; ichan<8; ichan++) {
|
||||
|
||||
//convert
|
||||
valw=(1<<cnv_bit);
|
||||
bus_w(ADC_WRITE_REG,valw);
|
||||
|
||||
usleep(20);
|
||||
|
||||
valw=(1<<sdi_bit);
|
||||
bus_w(ADC_WRITE_REG,(valw));
|
||||
|
||||
|
||||
printf("Channel %d ",ichan);
|
||||
//read
|
||||
for (i=0;i<16;i++) {
|
||||
//cldwn
|
||||
valw=0;
|
||||
bus_w(ADC_WRITE_REG,valw);
|
||||
// usleep(0);
|
||||
bus_w(ADC_WRITE_REG,valw|(1<<sck_bit));
|
||||
bus_w(ADC_WRITE_REG,valw);
|
||||
|
||||
obit=bus_r16(SLOW_ADC_REG)&0x1;
|
||||
printf("%d",obit);
|
||||
//write data (i)
|
||||
// usleep(0);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int prepareADC(){
|
||||
@ -3401,8 +3501,8 @@ int setPower(int ind, int val) {
|
||||
|
||||
if (pwrindex>=0) {
|
||||
if (bus_r(POWER_ON_REG)&(1<<(16+pwrindex))){
|
||||
retval1=vmax-(retval*1900)/4095;
|
||||
vmax=2700-(getDacRegister(19)*1000)/4095-200;
|
||||
vmax=2700-(getDacRegister(19)*1000)/4095-200;
|
||||
retval1=vmax-(retval*(vmax-vmin))/4095;
|
||||
if (retval1>vmax)
|
||||
retval1=vmax;
|
||||
if (retval1<vmin)
|
||||
|
@ -156,6 +156,7 @@ int allocateRAM();
|
||||
|
||||
int writeADC(int addr, int val);
|
||||
int prepareADC();
|
||||
int prepareSlowADC();
|
||||
|
||||
|
||||
int clearRAM();
|
||||
|
Binary file not shown.
@ -139,7 +139,7 @@
|
||||
#define FRAMES_FROM_START_PG_LSB_REG 36<<11
|
||||
#define FRAMES_FROM_START_PG_MSB_REG 37<<11
|
||||
|
||||
|
||||
#define SLOW_ADC_REG 43<<11
|
||||
|
||||
|
||||
|
||||
|
@ -131,6 +131,7 @@ int init_detector(int b, int checkType) {
|
||||
//bus_w16(CONTROL_REG, SYNC_RESET); // reset registers
|
||||
#endif
|
||||
|
||||
prepareSlowADC();
|
||||
// testFpga();
|
||||
// testRAM();
|
||||
// printf("ADC_SYNC_REG:%x\n",bus_r(ADC_SYNC_REG));
|
||||
@ -1222,10 +1223,11 @@ int get_adc(int file_des) {
|
||||
idac=TEMP_ADC;
|
||||
break;
|
||||
default:
|
||||
printf("Unknown DAC index %d\n",ind);
|
||||
sprintf(mess,"Unknown DAC index %d\n",ind);
|
||||
ret=FAIL;
|
||||
break;
|
||||
readSlowADC(ind);
|
||||
printf("Unknown DAC index %d\n",ind);
|
||||
sprintf(mess,"Unknown DAC index %d\n",ind);
|
||||
ret=FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret==OK)
|
||||
@ -2234,8 +2236,8 @@ int set_timer(int file_des) {
|
||||
retval=setGates(tns);
|
||||
break;
|
||||
case PROBES_NUMBER:
|
||||
sprintf(mess,"can't set timer for moench\n");
|
||||
ret=FAIL;
|
||||
sprintf(mess,"can't set timer for moench\n");
|
||||
ret=FAIL;
|
||||
break;
|
||||
case CYCLES_NUMBER:
|
||||
retval=setTrains(tns);
|
||||
|
@ -3955,9 +3955,9 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
||||
if (index!=MEASUREMENTS_NUMBER) {
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
//#ifdef VERBOSE
|
||||
std::cout<< "Setting timer "<< index << " to " << t << "ns/value" << std::endl;
|
||||
#endif
|
||||
//#endif
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
if (connectControl() == OK){
|
||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
@ -3984,29 +3984,29 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
||||
} else {
|
||||
//std::cout<< "offline " << std::endl;
|
||||
if (t>=0)
|
||||
thisDetector->timerValue[index]=t;
|
||||
thisDetector->timerValue[index]=t;
|
||||
if((thisDetector->myDetectorType==GOTTHARD)||
|
||||
(thisDetector->myDetectorType==PROPIX)||
|
||||
(thisDetector->myDetectorType==JUNGFRAU)||
|
||||
(thisDetector->myDetectorType==MOENCH))
|
||||
thisDetector->timerValue[PROBES_NUMBER]=0;
|
||||
(thisDetector->myDetectorType==PROPIX)||
|
||||
(thisDetector->myDetectorType==JUNGFRAU)||
|
||||
(thisDetector->myDetectorType==MOENCH))
|
||||
thisDetector->timerValue[PROBES_NUMBER]=0;
|
||||
}
|
||||
} else {
|
||||
if (t>=0)
|
||||
thisDetector->timerValue[index]=t;
|
||||
if (t>=0)
|
||||
thisDetector->timerValue[index]=t;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "Timer " << index << " set to "<< thisDetector->timerValue[index] << "ns" << std::endl;
|
||||
#endif
|
||||
|
||||
if ((thisDetector->myDetectorType==MYTHEN)&&(index==PROBES_NUMBER)) {
|
||||
setDynamicRange();
|
||||
//cout << "Changing probes: data size = " << thisDetector->dataBytes <<endl;
|
||||
setDynamicRange();
|
||||
//cout << "Changing probes: data size = " << thisDetector->dataBytes <<endl;
|
||||
}
|
||||
|
||||
/* set progress */
|
||||
if ((index==FRAME_NUMBER) || (index==CYCLES_NUMBER)) {
|
||||
setTotalProgress();
|
||||
setTotalProgress();
|
||||
}
|
||||
|
||||
double r;
|
||||
@ -4016,51 +4016,51 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
||||
|
||||
//send acquisiton period/frame number to receiver
|
||||
if((index==FRAME_NUMBER)||(index==FRAME_PERIOD)||(index==CYCLES_NUMBER)){
|
||||
if(ret != FAIL){
|
||||
retval = thisDetector->timerValue[index];
|
||||
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||
int64_t args[2];
|
||||
args[1] = retval;
|
||||
if((t == -1) && (ret!= FORCE_UPDATE)) args[1] = -1;
|
||||
if(ret != FAIL){
|
||||
retval = thisDetector->timerValue[index];
|
||||
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||
int64_t args[2];
|
||||
args[1] = retval;
|
||||
if((t == -1) && (ret!= FORCE_UPDATE)) args[1] = -1;
|
||||
|
||||
if((index==FRAME_NUMBER)||(index==CYCLES_NUMBER)){
|
||||
if((index==FRAME_NUMBER)||(index==CYCLES_NUMBER)){
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Setting/Getting number of frames " << index <<" to/from receiver " << args[1] << std::endl;
|
||||
std::cout << "Setting/Getting number of frames " << index <<" to/from receiver " << args[1] << std::endl;
|
||||
#endif
|
||||
args[0] = FRAME_NUMBER;
|
||||
retval = abs(thisDetector->timerValue[FRAME_NUMBER]*thisDetector->timerValue[CYCLES_NUMBER]);
|
||||
if(args[1] != -1) args[1]=retval;
|
||||
}else{
|
||||
args[0] = FRAME_NUMBER;
|
||||
retval = abs(thisDetector->timerValue[FRAME_NUMBER]*thisDetector->timerValue[CYCLES_NUMBER]);
|
||||
if(args[1] != -1) args[1]=retval;
|
||||
}else{
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Setting/Getting acquisition period " << index << " to/from receiver " << args[1] << std::endl;
|
||||
std::cout << "Setting/Getting acquisition period " << index << " to/from receiver " << args[1] << std::endl;
|
||||
#endif
|
||||
args[0] = FRAME_PERIOD;
|
||||
//if acquisition period is zero, then #frames/buffer depends on exposure time and not acq period
|
||||
if(!retval) args[1] = timerValue[ACQUISITION_TIME];
|
||||
}
|
||||
args[0] = FRAME_PERIOD;
|
||||
//if acquisition period is zero, then #frames/buffer depends on exposure time and not acq period
|
||||
if(!retval) args[1] = timerValue[ACQUISITION_TIME];
|
||||
}
|
||||
|
||||
|
||||
if (connectData() == OK)
|
||||
ret=thisReceiver->sendIntArray(fnum2,ut,args);
|
||||
disconnectData();
|
||||
if((ut != retval)|| (ret==FAIL)){
|
||||
ret = FAIL;
|
||||
if(index==FRAME_PERIOD){
|
||||
//exptime sent if acq period = 0
|
||||
if(retval){
|
||||
cout << "ERROR:Acquisition Period in receiver set incorrectly to " << ut << " instead of " << thisDetector->timerValue[index] << endl;
|
||||
setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET));
|
||||
}
|
||||
}else{
|
||||
cout << "ERROR:Number of Frames (* Number of cycles) in receiver set incorrectly to " << ut << " instead of " << thisDetector->timerValue[index] << endl;
|
||||
setErrorMask((getErrorMask())|(RECEIVER_FRAME_NUM_NOT_SET));
|
||||
}
|
||||
}
|
||||
|
||||
if(ret==FORCE_UPDATE)
|
||||
updateReceiver();
|
||||
}
|
||||
if (connectData() == OK)
|
||||
ret=thisReceiver->sendIntArray(fnum2,ut,args);
|
||||
disconnectData();
|
||||
if((ut != retval)|| (ret==FAIL)){
|
||||
ret = FAIL;
|
||||
if(index==FRAME_PERIOD){
|
||||
//exptime sent if acq period = 0
|
||||
if(retval){
|
||||
cout << "ERROR:Acquisition Period in receiver set incorrectly to " << ut << " instead of " << thisDetector->timerValue[index] << endl;
|
||||
setErrorMask((getErrorMask())|(RECEIVER_ACQ_PERIOD_NOT_SET));
|
||||
}
|
||||
}else{
|
||||
cout << "ERROR:Number of Frames (* Number of cycles) in receiver set incorrectly to " << ut << " instead of " << thisDetector->timerValue[index] << endl;
|
||||
setErrorMask((getErrorMask())|(RECEIVER_FRAME_NUM_NOT_SET));
|
||||
}
|
||||
}
|
||||
|
||||
if(ret==FORCE_UPDATE)
|
||||
updateReceiver();
|
||||
}
|
||||
}
|
||||
}
|
||||
return thisDetector->timerValue[index];
|
||||
};
|
||||
|
@ -791,6 +791,11 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="adc"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdADC;
|
||||
i++;
|
||||
|
||||
|
||||
/* r/w timers */
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="timing"; //
|
||||
@ -3859,6 +3864,7 @@ string slsDetectorCommand::helpDAC(int narg, char *args[], int action) {
|
||||
string slsDetectorCommand::cmdADC(int narg, char *args[], int action) {
|
||||
|
||||
dacIndex adc;
|
||||
int idac;
|
||||
// double val=-1;
|
||||
char answer[1000];
|
||||
|
||||
@ -3867,7 +3873,10 @@ string slsDetectorCommand::cmdADC(int narg, char *args[], int action) {
|
||||
else if (action==PUT_ACTION)
|
||||
return string("cannot set ")+cmd;
|
||||
|
||||
if (cmd=="temp_adc")
|
||||
if (sscanf(args[0],"adc:%d",&idac)==1) {
|
||||
printf("chiptestboard!\n");
|
||||
adc=(dacIndex)(idac+1000);
|
||||
} else if (cmd=="temp_adc")
|
||||
adc=TEMPERATURE_ADC;
|
||||
else if (cmd=="temp_fpga")
|
||||
adc=TEMPERATURE_FPGA;
|
||||
@ -3893,7 +3902,11 @@ string slsDetectorCommand::cmdADC(int narg, char *args[], int action) {
|
||||
sprintf(answer,"%f",myDet->getADC(adc));
|
||||
#endif
|
||||
//if ((adc == TEMPERATURE_ADC) || (adc == TEMPERATURE_FPGA))
|
||||
strcat(answer,"°C");
|
||||
if (adc<1000)
|
||||
strcat(answer,"°C");
|
||||
else
|
||||
strcat(answer,"mV");
|
||||
|
||||
return string(answer);
|
||||
|
||||
}
|
||||
@ -4001,12 +4014,13 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) {
|
||||
rval=(double)ret*1E-9;
|
||||
else rval=ret;
|
||||
|
||||
// cout << "here!"<< endl;
|
||||
//set frame index
|
||||
if (index==FRAME_NUMBER || index==CYCLES_NUMBER ){
|
||||
if ((myDet->setTimer(FRAME_NUMBER,-1)*myDet->setTimer(CYCLES_NUMBER,-1))>1)
|
||||
myDet->setFrameIndex(0);
|
||||
else
|
||||
myDet->setFrameIndex(-1);
|
||||
if ((myDet->setTimer(FRAME_NUMBER,-1)*myDet->setTimer(CYCLES_NUMBER,-1))>1) {
|
||||
myDet->setFrameIndex(0);
|
||||
} else
|
||||
myDet->setFrameIndex(-1);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user