Reynald,
Thanks for your response.
Regarding the second question;
The DynamicFINSAttribute class was actually copied and renamed from “ModbusDataViewer” under Communication.
After digging into existing code, I found critical bug in there.
The original code in [quote]DynamicAttributesHelper.cpp[/quote] is
void DynamicAttributesHelper::add (DynamicModbusAttribute * _attr)
throw (Tango::DevFailed)
{
// clipped
//- add it to the device
try
{
this->host_device_->add_attribute( _attr );
}
catch(Tango::DevFailed& ex)
{
RETHROW_DEVFAILED(ex,
"INTERNAL_ERROR",
"attribute could not be added to the device",
"DynamicAttributesHelper::add");
}
catch(...)
{
THROW_DEVFAILED("UNKNOWN_ERROR",
"unknown caught while trying to add attribute to the device",
"DynamicAttributesHelper::add");
}
//- ok, everything went fine :
//- insert the attribute into the list
std::pair<DynAttrIt, bool> insertion_result;
insertion_result = this->rep_.insert( DynAttrEntry(_attr->get_name(), _attr) );
The problem is when there’s chances to add duplicate attribute.
Then the add_attribute routine releases the attr without raise exception.
So the program abnormally quitted at the code of[quote] _attr->get_name()[/quote].
I’m not sure whether quick fix for this problem as below is the proper one;
//---------- _FIX_BUG --> added from here
// below copied from DeviceImpl::add_attribute(Tango::Attr *new_attr) at device.cpp
string &attr_name = _attr->get_name();
bool need_free = false;
long i;
vector<Tango::Attr *> &attr_list = this->host_device_->get_device_class()->get_class_attr()->get_attr_list();
long old_attr_nb = attr_list.size();
for (i = 0;i < old_attr_nb;i++)
{
if ((attr_list[i]->get_name() == attr_name) && (attr_list[i]->get_cl_name() == _attr->get_cl_name()))
{
need_free = true;
break;
}
}
//---------- _FIX_BUG --> added to here
//- add it to the device
try
{
this->host_device_->add_attribute( _attr );
}
catch(Tango::DevFailed& ex)
{
RETHROW_DEVFAILED(ex,
"INTERNAL_ERROR",
"attribute could not be added to the device",
"DynamicAttributesHelper::add");
}
catch(...)
{
THROW_DEVFAILED("UNKNOWN_ERROR",
"unknown caught while trying to add attribute to the device",
"DynamicAttributesHelper::add");
}
//---------- _FIX_BUG --> added from here
if (need_free)
{
//_attr is already freed - no longer available
return;
}
//---------- _FIX_BUG --> added to here
//- ok, everything went fine :
//- insert the attribute into the list
std::pair<DynAttrIt, bool> insertion_result;
insertion_result = this->rep_.insert( DynAttrEntry(_attr->get_name(), _attr) ); // no more abnormal quit here!!!
I wish the add_attribute function returns result value, not just deleting the passed parameter silently.