Forwarded attributes in PyTango

Hi there,

I am exploring forwarded attributes feature in PyTango 9.2.4.

As per documentation, if "__root_attr" attribute property is not specified, the attribute is not created by the Tango kernel and is therefore not visible for the external world. The state of the device to which the forwarded attribute belongs to is set to ALARM (if not already FAULT) and a detailed error report is available in the device status.

However, I get the following error when ran the device server (with/without the __root_att attribute property):

Exiting: Server exited with tango.DevFailed:
DevFailed[
DevError[
    desc = ArgumentError: Python argument types in
               DeviceClass._create_fwd_attribute(ForwardedAttrTestPythonClass, AttrList, NoneType, UserDefaultFwdAttrProp)
           did not match C++ signature:
               _create_fwd_attribute(CppDeviceClass {lvalue}, std::vector<Tango::Attr*, std::allocator<Tango::Attr*> > {lvalue}, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Tango::UserDefaultFwdAttrProp*)
           
  origin =   File "/usr/local/lib/python2.7/dist-packages/tango/device_class.py", line 341, in __DeviceClass__attribute_factory
    self._create_fwd_attribute(attr_list, attr_data.name, attr_data.att_prop)

  reason = PyDs_PythonError
severity = ERR]
]

Exited

Please note that I tried the same with Java and it works as expected. It seems that I am missing some configuration in the python code. Is there any documentation available for the same?

Sample code is attached to this post. Any inputs will be helpful.

Kind regards,
Jyotin
Edited 1 month ago
Hi there,

With inputs from Geoff Mant, this issue has been resolved.

Resolution:

The server will run if one changes the forward attribute definition to:
FwdAttr2 = attribute(name="FwdAttr2", label="FwdAttr2", forwarded=True)
The attribute name field was missing in the Forwarded Attribute definition (server code attached in previous post).

GitHub Issue: Unable to create Forwarded attributes in Python 9.2.4 #231

Kind regards,
Jyotin
Hi Everyone,

I need a bit of help in reading forwarded attributes in the code.

Let's say device "A" implements forwarded attribute of the root device "B".
I want to use the Forwarded Attribute value inside device A.

If I use,

print self._FwdAttr2


inside device A's server code, it returns an Attribute class object as:

Attribute(FwdAttr2)

How to get the value of FwdAttr2 inside A class? I went through the Attribute class APIs but it doesn't provide a method to read attribute value. Source code for Device A is attached to this post for testing.

One way of reading forwarded attributes in the code is by creating AttributeProxy/DeviceProxy of device "A" inside device "A" source code and reading the attribute. But to me, this seems as a TANGO anti-pattern.

Can anyone please guide on this issue?

Kind regards,
Jyotin
Po
One way of reading forwarded attributes in the code is by creating AttributeProxy/DeviceProxy of device "A" inside device "A" source code and reading the attribute. But to me, this seems as a TANGO anti-pattern.

As far as I know, this is actually the way. I don't think this is an anti-pattern.

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.
 
Register or login to create to post a reply.