From 4300e95a8ed217b20cd8d1edea2134c3f6d2bd2d Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 27 May 2020 14:37:52 +0200 Subject: [PATCH] virtual, adding veto command --- .../gotthard2DetectorServer/RegisterDefs.h | 2 + .../slsDetectorFunctionList.c | 35 ++++++++++++---- .../include/slsDetectorFunctionList.h | 2 + .../include/slsDetectorServer_funcs.h | 4 +- .../src/slsDetectorServer_funcs.c | 42 +++++++++++++++++++ slsSupportLib/include/sls_detector_funcs.h | 5 ++- 6 files changed, 80 insertions(+), 10 deletions(-) diff --git a/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h b/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h index 7c7c5a03c..5879a87b2 100644 --- a/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h +++ b/slsDetectorServers/gotthard2DetectorServer/RegisterDefs.h @@ -89,6 +89,8 @@ #define CONFIG_VETO_ENBL_OFST (0) #define CONFIG_VETO_ENBL_MSK (0x00000001 << CONFIG_VETO_ENBL_OFST) +#define CONFIG_VETO_CH_10GB_ENBL_OFST (1) +#define CONFIG_VETO_CH_10GB_ENBL_MSK (0x00000001 << CONFIG_VETO_CH_10GB_ENBL_OFST) /* Control RW register */ #define CONTROL_REG (0x21 * REG_OFFSET + BASE_CONTROL) diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index 0790943f8..fcab7c935 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -1295,23 +1295,21 @@ void setNumberofUDPInterfaces(int val) { // 2 interfaces (enable veto) if (val > 1) { - LOG(logINFOBLUE, - ("Setting #Interfaces: 2 (enabling veto streaming)\n")); - bus_w(addr, bus_r(addr) | CONFIG_VETO_ENBL_MSK); + LOG(logINFOBLUE, ("Setting #Interfaces: 2 (10gbps veto streaming)\n")); + bus_w(addr, bus_r(addr) | CONFIG_VETO_CH_10GB_ENBL_MSK); } // 1 interface (disable veto) else { - LOG(logINFOBLUE, - ("Setting #Interfaces: 1 (disabling veto streaming)\n")); - bus_w(addr, bus_r(addr) & ~CONFIG_VETO_ENBL_MSK); + LOG(logINFOBLUE, ("Setting #Interfaces: 1 (2.5gbps veto streaming)\n")); + bus_w(addr, bus_r(addr) & ~CONFIG_VETO_CH_10GB_ENBL_MSK); } LOG(logDEBUG, ("config reg:0x%x\n", bus_r(addr))); } int getNumberofUDPInterfaces() { LOG(logDEBUG, ("config reg:0x%x\n", bus_r(CONFIG_REG))); - // return 2 if veto enabled, else 1 - return ((bus_r(CONFIG_REG) & CONFIG_VETO_ENBL_MSK) ? 2 : 1); + // return 2 if 10gbps veto streaming enabled, else 1 + return ((bus_r(CONFIG_REG) & CONFIG_VETO_CH_10GB_ENBL_MSK) ? 2 : 1); } void setupHeader(int iRxEntry, int vetoInterface, uint32_t destip, @@ -2207,6 +2205,27 @@ enum timingSourceType getTimingSource() { return TIMING_INTERNAL; } +void setVeto(int enable) { + if (enable >= 0) { + uint32_t addr = CONFIG_REG; + + if (enable) { + LOG(logINFOBLUE, ("Enabling veto streaming\n")); + bus_w(addr, bus_r(addr) | CONFIG_VETO_ENBL_MSK); + } else { + LOG(logINFOBLUE, ("Disabling veto streaming\n")); + bus_w(addr, bus_r(addr) & ~CONFIG_VETO_ENBL_MSK); + } + LOG(logDEBUG, ("config reg:0x%x\n", bus_r(addr))); + } +} + +int getVeto() { + LOG(logDEBUG, ("config reg:0x%x\n", bus_r(CONFIG_REG))); + return ((bus_r(CONFIG_REG) & CONFIG_VETO_ENBL_MSK) >> + CONFIG_VETO_ENBL_OFST); +} + /* aquisition */ int startStateMachine() { diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 9c14c6460..febe29d11 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -518,6 +518,8 @@ void setCurrentSource(int value); int getCurrentSource(); void setTimingSource(enum timingSourceType value); enum timingSourceType getTimingSource(); +void setVeto(int enable); +int getVeto(); #endif #if defined(JUNGFRAUD) || defined(EIGERD) diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index 78d62c088..4513eb63c 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -224,4 +224,6 @@ int get_num_gates(int); int set_gate_delay(int); int get_gate_delay(int); int get_exptime_all_gates(int); -int get_gate_delay_all_gates(int); \ No newline at end of file +int get_gate_delay_all_gates(int); +int get_veto(int); +int set_veto(int); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 7fac645a1..800754f7e 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -336,6 +336,8 @@ void function_table() { flist[F_GET_GATE_DELAY] = &get_gate_delay; flist[F_GET_EXPTIME_ALL_GATES] = &get_exptime_all_gates; flist[F_GET_GATE_DELAY_ALL_GATES] = &get_gate_delay_all_gates; + flist[F_GET_VETO] = &get_veto; + flist[F_SET_VETO] = &set_veto; // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { @@ -7420,3 +7422,43 @@ int get_gate_delay_all_gates(int file_des) { #endif return Server_SendResult(file_des, INT64, retvals, sizeof(retvals)); } + +int get_veto(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + int retval = -1; + + LOG(logDEBUG1, ("Getting veto\n")); + +#ifndef GOTTHARD2D + functionNotImplemented(); +#else + // get only + retval = getVeto(); + LOG(logDEBUG1, ("veto mode retval: %u\n", retval)); +#endif + return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); +} + +int set_veto(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + int arg = 0; + + if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) + return printSocketReadError(); + LOG(logINFO, ("Setting veto mode: %u\n", arg)); + +#ifndef GOTTHARD2D + functionNotImplemented(); +#else + // only set + if (Server_VerifyLock() == OK) { + setVeto(arg); + int retval = getVeto(); + LOG(logDEBUG1, ("veto mode retval: %u\n", retval)); + validate(arg, retval, "set veto mode", DEC); + } +#endif + return Server_SendResult(file_des, INT32, NULL, 0); +} diff --git a/slsSupportLib/include/sls_detector_funcs.h b/slsSupportLib/include/sls_detector_funcs.h index 93326c79f..ab70c32c6 100755 --- a/slsSupportLib/include/sls_detector_funcs.h +++ b/slsSupportLib/include/sls_detector_funcs.h @@ -205,6 +205,8 @@ enum detFuncs { F_GET_GATE_DELAY, F_GET_EXPTIME_ALL_GATES, F_GET_GATE_DELAY_ALL_GATES, + F_GET_VETO, + F_SET_VETO, NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 256, /**< detector function should not exceed this @@ -508,7 +510,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_GET_GATE_DELAY: return "F_GET_GATE_DELAY"; case F_GET_EXPTIME_ALL_GATES: return "F_GET_EXPTIME_ALL_GATES"; case F_GET_GATE_DELAY_ALL_GATES: return "F_GET_GATE_DELAY_ALL_GATES"; - + case F_GET_VETO: return "F_GET_VETO"; + case F_SET_VETO: return "F_SET_VETO"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";