Dear all,
I’m having some problems while adding dynamic attributes to a device.
In short I have a base device class with a method for creating and adding dynamic attributes parsed from a config file. In an inherited device I want to create the dynamic attributes (using the base class method) and use them inside the init_device. Here’s the sample code of the init_device:
/*----- PROTECTED REGION END -----*/ // SPFDynEmulator::init_device_before
if (Tango::Util::instance()->is_svr_starting() == false &&
Tango::Util::instance()->is_device_restarting(device_name)==false)
{
//If not starting up call init device for inherited object
SEEmulatorBase_ns::SEEmulatorBase::init_device();
}
// Get the device properties from database
get_device_property();
/*----- PROTECTED REGION ID(SPFDynEmulator::init_device) ENABLED START -----*/
//Remove any existing dyn attribute (not sure is really needed...)
//...
//Create and add dynamic attributes parsed from config file
//...
//Use dyn attributes (e.g. find attr and set value, etc)
//...
//Crash occurs here (at init_device end)!
When I do that I get this fault at the end of the method:
SPFDynEmulator::init_device() - SPF startup completed with success…
1479288297 [139917439063808] INFO dserver/SPFDynEmulator/1 spf_mode is a UNWANTED dynamic attribute for device mid_dish_0001/spf/controller
1479288297 [139917439063808] DEBUG dserver/SPFDynEmulator/1 In get_monitor() mid_dish_0001/spf/controller, thread = 7, ctr = 0
1479288297 [139917439063808] DEBUG dserver/SPFDynEmulator/1 In rem_obj_polling method
1479288297 [139917439063808] DEBUG dserver/SPFDynEmulator/1 Input string = mid_dish_0001/spf/controller
1479288297 [139917439063808] DEBUG dserver/SPFDynEmulator/1 Input string = attribute
1479288297 [139917439063808] DEBUG dserver/SPFDynEmulator/1 Input string = spf_mode
1479288297 [139917439063808] DEBUG dserver/SPFDynEmulator/1 In rel_monitor() mid_dish_0001/spf/controller, ctr = 1, thread = 7
1479288297 [139917439063808] DEBUG dserver/SPFDynEmulator/1 Signalling !
1479288297 [139917439063808] DEBUG dserver/SPFDynEmulator/1 Entering DeviceClass destructor for class SPFDynEmulator
1479288297 [139917439063808] DEBUG dserver/SPFDynEmulator/1 Entering DeviceClas::delete_dev method for device with index 0
1479288297 [139917439063808] DEBUG dserver/SPFDynEmulator/1 Leaving DeviceClass delete_dev
1479288297 [139917439063808] DEBUG dserver/SPFDynEmulator/1 Leaving DeviceClass destructor for class SPFDynEmulator
terminate called after throwing an instance of ‘Tango::DevFailed’
Aborted (core dumped)
If however I move the code to create the dynamic attributes in the add_dynamic_attributes() method of the device I get no faults, but on the other hand I cannot use the created dynamic attributes in the init_device method since the add_dynamic_attributes() is inkoved when init_device completes.
Furthermore am I supposed to manually remove the created attributes at the init_device beginning?
Do you have suggestions? I think I’m missing something here.
Thanks a lot,
Simone