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 <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
|
||||||
#include "xfs_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_ndata = 0;
|
||||||
Beb_send_buffer_size = 1026;
|
Beb_send_buffer_size = 1026;
|
||||||
@ -137,14 +137,32 @@ void Beb_Beb(int arg1){
|
|||||||
|
|
||||||
Beb_SetByteOrder();
|
Beb_SetByteOrder();
|
||||||
|
|
||||||
/*
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
ll_beb_new_memory = &ll_beb_new_memory_local;
|
||||||
Local_LocalLinkInterface(ll_beb_new_memory);
|
Local_LocalLinkInterface(ll_beb_new_memory);
|
||||||
if(!Local_InitNewMemory(ll_beb_new_memory,XPAR_PLB_LL_NEW_MEMORY, arg1))
|
int ret = Local_GetModuleConfiguration(ll_beb_new_memory,XPAR_PLB_GPIO_SYS_BASEADDR, MODULE_CONFIGURATION);
|
||||||
printf("New Memory FAIL\n");
|
if(!ret)
|
||||||
else
|
printf("Module Configuration FAIL\n");
|
||||||
printf("New Memory OK\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();
|
void Beb_ClearBebInfos();
|
||||||
int Beb_InitBebInfos();
|
int Beb_InitBebInfos();
|
||||||
int Beb_ReadSetUpFromFile(char* file_name);
|
int Beb_ReadSetUpFromFile(char* file_name);
|
||||||
@ -67,9 +65,7 @@ struct BebInfo{
|
|||||||
int Beb_SetByteOrder();
|
int Beb_SetByteOrder();
|
||||||
|
|
||||||
|
|
||||||
|
void Beb_Beb();
|
||||||
|
|
||||||
void Beb_Beb(int arg1);
|
|
||||||
|
|
||||||
|
|
||||||
int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig, char* src_mac, char* src_ip, unsigned int src_port);
|
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;
|
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_current_index;
|
||||||
int Feb_Control_am_i_master;
|
|
||||||
|
|
||||||
void Module_Module(struct Module* mod,unsigned int number, unsigned int address_top){
|
void Module_Module(struct Module* mod,unsigned int number, unsigned int address_top){
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@ -151,85 +151,29 @@ int Feb_Control_IsBottomModule(){
|
|||||||
|
|
||||||
|
|
||||||
int Feb_Control_GetModuleNumber(){
|
int Feb_Control_GetModuleNumber(){
|
||||||
return Feb_Control_current_mod;
|
return Feb_Control_module_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Feb_Control_FebControl(){
|
void Feb_Control_FebControl(){
|
||||||
|
|
||||||
Feb_Control_staticBits=Feb_Control_acquireNReadoutMode=Feb_Control_triggerMode=Feb_Control_externalEnableMode=Feb_Control_subFrameMode=0;
|
Feb_Control_staticBits=Feb_Control_acquireNReadoutMode=Feb_Control_triggerMode=Feb_Control_externalEnableMode=Feb_Control_subFrameMode=0;
|
||||||
|
|
||||||
Feb_Control_trimbit_size=263680;
|
Feb_Control_trimbit_size=263680;
|
||||||
Feb_Control_last_downloaded_trimbits = malloc(Feb_Control_trimbit_size * sizeof(int));
|
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");;
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Feb_Control_ClearModules(){
|
|
||||||
unsigned int i;
|
|
||||||
//for(i=0;i<moduleSize;i++) free(modules[i]);
|
|
||||||
moduleSize = 0;
|
moduleSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Feb_Control_Init(){
|
|
||||||
|
|
||||||
|
|
||||||
|
int Feb_Control_Init(int master, int top){
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
Feb_Control_ClearModules();
|
Feb_Control_module_number = 0;
|
||||||
///*
|
|
||||||
Feb_Control_current_mod = 0;
|
|
||||||
Feb_Control_current_index = 0;
|
Feb_Control_current_index = 0;
|
||||||
Feb_Control_AddModule(0,0xff);//global send
|
|
||||||
|
|
||||||
|
//global send
|
||||||
|
Feb_Control_AddModule1(0,1,0xff,0,1);
|
||||||
Feb_Control_PrintModuleList();
|
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++){
|
|
||||||
char st[2000];
|
|
||||||
sprintf(st,"setup_mod%04d.txt",Module_GetModuleNumber(&modules[i]));
|
|
||||||
Feb_Control_ReadSetUpFile(Module_GetModuleNumber(&modules[i]),st);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//get module nummber
|
//get module nummber
|
||||||
int res=0;
|
int res=0;
|
||||||
char hostname[100];
|
char hostname[100];
|
||||||
@ -237,38 +181,66 @@ int Feb_Control_Init(){
|
|||||||
puts(hostname);
|
puts(hostname);
|
||||||
else
|
else
|
||||||
perror("gethostname");
|
perror("gethostname");
|
||||||
|
|
||||||
char *pch;
|
char *pch;
|
||||||
pch = strtok(hostname,"0");
|
pch = strtok(hostname,"0");
|
||||||
pch = strtok(NULL,"0");
|
pch = strtok(NULL,"0");
|
||||||
sscanf(pch,"%d",&res);
|
sscanf(pch,"%d",&res);
|
||||||
|
Feb_Control_module_number = (res & 0xFF);
|
||||||
|
|
||||||
Feb_Control_current_mod = (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);
|
||||||
|
|
||||||
|
Feb_Control_current_index = 1;
|
||||||
|
|
||||||
for(i=1;i<moduleSize;i++){
|
/*for(i=1;i<moduleSize;i++){
|
||||||
if(Module_GetModuleNumber(&modules[i])==Feb_Control_current_mod)
|
if(Module_GetModuleNumber(&modules[i])==Feb_Control_module_number)
|
||||||
Feb_Control_current_index = i;
|
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");
|
//Add the half module
|
||||||
printf("Done setting detector defaults\n");*/
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
void Feb_Control_Set_Master(){
|
void Feb_Control_Set_Master(){
|
||||||
Feb_Control_am_i_master = 1;
|
Feb_Control_am_i_master = 1;
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
unsigned int halfmastermodule = 0x80000000;
|
unsigned int halfmastermodule = 0x80000000;
|
||||||
unsigned int reg_nums[1];
|
unsigned int reg_nums[1];
|
||||||
unsigned int reg_vals[1];
|
unsigned int reg_vals[1];
|
||||||
@ -280,12 +252,9 @@ void Feb_Control_Set_Master(){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
printf("master is set\n");
|
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){
|
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;
|
int parameters_ok = 1;
|
||||||
unsigned int pre_module_index = 0;
|
unsigned int pre_module_index = 0;
|
||||||
if(Feb_Control_GetModuleIndex(module_number,&pre_module_index)){
|
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);
|
/* if((half_module)&& (top_address != 1)) Module_Module(m,module_number,top_address);
|
||||||
else if(half_module) Module_ModuleBottom(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 if (half_module) Module_ModuleBottom(m,module_number,bottom_address);
|
||||||
else Module_Module1(m,module_number,top_address,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){
|
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){
|
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_IsBottomModule();
|
||||||
int Feb_Control_GetModuleNumber();
|
int Feb_Control_GetModuleNumber();
|
||||||
void Feb_Control_Set_Master();
|
|
||||||
|
|
||||||
void Feb_Control_ClearModules();
|
|
||||||
|
|
||||||
|
|
||||||
void Feb_Control_PrintModuleList();
|
void Feb_Control_PrintModuleList();
|
||||||
@ -77,7 +76,7 @@ void Feb_Control_Set_Master();
|
|||||||
int Feb_Control_CheckModuleAddresses(struct Module* m);
|
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);
|
||||||
/*int Feb_Control_AddModule(unsigned int module_number, unsigned int top_address, unsigned int bottom_address, int half_module=0);*/
|
/*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_GetDACNumber(char* s, unsigned int* n);
|
||||||
int Feb_Control_SendDACValue(unsigned int dst_num, unsigned int ch, unsigned int* value);
|
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();
|
void Feb_Control_FebControl();
|
||||||
|
int Feb_Control_Init(int master, int top);
|
||||||
|
|
||||||
int Feb_Control_Init();
|
|
||||||
int Feb_Control_ReadSetUpFileToAddModules(char* file_name);
|
int Feb_Control_ReadSetUpFileToAddModules(char* file_name);
|
||||||
int Feb_Control_ReadSetUpFile(unsigned int module_num, char* file_name);
|
int Feb_Control_ReadSetUpFile(unsigned int module_num, char* file_name);
|
||||||
int Feb_Control_CheckSetup();
|
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_countdown-=n_to_send;
|
||||||
ndata_sent +=n_to_send;
|
ndata_sent +=n_to_send;
|
||||||
start_address +=n_to_send;
|
start_address +=n_to_send;
|
||||||
usleep(0);//500 works
|
usleep(500);//500 works
|
||||||
}
|
}
|
||||||
return passed;
|
return passed;
|
||||||
}
|
}
|
||||||
|
@ -25,51 +25,36 @@ Local_LocalLinkInterface1(struct LocalLinkInterface* ll,unsigned int ll_fifo_bad
|
|||||||
Local_Reset(ll);
|
Local_Reset(ll);
|
||||||
printf("\tFIFO Status : 0x%08x\n",Local_StatusVector(ll));
|
printf("\tFIFO Status : 0x%08x\n",Local_StatusVector(ll));
|
||||||
}else printf("\tError LocalLink Mappping : 0x%08x\n",ll_fifo_badr);
|
}else printf("\tError LocalLink Mappping : 0x%08x\n",ll_fifo_badr);
|
||||||
|
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*~LocalLinkInterface(){};*/
|
/*~LocalLinkInterface(){};*/
|
||||||
|
|
||||||
Local_LocalLinkInterface(struct LocalLinkInterface* ll){
|
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){
|
int Local_GetModuleConfiguration (struct LocalLinkInterface* ll, u_int32_t baseaddr, u_int32_t offset){
|
||||||
unsigned int CSP0BASE;
|
int fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
|
||||||
int fd;
|
|
||||||
|
|
||||||
/*fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
|
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
printf("\nCan't find /dev/mem!\n");
|
printf("\nCan't find /dev/mem!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
printf("/dev/mem opened\n");
|
printf("/dev/mem opened\n");
|
||||||
|
|
||||||
|
u_int32_t CSP0BASE = (u_int32_t)mmap(0, 0x100000, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, baseaddr);
|
||||||
CSP0BASE = (u_int32_t)mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, addr);
|
|
||||||
if (CSP0BASE == (u_int32_t)MAP_FAILED) {
|
if (CSP0BASE == (u_int32_t)MAP_FAILED) {
|
||||||
printf("\nCan't map memmory area!!\n");
|
printf("\nCan't map memmory area!!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
printf("CSP0 mapped\n");
|
printf("CSP0 mapped\n");
|
||||||
|
|
||||||
|
volatile u_int32_t *ptr1;
|
||||||
volatile u_int8_t *ptr1;
|
ptr1=(u_int32_t*)(CSP0BASE + offset);
|
||||||
|
//printf("LocalLinkInterface:: value:%d\n",*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);
|
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
*/
|
|
||||||
return 1;
|
return *ptr1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "xfs_types.h"
|
#include "xfs_types.h"
|
||||||
#include "HardwareIO.h"
|
#include "HardwareIO.h"
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
/*class LocalLinkInterface: public HardwareIO{ //*/
|
/*class LocalLinkInterface: public HardwareIO{ //*/
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ struct LocalLinkInterface{
|
|||||||
int Local_Test(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer);
|
int Local_Test(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer);
|
||||||
|
|
||||||
void Local_LocalLinkInterface(struct LocalLinkInterface* ll);
|
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);
|
int FiFoReset(unsigned int numb);
|
||||||
|
Binary file not shown.
@ -56,9 +56,10 @@ 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};
|
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;
|
enum masterFlags masterMode=IS_SLAVE;
|
||||||
int bottom = 0;
|
int top = 0;
|
||||||
//enum masterFlags trialMasterMode=NO_MASTER;
|
int master = 0;
|
||||||
|
|
||||||
|
|
||||||
int initDetector(){
|
int initDetector(){
|
||||||
int imod,i,n;
|
int imod,i,n;
|
||||||
@ -71,6 +72,7 @@ int initDetector(){
|
|||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
|
//Allocation of memory
|
||||||
detectorModules=malloc(n*sizeof(sls_detector_module));
|
detectorModules=malloc(n*sizeof(sls_detector_module));
|
||||||
detectorChips=malloc(n*NCHIP*sizeof(int));
|
detectorChips=malloc(n*NCHIP*sizeof(int));
|
||||||
|
|
||||||
@ -107,23 +109,22 @@ int initDetector(){
|
|||||||
sAdc=noneSelected;
|
sAdc=noneSelected;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//Feb and Beb Initializations
|
||||||
|
getModuleConfiguration();
|
||||||
Feb_Interface_FebInterface();
|
Feb_Interface_FebInterface();
|
||||||
Feb_Control_FebControl();
|
Feb_Control_FebControl();
|
||||||
Feb_Control_Init();
|
Feb_Control_Init(master,top);
|
||||||
printf("FEb control constructor done\n");
|
printf("FEB Initialization done\n");
|
||||||
Beb_Beb(-1);
|
Beb_Beb();
|
||||||
printf("BEB constructor done\n");
|
printf("BEB Initialization done\n");
|
||||||
|
|
||||||
//get dac values
|
//Get dac values
|
||||||
int retval[2];
|
int retval[2];
|
||||||
for(i=0;i<(detectorModules)->ndac;i++)
|
for(i=0;i<(detectorModules)->ndac;i++)
|
||||||
setDAC((enum detDacIndex)i,default_dac_values[i],(detectorModules)->module,0,retval);
|
setDAC((enum detDacIndex)i,default_dac_values[i],(detectorModules)->module,0,retval);
|
||||||
|
|
||||||
|
|
||||||
/* initialize dynamic range etc. */
|
//setting default measurement parameters
|
||||||
|
|
||||||
|
|
||||||
//set number of frames to 1
|
|
||||||
setTimer(FRAME_NUMBER,1);
|
setTimer(FRAME_NUMBER,1);
|
||||||
setTimer(ACQUISITION_TIME,1E9);
|
setTimer(ACQUISITION_TIME,1E9);
|
||||||
setTimer(FRAME_PERIOD,1E9);
|
setTimer(FRAME_PERIOD,1E9);
|
||||||
@ -134,40 +135,42 @@ int initDetector(){
|
|||||||
setHighVolage(150,0);
|
setHighVolage(150,0);
|
||||||
setIODelay(675,0);
|
setIODelay(675,0);
|
||||||
setTiming(AUTO_TIMING);
|
setTiming(AUTO_TIMING);
|
||||||
//setMaster(GET_MASTER);
|
//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};
|
int enable[2] = {0,1};
|
||||||
setExternalGating(enable);//disable external gating
|
setExternalGating(enable);//disable external gating
|
||||||
|
|
||||||
Feb_Control_SetTestModeVariable(0);
|
Feb_Control_SetTestModeVariable(0);
|
||||||
|
|
||||||
Feb_Control_CheckSetup();
|
Feb_Control_CheckSetup();
|
||||||
|
|
||||||
//top or bottom
|
printf("\n");
|
||||||
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;
|
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){
|
int setNMod(int nm, enum dimension dim){
|
||||||
return 1;
|
return 1;
|
||||||
@ -483,8 +486,7 @@ enum detectorSettings setSettings(enum detectorSettings sett, int imod){
|
|||||||
|
|
||||||
|
|
||||||
int startReceiver(int d){
|
int startReceiver(int d){
|
||||||
//if(trialMasterMode == IS_MASTER)
|
if(master)
|
||||||
if(!bottom)
|
|
||||||
Feb_Control_PrepareForAcquisition();
|
Feb_Control_PrepareForAcquisition();
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -492,8 +494,7 @@ int startReceiver(int d){
|
|||||||
|
|
||||||
int startStateMachine(){
|
int startStateMachine(){
|
||||||
int ret;int i=0;
|
int ret;int i=0;
|
||||||
//if(trialMasterMode == IS_MASTER){
|
if(master){
|
||||||
if(!bottom){
|
|
||||||
printf("Going to start acquisition\n");
|
printf("Going to start acquisition\n");
|
||||||
Feb_Control_StartAcquisition();
|
Feb_Control_StartAcquisition();
|
||||||
}
|
}
|
||||||
@ -507,7 +508,7 @@ int ret;int i=0;
|
|||||||
//if(trialMasterMode == IS_MASTER){
|
//if(trialMasterMode == IS_MASTER){
|
||||||
|
|
||||||
|
|
||||||
if(!bottom){
|
if(master){
|
||||||
/*
|
/*
|
||||||
if(getRunStatus() == IDLE){
|
if(getRunStatus() == IDLE){
|
||||||
for(i=0;i<100000;i++){
|
for(i=0;i<100000;i++){
|
||||||
|
@ -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_BASEADDR 0xD1000000
|
||||||
#define XPAR_PLB_GPIO_SYS_HIGHADDR 0xD100FFFF
|
#define XPAR_PLB_GPIO_SYS_HIGHADDR 0xD100FFFF
|
||||||
|
|
||||||
|
/* Master Slave Top Bottom Definition */
|
||||||
|
#define MODULE_CONFIGURATION 0x84
|
||||||
|
|
||||||
/* Definitions for peripheral PLB_GPIO_TEST */
|
/* Definitions for peripheral PLB_GPIO_TEST */
|
||||||
#define XPAR_PLB_GPIO_TEST_BASEADDR 0xD1010000
|
#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
|
#define XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_HIGHADDR 0xC410FFFF
|
||||||
|
|
||||||
/* Definitions for a new memory */
|
/* 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 */
|
/* Definitions for peripheral PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT */
|
||||||
|
@ -4542,7 +4542,7 @@ int* multiSlsDetector::readFrameFromReceiver(char* fName, int &fIndex){
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int n;
|
int n,complete=OK;
|
||||||
int i,k,offsetX, offsetY, maxX, maxY; double dr;
|
int i,k,offsetX, offsetY, maxX, maxY; double dr;
|
||||||
int* retval=new int[nel];
|
int* retval=new int[nel];
|
||||||
int *retdet, *p=retval;
|
int *retdet, *p=retval;
|
||||||
@ -4560,9 +4560,11 @@ int* multiSlsDetector::readFrameFromReceiver(char* fName, int &fIndex){
|
|||||||
retdet=detectors[id]->readFrameFromReceiver(fName,fIndex);
|
retdet=detectors[id]->readFrameFromReceiver(fName,fIndex);
|
||||||
if(detectors[id]->getErrorMask())
|
if(detectors[id]->getErrorMask())
|
||||||
setErrorMask(getErrorMask()|(1<<id));
|
setErrorMask(getErrorMask()|(1<<id));
|
||||||
if ((retdet) &&(fIndex!=-1)) {
|
if (retdet){
|
||||||
|
if (fIndex==-1)
|
||||||
|
complete = FAIL;
|
||||||
|
else{
|
||||||
n=detectors[id]->getDataBytes();
|
n=detectors[id]->getDataBytes();
|
||||||
|
|
||||||
if(getDetectorsType() == EIGER){
|
if(getDetectorsType() == EIGER){
|
||||||
//cout << "fname:"<<fName<<" findex:"<<fIndex<<endl;
|
//cout << "fname:"<<fName<<" findex:"<<fIndex<<endl;
|
||||||
//cout<<"n:"<<n<<endl;
|
//cout<<"n:"<<n<<endl;
|
||||||
@ -4596,6 +4598,7 @@ int* multiSlsDetector::readFrameFromReceiver(char* fName, int &fIndex){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fullFName.append(getReceiverFileNameToConcatenate(fName));
|
fullFName.append(getReceiverFileNameToConcatenate(fName));
|
||||||
|
}
|
||||||
}else {
|
}else {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "Receiver for detector " << id << " does not have data left " << endl;
|
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);
|
fullFName.append(ext);
|
||||||
strcpy(fName,fullFName.c_str());
|
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;
|
return retval;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -342,14 +342,26 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
}
|
}
|
||||||
pthread_mutex_unlock(&mg);
|
pthread_mutex_unlock(&mg);
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
pthread_mutex_lock(&mg);
|
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){
|
while(getReceiverStatus() != RUN_FINISHED){
|
||||||
pthread_mutex_unlock(&mg);
|
pthread_mutex_unlock(&mg);
|
||||||
usleep(50000);
|
usleep(50000);
|
||||||
pthread_mutex_lock(&mg);
|
pthread_mutex_lock(&mg);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
stopReceiver();
|
stopReceiver();
|
||||||
pthread_mutex_unlock(&mg);
|
pthread_mutex_unlock(&mg);
|
||||||
}
|
}
|
||||||
|
@ -522,6 +522,7 @@ void* postProcessing::processData(int delflag) {
|
|||||||
cout<<flush;
|
cout<<flush;
|
||||||
usleep(20000);
|
usleep(20000);
|
||||||
|
|
||||||
|
|
||||||
//get progress
|
//get progress
|
||||||
pthread_mutex_lock(&mg);
|
pthread_mutex_lock(&mg);
|
||||||
if(setReceiverOnline() == ONLINE_FLAG)
|
if(setReceiverOnline() == ONLINE_FLAG)
|
||||||
@ -532,7 +533,27 @@ void* postProcessing::processData(int delflag) {
|
|||||||
if(currentfIndex != -1)
|
if(currentfIndex != -1)
|
||||||
setCurrentProgress(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){
|
if (dataReady){
|
||||||
@ -544,6 +565,9 @@ void* postProcessing::processData(int delflag) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(newData){
|
if(newData){
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
|
cout << "new data" << endl;
|
||||||
|
#endif
|
||||||
if(setReceiverOnline()==ONLINE_FLAG){
|
if(setReceiverOnline()==ONLINE_FLAG){
|
||||||
//get data
|
//get data
|
||||||
strcpy(currentfName,"");
|
strcpy(currentfName,"");
|
||||||
@ -569,6 +593,9 @@ void* postProcessing::processData(int delflag) {
|
|||||||
|
|
||||||
//not garbage frame
|
//not garbage frame
|
||||||
if (currentfIndex >= 0) {
|
if (currentfIndex >= 0) {
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
|
cout<<"GOT data"<<endl;
|
||||||
|
#endif
|
||||||
fdata = decodeData(receiverData);
|
fdata = decodeData(receiverData);
|
||||||
delete [] receiverData;
|
delete [] receiverData;
|
||||||
if ((fdata) && (dataReady)){
|
if ((fdata) && (dataReady)){
|
||||||
@ -578,13 +605,21 @@ void* postProcessing::processData(int delflag) {
|
|||||||
delete thisData;
|
delete thisData;
|
||||||
fdata = NULL;
|
fdata = NULL;
|
||||||
progress = currentfIndex;
|
progress = currentfIndex;
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
|
cout << "progress:" << progress << endl;
|
||||||
|
#endif
|
||||||
/*if(!nthframe) //unnecessary to read every data, 09.12.2014**/
|
/*if(!nthframe) //unnecessary to read every data, 09.12.2014**/
|
||||||
newData = false;
|
newData = false;
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
|
cout << "newData set to false" << endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef VERY_VERY_DEBUG
|
||||||
else{
|
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 initDetector();
|
||||||
|
int initDetectorStop();
|
||||||
|
|
||||||
int setNMod(int nm, enum dimension dim);
|
int setNMod(int nm, enum dimension dim);
|
||||||
int getNModBoard(enum dimension arg);
|
int getNModBoard(enum dimension arg);
|
||||||
|
@ -64,6 +64,8 @@ int main(int argc, char *argv[]){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
printf("\nReady...\n\n");
|
||||||
|
|
||||||
/* waits for connection */
|
/* waits for connection */
|
||||||
while(retval!=GOODBYE) {
|
while(retval!=GOODBYE) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
|
@ -47,18 +47,11 @@ int init_detector(int b) {
|
|||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
printf("This is a VIRTUAL detector\n");
|
printf("This is a VIRTUAL detector\n");
|
||||||
#endif
|
#endif
|
||||||
//only for control server
|
|
||||||
if(b){
|
|
||||||
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||||
initDetector();
|
if(b) initDetector();
|
||||||
|
else initDetectorStop();
|
||||||
#endif
|
#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(mess,"dummy message");
|
||||||
strcpy(lastClientIP,"none");
|
strcpy(lastClientIP,"none");
|
||||||
strcpy(thisClientIP,"none1");
|
strcpy(thisClientIP,"none1");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user