Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Group usage from PyTango #21

Closed
gnyiri opened this issue Jun 8, 2016 · 3 comments
Closed

Group usage from PyTango #21

gnyiri opened this issue Jun 8, 2016 · 3 comments

Comments

@gnyiri
Copy link

gnyiri commented Jun 8, 2016

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:

http://www.tango-controls.org/community/forums/c/development/python/group-usage-from-pytango/?page=1#post-1526

@johanfforsberg
Copy link

I have reproduced this bug. In fact, neither of "read_attribute()" or "command_inout()" methods work on the proxy obtained from the group.

@vxgmichel
Copy link
Contributor

@johanfforsberg Yes, that's because such proxy objects never get their __init__ method called since they're created on the C++ side.

@vxgmichel
Copy link
Contributor

This fix will appear in the pytango 9.2.0 release.
@gnyiri Let me know if you need it backported to tango8.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants