Skip to content
Snippets Groups Projects
Commit c725c419 authored by Alexandre MALFREYT's avatar Alexandre MALFREYT
Browse files

refactor: use Tango 8 attr memorization (removed workaround)

parent d326b572
No related branches found
No related tags found
2 merge requests!4develop -> main,!2[CTRLRFC-1594] Apply memorized dynamic attributes at init
......@@ -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);
}
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment