module acquisition works, edit getrunstatus, added a small code for master incomplete, adjusted server to look for element in position 1 instead of zero

This commit is contained in:
Maliakal Dhanya
2014-10-06 11:01:51 +02:00
parent d8c7201749
commit 347a36b7c1
6 changed files with 60 additions and 45 deletions

View File

@ -694,7 +694,7 @@ int Feb_Control_SendHighVoltage(unsigned int dst_num,float* value){
int Feb_Control_DecodeDACString(char* dac_str, unsigned int* module_index, int* top, int* bottom, unsigned int* dac_ch){ int Feb_Control_DecodeDACString(char* dac_str, unsigned int* module_index, int* top, int* bottom, unsigned int* dac_ch){
char* local_s = dac_str; char* local_s = dac_str;
char temp[50]; char temp[50];
*module_index = 0; *module_index = 1;
char* p1 = strstr(local_s,"mod");//size_t p1 = local_s.find("mod"); char* p1 = strstr(local_s,"mod");//size_t p1 = local_s.find("mod");
char* p2 = strstr(local_s,"::");//size_t p2 =local_s.find("::"); char* p2 = strstr(local_s,"::");//size_t p2 =local_s.find("::");
@ -729,6 +729,15 @@ int Feb_Control_DecodeDACString(char* dac_str, unsigned int* module_index, int*
strcpy(local_s,p1+8); strcpy(local_s,p1+8);
*top=0; *top=0;
} }
/*
if(Module_BottomAddressIsValid(&modules[*module_index]))
*top=0;
else
*bottom=0;
printf("*****************top %d bottom %d\n",*top,*bottom);
*/
*dac_ch = 0; *dac_ch = 0;
if(!Feb_Control_GetDACNumber(local_s,dac_ch)){ if(!Feb_Control_GetDACNumber(local_s,dac_ch)){
printf("Error in dac_name: %s (%s)\n",dac_str,local_s); printf("Error in dac_name: %s (%s)\n",dac_str,local_s);
@ -955,8 +964,8 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits){
} //end row loop } //end row loop
if(!Feb_Interface_WriteMemoryInLoops(Module_GetTopLeftAddress(&modules[0]),0,0,1024,trimbits_to_load_r)|| if(!Feb_Interface_WriteMemoryInLoops(Module_GetTopLeftAddress(&modules[1]),0,0,1024,trimbits_to_load_r)||
!Feb_Interface_WriteMemoryInLoops(Module_GetTopRightAddress(&modules[0]),0,0,1024,trimbits_to_load_l)|| !Feb_Interface_WriteMemoryInLoops(Module_GetTopRightAddress(&modules[1]),0,0,1024,trimbits_to_load_l)||
//if(!Feb_Interface_WriteMemory(Module_GetTopLeftAddress(&modules[0]),0,0,1023,trimbits_to_load_r)|| //if(!Feb_Interface_WriteMemory(Module_GetTopLeftAddress(&modules[0]),0,0,1023,trimbits_to_load_r)||
// !Feb_Interface_WriteMemory(Module_GetTopRightAddress(&modules[0]),0,0,1023,trimbits_to_load_l)|| // !Feb_Interface_WriteMemory(Module_GetTopRightAddress(&modules[0]),0,0,1023,trimbits_to_load_l)||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){ !Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
@ -982,11 +991,14 @@ unsigned int* Feb_Control_GetTrimbits(){
unsigned int Feb_Control_AddressToAll(){ unsigned int Feb_Control_AddressToAll(){
if(moduleSize==0) return 0; if(moduleSize==0) return 0;
if(Module_BottomAddressIsValid(&modules[1])){//printf("************* bottom\n");
return Module_GetBottomLeftAddress(&modules[1])|Module_GetBottomRightAddress(&modules[1]);}
//printf("************* top\n"); if(Module_BottomAddressIsValid(&modules[0])){
return Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1]); //printf("************* bottom\n");
return Module_GetBottomLeftAddress(&modules[0])|Module_GetBottomRightAddress(&modules[0]);
}
// printf("************* top\n");
return Module_GetTopLeftAddress(&modules[0])|Module_GetTopRightAddress(&modules[0]);
} }
int Feb_Control_SetCommandRegister(unsigned int cmd){ int Feb_Control_SetCommandRegister(unsigned int cmd){
@ -1035,18 +1047,18 @@ int Feb_Control_AcquisitionInProgress(){
//printf("right:%d\n",Feb_Control_GetDAQStatusRegister(Module_GetTopRightAddress(&modules[1]),&status_reg_r)); //printf("right:%d\n",Feb_Control_GetDAQStatusRegister(Module_GetTopRightAddress(&modules[1]),&status_reg_r));
//printf("left:%d\n",Feb_Control_GetDAQStatusRegister(Module_GetTopLeftAddress(&modules[1]),&status_reg_l)); //printf("left:%d\n",Feb_Control_GetDAQStatusRegister(Module_GetTopLeftAddress(&modules[1]),&status_reg_l));
if(Module_BottomAddressIsValid(&modules[0])){ if(Module_BottomAddressIsValid(&modules[1])){
//printf("************* bottom1\n"); //printf("************* bottom1\n");
if(!(Feb_Control_GetDAQStatusRegister(Module_GetBottomRightAddress(&modules[1]),&status_reg_r))) if(!(Feb_Control_GetDAQStatusRegister(Module_GetBottomRightAddress(&modules[1]),&status_reg_r)))
return 0; {printf("**idle\n");return 0;}
}else{ }else{
//printf("************* top1\n"); //printf("************* top1\n");
if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopRightAddress(&modules[1]),&status_reg_r))) if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopRightAddress(&modules[1]),&status_reg_r)))
return 0; {printf("**idle\n");return 0;}
} }
if(status_reg_r&DAQ_STATUS_DAQ_RUNNING) return 1; if(status_reg_r&DAQ_STATUS_DAQ_RUNNING) {printf("******running\n");return 1;}
/* /*
if(!(GetDAQStatusRegister(modules[i]->Module_GetTopLeftAddress(),status_reg_r)&&GetDAQStatusRegister(modules[i]->Module_GetTopRightAddress(),status_reg_l))){ if(!(GetDAQStatusRegister(modules[i]->Module_GetTopLeftAddress(),status_reg_r)&&GetDAQStatusRegister(modules[i]->Module_GetTopRightAddress(),status_reg_l))){
@ -1057,7 +1069,7 @@ int Feb_Control_AcquisitionInProgress(){
} }
*/ */
return 0; //i.e. not running (status_reg_r|status_reg_l)&DAQ_STATUS_DAQ_RUNNING; printf("**idle\n");return 0; //i.e. not running (status_reg_r|status_reg_l)&DAQ_STATUS_DAQ_RUNNING;
} }
int Feb_Control_Reset(){ int Feb_Control_Reset(){
@ -1370,7 +1382,7 @@ int Feb_Control_WriteNRead(char* message, int length, int max_length){
} }
*/ */
int Feb_Control_StartAcquisition(){ int Feb_Control_StartAcquisition(){printf("****** starting acquisition********* \n");
static unsigned int reg_nums[20]; static unsigned int reg_nums[20];
static unsigned int reg_vals[20]; static unsigned int reg_vals[20];

View File

@ -1,6 +1,6 @@
CC = powerpc-4xx-softfloat-gcc CC = powerpc-4xx-softfloat-gcc
CCX = powerpc-4xx-softfloat-g++ CCX = powerpc-4xx-softfloat-g++
CFLAGS += -Wall -DDACS_INT -DEIGERD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSE #-DVIRTUAL -DPCCOMPILE CFLAGS += -Wall -DDACS_INT -DEIGERD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT #-DSTOP_SERVER #-DVERBOSE #-DVIRTUAL -DPCCOMPILE
LDLIBS += -lm -lstdc++ LDLIBS += -lm -lstdc++
PROGS = eigerDetectorServer PROGS = eigerDetectorServer

View File

@ -53,7 +53,8 @@ int dst_requested[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
int default_dac_values[16] = {0,2000,2000,1250,700,1278,500,500,2000,500,500,550,550,100,1000,775}; int default_dac_values[16] = {0,2000,2000,1250,700,1278,500,500,2000,500,500,550,550,100,1000,775};
enum masterFlags masterMode=NO_MASTER;
enum masterFlags trialMasterMode=NO_MASTER;
int initDetector(){ int initDetector(){
int imod,i,n; int imod,i,n;
@ -128,9 +129,12 @@ int initDetector(){
setHighVolage(150,0); setHighVolage(150,0);
setIODelay(675,0); setIODelay(675,0);
setTiming(AUTO_TIMING); setTiming(AUTO_TIMING);
setMaster(GET_MASTER);
int enable[2] = {0,1}; int enable[2] = {0,1};
setExternalGating(enable);//disable external gating setExternalGating(enable);//disable external gating
if(getDetectorNumber() == 0xbeb031)
trialMasterMode = IS_MASTER;
return 1; return 1;
} }
@ -453,8 +457,13 @@ enum detectorSettings setSettings(enum detectorSettings sett, int imod){
int startStateMachine(){ int startStateMachine(){
printf("Going to start acquisition\n"); printf("Going to start acquisition\n");
if(Feb_Control_StartAcquisition()){
if(trialMasterMode == IS_MASTER)
Feb_Control_StartAcquisition();
printf("requesting images\n");
//RequestImages(); //RequestImages();
int ret_val = 0; int ret_val = 0;
dst_requested[0] = 1; dst_requested[0] = 1;
@ -471,15 +480,19 @@ int startStateMachine(){
return FAIL; return FAIL;
else else
return OK; return OK;
}
return FAIL; return FAIL;
} }
int stopStateMachine(){ int stopStateMachine(){
printf("Going to stop acquisition\n"); printf("Going to stop acquisition\n");
if(Feb_Control_StopAcquisition())
return OK; if(trialMasterMode == IS_MASTER){
if(Feb_Control_StopAcquisition())
return OK;
}else return OK;
return FAIL; return FAIL;
} }
@ -885,7 +898,10 @@ void setExternalGating(int enable[]){
enum masterFlags setMaster(enum masterFlags arg){ enum masterFlags setMaster(enum masterFlags arg){
return NO_MASTER; if(arg != GET_MASTER)
masterMode = arg;
return arg;
} }

View File

@ -1198,15 +1198,6 @@ int multiSlsDetector::startAcquisition(){
int i=0; int i=0;
int ret=OK, ret1=OK; int ret=OK, ret1=OK;
if (detectors[0]) {
ret=detectors[0]->startAcquisition();
if(detectors[0]->getErrorMask())
setErrorMask(getErrorMask()|(1<<i));
if (ret!=OK)
ret1=FAIL;
}
/*
for (i=0; i<thisMultiDetector->numberOfDetectors; i++) { for (i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (i!=thisMultiDetector->masterPosition) if (i!=thisMultiDetector->masterPosition)
if (detectors[i]) { if (detectors[i]) {
@ -1226,7 +1217,7 @@ int multiSlsDetector::startAcquisition(){
if (ret!=OK) if (ret!=OK)
ret1=FAIL; ret1=FAIL;
} }
}*/ }
return ret1; return ret1;
}; };
@ -1515,6 +1506,7 @@ int multiSlsDetector::startAndReadAllNoWait(){
ret1=FAIL; ret1=FAIL;
} }
} }
return ret1; return ret1;
} }
@ -1536,20 +1528,16 @@ slsDetectorDefs::runStatus multiSlsDetector::getRunStatus() {
return s; return s;
} }
if (detectors[0]){
s=detectors[0]->getRunStatus();
if(detectors[0]->getErrorMask())
setErrorMask(getErrorMask()|(1<<0));
}
for (int i=1; i<thisMultiDetector->numberOfDetectors; i++) { for (int i=1; i<thisMultiDetector->numberOfDetectors; i++) {
s1=detectors[i]->getRunStatus(); s1=detectors[i]->getRunStatus();
if(detectors[i]->getErrorMask()) if(detectors[i]->getErrorMask())
setErrorMask(getErrorMask()|(1<<i)); setErrorMask(getErrorMask()|(1<<i));
if (s1==ERROR) if (s1==ERROR)
s=ERROR; s=ERROR;
if (s1==IDLE && s!=IDLE) if (s1!=IDLE)
s=ERROR; s = s1;
// if (s1==IDLE && s!=IDLE)
// s=ERROR;
} }
return s; return s;

View File

@ -2963,7 +2963,7 @@ int execute_trimming(int file_des) {
int configure_mac(int file_des) {printf("in hereeeeee\n"); int configure_mac(int file_des) {
int retval=-100; int retval=-100;
int ret=OK,ret1=OK; int ret=OK,ret1=OK;
@ -2979,7 +2979,7 @@ int configure_mac(int file_des) {printf("in hereeeeee\n");
int udpport2; int udpport2;
int detipad; int detipad;
#endif #endif
printf("111\n");
sprintf(mess,"Can't configure MAC\n"); sprintf(mess,"Can't configure MAC\n");
n = receiveData(file_des,arg,sizeof(arg),OTHER); n = receiveData(file_des,arg,sizeof(arg),OTHER);
@ -2987,7 +2987,7 @@ printf("111\n");
sprintf(mess,"Error reading from socket\n"); sprintf(mess,"Error reading from socket\n");
ret=FAIL; ret=FAIL;
} }
printf("222\n");
#ifdef MYTHEND #ifdef MYTHEND
ret = FAIL; ret = FAIL;
strcpy(mess,"Not applicable/implemented for this detector\n"); strcpy(mess,"Not applicable/implemented for this detector\n");
@ -3007,7 +3007,6 @@ printf("222\n");
printf("mess:%s\n",mess); printf("mess:%s\n",mess);
} }
#endif #endif
printf("333\n");
//#ifdef VERBOSE //#ifdef VERBOSE
int i; int i;
/*printf("\ndigital_test_bit in server %d\t",digitalTestBit);for gotthard*/ /*printf("\ndigital_test_bit in server %d\t",digitalTestBit);for gotthard*/
@ -3036,9 +3035,9 @@ printf("333\n");
if(retval==-1) ret=FAIL; if(retval==-1) ret=FAIL;
} }
#endif #endif
//#ifdef VERBOSE #ifdef VERBOSE
printf("Configured MAC with retval %d\n", retval); printf("Configured MAC with retval %d\n", retval);
//#endif #endif
if (ret==FAIL) { if (ret==FAIL) {
printf("configuring MAC of mod %d failed\n", imod); printf("configuring MAC of mod %d failed\n", imod);
} }