From f78f02558a3459f2b51f2775dac169bb77302592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derqvist?= Date: Mon, 23 Nov 2026 13:53:11 +0100 Subject: [PATCH] Fix a bug that active mode isn't set when all magnets demand are 0. set_values[] is a misused variable that is initized to -2.0f. It is used as a flag in certain parts of the code, and is only updated if a magnet's demand value is set. This causes issues when not all magnets have be set during the life cycle of the frontend. It's supposed to transition ZFC to active mode, once all magnet's demand values are 0. But if some haven't been set, they aren't seen as having a 0 value and it's not transitioning ZFC to active mode. --- device/expmag.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/device/expmag.cxx b/device/expmag.cxx index 7354c95..2259218 100644 --- a/device/expmag.cxx +++ b/device/expmag.cxx @@ -3906,12 +3906,17 @@ mode_again: if (value == 0.0) { // if this device was set to 0.0 int i; + float chk[EMNDEVS]; newmode = 1; // assume ACTIVE mode // and check other magnets + if (get_demand_array(info, chk) != DB_SUCCESS) + for (i = 0; i < EMNDEVS; i++) + chk[i] = info->set_values[i]; + for (i=0;iexpmag_settings.used[i] == 'Y') { - if (info->set_values[i] != 0.0) { + if (chk[i] != 0.0) { // HELM == -1 and HELMH2DAC or WEH82 == -1 are special cases. // special case: HELM is not used to set field (-1). // -1 is used to change polarity to attach another power @@ -3924,7 +3929,7 @@ mode_again: #else (strcmp(info->expmag_settings.device[i],"HELMH2DAC") == 0) #endif - ) && (info->set_values[i] == -1.0)) { + ) && (chk[i] == -1.0)) { /* do nothing */; } else { newmode = 2; // switch to TABLE mode -- 2.54.1