External Data Plugins
To add an external data plugin to PyDM, you will need to subclass the following base class and customize its methods:
- class pydm.data_plugins.PyDMPlugin[source]
Bases:
object
- connection_class
alias of
PyDMConnection
You will also need to create a connection class and refer to it with the
connection_class
class variable. It should be subclassed from the
following:
- class pydm.data_plugins.plugin.PyDMConnection(channel, address, protocol=None, parent=None)[source]
Bases:
QObject
- blockSignals(self, b: bool) bool
- childEvent(self, a0: Optional[QChildEvent])
- children(self) List[QObject]
- connectNotify(self, signal: QMetaMethod)
- customEvent(self, a0: Optional[QEvent])
- deleteLater(self)
- destroyed
typing.Optional[QObject] = None) [signal]
- Type:
destroyed(self, object
- disconnect(a0: QMetaObject.Connection) bool
- disconnect(self) None
- disconnectNotify(self, signal: QMetaMethod)
- dumpObjectInfo(self)
- dumpObjectTree(self)
- dynamicPropertyNames(self) List[QByteArray]
- event(self, a0: Optional[QEvent]) bool
- eventFilter(self, a0: Optional[QObject], a1: Optional[QEvent]) bool
- findChild(self, type: type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) QObject
- findChild(self, types: Tuple, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) QObject
- findChildren(self, type: type, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
- findChildren(self, types: Tuple, name: str = '', options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
- findChildren(self, type: type, regExp: QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
- findChildren(self, types: Tuple, regExp: QRegExp, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
- findChildren(self, type: type, re: QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
- findChildren(self, types: Tuple, re: QRegularExpression, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) List[QObject]
- inherits(self, classname: Optional[str]) bool
- installEventFilter(self, a0: Optional[QObject])
- isSignalConnected(self, signal: QMetaMethod) bool
- isWidgetType(self) bool
- isWindowType(self) bool
- killTimer(self, id: int)
- metaObject(self) Optional[QMetaObject]
- moveToThread(self, thread: Optional[QThread])
- objectName(self) str
- objectNameChanged
str) [signal]
- Type:
objectNameChanged(self, objectName
- parent(self) Optional[QObject]
- property(self, name: Optional[str]) Any
- pyqtConfigure(...)
Each keyword argument is either the name of a Qt property or a Qt signal. For properties the property is set to the given value which should be of an appropriate type. For signals the signal is connected to the given value which should be a callable.
- receivers(self, signal: PYQT_SIGNAL) int
- removeEventFilter(self, a0: Optional[QObject])
- remove_listener(channel, destroying: Optional[bool] = False) None [source]
Removes a listener from this PyDMConnection. If there are no more listeners remaining after removal, then the PyDMConnection will be closed.
- Parameters:
channel (PyDMChannel) – The PyDMChannel containing the signals/slots that were being used to listen to the connected address.
destroying (bool, optional) – Should be set to True if this method is being invoked from a flow in which the PyDMWidget using this channel is being destroyed. Since Qt will automatically handle the disconnect of signals/slots when a QObject is destroyed, setting this to True ensures we do not try to do the disconnection a second time. If set to False, any active signals/slots on the channel will be manually disconnected here.
- sender(self) Optional[QObject]
- senderSignalIndex(self) int
- setObjectName(self, name: str)
- setParent(self, a0: Optional[QObject])
- setProperty(self, name: Optional[str], value: Any) bool
- signalsBlocked(self) bool
- startTimer(self, interval: int, timerType: Qt.TimerType = Qt.CoarseTimer) int
- thread(self) Optional[QThread]
- timerEvent(self, a0: Optional[QTimerEvent])
- tr(self, sourceText: Optional[str], disambiguation: Optional[str] = None, n: int = -1) str
Configuration
There are two options for telling PyDM where your external data plugin can be found.
The first is the PYDM_DATA_PLUGINS_PATH
environment variable, which is an
delimited list of paths to search for files that match the pattern
*_plugin.py
. They can be in the provided path or any subdirectory of that
path. On Linux, the delimiter is “:” whereas on Windows it is “;”.
Alternatively, for Python packages that contain external data plugins, an entrypoint may be used to locate it.
Here is an example setup.py
that could be used to locate a PyDM data plugin
in your own Python package:
from setuptools import setup, find_packages
setup(
name="my_package",
# ... other settings will go here
entry_points={
"gui_scripts": ["my_package_gui=my_package.main:main"],
"pydm.data_plugin": [
"my_package=my_package.data:PluginClassName",
],
},
install_requires=[],
)
This would assume that you have the following:
A package named “my_package” with
my_package/__init__.py
andmy_package/data.py
.In
my_package/data.py
, aPluginClassName
that inherits fromPyDMPlugin
.
After running pip install
on the package, it should be readily available
in PyDM.