diff --git a/slsDetectorSoftware/commonFiles/sls_detector_defs.h b/slsDetectorSoftware/commonFiles/sls_detector_defs.h index 182c107b1..38b0042f6 100755 --- a/slsDetectorSoftware/commonFiles/sls_detector_defs.h +++ b/slsDetectorSoftware/commonFiles/sls_detector_defs.h @@ -385,7 +385,7 @@ enum detectorSettings{ LOWGAIN, /**< low gain settings */ MEDIUMGAIN, /**< medium gain settings */ VERYHIGHGAIN, /**< very high gain settings */ - LOWNOISE, /**< low noise settings */ + LOWNOISE, /**< low noise settings */ UNDEFINED, /**< undefined or custom settings */ UNINITIALIZED /**< uninitialiazed (status at startup) */ }; @@ -443,7 +443,9 @@ enum speedVariable { WAIT_STATES, /**< wait states for bus read */ TOT_CLOCK_DIVIDER, /**< wait states for bus read */ TOT_DUTY_CYCLE, /**< wait states for bus read */ - SET_SIGNAL_LENGTH /**< set/clear signal length */ + SET_SIGNAL_LENGTH, /**< set/clear signal length */ + PHASE_SHIFT, /**< adds phase shift */ + OVERSAMPLING /**< oversampling for analog detectors */ }; /** diff --git a/slsDetectorSoftware/moenchDetectorServer/firmware_funcs.c b/slsDetectorSoftware/moenchDetectorServer/firmware_funcs.c index 7b6868e29..52d00348b 100755 --- a/slsDetectorSoftware/moenchDetectorServer/firmware_funcs.c +++ b/slsDetectorSoftware/moenchDetectorServer/firmware_funcs.c @@ -39,7 +39,7 @@ int ram_size=0; int64_t totalTime=1; u_int32_t progressMask=0; -int phase_shift=DEFAULT_PHASE_SHIFT; +int phase_shift=0;//DEFAULT_PHASE_SHIFT; int ipPacketSize=DEFAULT_IP_PACKETSIZE; int udpPacketSize=DEFAULT_UDP_PACKETSIZE; @@ -253,6 +253,30 @@ int setPhaseShiftOnce(){ return OK; } +int phaseStep(int st){ + u_int32_t addr; + int i; + + addr=MULTI_PURPOSE_REG; + + if (st>0) { + bus_w(PLL_CNTRL_REG, 1);//reset PLL + bus_w(PLL_CNTRL_REG, 0); + phase_shift=0; + for (i=0;i1) nc=d;// nc=161/d; + else return -1; + + if (nc>255) + return -1; + + int addr, addr1, addr0; + u_int32_t pat,pat1,pat0; + + addr= PLL_PARAM_REG; + addr0= PLL_PARAM_OUT_REG; + addr1=PLL_CNTRL_REG; + pat1=0x10; + + + //write high count c0 +/* pat=(1<<12)|(7<<9)|nc; */ +/* bus_w(addr, pat); */ +/* bus_w(addr1, pat1); */ +/* bus_w(addr1, 0); */ +/* usleep (1000); */ +/* pat=bus_r(addr0); */ +/* bus_w(addr1, 0x4); */ +/* bus_w(addr1, 0); */ +/* pat=bus_r(addr0); */ +/* printf("M nominal count read %x (%d)\n",pat,(pat&0x1ff)); */ + + + + //write low count c0 + pat=(nc-1)|(4<<12)|(1<<9); + bus_w(addr, pat); + bus_w(addr1, pat1); + bus_w(addr1, 0); + pat0=bus_r(PLL_PARAM_OUT_REG); + usleep (1000); + printf("C0 low count status %x\n",pat0); + + //write high count c0 + pat=(nc)|(4<<12)|(0<<9); + bus_w(addr, pat); + bus_w(addr1, pat1); + bus_w(addr1, 0); + pat0=bus_r(PLL_PARAM_OUT_REG); + printf("C0 high count status %x\n",pat0); + usleep (1000); + + //write low count c1 + pat=(nc-1)|(5<<12)|(1<<9); + bus_w(addr, pat); + bus_w(addr1, pat1); + bus_w(addr1, 0); + pat0=bus_r(PLL_PARAM_OUT_REG); + printf("C1 high count status %x\n",pat0); + usleep (1000); + + //write high count c1 + pat=(nc)|(5<<12)|(0<<9); + bus_w(addr, pat); + bus_w(addr1, pat1); + bus_w(addr1, 0); + pat0=bus_r(PLL_PARAM_OUT_REG); + printf("C1 low count status %x\n",pat0); + usleep (1000); + + //reconfigure pll + pat1=0x8; + bus_w(addr1, pat1); + bus_w(addr1, 0); + pat0=bus_r(PLL_PARAM_OUT_REG); + printf("configure status %d\n",pat0); + sleep (1); + printf("finish status %x\n",pat0); + + + bus_w(PLL_CNTRL_REG, 1); //reset PLL + bus_w(PLL_CNTRL_REG, 0); + return 0; } u_int32_t getClockDivider() { - return 0; + int addr, addr1, addr0; + u_int32_t pat,pat1; + + addr0= PLL_PARAM_REG; + addr= PLL_PARAM_OUT_REG; + addr1=PLL_CNTRL_REG; + pat1=0x4; + + + //write low count c0 + pat=(4<<12)|(1<<9); + bus_w(addr0, pat); + bus_w(addr1, pat1); + bus_w(addr1, 0); + usleep (1000); + pat=bus_r(addr); + printf("C0 low count read %x (%d)\n",pat,(pat&0xff)); + + //write high count c0 + pat=(4<<12)|(0<<9); + bus_w(addr0, pat); + bus_w(addr1, pat1); + bus_w(addr1, 0); + usleep (1000); + pat=bus_r(addr); + printf("C0 high count read %x (%d)\n",pat,(pat&0xff)); + + + //write low count c1 + pat=(5<<12)|(1<<9); + bus_w(addr0, pat); + bus_w(addr1, pat1); + bus_w(addr1, 0); + usleep (1000); + pat=bus_r(addr); + printf("C1 low count read %x (%d)\n",pat,(pat&0xff)); + + //write high count c1 + pat=(5<<12)|(0<<9); + bus_w(addr0, pat); + bus_w(addr1, pat1); + bus_w(addr1, 0); + usleep (1000); + pat=bus_r(addr); + printf("C1 high count read %x (%d)\n",pat,(pat&0xff)); + + + return (pat&0xff); + +/* //write low count c0 */ +/* pat=(0<<12)|(7<<9); */ +/* bus_w(addr0, pat); */ +/* bus_w(addr1, pat1); */ +/* bus_w(addr1, 0); */ +/* usleep (1000); */ +/* pat=bus_r(addr); */ +/* printf("N nominal count read %x (%d)\n",pat,pat&0x1ff); */ + +/* //write high count c0 */ +/* pat=(1<<12)|(7<<9); */ +/* bus_w(addr0, pat); */ +/* bus_w(addr1, pat1); */ +/* bus_w(addr1, 0); */ +/* usleep (1000); */ +/* pat=bus_r(addr); */ +/* printf("M nominal count read %x (%d)\n",pat,(pat&0x1ff)); */ + + + +/* if ((pat&0x1ff)!=0) */ +/* return 161/(pat&0x1ff); */ +/* else */ +/* return -1; */ } u_int32_t setSetLength(int d) { @@ -371,6 +548,14 @@ u_int32_t getSetLength() { return 0; } +u_int32_t setOversampling(int d) { + + if (d>=0 && d<=255) + bus_w(OVERSAMPLING_REG, d); + + return bus_r(OVERSAMPLING_REG); +} + u_int32_t setWaitStates(int d1) { return 0; @@ -1445,6 +1630,8 @@ int configureMAC(int ipad,long long int macad,long long int detectormacad, int d // if(val!=0x2820) return -1; + + return adcConfigured; } @@ -1636,6 +1823,7 @@ u_int32_t* fifo_read_event() */ while((t&0x1)==0) { + printf("before readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG)); #ifdef VERYVERBOSE printf("look at me reg:%08x\n",bus_r(LOOK_AT_ME_REG)); #endif @@ -1916,7 +2104,6 @@ int prepareADC(){ valw=valw&(~(0x1<=0) { + if (differentClients==1 && lockStatus==1 && val>=0) { + ret=FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + } else { + switch (arg) { + case CLOCK_DIVIDER: + retval=setClockDivider(val); + break; + + case PHASE_SHIFT: + retval=phaseStep(val); + break; + + case OVERSAMPLING: + retval=setOversampling(val); + break; + + default: + ret=FAIL; + sprintf(mess,"Unknown speed parameter %d",arg); + } + } + } - sendDataOnly(file_des,&ret,sizeof(ret)); - sendDataOnly(file_des,mess,sizeof(mess)); + switch (arg) { + case CLOCK_DIVIDER: + retval=getClockDivider(); + break; + case PHASE_SHIFT: + retval=phaseStep(-1); + break; + + case OVERSAMPLING: + retval=setOversampling(-1); + break; + + default: + ret=FAIL; + sprintf(mess,"Unknown speed parameter %d",arg); + } + } + + + + n = sendDataOnly(file_des,&ret,sizeof(ret)); + if (ret==FAIL) { + n = sendDataOnly(file_des,mess,sizeof(mess)); + } else { + n = sendDataOnly(file_des,&retval,sizeof(retval)); + } return ret; } diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 46db5c198..a6b7ca1dd 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -771,6 +771,14 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSpeed; i++; + descrToFuncMap[i].m_pFuncName="phasestep"; // + descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSpeed; + i++; + + descrToFuncMap[i].m_pFuncName="oversampling"; // + descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSpeed; + i++; + /* settings dump/retrieve */ descrToFuncMap[i].m_pFuncName="config"; descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdConfiguration; @@ -3618,6 +3626,10 @@ string slsDetectorCommand::cmdSpeed(int narg, char *args[], int action) { index=TOT_CLOCK_DIVIDER; else if (cmd=="totdutycycle") index=TOT_DUTY_CYCLE; + else if (cmd=="phasestep") + index=PHASE_SHIFT; + else if (cmd=="oversampling") + index=OVERSAMPLING; else return string("could not decode speed variable ")+cmd; @@ -3629,11 +3641,9 @@ string slsDetectorCommand::cmdSpeed(int narg, char *args[], int action) { return string("cannot scan speed value ")+string(args[1]); } - myDet->setOnline(ONLINE_FLAG); ret=myDet->setSpeed(index,t); - sprintf(answer,"%d",ret); return string(answer); diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h index d260567dc..4dd8e4300 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUsers.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUsers.h @@ -54,9 +54,12 @@ More advanced configuration functions are not implemented and can be written in slsReceiverUsers is a class to receive the data for detectors with external data receiver (e.g. GOTTHARD). Callbacks can be registered to process the data or save them in specific formats. -detectorData is a structure containing the data and additional information which is used to return the data e.g. to the GUi for displaying them. +detectorData is a structure containing the data and additional information which is used to return the data e.g. to the GUI for displaying them. +You can find examples of how this classes can be instatiated in mainClient.cpp and mainReceiver.cpp + + \authors Anna Bergamaschi, Dhanya Maliakal @version 0.2

Currently supported detectors

diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverUsers.h b/slsDetectorSoftware/slsReceiver/slsReceiverUsers.h index 2c3f5ce96..8a5fb0a92 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiverUsers.h +++ b/slsDetectorSoftware/slsReceiver/slsReceiverUsers.h @@ -2,7 +2,7 @@ #ifndef SLS_RECEIVER_USERS_H #define SLS_RECEIVER_USERS_H -#include "slsReceiver_funcs.h" +#include class slsReceiverFuncs;