hi,
I am trying to use Group facility of Tango from python. The group command methods work fine but when I use get_device method for getting a DeviceProxy reference to a given Device some DeviceProxy methods fail (Exception: _green_mode). Note that the C++ version of the same scenario works as expected. Find both versions 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
#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;
}
Output:
direct access sys/tg_test/1 → 10
group access sys/tg_test/1 → 10
I found some hints about green modes in PyTango documentation, but the concept is not clear to me in fact.
Do you know why State() method throws an exception from Python (while it works properly in C++)?
Thanks in advance,
Gergely Nyiri