From 219318a52e9dc3abcd73f83009b8ff1434b1f7cc Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 23 Feb 2022 17:31:46 +0100 Subject: [PATCH] wip, removed extra virutal server binaries for eiger, --ignore-config for command line --- .../eigerDetectorServer/CMakeLists.txt | 72 ++----------------- .../slsDetectorFunctionList.c | 39 ++++------ .../slsDetectorFunctionList.c | 24 ++++++- .../slsDetectorFunctionList.c | 6 ++ .../slsDetectorFunctionList.c | 5 ++ .../include/slsDetectorFunctionList.h | 5 +- .../slsDetectorServer/src/slsDetectorServer.c | 27 +++++-- .../src/slsDetectorServer_funcs.c | 4 +- 8 files changed, 81 insertions(+), 101 deletions(-) diff --git a/slsDetectorServers/eigerDetectorServer/CMakeLists.txt b/slsDetectorServers/eigerDetectorServer/CMakeLists.txt index ae8b9b0ea..39f0aea23 100644 --- a/slsDetectorServers/eigerDetectorServer/CMakeLists.txt +++ b/slsDetectorServers/eigerDetectorServer/CMakeLists.txt @@ -16,91 +16,31 @@ include_directories( ../../slsSupportLib/include ) -add_executable(eigerDetectorServerMaster_virtual +add_executable(eigerDetectorServer_virtual ${src} ) -target_include_directories(eigerDetectorServerMaster_virtual +target_include_directories(eigerDetectorServer_virtual PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ) -target_compile_definitions(eigerDetectorServerMaster_virtual - PUBLIC EIGERD PCCOMPILE STOP_SERVER - PUBLIC VIRTUAL #VIRTUAL_9M - PUBLIC VIRTUAL_MASTER -) - -target_link_libraries(eigerDetectorServerMaster_virtual - PUBLIC pthread rt slsProjectCSettings -) - -set_target_properties(eigerDetectorServerMaster_virtual PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin -) - -install(TARGETS eigerDetectorServerMaster_virtual - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) - - - - - -add_executable(eigerDetectorServerSlaveTop_virtual - ${src} -) - -target_include_directories(eigerDetectorServerSlaveTop_virtual - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} -) - -target_compile_definitions(eigerDetectorServerSlaveTop_virtual - PUBLIC EIGERD PCCOMPILE STOP_SERVER - PUBLIC VIRTUAL #VIRTUAL_9M - PUBLIC VIRTUAL_TOP -) - -target_link_libraries(eigerDetectorServerSlaveTop_virtual - PUBLIC pthread rt slsProjectCSettings -) - -set_target_properties(eigerDetectorServerSlaveTop_virtual PROPERTIES - RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin -) - -install(TARGETS eigerDetectorServerSlaveTop_virtual - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) - - - - -add_executable(eigerDetectorServerSlaveBottom_virtual - ${src} -) - -target_include_directories(eigerDetectorServerSlaveBottom_virtual - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} -) - -target_compile_definitions(eigerDetectorServerSlaveBottom_virtual +target_compile_definitions(eigerDetectorServer_virtual PUBLIC EIGERD PCCOMPILE STOP_SERVER PUBLIC VIRTUAL #VIRTUAL_9M ) -target_link_libraries(eigerDetectorServerSlaveBottom_virtual +target_link_libraries(eigerDetectorServer_virtual PUBLIC pthread rt slsProjectCSettings ) -set_target_properties(eigerDetectorServerSlaveBottom_virtual PROPERTIES +set_target_properties(eigerDetectorServer_virtual PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -install(TARGETS eigerDetectorServerSlaveBottom_virtual +install(TARGETS eigerDetectorServer_virtual RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) - configure_file(config_eiger.txt ${CMAKE_BINARY_DIR}/bin/config_eiger.txt COPYONLY) configure_file(detid_eiger.txt ${CMAKE_BINARY_DIR}/bin/detid_eiger.txt COPYONLY) diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index 8034dd14a..2020b7544 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -26,6 +26,7 @@ extern int updateFlag; extern udpStruct udpDetails[MAX_UDP_DESTINATION]; extern int numUdpDestinations; extern const enum detectorType myDetectorType; +extern int ignoreConfigFileFlag; // Global variable from communication_funcs.c extern int isControlServer; @@ -381,20 +382,9 @@ void initStopServer() { } } -void setVirtualDefaultModuleConfigurations() { +void checkVirtual9MFlag() { + LOG(logINFORED, ("updating virtual\n")); #ifdef VIRTUAL -#ifdef VIRTUAL_MASTER - master = 1; - top = 1; -#else - master = 0; -#ifdef VIRTUAL_TOP - top = 1; -#else - top = 0; -#endif -#endif - #ifdef VIRTUAL_9M normal = 0; #else @@ -404,13 +394,17 @@ void setVirtualDefaultModuleConfigurations() { } int updateModuleConfiguration() { -#ifdef VIRTUAL - setVirtualDefaultModuleConfigurations(); -#else if (getModuleConfiguration(&master, &top, &normal) == FAIL) { return FAIL; } +#ifdef VIRTUAL + checkVirtual9MFlag(); #endif + if (isControlServer) { + LOG(logINFOBLUE, + ("Module: %s %s %s\n", (top ? "TOP" : "BOTTOM"), + (master ? "MASTER" : "SLAVE"), (normal ? "NORMAL" : "SPECIAL"))); + } return OK; } @@ -430,21 +424,17 @@ int getModuleConfiguration(int *m, int *t, int *n) { return FAIL; } #endif - if (isControlServer) { - LOG(logINFOBLUE, - ("Module: %s %s %s\n", (*t ? "TOP" : "BOTTOM"), - (*m ? "MASTER" : "SLAVE"), (*n ? "NORMAL" : "SPECIAL"))); - } return OK; } int readConfigFile() { - if (initError == FAIL) { return initError; } - master = -1; - top = -1; + + if (ignoreConfigFileFlag) { + return OK; + } const int fileNameSize = 128; char fname[fileNameSize]; @@ -1472,6 +1462,7 @@ int setHighVoltage(int val) { /* parameters - timing, extsig */ int setMaster(int m) { + LOG(logINFO, ("Setting up as %s\n", (m == 1 ? "Master" : "Slave"))); #ifdef VIRTUAL master = m; #else diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index da7576ef8..392a31957 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -28,6 +28,7 @@ extern int updateFlag; extern int checkModuleFlag; extern udpStruct udpDetails[MAX_UDP_DESTINATION]; extern const enum detectorType myDetectorType; +extern int ignoreConfigFileFlag; // Global variable from communication_funcs.c extern int isControlServer; @@ -69,6 +70,7 @@ int64_t burstPeriodReg = 0; int filterResistor = 0; int cdsGain = 0; int detPos[2] = {}; +int master = 1; int isInitCheckDone() { return initCheckDone; } @@ -600,6 +602,10 @@ int readConfigFile() { return initError; } + if (ignoreConfigFileFlag) { + return OK; + } + // require a sleep before and after the rst dac signal usleep(INITIAL_STARTUP_WAIT); @@ -1442,6 +1448,11 @@ int setHighVoltage(int val) { /* parameters - timing */ +int isMaster(int *retval) { + *retval = master; + return OK; +} + void updatingRegisters() { LOG(logINFO, ("\tUpdating registers\n")); // burst @@ -1921,9 +1932,16 @@ int checkDetectorType() { return -2; } - if ((abs(type - TYPE_GOTTHARD2_MODULE_VAL) > TYPE_TOLERANCE) && - (abs(type - TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL) > TYPE_TOLERANCE) && - (abs(type - TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL) > TYPE_TOLERANCE)) { + if (abs(type - TYPE_GOTTHARD2_25UM_MASTER_MODULE_VAL) <= TYPE_TOLERANCE) { + LOG(logINFOBLUE, ("MASTER 25um Module\n")); + } else if (abs(type - TYPE_GOTTHARD2_25UM_SLAVE_MODULE_VAL) <= + TYPE_TOLERANCE) { + master = 0; + LOG(logINFOBLUE, ("SLAVE 25um Module\n")); + } else if (abs(type - TYPE_GOTTHARD2_MODULE_VAL) <= TYPE_TOLERANCE) { + master = 0; + LOG(logINFOBLUE, ("50um Module\n")); + } else { LOG(logERROR, ("Wrong Module attached! Expected %d, %d or %d for Gotthard2, got " "%d\n", diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c index b8fa95f0b..549da04b2 100644 --- a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c @@ -25,6 +25,7 @@ extern int debugflag; extern int updateFlag; extern udpStruct udpDetails[MAX_UDP_DESTINATION]; extern const enum detectorType myDetectorType; +extern int ignoreConfigFileFlag; // Variables that will be exported int phaseShift = DEFAULT_PHASE_SHIFT; @@ -624,6 +625,11 @@ void setGbitReadout() { } int readConfigFile() { + + if (ignoreConfigFileFlag) { + return OK; + } + const int fileNameSize = 128; char fname[fileNameSize]; if (getAbsPath(fname, fileNameSize, CONFIG_FILE) == FAIL) { diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index dc8e1ea28..0f5a38437 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -28,6 +28,7 @@ extern int updateFlag; extern udpStruct udpDetails[MAX_UDP_DESTINATION]; extern int numUdpDestinations; extern const enum detectorType myDetectorType; +extern int ignoreConfigFileFlag; // Global variable from communication_funcs.c extern int isControlServer; @@ -643,6 +644,10 @@ int readConfigFile() { return initError; } + if (ignoreConfigFileFlag) { + return OK; + } + const int fileNameSize = 128; char fname[fileNameSize]; if (getAbsPath(fname, fileNameSize, CONFIG_FILE) == FAIL) { diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 0ef99858f..c2223b8c5 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -113,7 +113,7 @@ void initStopServer(); int updateModuleConfiguration(); int getModuleConfiguration(int *m, int *t, int *n); #ifdef VIRTUAL -void setVirtualDefaultModuleConfigurations(); +void checkVirtual9MFlag(); #endif #endif @@ -369,7 +369,8 @@ int setHighVoltage(int val); #ifdef EIGERD int setMaster(int m); #endif -#if defined(MYTHEN3D) || defined(EIGERD) || defined(GOTTHARDD) +#if defined(MYTHEN3D) || defined(EIGERD) || defined(GOTTHARDD) || \ + defined(GOTTHARD2D) int isMaster(int *retval); #endif diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c index e11055123..663064ec2 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c @@ -26,6 +26,7 @@ extern int sockfd; extern int debugflag; extern int updateFlag; extern int checkModuleFlag; +extern int ignoreConfigFileFlag; // Global variables from slsDetectorFunctionList #ifdef GOTTHARDD @@ -48,6 +49,7 @@ int main(int argc, char *argv[]) { updateFlag = 0; checkModuleFlag = 1; int version = 0; + ignoreConfigFileFlag = 0; // help message char helpMessage[MAX_STR_LENGTH]; @@ -58,15 +60,18 @@ int main(int argc, char *argv[]) { "Possible arguments are:\n" "\t-v, --version : Software version\n" "\t-p, --port : TCP communication port with client. \n" - "\t-g, --nomodule : [Mythen3][Gotthard2] Generic or No " - "Module mode. Skips detector type checks. \n" + "\t-g, --nomodule : [Mythen3][Gotthard2] \n" + "\t Generic or No Module mode. Skips " + "detector type checks. \n" "\t-f, --phaseshift : [Gotthard] only. Sets phase shift. \n" "\t-d, --devel : Developer mode. Skips firmware checks. \n" "\t-u, --update : Update mode. Skips firmware checks and " "initial detector setup. \n" + "\t-i, --ignore-config : " + "[Virtual][Eiger][Jungfrau][Gotthard][Gotthard2] \n" + "\t Ignore config file. \n" "\t-s, --stopserver : Stop server. Do not use as it is created " - "by " - "control server \n\n", + "by control server \n\n", argv[0]); // parse command line for config @@ -80,6 +85,7 @@ int main(int argc, char *argv[]) { {"nomodule", no_argument, NULL, 'g'}, // generic {"devel", no_argument, NULL, 'd'}, {"update", no_argument, NULL, 'u'}, + {"ignore-config", no_argument, NULL, 'i'}, {"stopserver", no_argument, NULL, 's'}, {NULL, 0, NULL, 0}}; @@ -89,7 +95,7 @@ int main(int argc, char *argv[]) { int c = 0; while (c != -1) { - c = getopt_long(argc, argv, "hvp:f:gdus", long_options, &option_index); + c = getopt_long(argc, argv, "hvp:f:gduis", long_options, &option_index); // Detect the end of the options if (c == -1) @@ -160,6 +166,17 @@ int main(int argc, char *argv[]) { isControlServer = 0; break; + case 'i': +#if defined(EIGERD) || defined(GOTTHARDD) || defined(GOTTHARD2D) || \ + defined(JUNGFRAU) + LOG(logINFO, ("Ignoring config file\n")); + ignoreConfigFileFlag = 1; +#else + LOG(logERROR, ("No server config files for this detector\n")); + exit(EXIT_FAILURE); +#endif + break; + case 'h': printf("%s", helpMessage); exit(EXIT_SUCCESS); diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index d155f86db..11bce66c3 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -54,6 +54,7 @@ int sockfd = 0; int debugflag = 0; int updateFlag = 0; int checkModuleFlag = 1; +int ignoreConfigFileFlag = 0; udpStruct udpDetails[MAX_UDP_DESTINATION]; int numUdpDestinations = 1; @@ -8194,7 +8195,8 @@ int get_master(int file_des) { LOG(logDEBUG1, ("Getting master\n")); -#if !defined(MYTHEN3D) && !defined(EIGERD) && !defined(GOTTHARDD) +#if !defined(MYTHEN3D) && !defined(EIGERD) && !defined(GOTTHARDD) && \ + !defined(GOTTHARD2D) functionNotImplemented(); #else ret = isMaster(&retval);