slaclab / pydm

Python Display Manager
http://slaclab.github.io/pydm/
Other
112 stars 77 forks source link

TANGO support #735

Open dschick opened 3 years ago

dschick commented 3 years ago

What's the problem this feature will solve? Combination of TANGO and EPICS data sources in pydm widgets

Describe the solution you'd like Add a TANGO data source plugin

Additional context I am wondering if anyone already did some work on implementing a TANGO data plugin based on pytango. We have a mixed environment in our labs and struggle with providing GUIs that allow for both control systems. pydm seems to be a suitable solution.

Many thanks in advance

Daniel

mattgibbs commented 3 years ago

Hi @dschick, I don't know of anybody who has done work on a TANGO plugin. I only know a little bit about TANGO, but I think it would be possible, and maybe not too difficult. Glancing through the pytango documentation, it looks like the client API maps pretty cleanly a to PyDM data source plugin.

We would certainly welcome a pull request adding this, if you are interested in giving it a shot!

dschick commented 3 years ago

Hi @mattgibbs , thanks for your promt reply.

I am pretty much interested in giving it a try. However, I am searching for some API documentation how a data plugin is defined. I just found the examples in the data_plugin folder but I am missing sufficient documentation here.

Is there maybe any blueprint available?

mattgibbs commented 3 years ago

Hi @dschick,

This is a poorly documented area of the code. The best thing to do is look at pydm/data_plugins/plugin.py -- this is where the PyDMPlugin and PyDMConnection base classes are. These two classes define the data plugin interface. All data plugins are subclasses of these two.

Your subclass of PyDMPlugin (lets call it TangoPlugin) will get instantiated once, at startup. TangoPlugin needs to set the protocol class variable to the protocol identifier you would like to use, probably 'tango'. Then, whenever PyDM sees a widget with an address with tango:// at the front, it will call TangoPlugin.add_connection().

Your subclass of PyDMConnection (TangoConnection) is what actually gets used to send/receive Tango data. The PyDMConnection class has a set of Qt signals defined - your subclass' job is to emit these signals (with appropriate values) when relevant control system data comes in. PyDMPlugin tries to maintain one Connection per 'address', so that if multiple widgets want to display data from the same address, only one connection is maintained.

Hopefully this (super brief) description will make it easier to look at the existing plugins, and see how they work. I'd recommend looking at pydm/data_plugins/epics_plugins/pyepics_plugin_component.py for a real-world example.

(Sorry I didn't reply to this sooner, the notification ended up in my junk mail.)