mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 15:20:02 +02:00
merged with developer after it merged with 2.1.1-rc(deactivate)
This commit is contained in:
commit
7ead69a761
@ -62,7 +62,9 @@ using namespace std;
|
||||
#define RATE_CORRECTION_NOT_32or16BIT 0x0000000000800000ULL
|
||||
#define RATE_CORRECTION_NO_TAU_PROVIDED 0x0000000001000000ULL
|
||||
#define PROGRAMMING_ERROR 0x0000000002000000ULL
|
||||
#define DATA_STREAMING_IN_RECEIVER 0x0000000004000000ULL
|
||||
#define RECEIVER_ACTIVATE 0x0000000004000000ULL
|
||||
#define DATA_STREAMING_IN_RECEIVER 0x0000000008000000ULL
|
||||
|
||||
// 0x00000000FFFFFFFFULL
|
||||
/** @short class returning all error messages for error mask */
|
||||
class errorDefs {
|
||||
@ -202,6 +204,9 @@ public:
|
||||
if(slsErrorMask&PROGRAMMING_ERROR)
|
||||
retval.append("Could not program FPGA\n");
|
||||
|
||||
if(slsErrorMask&RECEIVER_ACTIVATE)
|
||||
retval.append("Could not activate/deactivate receiver\n");
|
||||
|
||||
if(slsErrorMask&DATA_STREAMING_IN_RECEIVER)
|
||||
retval.append("Could not set/reset Data Streaming in Receiver\n");
|
||||
|
||||
|
@ -103,11 +103,13 @@ enum {
|
||||
F_SET_RATE_CORRECT, /** < set/reset rate correction tau */
|
||||
F_GET_RATE_CORRECT, /** < get rate correction tau */
|
||||
|
||||
|
||||
F_ACTIVATE, /** < activate/deactivate readout */
|
||||
F_SET_NETWORK_PARAMETER, /**< set network parameters such as transmission delay, flow control */
|
||||
|
||||
F_PROGRAM_FPGA /**< program FPGA */
|
||||
|
||||
|
||||
/* Always append functions hereafter!!! */
|
||||
|
||||
};
|
||||
|
@ -46,6 +46,8 @@
|
||||
short Beb_bit_mode;
|
||||
int BEB_MMAP_SIZE = 0x1000;
|
||||
|
||||
int Beb_activated = 1;
|
||||
|
||||
|
||||
|
||||
void BebInfo_BebInfo(struct BebInfo* bebInfo, unsigned int beb_num){
|
||||
@ -172,6 +174,10 @@ void Beb_GetModuleCopnfiguration(int* master, int* top){
|
||||
|
||||
/* do not work at the moment */
|
||||
int Beb_SetMasterViaSoftware(){
|
||||
|
||||
if(!Beb_activated)
|
||||
return 0;
|
||||
|
||||
//mapping new memory
|
||||
u_int32_t* csp0base=0;
|
||||
u_int32_t value = 0, ret = 1;
|
||||
@ -200,6 +206,10 @@ int Beb_SetMasterViaSoftware(){
|
||||
|
||||
/* do not work at the moment */
|
||||
int Beb_SetSlaveViaSoftware(){
|
||||
|
||||
if(!Beb_activated)
|
||||
return 0;
|
||||
|
||||
//mapping new memory
|
||||
u_int32_t* csp0base=0;
|
||||
u_int32_t value = 0, ret = 1;
|
||||
@ -268,11 +278,18 @@ int Beb_Activate(int enable){
|
||||
if(fd > 0)
|
||||
Beb_close(fd,csp0base);
|
||||
|
||||
Beb_activated = ret;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int Beb_SetNetworkParameter(enum detNetworkParameter mode, int val){
|
||||
|
||||
if(!Beb_activated)
|
||||
return val;
|
||||
|
||||
|
||||
//mapping new memory
|
||||
u_int32_t* csp0base=0;
|
||||
u_int32_t valueread = 0;
|
||||
@ -325,6 +342,10 @@ int Beb_SetNetworkParameter(enum detNetworkParameter mode, int val){
|
||||
|
||||
|
||||
int Beb_ResetToHardwareSettings(){
|
||||
|
||||
if(!Beb_activated)
|
||||
return 1;
|
||||
|
||||
//mapping new memory
|
||||
u_int32_t* csp0base=0;
|
||||
u_int32_t value = 0, ret = 1;
|
||||
@ -396,6 +417,10 @@ u_int32_t Beb_GetFirmwareSoftwareAPIVersion(){
|
||||
}
|
||||
|
||||
void Beb_ResetFrameNumber(){
|
||||
|
||||
if(!Beb_activated)
|
||||
return;
|
||||
|
||||
//mapping new memory to read master top module configuration
|
||||
u_int32_t* csp0base=0;
|
||||
//open file pointer
|
||||
@ -446,7 +471,6 @@ int Beb_InitBebInfos(){//file name at some point
|
||||
bebInfoSize++;
|
||||
|
||||
|
||||
//if(!Beb_ReadSetUpFromFile("/home/root/executables/setup_beb.txt")) return 0;
|
||||
/*
|
||||
//loop through file to fill vector.
|
||||
BebInfo* b = new BebInfo(26);
|
||||
@ -477,52 +501,6 @@ int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig, char* src_mac
|
||||
}
|
||||
|
||||
|
||||
int Beb_ReadSetUpFromFile(char* file_name){
|
||||
char line[100];
|
||||
char str[100];
|
||||
|
||||
int i0,i1;
|
||||
char mac0[50],mac1[50],ip0[50],ip1[0];
|
||||
FILE* fp = fopen(file_name, "r");
|
||||
if( fp == NULL ){
|
||||
perror("Error while opening the beb setup file.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("Setting up beb side of detector:\n");
|
||||
while ( fgets (line , 255 , fp) != NULL ){
|
||||
if(strlen(line)<=1)
|
||||
continue;
|
||||
sscanf (line, "%s", str);
|
||||
if (str[0]=='#')
|
||||
continue;
|
||||
|
||||
if(!strcmp(str,"add_beb")){
|
||||
if( sscanf (line,"%s %d %d %s %s %s %s",str,&i0,&i1,mac0,ip0,mac1,ip1) < 7){
|
||||
printf("Error adding beb from %s.\n",file_name);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
printf ("Read: %s %d %d %s %s %s %s\n", str,i0,i1,mac0,ip0,mac1,ip1);
|
||||
|
||||
if(Beb_GetBebInfoIndex(i0)){
|
||||
printf("Error adding beb from %s, beb number %d already added.\n",file_name,i0);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
struct BebInfo b0;
|
||||
BebInfo_BebInfo(&b0,i0);
|
||||
BebInfo_SetSerialAddress(&b0,i1);
|
||||
BebInfo_SetHeaderInfo(&b0,0,mac0,ip0,42000+i0);
|
||||
BebInfo_SetHeaderInfo(&b0,1,mac1,ip1,52000+i0);
|
||||
beb_infos[bebInfoSize] = b0;
|
||||
bebInfoSize++;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Beb_CheckSourceStuffBebInfo(){
|
||||
@ -552,6 +530,10 @@ unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb){
|
||||
|
||||
|
||||
int Beb_WriteTo(unsigned int index){
|
||||
|
||||
if(!Beb_activated)
|
||||
return 1;
|
||||
|
||||
if(index>=bebInfoSize){
|
||||
printf("WriteTo index error.\n");
|
||||
return 0;
|
||||
@ -575,35 +557,15 @@ void Beb_SwapDataFun(int little_endian, unsigned int n, unsigned int *d){
|
||||
|
||||
|
||||
int Beb_SetByteOrder(){
|
||||
/*
|
||||
Beb_send_data_raw[0] = 0x8fff0000;
|
||||
if(Local_Write(ll_beb,4,Beb_send_data_raw)!=4) return 0;
|
||||
|
||||
while((Local_Read(ll_beb,Beb_recv_buffer_size*4,Beb_recv_data_raw)/4)>0) printf("\t) Cleanning buffer ...\n");
|
||||
|
||||
if(bebInfoSize<2) return 0;
|
||||
|
||||
Beb_send_ndata = 3;
|
||||
Beb_send_data[0] = 0x000c0000;
|
||||
Beb_send_data[1] = 0;
|
||||
Beb_send_data[2] = 0;
|
||||
Beb_WriteTo(0);
|
||||
|
||||
//using little endian for data, big endian not fully tested, swap on 16 bit boundary.
|
||||
Beb_send_ndata = 3;
|
||||
Beb_send_data[0] = 0x000c0000;
|
||||
Beb_send_data[1] = 1;
|
||||
Beb_send_data[2] = 0;
|
||||
Beb_SwapDataFun(0,2,&(Beb_send_data[1]));
|
||||
Beb_WriteTo(0);
|
||||
|
||||
printf("\tSetting Byte Order .............. ok\n");
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header_number, char* dst_mac, char* dst_ip, unsigned int dst_port){
|
||||
|
||||
if(!Beb_activated)
|
||||
return 1;
|
||||
|
||||
u_int32_t bram_phy_addr;
|
||||
u_int32_t* csp0base=0;
|
||||
/*u_int32_t* bram_ptr = NULL;*/
|
||||
@ -809,7 +771,9 @@ int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, i
|
||||
cprintf(GREEN, "Beb_send_data[1] Swapped:%X\n",Beb_send_data[1]);
|
||||
#endif
|
||||
|
||||
if(!Beb_WriteTo(i)) return 0;
|
||||
if(Beb_activated){
|
||||
if(!Beb_WriteTo(i)) return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -828,6 +792,9 @@ int Beb_SetUpTransferParameters(short the_bit_mode){
|
||||
|
||||
int Beb_StopAcquisition()
|
||||
{
|
||||
if(!Beb_activated)
|
||||
return 1;
|
||||
|
||||
u_int32_t* csp0base=0;
|
||||
volatile u_int32_t valuel,valuer;
|
||||
//open file pointer
|
||||
@ -854,6 +821,10 @@ int Beb_StopAcquisition()
|
||||
}
|
||||
|
||||
int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_number, unsigned int nimages, int test_just_send_out_packets_no_wait){
|
||||
|
||||
if(!Beb_activated)
|
||||
return 1;
|
||||
|
||||
if(dst_number>64) return 0;
|
||||
|
||||
unsigned int header_size = 4; //4*64 bits
|
||||
|
@ -41,7 +41,6 @@ struct BebInfo{
|
||||
|
||||
void Beb_ClearBebInfos();
|
||||
int Beb_InitBebInfos();
|
||||
int Beb_ReadSetUpFromFile(char* file_name);
|
||||
int Beb_CheckSourceStuffBebInfo();
|
||||
unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb);
|
||||
|
||||
|
@ -64,7 +64,10 @@ int Feb_control_master = 0;
|
||||
|
||||
unsigned int Feb_Control_rate_correction_table[1024];
|
||||
double Feb_Control_rate_meas[16384];
|
||||
|
||||
double ratemax=-1;
|
||||
int Feb_Control_activated = 1;
|
||||
|
||||
|
||||
void Module_Module(struct Module* mod,unsigned int number, unsigned int address_top){
|
||||
unsigned int i;
|
||||
@ -152,6 +155,10 @@ int Module_GetBottomDACValue(struct Module* mod,unsigned int i)
|
||||
|
||||
|
||||
|
||||
void Feb_Control_activate(int activate){
|
||||
Feb_Control_activated = activate;
|
||||
}
|
||||
|
||||
int Feb_Control_IsBottomModule(){
|
||||
if(Module_BottomAddressIsValid(&modules[Feb_Control_current_index]))
|
||||
return 1;
|
||||
@ -186,40 +193,10 @@ int Feb_Control_Init(int master, int top, int module_num){
|
||||
Feb_Control_module_number = (module_num & 0xFF);
|
||||
|
||||
int serial = !top;
|
||||
|
||||
/*
|
||||
//for Gemmas modules: if master, serial 0, else 1
|
||||
int serial = 1;
|
||||
if(master)
|
||||
serial = 0;
|
||||
switch(Feb_Control_module_number){
|
||||
case 34: serial = 0; break; //martin half
|
||||
case 26: serial = 0; break; //leo
|
||||
|
||||
case 31: serial = 0; break; //martin
|
||||
case 32: serial = 1; break;
|
||||
case 24: serial = 2; break;
|
||||
case 25: serial = 3; break;
|
||||
|
||||
case 15: serial = 0; break; //dhanya
|
||||
case 16: serial = 1; break;
|
||||
case 30: serial = 2; break;
|
||||
case 38: serial = 3; break;
|
||||
|
||||
case 49: serial = 0; break; // Gemma
|
||||
case 48: serial = 1; break; // Gemma
|
||||
}*/
|
||||
printf("serial: %d\n",serial);
|
||||
|
||||
Feb_Control_current_index = 1;
|
||||
|
||||
/*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");
|
||||
|
||||
//Add the half module
|
||||
Feb_Control_AddModule1(Feb_Control_module_number,top,serial,serial,1);
|
||||
@ -242,7 +219,8 @@ printf("****current index:%d\n",i);
|
||||
Feb_Interface_SendCompleteList(nfebs,feb_list);
|
||||
free(feb_list);
|
||||
printf("\n");
|
||||
Feb_Interface_SetByteOrder();
|
||||
if(Feb_Control_activated)
|
||||
Feb_Interface_SetByteOrder();
|
||||
|
||||
|
||||
return 1;
|
||||
@ -250,106 +228,6 @@ printf("****current index:%d\n",i);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
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 detectors:\n");
|
||||
|
||||
while ( fgets (line , 255 , fp) != NULL ){
|
||||
if(strlen(line)<=1)
|
||||
continue;
|
||||
sscanf (line, "%s", str);
|
||||
if (str[0]=='#')
|
||||
continue;
|
||||
|
||||
|
||||
if(!strcmp(str,"add_module")){
|
||||
if( sscanf (line,"%s %d %d %d", str,&i0,&i1,&i2) < 4){
|
||||
cprintf(RED,"Error adding module from %s.\n",file_name);
|
||||
exit(0);
|
||||
}
|
||||
printf ("str:%s len:%d i0:%d i1:%d i2:%d\n", str, strlen(str),i0,i1,i2);
|
||||
if(!Feb_Control_AddModule1(i0,1,i1,i2,0)){
|
||||
cprintf(RED,"Error adding module, parameter was assigned twice in setup file: %s.\n",file_name);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
else if(!strcmp(str,"add_half_module")){
|
||||
if( sscanf (line,"%s %d %d %d", str,&i0,&i1,&i2) < 4){
|
||||
cprintf(RED,"Error adding half module from %s.\n",file_name);
|
||||
exit(0);
|
||||
}
|
||||
printf ("str:%s len:%d i0:%d i1:%d i2:%d\n", str, strlen(str),i0,i1,i2);
|
||||
|
||||
if(!Feb_Control_AddModule1(i0,i1,i2,i2,1)){
|
||||
cprintf(RED,"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)){
|
||||
cprintf(RED,"Error adding module, parameter was assigned twice in setup file: %s.\n",file_name);
|
||||
exit(0);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
|
||||
Feb_Control_PrintModuleList();
|
||||
unsigned int nfebs = 0;
|
||||
unsigned int* feb_list = malloc(moduleSize*4 * sizeof(unsigned int));
|
||||
unsigned int i;
|
||||
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");
|
||||
|
||||
return Feb_Interface_SetByteOrder();
|
||||
}
|
||||
|
||||
void Feb_Control_PrintModuleList(){
|
||||
unsigned int i;
|
||||
printf("\tModule list:\n");
|
||||
@ -447,92 +325,6 @@ int Feb_Control_AddModule1(unsigned int module_number, int top_enable, unsigned
|
||||
return parameters_ok;
|
||||
}
|
||||
|
||||
/* not called anywhere**/
|
||||
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;
|
||||
float f0;
|
||||
|
||||
FILE* fp = fopen(file_name, "r");
|
||||
if( fp == NULL ){
|
||||
perror("Error while opening the file.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
while ( fgets (line , 255 , fp) != NULL ){
|
||||
if(strlen(line)<=1)
|
||||
continue;
|
||||
sscanf (line, "%s", str);
|
||||
if ((str[0]=='#') || (!strcmp(str,"add_module")) || (!strcmp(str,"add_half_module")))
|
||||
continue;
|
||||
|
||||
if(!strcmp("iodelay",str)){
|
||||
if(sscanf (line,"%s %d", str,&i0) < 2){
|
||||
cprintf(RED,"Error reading io_delay\n");
|
||||
exit(0);
|
||||
}
|
||||
Feb_Control_SetIDelays(module_num,i0);
|
||||
}
|
||||
|
||||
else if(!strcmp("high_voltage",str)){
|
||||
if(sscanf (line,"%s %f", str,&f0) < 2){
|
||||
cprintf(RED,"Error reading high_voltage\n");
|
||||
exit(0);
|
||||
}
|
||||
Feb_Control_SetHighVoltage(f0);
|
||||
}
|
||||
/*
|
||||
else if(!strcmp("photon_energy",str)){
|
||||
if(sscanf (line,"%s %f", str,&f0) < 2){
|
||||
cprintf(RED,"Error reading photon_energy\n");
|
||||
exit(0);
|
||||
}
|
||||
Feb_Control_SetPhotonEnergy(f0);
|
||||
}*/
|
||||
|
||||
else if(!strcmp("dynamic_range",str)){
|
||||
if(sscanf (line,"%s %d", str,&i0) < 2){
|
||||
cprintf(RED,"Error reading dynamic_range\n");
|
||||
exit(0);
|
||||
}
|
||||
Feb_Control_SetDynamicRange(i0);
|
||||
}
|
||||
|
||||
else if(!strcmp("readout_speed",str)){
|
||||
if(sscanf (line,"%s %d", str,&i0) < 2){
|
||||
cprintf(RED,"Error reading readout_speed\n");
|
||||
exit(0);
|
||||
}
|
||||
Feb_Control_SetReadoutSpeed(i0);
|
||||
}
|
||||
|
||||
else if(!strcmp("readout_mode",str)){
|
||||
if(sscanf (line,"%s %d", str,&i0) < 2){
|
||||
cprintf(RED,"Error reading readout_mode\n");
|
||||
exit(0);
|
||||
}
|
||||
Feb_Control_SetReadoutMode(i0);
|
||||
}
|
||||
|
||||
else {
|
||||
if( sscanf (line,"%s %f", str,&f0) < 2){
|
||||
cprintf(RED,"Error reading dac\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(module_num>0)
|
||||
sprintf(str,"%s",str); /*sprintf(str,"mod%d::%s",module_num,str);*/
|
||||
if(!Feb_Control_SetDAC(str,f0,1))
|
||||
cprintf(RED,"Error in string: %s",str);
|
||||
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
printf("Done reading set up file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int Feb_Control_CheckSetup(int master){
|
||||
@ -675,12 +467,14 @@ int Feb_Control_SendIDelays(unsigned int dst_num, int chip_lr, unsigned int chan
|
||||
|
||||
printf(", tracks 0x%x to: %d, %d clks and %d units.\n",channels,(((15-delay_data_valid_nclks)<<6)|ndelay_units),delay_data_valid_nclks,ndelay_units);
|
||||
|
||||
if(!Feb_Interface_WriteRegister(dst_num,CHIP_DATA_OUT_DELAY_REG2, 1<<31 | delay_data_valid_nclks<<16 | ndelay_units,0,0) || //the 1<<31 time enables the setting of the data valid delays
|
||||
!Feb_Interface_WriteRegister(dst_num,CHIP_DATA_OUT_DELAY_REG3,set_left_delay_channels,0,0) ||
|
||||
!Feb_Interface_WriteRegister(dst_num,CHIP_DATA_OUT_DELAY_REG4,set_right_delay_channels,0,0) ||
|
||||
!Feb_Interface_WriteRegister(dst_num,CHIP_DATA_OUT_DELAY_REG_CTRL,CHIP_DATA_OUT_DELAY_SET,1,1)){
|
||||
cprintf(RED,"Warning: could not SetChipDataInputDelays(...).\n");
|
||||
return 0;
|
||||
if(Feb_Control_activated){
|
||||
if(!Feb_Interface_WriteRegister(dst_num,CHIP_DATA_OUT_DELAY_REG2, 1<<31 | delay_data_valid_nclks<<16 | ndelay_units,0,0) || //the 1<<31 time enables the setting of the data valid delays
|
||||
!Feb_Interface_WriteRegister(dst_num,CHIP_DATA_OUT_DELAY_REG3,set_left_delay_channels,0,0) ||
|
||||
!Feb_Interface_WriteRegister(dst_num,CHIP_DATA_OUT_DELAY_REG4,set_right_delay_channels,0,0) ||
|
||||
!Feb_Interface_WriteRegister(dst_num,CHIP_DATA_OUT_DELAY_REG_CTRL,CHIP_DATA_OUT_DELAY_SET,1,1)){
|
||||
cprintf(RED,"Warning: could not SetChipDataInputDelays(...).\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -738,9 +532,11 @@ int Feb_Control_SendHighVoltage(unsigned int dst_num,float* value){
|
||||
}
|
||||
|
||||
unsigned int r = 0x20000000 | (b&0xff);
|
||||
if(!Feb_Interface_WriteRegister(dst_num,0,r,0,0)){
|
||||
cprintf(RED,"Warning: trouble setting high voltage for dst_num %d.\n",dst_num);
|
||||
return 0;
|
||||
if(Feb_Control_activated){
|
||||
if(!Feb_Interface_WriteRegister(dst_num,0,r,0,0)){
|
||||
cprintf(RED,"Warning: trouble setting high voltage for dst_num %d.\n",dst_num);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
*value = Feb_Control_DACToVoltage(b,nsteps,vmin,vmax);
|
||||
@ -752,43 +548,15 @@ 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 = 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)){
|
||||
cprintf(RED,"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;//make them both 1 instead of this
|
||||
*bottom = 1;
|
||||
/*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)){
|
||||
cprintf(RED,"Error in dac_name: %s (%s)\n",dac_str,local_s);
|
||||
@ -799,37 +567,6 @@ int Feb_Control_DecodeDACString(char* dac_str, unsigned int* module_index, int*
|
||||
}
|
||||
|
||||
int Feb_Control_SetDAC(char* dac_str, int value, int is_a_voltage_mv){
|
||||
/*
|
||||
string local_s = dac_str;
|
||||
unsigned int module_index = 0;
|
||||
|
||||
size_t p1 = local_s.find("mod");
|
||||
size_t p2 = local_s.find("::");
|
||||
if(p1!=string::npos&&p2!=string::npos&&(p1+3)<p2){
|
||||
unsigned int number = atoi((local_s.substr(p1+3,p2-3)).c_str());
|
||||
if(!GetModuleIndex(number,module_index)){
|
||||
cprintf(RED,"Error in dac_name \""<<dac_str<<"\", module number "<<number<<" not in list.\n");;
|
||||
return 0;
|
||||
}
|
||||
local_s = local_s.substr(p2+2);
|
||||
}
|
||||
|
||||
int top = 1;
|
||||
int 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;
|
||||
}
|
||||
|
||||
unsigned int dac_ch = 0;
|
||||
if(!GetDACNumber(local_s,dac_ch)){
|
||||
cprintf(RED,"Error in dac_name: "<<dac_str<<" ("<<local_s<<")\n");;
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
unsigned int i;
|
||||
unsigned int module_index, dac_ch;
|
||||
int top, bottom;
|
||||
@ -901,10 +638,6 @@ int Feb_Control_GetDACNumber(char* s, unsigned int* n){
|
||||
|
||||
int Feb_Control_SendDACValue(unsigned int dst_num, unsigned int ch, unsigned int* value){
|
||||
|
||||
//static unsigned int nsteps = 4096; //12 bit dac
|
||||
//static float vmin = 0;
|
||||
//static float vmax = 2;
|
||||
|
||||
if(ch<0||ch>15){
|
||||
cprintf(RED,"Warning invalid ch for SetDAC.\n");
|
||||
return 0;
|
||||
@ -918,9 +651,11 @@ int Feb_Control_SendDACValue(unsigned int dst_num, unsigned int ch, unsigned int
|
||||
unsigned int r = dac_ic<<30 | 3<<16 | dac_ch<<12 | *value; //3 write and power up
|
||||
|
||||
|
||||
if(!Feb_Interface_WriteRegister(dst_num,0,r,1,0)){
|
||||
cprintf(RED,"Warning: trouble setting dac %d voltage.\n",ch);
|
||||
return 0;
|
||||
if(Feb_Control_activated){
|
||||
if(!Feb_Interface_WriteRegister(dst_num,0,r,1,0)){
|
||||
cprintf(RED,"Warning: trouble setting dac %d voltage.\n",ch);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
float voltage=Feb_Control_DACToVoltage(*value,4096,0,2048);
|
||||
@ -929,14 +664,7 @@ int Feb_Control_SendDACValue(unsigned int dst_num, unsigned int ch, unsigned int
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
float GetDAC(string s){
|
||||
static unsigned int n;
|
||||
if(!GetDACNumber(s,n)) return 0;
|
||||
|
||||
return dac[n];
|
||||
}
|
||||
*/
|
||||
|
||||
int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits){
|
||||
printf("Setting Trimbits\n");
|
||||
@ -959,12 +687,15 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits){
|
||||
for(l_r=0;l_r<2;l_r++){ // l_r loop
|
||||
//printf("\nl_r:%d\t\t",l_r);
|
||||
unsigned int disable_chip_mask = l_r ? DAQ_CS_BAR_LEFT : DAQ_CS_BAR_RIGHT;
|
||||
if(!(Feb_Interface_WriteRegister(0xfff,DAQ_REG_STATIC_BITS,disable_chip_mask|DAQ_STATIC_BIT_PROGRAM|DAQ_STATIC_BIT_M8,0,0)
|
||||
&&Feb_Control_SetCommandRegister(DAQ_SET_STATIC_BIT)
|
||||
&&Feb_Control_StartDAQOnlyNWaitForFinish(5000))){
|
||||
printf("Could not select chips\n");
|
||||
return 0;
|
||||
if(Feb_Control_activated){
|
||||
if(!(Feb_Interface_WriteRegister(0xfff,DAQ_REG_STATIC_BITS,disable_chip_mask|DAQ_STATIC_BIT_PROGRAM|DAQ_STATIC_BIT_M8,0,0)
|
||||
&&Feb_Control_SetCommandRegister(DAQ_SET_STATIC_BIT)
|
||||
&&Feb_Control_StartDAQOnlyNWaitForFinish(5000))){
|
||||
printf("Could not select chips\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int row_set;
|
||||
for(row_set=0;row_set<16;row_set++){ //16 rows at a time
|
||||
//printf("row_set:%d\t\t",row_set);
|
||||
@ -1020,22 +751,26 @@ int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits){
|
||||
} //end row loop
|
||||
|
||||
if(Module_TopAddressIsValid(&modules[1])){
|
||||
if(!Feb_Interface_WriteMemoryInLoops(Module_GetTopLeftAddress(&modules[Feb_Control_current_index]),0,0,1024,trimbits_to_load_l)||
|
||||
!Feb_Interface_WriteMemoryInLoops(Module_GetTopRightAddress(&modules[Feb_Control_current_index]),0,0,1024,trimbits_to_load_r)||
|
||||
//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(Feb_Control_activated){
|
||||
if(!Feb_Interface_WriteMemoryInLoops(Module_GetTopLeftAddress(&modules[Feb_Control_current_index]),0,0,1024,trimbits_to_load_l)||
|
||||
!Feb_Interface_WriteMemoryInLoops(Module_GetTopRightAddress(&modules[Feb_Control_current_index]),0,0,1024,trimbits_to_load_r)||
|
||||
//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_l)||
|
||||
!Feb_Interface_WriteMemoryInLoops(Module_GetBottomRightAddress(&modules[Feb_Control_current_index]),0,0,1024,trimbits_to_load_r)||
|
||||
//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(Feb_Control_activated){
|
||||
if(!Feb_Interface_WriteMemoryInLoops(Module_GetBottomLeftAddress(&modules[Feb_Control_current_index]),0,0,1024,trimbits_to_load_l)||
|
||||
!Feb_Interface_WriteMemoryInLoops(Module_GetBottomRightAddress(&modules[Feb_Control_current_index]),0,0,1024,trimbits_to_load_r)||
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1077,14 +812,20 @@ return Module_GetTopLeftAddress(&modules[1])|Module_GetTopRightAddress(&modules[
|
||||
}
|
||||
|
||||
int Feb_Control_SetCommandRegister(unsigned int cmd){
|
||||
return Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CHIP_CMDS,cmd,0,0);
|
||||
if(Feb_Control_activated)
|
||||
return Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CHIP_CMDS,cmd,0,0);
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int Feb_Control_GetDAQStatusRegister(unsigned int dst_address, unsigned int* ret_status){
|
||||
if(!Feb_Interface_ReadRegister(dst_address,DAQ_REG_STATUS,ret_status)){
|
||||
cprintf(RED,"Error: reading status register.\n");
|
||||
return 0;
|
||||
//if deactivated, should be handled earlier and should not get into this function
|
||||
if(Feb_Control_activated){
|
||||
if(!Feb_Interface_ReadRegister(dst_address,DAQ_REG_STATUS,ret_status)){
|
||||
cprintf(RED,"Error: reading status register.\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
*ret_status = (0x02FF0000 & *ret_status) >> 16;
|
||||
@ -1093,11 +834,12 @@ int Feb_Control_GetDAQStatusRegister(unsigned int dst_address, unsigned int* ret
|
||||
|
||||
|
||||
int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us){
|
||||
if(!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,0,0,0)||!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,DAQ_CTRL_START,0,0)){
|
||||
cprintf(RED,"Warning: could not start.\n");
|
||||
return 0;
|
||||
if(Feb_Control_activated){
|
||||
if(!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,0,0,0)||!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,DAQ_CTRL_START,0,0)){
|
||||
cprintf(RED,"Warning: could not start.\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return Feb_Control_WaitForFinishedFlag(sleep_time_us);
|
||||
}
|
||||
|
||||
@ -1105,6 +847,10 @@ int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us){
|
||||
int Feb_Control_AcquisitionInProgress(){
|
||||
unsigned int status_reg_r=0,status_reg_l=0;
|
||||
|
||||
//deactivated should return end of acquisition
|
||||
if(!Feb_Control_activated)
|
||||
return 0;
|
||||
|
||||
int ind = Feb_Control_current_index;
|
||||
if(Module_BottomAddressIsValid(&modules[ind])){
|
||||
|
||||
@ -1132,6 +878,10 @@ int Feb_Control_AcquisitionInProgress(){
|
||||
int Feb_Control_AcquisitionStartedBit(){
|
||||
unsigned int status_reg_r=0,status_reg_l=0;
|
||||
|
||||
//deactivated should return acquisition started/ready
|
||||
if(!Feb_Control_activated)
|
||||
return 1;
|
||||
|
||||
int ind = Feb_Control_current_index;
|
||||
if(Module_BottomAddressIsValid(&modules[ind])){
|
||||
|
||||
@ -1172,6 +922,11 @@ int Feb_Control_WaitForFinishedFlag(int sleep_time_us){
|
||||
|
||||
|
||||
int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag){
|
||||
|
||||
//deactivated dont wait (otherwise give a toggle value back)
|
||||
if(!Feb_Control_activated)
|
||||
return 1;
|
||||
|
||||
int value = prev_flag;
|
||||
while(value == prev_flag){
|
||||
usleep(sleep_time_us);
|
||||
@ -1186,10 +941,13 @@ int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag){
|
||||
}
|
||||
|
||||
|
||||
int Feb_Control_Reset(){printf("Reset daq\n");
|
||||
if(!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,0,0,0) || !Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,DAQ_CTRL_RESET,0,0) || !Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,0,0,0)){
|
||||
cprintf(RED,"Warning: Could not reset daq, no response.\n");
|
||||
return 0;
|
||||
int Feb_Control_Reset(){
|
||||
printf("Reset daq\n");
|
||||
if(Feb_Control_activated){
|
||||
if(!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,0,0,0) || !Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,DAQ_CTRL_RESET,0,0) || !Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CTRL,0,0,0)){
|
||||
cprintf(RED,"Warning: Could not reset daq, no response.\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return Feb_Control_WaitForFinishedFlag(5000);
|
||||
@ -1199,10 +957,12 @@ int Feb_Control_Reset(){printf("Reset daq\n");
|
||||
|
||||
|
||||
int Feb_Control_SetStaticBits(){
|
||||
//program=1,m4=2,m8=4,test=8,rotest=16,cs_bar_left=32,cs_bar_right=64
|
||||
if(!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_STATIC_BITS,Feb_Control_staticBits,0,0) || !Feb_Control_SetCommandRegister(DAQ_SET_STATIC_BIT) || !Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
|
||||
cprintf(RED,"Warning: Could not set static bits\n");
|
||||
return 0;
|
||||
if(Feb_Control_activated){
|
||||
//program=1,m4=2,m8=4,test=8,rotest=16,cs_bar_left=32,cs_bar_right=64
|
||||
if(!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_STATIC_BITS,Feb_Control_staticBits,0,0) || !Feb_Control_SetCommandRegister(DAQ_SET_STATIC_BIT) || !Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
|
||||
cprintf(RED,"Warning: Could not set static bits\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -1448,13 +1208,7 @@ void Feb_Control_PrintAcquisitionSetup(){
|
||||
}
|
||||
|
||||
int Feb_Control_SendBitModeToBebServer(){
|
||||
/*
|
||||
static int first_pass = 1;
|
||||
static char buffer[1024];
|
||||
|
||||
if(first_pass&&!Feb_Control_SetupSendToSocket("localhost",43212)) return 0;
|
||||
else first_pass=0;
|
||||
*/
|
||||
unsigned int just_bit_mode = (DAQ_STATIC_BIT_M4|DAQ_STATIC_BIT_M8) & Feb_Control_staticBits;
|
||||
unsigned int bit_mode = 16; //default
|
||||
if(just_bit_mode == DAQ_STATIC_BIT_M4) bit_mode = 4;
|
||||
@ -1467,60 +1221,9 @@ int Feb_Control_SendBitModeToBebServer(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
bzero(buffer,1024);
|
||||
sprintf(buffer,"setbitmode %d",bit_mode);
|
||||
|
||||
if(Feb_Control_WriteNRead(buffer,strlen(buffer),1024)<1||strncmp(buffer,"0",1)){
|
||||
cprintf(RED,"Error: sending bit mode ...\n");
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
int Feb_Control_SetupSendToSocket(const char* ip_address_hostname, unsigned short int port){
|
||||
|
||||
struct hostent *server;
|
||||
if((server = gethostbyname(ip_address_hostname)) == NULL){ //or look into getaddrinfo(3)
|
||||
fprintf(stderr,"ERROR, no such host\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
//struct sockaddr_in serv_addr;
|
||||
bzero((char *) &Feb_Control_serv_addr, sizeof(Feb_Control_serv_addr));
|
||||
Feb_Control_serv_addr.sin_family = AF_INET;
|
||||
bcopy((char *)server->h_addr,(char *)&Feb_Control_serv_addr.sin_addr.s_addr,server->h_length);
|
||||
Feb_Control_serv_addr.sin_port = htons(port);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Feb_Control_WriteNRead(char* message, int length, int max_length){
|
||||
|
||||
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if(sockfd <0){
|
||||
fprintf(stderr,"ERROR opening socket\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(connect(sockfd,(struct sockaddr *) &Feb_Control_serv_addr,sizeof(Feb_Control_serv_addr)) < 0){
|
||||
fprintf(stderr,"ERROR connecting\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int n = write(sockfd,message,length);
|
||||
if(n<0) cprintf(RED,"Error writing to socket");
|
||||
|
||||
length = read(sockfd,message,max_length);
|
||||
if(length<0) cprintf(RED,"Error reading to socket");
|
||||
|
||||
close(sockfd);
|
||||
|
||||
return length;
|
||||
}
|
||||
*/
|
||||
|
||||
int Feb_Control_PrepareForAcquisition(){//return 1;
|
||||
static unsigned int reg_nums[20];
|
||||
@ -1568,30 +1271,13 @@ int Feb_Control_PrepareForAcquisition(){//return 1;
|
||||
reg_nums[5]=DAQ_REG_SUBFRAME_EXPOSURES;
|
||||
reg_vals[5]= Feb_Control_subframe_exposure_time_in_10nsec; //(1 means 10ns, 100 means 1000ns)
|
||||
// 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(),6,reg_nums,reg_vals,0,0)){
|
||||
printf("Trouble starting acquisition....\n");;
|
||||
return 0;
|
||||
if(Feb_Control_activated){
|
||||
if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),6,reg_nums,reg_vals,0,0)){
|
||||
printf("Trouble starting acquisition....\n");;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
reg_nums[0]=DAQ_REG_NEXPOSURES;
|
||||
reg_vals[0]=Feb_Control_nimages;
|
||||
reg_nums[1]=DAQ_REG_EXPOSURE_TIMER;
|
||||
reg_vals[1]=Feb_Control_ConvertTimeToRegister(Feb_Control_exposure_time_in_sec);
|
||||
reg_nums[2]=DAQ_REG_EXPOSURE_REPEAT_TIMER;
|
||||
reg_vals[2]=Feb_Control_ConvertTimeToRegister(Feb_Control_exposure_period_in_sec);
|
||||
reg_nums[3]=DAQ_REG_CHIP_CMDS;
|
||||
reg_vals[3]=(Feb_Control_acquireNReadoutMode|Feb_Control_triggerMode|Feb_Control_externalEnableMode|Feb_Control_subFrameMode);
|
||||
reg_nums[4]=DAQ_REG_SUBFRAME_EXPOSURES;
|
||||
reg_vals[4]= Feb_Control_subframe_exposure_time_in_10nsec; //(1 means 10ns, 100 means 1000ns)
|
||||
// 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(),5,reg_nums,reg_vals,0,0)){
|
||||
printf("Trouble starting acquisition....\n");;
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1612,22 +1298,13 @@ int Feb_Control_StartAcquisition(){
|
||||
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)){
|
||||
cprintf(RED,"Trouble starting acquisition....\n");;
|
||||
return 0;
|
||||
if(Feb_Control_activated){
|
||||
if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),15,reg_nums,reg_vals,0,0)){
|
||||
cprintf(RED,"Trouble starting acquisition....\n");;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
reg_nums[0]=DAQ_REG_CTRL;
|
||||
reg_vals[0]=0;
|
||||
reg_nums[1]=DAQ_REG_CTRL;
|
||||
reg_vals[1]=ACQ_CTRL_START;
|
||||
|
||||
if(!Feb_Interface_WriteRegisters(Feb_Control_AddressToAll(),2,reg_nums,reg_vals,0,0)){
|
||||
printf("Trouble starting acquisition....\n");;
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -1706,11 +1383,13 @@ int Feb_Control_PulsePixelNMove(int npulses, int inc_x_pos, int inc_y_pos){
|
||||
c |= (inc_x_pos) ? DAQ_CLK_MAIN_CLK_TO_SELECT_NEXT_PIXEL : 0;
|
||||
c |= (inc_y_pos) ? DAQ_CLK_ROW_CLK_TO_SELECT_NEXT_ROW : 0;
|
||||
|
||||
if(!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_SEND_N_TESTPULSES,npulses,0,0) ||
|
||||
!Feb_Control_SetCommandRegister(c) ||
|
||||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
|
||||
cprintf(RED,"Warning: could not PulsePixelNMove(...).\n");
|
||||
return 0;
|
||||
if(Feb_Control_activated){
|
||||
if(!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_SEND_N_TESTPULSES,npulses,0,0) ||
|
||||
!Feb_Control_SetCommandRegister(c) ||
|
||||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
|
||||
cprintf(RED,"Warning: could not PulsePixelNMove(...).\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -1718,11 +1397,13 @@ int Feb_Control_PulsePixelNMove(int npulses, int inc_x_pos, int inc_y_pos){
|
||||
|
||||
/**new*/
|
||||
int Feb_Control_Shift32InSerialIn(unsigned int value_to_shift_in){
|
||||
if(!Feb_Control_SetCommandRegister(DAQ_SERIALIN_SHIFT_IN_32) ||
|
||||
!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_SHIFT_IN_32,value_to_shift_in,0,0) ||
|
||||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
|
||||
cprintf(RED,"Warning: could not shift in 32.\n");
|
||||
return 0;
|
||||
if(Feb_Control_activated){
|
||||
if(!Feb_Control_SetCommandRegister(DAQ_SERIALIN_SHIFT_IN_32) ||
|
||||
!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_SHIFT_IN_32,value_to_shift_in,0,0) ||
|
||||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
|
||||
cprintf(RED,"Warning: could not shift in 32.\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -1742,11 +1423,13 @@ int Feb_Control_ClockRowClock(unsigned int ntimes){
|
||||
ntimes=1023;
|
||||
}
|
||||
|
||||
if(!Feb_Control_SetCommandRegister(DAQ_CLK_ROW_CLK_NTIMES) ||
|
||||
!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CLK_ROW_CLK_NTIMES,ntimes,0,0) ||
|
||||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
|
||||
cprintf(RED,"Warning: could not clock row clock.\n");
|
||||
return 0;
|
||||
if(Feb_Control_activated){
|
||||
if(!Feb_Control_SetCommandRegister(DAQ_CLK_ROW_CLK_NTIMES) ||
|
||||
!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),DAQ_REG_CLK_ROW_CLK_NTIMES,ntimes,0,0) ||
|
||||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
|
||||
cprintf(RED,"Warning: could not clock row clock.\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -1939,18 +1622,22 @@ int Feb_Control_SetRateCorrectionTable(unsigned int *table){
|
||||
printf("daq reset completely\n");
|
||||
|
||||
if(Module_TopAddressIsValid(&modules[1])){
|
||||
if(!Feb_Interface_WriteMemoryInLoops(Module_GetTopLeftAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)||
|
||||
!Feb_Interface_WriteMemoryInLoops(Module_GetTopRightAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)||
|
||||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
|
||||
cprintf(BG_RED,"Error in Top Writing to Memory ::Feb_Control_SetRateCorrectionTable\n");
|
||||
return 0;
|
||||
if(Feb_Control_activated){
|
||||
if(!Feb_Interface_WriteMemoryInLoops(Module_GetTopLeftAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)||
|
||||
!Feb_Interface_WriteMemoryInLoops(Module_GetTopRightAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)||
|
||||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
|
||||
cprintf(BG_RED,"Error in Top Writing to Memory ::Feb_Control_SetRateCorrectionTable\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(!Feb_Interface_WriteMemoryInLoops(Module_GetBottomLeftAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)||
|
||||
!Feb_Interface_WriteMemoryInLoops(Module_GetBottomRightAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)||
|
||||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
|
||||
cprintf(BG_RED,"Error in Bottom Writing to Memory ::Feb_Control_SetRateCorrectionTable\n");
|
||||
return 0;
|
||||
if(Feb_Control_activated){
|
||||
if(!Feb_Interface_WriteMemoryInLoops(Module_GetBottomLeftAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)||
|
||||
!Feb_Interface_WriteMemoryInLoops(Module_GetBottomRightAddress(&modules[Feb_Control_current_index]),1,0,1024,Feb_Control_rate_correction_table)||
|
||||
!Feb_Control_StartDAQOnlyNWaitForFinish(5000)){
|
||||
cprintf(BG_RED,"Error in Bottom Writing to Memory ::Feb_Control_SetRateCorrectionTable\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
@ -64,6 +64,7 @@ int Module_GetBottomDACValue(struct Module* mod,unsigned int i);
|
||||
|
||||
|
||||
|
||||
void Feb_Control_activate(int activate);
|
||||
|
||||
int Feb_Control_IsBottomModule();
|
||||
int Feb_Control_GetModuleNumber();
|
||||
@ -112,8 +113,6 @@ int Feb_Control_GetModuleNumber();
|
||||
|
||||
void Feb_Control_FebControl();
|
||||
int Feb_Control_Init(int master, int top, int module_num);
|
||||
int Feb_Control_ReadSetUpFileToAddModules(char* file_name);
|
||||
int Feb_Control_ReadSetUpFile(unsigned int module_num, char* file_name);
|
||||
int Feb_Control_CheckSetup();
|
||||
|
||||
unsigned int Feb_Control_GetNModules();
|
||||
|
Binary file not shown.
@ -1329,7 +1329,9 @@ int getBebFPGATemp(){
|
||||
|
||||
|
||||
int activate(int enable){
|
||||
return Beb_Activate(enable);
|
||||
int ret = Beb_Activate(enable);
|
||||
Feb_Control_activate(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1269,6 +1269,13 @@ int slsDetector::activate(int const enable){
|
||||
int arg = enable;
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
int ret = OK;
|
||||
|
||||
if(thisDetector->myDetectorType != EIGER){
|
||||
std::cout<< "Not implemented for this detector" << std::endl;
|
||||
setErrorMask((getErrorMask())|(DETECTOR_ACTIVATE));
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
if(!enable)
|
||||
std::cout<< "Deactivating Detector" << std::endl;
|
||||
@ -1295,11 +1302,36 @@ int slsDetector::activate(int const enable){
|
||||
}
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
if(retval)
|
||||
if(retval==1)
|
||||
std::cout << "Detector Activated" << std::endl;
|
||||
else
|
||||
else if(retval==0)
|
||||
std::cout << "Detector Deactivated" << std::endl;
|
||||
else
|
||||
std::cout << "Detector Activation unknown:" << retval << std::endl;
|
||||
#endif
|
||||
|
||||
if(ret!=FAIL){
|
||||
if(setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG){
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Activating/Deactivating Receiver: " << retval << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK)
|
||||
ret=thisReceiver->sendInt(fnum,retval,retval);
|
||||
disconnectData();
|
||||
if(ret==FAIL)
|
||||
setErrorMask((getErrorMask())|(RECEIVER_ACTIVATE));
|
||||
}
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
if(retval==1)
|
||||
std::cout << "Receiver Activated" << std::endl;
|
||||
else if(retval==0)
|
||||
std::cout << "Receiver Deactivated" << std::endl;
|
||||
else
|
||||
std::cout << "Receiver Activation unknown:" << retval << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
return retval;
|
||||
|
||||
}
|
||||
@ -5546,6 +5578,7 @@ char* slsDetector::setReceiver(string receiverIP){
|
||||
setTimer(FRAME_PERIOD,thisDetector->timerValue[FRAME_PERIOD]);
|
||||
setTimer(FRAME_NUMBER,thisDetector->timerValue[FRAME_NUMBER]);
|
||||
setDynamicRange(thisDetector->dynamicRange);
|
||||
activate(-1);
|
||||
//set scan tag
|
||||
setUDPConnection();
|
||||
if(thisDetector->myDetectorType == EIGER)
|
||||
|
Loading…
x
Reference in New Issue
Block a user