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

fix: applied requested changes (by @langlois in !3)

parent 6a75fbda
No related branches found
No related tags found
No related merge requests found
......@@ -381,13 +381,15 @@ void SingleShotAO::init_device()
// Remove existing dynamic attributes to avoid duplicates or other issues
// --------------------------------------------
if (m_dyn_attr_manager) {
try {
try
{
m_dyn_attr_manager->remove_attributes();
delete m_dyn_attr_manager;
m_dyn_attr_manager = NULL;
DEBUG_STREAM << "Existing dynamic attributes manager cleaned up" << endl;
}
catch (...) {
catch (...)
{
ERROR_STREAM << "Error cleaning up existing dynamic attributes manager, continuing..." << endl;
// Continue anyway - we'll create a new one
}
......@@ -424,12 +426,6 @@ void SingleShotAO::init_device()
INFO_STREAM << "Creating dynamic attributes for " << m_nb_chan << " channels.";
INFO_STREAM << "Total attributes: " << m_nb_chan * (enableRamps ? 3 : 1) << endl;
// if enableRamps if false, skip speed and initial attributes
if (!enableRamps)
{
INFO_STREAM << "Ramps are disabled. Skipping speed and initial attributes" << std::endl;
}
for (unsigned int l_cpt = 0; l_cpt < m_nb_chan; l_cpt++)
{
yat::OSStream oss;
......@@ -454,7 +450,7 @@ void SingleShotAO::init_device()
dai_channel.tai.max_value = "10.0";
dai_channel.tai.min_value = "-10.0";
dai_channel.tai.description = "Output value for channel " + oss.str() + " (in measurementUnit).";
dai_channel.tai.format = "%1.2f";
dai_channel.tai.format = "%2.1f";
dai_channel.cdb = false;
//- read callback
......@@ -490,7 +486,7 @@ void SingleShotAO::init_device()
dai_speed.tai.standard_unit = "V/s";
dai_speed.tai.display_unit = "V/s";
dai_speed.tai.description = "Speed for ramp generation, in V/s. If speed is NULL, no ramp generated but direct write on channel output " + oss.str() + " (in measurementUnit).";
dai_speed.tai.format = "%1.2f";
dai_speed.tai.format = "%2.1f";
//- cleanup tango db option: cleanup tango db when removing this dyn. attr. (i.e. erase its properties from db)
dai_speed.cdb = false;
......@@ -523,7 +519,7 @@ void SingleShotAO::init_device()
dai_initial.tai.standard_unit = "V";
dai_initial.tai.display_unit = "V";
dai_initial.tai.description = "Initial value for ramp function, in V. Defaults to last written value in channel attribute " + oss.str() + ".";
dai_initial.tai.format = "%1.2f";
dai_initial.tai.format = "%2.1f";
//- cleanup tango db option: cleanup tango db when removing this dyn. attr. (i.e. erase its properties from db)
dai_initial.cdb = false;
......@@ -543,17 +539,20 @@ void SingleShotAO::init_device()
INFO_STREAM << "Prepared " << l_dynAttrList.size() << " dynamic attributes for creation" << endl;
// Add all attributes
try {
try
{
m_dyn_attr_manager->add_attributes(l_dynAttrList);
INFO_STREAM << "Successfully added all dynamic attributes" << endl;
}
catch (Tango::DevFailed &df) {
catch (Tango::DevFailed &df)
{
ERROR_STREAM << "Failed to add dynamic attributes: " << df << endl;
m_currStatus = "Failed to add dynamic attributes. See log for details";
m_state = Tango::FAULT;
return;
}
catch (...) {
catch (...)
{
ERROR_STREAM << "Unknown exception when adding dynamic attributes" << endl;
m_currStatus = "Failed to add dynamic attributes. Unknown error";
m_state = Tango::FAULT;
......@@ -561,7 +560,8 @@ void SingleShotAO::init_device()
}
// Initialize maps in manager class for all channels
try {
try
{
for (unsigned int l_cpt = 0; l_cpt < m_nb_chan; l_cpt++) {
// Initialize with default values
m_manager->set_channel(l_cpt, 0.0);
......@@ -588,7 +588,8 @@ void SingleShotAO::init_device()
auto applyMemorizedAttr = [&](const std::string& attrPrefix,
void (SingleShotAOManager::*setter)(yat::uint16, double))
{
try {
try
{
std::string attrName = attrPrefix + oss.str();
double val = yat4tango::PropertyHelper::get_memorized_attribute<double>(this, attrName);
DEBUG_STREAM << "Found memorized value for " << attrName << ": " << val << endl;
......@@ -599,7 +600,8 @@ void SingleShotAO::init_device()
// Write the value to the "write" attributes using helper function
setDynamicAttributeWriteValue(attrName, val);
}
catch (...) {
catch (...)
{
// nothing to do
}
};
......@@ -1131,7 +1133,8 @@ void SingleShotAO::write_initial(yat4tango::DynamicAttributeWriteCallbackData &
*/
bool SingleShotAO::setDynamicAttributeWriteValue(const std::string& attrName, double value)
{
try {
try
{
Tango::DeviceImpl* dev = static_cast<Tango::DeviceImpl*>(this);
Tango::DevDouble val_to_write = value;
......@@ -1142,12 +1145,14 @@ bool SingleShotAO::setDynamicAttributeWriteValue(const std::string& attrName, do
DEBUG_STREAM << "Set write value for " << attrName << " to " << value << endl;
return true;
}
catch (Tango::DevFailed &df) {
catch (Tango::DevFailed &df)
{
ERROR_STREAM << "Failed to set write value for " << attrName
<< ": " << df << endl;
return false;
}
catch (...) {
catch (...)
{
ERROR_STREAM << "Unknown exception setting write value for "
<< attrName << endl;
return false;
......
......@@ -54,9 +54,11 @@ public:
double get_channel(ChannelId_t p_chIdx);
//- set channel
// Updates the value for the channel in the device without sending it to hardware
void set_channel(ChannelId_t p_chIdx, double p_val);
//- write channel
// Writes value to the channel to the device and the hardware, with a ramp if speed is not null and EnableRamps property is true
void write_channel(ChannelId_t p_chIdx, double p_val);
//- write a channel directly (without ramp)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment