mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-14 05:47:14 +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:
@ -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
|
||||
|
@ -220,7 +220,7 @@ int Feb_Control_Init(int master, int top){
|
||||
Feb_Control_current_index = i;
|
||||
}
|
||||
printf("****current index:%d\n",i);
|
||||
*/
|
||||
*/
|
||||
//Feb_Control_ReadSetUpFileToAddModules("/home/root/executables/setup.txt");
|
||||
|
||||
//Add the half module
|
||||
@ -268,7 +268,7 @@ void Feb_Control_Set_Master(){
|
||||
printf("master is set\n");
|
||||
}
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -451,7 +451,7 @@ int Feb_Control_AddModule1(unsigned int module_number, int top_enable, unsigned
|
||||
|
||||
|
||||
int Feb_Control_ReadSetUpFile(unsigned int module_num, char* file_name){
|
||||
printf("Reading Setup file for module number:%d\n",module_num);
|
||||
printf("Reading Setup file for module number:%d\n",module_num);
|
||||
char line[100];
|
||||
char str[100];
|
||||
int i0;
|
||||
@ -532,7 +532,7 @@ printf("Reading Setup file for module number:%d\n",module_num);
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
printf("Done reading set up file\n");
|
||||
printf("Done reading set up file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -765,7 +765,7 @@ int Feb_Control_DecodeDACString(char* dac_str, unsigned int* module_index, int*
|
||||
//char temp[50];
|
||||
*module_index = Feb_Control_current_index;
|
||||
|
||||
/*
|
||||
/*
|
||||
char* p1 = strstr(local_s,"mod");//size_t p1 = local_s.find("mod");
|
||||
char* p2 = strstr(local_s,"::");//size_t p2 =local_s.find("::");
|
||||
if(p1!=NULL&&p2!=NULL&&(p1+3)<p2){//if(p1!=string::npos&&p2!=string::npos&&(p1+3)<p2){
|
||||
@ -779,7 +779,7 @@ int Feb_Control_DecodeDACString(char* dac_str, unsigned int* module_index, int*
|
||||
}
|
||||
strcpy(local_s,p2+2);//local_s = local_s.substr(p2+2);
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
*top = 1;//make them both 1 instead of this
|
||||
*bottom = 1;
|
||||
@ -946,7 +946,7 @@ float GetDAC(string s){
|
||||
|
||||
return dac[n];
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits){
|
||||
printf("Setting Trimbits\n");
|
||||
@ -1001,7 +1001,7 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits){
|
||||
/*
|
||||
int super_column_start_position_l = 1024*row + l_r *256 + sc*8; //256 per row, 8 per super column
|
||||
int super_column_start_position_r = 1024*row + 512 + l_r *256 + sc*8; //256 per row, 8 per super column
|
||||
*/
|
||||
*/
|
||||
int chip_sc = 31 - sc;
|
||||
trimbits_to_load_l[offset+chip_sc] = 0;
|
||||
trimbits_to_load_r[offset+chip_sc] = 0;
|
||||
@ -1067,19 +1067,19 @@ unsigned int Feb_Control_AddressToAll(){printf("in Feb_Control_AddressToAll()\n"
|
||||
|
||||
|
||||
|
||||
if(moduleSize==0) return 0;
|
||||
if(moduleSize==0) return 0;
|
||||
|
||||
|
||||
if(Module_BottomAddressIsValid(&modules[1])){
|
||||
if(Module_BottomAddressIsValid(&modules[1])){
|
||||
//printf("************* bottom\n");
|
||||
//if(Feb_Control_am_i_master)
|
||||
return Module_GetBottomLeftAddress(&modules[1])|Module_GetBottomRightAddress(&modules[1]);
|
||||
// else return 0;
|
||||
}
|
||||
// printf("************* top\n");
|
||||
}
|
||||
// printf("************* top\n");
|
||||
|
||||
return Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1]);
|
||||
//return Module_GetTopLeftAddress(&modules[0])|Module_GetTopRightAddress(&modules[0]);
|
||||
return Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1]);
|
||||
//return Module_GetTopLeftAddress(&modules[0])|Module_GetTopRightAddress(&modules[0]);
|
||||
|
||||
|
||||
}
|
||||
@ -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");
|
||||
@ -1396,13 +1430,13 @@ void Feb_Control_PrintAcquisitionSetup(){
|
||||
}
|
||||
|
||||
int Feb_Control_SendBitModeToBebServer(){
|
||||
/*
|
||||
/*
|
||||
static int first_pass = 1;
|
||||
static char buffer[1024];
|
||||
|
||||
if(first_pass&&!Feb_Control_SetupSendToSocket("localhost",43212)) return 0;
|
||||
else first_pass=0;
|
||||
*/
|
||||
*/
|
||||
unsigned int just_bit_mode = (DAQ_STATIC_BIT_M4|DAQ_STATIC_BIT_M8) & Feb_Control_staticBits;
|
||||
unsigned int bit_mode = 16; //default
|
||||
if(just_bit_mode == DAQ_STATIC_BIT_M4) bit_mode = 4;
|
||||
@ -1423,7 +1457,7 @@ int Feb_Control_SendBitModeToBebServer(){
|
||||
printf("Error: sending bit mode ...\n");
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1468,7 +1502,7 @@ int Feb_Control_WriteNRead(char* message, int length, int max_length){
|
||||
|
||||
return length;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
int Feb_Control_PrepareForAcquisition(){//return 1;
|
||||
static unsigned int reg_nums[20];
|
||||
@ -1525,8 +1559,8 @@ int Feb_Control_PrepareForAcquisition(){//return 1;
|
||||
|
||||
int Feb_Control_StartAcquisition(){printf("****** starting acquisition********* \n");
|
||||
|
||||
static unsigned int reg_nums[20];
|
||||
static unsigned int reg_vals[20];
|
||||
static unsigned int reg_nums[20];
|
||||
static unsigned int reg_vals[20];
|
||||
/*
|
||||
Feb_Control_PrintAcquisitionSetup();
|
||||
|
||||
@ -1562,7 +1596,7 @@ int Feb_Control_StartAcquisition(){printf("****** starting acquisition*********
|
||||
reg_vals[3]=Feb_Control_ConvertTimeToRegister(Feb_Control_exposure_period_in_sec);
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
reg_nums[4]=DAQ_REG_CHIP_CMDS;
|
||||
reg_vals[4]=(Feb_Control_acquireNReadoutMode|Feb_Control_triggerMode|Feb_Control_externalEnableMode|Feb_Control_subFrameMode);
|
||||
*/
|
||||
@ -1599,22 +1633,22 @@ int Feb_Control_StartAcquisition(){printf("****** starting acquisition*********
|
||||
printf("Trouble starting acquisition....\n");;
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
///*
|
||||
int i;
|
||||
for(i=0;i<14;i++){
|
||||
*/
|
||||
///*
|
||||
int i;
|
||||
for(i=0;i<14;i++){
|
||||
reg_nums[i]=DAQ_REG_CTRL;
|
||||
reg_vals[i]=0;
|
||||
}
|
||||
reg_nums[14]=DAQ_REG_CTRL;
|
||||
reg_vals[14]=ACQ_CTRL_START;
|
||||
}
|
||||
reg_nums[14]=DAQ_REG_CTRL;
|
||||
reg_vals[14]=ACQ_CTRL_START;
|
||||
|
||||
if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),15,reg_nums,reg_vals,0,0)){
|
||||
if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),15,reg_nums,reg_vals,0,0)){
|
||||
printf("Trouble starting acquisition....\n");;
|
||||
return 0;
|
||||
}
|
||||
//*/
|
||||
/*
|
||||
}
|
||||
//*/
|
||||
/*
|
||||
int i;
|
||||
for(i=5;i<19;i++){
|
||||
reg_nums[i]=DAQ_REG_CTRL;
|
||||
@ -1627,10 +1661,10 @@ int Feb_Control_StartAcquisition(){printf("****** starting acquisition*********
|
||||
printf("Trouble starting acquisition....\n");;
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
//*/
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Feb_Control_StopAcquisition(){
|
||||
|
@ -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");
|
||||
|
Reference in New Issue
Block a user