From c725c419534d6db0baf1e1c7988e13f8a28390c4 Mon Sep 17 00:00:00 2001 From: MALFREYT <alexandre.malfreyt@synchrotron-soleil.fr> Date: Thu, 20 Feb 2025 11:14:06 +0100 Subject: [PATCH] refactor: use Tango 8 attr memorization (removed workaround) --- src/SingleShotAO.cpp | 14 ++------- src/SingleShotAO.h | 70 -------------------------------------------- 2 files changed, 3 insertions(+), 81 deletions(-) diff --git a/src/SingleShotAO.cpp b/src/SingleShotAO.cpp index 8091197..21f3c40 100755 --- a/src/SingleShotAO.cpp +++ b/src/SingleShotAO.cpp @@ -505,9 +505,7 @@ void SingleShotAO::init_device() std::string attr_name = kINITIAL + oss.str(); std::string name = "__" + attr_name; - // To be activated with Tango 8 - //double l_val = yat4tango::PropertyHelper::get_memorized_attribute<double>(this,name); - double l_val = get_memorized_attribute<double>(name); + double l_val = yat4tango::PropertyHelper::get_memorized_attribute<double>(this,name); m_manager->set_initial(l_cpt, l_val); } catch (...) @@ -896,10 +894,7 @@ void SingleShotAO::write_speed(yat4tango::DynamicAttributeWriteCallbackData & cb "could not write initial [unknown error]", "SingleShotAO::write_initial"); } - // To be activated with Tango 8 - //yat4tango::PropertyHelper::set_memorized_attribute(this, l_attr_name, l_val); - std::string name = "__" + l_attr_name; - store_value_as_property(l_val, name); + yat4tango::PropertyHelper::set_memorized_attribute(this, l_attr_name, l_val); } @@ -969,10 +964,7 @@ void SingleShotAO::write_initial(yat4tango::DynamicAttributeWriteCallbackData & "could not write initial [unknown error]", "SingleShotAO::write_initial"); } - // To be activated with Tango 8 - //yat4tango::PropertyHelper::set_memorized_attribute(this, l_attr_name, l_val); - std::string name = "__" + l_attr_name; - store_value_as_property(l_val, name); + yat4tango::PropertyHelper::set_memorized_attribute(this, l_attr_name, l_val); } diff --git a/src/SingleShotAO.h b/src/SingleShotAO.h index 61f5f60..41ed361 100755 --- a/src/SingleShotAO.h +++ b/src/SingleShotAO.h @@ -279,76 +279,6 @@ protected : //- channel number unsigned short m_nb_chan; - // To be deleted with Tango 8 - //- Template class to store a current value in a Device property. - //- \param value Value to store. - //- \param property_name Name to use. - template <class T> - void store_value_as_property(T value, std::string property_name) - { - Tango::DbDatum current_value(property_name); - current_value << value; - Tango::DbData db_data; - db_data.push_back(current_value); - - try - { - get_db_device()->put_property(db_data); - } - catch(Tango::DevFailed &df) - { - ERROR_STREAM << df << endl; - RETHROW_DEVFAILED(df, - "SOFTWARE_FAILURE", - "Error while storing properties in database", - "SingleShotAO::store_value_as_property"); - } - } - - // To be deleted with Tango 8 - //- Template class to get a memorized attribute stored as a Device property. - //- \param property_name Name od the property to read. - template <class T> - T get_memorized_attribute(const std::string& property_name) - { - T value; - if (!Tango::Util::instance()->_UseDb) - { - //- throw exception - THROW_DEVFAILED("DEVICE_ERROR", - "No DATA BASE!", - "SingleShotAO::get_memorized_attribute"); - } - - Tango::DbData dev_prop; - dev_prop.push_back(Tango::DbDatum(property_name)); - - try - { - get_db_device()->get_property(dev_prop); - } - catch (Tango::DevFailed &df) - { - //- rethrow exception - RETHROW_DEVFAILED(df, - "DEVICE_ERROR", - "could not get Device properties! [caught Tango::DevFailed]", - "SingleShotAO::get_memorized_attribute"); - } - - if (dev_prop[0].is_empty()==false) - { - dev_prop[0] >> value; - } - else - { - //- throw exception - THROW_DEVFAILED("DATA_ERROR", - "No property stored in database!", - "SingleShotAO::get_memorized_attribute"); - } - return value; - } }; } // namespace_ns -- GitLab