From 89898becedd1f8e6207f5b0721578aab06dc22ad Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 26 May 2021 12:23:46 +0200 Subject: [PATCH] m3:different exception message for vths when counter disabled --- .../src/slsDetectorServer_funcs.c | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 765f95a14..17a31bf0c 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -1240,11 +1240,29 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) { ret = FAIL; #ifdef MYTHEN3D // give a different exception message if counter not enabled - uint32_t counter_retval = getCounterMask(); - if ((serverDacIndex == M_VTHRESHOLD || - serverDacIndex == M_VTH1 || serverDacIndex == M_VTH2 || - serverDacIndex == M_VTH3) && - counter_retval != MAX_COUNTER_MSK) { + int isCounterError = 0; + if (serverDacIndex == M_VTHRESHOLD || + serverDacIndex == M_VTH1 || serverDacIndex == M_VTH2 || + serverDacIndex == M_VTH3) { + uint32_t counter_retval = getCounterMask(); + // vthreshold, all counters should have been enabled + if (serverDacIndex == M_VTHRESHOLD) { + if (counter_retval != MAX_COUNTER_MSK) { + isCounterError = 1; + } + } + // corresponding counter should have been enabled + else { + int vthdacs[] = {M_VTH1, M_VTH2, M_VTH3}; + for (int i = 0; i < NCOUNTERS; ++i) { + if ((vthdacs[i] == (int)serverDacIndex) && + (!(counter_retval & (1 << i)))) { + isCounterError = 1; + } + } + } + } + if (isCounterError) { strcpy(mess, "Could not set dac as counter disabled\n"); } else #endif