diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index 0b9edfe78..62c9c7bd3 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -1112,8 +1112,7 @@ enum detectorSettings setSettings(enum detectorSettings sett) { if (sett == UNINITIALIZED) { return thisSettings; } - if (sett != GET_SETTINGS) - thisSettings = sett; + thisSettings = sett; LOG(logINFO, ("Settings: %d\n", thisSettings)); return thisSettings; } @@ -1355,7 +1354,7 @@ enum timingMode getTiming() { return GATED; default: LOG(logERROR, ("Unknown trigger mode found %d\n", eiger_triggermode)); - return GET_TIMING_MODE; + return GET_FLAG; } } diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index 81567ff37..bb1cc01c4 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -1044,34 +1044,31 @@ enum detectorSettings setSettings(enum detectorSettings sett) { // set settings uint32_t addr = ASIC_CONFIG_REG; uint32_t mask = ASIC_CONFIG_GAIN_MSK; - if (sett != GET_SETTINGS) { - switch (sett) { - case DYNAMICGAIN: - bus_w(addr, bus_r(addr) & ~mask); - bus_w(addr, bus_r(addr) | ASIC_CONFIG_DYNAMIC_GAIN_VAL); - LOG(logINFO, ("Set settings - Dyanmic Gain, val: 0x%x\n", - bus_r(addr) & mask)); - break; - case FIXGAIN1: - bus_w(addr, bus_r(addr) & ~mask); - bus_w(addr, bus_r(addr) | ASIC_CONFIG_FIX_GAIN_1_VAL); - LOG(logINFO, - ("Set settings - Fix Gain 1, val: 0x%x\n", bus_r(addr) & mask)); - break; - case FIXGAIN2: - bus_w(addr, bus_r(addr) & ~mask); - bus_w(addr, bus_r(addr) | ASIC_CONFIG_FIX_GAIN_2_VAL); - LOG(logINFO, - ("Set settings - Fix Gain 2, val: 0x%x\n", bus_r(addr) & mask)); - break; - default: - LOG(logERROR, - ("This settings is not defined for this detector %d\n", - (int)sett)); - return -1; - } - thisSettings = sett; + switch (sett) { + case DYNAMICGAIN: + bus_w(addr, bus_r(addr) & ~mask); + bus_w(addr, bus_r(addr) | ASIC_CONFIG_DYNAMIC_GAIN_VAL); + LOG(logINFO, + ("Set settings - Dyanmic Gain, val: 0x%x\n", bus_r(addr) & mask)); + break; + case FIXGAIN1: + bus_w(addr, bus_r(addr) & ~mask); + bus_w(addr, bus_r(addr) | ASIC_CONFIG_FIX_GAIN_1_VAL); + LOG(logINFO, + ("Set settings - Fix Gain 1, val: 0x%x\n", bus_r(addr) & mask)); + break; + case FIXGAIN2: + bus_w(addr, bus_r(addr) & ~mask); + bus_w(addr, bus_r(addr) | ASIC_CONFIG_FIX_GAIN_2_VAL); + LOG(logINFO, + ("Set settings - Fix Gain 2, val: 0x%x\n", bus_r(addr) & mask)); + break; + default: + LOG(logERROR, + ("This settings is not defined for this detector %d\n", (int)sett)); + return -1; } + thisSettings = sett; return getSettings(); } diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c index 10dbc7bb8..58b9b1c21 100644 --- a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c @@ -950,44 +950,41 @@ enum detectorSettings setSettings(enum detectorSettings sett) { return thisSettings; // set settings - if (sett != GET_SETTINGS) { - u_int32_t addr = GAIN_REG; + u_int32_t addr = GAIN_REG; - // find conf gain value - uint32_t confgain = 0x0; - switch (sett) { - case DYNAMICGAIN: - LOG(logINFO, ("Set settings - Dyanmic Gain\n")); - confgain = GAIN_CONFGAIN_DYNMC_GAIN_VAL; - break; - case HIGHGAIN: - LOG(logINFO, ("Set settings - High Gain\n")); - confgain = GAIN_CONFGAIN_HGH_GAIN_VAL; - break; - case LOWGAIN: - LOG(logINFO, ("Set settings - Low Gain\n")); - confgain = GAIN_CONFGAIN_LW_GAIN_VAL; - break; - case MEDIUMGAIN: - LOG(logINFO, ("Set settings - Medium Gain\n")); - confgain = GAIN_CONFGAIN_MDM_GAIN_VAL; - break; - case VERYHIGHGAIN: - LOG(logINFO, ("Set settings - Very High Gain\n")); - confgain = GAIN_CONFGAIN_VRY_HGH_GAIN_VAL; - break; - default: - LOG(logERROR, - ("This settings is not defined for this detector %d\n", - (int)sett)); - return -1; - } - // set conf gain - bus_w(addr, bus_r(addr) & ~GAIN_CONFGAIN_MSK); - bus_w(addr, bus_r(addr) | confgain); - LOG(logINFO, ("\tGain Reg: 0x%x\n", bus_r(addr))); - thisSettings = sett; + // find conf gain value + uint32_t confgain = 0x0; + switch (sett) { + case DYNAMICGAIN: + LOG(logINFO, ("Set settings - Dyanmic Gain\n")); + confgain = GAIN_CONFGAIN_DYNMC_GAIN_VAL; + break; + case HIGHGAIN: + LOG(logINFO, ("Set settings - High Gain\n")); + confgain = GAIN_CONFGAIN_HGH_GAIN_VAL; + break; + case LOWGAIN: + LOG(logINFO, ("Set settings - Low Gain\n")); + confgain = GAIN_CONFGAIN_LW_GAIN_VAL; + break; + case MEDIUMGAIN: + LOG(logINFO, ("Set settings - Medium Gain\n")); + confgain = GAIN_CONFGAIN_MDM_GAIN_VAL; + break; + case VERYHIGHGAIN: + LOG(logINFO, ("Set settings - Very High Gain\n")); + confgain = GAIN_CONFGAIN_VRY_HGH_GAIN_VAL; + break; + default: + LOG(logERROR, + ("This settings is not defined for this detector %d\n", (int)sett)); + return -1; } + // set conf gain + bus_w(addr, bus_r(addr) & ~GAIN_CONFGAIN_MSK); + bus_w(addr, bus_r(addr) | confgain); + LOG(logINFO, ("\tGain Reg: 0x%x\n", bus_r(addr))); + thisSettings = sett; return getSettings(); } diff --git a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c index f15523473..5e757661e 100644 --- a/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c @@ -753,53 +753,50 @@ enum detectorSettings setSettings(enum detectorSettings sett) { return thisSettings; // set settings - if (sett != GET_SETTINGS) { - switch (sett) { - case DYNAMICGAIN: - bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); - LOG(logINFO, ("Set settings - Dyanmic Gain, DAQ Reg: 0x%x\n", - bus_r(DAQ_REG))); - break; - case DYNAMICHG0: - bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); - bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_HIGHGAIN_VAL); - LOG(logINFO, ("Set settings - Dyanmic High Gain 0, DAQ Reg: 0x%x\n", - bus_r(DAQ_REG))); - break; - case FIXGAIN1: - bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); - bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_STG_1_VAL); - LOG(logINFO, - ("Set settings - Fix Gain 1, DAQ Reg: 0x%x\n", bus_r(DAQ_REG))); - break; - case FIXGAIN2: - bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); - bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_STG_2_VAL); - LOG(logINFO, - ("Set settings - Fix Gain 2, DAQ Reg: 0x%x\n", bus_r(DAQ_REG))); - break; - case FORCESWITCHG1: - bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); - bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FRCE_GAIN_STG_1_VAL); - LOG(logINFO, ("Set settings - Force Switch Gain 1, DAQ Reg: 0x%x\n", - bus_r(DAQ_REG))); - break; - case FORCESWITCHG2: - bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); - bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FRCE_GAIN_STG_2_VAL); - LOG(logINFO, ("Set settings - Force Switch Gain 2, DAQ Reg: 0x%x\n", - bus_r(DAQ_REG))); - break; - default: - LOG(logERROR, - ("This settings is not defined for this detector %d\n", - (int)sett)); - return -1; - } - - thisSettings = sett; + switch (sett) { + case DYNAMICGAIN: + bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); + LOG(logINFO, + ("Set settings - Dyanmic Gain, DAQ Reg: 0x%x\n", bus_r(DAQ_REG))); + break; + case DYNAMICHG0: + bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); + bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_HIGHGAIN_VAL); + LOG(logINFO, ("Set settings - Dyanmic High Gain 0, DAQ Reg: 0x%x\n", + bus_r(DAQ_REG))); + break; + case FIXGAIN1: + bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); + bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_STG_1_VAL); + LOG(logINFO, + ("Set settings - Fix Gain 1, DAQ Reg: 0x%x\n", bus_r(DAQ_REG))); + break; + case FIXGAIN2: + bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); + bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FIX_GAIN_STG_2_VAL); + LOG(logINFO, + ("Set settings - Fix Gain 2, DAQ Reg: 0x%x\n", bus_r(DAQ_REG))); + break; + case FORCESWITCHG1: + bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); + bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FRCE_GAIN_STG_1_VAL); + LOG(logINFO, ("Set settings - Force Switch Gain 1, DAQ Reg: 0x%x\n", + bus_r(DAQ_REG))); + break; + case FORCESWITCHG2: + bus_w(DAQ_REG, bus_r(DAQ_REG) & ~DAQ_SETTINGS_MSK); + bus_w(DAQ_REG, bus_r(DAQ_REG) | DAQ_FRCE_GAIN_STG_2_VAL); + LOG(logINFO, ("Set settings - Force Switch Gain 2, DAQ Reg: 0x%x\n", + bus_r(DAQ_REG))); + break; + default: + LOG(logERROR, + ("This settings is not defined for this detector %d\n", (int)sett)); + return -1; } + thisSettings = sett; + return getSettings(); } diff --git a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c index 54e5531bb..4da87e699 100644 --- a/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/moenchDetectorServer/slsDetectorFunctionList.c @@ -909,49 +909,46 @@ enum detectorSettings setSettings(enum detectorSettings sett) { return thisSettings; // set settings - if (sett != GET_SETTINGS) { - switch (sett) { - case G1_HIGHGAIN: - LOG(logINFO, ("Set settings - G1_HIGHGAIN\n")); - setPatternMask(G1_HIGHGAIN_PATMASK); - break; - case G1_LOWGAIN: - LOG(logINFO, ("Set settings - G1_LOWGAIN\n")); - setPatternMask(G1_LOWGAIN_PATMASK); - break; - case G2_HIGHCAP_HIGHGAIN: - LOG(logINFO, ("Set settings - G2_HIGHCAP_HIGHGAIN\n")); - setPatternMask(G2_HIGHCAP_HIGHGAIN_PATMASK); - break; - case G2_HIGHCAP_LOWGAIN: - LOG(logINFO, ("Set settings - G2_HIGHCAP_LOWGAIN\n")); - setPatternMask(G2_HIGHCAP_LOWGAIN_PATMASK); - break; - case G2_LOWCAP_HIGHGAIN: - LOG(logINFO, ("Set settings - G2_LOWCAP_HIGHGAIN\n")); - setPatternMask(G2_LOWCAP_HIGHGAIN_PATMASK); - break; - case G2_LOWCAP_LOWGAIN: - LOG(logINFO, ("Set settings - G2_LOWCAP_LOWGAIN\n")); - setPatternMask(G2_LOWCAP_LOWGAIN_PATMASK); - break; - case G4_HIGHGAIN: - LOG(logINFO, ("Set settings - G4_HIGHGAIN\n")); - setPatternMask(G4_HIGHGAIN_PATMASK); - break; - case G4_LOWGAIN: - LOG(logINFO, ("Set settings - G4_LOWGAIN\n")); - setPatternMask(G4_LOWGAIN_PATMASK); - break; - default: - LOG(logERROR, - ("This settings is not defined for this detector %d\n", - (int)sett)); - return -1; - } - setPatternBitMask(DEFAULT_PATSETBIT); - thisSettings = sett; + switch (sett) { + case G1_HIGHGAIN: + LOG(logINFO, ("Set settings - G1_HIGHGAIN\n")); + setPatternMask(G1_HIGHGAIN_PATMASK); + break; + case G1_LOWGAIN: + LOG(logINFO, ("Set settings - G1_LOWGAIN\n")); + setPatternMask(G1_LOWGAIN_PATMASK); + break; + case G2_HIGHCAP_HIGHGAIN: + LOG(logINFO, ("Set settings - G2_HIGHCAP_HIGHGAIN\n")); + setPatternMask(G2_HIGHCAP_HIGHGAIN_PATMASK); + break; + case G2_HIGHCAP_LOWGAIN: + LOG(logINFO, ("Set settings - G2_HIGHCAP_LOWGAIN\n")); + setPatternMask(G2_HIGHCAP_LOWGAIN_PATMASK); + break; + case G2_LOWCAP_HIGHGAIN: + LOG(logINFO, ("Set settings - G2_LOWCAP_HIGHGAIN\n")); + setPatternMask(G2_LOWCAP_HIGHGAIN_PATMASK); + break; + case G2_LOWCAP_LOWGAIN: + LOG(logINFO, ("Set settings - G2_LOWCAP_LOWGAIN\n")); + setPatternMask(G2_LOWCAP_LOWGAIN_PATMASK); + break; + case G4_HIGHGAIN: + LOG(logINFO, ("Set settings - G4_HIGHGAIN\n")); + setPatternMask(G4_HIGHGAIN_PATMASK); + break; + case G4_LOWGAIN: + LOG(logINFO, ("Set settings - G4_LOWGAIN\n")); + setPatternMask(G4_LOWGAIN_PATMASK); + break; + default: + LOG(logERROR, + ("This settings is not defined for this detector %d\n", (int)sett)); + return -1; } + setPatternBitMask(DEFAULT_PATSETBIT); + thisSettings = sett; return getSettings(); } diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 4f6687adf..db2e50022 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -1157,37 +1157,35 @@ int setHighVoltage(int val) { /* parameters - timing */ void setTiming(enum timingMode arg) { - if (arg != GET_TIMING_MODE) { - switch (arg) { - case AUTO_TIMING: - LOG(logINFO, ("Set Timing: Auto (Int. Trigger, Int. Gating)\n")); - bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK); - bus_w(ASIC_EXP_STATUS_REG, - bus_r(ASIC_EXP_STATUS_REG) & ~ASIC_EXP_STAT_GATE_SRC_EXT_MSK); - break; - case TRIGGER_EXPOSURE: - LOG(logINFO, ("Set Timing: Trigger (Ext. Trigger, Int. Gating)\n")); - bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK); - bus_w(ASIC_EXP_STATUS_REG, - bus_r(ASIC_EXP_STATUS_REG) & ~ASIC_EXP_STAT_GATE_SRC_EXT_MSK); - break; - case GATED: - LOG(logINFO, ("Set Timing: Gating (Int. Trigger, Ext. Gating)\n")); - bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK); - bus_w(ASIC_EXP_STATUS_REG, - bus_r(ASIC_EXP_STATUS_REG) | ASIC_EXP_STAT_GATE_SRC_EXT_MSK); - break; - case TRIGGER_GATED: - LOG(logINFO, - ("Set Timing: Trigger_Gating (Ext. Trigger, Ext. Gating)\n")); - bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK); - bus_w(ASIC_EXP_STATUS_REG, - bus_r(ASIC_EXP_STATUS_REG) | ASIC_EXP_STAT_GATE_SRC_EXT_MSK); - break; - default: - LOG(logERROR, ("Unknown timing mode %d\n", arg)); - return; - } + switch (arg) { + case AUTO_TIMING: + LOG(logINFO, ("Set Timing: Auto (Int. Trigger, Int. Gating)\n")); + bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK); + bus_w(ASIC_EXP_STATUS_REG, + bus_r(ASIC_EXP_STATUS_REG) & ~ASIC_EXP_STAT_GATE_SRC_EXT_MSK); + break; + case TRIGGER_EXPOSURE: + LOG(logINFO, ("Set Timing: Trigger (Ext. Trigger, Int. Gating)\n")); + bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK); + bus_w(ASIC_EXP_STATUS_REG, + bus_r(ASIC_EXP_STATUS_REG) & ~ASIC_EXP_STAT_GATE_SRC_EXT_MSK); + break; + case GATED: + LOG(logINFO, ("Set Timing: Gating (Int. Trigger, Ext. Gating)\n")); + bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK); + bus_w(ASIC_EXP_STATUS_REG, + bus_r(ASIC_EXP_STATUS_REG) | ASIC_EXP_STAT_GATE_SRC_EXT_MSK); + break; + case TRIGGER_GATED: + LOG(logINFO, + ("Set Timing: Trigger_Gating (Ext. Trigger, Ext. Gating)\n")); + bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK); + bus_w(ASIC_EXP_STATUS_REG, + bus_r(ASIC_EXP_STATUS_REG) | ASIC_EXP_STAT_GATE_SRC_EXT_MSK); + break; + default: + LOG(logERROR, ("Unknown timing mode %d\n", arg)); + return; } } diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 675c4fd77..7e9840510 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -574,15 +574,15 @@ int set_external_signal_flag(int file_des) { int set_timing_mode(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - enum timingMode arg = GET_TIMING_MODE; - enum timingMode retval = GET_TIMING_MODE; + enum timingMode arg = AUTO_TIMING; + enum timingMode retval = AUTO_TIMING; if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0) return printSocketReadError(); LOG(logDEBUG1, ("Setting external communication mode to %d\n", arg)); // set - if ((arg != GET_TIMING_MODE) && (Server_VerifyLock() == OK)) { + if (((int)arg != GET_FLAG) && (Server_VerifyLock() == OK)) { switch (arg) { case AUTO_TIMING: case TRIGGER_EXPOSURE: @@ -1501,7 +1501,6 @@ int set_module(int file_des) { case VERYHIGHGAIN: case VERYLOWGAIN: #elif JUNGFRAUD - case GET_SETTINGS: case DYNAMICGAIN: case DYNAMICHG0: case FIXGAIN1: @@ -1509,14 +1508,11 @@ int set_module(int file_des) { case FORCESWITCHG1: case FORCESWITCHG2: #elif GOTTHARDD - case GET_SETTINGS: case DYNAMICGAIN: case HIGHGAIN: case LOWGAIN: case MEDIUMGAIN: case VERYHIGHGAIN: -#elif MYTHEN3D - case GET_SETTINGS: #endif break; default: @@ -1541,8 +1537,8 @@ int set_module(int file_des) { int set_settings(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); - enum detectorSettings isett = GET_SETTINGS; - enum detectorSettings retval = GET_SETTINGS; + enum detectorSettings isett = STANDARD; + enum detectorSettings retval = STANDARD; if (receiveData(file_des, &isett, sizeof(isett), INT32) < 0) return printSocketReadError(); @@ -1553,58 +1549,62 @@ int set_settings(int file_des) { LOG(logDEBUG1, ("Setting settings %d\n", isett)); // set & get - if ((isett == GET_SETTINGS) || (Server_VerifyLock() == OK)) { + if (((int)isett == GET_FLAG) || (Server_VerifyLock() == OK)) { - // check index - switch (isett) { - case GET_SETTINGS: + if ((int)isett != GET_FLAG) { + // check index + switch (isett) { #ifdef JUNGFRAUD - case DYNAMICGAIN: - case DYNAMICHG0: - case FIXGAIN1: - case FIXGAIN2: - case FORCESWITCHG1: - case FORCESWITCHG2: + case DYNAMICGAIN: + case DYNAMICHG0: + case FIXGAIN1: + case FIXGAIN2: + case FORCESWITCHG1: + case FORCESWITCHG2: #elif GOTTHARDD - case DYNAMICGAIN: - case HIGHGAIN: - case LOWGAIN: - case MEDIUMGAIN: - case VERYHIGHGAIN: + case DYNAMICGAIN: + case HIGHGAIN: + case LOWGAIN: + case MEDIUMGAIN: + case VERYHIGHGAIN: #elif GOTTHARD2D - case DYNAMICGAIN: - case FIXGAIN1: - case FIXGAIN2: + case DYNAMICGAIN: + case FIXGAIN1: + case FIXGAIN2: #elif MOENCHD - case G1_HIGHGAIN: - case G1_LOWGAIN: - case G2_HIGHCAP_HIGHGAIN: - case G2_HIGHCAP_LOWGAIN: - case G2_LOWCAP_HIGHGAIN: - case G2_LOWCAP_LOWGAIN: - case G4_HIGHGAIN: - case G4_LOWGAIN: + case G1_HIGHGAIN: + case G1_LOWGAIN: + case G2_HIGHCAP_HIGHGAIN: + case G2_HIGHCAP_LOWGAIN: + case G2_LOWCAP_HIGHGAIN: + case G2_LOWCAP_LOWGAIN: + case G4_HIGHGAIN: + case G4_LOWGAIN: #endif - break; - default: - if (myDetectorType == EIGER) { - ret = FAIL; - sprintf(mess, "Cannot set settings via SET_SETTINGS, use " - "SET_MODULE (set threshold)\n"); - LOG(logERROR, (mess)); - } else - modeNotImplemented("Settings Index", (int)isett); - break; - } + break; + default: + if (myDetectorType == EIGER) { + ret = FAIL; + sprintf(mess, "Cannot set settings via SET_SETTINGS, use " + "SET_MODULE (set threshold)\n"); + LOG(logERROR, (mess)); + } else + modeNotImplemented("Settings Index", (int)isett); + break; + } - // if index is okay, set & get - if (ret == OK) { - retval = setSettings(isett); - LOG(logDEBUG1, ("Settings: %d\n", retval)); + if (ret == OK) { + setSettings(isett); + } + } + retval = getSettings(); + LOG(logDEBUG1, ("Settings: %d\n", retval)); + + if ((int)isett != GET_FLAG) { validate((int)isett, (int)retval, "set settings", DEC); #if defined(JUNGFRAUD) || defined(GOTTHARDD) // gotthard2 does not set default dacs - if (ret == OK && isett >= 0) { + if (ret == OK) { ret = setDefaultDacs(); if (ret == FAIL) { strcpy(mess, "Could change settings, but could not set to " diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 002682f5f..ebb88a31b 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -569,7 +569,7 @@ Result Detector::getNumberofUDPInterfaces(Positions pos) const { } void Detector::setNumberofUDPInterfaces(int n, Positions pos) { - int previouslyClientStreaming = pimpl->enableDataStreamingToClient(); + int previouslyClientStreaming = pimpl->getDataStreamingToClient(); bool useReceiver = getUseReceiverFlag().squash(false); bool previouslyReceiverStreaming = false; if (useReceiver) { @@ -583,8 +583,8 @@ void Detector::setNumberofUDPInterfaces(int n, Positions pos) { } // redo the zmq sockets if enabled if (previouslyClientStreaming != 0) { - pimpl->enableDataStreamingToClient(0); - pimpl->enableDataStreamingToClient(1); + pimpl->setDataStreamingToClient(false); + pimpl->setDataStreamingToClient(true); } if (previouslyReceiverStreaming) { setRxZmqDataStream(false, pos); @@ -995,11 +995,11 @@ Result Detector::getClientZmqIp(Positions pos) const { } void Detector::setClientZmqIp(const IpAddr ip, Positions pos) { - int previouslyClientStreaming = pimpl->enableDataStreamingToClient(-1); + int previouslyClientStreaming = pimpl->getDataStreamingToClient(); pimpl->Parallel(&Module::setClientStreamingIP, pos, ip); if (previouslyClientStreaming != 0) { - pimpl->enableDataStreamingToClient(0); - pimpl->enableDataStreamingToClient(1); + pimpl->setDataStreamingToClient(false); + pimpl->setDataStreamingToClient(true); } } diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp index 97aa617ee..d35c6ca8c 100644 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -975,19 +975,18 @@ int DetectorImpl::InsertGapPixels(char *image, char *&gpImage, bool quadEnable, return imagesize; } -bool DetectorImpl::enableDataStreamingToClient(int enable) { - if (enable >= 0) { - // destroy data threads - if (enable == 0) { - createReceivingDataSockets(true); - // create data threads - } else { - if (createReceivingDataSockets() == FAIL) { - throw RuntimeError("Could not create data threads in client."); - } +bool DetectorImpl::getDataStreamingToClient() { return client_downstream; } + +void DetectorImpl::setDataStreamingToClient(bool enable) { + // destroy data threads + if (!enable) { + createReceivingDataSockets(true); + // create data threads + } else { + if (createReceivingDataSockets() == FAIL) { + throw RuntimeError("Could not create data threads in client."); } } - return client_downstream; } void DetectorImpl::registerAcquisitionFinishedCallback(void (*func)(double, int, @@ -1003,7 +1002,7 @@ void DetectorImpl::registerDataCallback(void (*userCallback)(detectorData *, void *pArg) { dataReady = userCallback; pCallbackArg = pArg; - enableDataStreamingToClient(dataReady == nullptr ? 0 : 1); + setDataStreamingToClient(dataReady == nullptr ? false : true); } int DetectorImpl::acquire() { diff --git a/slsDetectorSoftware/src/DetectorImpl.h b/slsDetectorSoftware/src/DetectorImpl.h index 480e63ede..28e70e3a3 100644 --- a/slsDetectorSoftware/src/DetectorImpl.h +++ b/slsDetectorSoftware/src/DetectorImpl.h @@ -238,12 +238,8 @@ class DetectorImpl : public virtual slsDetectorDefs { /** [Eiger][Jungfrau] */ void setGapPixelsinCallback(const bool enable); - /** - * Enable data streaming to client - * @param enable 0 to disable, 1 to enable, -1 to get the value - * @returns data streaming to client enable - */ - bool enableDataStreamingToClient(int enable = -1); + bool getDataStreamingToClient(); + void setDataStreamingToClient(bool enable); /** * register callback for accessing acquisition final data