From 5a7eeb3d763040c4af92e1d71e9d0c95629e0677 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 12 Jun 2020 16:22:31 +0200 Subject: [PATCH] WIP --- .../eigerDetectorServer/FebControl.c | 87 +++---------------- .../eigerDetectorServer/FebControl.h | 22 +---- 2 files changed, 14 insertions(+), 95 deletions(-) diff --git a/slsDetectorServers/eigerDetectorServer/FebControl.c b/slsDetectorServers/eigerDetectorServer/FebControl.c index 3864902e3..1354f2e4f 100644 --- a/slsDetectorServers/eigerDetectorServer/FebControl.c +++ b/slsDetectorServers/eigerDetectorServer/FebControl.c @@ -64,66 +64,12 @@ int Feb_Control_hv_fd = -1; void Module_Module(struct Module *mod, unsigned int number, unsigned int address_top) { mod->module_number = number; - mod->top_address_valid = 1; - mod->top_left_address = 0x100 | (0xff & address_top); - mod->top_right_address = (0x200 | (0xff & address_top)); - mod->bottom_address_valid = 0; - mod->bottom_left_address = 0; - mod->bottom_right_address = 0; - + mod->left_address = 0x100 | (0xff & address_top); + mod->right_address = (0x200 | (0xff & address_top)); mod->high_voltage = -1; - mod->top_dac = malloc(Module_ndacs * sizeof(int)); - mod->bottom_dac = malloc(Module_ndacs * sizeof(int)); + mod->dac = malloc(Module_ndacs * sizeof(int)); for (unsigned int i = 0; i < Module_ndacs; i++) - mod->top_dac[i] = mod->top_address_valid ? -1 : 0; - for (unsigned int i = 0; i < Module_ndacs; i++) - mod->bottom_dac[i] = mod->bottom_address_valid ? -1 : 0; -} - -void Module_ModuleBottom(struct Module *mod, unsigned int number, - unsigned int address_bottom) { - mod->module_number = number; - mod->top_address_valid = 0; - mod->top_left_address = 0; - mod->top_right_address = 0; - mod->bottom_address_valid = 1; - mod->bottom_left_address = 0x100 | (0xff & address_bottom); - mod->bottom_right_address = (0x200 | (0xff & address_bottom)); - - mod->high_voltage = -1; - - for (unsigned int i = 0; i < 4; i++) - mod->idelay_top[i] = mod->idelay_bottom[i] = 0; - - mod->top_dac = malloc(Module_ndacs * sizeof(int)); - mod->bottom_dac = malloc(Module_ndacs * sizeof(int)); - for (unsigned int i = 0; i < Module_ndacs; i++) - mod->top_dac[i] = mod->top_address_valid ? -1 : 0; - for (unsigned int i = 0; i < Module_ndacs; i++) - mod->bottom_dac[i] = mod->bottom_address_valid ? -1 : 0; -} - -void Module_Module1(struct Module *mod, unsigned int number, - unsigned int address_top, unsigned int address_bottom) { - mod->module_number = number; - mod->top_address_valid = 1; - mod->top_left_address = 0x100 | (0xff & address_top); - mod->top_right_address = 0x200 | (0xff & address_top); - mod->bottom_address_valid = 1; - mod->bottom_left_address = 0x100 | (0xff & address_bottom); - mod->bottom_right_address = 0x200 | (0xff & address_bottom); - - mod->high_voltage = -1; - - for (unsigned int i = 0; i < 4; i++) - mod->idelay_top[i] = mod->idelay_bottom[i] = 0; - - mod->top_dac = malloc(Module_ndacs * sizeof(int)); - mod->bottom_dac = malloc(Module_ndacs * sizeof(int)); - for (unsigned int i = 0; i < Module_ndacs; i++) - mod->top_dac[i] = mod->top_address_valid ? -1 : 0; - for (unsigned int i = 0; i < Module_ndacs; i++) - mod->bottom_dac[i] = mod->bottom_address_valid ? -1 : 0; + mod->dac[i] = 0; } unsigned int Module_GetModuleNumber(struct Module *mod) { @@ -222,7 +168,7 @@ int Feb_Control_Init(int master, int top, int normal, int module_num) { Feb_control_normal = normal; // global send - Feb_Control_AddModule1(0, 1, 0xff, 0, 1); + Feb_Control_AddModule(0, 0xff); Feb_Control_PrintModuleList(); Feb_Control_module_number = (module_num & 0xFF); @@ -232,7 +178,7 @@ int Feb_Control_Init(int master, int top, int normal, int module_num) { Feb_Control_current_index = 1; // Add the half module - Feb_Control_AddModule1(Feb_Control_module_number, top, serial, serial, 1); + Feb_Control_AddModule(Feb_Control_module_number, serial); Feb_Control_PrintModuleList(); unsigned int nfebs = 0; @@ -389,13 +335,8 @@ 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, 1, top_address, 0, 1); -} -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; +<<<<<<< Updated upstream unsigned int pre_module_index = 0; if (Feb_Control_GetModuleIndex(module_number, &pre_module_index)) { LOG(logINFO, ("\tRemoving previous assignment of module number %d.\n", @@ -407,19 +348,11 @@ int Feb_Control_AddModule1(unsigned int module_number, int top_enable, parameters_ok = 0; } +======= +>>>>>>> Stashed changes struct Module mod, *m; m = &mod; - - /* 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) && (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); - + Module_Module(m, module_number, top_address); parameters_ok &= Feb_Control_CheckModuleAddresses(m); if (Module_TopAddressIsValid(m) && Module_BottomAddressIsValid(m)) { diff --git a/slsDetectorServers/eigerDetectorServer/FebControl.h b/slsDetectorServers/eigerDetectorServer/FebControl.h index 7968e97c6..e11a6fecb 100644 --- a/slsDetectorServers/eigerDetectorServer/FebControl.h +++ b/slsDetectorServers/eigerDetectorServer/FebControl.h @@ -5,26 +5,15 @@ struct Module { unsigned int module_number; - int top_address_valid; - unsigned int top_left_address; - unsigned int top_right_address; - int bottom_address_valid; - unsigned int bottom_left_address; - unsigned int bottom_right_address; - - unsigned int idelay_top[4]; // ll,lr,rl,ll - unsigned int idelay_bottom[4]; // ll,lr,rl,ll + unsigned int left_address; + unsigned int right_address; + unsigned int idelay_top[4]; // ll,lr,rl,ll float high_voltage; - int *top_dac; - int *bottom_dac; + int *dac; }; void Module_Module(struct Module *mod, unsigned int number, unsigned int address_top); -void Module_ModuleBottom(struct Module *mod, unsigned int number, - unsigned int address_bottom); -void Module_Module1(struct Module *mod, unsigned int number, - unsigned int address_top, unsigned int address_bottom); unsigned int Module_GetModuleNumber(struct Module *mod); int Module_TopAddressIsValid(struct Module *mod); unsigned int Module_GetTopBaseAddress(struct Module *mod); @@ -59,9 +48,6 @@ int Feb_Control_GetModuleIndex(unsigned int module_number, unsigned int *module_index); int Feb_Control_CheckModuleAddresses(struct Module *m); int Feb_Control_AddModule(unsigned int module_number, unsigned int top_address); -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);