mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 11:20:04 +02:00
eiger reading master slave top bottom configuration from firmware;not reading from file anymore, serial is hardcoded for each master: also bug changes in gui getting frame from receiver in postprocessing
This commit is contained in:
parent
b2c7944014
commit
d658799b20
@ -11,7 +11,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
#include "xfs_types.h"
|
||||
@ -89,7 +89,7 @@ void BebInfo_Print(struct BebInfo* bebInfo){
|
||||
}
|
||||
|
||||
|
||||
void Beb_Beb(int arg1){
|
||||
void Beb_Beb(){
|
||||
|
||||
Beb_send_ndata = 0;
|
||||
Beb_send_buffer_size = 1026;
|
||||
@ -137,14 +137,32 @@ 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");
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Beb_GetModuleCopnfiguration(int* master, int* top){
|
||||
*top = 0;
|
||||
*master = 0;
|
||||
//mapping new memory to read master top module configuration
|
||||
ll_beb_new_memory = &ll_beb_new_memory_local;
|
||||
Local_LocalLinkInterface(ll_beb_new_memory);
|
||||
int ret = Local_GetModuleConfiguration(ll_beb_new_memory,XPAR_PLB_GPIO_SYS_BASEADDR, MODULE_CONFIGURATION);
|
||||
if(!ret)
|
||||
printf("Module Configuration FAIL\n");
|
||||
else{
|
||||
printf("Module Configuration OK\n");
|
||||
printf("Beb: value =0x%x\n",ret);
|
||||
if(ret&0xf){
|
||||
*top = 1;
|
||||
// printf("Beb.c: TOP\n\n\n\n");
|
||||
}//else printf("Beb.c: BOTTOM\n\n\n\n");
|
||||
|
||||
if(ret&0x200){
|
||||
*master = 1;
|
||||
// printf("Beb.c: MASTER\n\n\n\n");
|
||||
}//else printf("Beb.c: SLAVE\n\n\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,8 +40,6 @@ struct BebInfo{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Beb_ClearBebInfos();
|
||||
int Beb_InitBebInfos();
|
||||
int Beb_ReadSetUpFromFile(char* file_name);
|
||||
@ -67,9 +65,7 @@ struct BebInfo{
|
||||
int Beb_SetByteOrder();
|
||||
|
||||
|
||||
|
||||
|
||||
void Beb_Beb(int arg1);
|
||||
void Beb_Beb();
|
||||
|
||||
|
||||
int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig, char* src_mac, char* src_ip, unsigned int src_port);
|
||||
|
@ -53,9 +53,9 @@ unsigned int Feb_Control_trimbit_size;
|
||||
unsigned int* Feb_Control_last_downloaded_trimbits;
|
||||
|
||||
|
||||
int Feb_Control_current_mod;
|
||||
int Feb_Control_module_number;
|
||||
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;
|
||||
@ -151,124 +151,96 @@ int Feb_Control_IsBottomModule(){
|
||||
|
||||
|
||||
int Feb_Control_GetModuleNumber(){
|
||||
return Feb_Control_current_mod;
|
||||
return Feb_Control_module_number;
|
||||
}
|
||||
|
||||
|
||||
void Feb_Control_FebControl(){
|
||||
|
||||
Feb_Control_staticBits=Feb_Control_acquireNReadoutMode=Feb_Control_triggerMode=Feb_Control_externalEnableMode=Feb_Control_subFrameMode=0;
|
||||
|
||||
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;
|
||||
Feb_Control_exposure_period_in_sec = 0;
|
||||
Feb_Control_SetTestModeVariable(0);
|
||||
//SetPhotonEnergyCalibrationParameters(-5.8381e-5,1.838515,5.09948e-7,-4.32390e-11,1.32527e-15);
|
||||
//SetRateCorrection(0); //deactivate rate correction
|
||||
Feb_Control_SetDynamicRange(16);
|
||||
Feb_Control_SetPhotonEnergy(8000);
|
||||
Feb_Control_SetReadoutMode(0);
|
||||
Feb_Control_SetReadoutSpeed(0);
|
||||
Feb_Control_SetTriggerMode(0,1);
|
||||
Feb_Control_SetExternalEnableMode(0,1);
|
||||
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");;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
moduleSize = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Feb_Control_ClearModules(){
|
||||
unsigned int i;
|
||||
//for(i=0;i<moduleSize;i++) free(modules[i]);
|
||||
moduleSize = 0;
|
||||
}
|
||||
|
||||
int Feb_Control_Init(){
|
||||
int Feb_Control_Init(int master, int top){
|
||||
unsigned int i;
|
||||
Feb_Control_ClearModules();
|
||||
///*
|
||||
Feb_Control_current_mod = 0;
|
||||
Feb_Control_module_number = 0;
|
||||
Feb_Control_current_index = 0;
|
||||
Feb_Control_AddModule(0,0xff);//global send
|
||||
|
||||
Feb_Control_PrintModuleList();
|
||||
//global send
|
||||
Feb_Control_AddModule1(0,1,0xff,0,1);
|
||||
Feb_Control_PrintModuleList();
|
||||
|
||||
//*/
|
||||
Feb_Control_ReadSetUpFileToAddModules("/home/root/executables/setup.txt");
|
||||
//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_module_number = (res & 0xFF);
|
||||
|
||||
//get serial
|
||||
int serial=1;
|
||||
switch(Feb_Control_module_number){
|
||||
case 34: serial = 0; break; //martin
|
||||
case 31: serial = 0; break; //dhanya
|
||||
case 26: serial = 0; break; //leo
|
||||
case 32: serial = 1; break;
|
||||
case 24: serial = 2; break;
|
||||
case 25: serial = 3; break;
|
||||
}
|
||||
printf("serial: %d\n",serial);
|
||||
|
||||
/*
|
||||
printf("\nSetting detector defaults:\n");
|
||||
Feb_Control_ReadSetUpFile(0,"/home/root/executables/setup.txt"); //send defaults to all
|
||||
Feb_Control_current_index = 1;
|
||||
|
||||
/* 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);
|
||||
}*/
|
||||
|
||||
//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);
|
||||
|
||||
|
||||
for(i=1;i<moduleSize;i++){
|
||||
if(Module_GetModuleNumber(&modules[i])==Feb_Control_current_mod)
|
||||
/*for(i=1;i<moduleSize;i++){
|
||||
if(Module_GetModuleNumber(&modules[i])==Feb_Control_module_number)
|
||||
Feb_Control_current_index = i;
|
||||
}
|
||||
printf("****current index:%d\n",i);
|
||||
*/
|
||||
//Feb_Control_ReadSetUpFileToAddModules("/home/root/executables/setup.txt");
|
||||
|
||||
/*Feb_Control_ReadSetUpFile(Feb_Control_current_mod,"/home/root/executables/setup.txt");
|
||||
printf("Done setting detector defaults\n");*/
|
||||
//Add the half module
|
||||
Feb_Control_AddModule1(Feb_Control_module_number,top,serial,serial,1);
|
||||
Feb_Control_PrintModuleList();
|
||||
|
||||
|
||||
unsigned int nfebs = 0;
|
||||
unsigned int* feb_list = malloc(moduleSize*4 * sizeof(unsigned int));
|
||||
for(i=1;i<moduleSize;i++){
|
||||
if(Module_TopAddressIsValid(&modules[i])){
|
||||
feb_list[nfebs++] = Module_GetTopRightAddress(&modules[i]);
|
||||
feb_list[nfebs++] = Module_GetTopLeftAddress(&modules[i]);
|
||||
}
|
||||
if(Module_BottomAddressIsValid(&modules[i])){
|
||||
feb_list[nfebs++] = Module_GetBottomRightAddress(&modules[i]);
|
||||
feb_list[nfebs++] = Module_GetBottomLeftAddress(&modules[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Feb_Interface_SendCompleteList(nfebs,feb_list);
|
||||
free(feb_list);
|
||||
printf("\n");
|
||||
Feb_Interface_SetByteOrder();
|
||||
|
||||
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];
|
||||
@ -280,12 +252,9 @@ void Feb_Control_Set_Master(){
|
||||
return 0;
|
||||
}
|
||||
printf("master is set\n");
|
||||
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -418,9 +387,9 @@ int Feb_Control_CheckModuleAddresses(struct Module* m){
|
||||
}
|
||||
|
||||
int Feb_Control_AddModule(unsigned int module_number, unsigned int top_address){
|
||||
return Feb_Control_AddModule1(module_number,0,top_address,0,1);
|
||||
return Feb_Control_AddModule1(module_number,1,top_address,0,1);
|
||||
}
|
||||
int Feb_Control_AddModule1(unsigned int module_number, int bottom_enable, unsigned int top_address, unsigned int bottom_address, int half_module){ //bot_address 0 for half module
|
||||
int Feb_Control_AddModule1(unsigned int module_number, int top_enable, 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)){
|
||||
@ -438,7 +407,7 @@ int Feb_Control_AddModule1(unsigned int module_number, int bottom_enable, unsign
|
||||
|
||||
/* 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_enable)) Module_Module(m,module_number,top_address);
|
||||
if ((half_module)&& (top_enable)) 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);
|
||||
|
||||
@ -726,7 +695,7 @@ float Feb_Control_DACToVoltage(unsigned int digital,unsigned int nsteps,float vm
|
||||
|
||||
|
||||
int Feb_Control_SetHighVoltage(float value){
|
||||
return Feb_Control_SetHighVoltage1(Feb_Control_current_mod,value);
|
||||
return Feb_Control_SetHighVoltage1(Feb_Control_module_number,value);
|
||||
}
|
||||
|
||||
int Feb_Control_SetHighVoltage1(unsigned int module_num,float value){
|
||||
|
@ -67,9 +67,8 @@ 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();
|
||||
|
||||
|
||||
|
||||
void Feb_Control_PrintModuleList();
|
||||
@ -77,7 +76,7 @@ void Feb_Control_Set_Master();
|
||||
int Feb_Control_CheckModuleAddresses(struct Module* m);
|
||||
int Feb_Control_AddModule(unsigned int module_number, unsigned int top_address);
|
||||
/*int Feb_Control_AddModule(unsigned int module_number, unsigned int top_address, unsigned int bottom_address, int half_module=0);*/
|
||||
int Feb_Control_AddModule1(unsigned int module_number, int bottom_enable, unsigned int top_address, unsigned int bottom_address, int half_module);
|
||||
int Feb_Control_AddModule1(unsigned int module_number, int top_enable, unsigned int top_address, unsigned int bottom_address, int half_module);
|
||||
|
||||
int Feb_Control_GetDACNumber(char* s, unsigned int* n);
|
||||
int Feb_Control_SendDACValue(unsigned int dst_num, unsigned int ch, unsigned int* value);
|
||||
@ -111,9 +110,7 @@ void Feb_Control_Set_Master();
|
||||
|
||||
|
||||
void Feb_Control_FebControl();
|
||||
|
||||
|
||||
int Feb_Control_Init();
|
||||
int Feb_Control_Init(int master, int top);
|
||||
int Feb_Control_ReadSetUpFileToAddModules(char* file_name);
|
||||
int Feb_Control_ReadSetUpFile(unsigned int module_num, char* file_name);
|
||||
int Feb_Control_CheckSetup();
|
||||
|
@ -177,7 +177,7 @@ int Feb_Interface_WriteMemoryInLoops(unsigned int sub_num, unsigned int mem_num,
|
||||
ndata_countdown-=n_to_send;
|
||||
ndata_sent +=n_to_send;
|
||||
start_address +=n_to_send;
|
||||
usleep(0);//500 works
|
||||
usleep(500);//500 works
|
||||
}
|
||||
return passed;
|
||||
}
|
||||
|
@ -25,51 +25,36 @@ Local_LocalLinkInterface1(struct LocalLinkInterface* ll,unsigned int ll_fifo_bad
|
||||
Local_Reset(ll);
|
||||
printf("\tFIFO Status : 0x%08x\n",Local_StatusVector(ll));
|
||||
}else printf("\tError LocalLink Mappping : 0x%08x\n",ll_fifo_badr);
|
||||
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
/*~LocalLinkInterface(){};*/
|
||||
|
||||
Local_LocalLinkInterface(struct LocalLinkInterface* ll){
|
||||
printf("Initialize new memory\n");
|
||||
printf("Initializing new memory\n");
|
||||
}
|
||||
|
||||
int Local_InitNewMemory (struct LocalLinkInterface* ll,unsigned int addr, int ifg){
|
||||
unsigned int CSP0BASE;
|
||||
int fd;
|
||||
|
||||
/*fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
|
||||
int Local_GetModuleConfiguration (struct LocalLinkInterface* ll, u_int32_t baseaddr, u_int32_t offset){
|
||||
int fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
|
||||
if (fd == -1) {
|
||||
printf("\nCan't find /dev/mem!\n");
|
||||
return 0;
|
||||
}
|
||||
printf("/dev/mem opened\n");
|
||||
|
||||
|
||||
CSP0BASE = (u_int32_t)mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, addr);
|
||||
u_int32_t CSP0BASE = (u_int32_t)mmap(0, 0x100000, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, baseaddr);
|
||||
if (CSP0BASE == (u_int32_t)MAP_FAILED) {
|
||||
printf("\nCan't map memmory area!!\n");
|
||||
return 0;
|
||||
}
|
||||
printf("CSP0 mapped\n");
|
||||
|
||||
|
||||
volatile u_int8_t *ptr1;
|
||||
|
||||
ptr1=(u_int8_t*)(CSP0BASE);
|
||||
|
||||
printf("pointer val=%x\n",(void*)ptr1);
|
||||
|
||||
printf("ifg_control=%02x\n",*ptr1);
|
||||
|
||||
*ptr1=ifg;
|
||||
|
||||
printf("ifg_control new=%02x\n",*ptr1);
|
||||
|
||||
volatile u_int32_t *ptr1;
|
||||
ptr1=(u_int32_t*)(CSP0BASE + offset);
|
||||
//printf("LocalLinkInterface:: value:%d\n",*ptr1);
|
||||
close(fd);
|
||||
*/
|
||||
return 1;
|
||||
|
||||
return *ptr1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "xfs_types.h"
|
||||
#include "HardwareIO.h"
|
||||
#include <sys/types.h>
|
||||
|
||||
/*class LocalLinkInterface: public HardwareIO{ //*/
|
||||
|
||||
@ -35,7 +36,7 @@ struct LocalLinkInterface{
|
||||
int Local_Test(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer);
|
||||
|
||||
void Local_LocalLinkInterface(struct LocalLinkInterface* ll);
|
||||
int Local_InitNewMemory (struct LocalLinkInterface* ll,unsigned int addr, int ifg);
|
||||
int Local_GetModuleConfiguration (struct LocalLinkInterface* ll, u_int32_t baseaddr, u_int32_t offset);
|
||||
|
||||
/*
|
||||
int FiFoReset(unsigned int numb);
|
||||
|
Binary file not shown.
@ -56,118 +56,121 @@ int dst_requested[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
int default_dac_values[16] = {0,2480,3300,1400,4000,2556,1000,1000,4000,1000,1000,1000,1000,200,2000,1550};
|
||||
|
||||
|
||||
enum masterFlags masterMode=NO_MASTER;
|
||||
int bottom = 0;
|
||||
//enum masterFlags trialMasterMode=NO_MASTER;
|
||||
enum masterFlags masterMode=IS_SLAVE;
|
||||
int top = 0;
|
||||
int master = 0;
|
||||
|
||||
|
||||
int initDetector(){
|
||||
int imod,i,n;
|
||||
n = getNModBoard(1);
|
||||
int imod,i,n;
|
||||
n = getNModBoard(1);
|
||||
|
||||
printf("This is the EIGER Server of revision %llx\n", getDetectorId(DETECTOR_SOFTWARE_VERSION));
|
||||
printf("This is the EIGER Server of revision %llx\n", getDetectorId(DETECTOR_SOFTWARE_VERSION));
|
||||
|
||||
//#ifdef VERBOSE
|
||||
printf("Board is for %d half modules\n",n);
|
||||
//#endif
|
||||
//#ifdef VERBOSE
|
||||
printf("Board is for %d half modules\n",n);
|
||||
//#endif
|
||||
|
||||
|
||||
detectorModules=malloc(n*sizeof(sls_detector_module));
|
||||
detectorChips=malloc(n*NCHIP*sizeof(int));
|
||||
//Allocation of memory
|
||||
detectorModules=malloc(n*sizeof(sls_detector_module));
|
||||
detectorChips=malloc(n*NCHIP*sizeof(int));
|
||||
|
||||
detectorChans=malloc(n*NCHIP*NCHAN*sizeof(int));
|
||||
detectorDacs=malloc(n*NDAC*sizeof(dacs_t));
|
||||
detectorAdcs=malloc(n*NADC*sizeof(dacs_t));
|
||||
detectorChans=malloc(n*NCHIP*NCHAN*sizeof(int));
|
||||
detectorDacs=malloc(n*NDAC*sizeof(dacs_t));
|
||||
detectorAdcs=malloc(n*NADC*sizeof(dacs_t));
|
||||
#ifdef VERBOSE
|
||||
printf("modules from 0x%x to 0x%x\n",detectorModules, detectorModules+n);
|
||||
printf("chips from 0x%x to 0x%x\n",detectorChips, detectorChips+n*NCHIP);
|
||||
printf("chans from 0x%x to 0x%x\n",detectorChans, detectorChans+n*NCHIP*NCHAN);
|
||||
printf("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs+n*NDAC);
|
||||
printf("adcs from 0x%x to 0x%x\n",detectorAdcs, detectorAdcs+n*NADC);
|
||||
printf("modules from 0x%x to 0x%x\n",detectorModules, detectorModules+n);
|
||||
printf("chips from 0x%x to 0x%x\n",detectorChips, detectorChips+n*NCHIP);
|
||||
printf("chans from 0x%x to 0x%x\n",detectorChans, detectorChans+n*NCHIP*NCHAN);
|
||||
printf("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs+n*NDAC);
|
||||
printf("adcs from 0x%x to 0x%x\n",detectorAdcs, detectorAdcs+n*NADC);
|
||||
#endif
|
||||
for (imod=0; imod<n; imod++) {
|
||||
(detectorModules+imod)->dacs=detectorDacs+imod*NDAC;
|
||||
(detectorModules+imod)->adcs=detectorAdcs+imod*NADC;
|
||||
(detectorModules+imod)->chipregs=detectorChips+imod*NCHIP;
|
||||
(detectorModules+imod)->chanregs=detectorChans+imod*NCHIP*NCHAN;
|
||||
(detectorModules+imod)->ndac=NDAC;
|
||||
(detectorModules+imod)->nadc=NADC;
|
||||
(detectorModules+imod)->nchip=NCHIP;
|
||||
(detectorModules+imod)->nchan=NCHIP*NCHAN;
|
||||
(detectorModules+imod)->module=imod;
|
||||
(detectorModules+imod)->gain=0;
|
||||
(detectorModules+imod)->offset=0;
|
||||
(detectorModules+imod)->reg=0;
|
||||
/* initialize registers, dacs, retrieve sn, adc values etc */
|
||||
}
|
||||
thisSettings = STANDARD;/**UNITIALIZED*/
|
||||
/*sChan=noneSelected;
|
||||
for (imod=0; imod<n; imod++) {
|
||||
(detectorModules+imod)->dacs=detectorDacs+imod*NDAC;
|
||||
(detectorModules+imod)->adcs=detectorAdcs+imod*NADC;
|
||||
(detectorModules+imod)->chipregs=detectorChips+imod*NCHIP;
|
||||
(detectorModules+imod)->chanregs=detectorChans+imod*NCHIP*NCHAN;
|
||||
(detectorModules+imod)->ndac=NDAC;
|
||||
(detectorModules+imod)->nadc=NADC;
|
||||
(detectorModules+imod)->nchip=NCHIP;
|
||||
(detectorModules+imod)->nchan=NCHIP*NCHAN;
|
||||
(detectorModules+imod)->module=imod;
|
||||
(detectorModules+imod)->gain=0;
|
||||
(detectorModules+imod)->offset=0;
|
||||
(detectorModules+imod)->reg=0;
|
||||
/* initialize registers, dacs, retrieve sn, adc values etc */
|
||||
}
|
||||
thisSettings = STANDARD;/**UNITIALIZED*/
|
||||
/*sChan=noneSelected;
|
||||
sChip=noneSelected;
|
||||
sMod=noneSelected;
|
||||
sDac=noneSelected;
|
||||
sAdc=noneSelected;
|
||||
*/
|
||||
*/
|
||||
|
||||
Feb_Interface_FebInterface();
|
||||
Feb_Control_FebControl();
|
||||
Feb_Control_Init();
|
||||
printf("FEb control constructor done\n");
|
||||
Beb_Beb(-1);
|
||||
printf("BEB constructor done\n");
|
||||
//Feb and Beb Initializations
|
||||
getModuleConfiguration();
|
||||
Feb_Interface_FebInterface();
|
||||
Feb_Control_FebControl();
|
||||
Feb_Control_Init(master,top);
|
||||
printf("FEB Initialization done\n");
|
||||
Beb_Beb();
|
||||
printf("BEB Initialization done\n");
|
||||
|
||||
//get dac values
|
||||
int retval[2];
|
||||
//Get dac values
|
||||
int retval[2];
|
||||
for(i=0;i<(detectorModules)->ndac;i++)
|
||||
setDAC((enum detDacIndex)i,default_dac_values[i],(detectorModules)->module,0,retval);
|
||||
|
||||
|
||||
/* initialize dynamic range etc. */
|
||||
|
||||
|
||||
//set number of frames to 1
|
||||
setTimer(FRAME_NUMBER,1);
|
||||
setTimer(ACQUISITION_TIME,1E9);
|
||||
setTimer(FRAME_PERIOD,1E9);
|
||||
setDynamicRange(16);
|
||||
setThresholdEnergy(8000,0);
|
||||
setReadOutFlags(PARALLEL);
|
||||
setSpeed(0,1);//clk_devider,half speed
|
||||
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();
|
||||
|
||||
//top or bottom
|
||||
bottom = Feb_Control_IsBottomModule();
|
||||
/*if(getDetectorNumber()==0xbeb031)
|
||||
bottom = 0;
|
||||
else bottom = 1;
|
||||
*/
|
||||
if(bottom)
|
||||
printf("BOTTOM ***************\n");
|
||||
else
|
||||
printf("TOP ***************\n");
|
||||
|
||||
|
||||
//if(getDetectorNumber()==0xbeb031){
|
||||
// printf("************** master ********************\n");
|
||||
// trialMasterMode = IS_MASTER;
|
||||
//Feb_Control_Set_Master();
|
||||
// }
|
||||
//else printf("************** slave ********************\n");
|
||||
|
||||
|
||||
|
||||
|
||||
return 1;
|
||||
//setting default measurement parameters
|
||||
setTimer(FRAME_NUMBER,1);
|
||||
setTimer(ACQUISITION_TIME,1E9);
|
||||
setTimer(FRAME_PERIOD,1E9);
|
||||
setDynamicRange(16);
|
||||
setThresholdEnergy(8000,0);
|
||||
setReadOutFlags(PARALLEL);
|
||||
setSpeed(0,1);//clk_devider,half speed
|
||||
setHighVolage(150,0);
|
||||
setIODelay(675,0);
|
||||
setTiming(AUTO_TIMING);
|
||||
//SetPhotonEnergyCalibrationParameters(-5.8381e-5,1.838515,5.09948e-7,-4.32390e-11,1.32527e-15);
|
||||
//SetRateCorrection(0); //deactivate rate correction
|
||||
int enable[2] = {0,1};
|
||||
setExternalGating(enable);//disable external gating
|
||||
Feb_Control_SetTestModeVariable(0);
|
||||
Feb_Control_CheckSetup();
|
||||
|
||||
printf("\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int initDetectorStop(){
|
||||
getModuleConfiguration();
|
||||
Feb_Interface_FebInterface();
|
||||
Feb_Control_Init(master,top);
|
||||
printf("FEB Initialization done\n");
|
||||
/* Beb_Beb(-1);
|
||||
printf("BEB constructor done\n");*/
|
||||
|
||||
printf("\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void getModuleConfiguration(){
|
||||
int *m=&master;
|
||||
int *t=⊤
|
||||
Beb_GetModuleCopnfiguration(m,t);
|
||||
if(top) printf("*************** TOP ***************\n");
|
||||
else printf("*************** BOTTOM ***************\n");
|
||||
if(master) printf("*************** MASTER ***************\n");
|
||||
else printf("*************** SLAVE ***************\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
int setNMod(int nm, enum dimension dim){
|
||||
return 1;
|
||||
@ -183,7 +186,7 @@ int getNModBoard(enum dimension arg){
|
||||
|
||||
int64_t getModuleId(enum idMode arg, int imod){
|
||||
|
||||
/**/
|
||||
/**/
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -215,16 +218,16 @@ int64_t getDetectorId(enum idMode arg){
|
||||
int getDetectorNumber(){
|
||||
|
||||
int res=0;
|
||||
char hostname[100];
|
||||
if (gethostname(hostname, sizeof hostname) == 0)
|
||||
puts(hostname);
|
||||
else
|
||||
perror("gethostname");
|
||||
sscanf(hostname,"%x",&res);
|
||||
return res;
|
||||
char hostname[100];
|
||||
if (gethostname(hostname, sizeof hostname) == 0)
|
||||
puts(hostname);
|
||||
else
|
||||
perror("gethostname");
|
||||
sscanf(hostname,"%x",&res);
|
||||
return res;
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
char output[255]="";
|
||||
int res=0;
|
||||
FILE* sysFile = popen("hostname", "r");
|
||||
@ -232,18 +235,18 @@ int getDetectorNumber(){
|
||||
pclose(sysFile);
|
||||
sscanf(output,"%x",&res);
|
||||
return res;
|
||||
*/
|
||||
*/
|
||||
/*
|
||||
int res=0;
|
||||
char hostname[100] = "beb000";
|
||||
sscanf(hostname,"%x",&res);
|
||||
return res;
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
u_int64_t getDetectorMAC() {
|
||||
/*
|
||||
/*
|
||||
char output[255],mac[255]="";
|
||||
u_int64_t res=0;
|
||||
FILE* sysFile = popen("ifconfig eth0 | grep HWaddr | cut -d \" \" -f 11", "r");
|
||||
@ -259,8 +262,8 @@ u_int64_t getDetectorMAC() {
|
||||
sscanf(mac,"%llx",&res);
|
||||
printf("mac:%llx\n",res);
|
||||
return res;
|
||||
*/
|
||||
return 0;
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
int moduleTest( enum digitalTestMode arg, int imod){
|
||||
@ -379,9 +382,9 @@ int enableTenGigabitEthernet(int val){
|
||||
|
||||
int setModule(sls_detector_module myMod){
|
||||
int retval[2];
|
||||
//#ifdef VERBOSE
|
||||
//#ifdef VERBOSE
|
||||
printf("Setting module with settings %d\n",myMod.reg);
|
||||
//#endif
|
||||
//#endif
|
||||
int i;
|
||||
for(i=0;i<myMod.ndac;i++)
|
||||
setDAC((enum detDacIndex)i,myMod.dacs[i],myMod.module,0,retval);
|
||||
@ -415,13 +418,13 @@ int setModule(sls_detector_module myMod){
|
||||
Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(),tt);
|
||||
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int getModule(sls_detector_module *myMod){
|
||||
int i;
|
||||
int retval[2];
|
||||
int i;
|
||||
int retval[2];
|
||||
|
||||
//dacs
|
||||
for(i=0;i<NDAC;i++)
|
||||
@ -448,10 +451,10 @@ int retval[2];
|
||||
}
|
||||
|
||||
//copy to local copy as well
|
||||
if (detectorModules)
|
||||
copyModule(myMod,detectorModules);
|
||||
else
|
||||
return FAIL;
|
||||
if (detectorModules)
|
||||
copyModule(myMod,detectorModules);
|
||||
else
|
||||
return FAIL;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -483,17 +486,15 @@ enum detectorSettings setSettings(enum detectorSettings sett, int imod){
|
||||
|
||||
|
||||
int startReceiver(int d){
|
||||
//if(trialMasterMode == IS_MASTER)
|
||||
if(!bottom)
|
||||
if(master)
|
||||
Feb_Control_PrepareForAcquisition();
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int startStateMachine(){
|
||||
int ret;int i=0;
|
||||
//if(trialMasterMode == IS_MASTER){
|
||||
if(!bottom){
|
||||
int ret;int i=0;
|
||||
if(master){
|
||||
printf("Going to start acquisition\n");
|
||||
Feb_Control_StartAcquisition();
|
||||
}
|
||||
@ -501,14 +502,14 @@ int ret;int i=0;
|
||||
//do not read status here, cannot get images then
|
||||
|
||||
////if(trialMasterMode == IS_MASTER){
|
||||
printf("requesting images\n");
|
||||
ret = startReadOut();
|
||||
printf("requesting images\n");
|
||||
ret = startReadOut();
|
||||
////}
|
||||
//if(trialMasterMode == IS_MASTER){
|
||||
|
||||
|
||||
if(!bottom){
|
||||
/*
|
||||
if(master){
|
||||
/*
|
||||
if(getRunStatus() == IDLE){
|
||||
for(i=0;i<100000;i++){
|
||||
usleep(1000);
|
||||
@ -522,25 +523,25 @@ int ret;int i=0;
|
||||
printf("*****Acquiring...\n");
|
||||
}
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
while(getRunStatus() == IDLE);
|
||||
printf("*****Acquiring...\n");
|
||||
while(getRunStatus() == IDLE);
|
||||
printf("*****Acquiring...\n");
|
||||
|
||||
|
||||
}
|
||||
/*else usleep(1000000);
|
||||
}
|
||||
/*else usleep(1000000);
|
||||
printf("****Returning\n");*/
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int stopStateMachine(){
|
||||
//if(trialMasterMode == IS_MASTER){
|
||||
printf("Going to stop acquisition\n");
|
||||
if(Feb_Control_StopAcquisition())
|
||||
return OK;
|
||||
printf("Going to stop acquisition\n");
|
||||
if(Feb_Control_StopAcquisition())
|
||||
return OK;
|
||||
//}else return OK;
|
||||
|
||||
return FAIL;
|
||||
@ -551,26 +552,26 @@ int startReadOut(){
|
||||
//RequestImages();
|
||||
int ret_val = 0;
|
||||
dst_requested[0] = 1;
|
||||
while(dst_requested[on_dst]){
|
||||
//waits on data
|
||||
int beb_num = BEB_NUM;//Feb_Control_GetModuleNumber();
|
||||
while(dst_requested[on_dst]){
|
||||
//waits on data
|
||||
int beb_num = BEB_NUM;//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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
if(ret_val)
|
||||
return FAIL;
|
||||
else
|
||||
return OK;
|
||||
if(ret_val)
|
||||
return FAIL;
|
||||
else
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
enum runStatus getRunStatus(){
|
||||
//if(trialMasterMode == IS_MASTER){
|
||||
//if(trialMasterMode == IS_MASTER){
|
||||
int i = Feb_Control_AcquisitionInProgress();
|
||||
if(i== 0){
|
||||
//printf("IDLE\n");
|
||||
@ -579,7 +580,7 @@ enum runStatus getRunStatus(){
|
||||
printf("RUNNING\n");
|
||||
return RUNNING;
|
||||
}
|
||||
//}else printf("***** not master*** \n");
|
||||
//}else printf("***** not master*** \n");
|
||||
|
||||
return IDLE;
|
||||
}
|
||||
@ -610,9 +611,9 @@ int64_t setTimer(enum timerIndex ind, int64_t val){
|
||||
if(Feb_Control_SetNExposures((unsigned int)val*eiger_ncycles)){
|
||||
eiger_nexposures = val;
|
||||
//SetDestinationParameters(EigerGetNumberOfExposures()*EigerGetNumberOfCycles());
|
||||
on_dst = 0;
|
||||
int i;
|
||||
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
|
||||
on_dst = 0;
|
||||
int i;
|
||||
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
|
||||
ndsts_in_use = 1;
|
||||
nimages_per_request = eiger_nexposures * eiger_ncycles;
|
||||
}
|
||||
@ -628,7 +629,7 @@ int64_t setTimer(enum timerIndex ind, int64_t val){
|
||||
printf(" Setting acq period: %fs\n",val/(1E9));
|
||||
Feb_Control_SetExposurePeriod(val/(1E9));
|
||||
}return (Feb_Control_GetExposurePeriod()*(1E9));
|
||||
/* case DELAY_AFTER_TRIGGER:
|
||||
/* case DELAY_AFTER_TRIGGER:
|
||||
if(val >= 0)
|
||||
EigerSetNumberOfExposures((unsigned int)val);
|
||||
return EigerGetNumberOfExposures();
|
||||
@ -648,9 +649,9 @@ int64_t setTimer(enum timerIndex ind, int64_t val){
|
||||
if(Feb_Control_SetNExposures((unsigned int)val*eiger_nexposures)){
|
||||
eiger_ncycles = val;
|
||||
//SetDestinationParameters(EigerGetNumberOfExposures()*EigerGetNumberOfCycles());
|
||||
on_dst = 0;
|
||||
int i;
|
||||
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
|
||||
on_dst = 0;
|
||||
int i;
|
||||
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
|
||||
nimages_per_request = eiger_nexposures * eiger_ncycles;
|
||||
}
|
||||
}return eiger_ncycles;
|
||||
@ -678,12 +679,12 @@ int setDynamicRange(int dr){
|
||||
if(Feb_Control_SetDynamicRange(dr)){
|
||||
|
||||
//EigerSetBitMode(dr);
|
||||
on_dst = 0;
|
||||
int i;
|
||||
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");
|
||||
on_dst = 0;
|
||||
int i;
|
||||
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
|
||||
@ -714,7 +715,7 @@ enum readOutFlags setReadOutFlags(enum readOutFlags val){
|
||||
default:ret=-1; break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@ -748,17 +749,17 @@ int configureMAC(int ipad, long long int macad, long long int detectormacadd, in
|
||||
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),
|
||||
(unsigned int)((detectormacadd>>32)&0xFF),
|
||||
(unsigned int)((detectormacadd>>24)&0xFF),
|
||||
(unsigned int)((detectormacadd>>16)&0xFF),
|
||||
(unsigned int)((detectormacadd>>8)&0xFF),
|
||||
(unsigned int)((detectormacadd>>0)&0xFF));
|
||||
(unsigned int)((detectormacadd>>32)&0xFF),
|
||||
(unsigned int)((detectormacadd>>24)&0xFF),
|
||||
(unsigned int)((detectormacadd>>16)&0xFF),
|
||||
(unsigned int)((detectormacadd>>8)&0xFF),
|
||||
(unsigned int)((detectormacadd>>0)&0xFF));
|
||||
sprintf(dst_mac,"%02x:%02x:%02x:%02x:%02x:%02x",(unsigned int)((macad>>40)&0xFF),
|
||||
(unsigned int)((macad>>32)&0xFF),
|
||||
(unsigned int)((macad>>24)&0xFF),
|
||||
(unsigned int)((macad>>16)&0xFF),
|
||||
(unsigned int)((macad>>8)&0xFF),
|
||||
(unsigned int)((macad>>0)&0xFF));
|
||||
(unsigned int)((macad>>32)&0xFF),
|
||||
(unsigned int)((macad>>24)&0xFF),
|
||||
(unsigned int)((macad>>16)&0xFF),
|
||||
(unsigned int)((macad>>8)&0xFF),
|
||||
(unsigned int)((macad>>0)&0xFF));
|
||||
|
||||
printf("src_port:%d\n",src_port);
|
||||
printf("src_ip:%s\n",src_ip);
|
||||
@ -775,27 +776,27 @@ int configureMAC(int ipad, long long int macad, long long int detectormacadd, in
|
||||
|
||||
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;
|
||||
/*}*/
|
||||
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;
|
||||
/*}*/
|
||||
|
||||
header_number = 32;
|
||||
dst_port = udpport2;
|
||||
printf("dst_port:%d\n\n",dst_port);
|
||||
|
||||
/*for(i=0;i<32;i++){*//** modified for Aldo*/
|
||||
if(Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) &&
|
||||
Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port))
|
||||
printf("set up right ok\n\n");
|
||||
else return -1;
|
||||
/*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\n");
|
||||
else return -1;
|
||||
/*}*/
|
||||
|
||||
on_dst = 0;
|
||||
on_dst = 0;
|
||||
|
||||
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
|
||||
nimages_per_request=eiger_nexposures * eiger_ncycles;
|
||||
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
|
||||
nimages_per_request=eiger_nexposures * eiger_ncycles;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -947,8 +948,8 @@ enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){
|
||||
void setExternalGating(int enable[]){
|
||||
if(enable>=0){
|
||||
Feb_Control_SetExternalEnableMode(enable[0], enable[1]);//enable = 0 or 1, polarity = 0 or 1 , where 1 is positive
|
||||
eiger_extgating = enable[0];
|
||||
eiger_extgatingpolarity = enable[1];
|
||||
eiger_extgating = enable[0];
|
||||
eiger_extgatingpolarity = enable[1];
|
||||
}
|
||||
enable[0] = eiger_extgating;
|
||||
enable[1] = eiger_extgatingpolarity;
|
||||
|
@ -49,6 +49,8 @@ XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR
|
||||
#define XPAR_PLB_GPIO_SYS_BASEADDR 0xD1000000
|
||||
#define XPAR_PLB_GPIO_SYS_HIGHADDR 0xD100FFFF
|
||||
|
||||
/* Master Slave Top Bottom Definition */
|
||||
#define MODULE_CONFIGURATION 0x84
|
||||
|
||||
/* Definitions for peripheral PLB_GPIO_TEST */
|
||||
#define XPAR_PLB_GPIO_TEST_BASEADDR 0xD1010000
|
||||
@ -60,7 +62,7 @@ XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR
|
||||
#define XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_HIGHADDR 0xC410FFFF
|
||||
|
||||
/* Definitions for a new memory */
|
||||
#define XPAR_PLB_LL_NEW_MEMORY 0xC4200000
|
||||
//#define XPAR_PLB_LL_NEW_MEMORY 0xD1000000//0xD1000084//0xC4200000
|
||||
|
||||
|
||||
/* Definitions for peripheral PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT */
|
||||
|
@ -4542,7 +4542,7 @@ int* multiSlsDetector::readFrameFromReceiver(char* fName, int &fIndex){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int n;
|
||||
int n,complete=OK;
|
||||
int i,k,offsetX, offsetY, maxX, maxY; double dr;
|
||||
int* retval=new int[nel];
|
||||
int *retdet, *p=retval;
|
||||
@ -4560,42 +4560,45 @@ int* multiSlsDetector::readFrameFromReceiver(char* fName, int &fIndex){
|
||||
retdet=detectors[id]->readFrameFromReceiver(fName,fIndex);
|
||||
if(detectors[id]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<id));
|
||||
if ((retdet) &&(fIndex!=-1)) {
|
||||
n=detectors[id]->getDataBytes();
|
||||
|
||||
if(getDetectorsType() == EIGER){
|
||||
//cout << "fname:"<<fName<<" findex:"<<fIndex<<endl;
|
||||
//cout<<"n:"<<n<<endl;
|
||||
//cout<<"maxchan:"<<detectors[id]->getMaxNumberOfChannels()<<" n:"<<n<<endl;
|
||||
dr = (double)n/detectors[id]->getMaxNumberOfChannels();
|
||||
//cout << "dr:"<<dr<<endl;
|
||||
k=(int)(detectors[id]->getMaxNumberOfChannels(X)*dr);//bit mode
|
||||
//cout << "k:"<<k<<endl;
|
||||
offsetY = (int)(((maxY - (thisMultiDetector->offsetY[id] + detectors[id]->getMaxNumberOfChannels(Y))) * maxX)*dr);//bit mode
|
||||
offsetX = (int)(thisMultiDetector->offsetX[id]*dr);
|
||||
//cout << "offsetY"<<offsetY<< " offsetX:"<<offsetX<<endl;
|
||||
if (retdet){
|
||||
if (fIndex==-1)
|
||||
complete = FAIL;
|
||||
else{
|
||||
n=detectors[id]->getDataBytes();
|
||||
if(getDetectorsType() == EIGER){
|
||||
//cout << "fname:"<<fName<<" findex:"<<fIndex<<endl;
|
||||
//cout<<"n:"<<n<<endl;
|
||||
//cout<<"maxchan:"<<detectors[id]->getMaxNumberOfChannels()<<" n:"<<n<<endl;
|
||||
dr = (double)n/detectors[id]->getMaxNumberOfChannels();
|
||||
//cout << "dr:"<<dr<<endl;
|
||||
k=(int)(detectors[id]->getMaxNumberOfChannels(X)*dr);//bit mode
|
||||
//cout << "k:"<<k<<endl;
|
||||
offsetY = (int)(((maxY - (thisMultiDetector->offsetY[id] + detectors[id]->getMaxNumberOfChannels(Y))) * maxX)*dr);//bit mode
|
||||
offsetX = (int)(thisMultiDetector->offsetX[id]*dr);
|
||||
//cout << "offsetY"<<offsetY<< " offsetX:"<<offsetX<<endl;
|
||||
for(i=0; i< 256;i++){
|
||||
memcpy((((char*)p) + offsetY + offsetX + ((int)(i*maxX*dr))) ,(((char*)retdet) + (i*k)),k);//bit mode
|
||||
}
|
||||
}
|
||||
else{
|
||||
memcpy(p,retdet,n);
|
||||
p+=n/sizeof(int);
|
||||
}
|
||||
delete [] retdet;
|
||||
//concatenate filenames
|
||||
if(!fullFName.length()){
|
||||
fullFName.assign(fileIO::getFileName());
|
||||
if (strrchr(fName,'.')!=NULL){
|
||||
ext.assign(fName);
|
||||
size_t dot = ext.rfind(".");
|
||||
if(dot != string::npos)
|
||||
ext = ext.erase(0,dot);
|
||||
else
|
||||
ext = "";
|
||||
}
|
||||
else{
|
||||
memcpy(p,retdet,n);
|
||||
p+=n/sizeof(int);
|
||||
}
|
||||
delete [] retdet;
|
||||
//concatenate filenames
|
||||
if(!fullFName.length()){
|
||||
fullFName.assign(fileIO::getFileName());
|
||||
if (strrchr(fName,'.')!=NULL){
|
||||
ext.assign(fName);
|
||||
size_t dot = ext.rfind(".");
|
||||
if(dot != string::npos)
|
||||
ext = ext.erase(0,dot);
|
||||
else
|
||||
ext = "";
|
||||
}
|
||||
}
|
||||
fullFName.append(getReceiverFileNameToConcatenate(fName));
|
||||
}
|
||||
fullFName.append(getReceiverFileNameToConcatenate(fName));
|
||||
}else {
|
||||
#ifdef VERBOSE
|
||||
cout << "Receiver for detector " << id << " does not have data left " << endl;
|
||||
@ -4607,6 +4610,9 @@ int* multiSlsDetector::readFrameFromReceiver(char* fName, int &fIndex){
|
||||
}
|
||||
fullFName.append(ext);
|
||||
strcpy(fName,fullFName.c_str());
|
||||
//if some of the receivers did not give data, dont count it
|
||||
if((getDetectorsType() == EIGER) &&(complete ==FAIL))
|
||||
fIndex = -1;
|
||||
return retval;
|
||||
};
|
||||
|
||||
|
@ -342,14 +342,26 @@ void slsDetectorUtils::acquire(int delflag){
|
||||
}
|
||||
pthread_mutex_unlock(&mg);
|
||||
}else{
|
||||
|
||||
pthread_mutex_lock(&mg);
|
||||
startReceiverReadout();
|
||||
acquiringDone = 1;
|
||||
pthread_mutex_unlock(&mg);
|
||||
|
||||
// wait until data processing thread has taken the last frame
|
||||
if (*threadedProcessing) {
|
||||
sem_wait(&sem_queue);
|
||||
pthread_mutex_lock(&mg);
|
||||
acquiringDone = 0;
|
||||
pthread_mutex_unlock(&mg);
|
||||
}
|
||||
pthread_mutex_lock(&mg);
|
||||
/* startReceiverReadout();
|
||||
while(getReceiverStatus() != RUN_FINISHED){
|
||||
pthread_mutex_unlock(&mg);
|
||||
usleep(50000);
|
||||
pthread_mutex_lock(&mg);
|
||||
}
|
||||
|
||||
*/
|
||||
stopReceiver();
|
||||
pthread_mutex_unlock(&mg);
|
||||
}
|
||||
|
@ -522,6 +522,7 @@ void* postProcessing::processData(int delflag) {
|
||||
cout<<flush;
|
||||
usleep(20000);
|
||||
|
||||
|
||||
//get progress
|
||||
pthread_mutex_lock(&mg);
|
||||
if(setReceiverOnline() == ONLINE_FLAG)
|
||||
@ -532,7 +533,27 @@ void* postProcessing::processData(int delflag) {
|
||||
if(currentfIndex != -1)
|
||||
setCurrentProgress(currentfIndex+1);
|
||||
|
||||
if (checkJoinThread()) break;
|
||||
/** IF detector acquisition is done, let the acquire() thread know to finish up and force join thread */
|
||||
if(acquiringDone == 1){
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout << "acquiring seems to be done" << endl;
|
||||
#endif
|
||||
//so that only once it checks for last frame and then next time, checks join thread
|
||||
pthread_mutex_lock(&mg);
|
||||
acquiringDone = 2;
|
||||
pthread_mutex_unlock(&mg);
|
||||
//newData = true;
|
||||
}else if (acquiringDone == 2){
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout << "gonna post for it to end" << endl;
|
||||
#endif
|
||||
sem_post(&sem_queue);
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout << "Sem posted" << endl;
|
||||
#endif
|
||||
//newData = false;
|
||||
}else if (checkJoinThread())
|
||||
break;
|
||||
|
||||
|
||||
if (dataReady){
|
||||
@ -544,6 +565,9 @@ void* postProcessing::processData(int delflag) {
|
||||
}
|
||||
|
||||
if(newData){
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout << "new data" << endl;
|
||||
#endif
|
||||
if(setReceiverOnline()==ONLINE_FLAG){
|
||||
//get data
|
||||
strcpy(currentfName,"");
|
||||
@ -569,6 +593,9 @@ void* postProcessing::processData(int delflag) {
|
||||
|
||||
//not garbage frame
|
||||
if (currentfIndex >= 0) {
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout<<"GOT data"<<endl;
|
||||
#endif
|
||||
fdata = decodeData(receiverData);
|
||||
delete [] receiverData;
|
||||
if ((fdata) && (dataReady)){
|
||||
@ -578,13 +605,21 @@ void* postProcessing::processData(int delflag) {
|
||||
delete thisData;
|
||||
fdata = NULL;
|
||||
progress = currentfIndex;
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout << "progress:" << progress << endl;
|
||||
#endif
|
||||
/*if(!nthframe) //unnecessary to read every data, 09.12.2014**/
|
||||
newData = false;
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
cout << "newData set to false" << endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef VERY_VERY_DEBUG
|
||||
else{
|
||||
;//cout<<"****Detector returned mismatched indices/garbage or acquisition is over. Trying again.***"<<endl;
|
||||
cout<<"****Detector returned mismatched indices/garbage or acquisition is over. Trying again.***"<<endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,9 @@ Here are the definitions, but the actual implementation should be done for each
|
||||
|
||||
|
||||
|
||||
|
||||
void getModuleConfiguration();
|
||||
int initDetector();
|
||||
int initDetectorStop();
|
||||
|
||||
int setNMod(int nm, enum dimension dim);
|
||||
int getNModBoard(enum dimension arg);
|
||||
|
@ -64,6 +64,8 @@ int main(int argc, char *argv[]){
|
||||
#endif
|
||||
|
||||
|
||||
printf("\nReady...\n\n");
|
||||
|
||||
/* waits for connection */
|
||||
while(retval!=GOODBYE) {
|
||||
#ifdef VERBOSE
|
||||
|
@ -47,18 +47,11 @@ int init_detector(int b) {
|
||||
#ifdef VIRTUAL
|
||||
printf("This is a VIRTUAL detector\n");
|
||||
#endif
|
||||
//only for control server
|
||||
if(b){
|
||||
|
||||
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||
initDetector();
|
||||
if(b) initDetector();
|
||||
else initDetectorStop();
|
||||
#endif
|
||||
}else{
|
||||
Feb_Interface_FebInterface();
|
||||
Feb_Control_Init();
|
||||
// printf("FEb control constructor done\n");
|
||||
/* Beb_Beb(-1);
|
||||
printf("BEB constructor done\n");*/
|
||||
}
|
||||
strcpy(mess,"dummy message");
|
||||
strcpy(lastClientIP,"none");
|
||||
strcpy(thisClientIP,"none1");
|
||||
|
Loading…
x
Reference in New Issue
Block a user