device server hierarchy calls

Hi All,
I coded 2 simple PyTango test device servers: in the first one a command first.SPFC_ has been defined; also the second device server has a command second.SPFC_ which is supposed to call first.SPFC_.

A client connects successfully to both device servers via the instructions:
first = PyTango.DeviceProxy("test/first/1")
second = PyTango.DeviceProxy("test/second/1")

The client is able to directly access without any problem both device servers attributes and their commands too, except for the command second.SPFC_ which, the first time it is called, generates the error at the bottom of this message.
The following times it is called, it works.

I tried to access second.SPFC_ also via jive and it behaved in the same way, generating an AttributeError message the first time and working perfectly the following times.

Which is the problem?

As far as I know forwarded attributes are not allowed in PyTango…

Thanks,
Alex


first.py excerpt:
—————–
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""PDU tango device server"""

import time
import numpy
import threading

from PyTango import AttrQuality, AttrWriteType, DispLevel, DevState, DebugIt
from PyTango.server import Device, DeviceMeta, attribute, command, run
from PyTango.server import device_property

class PDU(Device):
__metaclass__ = DeviceMeta
….
SPFC = attribute(label="SPFC", dtype=bool,
display_level=DispLevel.OPERATOR,
access=AttrWriteType.READ_WRITE,
#access=AttrWriteType.READ,
#unit="V",format="8.4f",
fget="get_spfc",
fset="set_spfc",
doc="SPFC power supply")
….
@command
def SPFC_(self):
self.__spfc = not self.__spfc

—————–
second.py excerpt:
—————–
same imports as first.py
….
pdu = PyTango.DeviceProxy("test/pdu/1")
….
class PM(Device):
__metaclass__ = DeviceMeta
….
SPFC = attribute(label="SPFC", dtype=bool,
display_level=DispLevel.OPERATOR,
access=AttrWriteType.READ_WRITE,
#access=AttrWriteType.READ,
#unit="V",format="8.4f",
fget="get_spfc",
fset="set_spfc",
doc="SPFC power supply")
….
@command
def SPFC_(self):
pdu.SPFC_()
self.__spfc = pdu.spfc

—————–
client.py excerpt:
—————–
import PyTango
import time

power_supply = PyTango.DeviceProxy("test/pm/1")
pdu = PyTango.DeviceProxy("test/pdu/1")

print(pdu.spfc)
pdu.spfc = True
print "spfc =",pdu.spfc
print "PM spfc =",power_supply.spfc
power_supply.SPFC_()

—————–
Generated Error:
—————–
Traceback (most recent call last):
File "testPower1.py", line 30, in <module>
power_supply.SPFC_()
File "/home/tango-cs/.local/lib/python2.7/site-packages/PyTango/device_proxy.py", line 198, in f
return self.command_inout(name, *args, **kwds)
File "/home/tango-cs/.local/lib/python2.7/site-packages/PyTango/green.py", line 165, in greener
ret = submit(fn, self, *args, **kwargs)
File "/home/tango-cs/.local/lib/python2.7/site-packages/PyTango/green.py", line 81, in synch_submit
return get_synch_executor().submit(fn, *args, **kwargs)
File "/home/tango-cs/.local/lib/python2.7/site-packages/PyTango/green.py", line 73, in submit
return fn(*args, **kwargs)
File "/home/tango-cs/.local/lib/python2.7/site-packages/PyTango/connection.py", line 101, in __Connection__command_inout
r = Connection.command_inout_raw(self, name, *args, **kwds)
File "/home/tango-cs/.local/lib/python2.7/site-packages/PyTango/connection.py", line 127, in __Connection__command_inout_raw
return self.__command_inout(cmd_name, param)
PyTango.DevFailed: DevFailed[
DevError[
desc = AttributeError: SPFC_

origin = File "/home/tango-cs/.local/lib/python2.7/site-packages/PyTango/server.py", line 742, in cmd
return get_worker().execute(f, self, *args, **kwargs)
File "/home/tango-cs/.local/lib/python2.7/site-packages/PyTango/server.py", line 1134, in execute
return func(*args, **kwargs)
File "PM.py", line 66, in SPFC_
pdu.SPFC_()
File "/home/tango-cs/.local/lib/python2.7/site-packages/PyTango/device_proxy.py", line 210, in __DeviceProxy__getattr
raise AttributeError(name)

reason = PyDs_PythonError
severity = ERR]

DevError[
desc = Failed to execute command_inout on device test/pm/1, command SPFC_
origin = Connection::command_inout()
reason = API_CommandFailed
severity = ERR]
Hi Alex,

Several comments:

- I can see from your traceback that you're still using pytango 8. Note that this version is not actively supported anymore. Moreover, many bug fixes and features have been added since the last pytango 8 release (including the forwarded attribute feature you were mentioning). Please consider moving to pytango 9.

- When you report a bug, please use a Minimal, Complete, and Verifiable example. The code you pasted seems minimal, but not complete and thus unverifiable. The `get_spcf` and `set_spcf` methods are not defined, and the `__spcf` attribute is not initialized. Also your naming is extremely obfuscated (uppercase and lowercase attribute names are being mixed, and some names only differ by an underscore).

- Please post properly formatted code along with the code markup, or upload your files as an a attachment:
if __name__ == '__main__':
    print('Hello world!')
 
Register or login to create to post a reply.