Merge branch 'master' of gitorious.psi.ch:sls_det_software/sls_detector_software

This commit is contained in:
sala 2014-11-17 15:00:32 +01:00
commit 02ab7a4ed0
66 changed files with 12509 additions and 266 deletions

View File

@ -177,7 +177,8 @@ enum networkParameter {
RECEIVER_HOSTNAME, /**< receiver IP/hostname */
RECEIVER_UDP_IP, /**< receiever UDP IP */
RECEIVER_UDP_PORT, /**< receiever UDP Port */
RECEIVER_UDP_MAC /**< receiever UDP MAC */
RECEIVER_UDP_MAC, /**< receiever UDP MAC */
RECEIVER_UDP_PORT2 /**< receiever UDP Port of second half module for eiger */
};
/**

View File

@ -90,7 +90,9 @@ enum {
F_CALIBRATE_PEDESTAL, /**< starts acquistion, calibrates pedestal and write back to fpga */
F_ENABLE_TEN_GIGA, /**< enable 10Gbe */
F_SET_ALL_TRIMBITS /** < set all trimbits to this value */
F_SET_ALL_TRIMBITS, /** < set all trimbits to this value */
F_SET_CTB_PATTERN /** < loads a pattern in the CTB */
/* Always append functions hereafter!!! */

View File

@ -42,6 +42,7 @@
short Beb_bit_mode;
void BebInfo_BebInfo(struct BebInfo* bebInfo, unsigned int beb_num){
bebInfo->beb_number=beb_num;
bebInfo->serial_address=0;
@ -52,6 +53,7 @@ void BebInfo_BebInfo(struct BebInfo* bebInfo, unsigned int beb_num){
bebInfo->src_port_1GbE=bebInfo->src_port_10GbE=0;
}
int BebInfo_SetSerialAddress(struct BebInfo* bebInfo, unsigned int a){
//address pre shifted
if(a>0xff) return 0;
@ -135,13 +137,14 @@ void Beb_Beb(int arg1){
Beb_SetByteOrder();
/*
ll_beb_new_memory = &ll_beb_new_memory_local;
Local_LocalLinkInterface(ll_beb_new_memory);
if(!Local_InitNewMemory(ll_beb_new_memory,XPAR_PLB_LL_NEW_MEMORY, arg1))
printf("New Memory FAIL\n");
else
printf("New Memory OK\n");
*/
}
@ -155,6 +158,7 @@ void Beb_ClearBebInfos(){
int Beb_InitBebInfos(){//file name at some point
Beb_ClearBebInfos();
struct BebInfo b0;
BebInfo_BebInfo(&b0,0);
if(BebInfo_SetSerialAddress(&b0,0xff)) { //all bebs for reset and possibly get request data?
@ -172,6 +176,7 @@ int Beb_InitBebInfos(){//file name at some point
beb_infos.push_back(b);
*/
return Beb_CheckSourceStuffBebInfo();
}
@ -181,7 +186,7 @@ int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig, char* src_mac
//so that the values can be reset externally for now....
unsigned int i = Beb_GetBebInfoIndex(beb_number);
if(!i){ printf("returning 000\n");return 0;} //i must be greater than 0, zero is the global send
/******* if(!i) return 0;****************************/ //i must be greater than 0, zero is the global send
BebInfo_SetHeaderInfo(&beb_infos[i],ten_gig,src_mac,src_ip,src_port);
printf("Printing Beb info number (%d) :\n",i);
@ -253,12 +258,13 @@ int Beb_CheckSourceStuffBebInfo(){
}
unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb){
if(!beb_numb) return 0;
/******************** if(!beb_numb) return 0;******************************/
unsigned int i;
for(i=1;i<bebInfoSize;i++)
if(beb_numb==BebInfo_GetBebNumber(&beb_infos[i]))
if(beb_numb==BebInfo_GetBebNumber(&beb_infos[i])){
printf("found beb index:%d, for beb number:%d\n",i,beb_numb);
return i;
}
return 0;
}
@ -319,7 +325,7 @@ int Beb_SetByteOrder(){
int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header_number, char* dst_mac, char* dst_ip, unsigned int dst_port){
unsigned int i = Beb_GetBebInfoIndex(beb_number);
if(!i) return 0; //i must be greater than 0, zero is the global send
/***********************************if(!i) return 0; *************************************///i must be greater than 0, zero is the global send
Beb_send_ndata = 14;
Beb_send_data[0] = ten_gig ? 0x00020000 : 0x00010000; //write to fanout numbers 1 or 2
@ -329,14 +335,14 @@ 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("beb dst_port:%d\n",dst_port);
return 1;
}
int Beb_SetHeaderData(unsigned int beb_number, int ten_gig, char* dst_mac, char* dst_ip, unsigned int dst_port){
unsigned int i = Beb_GetBebInfoIndex(beb_number);
if(!i) return 0; //i must be greater than 0, zero is the global send
/***********************************if(!i) return 0; *************************************///i must be greater than 0, zero is the global send
return Beb_SetHeaderData1(BebInfo_GetSrcMAC(&beb_infos[i],ten_gig),BebInfo_GetSrcIP(&beb_infos[i],ten_gig),BebInfo_GetSrcPort(&beb_infos[i],ten_gig),dst_mac,dst_ip,dst_port);
}
@ -368,12 +374,18 @@ int Beb_SetHeaderData1(char* src_mac, char* src_ip, unsigned int src_port, char*
*/
if(!Beb_SetMAC(src_mac,&(udp_header.src_mac[0]))) return 0;
printf("Setting Source MAC to %s\n",src_mac);
if(!Beb_SetIP(src_ip,&(udp_header.src_ip[0]))) return 0;
printf("Setting Source IP to %s\n",src_ip);
if(!Beb_SetPortNumber(src_port,&(udp_header.src_port[0]))) return 0;
printf("Setting Source port to %d\n",src_port);
if(!Beb_SetMAC(dst_mac,&(udp_header.dst_mac[0]))) return 0;
printf("Setting Destination MAC to %s\n",dst_mac);
if(!Beb_SetIP(dst_ip,&(udp_header.dst_ip[0]))) return 0;
printf("Setting Destination IP to %s\n",dst_ip);
if(!Beb_SetPortNumber(dst_port,&(udp_header.dst_port[0]))) return 0;
printf("Setting Destination port to %d\n",dst_port);
Beb_AdjustIPChecksum(&udp_header);
@ -392,8 +404,7 @@ int Beb_SetHeaderData1(char* src_mac, char* src_ip, unsigned int src_port, char*
int Beb_SetMAC(char* mac, uint8_t* dst_ptr){
char macVal[50];strcpy(macVal,mac);
char macVal[50];strcpy(macVal,mac);
int i = 0;
char *pch = strtok (macVal,":");
@ -506,19 +517,35 @@ int Beb_RequestNImages(unsigned int beb_number, unsigned int left_right, int ten
unsigned int npackets = ten_gig ? Beb_bit_mode*4 : Beb_bit_mode*16;
int in_two_requests = (!ten_gig&&Beb_bit_mode==32);
if(in_two_requests) npackets/=2;
// printf("npackets:%d\n",npackets);
//usleep needed after acquisition start, else you miss the single images
usleep(0);
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");
/*
unsigned int i;
for(i=0;i<nimages;i++){
//header then data request
//usleep(10000);
if(!Beb_SendMultiReadRequest(beb_number,left_right,ten_gig,dst_number,1,header_size,test_just_send_out_packets_no_wait)){printf("Send failed\n");return 0;}
//usleep(10000);
if(!Beb_SendMultiReadRequest(beb_number,left_right,ten_gig,dst_number,npackets,packet_size,test_just_send_out_packets_no_wait)){printf("Send failed\n");return 0;}
// usleep(0);
if(in_two_requests){if(!Beb_SendMultiReadRequest(beb_number,left_right,ten_gig,dst_number,npackets,packet_size,test_just_send_out_packets_no_wait)){printf("Send failed\n");return 0;}
}
}
*/
unsigned int i;
for(i=0;i<nimages;i++){
//header then data request
if(!Beb_SendMultiReadRequest(beb_number,left_right,ten_gig,dst_number,1,header_size,test_just_send_out_packets_no_wait) ||
!Beb_SendMultiReadRequest(beb_number,left_right,ten_gig,dst_number,npackets,packet_size,test_just_send_out_packets_no_wait) ||
(in_two_requests&&!Beb_SendMultiReadRequest(beb_number,left_right,ten_gig,dst_number,npackets,packet_size,test_just_send_out_packets_no_wait)))
(in_two_requests&&!Beb_SendMultiReadRequest(beb_number,left_right,ten_gig,dst_number,npackets,packet_size,test_just_send_out_packets_no_wait))){
printf("SendMultiReadRequest failed\n");
return 0;
}
}
return 1;

View File

@ -28,6 +28,7 @@ struct BebInfo{
void BebInfo_BebInfo(struct BebInfo* bebInfo, unsigned int beb_num);
void BebInfo_BebDstInfo(struct BebInfo* bebInfo, unsigned int beb_num);
int BebInfo_SetSerialAddress(struct BebInfo* bebInfo, unsigned int add);
int BebInfo_SetHeaderInfo(struct BebInfo* bebInfo, int ten_gig, char* src_mac, char* src_ip, unsigned int src_port);//src_port fixed 42000+beb_number or 52000 + beb_number);
unsigned int BebInfo_GetBebNumber(struct BebInfo* bebInfo);

View File

@ -53,7 +53,9 @@ unsigned int Feb_Control_trimbit_size;
unsigned int* Feb_Control_last_downloaded_trimbits;
int Feb_Control_current_mod;
int Feb_Control_current_index;
int Feb_Control_am_i_master;
void Module_Module(struct Module* mod,unsigned int number, unsigned int address_top){
unsigned int i;
@ -72,6 +74,29 @@ void Module_Module(struct Module* mod,unsigned int number, unsigned int address_
for(i=0;i<Module_ndacs;i++) mod->bottom_dac[i] = mod->bottom_address_valid ? -1:0;
}
void Module_ModuleBottom(struct Module* mod,unsigned int number, unsigned int address_bottom){
unsigned int i;
mod->module_number = number;
mod->top_address_valid = 0;
mod->top_left_address = 0;
mod->top_right_address = 0;
mod-> bottom_address_valid = 1;
mod-> bottom_left_address = 0x100 | (0xff & address_bottom);
mod-> bottom_right_address = (0x200 | (0xff & address_bottom));
mod->high_voltage = -1;
for(i=0;i<4;i++) mod->idelay_top[i]=mod->idelay_bottom[i]=0;
mod->top_dac = malloc(Module_ndacs * sizeof(int));
mod->bottom_dac = malloc(Module_ndacs * sizeof(int));
for(i=0;i<Module_ndacs;i++) mod->top_dac[i] = mod->top_address_valid ? -1:0;
for(i=0;i<Module_ndacs;i++) mod->bottom_dac[i] = mod->bottom_address_valid ? -1:0;
}
void Module_Module1(struct Module* mod,unsigned int number, unsigned int address_top, unsigned int address_bottom){
unsigned int i;
mod->module_number = number;
@ -118,9 +143,16 @@ int Module_GetBottomDACValue(struct Module* mod,unsigned int i)
int Feb_Control_IsBottomModule(){
if(Module_BottomAddressIsValid(&modules[Feb_Control_current_index]))
return 1;
return 0;
}
int Feb_Control_GetModuleNumber(){
return Feb_Control_current_mod;
}
void Feb_Control_FebControl(){
@ -130,6 +162,7 @@ void Feb_Control_FebControl(){
Feb_Control_trimbit_size=263680;
Feb_Control_last_downloaded_trimbits = malloc(Feb_Control_trimbit_size * sizeof(int));
/*
printf("\nDefault Settings:\n");
Feb_Control_nimages = 1;
Feb_Control_exposure_time_in_sec = 1;
@ -146,6 +179,23 @@ void Feb_Control_FebControl(){
printf("\n\n");
Feb_Control_Init();
*/
/*
unsigned int reg_nums[1];
unsigned int reg_vals[1];
reg_nums[0]=DAQ_REG_CHIP_CMDS;
reg_vals[0]=(0|Feb_Control_acquireNReadoutMode|Feb_Control_triggerMode|Feb_Control_externalEnableMode|Feb_Control_subFrameMode);
if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),1,reg_nums,reg_vals,0,0)){
printf("Trouble setting them up as slaves\n");;
}
*/
}
@ -159,36 +209,98 @@ void Feb_Control_ClearModules(){
int Feb_Control_Init(){
unsigned int i;
Feb_Control_ClearModules();
///*
Feb_Control_current_mod = 0;
Feb_Control_current_index = 0;
Feb_Control_AddModule(0,0xff);//global send
Feb_Control_PrintModuleList();
//*/
Feb_Control_ReadSetUpFileToAddModules("/home/root/executables/setup.txt");
/*
printf("\nSetting detector defaults:\n");
Feb_Control_ReadSetUpFile(0,"/home/root/executables/setup.txt"); //send defaults to all
for(i=1;i<moduleSize;i++){
/* for(i=1;i<moduleSize;i++){
char st[2000];
sprintf(st,"setup_mod%04d.txt",Module_GetModuleNumber(&modules[i]));
//Feb_Control_ReadSetUpFile(Module_GetModuleNumber(&modules[i]),st);
}
sprintf(st,"setup_mod%04d.txt",Module_GetModuleNumber(&modules[i]));
Feb_Control_ReadSetUpFile(Module_GetModuleNumber(&modules[i]),st);
}*/
//get module nummber
int res=0;
char hostname[100];
if (gethostname(hostname, sizeof hostname) == 0)
puts(hostname);
else
perror("gethostname");
char *pch;
pch = strtok(hostname,"0");
pch = strtok(NULL,"0");
sscanf(pch,"%d",&res);
Feb_Control_current_mod = (res & 0xFF);
return Feb_Control_CheckSetup();
for(i=1;i<moduleSize;i++){
if(Module_GetModuleNumber(&modules[i])==Feb_Control_current_mod)
Feb_Control_current_index = i;
}
/*Feb_Control_ReadSetUpFile(Feb_Control_current_mod,"/home/root/executables/setup.txt");
printf("Done setting detector defaults\n");*/
Feb_Control_am_i_master = 0;
return 1;
}
void Feb_Control_Set_Master(){
Feb_Control_am_i_master = 1;
/*
unsigned int halfmastermodule = 0x80000000;
unsigned int reg_nums[1];
unsigned int reg_vals[1];
reg_nums[0]=DAQ_REG_CHIP_CMDS;
reg_vals[0]=(halfmastermodule|Feb_Control_acquireNReadoutMode|Feb_Control_triggerMode|Feb_Control_externalEnableMode|Feb_Control_subFrameMode);
if(!Feb_Interface_WriteRegisters((Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1])),1,reg_nums,reg_vals,0,0)){
printf("Trouble writing commands....\n");;
return 0;
}
printf("master is set\n");
*/
}
int Feb_Control_ReadSetUpFileToAddModules(char* file_name){
char line[100];
char str[100];
int i0,i1,i2;
int memaddress = 1;
FILE* fp = fopen(file_name, "r");
if( fp == NULL ){
perror("Error while opening the file.\n");
return 0;
}
printf("\nSetting up detector:\n");
printf("\nSetting up detectors:\n");
while ( fgets (line , 255 , fp) != NULL ){
if(strlen(line)<=1)
@ -211,15 +323,39 @@ int Feb_Control_ReadSetUpFileToAddModules(char* file_name){
}
else if(!strcmp(str,"add_half_module")){
if( sscanf (line,"%s %d %d", str,&i0,&i1) < 3){
if( sscanf (line,"%s %d %d %d", str,&i0,&i1,&i2) < 4){
printf("Error adding half module from %s.\n",file_name);
exit(0);
}
printf ("str:%s len:%d i0:%d i1:%d\n", str, strlen(str),i0,i1);
if(!Feb_Control_AddModule(i0,i1)){
printf ("str:%s len:%d i0:%d i1:%d i2:%d\n", str, strlen(str),i0,i1,i2);
/**Added by dhanya*/
if(i1 == 0){
/*Feb_Control_AddModule1(0,0xff,0,1);//global send
Feb_Control_PrintModuleList();*/
if(!Feb_Control_AddModule1(i0,i2,0,1)){
printf("Error adding module, parameter was assigned twice in setup file: %s.\n",file_name);
exit(0);
}
}else{
/* Feb_Control_AddModule1(0,0,0xff,1);//global send
Feb_Control_PrintModuleList();*/
if(!Feb_Control_AddModule1(i0,0,i2,1)){
printf("Error adding module, parameter was assigned twice in setup file: %s.\n",file_name);
exit(0);
}
}
//memaddress++;
Feb_Control_PrintModuleList();
/* if(!Feb_Control_AddModule1(i0,i1)){
printf("Error adding module, parameter was assigned twice in setup file: %s.\n",file_name);
exit(0);
}
}*/
}
}
fclose(fp);
@ -301,7 +437,6 @@ int Feb_Control_AddModule(unsigned int module_number, unsigned int top_address){
int Feb_Control_AddModule1(unsigned int module_number, unsigned int top_address, unsigned int bottom_address, int half_module){ //bot_address 0 for half module
int parameters_ok = 1;
unsigned int pre_module_index = 0;
if(Feb_Control_GetModuleIndex(module_number,&pre_module_index)){
printf("\tRemoving previous assignment of module number %d.\n",module_number);
// free(modules[pre_module_index]);
@ -315,7 +450,10 @@ int Feb_Control_AddModule1(unsigned int module_number, unsigned int top_address,
struct Module mod,* m;
m= &mod;
if(half_module) Module_Module(m,module_number,top_address);
/* if((half_module)&& (top_address != 1)) Module_Module(m,module_number,top_address);
else if(half_module) Module_ModuleBottom(m,module_number,top_address);*/
if ((half_module)&& (!bottom_address)) Module_Module(m,module_number,top_address);
else if (half_module) Module_ModuleBottom(m,module_number,bottom_address);
else Module_Module1(m,module_number,top_address,bottom_address);
@ -344,7 +482,7 @@ int Feb_Control_AddModule1(unsigned int module_number, unsigned int top_address,
int Feb_Control_ReadSetUpFile(unsigned int module_num, char* file_name){
printf("Reading Setup file for module number:%d\n",module_num);
char line[100];
char str[100];
int i0;
@ -418,23 +556,26 @@ int Feb_Control_ReadSetUpFile(unsigned int module_num, char* file_name){
}
if(module_num>0)
sprintf(str,"mod%d::%s",module_num,str);
sprintf(str,"%s",str); /*sprintf(str,"mod%d::%s",module_num,str);*/
if(!Feb_Control_SetDAC(str,f0,1))
printf("error in string: %s",str);
}
}
fclose(fp);
printf("Done reading set up file\n");
return 1;
}
int Feb_Control_CheckSetup(){
printf("Checking Set up\n");
unsigned int i,j;
int ok = 1;
for(i=0;i<moduleSize;i++){
/*for(i=0;i<moduleSize;i++){*/
i = Feb_Control_current_index;
for(j=0;j<4;j++){
if(Module_GetTopIDelay(&modules[i],j)<0){
printf("Warning: module %d's idelay top number %d not set.\n",Module_GetModuleNumber(&modules[i]),j);
@ -459,8 +600,8 @@ int Feb_Control_CheckSetup(){
ok=0;
}
}
}
/* }*/
printf("Done Checking Set up\n");
return ok;
}
@ -599,16 +740,20 @@ float Feb_Control_DACToVoltage(unsigned int digital,unsigned int nsteps,float vm
int Feb_Control_SetHighVoltage(float value){
return Feb_Control_SetHighVoltage1(0,value);
return Feb_Control_SetHighVoltage1(Feb_Control_current_mod,value);
}
int Feb_Control_SetHighVoltage1(unsigned int module_num,float value){
unsigned int module_index=0;
unsigned int i;
if(!Feb_Control_GetModuleIndex(module_num,&module_index)||!Module_TopAddressIsValid(&modules[module_index])){
printf("Error could not set high voltage module number %d invalid.\n",module_num);
return 0;
}
if(Module_TopAddressIsValid(&modules[module_index])){
if(!Feb_Control_GetModuleIndex(module_num,&module_index)){/*||!Module_TopAddressIsValid(&modules[module_index])){*/
printf("Error could not set high voltage module number %d invalid.\n",module_num);
return 0;
}
}else
return 0;
if(!Feb_Control_SendHighVoltage(Module_GetTopRightAddress(&modules[module_index]),&value)) return 0;
@ -649,45 +794,48 @@ 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 = 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){
strncpy(temp, p1+3, (p2-p1));
temp[p2-p1] = '\0';
unsigned int number = atoi(temp); //unsigned int number = atoi((local_s.substr(p1+3,p2-3)).c_str());
if(!Feb_Control_GetModuleIndex(number,module_index)){
printf("Error in dac_name \"%s\", module number %d not in list.\n",dac_str,number);
return 0;
}
strcpy(local_s,p2+2);//local_s = local_s.substr(p2+2);
}
*/
*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;
*dac_ch = 0;
if(!Feb_Control_GetDACNumber(local_s,dac_ch)){
printf("Error in dac_name: %s (%s)\n",dac_str,local_s);
return 0;
}
return 1;
}
@ -730,11 +878,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;
}
@ -748,9 +896,9 @@ int Feb_Control_SetDAC(char* dac_str, int value, int is_a_voltage_mv){
}
if(bottom&&Module_BottomAddressIsValid(&modules[module_index])){
if(!Feb_Control_SendDACValue(Module_GetBottomRightAddress(&modules[module_index]),dac_ch,&v)) return 0;
if(module_index!=0) Module_SetBottomDACValue(&modules[module_index],dac_ch,v);
else for(i=0;i<moduleSize;i++) Module_SetBottomDACValue(&modules[i],dac_ch,v);
if(!Feb_Control_SendDACValue(Module_GetBottomRightAddress(&modules[module_index]),dac_ch,&v))return 0;
if(module_index!=0) Module_SetBottomDACValue(&modules[module_index],dac_ch,v);
else for(i=0;i<moduleSize;i++) Module_SetBottomDACValue(&modules[i],dac_ch,v);
}
return 1;
@ -893,28 +1041,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[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_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[Feb_Control_current_index]),0,0,1024,trimbits_to_load_r)||
!Feb_Interface_WriteMemoryInLoops(Module_GetTopRightAddress(&modules[Feb_Control_current_index]),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[Feb_Control_current_index]),0,0,1024,trimbits_to_load_r)||
!Feb_Interface_WriteMemoryInLoops(Module_GetBottomRightAddress(&modules[Feb_Control_current_index]),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)
@ -933,9 +1094,23 @@ unsigned int* Feb_Control_GetTrimbits(){
unsigned int Feb_Control_AddressToAll(){
unsigned int Feb_Control_AddressToAll(){printf("in Feb_Control_AddressToAll()\n");
if(moduleSize==0) return 0;
return Module_GetTopLeftAddress(&modules[0])|Module_GetTopRightAddress(&modules[0]);
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");
// if(Feb_Control_am_i_master)
return Module_GetTopLeftAddress(&modules[0])|Module_GetTopRightAddress(&modules[0]);
// else return 0;
}
int Feb_Control_SetCommandRegister(unsigned int cmd){
@ -978,11 +1153,23 @@ int Feb_Control_WaitForFinishedFlag(int sleep_time_us){
}
int Feb_Control_AcquisitionInProgress(){
unsigned int status_reg_r=0;
unsigned int status_reg_r=0,status_reg_l=0;
if(!(Feb_Control_GetDAQStatusRegister(Module_GetTopRightAddress(&modules[1]),&status_reg_r)))
return 0;
if(status_reg_r&DAQ_STATUS_DAQ_RUNNING) return 1;
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;}
}
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))){
@ -993,6 +1180,7 @@ int Feb_Control_AcquisitionInProgress(){
}
*/
/*printf("**idle\n");*/
return 0; //i.e. not running (status_reg_r|status_reg_l)&DAQ_STATUS_DAQ_RUNNING;
}
@ -1164,8 +1352,8 @@ int Feb_Control_SetExternalEnableMode(int use_external_enable, int polarity){
}
int Feb_Control_SetNExposures(unsigned int n_images){
if(!Feb_Control_nimages){
printf("Warning nimages must be greater than zero.%d\n",Feb_Control_nimages);
if(!n_images){
printf("Warning nimages must be greater than zero.%d\n",n_images);
return 0;
}
@ -1306,7 +1494,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];
@ -1319,7 +1507,7 @@ int Feb_Control_StartAcquisition(){
return 0;
}
if(!Feb_Control_SetStaticBits(Feb_Control_staticBits&(DAQ_STATIC_BIT_M4|DAQ_STATIC_BIT_M8))){
if(!Feb_Control_SetStaticBits1(Feb_Control_staticBits&(DAQ_STATIC_BIT_M4|DAQ_STATIC_BIT_M8))){
printf("Trouble setting static bits ...\n");;
return 0;
}
@ -1334,6 +1522,7 @@ int Feb_Control_StartAcquisition(){
return 0;
}
reg_nums[0]=DAQ_REG_CTRL;
reg_vals[0]=0;
reg_nums[1]=DAQ_REG_NEXPOSURES;
@ -1342,6 +1531,53 @@ int Feb_Control_StartAcquisition(){
reg_vals[2]=Feb_Control_ConvertTimeToRegister(Feb_Control_exposure_time_in_sec);
reg_nums[3]=DAQ_REG_EXPOSURE_REPEAT_TIMER;
reg_vals[3]=Feb_Control_ConvertTimeToRegister(Feb_Control_exposure_period_in_sec);
///*
if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),4,reg_nums,reg_vals,0,0)){
printf("Trouble starting acquisition....\n");;
return 0;
}
unsigned int masterHalfModuleMode = 0;
reg_nums[0]=DAQ_REG_CHIP_CMDS;
reg_vals[0]=(masterHalfModuleMode|Feb_Control_acquireNReadoutMode|Feb_Control_triggerMode|Feb_Control_externalEnableMode|Feb_Control_subFrameMode);
if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),1,reg_nums,reg_vals,0,0)){
printf("Trouble writing commands....\n");;
return 0;
}
/*
masterHalfModuleMode = 0x80000000;
reg_nums[0]=DAQ_REG_CHIP_CMDS;
reg_vals[0]=(masterHalfModuleMode|Feb_Control_acquireNReadoutMode|Feb_Control_triggerMode|Feb_Control_externalEnableMode|Feb_Control_subFrameMode);
if(!Feb_Interface_WriteRegisters((Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1])),1,reg_nums,reg_vals,0,0)){
printf("Trouble writing commands....\n");;
return 0;
}
*/
//if(!Feb_Interface_WriteRegisters((Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1])),1,reg_nums,reg_vals,0,0)){
///*
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;
if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),15,reg_nums,reg_vals,0,0)){
printf("Trouble starting acquisition....\n");;
return 0;
}
//*/
/*
reg_nums[4]=DAQ_REG_CHIP_CMDS;
reg_vals[4]=(Feb_Control_acquireNReadoutMode|Feb_Control_triggerMode|Feb_Control_externalEnableMode|Feb_Control_subFrameMode);
int i;
@ -1352,11 +1588,12 @@ int Feb_Control_StartAcquisition(){
reg_nums[19]=DAQ_REG_CTRL;
reg_vals[19]=ACQ_CTRL_START;
// if(!Feb_Interface_WriteRegisters((Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[1])),20,reg_nums,reg_vals,0,0)){
if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),20,reg_nums,reg_vals,0,0)){
printf("Trouble starting acquisition....\n");;
return 0;
}
*/
return 1;
}

View File

@ -35,6 +35,7 @@ struct Module{
void Module_Module(struct Module* mod,unsigned int number, unsigned int address_top);
void Module_ModuleBottom(struct Module* mod,unsigned int number, unsigned int address_bottom);
void Module_Module1(struct Module* mod,unsigned int number, unsigned int address_top, unsigned int address_bottom);
unsigned int Module_GetModuleNumber(struct Module* mod);
int Module_TopAddressIsValid(struct Module* mod);
@ -64,8 +65,9 @@ int Module_GetBottomDACValue(struct Module* mod,unsigned int i);
int Feb_Control_IsBottomModule();
int Feb_Control_GetModuleNumber();
void Feb_Control_Set_Master();
void Feb_Control_ClearModules();
@ -101,7 +103,7 @@ int Module_GetBottomDACValue(struct Module* mod,unsigned int i);
int Feb_Control_ResetChipCompletely();
struct sockaddr_in Feb_Control_serv_addr;
//struct sockaddr_in Feb_Control_serv_addr;
/*
int Feb_Control_SetupSendToSocket(const char* ip_address_hostname, unsigned short int port);
int Feb_Control_WriteNRead(char* message, int length, int max_length);

View File

@ -36,4 +36,4 @@ beb_debug:$(SRC_CLNT3)
clean:
rm -rf $(DESTDIR)/$(PROGS) *.o

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
URL: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/eigerDetectorServer
Repository Root: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git
Repsitory UUID: c31619c88e5690230fcd389dc18f9139295c442c
Revision: 91
Repsitory UUID: ce7cd6255b7b3abf1c046e9703ae8288ec55135a
Revision: 97
Branch: master
Last Changed Author: Maliakal_Dhanya
Last Changed Rev: 280
Last Changed Date: 2014-09-09 15:43:18 +0200
Last Changed Rev: 282
Last Changed Date: 2014-10-16 13:49:56 +0200

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURL "git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/eigerDetectorServer"
//#define SVNREPPATH ""
#define SVNREPUUID "c31619c88e5690230fcd389dc18f9139295c442c"
//#define SVNREV 0x280
#define SVNREPUUID "ce7cd6255b7b3abf1c046e9703ae8288ec55135a"
//#define SVNREV 0x282
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTH "Maliakal_Dhanya"
#define SVNREV 0x280
#define SVNDATE 0x20140909
#define SVNREV 0x282
#define SVNDATE 0x20141016
//

View File

@ -6,6 +6,7 @@
#include <string.h>
#include "slsDetectorFunctionList.h"
#include "gitInfoEiger.h"
/*#include "EigerHighLevelFunctions.c"
@ -49,6 +50,11 @@ unsigned int nimages_per_request=1;
int on_dst=0;
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,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;
@ -99,16 +105,16 @@ int initDetector(){
Feb_Interface_FebInterface();
Feb_Control_FebControl();
Feb_Control_Init();
printf("FEb control constructor done\n");
Beb_Beb(-1);
printf("BEB constructor done\n");
//get dac values
int retval[2];
for(i=0;i<(detectorModules)->ndac;i++){
setDAC((enum detDacIndex)i,-1,(detectorModules)->module,0,retval);
(detectorModules)->dacs[i] = retval[0];
}
for(i=0;i<(detectorModules)->ndac;i++)
setDAC((enum detDacIndex)i,default_dac_values[i],(detectorModules)->module,0,retval);
/* initialize dynamic range etc. */
@ -121,12 +127,32 @@ int initDetector(){
setThresholdEnergy(8000,0);
setReadOutFlags(PARALLEL);
setSpeed(0,1);//clk_devider,half speed
setHighVolage(150,0);
setHighVolage(150,0);
setIODelay(675,0);
setTiming(AUTO_TIMING);
//setMaster(GET_MASTER);
int enable[2] = {0,1};
setExternalGating(enable);//disable external gating
Feb_Control_SetTestModeVariable(0);
Feb_Control_CheckSetup();
//if(!Feb_Control_IsBottomModule()){
//if(getDetectorNumber()==0xbeb031){
printf("************** master ********************\n");
trialMasterMode = IS_MASTER;
Feb_Control_Set_Master();
//}
//else printf("************** slave ********************\n");
if(Feb_Control_IsBottomModule())
printf("BOTTOM ***************\n");
else
printf("TOP ***************\n");
return 1;
}
@ -287,10 +313,10 @@ void setDAC(enum detDacIndex ind, int val, int imod, int mV, int retval[]){
if(val >= 0)
Feb_Control_SetDAC(iname,val,mV);
int k;
Feb_Control_GetDAC(iname, &k,0);
retval[0] = k;
Feb_Control_GetDAC(iname,&k,1);
retval[1] = k;
Feb_Control_GetDAC(iname, &k,0);
retval[0] = k;
Feb_Control_GetDAC(iname,&k,1);
retval[1] = k;
(detectorModules)->dacs[ind] = retval[0];
@ -316,7 +342,7 @@ int getADC(enum detDacIndex ind, int imod){
int setIODelay(int val, int imod){
if(val!=-1){
printf(" Setting IO Delay: %d\n",val);
if(Feb_Control_SetIDelays(0,val))
if(Feb_Control_SetIDelays(Feb_Control_GetModuleNumber(),val))
eiger_iodelay = val;
}
return eiger_iodelay;
@ -373,7 +399,7 @@ int setModule(sls_detector_module myMod){
}
Feb_Control_SetTrimbits(0,tt);
Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(),tt);
return 0;
@ -447,34 +473,35 @@ enum detectorSettings setSettings(enum detectorSettings sett, int imod){
int startStateMachine(){
printf("Going to start acquisition\n");
if(Feb_Control_StartAcquisition()){
//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;
int ret;
if(trialMasterMode == IS_MASTER){
printf("Going to start acquisition\n");
Feb_Control_StartAcquisition();
}
return FAIL;
//if(trialMasterMode == IS_MASTER){
printf("requesting images\n");
ret = startReadOut();
//}
if(trialMasterMode == IS_MASTER){
/*for(i=0;i<3;i++)
usleep(1000000);*/
while(getRunStatus() == IDLE);
printf("Acquiring..\n");
}
printf("Returning\n");
return ret;
}
int stopStateMachine(){
printf("Going to stop acquisition\n");
if(Feb_Control_StopAcquisition())
return OK;
if(trialMasterMode == IS_MASTER){
printf("Going to stop acquisition\n");
if(Feb_Control_StopAcquisition())
return OK;
}else return OK;
return FAIL;
}
@ -485,8 +512,10 @@ int startReadOut(){
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))))
int beb_num = 24;//Feb_Control_GetModuleNumber();
if((ret_val = (!Beb_RequestNImages(beb_num,1,send_to_ten_gig,on_dst,nimages_per_request,0)||
!Beb_RequestNImages(beb_num,2,send_to_ten_gig,0x20|on_dst,nimages_per_request,0))))
break;
dst_requested[on_dst++]=0;
on_dst%=ndsts_in_use;
@ -496,20 +525,22 @@ int startReadOut(){
return FAIL;
else
return OK;
return OK;
}
enum runStatus getRunStatus(){
if(trialMasterMode == IS_MASTER){
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;
}
}
return IDLE;
}
@ -517,6 +548,8 @@ enum runStatus getRunStatus(){
char *readFrame(int *ret, char *mess){
if(!Feb_Control_WaitForFinishedFlag(5000))
printf("error in waiting for finished flag\n");
printf("acquisition finished\n");
*ret = (int)FINISHED;
return NULL;
}
@ -532,8 +565,8 @@ int64_t setTimer(enum timerIndex ind, int64_t val){
switch(ind){
case FRAME_NUMBER:
if(val >= 0){
printf(" Setting number of frames: %d\n",(unsigned int)val);
if(Feb_Control_SetNExposures((unsigned int)val)*eiger_ncycles){
printf(" Setting number of frames: %d * %d\n",(unsigned int)val,eiger_ncycles);
if(Feb_Control_SetNExposures((unsigned int)val*eiger_ncycles)){
eiger_nexposures = val;
//SetDestinationParameters(EigerGetNumberOfExposures()*EigerGetNumberOfCycles());
on_dst = 0;
@ -570,7 +603,7 @@ int64_t setTimer(enum timerIndex ind, int64_t val){
return EigerGetNumberOfExposures();*/
case CYCLES_NUMBER:
if(val >= 0){
printf(" Setting number of triggers: %d\n",(unsigned int)val);
printf(" Setting number of triggers: %d * %d\n",(unsigned int)val,eiger_nexposures);
if(Feb_Control_SetNExposures((unsigned int)val*eiger_nexposures)){
eiger_ncycles = val;
//SetDestinationParameters(EigerGetNumberOfExposures()*EigerGetNumberOfCycles());
@ -609,6 +642,7 @@ int setDynamicRange(int dr){
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
if(Beb_SetUpTransferParameters(dr))
eiger_dynamicrange = dr;
else printf("ERROR:Could not set bit mode in the back end\n");
}
}
//make sure back end and front end have the same bit mode
@ -667,10 +701,9 @@ 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 ival){
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),
@ -686,35 +719,38 @@ int configureMAC(int ipad, long long int macad, long long int detectormacadd, in
(unsigned int)((macad>>8)&0xFF),
(unsigned int)((macad>>0)&0xFF));
printf("Seting up Table Entry Left:\n");
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 beb_num = 24;//Feb_Control_GetModuleNumber();
int header_number = 0;
int dst_port = udpport;
int i=0;
//EigerSetupTableEntryLeft(ipad, macad, detectormacadd, detipad, udpport);
printf("dst_port:%d\n\n",dst_port);
int i=0;
/* 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 left ok\n");
else return -1;
/*}*/
//EigerSetupTableEntryRight(ipad, macad, detectormacadd, detipad, udpport);
header_number = 32;
dst_port = udpport +1;
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;
/*}*/
//SetDestinationParameters(EigerGetNumberOfExposures()*EigerGetNumberOfCycles());
on_dst = 0;
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
@ -879,6 +915,9 @@ void setExternalGating(int enable[]){
enum masterFlags setMaster(enum masterFlags arg){
//if(arg != GET_MASTER)
// masterMode = arg;
return NO_MASTER;
}

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware
URL: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git
Repository Root: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git
Repsitory UUID: c31619c88e5690230fcd389dc18f9139295c442c
Revision: 852
Repsitory UUID: ce7cd6255b7b3abf1c046e9703ae8288ec55135a
Revision: 865
Branch: master
Last Changed Author: Maliakal_Dhanya
Last Changed Rev: 852
Last Changed Date: 2014-09-09 15:43:18 +0200
Last Changed Rev: 865
Last Changed Date: 2014-10-16 13:49:56 +0200

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/gotthardDetectorServer
URL: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/gotthardDetectorServer
Repository Root: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git
Repsitory UUID: c31619c88e5690230fcd389dc18f9139295c442c
Revision: 173
Repsitory UUID: ce7cd6255b7b3abf1c046e9703ae8288ec55135a
Revision: 175
Branch: master
Last Changed Author: Maliakal_Dhanya
Last Changed Rev: 280
Last Changed Date: 2014-09-09 15:43:18 +0200
Last Changed Rev: 282
Last Changed Date: 2014-10-16 13:49:56 +0200

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURL "git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/gotthardDetectorServer"
//#define SVNREPPATH ""
#define SVNREPUUID "c31619c88e5690230fcd389dc18f9139295c442c"
//#define SVNREV 0x280
#define SVNREPUUID "ce7cd6255b7b3abf1c046e9703ae8288ec55135a"
//#define SVNREV 0x282
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTH "Maliakal_Dhanya"
#define SVNREV 0x280
#define SVNDATE 0x20140909
#define SVNREV 0x282
#define SVNDATE 0x20141016
//

View File

@ -2547,7 +2547,7 @@ int update_client(int file_des) {
int configure_mac(int file_des) {
int ret=OK;
char arg[5][50];
char arg[6][50];
int n;
int imod=0;//should be in future sent from client as -1, arg[2]
@ -2572,7 +2572,7 @@ int configure_mac(int file_des) {
sscanf(arg[2], "%x", &udpport);
sscanf(arg[3], "%llx", &idetectormacadd);
sscanf(arg[4], "%x", &detipad);
//arg[5] is udpport2 for eiger
#ifdef VERBOSE
int i;
printf("\ndigital_test_bit in server %d\t",digitalTestBit);

View File

@ -0,0 +1 @@
AXIS_BUILDTYPE ?= cris-axis-linux-gnu

View File

@ -0,0 +1,48 @@
# $Id: Makefile,v 1.1.1.1 2006/02/04 03:35:01 freza Exp $
# first compile
# make cris-axis-linux-gnu
CROSS = bfin-uclinux-
CC = $(CROSS)gcc
CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG #-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER
PROGS= jungfrauDetectorServer
INSTDIR= /tftpboot
INSTMODE= 0777
BINS = testlib_sharedlibc
SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c
OBJS = $(SRCS:%.c=%.o)
all: clean $(PROGS)
boot: $(OBJS)
$(PROGS): $(OBJS)
echo $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
install: $(PROGS)
$(INSTALL) -d $(INSTDIR)
$(INSTALL) -m $(INSTMODE) $(PROGS) $(INSTDIR)
romfs:
$(ROMFSINST) /bin/$(PROGS)
clean:
rm -rf $(PROGS) *.o *.gdb

View File

@ -0,0 +1,30 @@
DESTDIR ?= ./
CC = gcc
CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DVIRTUAL
PROGS= $(DESTDIR)/moenchVirtualServer
SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c
OBJS = $(SRCS:%.c=%.o)
moenchVirtualServer = $(PROGS)
all: clean $(PROGS)
$(PROGS): $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
clean:
rm -rf $(PROGS) *.o *.gdb

View File

@ -0,0 +1 @@
../commonFiles/communication_funcs.c

View File

@ -0,0 +1 @@
../commonFiles/communication_funcs.h

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,187 @@
#ifndef FIRMWARE_FUNCS_H
#define FIRMWARE_FUNCS_H
#include "sls_detector_defs.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdarg.h>
#include <unistd.h>
//#include <asm/page.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdarg.h>
#include <unistd.h>
int mapCSP0(void);
u_int16_t bus_r16(u_int32_t offset);
u_int16_t bus_w16(u_int32_t offset, u_int16_t data);//aldos function
u_int32_t bus_w(u_int32_t offset, u_int32_t data);
u_int32_t bus_r(u_int32_t offset);
int setPhaseShiftOnce();
int phaseStep(int st);
int cleanFifo();
int setDAQRegister();
u_int32_t putout(char *s, int modnum);
u_int32_t readin(int modnum);
u_int32_t setClockDivider(int d);
u_int32_t getClockDivider();
u_int32_t setSetLength(int d);
u_int32_t getSetLength();
u_int32_t setWaitStates(int d);
u_int32_t getWaitStates();
u_int32_t setTotClockDivider(int d);
u_int32_t getTotClockDivider();
u_int32_t setTotDutyCycle(int d);
u_int32_t getTotDutyCycle();
u_int32_t setOversampling(int d);
u_int32_t setExtSignal(int d, enum externalSignalFlag mode);
int getExtSignal(int d);
u_int32_t setFPGASignal(int d, enum externalSignalFlag mode);
int getFPGASignal(int d);
int setTiming(int t);
int setConfigurationRegister(int d);
int setToT(int d);
int setContinousReadOut(int d);
int startReceiver(int d);
int setDACRegister(int idac, int val, int imod);
int getTemperature(int tempSensor,int imod);
int initHighVoltage(int val,int imod);
int initConfGain(int isettings,int val,int imod);
int setADC(int adc);
int configureMAC(int ipad, long long int macad, long long int detectormacadd, int detipad, int ival, int udpport);
int getAdcConfigured();
u_int64_t getDetectorNumber();
u_int32_t getFirmwareVersion();
int testFifos(void);
u_int32_t testFpga(void);
u_int32_t testRAM(void);
int testBus(void);
int setDigitalTestBit(int ival);
int64_t set64BitReg(int64_t value, int aLSB, int aMSB);
int64_t get64BitReg(int aLSB, int aMSB);
int64_t setFrames(int64_t value);
int64_t getFrames();
int64_t setExposureTime(int64_t value);
int64_t getExposureTime();
int64_t setGates(int64_t value);
int64_t getGates();
int64_t setDelay(int64_t value);
int64_t getDelay();
int64_t setPeriod(int64_t value);
int64_t getPeriod();
int64_t setTrains(int64_t value);
int64_t getTrains();
int64_t setProbes(int64_t value);
int64_t getProbes();
int64_t getProgress();
int64_t setProgress();
int64_t getActualTime();
int64_t getMeasurementTime();
u_int32_t runBusy(void);
u_int32_t runState(void);
u_int32_t dataPresent(void);
int startStateMachine();
int stopStateMachine();
int startReadOut();
u_int32_t fifoReset(void);
u_int32_t fifoReadCounter(int fifonum);
u_int32_t fifoReadStatus();
u_int32_t fifo_full(void);
u_int32_t* fifo_read_event();
u_int32_t* decode_data(int* datain);
//u_int32_t move_data(u_int64_t* datain, u_int64_t* dataout);
int setDynamicRange(int dr);
int getDynamicRange();
int getNModBoard();
int setNMod(int n);
int setStoreInRAM(int b);
int allocateRAM();
int clearRAM();
int setMaster(int f);
int setSynchronization(int s);
int loadImage(int index, short int ImageVals[]);
int readCounterBlock(int startACQ, short int CounterVals[]);
int resetCounterBlock(int startACQ);
int calibratePedestal(int frames);
uint64_t writePatternWord(int addr, uint64_t word);
uint64_t writePatternIOControl(uint64_t word);
uint64_t writePatternClkControl(uint64_t word);
int setPatternLoop(int level, int *start, int *stop, int *n);
int setPatternWaitAddress(int level, int addr);
uint64_t setPatternWaitTime(int level, uint64_t t);
/*
u_int32_t setNBits(u_int32_t);
u_int32_t getNBits();
*/
/*
//move to mcb_funcs?
int readOutChan(int *val);
u_int32_t getModuleNumber(int modnum);
int testShiftIn(int imod);
int testShiftOut(int imod);
int testShiftStSel(int imod);
int testDataInOut(int num, int imod);
int testExtPulse(int imod);
int testExtPulseMux(int imod, int ow);
int testDataInOutMux(int imod, int ow, int num);
int testOutMux(int imod);
int testFpgaMux(int imod);
int calibration_sensor(int num, int *values, int *dacs) ;
int calibration_chip(int num, int *values, int *dacs);
*/
#endif

View File

@ -0,0 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/moenchDetectorServer
URL: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/moenchDetectorServer
Repository Root: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git
Repsitory UUID: 046a469b1e6582c4c55bd6eaeb4818b618d0a9a9
Revision: 55
Branch: separate_receiver
Last Changed Author: Maliakal_Dhanya
Last Changed Rev: 14
Last Changed Date: 2014-06-03 12:26:45 +0200

View File

@ -0,0 +1,11 @@
//#define SVNPATH ""
#define SVNURL "git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/moenchDetectorServer"
//#define SVNREPPATH ""
#define SVNREPUUID "046a469b1e6582c4c55bd6eaeb4818b618d0a9a9"
//#define SVNREV 0x14
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTH "Maliakal_Dhanya"
#define SVNREV 0x14
#define SVNDATE 0x20140603
//

View File

@ -0,0 +1,11 @@
//#define SVNPATH ""
#define SVNURL ""
//#define SVNREPPATH ""
#define SVNREPUUID ""
//#define SVNREV ""
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTH ""
#define SVNREV ""
#define SVNDATE ""
//

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,174 @@
#ifdef MCB_FUNCS
#ifndef MCB_FUNCS_H
#define MCB_FUNCS_H
#include "sls_detector_defs.h"
#define RGPRVALS {100,50,200}
#define RGSH1VALS {300,200,400}
#define RGSH2VALS {260,300,260}
//high,dynamic,low,medium,very high
#define CONF_GAIN {0,0, 0, 1, 6, 2, 1}//dynamic gain confgain yet to be figured out-probably 8 or 16
#define DEFAULTGAIN {11.66,9.32,14.99}
#define DEFAULTOFFSET {817.5,828.6,804.2}
// DAC definitions
enum dacsVal{VDAC0, VDAC1, VDAC2, VDAC3, VDAC4, VDAC5, VDAC6, VDAC7, HIGH_VOLTAGE, CONFGAIN};
/* DAC adresses */
#define DACCS {0,0,1,1,2,2,3,3,4,4,5,5,6,6}
#define DACADDR {0,1,0,1,0,1,0,1,0,1,0,1,0,1}
//Register Definitions for temp,hv,dac gain
enum adcVals{TEMP_FPGA, TEMP_ADC};
//dynamic range
/*
#define MAX5523 commented out by dhanya
#ifndef MAX5523
#define MAX5533
#endif
#ifdef MAX5533
#define DAC_DR 4096
#endif
#ifdef MAX5523
*/
#define DAC_DR 1024
//#endif
//reference voltage
#define DAC_REFOUT1
#ifdef DAC_REFOUT2
#define DAC_MAX 2.425
#define DAC_REFOUT 2
#define DAC_REFOUT1
#endif
#ifdef DAC_REFOUT3
#define DAC_MAX 3.885
#define DAC_REFOUT 3
#define DAC_REFOUT1
#endif
#ifdef DAC_REFOUT0
#define DAC_MAX 1.214
#define DAC_REFOUT 0
#endif
#ifdef DAC_REFOUT1
#define DAC_MAX 1.940
#define DAC_REFOUT 1
#endif
/* dac calibration constants */
#define VA 1.11
#define CVTRIM 52.430851
#define BVTRIM -0.102022
#define AVTRIM 0.000050
#define PARTREF {100,1.55,-2.5,-2.5,0,-2.5}
#define PARTR1 {78,10,10,10,10,10}
#define PARTR2 {0,4.7,27,47,22,47}
//chip shiftin register meaning
#define OUTMUX_OFFSET 20
#define PROBES_OFFSET 4
#define OUTBUF_OFFSET 0
void showbits(int h);
int initDetector();
int copyChannel(sls_detector_channel *destChan, sls_detector_channel *srcChan);
int copyChip(sls_detector_chip *destChip, sls_detector_chip *srcChip);
int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod);
/* Register commands */
int clearDACSregister(int imod );
int nextDAC(int imod );
int clearCSregister(int imod );
int setCSregister(int imod );
int nextChip(int imod );
int firstChip(int imod );
int clearSSregister(int imod );
int setSSregister(int imod );
int nextStrip(int imod );
int selChannel(int strip,int imod );
int selChip(int chip,int imod );
int selMod(int mod,int imod );
/* DACs routines */
int program_one_dac(int addr, int value,int imod );
int set_one_dac(int imod);
int initDAC(int dac_addr, int value,int imod );
int initDACs(int* v,int imod );
int setSettings(int i,int imod);
int initDACbyIndex(int ind,int val, int imod);
int initDACbyIndexDACU(int ind,int val, int imod);
int getDACbyIndexDACU(int ind, int imod);
int getThresholdEnergy();
int setThresholdEnergy(int ethr);
/* Other DAC index routines*/
int getTemperatureByModule(int tempSensor, int imod);
int initHighVoltageByModule(int val, int imod);
int initConfGainByModule(int isettings,int val,int imod);
/* Initialization*/
int initChannel(int ft,int cae, int ae, int coe, int ocoe, int counts,int imod );
int initChannelbyNumber(sls_detector_channel myChan);
int getChannelbyNumber(sls_detector_channel*);
int getTrimbit(int imod, int ichip, int ichan);
int initChip(int obe, int ow,int imod );
int initChipWithProbes(int obe, int ow,int nprobes, int imod);
//int getNProbes();
int initChipbyNumber(sls_detector_chip myChip);
int getChipbyNumber(sls_detector_chip*);
int initMCBregisters(int cm,int imod );
int initModulebyNumber(sls_detector_module);
int getModulebyNumber(sls_detector_module*);
/* To chips */
int clearCounter(int imod );
int clearOutReg(int imod);
int setOutReg(int imod );
int extPulse(int ncal,int imod );
int calPulse(int ncal,int imod );
int counterClear(int imod );
int countEnable(int imod );
int counterSet(int imod );
/* moved from firmware_funcs */
int readOutChan(int *val);
int getModuleNumber(int modnum);
int testShiftIn(int imod);
int testShiftOut(int imod);
int testShiftStSel(int imod);
int testDataInOut(int num, int imod);
int testExtPulse(int imod);
int testExtPulseMux(int imod, int ow);
int testDataInOutMux(int imod, int ow, int num);
int testOutMux(int imod);
int testFpgaMux(int imod);
int calibration_sensor(int num, int *values, int *dacs) ;
int calibration_chip(int num, int *values, int *dacs);
ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret);
#endif
#endif

View File

@ -0,0 +1,505 @@
#ifndef REGISTERS_G_H
#define REGISTERS_G_H
#include "sls_detector_defs.h"
/* Definitions for FPGA*/
#define CSP0 0x20200000
#define MEM_SIZE 0x100000
/* values defined for FPGA */
#define MCSNUM 0x0
#define FIXED_PATT_VAL 0xacdc1980
#define FPGA_INIT_PAT 0x60008
#define FPGA_INIT_ADDR 0xb0000000
/* constant FPGAVersionReg_c : integer:= 0; */
/* constant FixedPatternReg_c : integer:= 1; */
/* constant StatusReg_c : integer:= 2; */
/* constant LookAtMeReg_c : integer:= 3; */
/* constant SystemStatusReg_c : integer:= 4; */
/* constant PLL_ParamOutReg_c : integer:=5; -- RO register to check control signals going to the chip */
/* --time registers use only even numbers! */
/* constant TimeFromStartReg_c : integer:= 16; */
/* --constant TimeFromStartReg_c : integer:= 17; MSB */
/* constant GetDelayReg_c : integer:= 18; */
/* --constant GetDelayReg_c : integer:= 19; MSB */
/* constant GetCyclesReg_c : integer:= 20; */
/* --constant GetTrainsReg_c : integer:= 21; MSB */
/* constant GetFramesReg_c : integer:= 22; */
/* --constant GetFramesReg_c : integer:= 23; MSB */
/* constant GetPeriodReg_c : integer:= 24; */
/* --constant GetPeriodReg_c : integer:= 25; MSB */
/* constant GetExpTimeReg_c : integer:= 26; */
/* --constant GetExpTimeReg_c : integer:= 27; MSB */
/* constant GetGatesReg_c : integer:= 28; */
/* --constant GetGatesReg_c : integer:= 29; MSB */
/* -----rw: */
/* constant DACReg_c : integer:= 64; */
/* constant ADCWriteReg_c : integer:= 65; */
/* constant ADCsyncReg_c : integer:= 66; */
/* constant HVReg_c : integer:= 67; */
/* constant DummyReg_c : integer:= 68; */
/* constant rx_udpip_AReg_c : integer:= 69; */
/* constant udpports_AReg_c : integer:= 70; */
/* constant rx_udpmacL_AReg_c : integer:= 71; */
/* constant rx_udpmacH_AReg_c : integer:= 72; */
/* constant detectormacL_AReg_c : integer:= 73; */
/* constant detectormacH_AReg_c : integer:= 74; */
/* constant detectorip_AReg_c : integer:= 75; */
/* constant ipchksum_AReg_c : integer:= 76; */
/* constant ConfigReg_c : integer:= 77; */
/* constant ExtSignalReg_c : integer:= 78; */
/* constant ControlReg_c : integer:= 79; */
/* constant PLL_ParamReg_c : integer:= 80; */
/* constant PLL_CntrlReg_c : integer:=81; */
/* --time registers use only even numbers! */
/* -- DELAY_AFTER_TRIGGER, */
/* constant SetDelayReg_c : integer:= 96; */
/* --constant SetDelayReg_c : integer:= 97; MSB */
/* -- CYCLES_NUMBER, */
/* constant SetCyclesReg_c : integer:= 98; */
/* --constant SetCyclesReg_c : integer:= 99;MSB */
/* -- FRAME_NUMBER, */
/* constant SetFramesReg_c : integer:= 100; */
/* --constant SetFramesReg_c : integer:= 101; MSB */
/* -- FRAME_PERIOD, */
/* constant SetPeriodReg_c : integer:= 102; */
/* --constant SetPeriodReg_c : integer:= 103; MSB */
/* -- ACQUISITION_TIME, */
/* constant SetExpTimeReg_c : integer:= 104; */
/* --constant SetExpTimeReg_c : integer:= 105; MSB */
/* -- GATES_NUMBER, */
/* constant SetGatesReg_c : integer:= 106; */
/* --constant SetGatesReg_c : integer:= 107; MSB */
/* registers defined in FPGA */
#define PCB_REV_REG 0x2c<<11
#define GAIN_REG 0x10<<11
//#define FLOW_CONTROL_REG 0x11<<11
//#define FLOW_STATUS_REG 0x12<<11
//#define FRAME_REG 0x13<<11
#define MULTI_PURPOSE_REG 0x14<<11
//#define TIME_FROM_START_REG 0x16<<11
#define DAC_REG 64<<11//0x17<<11// control the dacs
//ADC
#define ADC_WRITE_REG 65<<11//0x18<<11
#define ADC_SYNC_REG 66<<11//0x19<<11
//#define MUTIME_REG 0x1a<<11
//temperature
#define TEMP_IN_REG 0x1b<<11
#define TEMP_OUT_REG 0x1c<<11
//configure MAC
#define TSE_CONF_REG 0x1d<<11
#define ENET_CONF_REG 0x1e<<11
//#define WRTSE_SHAD_REG 0x1f<<11
//HV
#define HV_REG 67<<11//0x20<<11
#define DUMMY_REG 68<<11//0x21<<11
#define FPGA_VERSION_REG 0<<11 //0x22<<11
#define FIX_PATT_REG 1<<11 //0x23<<11
#define CONTROL_REG 79<<11//0x24<<11
#define STATUS_REG 2<<11 //0x25<<11
#define CONFIG_REG 77<<11//0x26<<11
#define EXT_SIGNAL_REG 78<<11// 0x27<<11
#define FPGA_SVN_REG 0x29<<11
#define CHIP_OF_INTRST_REG 0x2A<<11
//FIFO
#define LOOK_AT_ME_REG 3<<11 //0x28<<11
#define SYSTEM_STATUS_REG 4<<11
#define FIFO_DATA_REG_OFF 0x50<<11 ///////
//to read back dac registers
#define MOD_DACS1_REG 0x65<<11
#define MOD_DACS2_REG 0x66<<11
#define MOD_DACS3_REG 0x67<<11
//user entered
#define GET_ACTUAL_TIME_LSB_REG 16<<11
#define GET_ACTUAL_TIME_MSB_REG 17<<11
#define SET_DELAY_LSB_REG 96<<11 //0x68<<11
#define SET_DELAY_MSB_REG 97<<11 //0x69<<11
#define GET_DELAY_LSB_REG 18<<11//0x6a<<11
#define GET_DELAY_MSB_REG 19<<11//0x6b<<11
#define SET_CYCLES_LSB_REG 98<<11//0x6c<<11
#define SET_CYCLES_MSB_REG 99<<11//0x6d<<11
#define GET_CYCLES_LSB_REG 20<<11//0x6e<<11
#define GET_CYCLES_MSB_REG 21<<11//0x6f<<11
#define SET_FRAMES_LSB_REG 100<<11//0x70<<11
#define SET_FRAMES_MSB_REG 101<<11//0x71<<11
#define GET_FRAMES_LSB_REG 22<<11//0x72<<11
#define GET_FRAMES_MSB_REG 23<<11//0x73<<11
#define SET_PERIOD_LSB_REG 102<<11//0x74<<11
#define SET_PERIOD_MSB_REG 103<<11//0x75<<11
#define GET_PERIOD_LSB_REG 24<<11//0x76<<11
#define GET_PERIOD_MSB_REG 25<<11//0x77<<11
#define SET_EXPTIME_LSB_REG 104<<11//0x78<<11
#define SET_EXPTIME_MSB_REG 105<<11//0x79<<11
#define GET_EXPTIME_LSB_REG 26<<11//0x7a<<11
#define GET_EXPTIME_MSB_REG 27<<11//0x7b<<11
#define SET_GATES_LSB_REG 106<<11//0x7c<<11
#define SET_GATES_MSB_REG 107<<11//0x7d<<11
#define GET_GATES_LSB_REG 28<<11//0x7e<<11
#define GET_GATES_MSB_REG 29<<11//0x7f<<11
#define PLL_PARAM_REG 80<<11//0x37<<11
#define PLL_PARAM_OUT_REG 5<<11 //0x38<<11
#define PLL_CNTRL_REG 81<<11//0x34<<11
#define RX_UDP_AREG 69<<11 //rx_udpip_AReg_c : integer:= 69; */
#define UDPPORTS_AREG 70<<11// udpports_AReg_c : integer:= 70; */
#define RX_UDPMACL_AREG 71<<11//rx_udpmacL_AReg_c : integer:= 71; */
#define RX_UDPMACH_AREG 72<<11//rx_udpmacH_AReg_c : integer:= 72; */
#define DETECTORMACL_AREG 73<<11//detectormacL_AReg_c : integer:= 73; */
#define DETECTORMACH_AREG 74<<11//detectormacH_AReg_c : integer:= 74; */
#define DETECTORIP_AREG 75<<11//detectorip_AReg_c : integer:= 75; */
#define IPCHKSUM_AREG 76<<11//ipchksum_AReg_c : integer:= 76; */
#define PATTERN_CNTRL_REG 82<<11
#define PATTERN_LIMITS_AREG 83<<11
#define PATTERN_LOOP0_AREG 84<<11
#define PATTERN_N_LOOP0_REG 85<<11
#define PATTERN_LOOP1_AREG 86<<11
#define PATTERN_N_LOOP1_REG 87<<11
#define PATTERN_LOOP2_AREG 88<<11
#define PATTERN_N_LOOP2_REG 89<<11
#define PATTERN_WAIT0_AREG 90<<11
#define PATTERN_WAIT1_AREG 91<<11
#define PATTERN_WAIT2_AREG 92<<11
#define DAQ_REG 93<<11
#define ADC_LATCH_ENABLE_REG 94<<11
#define PATTERN_IOCTRL_REG_LSB 108<<11
#define PATTERN_IOCTRL_REG_MSB 109<<12
#define PATTERN_IOCLKCTRL_REG_LSB 110<<11
#define PATTERN_IOCLKCTRL_REG_MSB 111<<11
#define PATTERN_IN_REG_LSB 112<<11
#define PATTERN_IN_REG_MSB 113<<11
#define PATTERN_WAIT0_TIME_REG_LSB 114<<11
#define PATTERN_WAIT0_TIME_REG_MSB 115<<11
#define PATTERN_WAIT1_TIME_REG_LSB 116<<11
#define PATTERN_WAIT1_TIME_REG_MSB 117<<11
#define PATTERN_WAIT2_TIME_REG_LSB 118<<11
#define PATTERN_WAIT2_TIME_REG_MSB 119<<11
#define ROI_REG 0 // 0x35<<11
#define OVERSAMPLING_REG 0 // 0x36<<11
#define MOENCH_CNTR_REG 0 // 0x31<<11
#define MOENCH_CNTR_OUT_REG 0 // 0x33<<11
#define MOENCH_CNTR_CONF_REG 0 // 0x32<<11
//image
#define DARK_IMAGE_REG 0 // 0x81<<11
#define GAIN_IMAGE_REG 0 // 0x82<<11
//counter block memory
#define COUNTER_MEMORY_REG 0 // 0x85<<11
#define GET_MEASUREMENT_TIME_LSB_REG 0 // 0x023000
#define GET_MEASUREMENT_TIME_MSB_REG 0 // 0x024000
//#define GET_ACTUAL_TIME_LSB_REG 0 // 0x025000
//#define GET_ACTUAL_TIME_MSB_REG 0 // 0x026000
//not used
//#define MCB_DOUT_REG_OFF 0 // 0x200000
//#define FIFO_CNTRL_REG_OFF 0 // 0x300000
//#define FIFO_COUNTR_REG_OFF 0 // 0x400000
//not used so far
//#define SPEED_REG 0 // 0x006000
//#define SET_NBITS_REG 0 // 0x008000
//not used
//#define GET_SHIFT_IN_REG 0 // 0x022000
#define SHIFTMOD 2
#define SHIFTFIFO 9
/** for PCB_REV_REG */
#define DETECTOR_TYPE_MASK 0xF0000
#define DETECTOR_TYPE_OFFSET 16
#define BOARD_REVISION_MASK 0xFFFF
#define MOENCH_MODULE 2
/* for control register */
#define START_ACQ_BIT 0x00000001
#define STOP_ACQ_BIT 0x00000002
#define START_FIFOTEST_BIT 0x00000004 // ?????
#define STOP_FIFOTEST_BIT 0x00000008 // ??????
#define START_READOUT_BIT 0x00000010
#define STOP_READOUT_BIT 0x00000020
#define START_EXPOSURE_BIT 0x00000040
#define STOP_EXPOSURE_BIT 0x00000080
#define START_TRAIN_BIT 0x00000100
#define STOP_TRAIN_BIT 0x00000200
#define SYNC_RESET 0x00000400
/* for status register */
#define RUN_BUSY_BIT 0x00000001
#define READOUT_BUSY_BIT 0x00000002
#define FIFOTEST_BUSY_BIT 0x00000004 //????
#define WAITING_FOR_TRIGGER_BIT 0x00000008
#define DELAYBEFORE_BIT 0x00000010
#define DELAYAFTER_BIT 0x00000020
#define EXPOSING_BIT 0x00000040
#define COUNT_ENABLE_BIT 0x00000080
#define READSTATE_0_BIT 0x00000100
#define READSTATE_1_BIT 0x00000200
#define READSTATE_2_BIT 0x00000400
#define RUNSTATE_0_BIT 0x00001000
#define RUNSTATE_1_BIT 0x00002000
#define RUNSTATE_2_BIT 0x00004000
#define SOME_FIFO_FULL_BIT 0x00008000 // error!
#define ALL_FIFO_EMPTY_BIT 0x00010000 // data ready
#define RUNMACHINE_BUSY_BIT 0x00020000
#define READMACHINE_BUSY_BIT 0x00040000
/* for fifo status register */
#define FIFO_ENABLED_BIT 0x80000000
#define FIFO_DISABLED_BIT 0x01000000
#define FIFO_ERROR_BIT 0x08000000
#define FIFO_EMPTY_BIT 0x04000000
#define FIFO_DATA_READY_BIT 0x02000000
#define FIFO_COUNTER_MASK 0x000001ff
#define FIFO_NM_MASK 0x00e00000
#define FIFO_NM_OFF 21
#define FIFO_NC_MASK 0x001ffe00
#define FIFO_NC_OFF 9
/* for config register *///not really used yet
#define TOT_ENABLE_BIT 0x00000002
#define TIMED_GATE_BIT 0x00000004
#define CONT_RO_ENABLE_BIT 0x00080000
#define CPU_OR_RECEIVER_BIT 0x00001000
/* for speed register */
#define CLK_DIVIDER_MASK 0x000000ff
#define CLK_DIVIDER_OFFSET 0
#define SET_LENGTH_MASK 0x00000f00
#define SET_LENGTH_OFFSET 8
#define WAIT_STATES_MASK 0x0000f000
#define WAIT_STATES_OFFSET 12
#define TOTCLK_DIVIDER_MASK 0xff000000
#define TOTCLK_DIVIDER_OFFSET 24
#define TOTCLK_DUTYCYCLE_MASK 0x00ff0000
#define TOTCLK_DUTYCYCLE_OFFSET 16
/* for external signal register */
#define SIGNAL_OFFSET 4
#define SIGNAL_MASK 0xF
#define EXT_SIG_OFF 0x0
#define EXT_GATE_IN_ACTIVEHIGH 0x1
#define EXT_GATE_IN_ACTIVELOW 0x2
#define EXT_TRIG_IN_RISING 0x3
#define EXT_TRIG_IN_FALLING 0x4
#define EXT_RO_TRIG_IN_RISING 0x5
#define EXT_RO_TRIG_IN_FALLING 0x6
#define EXT_GATE_OUT_ACTIVEHIGH 0x7
#define EXT_GATE_OUT_ACTIVELOW 0x8
#define EXT_TRIG_OUT_RISING 0x9
#define EXT_TRIG_OUT_FALLING 0xA
#define EXT_RO_TRIG_OUT_RISING 0xB
#define EXT_RO_TRIG_OUT_FALLING 0xC
/* for temperature register */
#define T1_CLK_BIT 0x00000001
#define T1_CS_BIT 0x00000002
#define T2_CLK_BIT 0x00000004
#define T2_CS_BIT 0x00000008
/* fifo control register */
#define FIFO_RESET_BIT 0x00000001
#define FIFO_DISABLE_TOGGLE_BIT 0x00000002
//chip shiftin register meaning
#define OUTMUX_OFF 20
#define OUTMUX_MASK 0x1f
#define PROBES_OFF 4
#define PROBES_MASK 0x7f
#define OUTBUF_OFF 0
#define OUTBUF_MASK 1
/* multi purpose register */
#define PHASE_STEP_BIT 0x00000001
#define PHASE_STEP_OFFSET 0
// #define xxx_BIT 0x00000002
#define RESET_COUNTER_BIT 0x00000004
#define RESET_COUNTER_OFFSET 2
//#define xxx_BIT 0x00000008
//#define xxx_BIT 0x00000010
#define SW1_BIT 0x00000020
#define SW1_OFFSET 5
#define WRITE_BACK_BIT 0x00000040
#define WRITE_BACK_OFFSET 6
#define RESET_BIT 0x00000080
#define RESET_OFFSET 7
#define ENET_RESETN_BIT 0x00000800
#define ENET_RESETN_OFFSET 11
#define INT_RSTN_BIT 0x00002000
#define INT_RSTN_OFFSET 13
#define DIGITAL_TEST_BIT 0x00004000
#define DIGITAL_TEST_OFFSET 14
//#define CHANGE_AT_POWER_ON_BIT 0x00008000
//#define CHANGE_AT_POWER_ON_OFFSET 15
/* settings/conf gain register */
#define GAIN_MASK 0x0000000f
#define GAIN_OFFSET 0
#define SETTINGS_MASK 0x000000f0
#define SETTINGS_OFFSET 4
/* CHIP_OF_INTRST_REG */
#define CHANNEL_MASK 0xffff0000
#define CHANNEL_OFFSET 16
#define ACTIVE_ADC_MASK 0x0000001f
/**ADC SYNC CLEAN FIFO*/
#define ADCSYNC_CLEAN_FIFO_BITS 0x300000
#define CLEAN_FIFO_MASK 0x0fffff
#define PLL_CNTR_ADDR_OFF 16 //PLL_CNTR_REG bits 21 downto 16 represent the counter address
#define PLL_CNTR_RECONFIG_RESET_BIT 0
#define PLL_CNTR_READ_BIT 1
#define PLL_CNTR_WRITE_BIT 2
#define PLL_MODE_REG 0x0
#define PLL_STATUS_REG 0x1
#define PLL_START_REG 0x2
#define PLL_N_COUNTER_REG 0x3
#define PLL_M_COUNTER_REG 0x4
#define PLL_C_COUNTER_REG 0x5 //which ccounter stands in param 22:18; 7:0 lowcount 15:8 highcount; 16 bypassenable; 17 oddivision
#define PLL_PHASE_SHIFT_REG 0x6
#define PLL_K_COUNTER_REG 0x7
#define PLL_BANDWIDTH_REG 0x8
#define PLL_CHARGEPUMP_REG 0x9
#define PLL_VCO_DIV_REG 0x1c
#define PLL_MIF_REG 0x1f
#define PPL_M_CNT_PARAM_DEFAULT 0x4040
#define PPL_N_CNT_PARAM_DEFAULT 0x20D0C
#define PPL_C0_CNT_PARAM_DEFAULT 0x20D0C
#define PPL_C1_CNT_PARAM_DEFAULT 0xA0A0
#define PPL_C2_CNT_PARAM_DEFAULT 0x20D0C
#define PPL_C3_CNT_PARAM_DEFAULT 0x0808
#define PPL_BW_PARAM_DEFAULT 0x2EE0
#define PPL_VCO_PARAM_DEFAULT 0x1
/**------------------
-- pattern registers definitions
--------------------------------------------- */
#define IOSIGNALS_MASK 0xfffffffffffff
#define ADC_ENABLE_BIT 63
#define APATTERN_MASK 0x3ff
#define ASTART_OFFSET 0
#define ASTOP_OFFSET 16
#define PATTERN_CTRL_WRITE_BIT 0
#define PATTERN_CTRL_ADDR_OFFSET 16
#define MAX_PATTERN_LENGTH 1024
#endif

View File

@ -0,0 +1,137 @@
/* A simple server in the internet domain using TCP
The port number is passed as an argument */
#include "sls_detector_defs.h"
#include "communication_funcs.h"
#include "server_funcs.h"
#include <stdlib.h>
extern int sockfd;
extern int phase_shift;
void error(char *msg)
{
perror(msg);
}
int main(int argc, char *argv[])
{
int portno, b;
char cmd[500];
int retval=OK;
int sd, fd;
int iarg;
int checkType = 1;
for(iarg=1; iarg<argc; iarg++){
if(!strcasecmp(argv[iarg],"-phaseshift")){
if(argc==iarg+1){
printf("No phaseshift given. Exiting.\n");
return 1;
}
if ( sscanf(argv[iarg+1],"%d",&phase_shift)==0) {
printf("could not decode phase shift\n");
return 1;
}
}
else if(!strcasecmp(argv[iarg],"-test")){
if(argc==iarg+1){
printf("No test condition given. Exiting.\n");
return 1;
}
if(!strcasecmp(argv[iarg+1],"with_gotthard")){
checkType = 0;
}else{
printf("could not decode test condition. Possible arguments: with_gotthard. Exiting\n");
return 1;
}
}
}
//stop server
if ((argc > 2) && (!strcasecmp(argv[2],"stopserver"))){
portno = DEFAULT_PORTNO+1;
if ( sscanf(argv[1],"%d",&portno) ==0) {
printf("could not open stop server: unknown port\n");
return 1;
}
b=0;
printf("\n\nStop Server\nOpening stop server on port %d\n",portno);
checkType=0;
}
//control server
else {
portno = DEFAULT_PORTNO;
if(checkType)
sprintf(cmd,"%s %d stopserver &",argv[0],DEFAULT_PORTNO+1);
else
sprintf(cmd,"%s %d stopserver -test with_gotthard &",argv[0],DEFAULT_PORTNO+1);
printf("\n\nControl Server\nOpening control server on port %d\n",portno );
//printf("\n\ncmd:%s\n",cmd);
system(cmd);
b=1;
checkType=1;
}
init_detector(b, checkType);
sd=bindSocket(portno);
sockfd=sd;
if (getServerError(sd)) {
printf("server error!\n");
return -1;
}
/* assign function table */
function_table();
#ifdef VERBOSE
printf("function table assigned \n");
#endif
/* waits for connection */
while(retval!=GOODBYE) {
#ifdef VERBOSE
printf("\n");
#endif
#ifdef VERY_VERBOSE
printf("Waiting for client call\n");
#endif
fd=acceptConnection(sockfd);
#ifdef VERY_VERBOSE
printf("Conenction accepted\n");
#endif
retval=decode_function(fd);
#ifdef VERY_VERBOSE
printf("function executed\n");
#endif
closeConnection(fd);
#ifdef VERY_VERBOSE
printf("connection closed\n");
#endif
}
exitServer(sockfd);
printf("Goodbye!\n");
return 0;
}

View File

@ -0,0 +1,63 @@
#ifndef SERVER_DEFS_H
#define SERVER_DEFS_H
#include "sls_detector_defs.h"
#include <stdint.h>
// Hardware definitions
#define NCHAN (160*160)
#define NCHIP 1
#define NMAXMODX 1
#define NMAXMODY 1
#define NMAXMOD (NMAXMODX*NMAXMODY)
#define NDAC 8
#define NADC 1
/**when moench readout tested with gotthard module*/
#define GOTTHARDNCHAN 128
#define GOTTHARDNCHIP 10
#define NCHANS (NCHAN*NCHIP*NMAXMOD)
#define NDACS (NDAC*NMAXMOD)
#define NTRIMBITS 6
#define NCOUNTBITS 24
#define NCHIPS_PER_ADC 2
//#define TRIM_DR ((2**NTRIMBITS)-1)
//#define COUNT_DR ((2**NCOUNTBITS)-1)
#define TRIM_DR (((int)pow(2,NTRIMBITS))-1)
#define COUNT_DR (((int)pow(2,NCOUNTBITS))-1)
#define ALLMOD 0xffff
#define ALLFIFO 0xffff
#define GOTTHARD_ADCSYNC_VAL 0x32214
#define ADCSYNC_VAL 0x02111
#define TOKEN_RESTART_DELAY 0x88000000
#define TOKEN_RESTART_DELAY_ROI 0x1b000000
#define TOKEN_TIMING_REV1 0x1f16
#define TOKEN_TIMING_REV2 0x1f0f
#define DEFAULT_PHASE_SHIFT 0 // 120
#define DEFAULT_IP_PACKETSIZE 0x0522
#define DEFAULT_UDP_PACKETSIZE 0x050E
#define ADC1_IP_PACKETSIZE 256*2+14+20
#define ADC1_UDP_PACKETSIZE 256*2+4+8+2
#ifdef VIRTUAL
#define DEBUGOUT
#endif
#define CLK_FREQ 65.6E+6
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,98 @@
#ifndef SERVER_FUNCS_H
#define SERVER_FUNCS_H
#include "sls_detector_defs.h"
#include <stdio.h>
/*
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
*/
#include "communication_funcs.h"
#define GOODBYE -200
int sockfd;
int function_table();
int decode_function(int);
int init_detector(int,int);
int M_nofunc(int);
int exit_server(int);
// General purpose functions
int get_detector_type(int);
int set_number_of_modules(int);
int get_max_number_of_modules(int);
int exec_command(int);
int set_external_signal_flag(int);
int set_external_communication_mode(int);
int get_id(int);
int digital_test(int);
int write_register(int);
int read_register(int);
int set_dac(int);
int get_adc(int);
int set_channel(int);
int set_chip(int);
int set_module(int);
int get_channel(int);
int get_chip(int);
int get_module(int);
int get_threshold_energy(int);
int set_threshold_energy(int);
int set_settings(int);
int start_acquisition(int);
int stop_acquisition(int);
int start_readout(int);
int get_run_status(int);
int read_frame(int);
int read_all(int);
int start_and_read_all(int);
int set_timer(int);
int get_time_left(int);
int set_dynamic_range(int);
int set_roi(int);
int get_roi(int);
int set_speed(int);
void prepareADC(void);
int set_readout_flags(int);
int execute_trimming(int);
int lock_server(int);
int set_port(int);
int get_last_client_ip(int);
int set_master(int);
int set_synchronization(int);
int update_client(int);
int send_update(int);
int configure_mac(int);
int load_image(int);
int read_counter_block(int);
int reset_counter_block(int);
int start_receiver(int);
int stop_receiver(int);
int calibrate_pedestal(int);
int set_roi(int);
int set_ctb_pattern(int);
#endif

View File

@ -0,0 +1,39 @@
#include "sharedmemory.h"
struct statusdata *stdata;
int inism(int clsv) {
static int scansmid;
if (clsv==SMSV) {
if ( (scansmid=shmget(SMKEY,1024,IPC_CREAT | 0666 ))==-1 ) {
return -1;
}
if ( (stdata=shmat(scansmid,NULL,0))==(void*)-1) {
return -2;
}
}
if (clsv==SMCL) {
if ( (scansmid=shmget(SMKEY,0,0) )==-1 ) {
return -3;
}
if ( (stdata=shmat(scansmid,NULL,0))==(void*)-1) {
return -4;
}
}
return 1;
}
void write_status_sm(char *status) {
strcpy(stdata->status,status);
}
void write_stop_sm(int v) {
stdata->stop=v;
}
void write_runnumber_sm(int v) {
stdata->runnumber=v;
}

View File

@ -0,0 +1,48 @@
#ifndef SM
#define SM
#include "sls_detector_defs.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdarg.h>
#include <unistd.h>
//#include <asm/page.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdarg.h>
#include <unistd.h>
#include <sys/shm.h>
#include <sys/ipc.h>
#include <sys/stat.h>
/* key for shared memory */
#define SMKEY 10001
#define SMSV 1
#define SMCL 2
struct statusdata {
int runnumber;
int stop;
char status[20];
} ;
/* for shared memory */
int inism(int clsv);
void write_status_sm(char *status);
void write_stop_sm(int v);
void write_runnumber_sm(int v);
#endif

View File

@ -0,0 +1 @@
../commonFiles/sls_detector_defs.h

View File

@ -0,0 +1 @@
../commonFiles/sls_detector_funcs.h

View File

@ -0,0 +1 @@
../../slsReceiverSoftware/includes/sls_receiver_defs.h

View File

@ -0,0 +1 @@
../../slsReceiverSoftware/includes/sls_receiver_funcs.h

View File

@ -0,0 +1,46 @@
/* A simple server in the internet domain using TCP
The port number is passed as an argument */
#include "sls_detector_defs.h"
#include "communication_funcs.h"
#include "firmware_funcs.h"
int sockfd;
int main(int argc, char *argv[])
{
int portno;
int retval=0;
portno = DEFAULT_PORTNO;
bindSocket(portno);
if (getServerError())
return -1;
/* waits for connection */
while(retval!=GOODBYE) {
#ifdef VERBOSE
printf("\n");
#endif
#ifdef VERY_VERBOSE
printf("Stop server: waiting for client call\n");
#endif
acceptConnection();
retval=stopStateMachine();
closeConnection();
}
exitServer();
printf("Goodbye!\n");
return 0;
}

View File

@ -0,0 +1,749 @@
#ifndef PICASSOD
#include "server_defs.h"
#else
#include "picasso_defs.h"
#endif
#include "trimming_funcs.h"
#include "mcb_funcs.h"
#include "firmware_funcs.h"
#include <math.h>
extern int nModX;
//extern int *values;
extern const int nChans;
extern const int nChips;
extern const int nDacs;
extern const int nAdcs;
int trim_fixed_settings(int countlim, int par2, int im)
{
int retval=OK;
#ifdef VERBOSE
printf("Trimming with fixed settings\n");
#endif
#ifdef VIRTUAL
return OK;
#endif
if (par2<=0)
retval=trim_with_level(countlim, im);
else
retval=trim_with_median(countlim,im);
return retval;
}
int trim_with_noise(int countlim, int nsigma, int im)
{
int retval=OK, retval1=OK, retval2=OK;
#ifdef VERBOSE
printf("Trimming using noise\n");
#endif
#ifdef VIRTUAL
return OK;
#endif
/* threshold scan */
#ifdef VERBOSE
printf("chosing vthresh and vtrim.....");
#endif
retval1=choose_vthresh_and_vtrim(countlim,nsigma, im);
#ifdef VERBOSE
printf("trimming with noise.....\n");
#endif
retval2=trim_with_level(countlim, im);
#ifdef DEBUGOUT
printf("done\n");
#endif
if (retval1==OK && retval2==OK)
retval=OK;
else
retval=FAIL;
return retval;
}
int trim_with_beam(int countlim, int nsigma, int im) //rpc
{
int retval=OK, retval1=OK, retval2=OK;
printf("Trimming using beam\n");
//return OK;
#ifdef VIRTUAL
printf("Trimming using beam\n");
return OK;
#endif
/* threshold scan */
#ifdef DEBUGOUT
printf("chosing vthresh and vtrim.....");
#endif
retval1=choose_vthresh_and_vtrim(countlim,nsigma,im);
retval2=trim_with_median(TRIM_DR, im);
#ifdef DEBUGOUT
printf("done\n");
#endif
if (retval1==OK && retval2==OK)
retval=OK;
else
retval=FAIL;
return retval;
}
int trim_improve(int maxit, int par2, int im) //rpc
{
int retval=OK, retval1=OK, retval2=OK;
#ifdef VERBOSE
printf("Improve the trimming\n");
#endif
#ifdef VIRTUAL
return OK;
#endif
if (par2!=0 && im==ALLMOD)
retval1=choose_vthresh();
retval2=trim_with_median(2*maxit+1, im);
#ifdef DEBUGOUT
printf("done\n");
#endif
if (retval1==OK && retval2==OK)
retval=OK;
else
retval=FAIL;
return retval;
}
int calcthr_from_vcal(int vcal) {
int thrmin;
//thrmin=140+3*vcal/5;
thrmin=180+3*vcal/5;
return thrmin;
}
int calccal_from_vthr(int vthr) {
int vcal;
vcal=5*(vthr-140)/3;
return vcal;
}
int choose_vthresh_and_vtrim(int countlim, int nsigma, int im) {
int retval=OK;
#ifdef MCB_FUNCS
int modma, modmi, nm;
int thr, thrstep=5, nthr=31;
int *fifodata;
double vthreshmean, vthreshSTDev;
int *thrmi, *thrma;
double c;
double b=BVTRIM;
double a=AVTRIM;
int *trim;
int ich, imod, ichan;
int nvalid=0;
u_int32_t *scan;
int ithr;
sls_detector_channel myChan;
setFrames(1);
// setNMod(getNModBoard());
if (im==ALLMOD){
modmi=0;
modma=nModX;
} else {
modmi=im;
modma=im+1;
}
nm=modma-modmi;
trim=malloc(sizeof(int)*nChans*nChips*nModX);
thrmi=malloc(sizeof(int)*nModX);
thrma=malloc(sizeof(int)*nModX);
for (ich=0; ich<nChans*nChips*nm; ich++)
trim[ich]=-1;
/*
setCSregister(im);
setSSregister(im);
initChannel(0,0,0,1,0,0,im);
counterClear(im);
clearSSregister(im);
usleep(500);
*/
myChan.chan=-1;
myChan.chip=-1;
myChan.module=ALLMOD;
myChan.reg=COMPARATOR_ENABLE;
initChannelbyNumber(myChan);
for (ithr=0; ithr<nthr; ithr++) {
fifoReset();
/* scanning threshold */
for (imod=modmi; imod<modma; imod++) {
//commented out by dhanya thr=getDACbyIndexDACU(VTHRESH,imod);
if (ithr==0) {
thrmi[imod]=thr;
//commented out by dhanya initDACbyIndexDACU(VTHRESH,thr,imod);
} else
;//commented out by dhanya initDACbyIndexDACU(VTHRESH,thr+thrstep,imod);
}
/* setCSregister(ALLMOD);
setSSregister(ALLMOD);
initChannel(0,0,0,1,0,0,im);
setDynamicRange(32);
*/
counterClear(ALLMOD);
clearSSregister(ALLMOD);
usleep(500);
startStateMachine();
while (runBusy()) {
}
usleep(500);
fifodata=fifo_read_event();
scan=decode_data(fifodata);
for (imod=modmi; imod<modma; imod++) {
for (ichan=0; ichan<nChans*nChips; ichan++){
ich=imod*nChips*nChans+ichan;
if (scan[ich]>countlim && trim[ich]==-1) {
//commented out by dhanya trim[ich]=getDACbyIndexDACU(VTHRESH,imod);
#ifdef VERBOSE
// printf("yes: %d %d %d\n",ich,ithr,scan[ich]);
#endif
}
#ifdef VERBOSE
/* else {
printf("no: %d %d %d\n",ich,ithr,scan[ich]);
}*/
#endif
}
}
free(scan);
}
for (imod=modmi; imod<modma; imod++) {
vthreshmean=0;
vthreshSTDev=0;
nvalid=0;
//commented out by dhanya thrma[imod]=getDACbyIndexDACU(VTHRESH,imod);
for (ichan=0; ichan<nChans*nChips; ichan++){
ich=imod*nChans*nChips+ichan;
if(trim[ich]>thrmi[imod] && trim[ich]<thrma[imod]) {
vthreshmean=vthreshmean+trim[ich];
vthreshSTDev=vthreshSTDev+trim[ich]*trim[ich];
nvalid++;
}
}
if (nvalid>0) {
vthreshmean=vthreshmean/nvalid;
//commented out by dhanya vthreshSTDev=sqrt((vthreshSTDev/nvalid)-vthreshmean*vthreshmean);
} else {
vthreshmean=thrmi[imod];
vthreshSTDev=nthr*thrstep;
printf("No valid channel for module %d\n",imod);
retval=FAIL;
}
#ifdef DEBUGOUT
printf("module= %d nvalid = %d mean=%f RMS=%f\n",imod, nvalid, vthreshmean,vthreshSTDev);
#endif
// *vthresh=round(vthreshmean-nsigma*vthreshSTDev);
thr=(int)(vthreshmean-nsigma*vthreshSTDev);
if (thr<0 || thr>(DAC_DR-1)) {
thr=thrmi[imod]/2;
printf("Can't find correct threshold for module %d\n",imod);
retval=FAIL;
}
//commented out by dhanya initDACbyIndexDACU(VTHRESH,thr,imod);
#ifdef VERBOSE
printf("vthresh=%d \n",thr);
#endif
c=CVTRIM-2.*nsigma*vthreshSTDev/63.;
//commented out by dhanya thr=(int)((-b-sqrt(b*b-4*a*c))/(2*a));
if (thr<500 || thr>(DAC_DR-1)) {
thr=750;
printf("Can't find correct trimbit size for module %d\n",imod);
retval=FAIL;
}
//commented out by dhanya initDACbyIndexDACU(VTRIM,thr,imod);
#ifdef VERBOSE
printf("vtrim=%d \n",thr);
#endif
}
free(trim);
free(thrmi);
free(thrma);
#endif
return retval;
}
int trim_with_level(int countlim, int im) {
int ich, itrim, ichan, ichip, imod;
u_int32_t *scan;
int *inttrim;
int modma, modmi, nm;
int retval=OK;
int *fifodata;
sls_detector_channel myChan;
printf("trimming module number %d", im);
#ifdef MCB_FUNCS
setFrames(1);
// setNMod(getNModBoard());
if (im==ALLMOD){
modmi=0;
modma=nModX;
} else {
modmi=im;
modma=im+1;
}
nm=modma-modmi;
inttrim=malloc(sizeof(int)*nChips*nChans*nModX);
printf("countlim=%d\n",countlim);
for (ich=0; ich<nChans*nChips*nModX; ich++)
inttrim[ich]=-1;
for (itrim=0; itrim<TRIM_DR+1; itrim++) {
fifoReset();
printf("Trimbit %d\n",itrim);
myChan.chan=-1;
myChan.chip=-1;
myChan.module=ALLMOD;
myChan.reg=COMPARATOR_ENABLE|(itrim<<TRIMBIT_OFF);
initChannelbyNumber(myChan);
/*
setCSregister(im);
setSSregister(im);
initChannel(itrim,0,0,1,0,0,ALLMOD);
setDynamicRange(32);
*/
setCSregister(ALLMOD);
setSSregister(ALLMOD);
counterClear(ALLMOD);
clearSSregister(ALLMOD);
usleep(500);
startStateMachine();
while (runBusy()) {
}
usleep(500);
fifodata=fifo_read_event();
scan=decode_data(fifodata);
for (imod=modmi; imod<modma; imod++) {
for (ichan=0; ichan<nChans*nChips; ichan++) {
ich=ichan+imod*nChans*nChips;
if (inttrim[ich]==-1) {
if (scan[ich]>countlim){
inttrim[ich]=itrim;
if (scan[ich]>2*countlim && itrim>0) {
//if (scan[ich]>2*countlim || itrim==0) {
inttrim[ich]=itrim-1;
}
#ifdef VERBOSE
printf("Channel %d trimbit %d counted %d (%08x) countlim %d\n",ich,itrim,scan[ich],fifodata[ich],countlim);
#endif
}
}
#ifdef VERBOSE
/* else
printf("Channel %d trimbit %d counted %d countlim %d\n",ich,itrim,scan[ich],countlim);*/
#endif
}
}
free(scan);
}
for (imod=modmi; imod<modma; imod++) {
clearCSregister(imod);
firstChip(im);
for (ichip=0; ichip<nChips; ichip++) {
clearSSregister(imod);
for (ichan=0; ichan<nChans; ichan++) {
nextStrip(imod);
ich=ichan+imod*nChans*nChips+ichip*nChans;
if (*(inttrim+ich)==-1) {
*(inttrim+ich)=TRIM_DR;
// printf("could not trim channel %d chip %d module %d - set to %d\n", ichan, ichip, imod, *(inttrim+ich) );
retval=FAIL;
}
#ifdef VERBOSE
// else
// printf("channel %d trimbit %d\n",ich,*(inttrim+ich) );
#endif
initChannel(inttrim[ich],0,0,1,0,0,imod);
}
nextChip(imod);
}
}
free(inttrim);
#endif
return retval;
}
#define ELEM_SWAP(a,b) { register int t=(a);(a)=(b);(b)=t; }
#define median(a,n) kth_smallest(a,n,(((n)&1)?((n)/2):(((n)/2)-1)))
int kth_smallest(int *a, int n, int k)
{
register int i,j,l,m ;
register double x ;
l=0 ; m=n-1 ;
while (l<m) {
x=a[k] ;
i=l ;
j=m ;
do {
while (a[i]<x) i++ ;
while (x<a[j]) j-- ;
if (i<=j) {
ELEM_SWAP(a[i],a[j]) ;
i++ ; j-- ;
}
} while (i<=j) ;
if (j<k) l=i ;
if (k<i) m=j ;
}
return a[k] ;
}
int ave(int *a, int n)
{
int av=0,i;
for (i=0; i<n; i++)
av=av+((double)*(a+i))/((double)n);
return av;
}
int choose_vthresh() {
int retval=OK;
#ifdef MCB_FUNCS
int imod, ichan;
u_int32_t *scan, *scan1;
int olddiff[nModX], direction[nModX];
int med[nModX], med1[nModX], diff, media;
int change_flag=1;
int iteration=0;
int maxiterations=10;
int vthreshmean=0;
int vthresh;
int im=ALLMOD;
int modma, modmi, nm;
int *fifodata;
setFrames(1);
// setNMod(getNModBoard());
if (im==ALLMOD){
modmi=0;
modma=nModX;
} else {
modmi=im;
modma=im+1;
}
nm=modma-modmi;
setDynamicRange(32);
setCSregister(ALLMOD);
setSSregister(ALLMOD);
counterClear(ALLMOD);
clearSSregister(ALLMOD);
usleep(500);
startStateMachine();
while (runBusy()) {
//printf(".");
}
usleep(500);
fifodata=fifo_read_event();
scan=decode_data(fifodata);
//
scan1=decode_data(fifodata);
for (imod=modmi; imod<modma; imod++) {
//
med[imod]=median(scan1+imod*nChans*nChips,nChans*nChips);
med1[imod]=med[imod];
//commented out by dhanya vthreshmean=vthreshmean+getDACbyIndexDACU(VTHRESH,imod);
olddiff[imod]=0xffffff;
direction[imod]=0;
printf("Median of module %d=%d\n",imod,med[imod]);
}
vthreshmean=vthreshmean/nm;
//media=median(scan,nChans*nChips*nModX);
//printf("Median overall=%d\n",media);
media=median(med1+modmi,nm);
printf("Median of modules=%d\n",media);
free(scan);
free(scan1);
while(change_flag && iteration<maxiterations) {
setDynamicRange(32);
fifoReset();
setCSregister(ALLMOD);
setSSregister(ALLMOD);
counterClear(ALLMOD);
clearSSregister(ALLMOD);
usleep(500);
startStateMachine();
while (runBusy()) {
}
usleep(500);
fifodata=fifo_read_event();
scan=decode_data(fifodata);
//
scan1=decode_data(fifodata);
change_flag=0;
printf("Vthresh iteration %3d 0f %3d\n",iteration, maxiterations);
for (ichan=modmi; ichan<modma; ichan++) {
med[ichan]=median(scan1+ichan*nChans*nChips,nChans*nChips);
med1[imod]=med[imod];
media=median(med1+modmi,nm);
diff=med[ichan]-media;
if (direction[ichan]==0) {
if (diff>0)
direction[ichan]=1;
else
direction[ichan]=-1;
}
//commented out by dhanya vthresh=getDACbyIndexDACU(VTHRESH,imod);
if ( direction[ichan]!=-3) {
if (abs(diff)>abs(olddiff[ichan])) {
vthresh=vthresh-direction[ichan];
if (vthresh>(DAC_DR-1)) {
vthresh=(DAC_DR-1);
printf("can't equalize threshold for module %d\n", ichan);
retval=FAIL;
}
if (vthresh<0) {
vthresh=0;
printf("can't equalize threshold for module %d\n", ichan);
retval=FAIL;
}
direction[ichan]=-3;
} else {
vthresh=vthresh+direction[ichan];
olddiff[ichan]=diff;
change_flag=1;
}
//commented out by dhanya initDACbyIndex(VTHRESH,vthresh, ichan);
}
}
iteration++;
free(scan);
free(scan1);
}
#endif
return retval;
}
int trim_with_median(int stop, int im) {
int retval=OK;
#ifdef MCB_FUNCS
int ichan, imod, ichip, ich;
u_int32_t *scan, *scan1;
int *olddiff, *direction;
int med, diff;
int change_flag=1;
int iteration=0;
int me[nModX], me1[nModX];
int modma, modmi, nm;
int trim;
int *fifodata;
setFrames(1);
// setNMod(getNModBoard());
if (im==ALLMOD){
modmi=0;
modma=nModX;
} else {
modmi=im;
modma=im+1;
}
nm=modma-modmi;
olddiff=malloc(4*nModX*nChips*nChans);
direction=malloc(4*nModX*nChips*nChans);
for (imod=modmi; imod<modma; imod++) {
for (ichip=0; ichip<nChips; ichip++) {
for (ich=0; ich<nChans; ich++) {
ichan=imod*nChips*nChans+ichip*nChans+ich;
direction[ichan]=0;
olddiff[ichan]=0x0fffffff;
}
}
}
/********
fifoReset();
setCSregister(ALLMOD);
setSSregister(ALLMOD);
counterClear(ALLMOD);
clearSSregister(ALLMOD);
usleep(500);
startStateMachine();
while (runBusy()) {
}
usleep(500);
scan=decode_data(fifo_read_event());
for (imod=modmi; imod<modma; imod++) {
me[imod]=median(scan+imod*nChans*nChips,nChans*nChips);
printf("Median of module %d=%d\n",imod,me[imod]);
}
med=median(me,nm);
printf("median is %d\n",med);
free(scan);
**************/
while(change_flag && iteration<stop) {
setDynamicRange(32);
fifoReset();
setCSregister(ALLMOD);
setSSregister(ALLMOD);
counterClear(ALLMOD);
clearSSregister(ALLMOD);
usleep(500);
startStateMachine();
while (runBusy()) {
}
usleep(500);
fifodata=fifo_read_event();
scan=decode_data(fifodata);
scan1=decode_data(fifodata);
/********* calculates median every time ***********/
for (imod=modmi; imod<modma; imod++) {
me[imod]=median(scan1+imod*nChans*nChips,nChans*nChips);
me1[imod]=me[imod];
printf("Median of module %d=%d\n",imod,me[imod]);
}
med=median(me1,nm);
printf("median is %d\n",med);
change_flag=0;
printf("Trimbits iteration %d of %d\n",iteration, stop);
for (imod=modmi; imod<modma; imod++) {
for (ichip=0; ichip<nChips; ichip++) {
selChip(ichip,imod);
clearSSregister(imod);
for (ich=0; ich<nChans; ich++) {
ichan=imod*nChips*nChans+ichip*nChans+ich;
nextStrip(imod);
diff=scan[ichan]-me[imod];
if (direction[ichan]==0) {
if (diff>0) {
direction[ichan]=1;
} else {
direction[ichan]=-1;
}
}
if ( direction[ichan]!=-3) {
if (abs(diff)>abs(olddiff[ichan])) {
trim=getTrimbit(imod,ichip,ich)+direction[ichan];
printf("%d old diff %d < new diff %d %d - trimbit %d\n",ichan, olddiff[ichan], diff, direction[ichan], trim);
direction[ichan]=-3;
} else {
trim=getTrimbit(imod,ichip,ich)-direction[ichan];
olddiff[ichan]=diff;
change_flag=1;
}
if (trim>TRIM_DR) {
trim=63;
printf("can't trim channel %d chip %d module %d to trim %d\n",ich, ichip, imod, trim);
retval=FAIL;
}
if (trim<0) {
printf("can't trim channel %d chip %d module %d to trim %d\n",ich, ichip, imod, trim);
trim=0;
retval=FAIL;
}
initChannel(trim,0,0,1,0,0,imod);
}
}
}
}
iteration++;
free(scan);
free(scan1);
}
free(olddiff);
free(direction);
#endif
return retval;
}

View File

@ -0,0 +1,20 @@
#ifndef TRIMMING_FUNCS_H
#define TRIMMING_FUNCS_H
#include "sls_detector_defs.h"
int trim_fixed_settings(int countlim, int par2, int imod);
int trim_with_noise(int countlim, int nsigma, int imod);
int trim_with_beam(int countlim, int nsigma, int imod);
int trim_improve(int maxit, int par2, int imod);
int calcthr_from_vcal(int vcal);
int calccal_from_vthr(int vthr);
int choose_vthresh_and_vtrim(int countlim, int nsigma, int imod);
int choose_vthresh();
int trim_with_level(int countlim, int imod);
int trim_with_median(int stop, int imod);
int calcthr_from_vcal(int vcal);
int calccal_from_vthr(int vthr);
#endif

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/moenchDetectorServer
URL: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/moenchDetectorServer
Repository Root: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git
Repsitory UUID: c31619c88e5690230fcd389dc18f9139295c442c
Revision: 58
Repsitory UUID: ce7cd6255b7b3abf1c046e9703ae8288ec55135a
Revision: 62
Branch: master
Last Changed Author: Maliakal_Dhanya
Last Changed Rev: 280
Last Changed Date: 2014-09-09 15:43:18 +0200
Last Changed Rev: 282
Last Changed Date: 2014-10-16 13:49:56 +0200

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURL "git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/moenchDetectorServer"
//#define SVNREPPATH ""
#define SVNREPUUID "c31619c88e5690230fcd389dc18f9139295c442c"
//#define SVNREV 0x280
#define SVNREPUUID "ce7cd6255b7b3abf1c046e9703ae8288ec55135a"
//#define SVNREV 0x282
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTH "Maliakal_Dhanya"
#define SVNREV 0x280
#define SVNDATE 0x20140909
#define SVNREV 0x282
#define SVNDATE 0x20141016
//

View File

@ -2629,7 +2629,7 @@ int update_client(int file_des) {
int configure_mac(int file_des) {
int ret=OK;
char arg[5][50];
char arg[6][50];
int n;
int imod=0;//should be in future sent from client as -1, arg[2]
@ -2654,7 +2654,7 @@ int configure_mac(int file_des) {
sscanf(arg[2], "%x", &udpport);
sscanf(arg[3], "%llx", &idetectormacadd);
sscanf(arg[4], "%x", &detipad);
//arg[5] is for eiger
#ifdef VERBOSE
int i;
printf("\ndigital_test_bit in server %d\t",digitalTestBit);

View File

@ -351,56 +351,71 @@ int multiSlsDetector::addSlsDetector(int id, int pos) {
void multiSlsDetector::updateOffsets(){
int offsetX=0,offsetY=0,numX,numY;
int maxChanX = thisMultiDetector->maxNumberOfChannelsPerDetector[X];
int maxChanY = thisMultiDetector->maxNumberOfChannelsPerDetector[Y];
cout << "Updating multi detector offsets" << endl;
thisMultiDetector->numberOfChannel[X] = 0;
thisMultiDetector->maxNumberOfChannel[X] = 0;
thisMultiDetector->numberOfChannel[Y] = 0;
thisMultiDetector->maxNumberOfChannel[Y] = 0;
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (detectors[i]) {
thisMultiDetector->offsetX[i] = offsetX;
thisMultiDetector->offsetY[i] = offsetY;
cout << endl << "Updating multi detector offsets" << endl;
cout << "Detector at position: " << i << " x offset:" << offsetX << " y offset:" << offsetY << endl;
int offsetX=0, offsetY=0, numX=0, numY=0, maxX=0, maxY=0;
int maxChanX = thisMultiDetector->maxNumberOfChannelsPerDetector[X];
int maxChanY = thisMultiDetector->maxNumberOfChannelsPerDetector[Y];
thisMultiDetector->numberOfChannel[X] = 0;
thisMultiDetector->maxNumberOfChannel[X] = 0;
thisMultiDetector->numberOfChannel[Y] = 0;
thisMultiDetector->maxNumberOfChannel[Y] = 0;
numX = detectors[i]->getMaxNumberOfChannels(X);
numY = detectors[i]->getMaxNumberOfChannels(Y);
//0th position
if (detectors[0]){
offsetX = thisMultiDetector->offsetX[0] = 0;
offsetY = thisMultiDetector->offsetY[0] = 0;
numX = thisMultiDetector->numberOfChannel[X] = detectors[0]->getTotalNumberOfChannels(X);
numY = thisMultiDetector->numberOfChannel[Y] = detectors[0]->getTotalNumberOfChannels(Y);
maxX = thisMultiDetector->maxNumberOfChannel[X] = detectors[0]->getMaxNumberOfChannels(X);
maxY = thisMultiDetector->maxNumberOfChannel[Y] = detectors[0]->getMaxNumberOfChannels(Y);
offsetX += numX;
if ((maxChanX == -1) || ((maxChanX > 0) && (offsetX < maxChanX))){
thisMultiDetector->numberOfChannel[X] += detectors[i]->getTotalNumberOfChannels(X);
thisMultiDetector->maxNumberOfChannel[X] += numX;
//the first time y should be added but offset not increased
if (thisMultiDetector->numberOfChannel[Y] == 0){
if ((maxChanY == -1) || ((maxChanY > 0) && (numY < maxChanY))){
thisMultiDetector->numberOfChannel[Y] += detectors[i]->getTotalNumberOfChannels(Y);
thisMultiDetector->maxNumberOfChannel[Y] += numY;
}else{
cout<<"Detector at position " << i << "exceeds maximum channels allowed for complete detector set in y dimension also!" << endl;
thisMultiDetector->numberOfChannel[Y] += detectors[i]->getTotalNumberOfChannels(Y);
thisMultiDetector->maxNumberOfChannel[Y] += numY;
}
}
}else{
offsetX = 0;
thisMultiDetector->numberOfChannel[X] = 0;
thisMultiDetector->maxNumberOfChannel[X] = 0;
offsetY += numY;
if ((maxChanY == -1) || ((maxChanY > 0) && (offsetY < maxChanY))){
thisMultiDetector->numberOfChannel[Y] += detectors[i]->getTotalNumberOfChannels(Y);
thisMultiDetector->maxNumberOfChannel[Y] += numY;
}else{
cout<<"Detector at position " << i << "exceeds maximum channels allowed for complete detector set in y dimension also!" << endl;
thisMultiDetector->numberOfChannel[Y] += detectors[i]->getTotalNumberOfChannels(Y);
thisMultiDetector->maxNumberOfChannel[Y] += numY;
}
}
}
}
cout << "Detector at position 0: x offset:" << offsetX << " y offset:" << offsetY << endl;
}
for (int i=1; i<thisMultiDetector->numberOfDetectors; i++) {
if (detectors[i]) {
//incrementing in x direction
if ((maxChanX == -1) || ((maxChanX > 0) && ((offsetX + numX) < maxChanX))){
offsetX += detectors[i]->getMaxNumberOfChannels(X);
maxX += detectors[i]->getMaxNumberOfChannels(X);
numX += detectors[i]->getTotalNumberOfChannels(X);
}
//incrementing in y direction
else{
offsetX = 0;
numX = 0;
maxX = 0;
thisMultiDetector->maxNumberOfChannel[X] = 0;
offsetY += detectors[i]->getMaxNumberOfChannels(Y);
if ((maxChanY == -1) || ((maxChanY > 0) && (offsetY <= maxChanY))){
numY += detectors[i]->getTotalNumberOfChannels(Y);
maxY += detectors[i]->getMaxNumberOfChannels(Y);
}else{
cout<<"Detector at position " << i << "exceeds maximum channels allowed for complete detector set in y dimension also!" << endl;
numY += detectors[i]->getTotalNumberOfChannels(Y);
maxY += detectors[i]->getMaxNumberOfChannels(Y);
}
}
thisMultiDetector->offsetX[i] = offsetX;
thisMultiDetector->offsetY[i] = offsetY;
cout << "Detector at position: " << i << " x offset:" << thisMultiDetector->offsetX[i] << " y offset:" << thisMultiDetector->offsetY[i] << endl;
if(numX > thisMultiDetector->numberOfChannel[X])
thisMultiDetector->numberOfChannel[X] = numX;
if(numY > thisMultiDetector->numberOfChannel[Y])
thisMultiDetector->numberOfChannel[Y] = numY;
if(maxX > thisMultiDetector->maxNumberOfChannel[X])
thisMultiDetector->maxNumberOfChannel[X] = maxX;
if(maxY > thisMultiDetector->maxNumberOfChannel[Y])
thisMultiDetector->maxNumberOfChannel[Y] = maxY;
}
}
cout << "Number of Channels in X direction:" << thisMultiDetector->numberOfChannel[X] << endl;
cout << "Number of Channels in Y direction:" << thisMultiDetector->numberOfChannel[Y] << endl << endl;
}
string multiSlsDetector::setHostname(const char* name, int pos){
@ -1182,6 +1197,7 @@ int multiSlsDetector::startAcquisition(){
int i=0;
int ret=OK, ret1=OK;
for (i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (i!=thisMultiDetector->masterPosition)
if (detectors[i]) {
@ -1213,6 +1229,8 @@ int multiSlsDetector::stopAcquisition(){
int i=0;
int ret=OK, ret1=OK;
i=thisMultiDetector->masterPosition;
if (thisMultiDetector->masterPosition>=0) {
@ -1447,7 +1465,7 @@ int* multiSlsDetector::startAndReadAll(){
if (detectors[id]) {
detectors[id]->disconnectControl();
}
}
}
}
@ -1488,6 +1506,7 @@ int multiSlsDetector::startAndReadAllNoWait(){
ret1=FAIL;
}
}
return ret1;
}
@ -1509,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++) {
for (int i=0; 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;
@ -3474,11 +3489,13 @@ int multiSlsDetector::getMaxMods() {
int multiSlsDetector::getTotalNumberOfChannels(){thisMultiDetector->numberOfChannels=0; for (int id=0; id< thisMultiDetector->numberOfDetectors; id++) thisMultiDetector->numberOfChannels+=detectors[id]->getTotalNumberOfChannels(); return thisMultiDetector->numberOfChannels;};
int multiSlsDetector::getTotalNumberOfChannels(dimension d){thisMultiDetector->numberOfChannel[d]=0; for (int id=0; id< thisMultiDetector->numberOfDetectors; id++) thisMultiDetector->numberOfChannel[d]+=detectors[id]->getTotalNumberOfChannels(d); return thisMultiDetector->numberOfChannel[d];};
//int multiSlsDetector::getTotalNumberOfChannels(dimension d){thisMultiDetector->numberOfChannel[d]=0; for (int id=0; id< thisMultiDetector->numberOfDetectors; id++) thisMultiDetector->numberOfChannel[d]+=detectors[id]->getTotalNumberOfChannels(d); return thisMultiDetector->numberOfChannel[d];};
int multiSlsDetector::getTotalNumberOfChannels(dimension d){updateOffsets();return thisMultiDetector->numberOfChannel[d];};
int multiSlsDetector::getMaxNumberOfChannels(){thisMultiDetector->maxNumberOfChannels=0; for (int id=0; id< thisMultiDetector->numberOfDetectors; id++) thisMultiDetector->maxNumberOfChannels+=detectors[id]->getMaxNumberOfChannels();return thisMultiDetector->maxNumberOfChannels;};
int multiSlsDetector::getMaxNumberOfChannels(dimension d){thisMultiDetector->maxNumberOfChannel[d]=0; for (int id=0; id< thisMultiDetector->numberOfDetectors; id++) thisMultiDetector->maxNumberOfChannel[d]+=detectors[id]->getMaxNumberOfChannels(d);return thisMultiDetector->maxNumberOfChannel[d];};
// int multiSlsDetector::getMaxNumberOfChannels(dimension d){thisMultiDetector->maxNumberOfChannel[d]=0; for (int id=0; id< thisMultiDetector->numberOfDetectors; id++) thisMultiDetector->maxNumberOfChannel[d]+=detectors[id]->getMaxNumberOfChannels(d);return thisMultiDetector->maxNumberOfChannel[d];};
int multiSlsDetector::getMaxNumberOfChannels(dimension d){updateOffsets();return thisMultiDetector->maxNumberOfChannel[d];};
@ -4814,3 +4831,126 @@ int multiSlsDetector::enableTenGigabitEthernet(int i){
}
return ret;
}
/** opens pattern file and sends pattern to CTB
@param fname pattern file to open
@returns OK/FAIL
*/
int multiSlsDetector::setCTBPattern(string fname) {
}
/** Writes a pattern word to the CTB
@param addr address of the word, -1 is I/O control register, -2 is clk control register
@param word 64bit word to be written, -1 gets
@returns actual value
*/
uint64_t multiSlsDetector::setCTBWord(int addr,uint64_t word) {
uint64_t ret=-100,ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++)
if (detectors[idet]){
ret1=detectors[idet]->setCTBWord(addr, word);
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
if(ret==-100)
ret=ret1;
else if (ret!=ret1)
ret=-1;
}
return ret;
}
/** Sets the pattern or loop limits in the CTB
@param level -1 complete pattern, 0,1,2, loop level
@param start start address if >=0
@param stop stop address if >=0
@param n number of loops (if level >=0)
@returns OK/FAIL
*/
int multiSlsDetector::setCTBPatLoops(int level,int &start, int &stop, int &n) {
int ret=-100,ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++)
if (detectors[idet]){
ret1=detectors[idet]->setCTBPatLoops(level, start, stop, n);
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
if(ret==-100)
ret=ret1;
else if (ret!=ret1)
ret=-1;
}
return ret;
}
/** Sets the wait address in the CTB
@param level 0,1,2, wait level
@param addr wait address, -1 gets
@returns actual value
*/
int multiSlsDetector::setCTBPatWaitAddr(int level, int addr) {
int ret=-100,ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++)
if (detectors[idet]){
ret1=detectors[idet]->setCTBPatWaitAddr(level, addr);
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
if(ret==-100)
ret=ret1;
else if (ret!=ret1)
ret=-1;
}
return ret;
}
/** Sets the wait time in the CTB
@param level 0,1,2, wait level
@param t wait time, -1 gets
@returns actual value
*/
int multiSlsDetector::setCTBPatWaitTime(int level, uint64_t t) {
int ret=-100,ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++)
if (detectors[idet]){
ret1=detectors[idet]->setCTBPatWaitTime(level,t);
if(detectors[idet]->getErrorMask())
setErrorMask(getErrorMask()|(1<<idet));
if(ret==-100)
ret=ret1;
else if (ret!=ret1)
ret=-1;
}
return ret;
}

View File

@ -1240,6 +1240,59 @@ class multiSlsDetector : public slsDetectorUtils {
/******** CTB funcs */
/** opens pattern file and sends pattern to CTB
@param fname pattern file to open
@returns OK/FAIL
*/
int setCTBPattern(string fname);
/** Writes a pattern word to the CTB
@param addr address of the word, -1 is I/O control register, -2 is clk control register
@param word 64bit word to be written, -1 gets
@returns actual value
*/
uint64_t setCTBWord(int addr,uint64_t word=-1);
/** Sets the pattern or loop limits in the CTB
@param level -1 complete pattern, 0,1,2, loop level
@param start start address if >=0
@param stop stop address if >=0
@param n number of loops (if level >=0)
@returns OK/FAIL
*/
int setCTBPatLoops(int level,int &start, int &stop, int &n);
/** Sets the wait address in the CTB
@param level 0,1,2, wait level
@param addr wait address, -1 gets
@returns actual value
*/
int setCTBPatWaitAddr(int level, int addr=-1);
/** Sets the wait time in the CTB
@param level 0,1,2, wait level
@param t wait time, -1 gets
@returns actual value
*/
int setCTBPatWaitTime(int level, uint64_t t=-1);
protected:

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/mythenDetectorServer
URL: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/mythenDetectorServer
Repository Root: origin git@gitorious.psi.ch:sls_det_software/sls_detector_software.git
Repsitory UUID: c31619c88e5690230fcd389dc18f9139295c442c
Revision: 90
Repsitory UUID: ce7cd6255b7b3abf1c046e9703ae8288ec55135a
Revision: 91
Branch: master
Last Changed Author: Maliakal_Dhanya
Last Changed Rev: 280
Last Changed Date: 2014-09-09 15:43:18 +0200
Last Changed Rev: 282
Last Changed Date: 2014-10-16 13:49:56 +0200

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURL "git@gitorious.psi.ch:sls_det_software/sls_detector_software.git/mythenDetectorServer"
//#define SVNREPPATH ""
#define SVNREPUUID "c31619c88e5690230fcd389dc18f9139295c442c"
//#define SVNREV 0x280
#define SVNREPUUID "ce7cd6255b7b3abf1c046e9703ae8288ec55135a"
//#define SVNREV 0x282
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTH "Maliakal_Dhanya"
#define SVNREV 0x280
#define SVNDATE 0x20140909
#define SVNREV 0x282
#define SVNDATE 0x20141016
//

View File

@ -0,0 +1,20 @@
if [ "$#" -eq 0 ]; then
echo "Wrong number of arguments: usage should be $0 patname"
exit 1
fi
infile=$1
outfile=$infile"at"
if [ "$#" -ge 2 ]; then
outfile=$2
fi
exe=$infile"exe"
if [ "$#" -ge 3 ]; then
exe=$3
fi
if [ -f "$infile" ]
then
gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -o $exe generator.c ; ./$exe ; rm $exe
else
echo "$infile not found."
fi

View File

@ -0,0 +1,160 @@
/****************************************************************************
usage to generate a patter test.pat from test.p
gcc -DINFILE="\"test.p\"" -DOUTFILE="\"test.pat\"" -o test.exe generator.c ; ./test.exe ; rm test.exe
*************************************************************************/
#include <stdlib.h> /* exit() */
#include <stdint.h> /* exit() */
#include <string.h> /* memset(), memcpy() */
#include <sys/utsname.h> /* uname() */
#include <sys/types.h>
#include <unistd.h> /* fork(), write(), close() */
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <math.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
//#include <asm/page.h>
#define MAXLOOPS 3
#define MAXTIMERS 3
#define MAXWORDS 1024
uint64_t pat=0;
uint64_t iopat=0;
uint64_t clkpat=0;
int iaddr=0;
int waitaddr[3]={-1,-1,-1};
int startloopaddr[3]={-1,-1,-1};
int stoploopaddr[3]={-1,-1,-1};
int start=0, stop=0;
uint64_t waittime[3]={0,0,0};
int nloop[3]={0,0,0};
char infile[10000], outfile[10000];
FILE *fd;
int i,ii,iii,j,jj,jjj,pixx,pixy,memx,memy,muxout,memclk,colclk,rowclk,muxclk,memcol,memrow,loopcounter;
//int W[33];
//u_int32_t W;
void setstart() {
start=iaddr;
}
void setstop() {
stop=iaddr;
}
void setinput(int bit) {
uint64_t mask=1;
mask=mask<<bit;
iopat &= ~mask;
}
void setoutput(int bit) {
uint64_t mask=1;
mask=mask<<bit;
iopat |= mask;
}
void setclk(int bit) {
uint64_t mask=1;
mask=mask<<bit;
iopat |= mask;
clkpat |= mask;
}
void clearbit(int bit){
uint64_t mask=1;
mask=mask<<bit;
// printf("CB %d %016llx %016llx ",bit, pat, mask);
pat &= ~mask;
// printf("%016llx\n", pat);
}
void setbit(int bit){
uint64_t mask=1;
mask=mask<<bit;
// printf("SB %d %016llx %016llx ",bit, pat, mask);
pat |= mask;
// printf("%016llx\n", pat);
}
int checkbit(int bit) {
uint64_t mask=1;
mask=mask<<bit;
return (pat & mask ) >>bit;
}
void setstartloop(int iloop) {
if (iloop>=0 && iloop<MAXLOOPS)
startloopaddr[iloop]=iaddr;
}
void setstoploop(int iloop) {
if (iloop>=0 && iloop<MAXLOOPS)
stoploopaddr[iloop]=iaddr;
}
void setnloop(int iloop, int n) {
if (iloop>=0 && iloop<MAXLOOPS)
nloop[iloop]=n;
}
void setwaitpoint(int iloop) {
if (iloop>=0 && iloop<MAXTIMERS)
waitaddr[iloop]=iaddr;
}
void setwaittime(int iloop, uint64_t t) {
if (iloop>=0 && iloop<MAXTIMERS)
waittime[iloop]=t;
}
void pw(){
fprintf(fd,"patword %04x %016llx\n",iaddr, pat);
iaddr++;
if (iaddr>=MAXWORDS) printf("ERROR: too many word in the pattern (%d instead of %d)!",iaddr, MAXWORDS);
}
main(void) {
int iloop=0;
fd=fopen(OUTFILE,"w");
#include INFILE
fprintf(fd,"patctrl %016llx\n",iopat);
fprintf(fd,"patclkctrl %016llx\n",clkpat);
fprintf(fd,"patlimits %04x %04x\n",start, stop);
for (iloop=0; iloop<MAXLOOPS; iloop++) {
fprintf(fd,"patloop%d %04x %04x\n",iloop, startloopaddr[iloop], stoploopaddr[iloop]);
if ( startloopaddr[iloop]<0 || stoploopaddr[iloop]<= startloopaddr[iloop]) nloop[iloop]=0;
fprintf(fd,"patnloop%d %d\n",iloop, nloop[iloop]);
}
for (iloop=0; iloop<MAXTIMERS; iloop++) {
fprintf(fd,"patwait%d %04x\n",iloop, waitaddr[iloop]);
if (waitaddr[iloop]<0) waittime[iloop]=0;
fprintf(fd,"patwaittime%d %lld\n",iloop, waittime[iloop]);
}
close((int)fd);
}

View File

@ -0,0 +1,197 @@
//define signals and directions (Input, outputs, clocks)
#define compTestIN 1
setoutput(compTestIN);
#define curON 32
setoutput(curON);
#define side_clk 2
setclk(side_clk);
#define side_din 3
setoutput(side_din);
#define clear_shr 4
setoutput(clear_shr);
#define bottom_din 5
setoutput(bottom_din);
#define bottom_clk 6
setclk(bottom_clk);
#define gHG 7
setoutput(gHG);
#define bypassCDS 31
setoutput(bypassCDS);
#define ENprechPRE 8
setoutput(ENprechPRE);
#define res 9
setoutput(res);
#define pulseOFF 30
setoutput(pulseOFF);
#define connCDS 27
setoutput(connCDS);
#define Dsg_1 24
setoutput(Dsg_1);
#define Dsg_2 25
setoutput(Dsg_2);
#define Dsg_3 23
setoutput(Dsg_3);
#define sto0 10
setoutput(sto0);
#define sto1 11
setoutput(sto1);
#define sto2 12
setoutput(sto2);
#define resCDS 13
setoutput(resCDS);
#define prechargeConnect 14
setoutput(prechargeConnect);
#define pulse 15
setoutput(pulse);
#define PCT_mode 21
setoutput(PCT_mode);
#define res_DGS 16
setoutput(res_DGS);
#define adc_ena 17
setoutput(adc_ena);
#define CLKBIT 18
setclk(CLKBIT);
#define adc_sync 19
setoutput(adc_sync);
#define PW pw()
#define SB(x) setbit(x)
#define CB(x) clearbit(x)
#define CLOCK clearbit(CLKBIT); pw();setbit(CLKBIT);pw()
#define LCLOCK clearbit(CLKBIT); pw();setbit(CLKBIT);pw();clearbit(CLKBIT); pw()
#define CLOCKS(x) for (i=0;i<x;i++) {clearbit(CLKBIT);pw(); setbit(CLKBIT); pw();}
#define STOP setstop();
#define START setstart();
#define REPEAT(x) for (i=0;i<(x);i++) {pw();}
#define DOFOR(x) for (j=0;j<(x);j++) {
// }
#define STARTUP1 CB(compTestIN);SB(clear_shr);CB(side_clk);CB(side_din);CB(bottom_din);CB(bottom_clk);
#define STARTUP2 CB(pulse);SB(PCT_mode);SB(pulseOFF);CB(curON);
#define STARTUP3 SB(res);SB(gHG);SB(ENprechPRE);
#define STARTUP4 SB(bypassCDS); CB(connCDS);CB(sto0);SB(sto1);SB(sto2);
#define STARTUP5 SB(resCDS);CB(Dsg_1);CB(Dsg_2);SB(Dsg_3);CB(prechargeConnect);SB(res_DGS);
#define STARTUP STARTUP1 STARTUP2 STARTUP3 STARTUP4 STARTUP5 PW;
//****NOTES****//
//FUNCTIONS
//Declare functions at the beginning
void load_pix(int nx, int ny)
{//SELECT PIXEL 1,1 for readout
SB(clear_shr);PW;PW;
CB(clear_shr);PW;PW;PW;PW;
SB(side_din);PW;
SB(side_clk);PW;
CB(side_din);
setstartloop(0); //loop on the rows
SB(side_clk);PW;
setstoploop(0); //finish loop on the rows
setnloop(0,ny); //set number row selected -can be changed dynamically
CB(side_clk);PW;
SB(bottom_din);PW;
SB(bottom_clk);PW;
CB(bottom_din);
setstartloop(1); //loop on the columns
SB(bottom_clk);PW;
setstoploop(1); //loop on the columns
setnloop(1,ny); //set number columns selected -can be changed dynamically
}
void load_col(void)
{//SELECT COLUMN 1 for readout
SB(clear_shr);PW;PW;
CB(clear_shr);PW;PW;PW;PW;
SB(bottom_din);PW;
SB(bottom_clk);PW;
CB(bottom_clk);PW;
CB(bottom_din);PW;
}
//END of FUNCTIONS
////////////////////////////////////////////////////////
//LET'S BYPASS PREAMP AND CDS and write on preamp out.//
//THIS ALLOWS CHECKING SOURCE FOLLOWERS //
////////////////////////////////////////////////////////
PW;
SB(5); PW;
CB(5); PW;
START; //pattern starts from here
STARTUP;
setwaitpoint(0); //set wait points
PW;
setwaittime(0,20); //wait time - can be changed dynamically
SB(adc_ena);PW;
SB(adc_sync);
CB(gHG);
setwaitpoint(1); //set wait points
setwaittime(1,16); //wait time - can be changed dynamically
CB(adc_sync);PW;
//NB: We have to SELECT A PIXEL to enable column out.
//SELECT PIXEL 1,1 for readout
load_pix(10, 20);
CB(res);
//CB(Dsg_3);PW;
CB(res_DGS);
setwaitpoint(2); //set wait points
setwaittime(2,1000); //wait time - can be changed dynamically
//SB(res_DGS);
//PW;
//SB(Dsg_3);
//
//CB(connCDS);
//TEST SIGNALS END
//
REPEAT(20)
//****************//
//*FINAL COMMANDS*//
//****************//
CB(adc_ena);PW;
//STARTUP;
STOP; PW; //stops here
//REPEAT(4);

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURLLIB "git@gitorious.psi.ch:sls_det_software/sls_detector_software.git"
//#define SVNREPPATH ""
#define SVNREPUUIDLIB "c31619c88e5690230fcd389dc18f9139295c442c"
//#define SVNREV 0x852
#define SVNREPUUIDLIB "ce7cd6255b7b3abf1c046e9703ae8288ec55135a"
//#define SVNREV 0x865
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTHLIB "Maliakal_Dhanya"
#define SVNREVLIB 0x852
#define SVNDATELIB 0x20140909
#define SVNREVLIB 0x865
#define SVNDATELIB 0x20141016
//

View File

@ -488,6 +488,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
thisDetector->receiverTCPPort=DEFAULT_PORTNO+2;
/** set receiver udp port */
thisDetector->receiverUDPPort=DEFAULT_UDP_PORTNO;
/** set receiver udp port for Eiger */
thisDetector->receiverUDPPort2=DEFAULT_UDP_PORTNO+1;
/** set receiver ip address/hostname */
strcpy(thisDetector->receiver_hostname,"none");
/** set receiver udp ip address */
@ -4838,6 +4840,15 @@ char* slsDetector::setNetworkParameter(networkParameter index, string value) {
sscanf(value.c_str(),"%d",&i);
setReceiverUDPPort(i);
return getReceiverUDPPort();
case RECEIVER_UDP_PORT2:
sscanf(value.c_str(),"%d",&i);
if(thisDetector->myDetectorType == EIGER)
setReceiverUDPPort2(i);
else
setReceiverUDPPort(i);
if(thisDetector->myDetectorType == EIGER)
return getReceiverUDPPort2();
return getReceiverUDPPort();
default:
return ("unknown network parameter");
}
@ -4867,6 +4878,9 @@ char* slsDetector::getNetworkParameter(networkParameter index) {
case RECEIVER_UDP_PORT:
return getReceiverUDPPort();
break;
case RECEIVER_UDP_PORT2:
return getReceiverUDPPort2();
break;
default:
return ("unknown network parameter");
}
@ -5012,14 +5026,17 @@ int slsDetector::setReceiverUDPPort(int udpport){
return thisDetector->receiverUDPPort;
}
int slsDetector::setReceiverUDPPort2(int udpport){
thisDetector->receiverUDPPort2 = udpport;
return thisDetector->receiverUDPPort2;
}
int slsDetector::setUDPConnection(){
int ret = FAIL;
int fnum = F_SETUP_RECEIVER_UDP;
char args[2][MAX_STR_LENGTH];
char args[3][MAX_STR_LENGTH];
char retval[MAX_STR_LENGTH]="";
@ -5043,9 +5060,11 @@ int slsDetector::setUDPConnection(){
//copy arguments to args[][]
strcpy(args[0],thisDetector->receiverUDPIP);
sprintf(args[1],"%d",thisDetector->receiverUDPPort);
sprintf(args[2],"%d",thisDetector->receiverUDPPort2);
#ifdef VERBOSE
std::cout << "Receiver udp ip address: " << thisDetector->receiverUDPIP << std::endl;
std::cout << "Receiver udp port: " << thisDetector->receiverUDPPort << std::endl;
std::cout << "Receiver udp port2: " << thisDetector->receiverUDPPort2 << std::endl;
#endif
//set up receiver for UDP Connection and get receivermac address
@ -5084,7 +5103,7 @@ int slsDetector::configureMAC(){
int ret=FAIL;
int fnum=F_CONFIGURE_MAC,fnum2=F_RECEIVER_SHORT_FRAME;
char mess[100];
char arg[5][50];
char arg[6][50];
char cword[50]="", *pcword;
string sword;
int retval=-1;
@ -5112,6 +5131,7 @@ int slsDetector::configureMAC(){
sprintf(arg[2],"%x",thisDetector->receiverUDPPort);
strcpy(arg[3],thisDetector->detectorMAC);
strcpy(arg[4],thisDetector->detectorIP);
sprintf(arg[5],"%x",thisDetector->receiverUDPPort2);
#ifdef VERBOSE
std::cout<< "Configuring MAC"<< std::endl;
@ -5174,6 +5194,9 @@ int slsDetector::configureMAC(){
#ifdef VERBOSE
std::cout<<"detector ip:"<<arg[4]<<"."<<std::endl;
#endif
#ifdef VERBOSE
std::cout<<"receiver udp port2:"<<arg[5]<<"."<<std::endl;
#endif
//send to server
if (thisDetector->onlineFlag==ONLINE_FLAG) {
@ -6769,3 +6792,233 @@ int slsDetector::enableTenGigabitEthernet(int i){
thisDetector->tenGigaEnable=retval;
return retval;
}
/******** CTB funcs */
/** opens pattern file and sends pattern to CTB
@param fname pattern file to open
@returns OK/FAIL
*/
int slsDetector::setCTBPattern(string fname) {
int fnum=F_SET_CTB_PATTERN;
int ret = FAIL;
char retval[MAX_STR_LENGTH]="";
// if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
// #ifdef VERBOSE
// std::cout << "Sending detector hostname to Receiver " << thisDetector->hostname << std::endl;
// #endif
// if (connectData() == OK)
// ret=thisReceiver->sendString(fnum,retval,thisDetector->hostname);
// if((ret==FAIL) || (strcmp(retval,thisDetector->hostname)))
// setErrorMask((getErrorMask())|(RECEIVER_DET_HOSTNAME_NOT_SET));
// }
return ret;
}
/** Writes a pattern word to the CTB
@param addr address of the word, -1 is I/O control register, -2 is clk control register
@param word 64bit word to be written, -1 gets
@returns actual value
*/
uint64_t slsDetector::setCTBWord(int addr,uint64_t word) {
//uint64_t ret;
int ret=FAIL;
uint64_t retval=-1;
int fnum=F_SET_CTB_PATTERN;
int mode=0; //sets word
char mess[100];
#ifdef VERBOSE
std::cout<<"Setting CTB word" <<std::endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(&mode,sizeof(mode));
controlSocket->SendDataOnly(&addr,sizeof(addr));
controlSocket->SendDataOnly(&word,sizeof(word));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret!=FAIL)
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
else {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
}
controlSocket->Disconnect();
if (ret==FORCE_UPDATE)
updateDetector();
}
}
return retval;
}
/** Sets the pattern or loop limits in the CTB
@param level -1 complete pattern, 0,1,2, loop level
@param start start address if >=0
@param stop stop address if >=0
@param n number of loops (if level >=0)
@returns OK/FAIL
*/
int slsDetector::setCTBPatLoops(int level,int &start, int &stop, int &n) {
int retval[3], args[4];
args[0]=level;
args[1]=start;
args[2]=stop;
args[3]=n;
int ret=FAIL;
int fnum=F_SET_CTB_PATTERN;
int mode=1; //sets loop
char mess[100];
#ifdef VERBOSE
std::cout<<"Setting CTB word" <<std::endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(&mode,sizeof(mode));
controlSocket->SendDataOnly(&args,sizeof(args));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret!=FAIL) {
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
start=retval[0];
stop=retval[1];
n=retval[2];
} else {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
}
controlSocket->Disconnect();
if (ret==FORCE_UPDATE)
updateDetector();
}
}
return ret;
}
/** Sets the wait address in the CTB
@param level 0,1,2, wait level
@param addr wait address, -1 gets
@returns actual value
*/
int slsDetector::setCTBPatWaitAddr(int level, int addr) {
int retval=-1;
int ret=FAIL;
int fnum=F_SET_CTB_PATTERN;
int mode=3; //sets loop
char mess[100];
#ifdef VERBOSE
std::cout<<"Setting CTB word" <<std::endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(&mode,sizeof(mode));
controlSocket->SendDataOnly(&level,sizeof(level));
controlSocket->SendDataOnly(&addr,sizeof(addr));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret!=FAIL) {
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
} else {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
}
controlSocket->Disconnect();
if (ret==FORCE_UPDATE)
updateDetector();
}
}
return retval;
}
/** Sets the wait time in the CTB
@param level 0,1,2, wait level
@param t wait time, -1 gets
@returns actual value
*/
int slsDetector::setCTBPatWaitTime(int level, uint64_t t) {
uint64_t retval=-1;
int ret=FAIL;
// uint64_t retval=-1;
int fnum=F_SET_CTB_PATTERN;
int mode=4; //sets loop
char mess[100];
#ifdef VERBOSE
std::cout<<"Setting CTB word" <<std::endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectControl() == OK){
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(&mode,sizeof(mode));
controlSocket->SendDataOnly(&level,sizeof(level));
controlSocket->SendDataOnly(&t,sizeof(t));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret!=FAIL) {
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
} else {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
}
controlSocket->Disconnect();
if (ret==FORCE_UPDATE)
updateDetector();
}
}
return retval;
}

View File

@ -240,6 +240,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
int receiverTCPPort;
/** is the port used to communicate between detector and the receiver*/
int receiverUDPPort;
/** is the port used to communicate between second half module of Eiger detector and the receiver*/
int receiverUDPPort2;
/** ip address of the receiver for the detector to send packets to**/
char receiverUDPIP[MAX_STR_LENGTH];
/** mac address of receiver for the detector to send packets to **/
@ -1603,6 +1605,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
char* getReceiverUDPMAC() {return thisDetector->receiverUDPMAC;};
/** returns the receiver UDP IP address \sa sharedSlsDetector */
char* getReceiverUDPPort() {char *c= new char[MAX_STR_LENGTH];sprintf(c,"%d",thisDetector->receiverUDPPort); return c;};
/** returns the receiver UDP2 for Eiger IP address \sa sharedSlsDetector */
char* getReceiverUDPPort2() {char *c= new char[MAX_STR_LENGTH];sprintf(c,"%d",thisDetector->receiverUDPPort2); return c;};
/** validates the format of detector MAC address and sets it \sa sharedSlsDetector */
char* setDetectorMAC(string detectorMAC);
@ -1616,6 +1620,8 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
char* setReceiverUDPMAC(string udpmac);
/** sets the receiver udp port \sa sharedSlsDetector */
int setReceiverUDPPort(int udpport);
/** sets the receiver udp port2 for Eiger \sa sharedSlsDetector */
int setReceiverUDPPort2(int udpport);
/** Sets the read receiver frequency
if Receiver read upon gui request, readRxrFrequency=0,
@ -1644,6 +1650,48 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/
int enableTenGigabitEthernet(int i = -1);
/******** CTB funcs */
/** opens pattern file and sends pattern to CTB
@param fname pattern file to open
@returns OK/FAIL
*/
int setCTBPattern(string fname);
/** Writes a pattern word to the CTB
@param addr address of the word, -1 is I/O control register, -2 is clk control register
@param word 64bit word to be written, -1 gets
@returns actual value
*/
uint64_t setCTBWord(int addr,uint64_t word=-1);
/** Sets the pattern or loop limits in the CTB
@param level -1 complete pattern, 0,1,2, loop level
@param start start address if >=0
@param stop stop address if >=0
@param n number of loops (if level >=0)
@returns OK/FAIL
*/
int setCTBPatLoops(int level,int &start, int &stop, int &n);
/** Sets the wait address in the CTB
@param level 0,1,2, wait level
@param addr wait address, -1 gets
@returns actual value
*/
int setCTBPatWaitAddr(int level, int addr=-1);
/** Sets the wait time in the CTB
@param level 0,1,2, wait level
@param t wait time, -1 gets
@returns actual value
*/
int setCTBPatWaitTime(int level, uint64_t t=-1);
protected:

View File

@ -519,6 +519,8 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
case GOTTHARD: return string("Gotthard"); \
case AGIPD: return string("Agipd"); \
case MOENCH: return string("Moench"); \
case JUNGFRAU: return string("Jungfrau"); \
case JUNGFRAUCTB: return string("JungfrauCTB"); \
default: return string("Unknown"); \
}};
@ -533,6 +535,8 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
if (type=="Gotthard") return GOTTHARD; \
if (type=="Agipd") return AGIPD; \
if (type=="Moench") return MOENCH; \
if (type=="Jungfrau") return JUNGFRAU; \
if (type=="JungfrauCTB") return JUNGFRAUCTB; \
return GENERIC;};

View File

@ -344,6 +344,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
i++;
descrToFuncMap[i].m_pFuncName="rx_udpport2"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
i++;
descrToFuncMap[i].m_pFuncName="detectormac"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdNetworkParameter;
i++;
@ -865,6 +869,97 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
i++;
/* pattern generator */
descrToFuncMap[i].m_pFuncName="pattern"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
i++;
descrToFuncMap[i].m_pFuncName="patword"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
i++;
descrToFuncMap[i].m_pFuncName="patioctrl"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
i++;
descrToFuncMap[i].m_pFuncName="patclkctrl"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
i++;
descrToFuncMap[i].m_pFuncName="patlimits"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
i++;
descrToFuncMap[i].m_pFuncName="patloop0"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
i++;
descrToFuncMap[i].m_pFuncName="patnloop0"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
i++;
descrToFuncMap[i].m_pFuncName="patwait0"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
i++;
descrToFuncMap[i].m_pFuncName="patwaittime0"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
i++;
descrToFuncMap[i].m_pFuncName="patloop1"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
i++;
descrToFuncMap[i].m_pFuncName="patnloop1"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
i++;
descrToFuncMap[i].m_pFuncName="patwait1"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
i++;
descrToFuncMap[i].m_pFuncName="patwaittime1"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
i++;
descrToFuncMap[i].m_pFuncName="patloop2"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
i++;
descrToFuncMap[i].m_pFuncName="patnloop2"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
i++;
descrToFuncMap[i].m_pFuncName="patwait2"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
i++;
descrToFuncMap[i].m_pFuncName="patwaittime2"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
i++;
numberOfCommands=i;
// #ifdef VERBOSE
@ -2464,6 +2559,12 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio
if (!(sscanf(args[1],"%d",&i)))
return ("cannot parse argument") + string(args[1]);
}
} else if (cmd=="rx_udpport2") {
t=RECEIVER_UDP_PORT2;
if (action==PUT_ACTION){
if (!(sscanf(args[1],"%d",&i)))
return ("cannot parse argument") + string(args[1]);
}
} else return ("unknown network parameter")+cmd;
if (action==PUT_ACTION)
@ -2485,6 +2586,7 @@ string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int acti
os << "rx_udpip ip \n sets receiver udp ip to ip"<< std::endl;
os << "rx_udpmac mac \n sets receiver udp mac to mac"<< std::endl;
os << "rx_udpport port \n sets receiver udp port to port"<< std::endl;
os << "rx_udpport2 port \n sets receiver udp port to port. For Eiger, it is the second half module and for other detectors, same as rx_udpport"<< std::endl;
}
if (action==GET_ACTION || action==HELP_ACTION) {
os << "detectormac \n gets detector mac "<< std::endl;
@ -2492,6 +2594,8 @@ string slsDetectorCommand::helpNetworkParameter(int narg, char *args[], int acti
os << "rx_hostname \n gets receiver ip "<< std::endl;
os << "rx_udpmac \n gets receiver udp mac "<< std::endl;
os << "rx_udpport \n gets receiver udp port "<< std::endl;
os << "rx_udpport2 \n gets receiver udp port. For Eiger, it is the second half module and for other detectors, same as rx_udpport"<< std::endl;
}
return os.str();
@ -4140,10 +4244,11 @@ string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) {
string slsDetectorCommand::helpReceiver(int narg, char *args[], int action) {
ostringstream os;
if (action==PUT_ACTION || action==HELP_ACTION)
if (action==PUT_ACTION || action==HELP_ACTION) {
os << "receiver [status] \t starts/stops the receiver to listen to detector packets. - can be start or stop" << std::endl;
os << "r_readfreq \t sets the gui read frequency of the receiver, 0 if gui requests frame, >0 if receiver sends every nth frame to gui" << std::endl;
os << "tengiga \t sets system to be configure for 10Gbe if set to 1, else 1Gbe if set to 0" << std::endl;
}
if (action==GET_ACTION || action==HELP_ACTION){
os << "receiver \t returns the status of receiver - can be running or idle" << std::endl;
os << "framescaught \t returns the number of frames caught by receiver(average for multi)" << std::endl;
@ -4160,4 +4265,82 @@ string slsDetectorCommand::helpReceiver(int narg, char *args[], int action) {
}
string slsDetectorCommand::helpPattern(int narg, char *args[], int action) {
ostringstream os;
if (action==PUT_ACTION || action==HELP_ACTION) {
os << "pattern fname \t loads pattern file" << std::endl;
os << "patword addr word \t writes pattern word - only very advanced users!" << std::endl;
os << "patioctrl reg\t configures inputs/outputs of the chiptest board - only advanced users!" << std::endl;
os << "patclkctrl reg\t configures output clk enable of the chiptest board- only advanced users! " << std::endl;
os << "patlimits addr1 addr2\t defines pattern limits between addr1 and addr2" << std::endl;
os << "patloop0 addr1 adrr2 \t configures the limits of the 0 loop " << std::endl;
os << "patloop1 addr1 adrr2 \t configures the limits of the 1 loop " << std::endl;
os << "patloop2 addr1 adrr2 \t configures the limits of the 2 loop " << std::endl;
os << "patnloop0 n \t sets number of cycles of the 0 loop " << std::endl;
os << "patnloop1 n \t sets number of cycles of the 1 loop " << std::endl;
os << "patnloop2 n \t sets number of cycles of the 2 loop " << std::endl;
os << "patwait0 addr \t configures pattern wait 0 address " << std::endl;
os << "patwait1 addr \t configures pattern wait 1 address " << std::endl;
os << "patwait2 addr \t configures pattern wait 2 address " << std::endl;
os << "patwaittime0 nclk \t sets wait 0 waiting time in clock number " << std::endl;
os << "patwaittime1 nclk \t sets wait 1 waiting time in clock number " << std::endl;
os << "patwaittime2 nclk \t sets wait 2 waiting time in clock number " << std::endl;
}
if (action==GET_ACTION || action==HELP_ACTION){
os << "pattern \t cannot get" << std::endl;
os << "patword \t cannot get" << std::endl;
os << "patioctrl \t returns inputs/outputs of the chiptest board - only advanced users!" << std::endl;
os << "patclkctrl\t returns output clk enable of the chiptest board- only advanced users! " << std::endl;
os << "patlimits \t returns pattern limits between addr1 and addr2" << std::endl;
os << "patloop0 \t returns the limits of the 0 loop " << std::endl;
os << "patloop1 \t returns the limits of the 1 loop " << std::endl;
os << "patloop2 \t returns the limits of the 2 loop " << std::endl;
os << "patnloop0 \t returns the number of cycles of the 0 loop " << std::endl;
os << "patnloop1 \t returns the number of cycles of the 1 loop " << std::endl;
os << "patnloop2 \t returns the number of cycles of the 2 loop " << std::endl;
os << "patwait0 \t returns the pattern wait 0 address " << std::endl;
os << "patwait1 \t returns the pattern wait 1 address " << std::endl;
os << "patwait2 \t returns the pattern wait 2 address " << std::endl;
os << "patwaittime0 \t returns the wait 0 waiting time in clock number " << std::endl;
os << "patwaittime1 \t returns the wait 1 waiting time in clock number " << std::endl;
os << "patwaittime2 \t returns the wait 2 waiting time in clock number " << std::endl;
}
return os.str();
}
string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
/********
Must implement set ctb functions in slsDetector and multiSlsDetector
**********/
ostringstream os;
if (cmd=="pattern") ;
else if (cmd=="patword") ;
else if (cmd=="patioctrl") ;
else if (cmd=="patclkctrl") ;
else if (cmd=="patlimits") ;
else if (cmd=="patloop0") ;
else if (cmd=="patloop1") ;
else if (cmd=="patloop2") ;
else if (cmd=="patnloop0") ;
else if (cmd=="patnloop1") ;
else if (cmd=="patnloop2") ;
else if (cmd=="patwait0") ;
else if (cmd=="patwait1") ;
else if (cmd=="patwait2") ;
else if (cmd=="patwaittime0") ;
else if (cmd=="patwaittime1") ;
else if (cmd=="patwaittime2") ;
else return helpPattern(narg, args, action);
return os.str();
}

View File

@ -84,6 +84,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
static string helpEnablefwrite(int narg, char *args[], int action);
static string helpOverwrite(int narg, char *args[], int action);
static string helpReceiver(int narg, char *args[], int action);
static string helpPattern(int narg, char *args[], int action);
@ -155,6 +156,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
string cmdEnablefwrite(int narg, char *args[], int action);
string cmdOverwrite(int narg, char *args[], int action);
string cmdReceiver(int narg, char *args[], int action);
string cmdPattern(int narg, char *args[], int action);
int numberOfCommands;

View File

@ -702,12 +702,77 @@ virtual int enableReceiverCompression(int i = -1)=0;
/returns if 10Gbe is enabled
*/
virtual int enableTenGigabitEthernet(int i = -1)=0;
/******** CTB funcs */
/** opens pattern file and sends pattern to CTB
@param fname pattern file to open
@returns OK/FAIL
*/
virtual int setCTBPattern(string fname)=0;
/** Writes a pattern word to the CTB
@param addr address of the word, -1 is I/O control register, -2 is clk control register
@param word 64bit word to be written, -1 gets
@returns actual value
*/
virtual uint64_t setCTBWord(int addr,uint64_t word=-1)=0;
/** Sets the pattern or loop limits in the CTB
@param level -1 complete pattern, 0,1,2, loop level
@param start start address if >=0
@param stop stop address if >=0
@param n number of loops (if level >=0)
@returns OK/FAIL
*/
virtual int setCTBPatLoops(int level,int &start, int &stop, int &n)=0;
/** Sets the wait address in the CTB
@param level 0,1,2, wait level
@param addr wait address, -1 gets
@returns actual value
*/
virtual int setCTBPatWaitAddr(int level, int addr=-1)=0;
/** Sets the wait time in the CTB
@param level 0,1,2, wait level
@param t wait time, -1 gets
@returns actual value
*/
virtual int setCTBPatWaitTime(int level, uint64_t t=-1)=0;
protected:
static const int64_t thisSoftwareVersion=0x20120124;
static const int64_t thisSoftwareVersion=0x20141013;

View File

@ -95,7 +95,7 @@ int executeTrimming(enum trimMode mode, int par1, int par2, int imod);
#ifndef MYTHEND
int configureMAC(int ipad, long long int macad, long long int detectormacadd, int detipad, int udpport, int ival);
int configureMAC(int ipad, long long int macad, long long int detectormacadd, int detipad, int udpport, int udpport2, int ival);
#endif
#ifdef GOTTHARDD

View File

@ -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_Init();
// printf("FEb control constructor done\n");
/* Beb_Beb(-1);
printf("BEB constructor done\n");*/
}
@ -2275,9 +2275,9 @@ int get_run_status(int file_des) {
enum runStatus s;
sprintf(mess,"getting run status\n");
//#ifdef VERBOSE
#ifdef VERBOSE
printf("Getting status\n");
//#endif
#endif
#ifdef SLS_DETECTOR_FUNCTION_LIST
s= getRunStatus();printf("status:%d\n");
#endif
@ -2967,7 +2967,7 @@ int configure_mac(int file_des) {
int retval=-100;
int ret=OK,ret1=OK;
char arg[5][50];
char arg[6][50];
int n;
#ifndef MYTHEND
@ -2976,6 +2976,7 @@ int configure_mac(int file_des) {
long long int imacadd;
long long int idetectormacadd;
int udpport;
int udpport2;
int detipad;
#endif
@ -2996,7 +2997,7 @@ int configure_mac(int file_des) {
sscanf(arg[2], "%x", &udpport);
sscanf(arg[3], "%llx", &idetectormacadd);
sscanf(arg[4], "%x", &detipad);
sscanf(arg[5], "%x", &udpport2);
#ifdef SLS_DETECTOR_FUNCTION_LIST
@ -3006,7 +3007,7 @@ int configure_mac(int file_des) {
printf("mess:%s\n",mess);
}
#endif
#ifdef VERBOSE
//#ifdef VERBOSE
int i;
/*printf("\ndigital_test_bit in server %d\t",digitalTestBit);for gotthard*/
printf("\nipadd %x\t",ipad);
@ -3019,9 +3020,10 @@ int configure_mac(int file_des) {
for (i=0;i<6;i++)
printf("detector mac adress %d is 0x%x \n",6-i,(unsigned int)(((idetectormacadd>>(8*i))&0xFF)));
printf("detipad %x\n",detipad);
printf("udp port2:0x%x\n",udpport2);
printf("\n");
printf("Configuring MAC of module %d at port %x\n", imod, udpport);
#endif
//#endif
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) {
@ -3029,7 +3031,7 @@ int configure_mac(int file_des) {
stopStateMachine();
}
retval=configureMAC(ipad,imacadd,idetectormacadd,detipad,udpport,0); /*digitalTestBit);*/
retval=configureMAC(ipad,imacadd,idetectormacadd,detipad,udpport,udpport2,0); /*digitalTestBit);*/
if(retval==-1) ret=FAIL;
}
#endif

View File

@ -40,8 +40,8 @@ int receiverInterface::sendString(int fnum, char retval[], char arg[]){
int receiverInterface::sendUDPDetails(int fnum, char retval[], char arg[2][MAX_STR_LENGTH]){
char args[2][MAX_STR_LENGTH];
int receiverInterface::sendUDPDetails(int fnum, char retval[], char arg[3][MAX_STR_LENGTH]){
char args[3][MAX_STR_LENGTH];
int ret = slsDetectorDefs::FAIL;
char mess[100] = "";

View File

@ -56,7 +56,7 @@ public:
* @param arg value to send
* \returns success of operation
*/
int sendUDPDetails(int fnum, char retval[], char arg[2][MAX_STR_LENGTH]);
int sendUDPDetails(int fnum, char retval[], char arg[3][MAX_STR_LENGTH]);
/**