mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 22:40:02 +02:00
full module server works now, slave and master yet to be done
This commit is contained in:
parent
347a36b7c1
commit
bbf26927dd
@ -330,7 +330,7 @@ int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header
|
||||
Beb_SwapDataFun(1,12,&(Beb_send_data[2]));
|
||||
|
||||
if(!Beb_WriteTo(i)) return 0;
|
||||
printf("dst_port:%d\n",dst_port);
|
||||
printf("beb dst_port:%d\n",dst_port);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -514,7 +514,7 @@ int Beb_RequestNImages(unsigned int beb_number, unsigned int left_right, int ten
|
||||
if(in_two_requests) npackets/=2;
|
||||
// printf("npackets:%d\n",npackets);
|
||||
//usleep needed after acquisition start, else you miss the single images
|
||||
usleep(1000);
|
||||
usleep(10000);//less than this and it starts sending half stuff sometimes
|
||||
|
||||
//printf("beb no:%d left_right:%d ten_gig:%d dst_number:%d #images:%d header_size:%d test_just_send_out_packets_no_wait:%d\n",beb_number,left_right,ten_gig,dst_number,nimages, header_size,test_just_send_out_packets_no_wait);
|
||||
//printf("here: "<<beb_number<<","<<left_right<<","<<ten_gig<<","<<dst_number<<","<<1<<","<<header_size<<","<<test_just_send_out_packets_no_wait\n");
|
||||
|
@ -141,9 +141,11 @@ int Module_GetBottomDACValue(struct Module* mod,unsigned int i)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int Feb_Control_IsBottomModule(){
|
||||
if(Module_BottomAddressIsValid(&modules[1]))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Feb_Control_FebControl(){
|
||||
@ -711,31 +713,22 @@ int Feb_Control_DecodeDACString(char* dac_str, unsigned int* module_index, int*
|
||||
}
|
||||
|
||||
|
||||
*top = 1;
|
||||
*top = 1;//make them both 1 instead of this
|
||||
*bottom = 1;
|
||||
/*
|
||||
if((p1 = local_s.find("top::"))!=string::npos){
|
||||
local_s = local_s.substr(p1+5);
|
||||
*bottom=0;
|
||||
}else if((p1 = local_s.find("bottom::"))!=string::npos){
|
||||
local_s = local_s.substr(p1+8);
|
||||
*top=0;
|
||||
}
|
||||
*/
|
||||
if(p1 = strstr(local_s,"top::")!=NULL){
|
||||
/*if(p1 = strstr(local_s,"top::")!=NULL){
|
||||
strcpy(local_s,p1+5);
|
||||
*bottom=0;
|
||||
}else if(p1 = strstr(local_s,"bottom::")!=NULL){
|
||||
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;
|
||||
@ -786,11 +779,11 @@ int Feb_Control_SetDAC(char* dac_str, int value, int is_a_voltage_mv){
|
||||
|
||||
unsigned int v = value;
|
||||
if(is_a_voltage_mv&&!Feb_Control_VoltageToDAC(value,&v,4096,0,2048)){
|
||||
printf("Waring: SetDac bad value, %d. The range is 0 to 2048 mV.\n",value);
|
||||
printf("Warning: SetDac bad value, %d. The range is 0 to 2048 mV.\n",value);
|
||||
return 0;
|
||||
}
|
||||
if(v<0||v>4095){
|
||||
printf("Waring: SetDac bad value, %d. The range is 0 to 4095.\n",v);
|
||||
printf("Warning: SetDac bad value, %d. The range is 0 to 4095.\n",v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -949,28 +942,41 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits){
|
||||
int i;
|
||||
for(i=0;i<8;i++){ // column loop i
|
||||
//printf("i:%d\t\t",i);
|
||||
trimbits_to_load_l[offset+chip_sc] |= ( 0x7 & trimbits[row_set*16480+super_column_start_position_l+i])<<((7-i)*4);//low
|
||||
trimbits_to_load_l[offset+chip_sc+32] |= ((0x38 & trimbits[row_set*16480+super_column_start_position_l+i])>>3)<<((7-i)*4);//upper
|
||||
trimbits_to_load_r[offset+chip_sc] |= ( 0x7 & trimbits[row_set*16480+super_column_start_position_r+i])<<((7-i)*4);//low
|
||||
trimbits_to_load_r[offset+chip_sc+32] |= ((0x38 & trimbits[row_set*16480+super_column_start_position_r+i])>>3)<<((7-i)*4);//upper
|
||||
/*
|
||||
trimbits_to_load_l[offset+chip_sc] |= ( 0x7 & trimbits[263679 - (row_set*16480+super_column_start_position_l+i)])<<((7-i)*4);//low
|
||||
trimbits_to_load_l[offset+chip_sc+32] |= ((0x38 & trimbits[263679 - (row_set*16480+super_column_start_position_l+i)])>>3)<<((7-i)*4);//upper
|
||||
trimbits_to_load_r[offset+chip_sc] |= ( 0x7 & trimbits[263679 - (row_set*16480+super_column_start_position_r+i)])<<((7-i)*4);//low
|
||||
trimbits_to_load_r[offset+chip_sc+32] |= ((0x38 & trimbits[263679 - (row_set*16480+super_column_start_position_r+i)])>>3)<<((7-i)*4);//upper
|
||||
*/
|
||||
|
||||
if(Module_TopAddressIsValid(&modules[0])){
|
||||
trimbits_to_load_l[offset+chip_sc] |= ( 0x7 & trimbits[row_set*16480+super_column_start_position_l+i])<<((7-i)*4);//low
|
||||
trimbits_to_load_l[offset+chip_sc+32] |= ((0x38 & trimbits[row_set*16480+super_column_start_position_l+i])>>3)<<((7-i)*4);//upper
|
||||
trimbits_to_load_r[offset+chip_sc] |= ( 0x7 & trimbits[row_set*16480+super_column_start_position_r+i])<<((7-i)*4);//low
|
||||
trimbits_to_load_r[offset+chip_sc+32] |= ((0x38 & trimbits[row_set*16480+super_column_start_position_r+i])>>3)<<((7-i)*4);//upper
|
||||
}else{
|
||||
trimbits_to_load_l[offset+chip_sc] |= ( 0x7 & trimbits[263679 - (row_set*16480+super_column_start_position_l+i)])<<((7-i)*4);//low
|
||||
trimbits_to_load_l[offset+chip_sc+32] |= ((0x38 & trimbits[263679 - (row_set*16480+super_column_start_position_l+i)])>>3)<<((7-i)*4);//upper
|
||||
trimbits_to_load_r[offset+chip_sc] |= ( 0x7 & trimbits[263679 - (row_set*16480+super_column_start_position_r+i)])<<((7-i)*4);//low
|
||||
trimbits_to_load_r[offset+chip_sc+32] |= ((0x38 & trimbits[263679 - (row_set*16480+super_column_start_position_r+i)])>>3)<<((7-i)*4);//upper
|
||||
|
||||
}
|
||||
} // end column loop i
|
||||
} //end supercolumn loop sc
|
||||
} //end row loop
|
||||
|
||||
|
||||
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)){
|
||||
printf(" some errror!\n");
|
||||
return 0;
|
||||
if(Module_TopAddressIsValid(&modules[0])){
|
||||
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)){
|
||||
printf(" some errror!\n");
|
||||
return 0;
|
||||
}
|
||||
}else{
|
||||
if(!Feb_Interface_WriteMemoryInLoops(Module_GetBottomLeftAddress(&modules[1]),0,0,1024,trimbits_to_load_r)||
|
||||
!Feb_Interface_WriteMemoryInLoops(Module_GetBottomRightAddress(&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)){
|
||||
printf(" some errror!\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
} //end row_set loop (groups of 16 rows)
|
||||
@ -996,7 +1002,7 @@ unsigned int Feb_Control_AddressToAll(){
|
||||
//printf("************* bottom\n");
|
||||
return Module_GetBottomLeftAddress(&modules[0])|Module_GetBottomRightAddress(&modules[0]);
|
||||
}
|
||||
// printf("************* top\n");
|
||||
//printf("************* top\n");
|
||||
return Module_GetTopLeftAddress(&modules[0])|Module_GetTopRightAddress(&modules[0]);
|
||||
|
||||
}
|
||||
@ -1051,14 +1057,14 @@ int Feb_Control_AcquisitionInProgress(){
|
||||
//printf("************* bottom1\n");
|
||||
|
||||
if(!(Feb_Control_GetDAQStatusRegister(Module_GetBottomRightAddress(&modules[1]),&status_reg_r)))
|
||||
{printf("**idle\n");return 0;}
|
||||
return 0;
|
||||
}else{
|
||||
//printf("************* top1\n");
|
||||
if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopRightAddress(&modules[1]),&status_reg_r)))
|
||||
{printf("**idle\n");return 0;}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(status_reg_r&DAQ_STATUS_DAQ_RUNNING) {printf("******running\n");return 1;}
|
||||
if(status_reg_r&DAQ_STATUS_DAQ_RUNNING) return 1;
|
||||
|
||||
/*
|
||||
if(!(GetDAQStatusRegister(modules[i]->Module_GetTopLeftAddress(),status_reg_r)&&GetDAQStatusRegister(modules[i]->Module_GetTopRightAddress(),status_reg_l))){
|
||||
@ -1069,7 +1075,7 @@ int Feb_Control_AcquisitionInProgress(){
|
||||
}
|
||||
*/
|
||||
|
||||
printf("**idle\n");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(){
|
||||
|
@ -65,7 +65,7 @@ int Module_GetBottomDACValue(struct Module* mod,unsigned int i);
|
||||
|
||||
|
||||
|
||||
|
||||
int Feb_Control_IsBottomModule();
|
||||
|
||||
|
||||
void Feb_Control_ClearModules();
|
||||
|
Binary file not shown.
@ -129,7 +129,7 @@ int initDetector(){
|
||||
setHighVolage(150,0);
|
||||
setIODelay(675,0);
|
||||
setTiming(AUTO_TIMING);
|
||||
setMaster(GET_MASTER);
|
||||
//setMaster(GET_MASTER);
|
||||
int enable[2] = {0,1};
|
||||
setExternalGating(enable);//disable external gating
|
||||
|
||||
@ -456,39 +456,38 @@ enum detectorSettings setSettings(enum detectorSettings sett, int imod){
|
||||
|
||||
|
||||
int startStateMachine(){
|
||||
printf("Going to start acquisition\n");
|
||||
|
||||
|
||||
if(trialMasterMode == IS_MASTER)
|
||||
if(trialMasterMode == IS_MASTER){
|
||||
printf("Going to start acquisition\n");
|
||||
Feb_Control_StartAcquisition();
|
||||
}
|
||||
|
||||
|
||||
printf("requesting images\n");
|
||||
//RequestImages();
|
||||
int ret_val = 0;
|
||||
dst_requested[0] = 1;
|
||||
while(dst_requested[on_dst]){
|
||||
//waits on data
|
||||
if((ret_val = (!Beb_RequestNImages(0,1,send_to_ten_gig,on_dst,nimages_per_request,0)||
|
||||
!Beb_RequestNImages(0,2,send_to_ten_gig,0x20|on_dst,nimages_per_request,0))))
|
||||
break;
|
||||
dst_requested[on_dst++]=0;
|
||||
on_dst%=ndsts_in_use;
|
||||
}
|
||||
printf("requesting images\n");
|
||||
//RequestImages();
|
||||
int ret_val = 0;
|
||||
dst_requested[0] = 1;
|
||||
while(dst_requested[on_dst]){
|
||||
//waits on data
|
||||
if((ret_val = (!Beb_RequestNImages(0,1,send_to_ten_gig,on_dst,nimages_per_request,0)||
|
||||
!Beb_RequestNImages(0,2,send_to_ten_gig,0x20|on_dst,nimages_per_request,0))))
|
||||
break;
|
||||
dst_requested[on_dst++]=0;
|
||||
on_dst%=ndsts_in_use;
|
||||
}
|
||||
|
||||
if(ret_val)
|
||||
return FAIL;
|
||||
else
|
||||
return OK;
|
||||
if(ret_val)
|
||||
return FAIL;
|
||||
else
|
||||
return OK;
|
||||
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
int stopStateMachine(){
|
||||
printf("Going to stop acquisition\n");
|
||||
|
||||
if(trialMasterMode == IS_MASTER){
|
||||
printf("Going to stop acquisition\n");
|
||||
if(Feb_Control_StopAcquisition())
|
||||
return OK;
|
||||
}else return OK;
|
||||
@ -522,10 +521,10 @@ int startReadOut(){
|
||||
enum runStatus getRunStatus(){
|
||||
int i = Feb_Control_AcquisitionInProgress();
|
||||
if(i== 0){
|
||||
printf("IDLE\n");
|
||||
/*printf("IDLE\n");*/
|
||||
return IDLE;
|
||||
}else{
|
||||
printf("RUNNING\n");
|
||||
/*printf("RUNNING\n");*/
|
||||
return RUNNING;
|
||||
}
|
||||
}
|
||||
@ -689,7 +688,6 @@ int executeTrimming(enum trimMode mode, int par1, int par2, int imod){
|
||||
int configureMAC(int ipad, long long int macad, long long int detectormacadd, int detipad, int udpport, int udpport2, int ival){
|
||||
char src_mac[50], src_ip[50],dst_mac[50], dst_ip[50];
|
||||
int src_port = 0xE185;
|
||||
int dst_port = udpport;
|
||||
sprintf(src_ip,"%d.%d.%d.%d",(detipad>>24)&0xff,(detipad>>16)&0xff,(detipad>>8)&0xff,(detipad)&0xff);
|
||||
sprintf(dst_ip,"%d.%d.%d.%d",(ipad>>24)&0xff,(ipad>>16)&0xff,(ipad>>8)&0xff,(ipad)&0xff);
|
||||
sprintf(src_mac,"%02x:%02x:%02x:%02x:%02x:%02x",(unsigned int)((detectormacadd>>40)&0xFF),
|
||||
@ -706,15 +704,17 @@ int configureMAC(int ipad, long long int macad, long long int detectormacadd, in
|
||||
(unsigned int)((macad>>0)&0xFF));
|
||||
|
||||
printf("src_port:%d\n",src_port);
|
||||
printf("dst_port:%d\n",dst_port);
|
||||
printf("src_ip:%s\n",src_ip);
|
||||
printf("dst_ip:%s\n",dst_ip);
|
||||
printf("src_mac:%s\n",src_mac);
|
||||
printf("dst_mac:%s\n\n",dst_mac);
|
||||
printf("dst_mac:%s\n",dst_mac);
|
||||
|
||||
|
||||
int beb_num = 34;
|
||||
int header_number = 0;
|
||||
int dst_port = udpport;
|
||||
|
||||
printf("dst_port:%d\n\n",dst_port);
|
||||
|
||||
int i=0;
|
||||
/* for(i=0;i<32;i++){/** modified for Aldo*/
|
||||
@ -726,11 +726,12 @@ int configureMAC(int ipad, long long int macad, long long int detectormacadd, in
|
||||
|
||||
header_number = 32;
|
||||
dst_port = udpport2;
|
||||
printf("dst_port:%d\n\n",dst_port);
|
||||
|
||||
/*for(i=0;i<32;i++){*//** modified for Aldo*/
|
||||
if(Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) &&
|
||||
Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port))
|
||||
printf("set up right ok\n");
|
||||
printf("set up right ok\n\n");
|
||||
else return -1;
|
||||
/*}*/
|
||||
|
||||
@ -898,10 +899,10 @@ void setExternalGating(int enable[]){
|
||||
|
||||
|
||||
enum masterFlags setMaster(enum masterFlags arg){
|
||||
if(arg != GET_MASTER)
|
||||
masterMode = arg;
|
||||
//if(arg != GET_MASTER)
|
||||
// masterMode = arg;
|
||||
|
||||
return arg;
|
||||
return NO_MASTER;
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,8 +54,8 @@ int init_detector(int b) {
|
||||
#endif
|
||||
}else{
|
||||
Feb_Interface_FebInterface();
|
||||
Feb_Control_FebControl();
|
||||
printf("FEb control constructor done\n");
|
||||
//Feb_Control_FebControl();
|
||||
// printf("FEb control constructor done\n");
|
||||
/* Beb_Beb(-1);
|
||||
printf("BEB constructor done\n");*/
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user