mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
added the code for toggle bit to know when acquisition started in febcontrol and list, indentation as well
This commit is contained in:
parent
1f1581a1fa
commit
302d9ca0ed
@ -101,7 +101,7 @@
|
||||
#define DAQ_STATUS_TOKEN_OUT 0x20
|
||||
#define DAQ_STATUS_SERIAL_OUT 0x40
|
||||
#define DAQ_STATUS_PIXELS_ARE_ENABLED 0x80
|
||||
|
||||
#define DAQ_STATUS_DAQ_RUN_TOGGLE 0x200
|
||||
|
||||
//data delay registers
|
||||
#define CHIP_DATA_OUT_DELAY_REG_CTRL 1
|
||||
|
@ -1095,7 +1095,7 @@ int Feb_Control_GetDAQStatusRegister(unsigned int dst_address, unsigned int* ret
|
||||
return 0;
|
||||
}
|
||||
|
||||
*ret_status = (0x00FF0000 & *ret_status) >> 16;
|
||||
*ret_status = (0x02FF0000 & *ret_status) >> 16;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1109,6 +1109,61 @@ int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us){
|
||||
return Feb_Control_WaitForFinishedFlag(sleep_time_us);
|
||||
}
|
||||
|
||||
|
||||
int Feb_Control_AcquisitionInProgress(){
|
||||
unsigned int status_reg_r=0,status_reg_l=0;
|
||||
|
||||
int ind = Feb_Control_current_index;
|
||||
if(Module_BottomAddressIsValid(&modules[ind])){
|
||||
|
||||
if(!(Feb_Control_GetDAQStatusRegister(Module_GetBottomRightAddress(&modules[ind]),&status_reg_r)))
|
||||
{printf("ERROR: Trouble reading Status register. bottom right address\n");return 0;}
|
||||
if(!(Feb_Control_GetDAQStatusRegister(Module_GetBottomLeftAddress(&modules[ind]),&status_reg_l)))
|
||||
{printf("ERROR: Trouble reading Status register. bottom left address\n");return 0;}
|
||||
|
||||
}else{
|
||||
if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopRightAddress(&modules[ind]),&status_reg_r)))
|
||||
{printf("ERROR: Trouble reading Status register. top right address\n");return 0;}
|
||||
if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopLeftAddress(&modules[ind]),&status_reg_l)))
|
||||
{printf("ERROR: Trouble reading Status register. top left address\n");return 0;}
|
||||
}
|
||||
|
||||
//running
|
||||
if((status_reg_r|status_reg_l)&DAQ_STATUS_DAQ_RUNNING) {/*printf("**runningggg\n");*/
|
||||
return 1;
|
||||
}
|
||||
//idle
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int Feb_Control_AcquisitionStartedBit(){
|
||||
unsigned int status_reg_r=0,status_reg_l=0;
|
||||
|
||||
int ind = Feb_Control_current_index;
|
||||
if(Module_BottomAddressIsValid(&modules[ind])){
|
||||
|
||||
if(!(Feb_Control_GetDAQStatusRegister(Module_GetBottomRightAddress(&modules[ind]),&status_reg_r)))
|
||||
{printf("ERROR: Trouble reading Status register. bottom right address\n");return -1;}
|
||||
if(!(Feb_Control_GetDAQStatusRegister(Module_GetBottomLeftAddress(&modules[ind]),&status_reg_l)))
|
||||
{printf("ERROR: Trouble reading Status register. bottom left address\n");return -1;}
|
||||
|
||||
}else{
|
||||
if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopRightAddress(&modules[ind]),&status_reg_r)))
|
||||
{printf("ERROR: Trouble reading Status register. top right address\n"); return -1;}
|
||||
if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopLeftAddress(&modules[ind]),&status_reg_l)))
|
||||
{printf("ERROR: Trouble reading Status register. top left address\n");return -1;}
|
||||
}
|
||||
|
||||
//doesnt mean it started, just the bit
|
||||
if((status_reg_r|status_reg_l)&DAQ_STATUS_DAQ_RUN_TOGGLE)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Feb_Control_WaitForFinishedFlag(int sleep_time_us){
|
||||
int is_running = Feb_Control_AcquisitionInProgress();
|
||||
while(is_running){
|
||||
@ -1123,43 +1178,22 @@ int Feb_Control_WaitForFinishedFlag(int sleep_time_us){
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Feb_Control_AcquisitionInProgress(){
|
||||
unsigned int status_reg_r=0,status_reg_l=0;
|
||||
|
||||
int ind = Feb_Control_current_index;
|
||||
if(Module_BottomAddressIsValid(&modules[ind])){
|
||||
|
||||
if(!(Feb_Control_GetDAQStatusRegister(Module_GetBottomRightAddress(&modules[ind]),&status_reg_r)))
|
||||
{printf("ERROR: Trouble reading Status register. bottom right address\n");return 0;}
|
||||
if(!(Feb_Control_GetDAQStatusRegister(Module_GetBottomLeftAddress(&modules[ind]),&status_reg_l)))
|
||||
{printf("ERROR: Trouble reading Status register. bottom left address\n");return 0;}
|
||||
|
||||
}else{
|
||||
if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopRightAddress(&modules[ind]),&status_reg_r)))
|
||||
{printf("ERROR: Trouble reading Status register. top right address\n");
|
||||
if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopRightAddress(&modules[0]),&status_reg_r)))
|
||||
printf("ERROR: error with normal register\n");
|
||||
else
|
||||
printf("**********NO error reading normal register\n");
|
||||
return 0;}
|
||||
if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopLeftAddress(&modules[ind]),&status_reg_l)))
|
||||
{printf("ERROR: Trouble reading Status register. top left address\n");return 0;}
|
||||
int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag){
|
||||
int value = prev_flag;
|
||||
while(value == prev_flag){
|
||||
usleep(sleep_time_us);
|
||||
value = Feb_Control_AcquisitionStartedBit();
|
||||
}
|
||||
if((status_reg_r|status_reg_l)&DAQ_STATUS_DAQ_RUNNING) {/*printf("**runningggg\n");*/return 1;}
|
||||
|
||||
/*
|
||||
if(!(GetDAQStatusRegister(modules[i]->Module_GetTopLeftAddress(),status_reg_r)&&GetDAQStatusRegister(modules[i]->Module_GetTopRightAddress(),status_reg_l))){
|
||||
for(int i=0;i<2;i++) printf("Waring trouble reading status register. Returning zero to avoid inifite loops, this could cause trouble!"\n");;
|
||||
return 0; //to avoid inifite loops
|
||||
}
|
||||
if((status_reg_r|status_reg_l)&DAQ_STATUS_DAQ_RUNNING) return 1;
|
||||
}
|
||||
*/
|
||||
//did not start
|
||||
if(value == -1)
|
||||
return 0;
|
||||
|
||||
/*printf("**idle\n");*/
|
||||
return 0; //i.e. not running (status_reg_r|status_reg_l)&DAQ_STATUS_DAQ_RUNNING;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int Feb_Control_Reset(){
|
||||
if(!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,0,0,0) || !Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,DAQ_CTRL_RESET,0,0) || !Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,0,0,0)){
|
||||
printf("Warning: Could not reset daq, no response.\n");
|
||||
|
@ -149,8 +149,10 @@ int Feb_Control_GetModuleNumber();
|
||||
int Feb_Control_StartAcquisition();
|
||||
int Feb_Control_StopAcquisition();
|
||||
int Feb_Control_AcquisitionInProgress();
|
||||
int Feb_Control_AcquisitionStartedBit();
|
||||
/*int Feb_Control_WaitForFinishedFlag(int sleep_time_us=5000);*/
|
||||
int Feb_Control_WaitForFinishedFlag(int sleep_time_us);
|
||||
int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag);
|
||||
|
||||
//functions for setting up exposure
|
||||
void Feb_Control_PrintAcquisitionSetup();
|
||||
|
@ -101,7 +101,7 @@
|
||||
#define DAQ_STATUS_TOKEN_OUT 0x20
|
||||
#define DAQ_STATUS_SERIAL_OUT 0x40
|
||||
#define DAQ_STATUS_PIXELS_ARE_ENABLED 0x80
|
||||
|
||||
#define DAQ_STATUS_DAQ_RUN_TOGGLE 0x200
|
||||
|
||||
//data delay registers
|
||||
#define CHIP_DATA_OUT_DELAY_REG_CTRL 1
|
||||
|
Binary file not shown.
@ -502,58 +502,34 @@ int startReceiver(int d){
|
||||
|
||||
|
||||
int startStateMachine(){
|
||||
int ret;
|
||||
//if(master){
|
||||
int ret,prev_flag;
|
||||
//get the DAQ toggle bit
|
||||
prev_flag = Feb_Control_AcquisitionStartedBit();
|
||||
|
||||
printf("Going to start acquisition\n");
|
||||
Feb_Control_StartAcquisition();
|
||||
//}
|
||||
|
||||
//do not read status here, cannot get images then
|
||||
|
||||
////if(trialMasterMode == IS_MASTER){
|
||||
printf("requesting images\n");
|
||||
ret = startReadOut();
|
||||
////}
|
||||
//if(trialMasterMode == IS_MASTER){
|
||||
|
||||
|
||||
//if(master){
|
||||
/*
|
||||
* int i=0;
|
||||
if(getRunStatus() == IDLE){
|
||||
for(i=0;i<100000;i++){
|
||||
usleep(1000);
|
||||
if(getRunStatus() != IDLE){
|
||||
printf("*****i=%d\n",i);
|
||||
break;
|
||||
//wait for acquisition start
|
||||
if(ret == OK){
|
||||
if(!Feb_Control_WaitForStartedFlag(5000, prev_flag)){
|
||||
cprintf(RED,"Error: Acquisition did no start or trouble reading register\n");
|
||||
ret = FAIL;
|
||||
}
|
||||
cprintf(GREEN,"***Acquisition started\n");
|
||||
}
|
||||
//while(getRunStatus() == IDLE);
|
||||
//}
|
||||
printf("*****Acquiring...\n");
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
while(getRunStatus() == IDLE){
|
||||
printf("waiting for being not idle anymore\n");
|
||||
}
|
||||
printf("*****Acquiring...\n");
|
||||
//}
|
||||
/*else usleep(1000000);
|
||||
printf("****Returning\n");*/
|
||||
/*while(getRunStatus() == IDLE){printf("waiting for being not idle anymore\n");}*/
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int stopStateMachine(){
|
||||
//if(trialMasterMode == IS_MASTER){
|
||||
printf("Going to stop acquisition\n");
|
||||
if(Feb_Control_StopAcquisition())
|
||||
return OK;
|
||||
//}else return OK;
|
||||
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -600,8 +576,8 @@ enum runStatus getRunStatus(){
|
||||
char *readFrame(int *ret, char *mess){
|
||||
//if(master){
|
||||
if(!Feb_Control_WaitForFinishedFlag(5000))
|
||||
printf("error in waiting for finished flag\n");
|
||||
printf("Acquisition finished\n");
|
||||
cprintf(RED,"Error: Waiting for finished flag\n");
|
||||
cprintf(GREEN,"Acquisition finished***\n");
|
||||
//usleep(0);
|
||||
usleep(1000000);
|
||||
printf("*****Done Waiting...\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user