Skip to content
Snippets Groups Projects

[CTRLRFC-1594] Apply memorized dynamic attributes at init

3 files
+ 41
26
Compare changes
  • Side-by-side
  • Inline

Files

+ 20
25
@@ -489,32 +489,25 @@ void SingleShotAO::init_device()
yat::OSStream oss;
oss << l_cpt;
// speed value
try
{
std::string attr_name = kSPEED + oss.str();
std::string name = "__" + attr_name;
double l_val = yat4tango::PropertyHelper::get_memorized_attribute<double>(this, name);
m_manager->set_speed(l_cpt, l_val);
}
catch (...) {
// nothing to do
}
// initial value
try
// Helper function to get and set memorized attributes
auto applyMemorizedAttr = [&](const std::string& attrPrefix,
void (SingleShotAOManager::*setter)(yat::uint16, double))
{
std::string attr_name = kINITIAL + oss.str();
std::string name = "__" + attr_name;
double l_val = yat4tango::PropertyHelper::get_memorized_attribute<double>(this,name);
m_manager->set_initial(l_cpt, l_val);
}
catch (...)
{
//nothing to do
}
try {
std::string attrName = attrPrefix + oss.str();
double val = yat4tango::PropertyHelper::get_memorized_attribute<double>(this, attrName);
(m_manager->*setter)(l_cpt, val);
}
catch (...) {
// nothing to do
}
};
// Get and set memorized values for speed, initial and channel
applyMemorizedAttr(kSPEED, &SingleShotAOManager::set_speed);
applyMemorizedAttr(kINITIAL, &SingleShotAOManager::set_initial);
applyMemorizedAttr(kCHANNEL, &SingleShotAOManager::set_channel);
// TODO: add a property to call write_channel instead of set_channel (false by default)
}
//- GO for task
@@ -850,6 +843,8 @@ void SingleShotAO::write_channel(yat4tango::DynamicAttributeWriteCallbackData &
"could not write channel [unknown error]",
"SingleShotAO::write_channel");
}
yat4tango::PropertyHelper::set_memorized_attribute(this, l_attr_name, l_val);
}
Loading