Fix a bug that ZFC active mode isn't set when all magnets demand are 0. #3

Merged
soederqvist_a merged 1 commits from gps-zfc-active-mode-fix into main 2026-11-23 16:59:31 +01:00
+7 -2
View File
@@ -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;i<EMNDEVS;i++) {
if (info->expmag_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