@@ -881,6 +881,53 @@ void MultiAttribute::add_fwd_attribute(string &dev_name,DeviceClass *dev_class_p
881881 add_user_default (prop_list,def_user_prop);
882882 add_default (prop_list,dev_name,attr.get_name (),attr.get_type ());
883883
884+ //
885+ // Validate and register the root attribute configuration
886+ //
887+ if (new_attr->is_fwd () == true )
888+ {
889+ Tango::FwdAttr *fwd_attr = (Tango::FwdAttr *) new_attr;
890+ // If forwarded attribute is dynamically created and was constructed without specifying
891+ // the root_attribute parameter then we have to get its __root_att property from tango DB
892+ // prior to calling validate_fwd_att()
893+ vector<AttrProperty> dev_prop;
894+ Tango::Util *tg = Tango::Util::instance ();
895+ if ((tg->_UseDb ==true ) && (fwd_attr->get_full_root_att ()==RootAttNotDef))
896+ {
897+ Tango::DbData db_list;
898+ db_list.push_back (DbDatum (fwd_attr->get_name ()));
899+ tg->get_database ()->get_device_attribute_property (dev_name,db_list,tg->get_db_cache ());
900+ for (unsigned int ind=0 ; ind<db_list.size () ; ind++)
901+ {
902+ if (db_list[ind].name == RootAttrPropName)
903+ {
904+ dev_prop.push_back (AttrProperty (db_list[ind].name , db_list[ind].value_string [0 ]));
905+ break ;
906+ }
907+ }
908+ }
909+
910+ // Validate the __root_att property of the attribute
911+ fwd_attr->validate_fwd_att (dev_prop, dev_name);
912+
913+ // Register the root attribute configuration
914+ Tango::DeviceImpl *device = tg->get_device_by_name (dev_name);
915+ try
916+ {
917+ fwd_attr->get_root_conf (dev_name,device);
918+ }
919+ catch (...)
920+ {
921+ // If any error add this attribute to the device list of wrong configured attributes
922+ DeviceImpl::FwdWrongConf fwc;
923+ fwc.att_name = fwd_attr->get_name ();
924+ fwc.full_root_att_name = fwd_attr->get_full_root_att ();
925+ fwc.fae = fwd_attr->get_err_kind ();
926+ vector<DeviceImpl::FwdWrongConf> &fwd_att_wrong_conf = device->get_fwd_att_wrong_conf ();
927+ fwd_att_wrong_conf.push_back (fwc);
928+ }
929+ }
930+
884931//
885932// Create an Attribute instance and insert it in the attribute list. If the device implement IDL 3
886933// (with state and status as attributes), add it at the end of the list but before state and status.
@@ -913,6 +960,12 @@ void MultiAttribute::add_fwd_attribute(string &dev_name,DeviceClass *dev_class_p
913960 alarm_attr_list.push_back (index);
914961 }
915962
963+ //
964+ // Check if the writable_attr_name property is set and in this case, check if the associated attribute exists and is
965+ // writable
966+ //
967+ check_associated (index,dev_name);
968+
916969 cout4 << " Leaving MultiAttribute::add_fwd_attribute" << endl;
917970}
918971
0 commit comments