jungfrau works

This commit is contained in:
Dhanya Maliakal 2015-11-27 15:56:29 +01:00
parent ac53cb2ae4
commit 0958a4544e
7 changed files with 137 additions and 38 deletions

View File

@ -725,9 +725,9 @@ int setSettings(int i, int imod) {
} }
} }
thisSettings=isett; thisSettings=isett;
#ifdef VERBOSE //#ifdef VERBOSE
printf("detector settings are %d\n",thisSettings); printf("detector settings are %d\n",thisSettings);
#endif //#endif
return thisSettings; return thisSettings;
} }

View File

@ -6,10 +6,10 @@
CROSS = bfin-uclinux- CROSS = bfin-uclinux-
CC = $(CROSS)gcc 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 INSTDIR= /tftpboot
INSTMODE= 0777 INSTMODE= 0777
@ -27,6 +27,11 @@ test: clean jungfrauADCTEst
boot: $(OBJS) boot: $(OBJS)
jungfrauDetectorServerTest: $(OBJS)
echo $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
jungfrauDetectorServer: $(OBJS) jungfrauDetectorServer: $(OBJS)
echo $(OBJS) echo $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@) $(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)

View File

@ -1211,7 +1211,7 @@ int64_t setFrames(int64_t value){
} }
int64_t getFrames(){ int64_t getFrames(){
printf("gf"); /*printf("gf");*/
return get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG); 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){ //int configureMAC(int ipad,long long int macad,long long int detectormacad, int detipad, int ival, int udpport){
uint32_t sourceport = 0x7e9a; // 0xE185; 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, */ /* void setheader(uint64_t destmac, uint64_t sourcemac, uint32_t destip, uint32_t sourceip, uint32_t destport, */
/* uint32_t sourceport){ */ /* uint32_t sourceport){ */
@ -1717,7 +1718,11 @@ ip.ip_destip = destip;
bus_w(RX_UDPMACL_AREG,(destmac)&0xFFFFFFFF);//rx_udpmacL_AReg_c bus_w(RX_UDPMACL_AREG,(destmac)&0xFFFFFFFF);//rx_udpmacL_AReg_c
bus_w(DETECTORMACH_AREG,(sourcemac>>32)&0xFFFFFFFF);//detectormacH_AReg_c bus_w(DETECTORMACH_AREG,(sourcemac>>32)&0xFFFFFFFF);//detectormacH_AReg_c
bus_w(DETECTORMACL_AREG,(sourcemac)&0xFFFFFFFF);//detectormacL_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 bus_w(UDPPORTS_AREG,((destport&0xFFFF)<<16)+(sourceport&0xFFFF));//udpports_AReg_c
#endif
bus_w(IPCHKSUM_AREG,(checksum&0xFFFF));//ipchksum_AReg_c bus_w(IPCHKSUM_AREG,(checksum&0xFFFF));//ipchksum_AReg_c
bus_w(CONTROL_REG,GB10_RESET_BIT); bus_w(CONTROL_REG,GB10_RESET_BIT);

View File

@ -1854,7 +1854,35 @@ int get_run_status(int file_des) {
retval= runState(); retval= runState();
printf("\n\nSTATUS=%08x\n",retval); 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 //error
if(retval&SOME_FIFO_FULL_BIT){ if(retval&SOME_FIFO_FULL_BIT){
printf("-----------------------------------ERROR--------------------------------------x%0x\n",retval); printf("-----------------------------------ERROR--------------------------------------x%0x\n",retval);
@ -1900,7 +1928,7 @@ int get_run_status(int file_des) {
} }
} }
#endif
if (ret!=OK) { if (ret!=OK) {
@ -1932,6 +1960,7 @@ int read_frame(int file_des) {
if (differentClients==1 && lockStatus==1) { if (differentClients==1 && lockStatus==1) {
dataret=FAIL; 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,&dataret,sizeof(dataret));
sendDataOnly(file_des,mess,sizeof(mess)); sendDataOnly(file_des,mess,sizeof(mess));
#ifdef VERBOSE #ifdef VERBOSE
@ -1940,6 +1969,29 @@ int read_frame(int file_des) {
return dataret; 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(); p=fifo_read_frame();
if (p) { if (p) {
nframes++; nframes++;
@ -1971,6 +2023,10 @@ int read_frame(int file_des) {
sendDataOnly(file_des,&dataret,sizeof(dataret)); sendDataOnly(file_des,&dataret,sizeof(dataret));
sendDataOnly(file_des,mess,sizeof(mess)); sendDataOnly(file_des,mess,sizeof(mess));
} }
#endif
return dataret; return dataret;
} }

View File

@ -4618,7 +4618,6 @@ int* multiSlsDetector::readFrameFromReceiver(char* fName, int &acquisitionIndex
acquisitionIndex = -1; acquisitionIndex = -1;
return NULL; return NULL;
} }
int n,complete=OK; int n,complete=OK;
int i,k,offsetX, offsetY, maxX, maxY; double dr; int i,k,offsetX, offsetY, maxX, maxY; double dr;
int* retval=new int[nel]; int* retval=new int[nel];

View File

@ -72,6 +72,14 @@ int slsDetector::initSharedMemory(detectorType type, int id) {
ng=0; ng=0;
no=0; no=0;
break; break;
case JUNGFRAU:
nch=256*256;
nm=1; //modules/detector
nc=8; //chips
nd=16; //dacs+adcs
ng=0;
no=0;
break;
case JUNGFRAUCTB: case JUNGFRAUCTB:
nch=32; nch=32;
nm=1; //modules/detector nm=1; //modules/detector
@ -612,6 +620,19 @@ int slsDetector::initializeDetectorSize(detectorType type) {
thisDetector->nModMax[Y]=1; thisDetector->nModMax[Y]=1;
thisDetector->dynamicRange=16; thisDetector->dynamicRange=16;
break; 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: case JUNGFRAUCTB:
thisDetector->nChan[X]=32; thisDetector->nChan[X]=32;
thisDetector->nChan[Y]=1; thisDetector->nChan[Y]=1;
@ -837,6 +858,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
setFramesPerFile(MAX_FRAMES_PER_FILE); setFramesPerFile(MAX_FRAMES_PER_FILE);
if (thisDetector->myDetectorType==MOENCH) if (thisDetector->myDetectorType==MOENCH)
setFramesPerFile(MOENCH_MAX_FRAMES_PER_FILE); setFramesPerFile(MOENCH_MAX_FRAMES_PER_FILE);
if (thisDetector->myDetectorType==JUNGFRAU)
setFramesPerFile(JFRAU_MAX_FRAMES_PER_FILE);
if (thisDetector->myDetectorType==JUNGFRAUCTB) if (thisDetector->myDetectorType==JUNGFRAUCTB)
setFramesPerFile(JFCTB_MAX_FRAMES_PER_FILE); setFramesPerFile(JFCTB_MAX_FRAMES_PER_FILE);
thisReceiver = new receiverInterface(dataSocket); thisReceiver = new receiverInterface(dataSocket);
@ -972,6 +995,13 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType t)
nd=8; //dacs nd=8; //dacs
na=1; na=1;
break; break;
case JUNGFRAU:
nch=256*256;//32;
nm=1;
nc=4*2;
nd=16; // dacs+adcs
na=0;
break;
case JUNGFRAUCTB: case JUNGFRAUCTB:
nch=32;//32; nch=32;//32;
nm=1; nm=1;
@ -3342,6 +3372,7 @@ int slsDetector::updateDetectorNoWait() {
if((thisDetector->myDetectorType!= GOTTHARD)&& if((thisDetector->myDetectorType!= GOTTHARD)&&
(thisDetector->myDetectorType!= PROPIX)&& (thisDetector->myDetectorType!= PROPIX)&&
(thisDetector->myDetectorType!= JUNGFRAU)&&
(thisDetector->myDetectorType!= MOENCH)){ (thisDetector->myDetectorType!= MOENCH)){
//thr=getThresholdEnergy(); //thr=getThresholdEnergy();
n = controlSocket->ReceiveDataOnly( &thr,sizeof(thr)); n = controlSocket->ReceiveDataOnly( &thr,sizeof(thr));
@ -3600,7 +3631,7 @@ int* slsDetector::getDataFromDetector(int *retval){
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: 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;
ret=FAIL; ret=FAIL;
if (r==NULL) { if (r==NULL) {
@ -3821,6 +3852,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
thisDetector->timerValue[index]=t; thisDetector->timerValue[index]=t;
if((thisDetector->myDetectorType==GOTTHARD)|| if((thisDetector->myDetectorType==GOTTHARD)||
(thisDetector->myDetectorType==PROPIX)|| (thisDetector->myDetectorType==PROPIX)||
(thisDetector->myDetectorType==JUNGFRAU)||
(thisDetector->myDetectorType==MOENCH)) (thisDetector->myDetectorType==MOENCH))
thisDetector->timerValue[PROBES_NUMBER]=0; thisDetector->timerValue[PROBES_NUMBER]=0;
} }
@ -5948,6 +5980,7 @@ int slsDetector::writeConfigurationFile(ofstream &outfile, int id){
if ((thisDetector->myDetectorType==GOTTHARD)|| if ((thisDetector->myDetectorType==GOTTHARD)||
(thisDetector->myDetectorType==PROPIX)|| (thisDetector->myDetectorType==PROPIX)||
(thisDetector->myDetectorType==JUNGFRAU)||
(thisDetector->myDetectorType==MOENCH)) { (thisDetector->myDetectorType==MOENCH)) {
names[0]= "hostname"; names[0]= "hostname";
names[1]= "port"; names[1]= "port";
@ -6589,7 +6622,7 @@ int slsDetector::startReceiver(){
setErrorMask((getErrorMask())|(COULDNOT_START_RECEIVER)); setErrorMask((getErrorMask())|(COULDNOT_START_RECEIVER));
} }
} }
if((ret==OK))//&& (thisDetector->myDetectorType != EIGER)) if((ret==OK) && (thisDetector->myDetectorType != JUNGFRAU))
ret=detectorSendToReceiver(true); ret=detectorSendToReceiver(true);
return ret; return ret;
@ -6603,7 +6636,7 @@ int slsDetector::stopReceiver(){
int ret = FAIL; int ret = FAIL;
char mess[] = ""; char mess[] = "";
if(thisDetector->myDetectorType != EIGER) if(thisDetector->myDetectorType != EIGER && thisDetector->myDetectorType != JUNGFRAU)
detectorSendToReceiver(false); detectorSendToReceiver(false);
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
@ -6781,7 +6814,6 @@ int* slsDetector::readFrameFromReceiver(char* fName, int &acquisitionIndex, int
int n; int n;
char mess[100]="Nothing"; char mess[100]="Nothing";
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) { if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "slsDetector: Reading frame from receiver "<< thisDetector->dataBytes << " " <<nel <<std::endl; std::cout<< "slsDetector: Reading frame from receiver "<< thisDetector->dataBytes << " " <<nel <<std::endl;

View File

@ -362,7 +362,7 @@ int slsDetectorUtils::acquire(int delflag){
usleep(100000); usleep(100000);
}*/ }*/
if ((getDetectorsType()==GOTTHARD) || (getDetectorsType()==MOENCH)){ if ((getDetectorsType()==GOTTHARD) || (getDetectorsType()==MOENCH) || (getDetectorsType()==JUNGFRAU) ){
if((*correctionMask)&(1<<WRITE_FILE)) if((*correctionMask)&(1<<WRITE_FILE))
closeDataFile(); closeDataFile();
} }
@ -836,6 +836,7 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
break; break;
case GOTTHARD: case GOTTHARD:
case PROPIX: case PROPIX:
case JUNGFRAU:
names[nvar++]="flags"; names[nvar++]="flags";
names[nvar++]="delay"; names[nvar++]="delay";
names[nvar++]="gates"; names[nvar++]="gates";
@ -920,6 +921,7 @@ int slsDetectorUtils::dumpDetectorSetup(string const fname, int level){
case MYTHEN: case MYTHEN:
case GOTTHARD: case GOTTHARD:
case PROPIX: case PROPIX:
case JUNGFRAU:
names[nvar++]="flatfield"; names[nvar++]="flatfield";
names[nvar++]="badchannels"; names[nvar++]="badchannels";
break; break;