Group usage from PyTango
Using State() method on a DeviceProxy returned from get_device of a Group instance throws an exception. The same method works fine when the DeviceProxy instance was created directly. See example below:
import PyTango
if __name__ == "__main__":
device_group = PyTango.Group("group")
device_group.add("sys/tg_test/1")
device_proxy_a = PyTango.DeviceProxy("sys/tg_test/1")
device_proxy_b = device_group.get_device("sys/tg_test/1")
try:
print("direct access " + device_proxy_a.name() + " -> " + str(device_proxy_a.State()) + "\n")
except Exception as e:
print("Exception caught: " + str(e))
try:
print("group access " + device_proxy_b.name() + " -> " + str(device_proxy_b.State()) + "\n")
except Exception as e:
print("Exception caught: " + str(e))
Output:
direct access sys/tg_test/1 -> RUNNING Exception caught: _green_mode
Associated C++ version works fine:
#include <tango.h>
#include <log4tango.h>
#include <vector>
#include <unistd.h>
int main(int argc,char *argv[])
{
Tango::Group* l_group = new Tango::Group("group");
std::string l_device_name("sys/tg_test/1");
l_group->add(l_device_name);
Tango::DeviceProxy* l_device_proxy_a = new Tango::DeviceProxy(l_device_name);
Tango::DeviceProxy* l_device_proxy_b = l_group->get_device(l_device_name);
try
{
std::cout << "direct access " << l_device_proxy_a->name() << " -> " << l_device_proxy_a->state() << std::endl;
std::cout << "group access " << l_device_proxy_b->name() << " -> " << l_device_proxy_b->state() << std::endl;
}
catch(…)
{
std::cout << "Could not connect" << std::endl;
}
delete l_device_proxy_a;
delete l_group;
return 0;
}
The issue was originally reported at tango-controls forum: