From 1753f92c226e59b93aa8df7a4cc77c88d2a6e8f4 Mon Sep 17 00:00:00 2001 From: marcus o'flaherty Date: Fri, 7 Aug 2026 17:13:48 +0000 Subject: [PATCH] make SetChangeConfigFunc, SetRunStopFunc and SetExportConfigFunc wrappers around Services, to which the content has migrated --- src/DAQInterface.cpp | 150 +------------------------------------------ 1 file changed, 3 insertions(+), 147 deletions(-) diff --git a/src/DAQInterface.cpp b/src/DAQInterface.cpp index d125f9a..75d9d19 100644 --- a/src/DAQInterface.cpp +++ b/src/DAQInterface.cpp @@ -353,157 +353,13 @@ void DAQInterface::ClearState(){ } bool DAQInterface::SetChangeConfigFunc(std::function func){ - - // we'll make three things that call this function: - // 1. subscribe to alerts. - // 2. a BUTTON slow control. - // 3. a COMMAND slow control. - // However, the signatures here are different: - // Alert callbacks receive an alert name and payload, and return a bool. - // Slow controls receive a control name, and return a string. - // COMMANDs have an associated string variable in the SlowControlCollection, but buttons don't. - // The idea here is the Alert and BUTTON will retrieve their configuration from the LocalConfig member of - // the SlowControlCollection, while the COMMAND will get its configuration from the slow control variable. - // To align these we accept something whihc is none of these, and pass it whatever's appropriate. - bool allgood=true; - - // 1. - allgood = AlertSubscribe("ChangeConfig", [this, func](const char*, const char*) -> bool{ - if(func(m_services->GetLocalConfig())) return true; - SetWarning(true); - std::cerr<<"ChangeConfig Error"< std::string { - sc_vars["Config"]->SetValue((int)ConfigState::ChangeStart); - bool ok = func(m_services->GetLocalConfig()); - if(!ok){ - std::cerr<<"ChangeConfig Error"<SetValue(new_state); - sc_vars["NewConfig"]->SetValue(0); - // FIXME dcsdue to a present bug in the webserver, if we leave a JSON value - // in a slow control, it will break the display of slow controls. :( - return (ok ? "OK" : "Error"); - }, - 0, - false); // this version will not be locked during non-testing runs, - // since it only allows loading configurations in line with the current run type. - - // 3. - allgood = allgood && - sc_vars.Add("ChangeToConfig", - COMMAND, - [this, func](const char* name) -> std::string { - sc_vars["Config"]->SetValue((int)ConfigState::ChangeStart); - bool ok = func(sc_vars[name]->GetValue()); - int new_state = ok ? (int)ConfigState::ChangeEnd : (int)ConfigState::ChangeFail; - sc_vars["Config"]->SetValue(new_state); - if(!ok){ - SetWarning(true); - std::cerr<<"ChangeConfig Error"<SetChangeConfigFunc(func); } bool DAQInterface::SetRunStopFunc(std::function func){ - - // as per SetChangeConfigFunc, but for RunStop, make: - // 1. subscribe to alerts. - // 2. a BUTTON slow control. - // as an addition, on RunStop clear the Services class' last base and runmode configuration IDs. - // the ChangeConfig callback is only invoked when these change, so by resetting them we ensure - // the callback is invoked on the next ChangeConfig alert, - // which may be required to re-start data acquisition after a RunStop. - bool allgood=true; - - // 1. - allgood = AlertSubscribe("RunStop", [this, func](const char*, const char*) -> bool{ - m_services->ResetConfigIDs(); - if(func()) return true; - SetWarning(true); - std::cerr<<"RunStop Error"< std::string { - m_services->ResetConfigIDs(); - bool ok = func(); - if(!ok){ - SetWarning(true); - std::cerr<<"RunStop Error"<SetValue((int)ConfigState::Unconfigured); - return (ok ? "OK" : "Error"); - }, - 0, - false); // this version will not be locked during non-testing runs, - // since it only allows loading configurations in line with the current run type. - - return allgood; - + return m_services->SetRunStopFunc(func); } bool DAQInterface::SetExportConfigFunc(std::function func){ - - // for ExportConfig, make: - // 1. subscribe to alerts. - // 2. a BUTTON slow control. - bool allgood=true; - - // 1. - allgood = AlertSubscribe("ExportConfig", [this, func](const char*, const char*) -> bool{ - if(func(tmp_config)) return true; - SetWarning(true); - std::cerr<<"ExportConfig Error"< std::string { - - bool ok = func(tmp_config); - if(!ok){ - SetWarning(true); - std::cerr<<"ExportConfig Error"<SetExportConfigFunc(func); }