auto populate __root_att of forwarded attribute

Hello,

I have a C++ device server that abstracts and controls two lower level devices. This device server has several forwarded attributes from the lower level devices.

Is there a way for the device server automatically populate the __root_att properties of its forwarded attributes in the database on startup? Once the device starts it has all the knowledge to generate the correct __root_att string property.

Thanks,
Mike
Hi Mike,

Very good question. Thanks for asking!

Sorry for the delay in the answer… I made some tests to verify my theories and I encountered some problems…

In theory, you would need to write the "__root_att" attribute property corresponding to your forwarded attributes before your device creation.
So for instance, you could add some code like the following in your device_factory method (in xxxClass.cpp file generated by Pogo):


for (unsigned long i=0 ; i<devlist_ptr->length() ; i++)
{
	Tango::Database db;
	Tango::DbDatum fwd_att("MyFwdAttr");
	Tango::DbDatum root_att("__root_att");
		
	fwd_att << (short)1;
	string my_root_attr_name = yourGreatMethodToComputeRoot_attr_name(…);
	root_att << my_root_attr_name;
	Tango::DbData dd;
	dd.push_back(fwd_att);
	dd.push_back(root_att);
	
	db.put_device_attribute_property((*devlist_ptr)[i].in(),dd);
}

I made some tests, and sadly this does not seem to work if you start your device server when this "__root_att" attribute property does not exist at all.
It seems to work if the property already exists, whatever the value inside (as long as the value you put by code is correct of course).
I tracked down this issue to the fact that some Database Cache is used during the device server startup. If you don't use the cache, it works… But we would need to modify the Tango library to avoid using the DB cache in this specific case (in MultiAttribute constructor). We have to study this case and the potential consequences of such a change in more details.

Another possibility available in the recent cppTango development versions is to create some dynamic forwarded attributes.
You can have a look at the following Pull Requests proposed by Jairo Moldes for more details:

https://github.com/tango-controls/cppTango/pull/469
https://github.com/tango-controls/cppTango/pull/342

If you don't want to use the dynamic forwarded attributes and if you want to configure your forwarded attributes during the init_device(), you could also edit the "__root_att" attribute property in init_device() and trigger a restart of your device server instance or device. I didn't test that. I suspect some difficulties when trying to restart a device from itself. So this might be tricky.

I hope this helps a bit.
Reynald
Rosenberg's Law: Software is easy to make, except when you want it to do something new.
Corollary: The only software that's worth making is software that does something new.
Thanks Reynald.

It looks like dynamic forwarded attributes would work in this case. I don't mind waiting for them to be implemented into Tango; for now I can populate the __root_att manually since it's only 10s of attributes. In the future this would be a nice convenience.

Regards,
Mike
 
Register or login to create to post a reply.