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){
char* local_s = dac_str;
char temp[50];
*module_index = 0;
*module_index = 1;
char* p1 = strstr(local_s,"mod");//size_t p1 = local_s.find("mod");
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);
*top=0;
}
/*
if(Module_BottomAddressIsValid(&modules[*module_index]))
*top=0;
else
*bottom=0;
printf("*****************top %d bottom %d\n",*top,*bottom);
*/
*dac_ch = 0;
if(!Feb_Control_GetDACNumber(local_s,dac_ch)){
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
if(!Feb_Interface_WriteMemoryInLoops(Module_GetTopLeftAddress(&modules[0]),0,0,1024,trimbits_to_load_r)||
!Feb_Interface_WriteMemoryInLoops(Module_GetTopRightAddress(&modules[0]),0,0,1024,trimbits_to_load_l)||
if(!Feb_Interface_WriteMemoryInLoops(Module_GetTopLeftAddress(&modules[1]),0,0,1024,trimbits_to_load_r)||
!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)||
// !Feb_Interface_WriteMemory(Module_GetTopRightAddress(&modules[0]),0,0,1023,trimbits_to_load_l)||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
@ -982,11 +991,14 @@ unsigned int* Feb_Control_GetTrimbits(){
unsigned int Feb_Control_AddressToAll(){
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");
return Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1]);
if(Module_BottomAddressIsValid(&modules[0])){
//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){
@ -1035,18 +1047,18 @@ int Feb_Control_AcquisitionInProgress(){
//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));
if(Module_BottomAddressIsValid(&modules[0])){
if(Module_BottomAddressIsValid(&modules[1])){
//printf("************* bottom1\n");
if(!(Feb_Control_GetDAQStatusRegister(Module_GetBottomRightAddress(&modules[1]),&status_reg_r)))
return 0;
{printf("**idle\n");return 0;}
}else{
//printf("************* top1\n");
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))){
@ -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(){
@ -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_vals[20];

View File

@ -1,6 +1,6 @@
CC = powerpc-4xx-softfloat-gcc
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++
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};
enum masterFlags masterMode=NO_MASTER;
enum masterFlags trialMasterMode=NO_MASTER;
int initDetector(){
int imod,i,n;
@ -128,9 +129,12 @@ int initDetector(){
setHighVolage(150,0);
setIODelay(675,0);
setTiming(AUTO_TIMING);
setMaster(GET_MASTER);
int enable[2] = {0,1};
setExternalGating(enable);//disable external gating
if(getDetectorNumber() == 0xbeb031)
trialMasterMode = IS_MASTER;
return 1;
}
@ -453,8 +457,13 @@ enum detectorSettings setSettings(enum detectorSettings sett, int imod){
int startStateMachine(){
printf("Going to start acquisition\n");
if(Feb_Control_StartAcquisition()){
if(trialMasterMode == IS_MASTER)
Feb_Control_StartAcquisition();
printf("requesting images\n");
//RequestImages();
int ret_val = 0;
dst_requested[0] = 1;
@ -471,15 +480,19 @@ int startStateMachine(){
return FAIL;
else
return OK;
}
return FAIL;
}
int stopStateMachine(){
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;
}
@ -885,7 +898,10 @@ void setExternalGating(int enable[]){
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 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++) {
if (i!=thisMultiDetector->masterPosition)
if (detectors[i]) {
@ -1226,7 +1217,7 @@ int multiSlsDetector::startAcquisition(){
if (ret!=OK)
ret1=FAIL;
}
}*/
}
return ret1;
};
@ -1474,7 +1465,7 @@ int* multiSlsDetector::startAndReadAll(){
if (detectors[id]) {
detectors[id]->disconnectControl();
}
}
}
}
@ -1515,6 +1506,7 @@ int multiSlsDetector::startAndReadAllNoWait(){
ret1=FAIL;
}
}
return ret1;
}
@ -1536,20 +1528,16 @@ slsDetectorDefs::runStatus multiSlsDetector::getRunStatus() {
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++) {
s1=detectors[i]->getRunStatus();
if(detectors[i]->getErrorMask())
setErrorMask(getErrorMask()|(1<<i));
if (s1==ERROR)
s=ERROR;
if (s1==IDLE && s!=IDLE)
s=ERROR;
if (s1!=IDLE)
s = s1;
// if (s1==IDLE && s!=IDLE)
// s=ERROR;
}
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 ret=OK,ret1=OK;
@ -2979,7 +2979,7 @@ int configure_mac(int file_des) {printf("in hereeeeee\n");
int udpport2;
int detipad;
#endif
printf("111\n");
sprintf(mess,"Can't configure MAC\n");
n = receiveData(file_des,arg,sizeof(arg),OTHER);
@ -2987,7 +2987,7 @@ printf("111\n");
sprintf(mess,"Error reading from socket\n");
ret=FAIL;
}
printf("222\n");
#ifdef MYTHEND
ret = FAIL;
strcpy(mess,"Not applicable/implemented for this detector\n");
@ -3007,7 +3007,6 @@ printf("222\n");
printf("mess:%s\n",mess);
}
#endif
printf("333\n");
//#ifdef VERBOSE
int i;
/*printf("\ndigital_test_bit in server %d\t",digitalTestBit);for gotthard*/
@ -3036,9 +3035,9 @@ printf("333\n");
if(retval==-1) ret=FAIL;
}
#endif
//#ifdef VERBOSE
#ifdef VERBOSE
printf("Configured MAC with retval %d\n", retval);
//#endif
#endif
if (ret==FAIL) {
printf("configuring MAC of mod %d failed\n", imod);
}