diff --git a/src/ServiceDiscovery/SlowControlCollection.cpp b/src/ServiceDiscovery/SlowControlCollection.cpp index 6ee3138..f65c6f9 100644 --- a/src/ServiceDiscovery/SlowControlCollection.cpp +++ b/src/ServiceDiscovery/SlowControlCollection.cpp @@ -694,6 +694,7 @@ bool SlowControlCollection::Update(SlowControlCollection* SCC, std::string key, (*SCC)[key]->SetValue(value); //(*SCC)[key]->Print(); + /* SCFunction tmp_func= (*SCC)[key]->GetChangeFunction(); if (tmp_func!=nullptr){ try{ @@ -703,11 +704,13 @@ bool SlowControlCollection::Update(SlowControlCollection* SCC, std::string key, catch(...){ reply= "change function failed"; } - } + } + */ } else reply = key + " locked"; } else{ + /* SCFunction tmp_func= (*SCC)[key]->GetReadFunction(); if (tmp_func!=nullptr){ try{ @@ -718,8 +721,8 @@ bool SlowControlCollection::Update(SlowControlCollection* SCC, std::string key, } } else (*SCC)[key]->GetValue(reply); - - + */ + (*SCC)[key]->GetValue(reply); } } return true; diff --git a/src/ServiceDiscovery/SlowControlElement.cpp b/src/ServiceDiscovery/SlowControlElement.cpp index 0448845..753e1af 100644 --- a/src/ServiceDiscovery/SlowControlElement.cpp +++ b/src/ServiceDiscovery/SlowControlElement.cpp @@ -35,12 +35,19 @@ std::string SlowControlElement::Print(){ else if (m_type==SlowControlElementType(OPTIONS)) out+="OPTIONS\""; else if (m_type==SlowControlElementType(COMMAND)) out+="COMMAND\""; else if (m_type==SlowControlElementType(INFO)) out+="INFO\""; - - mtx.lock(); + mtx.lock(); + if(m_read_function!=0){ + try{ + options.Set("value",m_read_function("")); + } + catch(...){ + std::cerr<<"failed to call read fucntion"<::iterator it=options.begin(); it!=options.end(); it++){ - out+=",\""+it->first+"\":"+it->second; } out+="}"; @@ -210,6 +217,16 @@ bool SlowControlElement::SetValue(const char value[]){ bool SlowControlElement::SetValue(std::string value){ mtx.lock(); + + if(m_change_function!=0){ + try{ + m_change_function(value.c_str()); + } + catch(...){ + std::cerr<<"failed to call change fucntion"<max) value=max; } } + if(m_change_function!=0){ + std::stringstream tmp; + tmp< T GetValue(){ T tmp; mtx.lock(); + if(m_read_function!=0){ + try{ + options.Set("value",m_read_function("")); + } + catch(...){ + std::cerr<<"failed to call read fucntion"< bool GetValue(T &value){ - mtx.lock(); + mtx.lock(); + if(m_read_function!=0){ + try{ + options.Set("value",m_read_function("")); + } + catch(...){ + std::cerr<<"failed to call read fucntion"<