diff --git a/src/ServiceDiscovery/SlowControlCollection.cpp b/src/ServiceDiscovery/SlowControlCollection.cpp index f44a9aed..906599f7 100644 --- a/src/ServiceDiscovery/SlowControlCollection.cpp +++ b/src/ServiceDiscovery/SlowControlCollection.cpp @@ -737,28 +737,21 @@ bool SlowControlCollection::Update(SlowControlCollection* SCC, std::string key, //printf("d0 %s = %s : %s\n", reply.c_str(), key.c_str(), value.c_str()); if(value!=""){ if(!testing || (testing && !(*SCC)[key]->Lockable())){ - - if(!(*SCC)[key]->SetValue(value)){ + + std::string change_result; + if(!(*SCC)[key]->SetValue(value, change_result)){ reply =" Error setting "+key+" to value: " + value; return false; } else{ - reply = value; + // A change function's actual return (e.g. ExportConfig's JSON + // payload) matters for some controls - fall back to echoing + // value for the common case of no change function / nothing + // returned, matching the old behaviour. + reply = change_result.empty() ? value : change_result; return true; } //(*SCC)[key]->Print(); - /* - SCFunction tmp_func= (*SCC)[key]->GetChangeFunction(); - if (tmp_func!=nullptr){ - try{ - reply=tmp_func(key.c_str()); - - } - catch(...){ - reply= "change function failed"; - } - } - */ } else reply = key + " locked"; } diff --git a/src/ServiceDiscovery/SlowControlElement.cpp b/src/ServiceDiscovery/SlowControlElement.cpp index fad1e466..1db40533 100644 --- a/src/ServiceDiscovery/SlowControlElement.cpp +++ b/src/ServiceDiscovery/SlowControlElement.cpp @@ -216,6 +216,11 @@ bool SlowControlElement::SetValue(const char value[]){ bool SlowControlElement::SetValue(std::string value){ + std::string result; + return SetValue(value, result); +} + +bool SlowControlElement::SetValue(std::string value, std::string& result){ mtx.lock(); if(m_type == SlowControlElementType(VARIABLE)){ @@ -225,10 +230,10 @@ bool SlowControlElement::SetValue(std::string value){ mtx.unlock(); return SetValue(val); } - + if(m_change_function!=0){ try{ - m_change_function(value.c_str()); + result = m_change_function(value.c_str()); } catch(...){ std::cerr<<"failed to call change fucntion"<