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
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]