diff --git a/slsDetectorSoftware/gotthardDetectorServer/mcb_funcs.c b/slsDetectorSoftware/gotthardDetectorServer/mcb_funcs.c index 577b740a1..4670e4968 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/mcb_funcs.c +++ b/slsDetectorSoftware/gotthardDetectorServer/mcb_funcs.c @@ -725,9 +725,9 @@ int setSettings(int i, int imod) { } } thisSettings=isett; -#ifdef VERBOSE +//#ifdef VERBOSE printf("detector settings are %d\n",thisSettings); -#endif +//#endif return thisSettings; } diff --git a/slsDetectorSoftware/jungfrauDetectorServer/Makefile b/slsDetectorSoftware/jungfrauDetectorServer/Makefile index 6333c7b88..1a5b41550 100755 --- a/slsDetectorSoftware/jungfrauDetectorServer/Makefile +++ b/slsDetectorSoftware/jungfrauDetectorServer/Makefile @@ -6,10 +6,10 @@ CROSS = bfin-uclinux- CC = $(CROSS)gcc -CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DV1#-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER +CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DV1 -DJUNGFRAU_DHANYA #-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER -PROGS= jungfrauDetectorServer +PROGS= jungfrauDetectorServerTest INSTDIR= /tftpboot INSTMODE= 0777 @@ -27,6 +27,11 @@ test: clean jungfrauADCTEst boot: $(OBJS) +jungfrauDetectorServerTest: $(OBJS) + echo $(OBJS) + $(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@) + + jungfrauDetectorServer: $(OBJS) echo $(OBJS) $(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@) diff --git a/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c b/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c index c2fcde194..eff5027c6 100755 --- a/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c +++ b/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c @@ -1211,7 +1211,7 @@ int64_t setFrames(int64_t value){ } int64_t getFrames(){ - printf("gf"); + /*printf("gf");*/ return get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG); } @@ -1671,7 +1671,8 @@ int configureMAC(uint32_t destip,uint64_t destmac,uint64_t sourcemac,int source //int configureMAC(int ipad,long long int macad,long long int detectormacad, int detipad, int ival, int udpport){ uint32_t sourceport = 0x7e9a; // 0xE185; - //setheader(0xF452142F3200,0x00ad29ae39fd,0x0a000264,0x0A00020d ,0x8436, 0x7e9a); + + //setheader(0xF452142F3200,0x00ad29ae39fd,0x0a000264,0x0A00020d ,0x8436, 0x7e9a); /* void setheader(uint64_t destmac, uint64_t sourcemac, uint32_t destip, uint32_t sourceip, uint32_t destport, */ /* uint32_t sourceport){ */ @@ -1717,7 +1718,11 @@ ip.ip_destip = destip; bus_w(RX_UDPMACL_AREG,(destmac)&0xFFFFFFFF);//rx_udpmacL_AReg_c bus_w(DETECTORMACH_AREG,(sourcemac>>32)&0xFFFFFFFF);//detectormacH_AReg_c bus_w(DETECTORMACL_AREG,(sourcemac)&0xFFFFFFFF);//detectormacL_AReg_c +#ifdef JUNGFRAU_DHANYA + bus_w(UDPPORTS_AREG,((sourceport&0xFFFF)<<16)+(destport&0xFFFF));//udpports_AReg_c +#else bus_w(UDPPORTS_AREG,((destport&0xFFFF)<<16)+(sourceport&0xFFFF));//udpports_AReg_c +#endif bus_w(IPCHKSUM_AREG,(checksum&0xFFFF));//ipchksum_AReg_c bus_w(CONTROL_REG,GB10_RESET_BIT); @@ -2102,12 +2107,12 @@ u_int16_t* fifo_read_event(int ns) { int i=0;//, j=0; /* volatile u_int16_t volatile *dum; */ - volatile u_int16_t a; - volatile u_int32_t val; + volatile u_int16_t a; + volatile u_int32_t val; // volatile u_int32_t volatile *dum; // volatile u_int32_t a; - bus_w16(DUMMY_REG,0); // + bus_w16(DUMMY_REG,0); // /* #ifdef TIMEDBG */ /* gettimeofday(&tse,NULL); */ /* #endif */ @@ -2122,9 +2127,9 @@ u_int16_t* fifo_read_event(int ns) printf("no frame found and acquisition finished - exiting\n"); printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG)); return NULL; - } else { - // printf("status idle, look at me %x status %x\n", bus_r(LOOK_AT_ME_REG),runState()); - break; + } else { + // printf("status idle, look at me %x status %x\n", bus_r(LOOK_AT_ME_REG),runState()); + break; } } a = bus_r(LOOK_AT_ME_REG); @@ -2136,19 +2141,19 @@ u_int16_t* fifo_read_event(int ns) /* // tsss=tss; */ /* gettimeofday(&tss,NULL); */ /* printf("look for data = %ld usec\n", (tss.tv_usec) - (tse.tv_usec)); */ - + /* #endif */ } // printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG)); /* dma_memcpy(now_ptr,values ,dataBytes); */ /* #else */ - + bus_w16(DUMMY_REG,1<<8); // read strobe to all fifos - bus_w16(DUMMY_REG,0); + bus_w16(DUMMY_REG,0); // i=0;// /* for (i=0; i<32; i++) { */ - + /* /\* while (((adcDisableMask&(3<<((i)*2)))>>((i)*2))==3) { *\/ */ /* /\* i++; *\/ */ /* /\* if (i>15) *\/ */ @@ -2158,12 +2163,12 @@ u_int16_t* fifo_read_event(int ns) /* bus_w16(DUMMY_REG,i); */ /* } */ /* val=*values; */ - - // bus_w16(DUMMY_REG,0); // - for (i=0; i<16; i++) { - + // bus_w16(DUMMY_REG,0); // + for (i=0; i<16; i++) { + + // bus_w16(DUMMY_REG,i); // bus_r16(DUMMY_REG); /* dum=(((u_int16_t*)(now_ptr))+i); */ @@ -2174,36 +2179,36 @@ u_int16_t* fifo_read_event(int ns) // a=*values;//bus_r(FIFO_DATA_REG); // if ((adcDisableMask&(3<<(i*2)))==0) { *((u_int32_t*)now_ptr)=*values;//bus_r(FIFO_DATA_REG); - - + + if (i!=0 || ns!=0) { a=0; while (*((u_int32_t*)now_ptr)==*((u_int32_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_int32_t*)now_ptr)=*values; // printf("%d-",i); - + } } now_ptr+=4; - // } + // } /* while (((adcDisableMask&(3<<((i+1)*2)))>>((i+1)*2))==3) { */ /* i++; */ /* } */ // if (((adcDisableMask&(3<<((i+1)*2)))>>((i+1)*2))!=3) { - + bus_w16(DUMMY_REG,i+1); // } // *(((u_int16_t*)(now_ptr))+i)=bus_r16(FIFO_DATA_REG); - } - // bus_w16(DUMMY_REG,0); // + } + // bus_w16(DUMMY_REG,0); // /* #ifdef TIMEDBG */ - + /* gettimeofday(&tss,NULL); */ /* printf("read data loop = %ld usec\n",(tss.tv_usec) - (tse.tv_usec)); */ - + /* #endif */ #ifdef VERBOSE printf("*"); diff --git a/slsDetectorSoftware/jungfrauDetectorServer/server_funcs.c b/slsDetectorSoftware/jungfrauDetectorServer/server_funcs.c index 30afd1dbf..f962c5ab9 100755 --- a/slsDetectorSoftware/jungfrauDetectorServer/server_funcs.c +++ b/slsDetectorSoftware/jungfrauDetectorServer/server_funcs.c @@ -1854,7 +1854,35 @@ int get_run_status(int file_des) { retval= runState(); printf("\n\nSTATUS=%08x\n",retval); +#ifdef JUNGFRAU_DHANYA + if(!(retval&RUN_BUSY_BIT)){ + if((retval&READMACHINE_BUSY_BIT) ){ + printf("-----------------------------------READ MACHINE BUSY--------------------------\n"); + s=TRANSMITTING; + } + //and readbusy=0,idle + else if((!(retval&0xffff))||(retval==SOME_FIFO_FULL_BIT)){ + printf("-----------------------------------IDLE--------------------------------------\n"); + s=IDLE; + } else { + printf("-----------------------------------Unknown status %08x--------------------------------------\n", retval); + s=ERROR; + ret=FAIL; + } + } + //if runbusy=1 + else { + if (retval&WAITING_FOR_TRIGGER_BIT){ + printf("-----------------------------------WAITING-----------------------------------\n"); + s=WAITING; + } + else{ + printf("-----------------------------------RUNNING-----------------------------------\n"); + s=RUNNING; + } + } +#else //error if(retval&SOME_FIFO_FULL_BIT){ printf("-----------------------------------ERROR--------------------------------------x%0x\n",retval); @@ -1900,7 +1928,7 @@ int get_run_status(int file_des) { } } - +#endif if (ret!=OK) { @@ -1931,7 +1959,8 @@ int read_frame(int file_des) { if (differentClients==1 && lockStatus==1) { dataret=FAIL; - sprintf(mess,"Detector locked by %s\n",lastClientIP); + sprintf(mess,"Detector locked by %s\n",lastClientIP); + printf("Warning: %s\n",mess); sendDataOnly(file_des,&dataret,sizeof(dataret)); sendDataOnly(file_des,mess,sizeof(mess)); #ifdef VERBOSE @@ -1940,6 +1969,29 @@ int read_frame(int file_des) { return dataret; } + + +#ifdef JUNGFRAU_DHANYA1 + while(runBusy()){ + usleep(0); + if (getFrames() <= -1) { + printf("no frames left, but still busy\n"); + } + } + if (getFrames() > -1) { + dataret=FAIL; + sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames())); + printf("Warning: %s\n",mess); + }else{ + dataret = FINISHED; + sprintf(mess,"acquisition successfully finished\n"); + printf("%s\n",mess); + } + sendDataOnly(file_des,&dataret,sizeof(dataret)); + sendDataOnly(file_des,mess,sizeof(mess)); + //dataret is never ok to send databytes for jungfrau (not reading from fifo) +#else + p=fifo_read_frame(); if (p) { nframes++; @@ -1971,6 +2023,10 @@ int read_frame(int file_des) { sendDataOnly(file_des,&dataret,sizeof(dataret)); sendDataOnly(file_des,mess,sizeof(mess)); } + +#endif + + return dataret; } diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 446b5e936..bfc2bd293 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -4618,7 +4618,6 @@ int* multiSlsDetector::readFrameFromReceiver(char* fName, int &acquisitionIndex acquisitionIndex = -1; return NULL; } - int n,complete=OK; int i,k,offsetX, offsetY, maxX, maxY; double dr; int* retval=new int[nel]; diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 8b0581c8b..f8d91aa47 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -72,6 +72,14 @@ int slsDetector::initSharedMemory(detectorType type, int id) { ng=0; no=0; break; + case JUNGFRAU: + nch=256*256; + nm=1; //modules/detector + nc=8; //chips + nd=16; //dacs+adcs + ng=0; + no=0; + break; case JUNGFRAUCTB: nch=32; nm=1; //modules/detector @@ -612,6 +620,19 @@ int slsDetector::initializeDetectorSize(detectorType type) { thisDetector->nModMax[Y]=1; thisDetector->dynamicRange=16; break; + case JUNGFRAU: + thisDetector->nChan[X]=256; + thisDetector->nChan[Y]=256; + thisDetector->nChip[X]=4; + thisDetector->nChip[Y]=2; + thisDetector->nDacs=16; + thisDetector->nAdcs=0; + thisDetector->nGain=0; + thisDetector->nOffset=0; + thisDetector->nModMax[X]=1; + thisDetector->nModMax[Y]=1; + thisDetector->dynamicRange=16; + break; case JUNGFRAUCTB: thisDetector->nChan[X]=32; thisDetector->nChan[Y]=1; @@ -837,6 +858,8 @@ int slsDetector::initializeDetectorSize(detectorType type) { setFramesPerFile(MAX_FRAMES_PER_FILE); if (thisDetector->myDetectorType==MOENCH) setFramesPerFile(MOENCH_MAX_FRAMES_PER_FILE); + if (thisDetector->myDetectorType==JUNGFRAU) + setFramesPerFile(JFRAU_MAX_FRAMES_PER_FILE); if (thisDetector->myDetectorType==JUNGFRAUCTB) setFramesPerFile(JFCTB_MAX_FRAMES_PER_FILE); thisReceiver = new receiverInterface(dataSocket); @@ -972,6 +995,13 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType t) nd=8; //dacs na=1; break; + case JUNGFRAU: + nch=256*256;//32; + nm=1; + nc=4*2; + nd=16; // dacs+adcs + na=0; + break; case JUNGFRAUCTB: nch=32;//32; nm=1; @@ -3342,6 +3372,7 @@ int slsDetector::updateDetectorNoWait() { if((thisDetector->myDetectorType!= GOTTHARD)&& (thisDetector->myDetectorType!= PROPIX)&& + (thisDetector->myDetectorType!= JUNGFRAU)&& (thisDetector->myDetectorType!= MOENCH)){ //thr=getThresholdEnergy(); n = controlSocket->ReceiveDataOnly( &thr,sizeof(thr)); @@ -3600,7 +3631,7 @@ int* slsDetector::getDataFromDetector(int *retval){ std::cout<< "Received "<< n << " data bytes" << std::endl; #endif if (n!=thisDetector->dataBytes) { - std::cout<< "wrong data size received: 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; ret=FAIL; if (r==NULL) { @@ -3821,6 +3852,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){ thisDetector->timerValue[index]=t; if((thisDetector->myDetectorType==GOTTHARD)|| (thisDetector->myDetectorType==PROPIX)|| + (thisDetector->myDetectorType==JUNGFRAU)|| (thisDetector->myDetectorType==MOENCH)) thisDetector->timerValue[PROBES_NUMBER]=0; } @@ -5948,6 +5980,7 @@ int slsDetector::writeConfigurationFile(ofstream &outfile, int id){ if ((thisDetector->myDetectorType==GOTTHARD)|| (thisDetector->myDetectorType==PROPIX)|| + (thisDetector->myDetectorType==JUNGFRAU)|| (thisDetector->myDetectorType==MOENCH)) { names[0]= "hostname"; names[1]= "port"; @@ -6589,7 +6622,7 @@ int slsDetector::startReceiver(){ setErrorMask((getErrorMask())|(COULDNOT_START_RECEIVER)); } } - if((ret==OK))//&& (thisDetector->myDetectorType != EIGER)) + if((ret==OK) && (thisDetector->myDetectorType != JUNGFRAU)) ret=detectorSendToReceiver(true); return ret; @@ -6603,7 +6636,7 @@ int slsDetector::stopReceiver(){ int ret = FAIL; char mess[] = ""; - if(thisDetector->myDetectorType != EIGER) + if(thisDetector->myDetectorType != EIGER && thisDetector->myDetectorType != JUNGFRAU) detectorSendToReceiver(false); if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { @@ -6781,7 +6814,6 @@ int* slsDetector::readFrameFromReceiver(char* fName, int &acquisitionIndex, int int n; char mess[100]="Nothing"; - if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { #ifdef VERBOSE std::cout<< "slsDetector: Reading frame from receiver "<< thisDetector->dataBytes << " " <