5. Library Reference
5.1. The plugin module
This module contains only plugins
and plugin templates.
The user controls generally have a large amount of logic integrated and can act as an intelligent database.
This avoids complex and error prone synchronization between redundant data in the UI and a separate database.
Every parameter should only exist in one unique location at run time.
- class esibd.plugins.ChannelManager(*args: Any, **kwargs: Any)
- class ChannelPlot(*args: Any, **kwargs: Any)
Simplified version of the Line plugin for plotting channels.
- finalizeInit(aboutFunc=None)
Executed after all other Plugins are initialized. Use this for code that modifies other
Plugins
, e.g. adding anAction
to theDeviceManager
.- Parameters:
aboutFunc (method, optional) – Function displaying the about dialog of the plugin, defaults to None.
about()
is used if no other is provided.
- getIcon(desaturate=False)
Gets the plugin icon. Consider using a themed icon that works in dark and light modes. Overwrite only if definition of iconFile and iconFileDark is not sufficient.
- Returns:
Icon
- Return type:
- iconFile: str = 'chart.png'
Default icon file. Expected to be in dependencyPath.
- initFig()
Will be called when a display is closed and reopened or the theme is changed. Overwrite your figure initialization here to make sure all references are updated correctly.
- initGUI()
Initializes the graphic user interface (GUI), independent of all other plugins.
- name: str = 'Line'
A unique name that will be used in the graphic user interface. Plugins can be accessed directly from the Console using their name.
- pluginType: PluginManager.TYPE = 'Display'
The type defines the location of the plugin in the user interface and allows to run operations on a group of plugins with the same type using
getPluginsByType()
.
- provideDock()
Adds existing
dock
to UI at position defined byesibd.plugins.Plugin.pluginType
.
- runTestParallel()
Runs a series of tests by changing values of selected controls and triggering the corresponding events. Extend and add call to super().runTestParallel() to the end to make sure testing flag is set to False after all test completed!
- version: str = '1.0'
The version of the plugin. Plugins are independent programs that require independent versioning and documentation.
- class SignalCommunicate(*args: Any, **kwargs: Any)
Object than bundles pyqtSignals for the Channelmanager
- plotSignal
Signal that triggers plotting of history.
- channelConfigChanged(file=None, default=True)
Scans for changes when saving configuration.
- channelType
Type of
Channel
used by the device. Overwrite by appropriate type in derived classes.alias of
Channel
- close()
Closes plugin cleanly without leaving any data or communication running. Extend to make sure your custom data and custom communication is closed as well.
- closeCommunication()
Stops recording and also closes all device communication. Extend to add custom code to close device communication.
- compareItemsConfig(items, ignoreIndicators=False)
Compares channel items from file with current configuration. This allows to track changes and decide if files need to be updated.
- convertDataDisplay(data)
Overwrite to apply scaling and offsets to data before it is displayed. Use, e.g., to convert to another unit.
- copyClipboard()
Copy matplotlib figure to clipboard.
- exportConfiguration(file=None, default=False)
Saves an .ini or .h5 file which contains the configuration for this
Device
. The .ini file can be easily edited manually with a text editor to add morechannels
.
- finalizeInit(aboutFunc=None)
Executed after all other Plugins are initialized. Use this for code that modifies other
Plugins
, e.g. adding anAction
to theDeviceManager
.- Parameters:
aboutFunc (method, optional) – Function displaying the about dialog of the plugin, defaults to None.
about()
is used if no other is provided.
- getChannelByName(name)
Returns a device specific channel based on its unique name.
- getDefaultSettings()
Define specific settings that will be added to the general settings tab. Settings will be generated automatically if not found in the settings file. Overwrite and extend as needed.
- getSelectedChannel()
Returns selected channel. Note, channels can only be selected in advanced mode.
- initGUI()
Initializes the graphic user interface (GUI), independent of all other plugins.
- initializeCommunication()
Extend to initialize communication. Can be used to initialize GUI. Redirect initialization of hardware communication to the corresponding
DeviceController
.
- isOn()
Overwrite to signal if device output (e.g. for voltage supplies) is on.
- liveDisplay: LiveDisplay
Internal plugin to display data in real time.
- loadConfiguration(file=None, default=False)
Loads
channel
configuration from file. If only values should be loaded without complete reinitialization, useloadValues
instead.- Parameters:
file (pathlib.Path, optional) – File from which to load configuration, defaults to None
default (bool, optional) – Use internal configuration file if True, defaults to False
- loadValues(file=None)
Loads values only, instead of entire configuration, for
channels
matching in file and current configuration. Channels that exist in the file but not in the current configuration will be ignored. Only used by input devices.
- moveChannel(up)
Moves the channel up or down in the list of channels.
- Parameters:
up (bool) – Move up if True, else down.
- name: str = 'Channel Manager'
A unique name that will be used in the graphic user interface. Plugins can be accessed directly from the Console using their name.
- optional: bool = False
Defines if the user can deactivate the plugin in the
PluginManager
user interface.
- plot(apply=False)
If applicable, overwrite with a plugin specific plot method.
- pluginType: PluginManager.TYPE = 'Generic Control'
The type defines the location of the plugin in the user interface and allows to run operations on a group of plugins with the same type using
getPluginsByType()
.
- previewFileTypes: List[str] = []
File extensions that are supported by this plugin. If a corresponding file is selected in the
Explorer()
, the pluginsloadData()
function will be called.
- runDataThread(recording)
Regularly triggers plotting of data. Overwrite to add logic for appending data to channels.
- staticDisplay: StaticDisplay
Internal plugin to display data from file.
- supportsFile(file)
Tests if a file is supported by the plugin, based on file name or content.
- Parameters:
file (pathlib.Path) – File that has been selected by the user.
- Returns:
Returns True if the file is supported by the plugin. Test if supported based on file extension or content.
- Return type:
bool
- toggleRecording(on=None, manual=True)
Toggle plotting of data in
LiveDisplay
. Extend to add recoding logic for devices.- Parameters:
on (bool, optional) – If true recording will be turned on, if false it will be turned off. If already on or off nothing happens. If None, recording is toggled.
manual (bool, optional) – If true, signal was send directly from corresponding live display. Otherwise might be send from device manager
- updateChannelConfig(items, file)
Scans for changes when loading configuration and displays change log before overwriting old channel configuration.
- useBackgrounds: bool = False
If True, the device implements controls to define and subtract background signals.
- useDisplays = True
use liveDisplay, StaticDisplay, ChannelPlot, and all related functionality.
- useMonitors = False
Use record monitors and compare them to set points.
- useOnOffLogic = False
Creates an Action in the DeviceManager that handles turning key functions on and off.
- version: str = '1.0'
The version of the plugin. Plugins are independent programs that require independent versioning and documentation.
- class esibd.plugins.Device(*args: Any, **kwargs: Any)
Devices
are used to handle communication with one or more physical devices, provide controls to configure the device and display live or previously recorded data. There are input devices (sending input from the user to hardware) and output devices (reading outputs from hardware). Note that some input devices may also read back data from hardware to confirm that the user defined values are applied correctly.The main interface consists of a list of Channels. By default only the physically relevant information is shown. By entering the advanced mode, additional channel parameters can be configured. The configuration can be exported and imported, though once all channels have been setup it is sufficient to only load values which can be done using a file dialog or from the context menu of an appropriate file in the Explorer. After loading the configurations or values, a change log will be available in the Text plugin to quickly identify what has changed. Each device also comes with a display and a live display. The current values can also be plotted to get a quick overview and identify any unusual values.
- class SignalCommunicate(*args: Any, **kwargs: Any)
- appendDataSignal
Signal that triggers appending of data from channels to history.
- applyValues(apply=False)
Applies
Channel
values to physical devices. Only used by inputdevices
.- Parameters:
apply (bool, optional) – If false, only values that have changed since last apply will be updated, defaults to False
- close()
Closes plugin cleanly without leaving any data or communication running. Extend to make sure your custom data and custom communication is closed as well.
- closeCommunication()
Stops all communication. Make sure that final calls to device are send from main thread or use a delay so they are not send after connection has terminated!
- documentation: str = 'Device plugins are used to handle communication with one or more\n devices, provide controls to configure the device and display live or\n previously recorded data. There are input devices (sending input from\n the user to hardware) and output devices (reading outputs from\n hardware). Note that some input devices may also read back data from\n hardware to confirm that the user defined values are applied correctly.\n\n The main interface consists of a list of channels. By\n default only the physically relevant information is shown. By entering\n the advanced mode, additional channel parameters can be configured. The\n configuration can be exported and imported, though once all channels\n have been setup it is sufficient to only load values which can be done\n using a file dialog or from the context menu of an appropriate file in\n the Explorer. After loading the configurations or values, a change log will be\n available in the Text plugin to quickly identify what has changed. Each\n device also comes with a display and a live display.\n The current values can also be plotted to get a quick overview and identify any\n unusual values.'
The plugin documentation used in the internal about dialog in the Browser. If None, the doc string __doc__ will be used instead.
- getDefaultSettings()
Define device specific settings that will be added to the general settings tab. Settings will be generated automatically if not found in the settings file. Overwrite and extend as needed.
- getUnit()
Overwrite if you want to change units dynamically.
- initializeCommunication()
Extend to initialize communication. Can be used to initialize GUI. Redirect initialization of hardware communication to the corresponding
DeviceController
.
- initialized()
Extend or overwrite to indicate when the device is initialized. Default implementation works when using
DeviceController
.
- moveChannel(up)
Moves the channel up or down in the list of channels.
- Parameters:
up (bool) – Move up if True, else down.
- name: str = 'Device'
A unique name that will be used in the graphic user interface. Plugins can be accessed directly from the Console using their name.
- optional: bool = True
Defines if the user can deactivate the plugin in the
PluginManager
user interface.
- pluginType: PluginManager.TYPE = 'Input Device'
Devices
are categorized as input or output devices. Overwrite withOUTPUTDEVICE
after inheriting if applicable.
- restoreOutputData()
Restores data from internal restore file.
- runDataThread(recording)
Regularly triggers reading and appending of data. This uses the current value of
channels
which is updated independently by the correspondingDeviceController
.
- setBackground()
Sets the background based on current channel values. Only used by output devices.
- startAcquisition()
Starts device Acquisition. Default implementation works when using
DeviceController
.
- stopAcquisition()
Stops device acquisition. Communication stays initialized! Default implementation works when using
DeviceController
.
- toggleRecording(on=None, manual=False)
Toggle recoding of data in
LiveDisplay
.
- unit: str = 'unit'
Unit used in user interface.
- updateValues(N=2, apply=False)
Updates channel values based on equations. This minimal implementation will not give a warning about circular definitions. It will also fail if expressions are nested on more than N levels but N can be increased as needed. N=2 should however be sufficient for day to day work. More complex algorithms should only be implemented if they are required to solve a practical problem.
- useBackgrounds: bool = False
If True, the device implements controls to define and subtract background signals.
- version: str = 1.0
The version of the plugin. Plugins are independent programs that require independent versioning and documentation.
- class esibd.plugins.DeviceManager(*args: Any, **kwargs: Any)
The device manager, by default located below the Live displays, bundles functionality of devices and thus allows to initialize, start, and stop data acquisition from all devices with a single click. Ideally, plugins that control potentially dangerous hardware like power supplies, cryo coolers, or vacuum valves should add a status icon to the instrument manager, so that their status is visible at all times and they can be shut down quickly, even when the corresponding plugin tab is is not selected. Internally, the device manager also serves as a central interface to all data channels, independent of the devices they belong to, making it easy to setup collection of any number of output signals as a function of any number of input signals.
- class SignalCommunicate(*args: Any, **kwargs: Any)
Object that bundles pyqtSignals.
- closeCommunicationSignal
Signal that triggers stop communication.
- storeSignal
Signal that triggers storage of device data.
- closeCommunication(manual=False, closing=False, message='Stopping communication.')
Close all communication
- Parameters:
manual (bool, optional) – Indicates if triggered by user, defaults to False
- documentation: str = 'The device manager, by default located below the live displays, bundles\n functionality of devices and thus allows to initialize, start, and stop\n data acquisition from all devices with a single click. Ideally, plugins\n that control potentially dangerous hardware like power supplies, cryo\n coolers, or vacuum valves should add a status icon to the instrument\n manager, so that their status is visible at all times and they can be\n shut down quickly, even when the corresponding plugin tab is is not\n selected. Internally, the device manager also serves as a\n central interface to all data channels, independent of the devices they\n belong to, making it easy to setup collection of any output\n signals as a function of any input signals.'
The plugin documentation used in the internal about dialog in the Browser. If None, the doc string __doc__ will be used instead.
- getChannelByName(name, inout=INOUT.BOTH)
Get channel based on unique name and type.
- iconFile: str = 'DeviceManager.png'
Default icon file. Expected to be in dependencyPath.
- name: str = 'DeviceManager'
A unique name that will be used in the graphic user interface. Plugins can be accessed directly from the Console using their name.
- optional: bool = False
Defines if the user can deactivate the plugin in the
PluginManager
user interface.
- pluginType: PluginManager.TYPE = 'DeviceManager'
The type defines the location of the plugin in the user interface and allows to run operations on a group of plugins with the same type using
getPluginsByType()
.
- previewFileTypes: List[str] = ['_combi.dat.h5']
File extensions that are supported by this plugin. If a corresponding file is selected in the
Explorer()
, the pluginsloadData()
function will be called.
- store()
Regularly stores device settings and data to minimize loss in the event of a program crash. Make sure that no GUI elements are accessed when running from parallel thread!
- toggleRecording()
Toggle recording of data.
- version: str = '1.0'
The version of the plugin. Plugins are independent programs that require independent versioning and documentation.
- class esibd.plugins.LiveDisplay(*args: Any, **kwargs: Any)
Live displays show the history of measured data over time. Use start/pause icon in corresponding device control. The toolbar provides icons to initialize and stop acquisition, optionally subtract backgrounds, or export displayed data to the current session. Data is only collected if the corresponding live display is visible. The length of the displayed history is determined by the display time control in the tool bar.
Frequently updating those plots is typically the computationally most expensive action. Thus you might want to reduce the number of displayed data points in the acquisition settings. This will make sure that the graphs are updated less frequently and select a smaller but consistent subset of data points for a smooth visualization. While PyQtGraph provides its own algorithms for down sampling data (accessible via the context menu), they tend to cause a flicker when updating data.
- clearPlot()
Clears all references to plotCurves, plotItems, and legends. To be recreated if needed.
- copyClipboard()
Copy matplotlib figure to clipboard.
- documentation: str = 'Live displays show the history of measured data over time.\n Use start/pause icon in corresponding device control. The toolbar\n provides icons to initialize and stop acquisition, optionally\n subtract backgrounds, or export displayed data to the current session.\n Data is only collected if the corresponding live display is visible.\n The length of the displayed history is determined by the display time\n control in the tool bar.\n\n Frequently updating those plots is typically the computationally most\n expensive action. Thus you might want to reduce\n the number of displayed data points in the Settings. This will make sure that\n the graphs are updated less frequently and select a smaller but\n consistent subset of data points for a smooth visualization. While\n PyQtGraph provides its own algorithms for down sampling data (accessible\n via the context menu), they tend to cause a flicker when updating data.'
The plugin documentation used in the internal about dialog in the Browser. If None, the doc string __doc__ will be used instead.
- getDisplayTime()
Gets displaytime independent of displayTimeComboBox
- getIcon(**kwargs)
Gets the plugin icon. Consider using a themed icon that works in dark and light modes. Overwrite only if definition of iconFile and iconFileDark is not sufficient.
- Returns:
Icon
- Return type:
- initFig()
Will be called when a display is closed and reopened or the theme is changed. Overwrite your figure initialization here to make sure all references are updated correctly.
- plot(apply=False)
- Plots the enabled and initialized channels in the main output plot
The x axis is either time or a selected channel
- Parameters:
apply (bool) – Apply most recent data, otherwise update rate depends on data thinning
- pluginType: PluginManager.TYPE = 'LiveDisplay'
The type defines the location of the plugin in the user interface and allows to run operations on a group of plugins with the same type using
getPluginsByType()
.
- class esibd.plugins.PID(*args: Any, **kwargs: Any)
Allows to connect an input (controlling) and output (controlled) channel via PID logic. Whenever the output changes, the input will be adjusted to stabilize the output to its setpoint. Proportional: If you’re not where you want to be, get there. Integral: If you haven’t been where you want to be for a long time, get there faster. Derivative: If you’re getting close to where you want to be, slow down.
- class PIDChannel(*args: Any, **kwargs: Any)
Minimal UI for abstract PID channel.
- getDefaultChannel()
Defines parameter(s) of the default channel. This is also use to assign widgetTypes and if settings are visible outside of advanced mode. See
parameterDict()
. If parameters do not exist in the settings file, the default parameter will be added. Overwrite in dependent classes as needed.
- initGUI(item)
Call after item has been added to tree. Item needs parent for all graphics operations.
- monitorChanged()
Highlights monitors if they deviate to far from set point. Extend for custom monitor logic if applicable.
- onDelete()
Extend to handle events on deleting. E.g. handle references that should remain available.
- setDisplayedParameters()
Used to determine which parameters to use and in what order. Extend using
insertDisplayedParameter()
to add more parameters.
- tempParameters()
List of parameters, such as live signal or status, that will not be saved and restored.
- afterFinalizeInit()
Execute after all other plugins are finalized
- channelType
alias of
PIDChannel
- iconFile: str = 'PID.png'
Default icon file. Expected to be in dependencyPath.
- loadConfiguration(file=None, default=False)
Loads
channel
configuration from file. If only values should be loaded without complete reinitialization, useloadValues
instead.- Parameters:
file (pathlib.Path, optional) – File from which to load configuration, defaults to None
default (bool, optional) – Use internal configuration file if True, defaults to False
- loadData(file, _show=True)
Loads and displays data from file. This should only be called for files where
supportsFile()
returns True. Overwrite depending on data supported by the plugin.- Parameters:
file (pathlib.Path) – File from which to load data.
_show (bool, optional) – Show plugin after loading data, defaults to True. Some files are handled by multiple plugins and only one of them should be shown by default.
- moveChannel(up)
Moves the channel up or down in the list of channels.
- Parameters:
up (bool) – Move up if True, else down.
- name: str = 'PID'
A unique name that will be used in the graphic user interface. Plugins can be accessed directly from the Console using their name.
- optional: bool = True
Defines if the user can deactivate the plugin in the
PluginManager
user interface.
- pluginType: PluginManager.TYPE = 'Channel Manager'
The type defines the location of the plugin in the user interface and allows to run operations on a group of plugins with the same type using
getPluginsByType()
.
- previewFileTypes: List[str] = []
File extensions that are supported by this plugin. If a corresponding file is selected in the
Explorer()
, the pluginsloadData()
function will be called.
- version: str = '1.0'
The version of the plugin. Plugins are independent programs that require independent versioning and documentation.
- class esibd.plugins.Plugin(*args: Any, **kwargs: Any)
Plugins
abstract basic GUI code for devices, scans, and other high level UI elements. All plugins are ultimately derived from thePlugin
class. The doc string of the plugin class will be shown in the corresponding help window unless documentation is implemented explicitly.- class SignalCommunicate(*args: Any, **kwargs: Any)
Object than bundles pyqtSignals for the Channelmanager
- addAction(event=None, toolTip='', icon=None, before=None)
Adds a simple Action to the toolBar.
- Parameters:
func (method, optional) – The function triggered by the action, defaults to None
toolTip (str, optional) – The toolTip of the action, defaults to ‘’
icon (
Icon
, optional) – The icon of the action, defaults to Nonebefore (
Action
, optional) – The existing action before which the new action will be placed, defaults to None. If None, the new action will be added to the end.
- Returns:
The new Action
- Return type:
- addContentLayout(lay)
Use this to add a content layout instead of a content widget to the user interface.
- Parameters:
lay (QLayout) – Content layout
- addContentWidget(cw)
Use this to add your main content widget to the user interface.
- Parameters:
cw (QWidget) – Content widget
- addMultiStateAction(event=None, states=None, before=None, attr=None, restore=True, default=0)
Adds an action with can be toggled between two states, each having a dedicated tooltip and icon.
- Parameters:
event (method, optional) – The function triggered by the stateAction, defaults to None
states (List[
MultiState
], optional) – The list of states the control can represent, defaults to a list of empty statesbefore (
Action
, optional) – An existing action or stateAction before which the new action will be placed, defaults to None. If None, the new stateAction will be added to the end.attr (str, optional) – Used to save and restore state, defaults to None
restore (bool, optional) – If True state will be restored when the program is restarted, defaults to True
default (int, optional) – Index of default state, defaults to 0
- Returns:
The new StateAction
- Return type:
- addRightAxis(ax)
Adds additional y labels on the right.
- addStateAction(event=None, toolTipFalse='', iconFalse=None, toolTipTrue='', iconTrue=None, before=None, attr=None, restore=True, default='false')
Adds an action with can be toggled between two states, each having a dedicated tooltip and icon.
- Parameters:
event (method, optional) – The function triggered by the stateAction, defaults to None
toolTipFalse (str, optional) – The toolTip of the stateAction if state is False, defaults to ‘’
iconFalse (
Icon
, optional) – The icon of the stateAction if state is False, defaults to NonetoolTipTrue (str, optional) – The toolTip of the stateAction if state is True, defaults to ‘’
iconTrue (
Icon
, optional) – The icon of the stateAction if state is True, defaults to Nonebefore (
Action
, optional) – An existing action or stateAction before which the new action will be placed, defaults to None. If None, the new stateAction will be added to the end.attr (str, optional) – used to save and restore state, defaults to None
restore (bool, optional) – If True state will be restored when the program is restarted, defaults to True
default (str, optional) – Default state as saved by qSettings, defaults to false
- Returns:
The new StateAction
- Return type:
- afterFinalizeInit()
Execute after all other plugins are finalized
- canvas: matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg
The canvas the figure renders into.
- close()
Closes plugin cleanly without leaving any data or communication running. Extend to make sure your custom data and custom communication is closed as well.
- closeGUI()
Closes the user interface but might keep data available in case the user interface is restored later. Closes all open references. Extend to save data and make hardware save if needed.
- closeUserGUI()
Called when the user closes a single plugin. Extend to react to user triggered closing.
- copyClipboard()
Copy matplotlib figure to clipboard.
- dependencyPath: Path = WindowsPath('.')
Path to the plugin file defining the plugin. Can be used to locate corresponding dependencies like external scripts or media which are stored next to the plugin file or in sub folders relative to its location.
- dock: DockWidget
The dockWidget that allows to float and rearrange the plugin user interface.
- documentation: str = None
The plugin documentation used in the internal about dialog in the Browser. If None, the doc string __doc__ will be used instead.
- fig: matplotlib.pyplot.figure
A figure, initialized e.g. using plt.figure(constrained_layout=True, dpi=getDPI()) and followed by self.makeFigureCanvasWithToolbar(self.fig).
- finalizeInit(aboutFunc=None)
Executed after all other Plugins are initialized. Use this for code that modifies other
Plugins
, e.g. adding anAction
to theDeviceManager
.- Parameters:
aboutFunc (method, optional) – Function displaying the about dialog of the plugin, defaults to None.
about()
is used if no other is provided.
- getDefaultSettings()
Defines a dictionary of
parameterDict()
which specifies default settings for this plugin. Overwrite or extend as needed to define specific settings that will be added to Settings section.- Returns:
Settings dictionary
- Return type:
- getIcon(desaturate=False)
Gets the plugin icon. Consider using a themed icon that works in dark and light modes. Overwrite only if definition of iconFile and iconFileDark is not sufficient.
- Returns:
Icon
- Return type:
- iconFile: str = ''
Default icon file. Expected to be in dependencyPath.
- iconFileDark: str = ''
Default icon file for dark mode. Expected to be in dependencyPath. Will fallback to iconFile.
- initDock()
Initializes the
DockWidget
.
- initFig()
Will be called when a display is closed and reopened or the theme is changed. Overwrite your figure initialization here to make sure all references are updated correctly.
- initGUI()
Initializes the graphic user interface (GUI), independent of all other plugins.
- initializedDock: bool
A flag signaling if the plugin
dock
has been initialized. You may want to ignore certain events before initialization is complete.
- initializedGUI: bool
A flag signaling if the plugin graphical user interface has been initialized. You may want to ignore certain events before initialization is complete.
- labelPlot(ax, label)
Adds file name labels to plot to trace back which file it is based on.
- loadData(file, _show=True)
Loads and displays data from file. This should only be called for files where
supportsFile()
returns True. Overwrite depending on data supported by the plugin.- Parameters:
file (pathlib.Path) – File from which to load data.
_show (bool, optional) – Show plugin after loading data, defaults to True. Some files are handled by multiple plugins and only one of them should be shown by default.
- property loading
A flag that can be used to suppress certain events while loading data or initializing the user interface. Make sure the flag is reset after every use. Internal logic allows nested use.
- lock: TimeoutLock
Locks are used to make sure methods decorated with @synchronized() cannot run in parallel, but one call has to be completed before the next.
- makeFigureCanvasWithToolbar(figure)
Creates
canvas()
, which can be added to the user interface, and adds the correspondingnavToolBar()
to the plugintitleBar()
.- Parameters:
figure (matplotlib.pyplot.figure) – A matplotlib figure.
- makeIcon(file, path=None, desaturate=False)
Returns an icon based on a filename. Looks for files in the
dependencyPath()
.- Parameters:
file (str) – Icon file name.
- Returns:
Icon
- Return type:
- name: str = ''
A unique name that will be used in the graphic user interface. Plugins can be accessed directly from the Console using their name.
Provides controls to interact with the figure.
- optional: bool = True
Defines if the user can deactivate the plugin in the
PluginManager
user interface.
- plot()
If applicable, overwrite with a plugin specific plot method.
- pluginManager: PluginManager
A reference to the central
PluginManager
.
- pluginType: TYPE = 'Internal'
The type defines the location of the plugin in the user interface and allows to run operations on a group of plugins with the same type using
getPluginsByType()
.
- previewFileTypes: List[str] = []
File extensions that are supported by this plugin. If a corresponding file is selected in the
Explorer()
, the pluginsloadData()
function will be called.
- print(message, flag=PRINT.MESSAGE)
The print function will send a message to stdout, the statusbar, the Console, and if enabled to the logfile. It will automatically add a timestamp and the name of the sending plugin.
- provideDock()
Adds existing
dock
to UI at position defined byesibd.plugins.Plugin.pluginType
.
- requireGroup(group, name)
Replaces require_group from h5py, and adds support for track_order.
- requiredPlugin(name)
Displays error message if required plugin is not available.
- runTestParallel()
Runs a series of tests by changing values of selected controls and triggering the corresponding events. Extend and add call to super().runTestParallel() to the end to make sure testing flag is set to False after all test completed!
- setLabelMargin(ax, margin)
Sets top margin only, to reserve space for file name label.
- Parameters:
ax (matplotlib.pyplot.axis) – The axis to which to add the top margin
margin (float) – The margin to add. 0.15 -> add 15 % margin
- supportedVersion: str = '0.7'
By default the current program version is used. You can define a fixed plugin version and future program versions will state that they are incompatible with this plugin. This can be used to prompt developers to update and test their plugins before distributing them for a more recent program version.
- supportsFile(file)
Tests if a file is supported by the plugin, based on file name or content.
- Parameters:
file (pathlib.Path) – File that has been selected by the user.
- Returns:
Returns True if the file is supported by the plugin. Test if supported based on file extension or content.
- Return type:
bool
- test()
Runs
runTestParallel()
in parallel thread.
- testControl(control, value, delay=0, label=None)
Changes control states and triggers corresponding events.
- titleBar: PyQt6.QtWidgets.QToolBar
Actions can be added to the titleBar using
addAction()
oraddStateAction()
.
- titleBarLabel: PyQt6.QtWidgets.QLabel
The label used in the titleBar.
- toggleTitleBar()
Adjusts the title bar layout and
titleBarLabel
depending on the state of thedock
(tabbed, floating, …). Extend to make sure toggleTitleBar is called for dependent plugins.
- updateTheme()
Changes between dark and light themes. Most controls should update automatically as the color pallet is changed. Only update the remaining controls using style sheets. Extend to adjust colors to app theme.
- version: str = ''
The version of the plugin. Plugins are independent programs that require independent versioning and documentation.
- waitForCondition(condition, interval=0.1, timeout=5, timeoutMessage='')
Waits until condition returns false or timeout expires. This can be safer and easier to understand than using signals and locks. The flag not just blocks other functions but informs them and allows them to react instantly.
- Parameters:
condition (callable) – will wait while condition returns True
interval (float) – wait interval seconds before checking condition
timeout (float) – timeout in seconds
- class esibd.plugins.Scan(*args: Any, **kwargs: Any)
Scans
are all sort of measurements that record any number of outputs as a function of any number of inputs. The main interface consists of a list of scan settings. Each scan comes with a tailored display optimized for its specific data format. Scan settings can be imported and exported from the scan toolbar, though in most cases it will be sufficient to import them from the context menu of a previously saved scan file in the Explorer. When all settings are defined and all relevant channels are communicating the scan can be started. A scan can be stopped at any time. At the end of a scan the corresponding file will be saved to the session path. The filename is displayed inside the corresponding graph to allow to find the file later based on exported figures. Scan files are saved in the widely used HDF5 file format that allows to keep data and metadata together in a structured binary file. External viewers, such as HDFView, or minimal python scripts based on the h5py package can be used if files need to be accessed externally. Use the context menu of a scan file to create a template plot file using h5py and adjust it to your needs.- class ScanChannel(*args: Any, **kwargs: Any)
Minimal UI for abstract PID channel.
- getDefaultChannel()
Defines parameter(s) of the default channel. This is also use to assign widgetTypes and if settings are visible outside of advanced mode. See
parameterDict()
. If parameters do not exist in the settings file, the default parameter will be added. Overwrite in dependent classes as needed.
- initGUI(item)
Call after item has been added to tree. Item needs parent for all graphics operations.
- onDelete()
Extend to handle events on deleting. E.g. handle references that should remain available.
- setDisplayedParameters()
Used to determine which parameters to use and in what order. Extend using
insertDisplayedParameter()
to add more parameters.
- tempParameters()
This channel is not restored from file, this every parameter is a tempParameter.
- class SignalCommunicate(*args: Any, **kwargs: Any)
Object that bundles pyqtSignals.
- saveScanCompleteSignal
Signal that confirms that scan data has been saved and a new scan can be started.
- scanUpdateSignal
Signal that triggers update of the figure and, if True is passed, saving of data.
alias of
bool
- updateRecordingSignal
Signal that allows to stop recording from an external thread.
alias of
bool
- class TreeSplitter(*args: Any, **kwargs: Any)
- addInputChannel(name, _from, to, step)
Converting channel to generic input data. Returns True if channel is valid for scanning.
- afterFinalizeInit()
Execute after all other plugins are finalized
- channels: List[ScanChannel]
List of output
meta channels
.
- documentation: str = 'Scans are all sort of measurements that record any number of outputs as a\n function of any number of inputs. The main interface consists of a list of\n scan settings. Each scan comes with a tailored display\n optimized for its specific data format. Scan settings can be imported\n and exported from the scan toolbar, though in most cases it will be\n sufficient to import them from the context menu of a previously saved\n scan file in the Explorer. When all settings are defined and all relevant channels are\n communicating the scan can be started. A scan can be stopped at any\n time. At the end of a scan the corresponding file will be saved to the\n session path. The filename is displayed inside the corresponding graph to\n allow to find the file later based on exported figures. Scan files are\n saved in the widely used HDF5 file format that allows to keep data and\n metadata together in a structured binary file. External viewers, such as\n HDFView, or minimal python scripts based on the h5py package can be used\n if files need to be accessed externally. Use the\n context menu of a scan file to create a template plot file using h5py\n and adjust it to your needs.'
The plugin documentation used in the internal about dialog in the Browser. If None, the doc string __doc__ will be used instead.
- estimateScanTime()
Estimates scan time. Will likely need to be adapted for custom scans.
- file: Path
The scan file. Either existing file or file to be created when scan finishes.
- property finished
True before and after scanning. Even when
recording
is set to False it will take time for the scan to complete and be ready to be started again.
- generatePythonPlotCode()
Saves minimal code to create a plot which can be customized by the user.
- getChannelByName: callable
Reference to
getChannelByName()
.
- getData(i, inout)
Gets the data of a scan channel based on index and type.
- Parameters:
i (int) – Index of channel.
inout (
INOUT
) – Type of channel.
- Returns:
The requested data.
- Return type:
numpy.array
- getOutputIndex()
Gets the index of the output channel corresponding to the currently selected display channel. See
useDisplayChannel
.
- getSteps(_from, to, step)
Returns steps based on _from, to, and step parameters.
- initScan()
Initializes all data and metadata. Returns True if initialization successful and scan is ready to start. Will likely need to be adapted for custom scans.
- inputs: List[MetaChannel]
List of input
meta channels
.
- loadDataInternal()
Loads data from scan file. Data is stored in scan-neutral format of input and output channels. Extend to provide support for previous file formats.
- measurementsPerStep: int
Number of measurements per step based on the average time and acquisition rate.
- outputs: List[ScanChannel]
List of output
meta channels
.
- plot(update=False, **kwargs)
Plot showing a current or final state of the scan. Extend to add scan specific plot code.
- Parameters:
update (bool, optional) – If update is True, only data will be updates, otherwise entire figure will be initialized, defaults to False
- pythonPlotCode()
Defines minimal code to create a plot which can be customized by user. Accessible from context menu of scan files. Overwrite to add scan specific plot code here.
- property recording
True if currently recording. Set to False to stop recording and save available data.
- run(recording)
Steps through input values, records output values, and triggers plot update. Executed in runThread. Will likely need to be adapted for custom scans.
- runThread: Thread
Parallel thread that updates the scan channel(s) and reads out the display channel(s).
- saveData(file)
Writes generic scan data to hdf file.
- saveScanParallel(file)
Keeps GUI interactive by saving scan data in external thread.
- toggleRecording()
Handles start and stop of scan.
- useDisplayChannel: bool
If True, a combobox will be created to allow to select for which channel data should be displayed.
- useDisplayParameter = False
Use display parameter to control which scan channels are displayed.
- class esibd.plugins.Settings(*args: Any, **kwargs: Any)
The settings plugin allows to edit, save, and load all general program and hardware settings. Settings can be edited either directly or using the context menu that opens on right click. Settings are stored in an .ini file which can be edited directly with any text editor if needed. The settings file that is used on startup is automatically generated if it does not exist. Likewise, default values are used for any missing parameters. Setting files can be exported or imported from the user interface. A change log will show which settings have changed after importing. In addition, the plugin manager and console can be opened from here.
- getDefaultSettings()
Defines general default settings
- iconFile: str = 'gear.png'
Default icon file. Expected to be in dependencyPath.
- incrementMeasurementNumber()
increment without triggering event
- init()
Call externally to init all internal settings and those of all other plugins.
- loadSettings(file=None, default=False)
Loads settings from hdf or ini file.
- name: str = 'Settings'
A unique name that will be used in the graphic user interface. Plugins can be accessed directly from the Console using their name.
- optional: bool = False
Defines if the user can deactivate the plugin in the
PluginManager
user interface.
- pluginType: PluginManager.TYPE = 'Generic Control'
The type defines the location of the plugin in the user interface and allows to run operations on a group of plugins with the same type using
getPluginsByType()
.
- runTestParallel()
Runs a series of tests by changing values of selected controls and triggering the corresponding events. Extend and add call to super().runTestParallel() to the end to make sure testing flag is set to False after all test completed!
- updateSessionPath(mesNum=0)
Updates the session path based on settings. Overwrite if you want to use different fields instead.
- Parameters:
mesNum (int, optional) – measurement number, defaults to 0
- version: str = '1.0'
The version of the plugin. Plugins are independent programs that require independent versioning and documentation.
- class esibd.plugins.SettingsManager(*args: Any, **kwargs: Any)
Bundles multiple
settings
into a single object to handle shared functionality.- initSettingsContextMenuBase(setting, pos)
General implementation of a context menu. The relevant actions will be chosen based on the type and properties of the
Setting
.
- loadSettings(file=None, default=False)
Loads settings from hdf or ini file.
- pluginType: PluginManager.TYPE = 'Internal'
The type defines the location of the plugin in the user interface and allows to run operations on a group of plugins with the same type using
getPluginsByType()
.
- saveSettings(file=None, default=False)
Saves settings to hdf or ini file.
- updateSettings(items, file)
Scans for changes and shows change log before overwriting old channel configuration.
- version: str = '1.0'
The version of the plugin. Plugins are independent programs that require independent versioning and documentation.
- class esibd.plugins.StaticDisplay(*args: Any, **kwargs: Any)
Displays
Device
data from file.- copyClipboard()
Extends matplotlib based version to add support for pyqtgraph.
- getIcon(**kwargs)
Gets the plugin icon. Consider using a themed icon that works in dark and light modes. Overwrite only if definition of iconFile and iconFileDark is not sufficient.
- Returns:
Icon
- Return type:
- loadDataInternal(file)
Load data in standard format. Overwrite in derived classes to add support for old file formats.
- plot(update=False)
Plots channels from file, using real channel information (color, linewidth, linestyle, …) if available.
- pluginType: PluginManager.TYPE = 'Display'
The type defines the location of the plugin in the user interface and allows to run operations on a group of plugins with the same type using
getPluginsByType()
.
- class esibd.plugins.UCM(*args: Any, **kwargs: Any)
Unified Channel Manager (UCM) allows to specify a custom list of channels from all
devices
. This allows to have the most relevant controls and information in one place. All logic remains within the corresponding device plugins. This is just an interface! To get started, simply add channels and name them after existing channels from other devices.- class UCMChannel(*args: Any, **kwargs: Any)
Minimal UI for abstract channel.
- getDefaultChannel()
Defines parameter(s) of the default channel. This is also use to assign widgetTypes and if settings are visible outside of advanced mode. See
parameterDict()
. If parameters do not exist in the settings file, the default parameter will be added. Overwrite in dependent classes as needed.
- initGUI(item)
Call after item has been added to tree. Item needs parent for all graphics operations.
- monitorChanged()
Highlights monitors if they deviate to far from set point. Extend for custom monitor logic if applicable.
- onDelete()
Extend to handle events on deleting. E.g. handle references that should remain available.
- setDisplayedParameters()
Used to determine which parameters to use and in what order. Extend using
insertDisplayedParameter()
to add more parameters.
- tempParameters()
List of parameters, such as live signal or status, that will not be saved and restored.
- afterFinalizeInit()
Execute after all other plugins are finalized
- channelType
alias of
UCMChannel
- documentation: str = 'Unified Channel Manager (UCM) allows to specify a custom list of channels from all devices.\n This allows to have the most relevant controls and information in one place.\n All logic remains within the corresponding device plugins. This is just an interface!\n To get started, simply add channels and name them after existing channels from other devices.'
The plugin documentation used in the internal about dialog in the Browser. If None, the doc string __doc__ will be used instead.
- iconFile: str = 'UCM.png'
Default icon file. Expected to be in dependencyPath.
- initGUI()
Initializes the graphic user interface (GUI), independent of all other plugins.
- loadConfiguration(file=None, default=False)
Loads
channel
configuration from file. If only values should be loaded without complete reinitialization, useloadValues
instead.- Parameters:
file (pathlib.Path, optional) – File from which to load configuration, defaults to None
default (bool, optional) – Use internal configuration file if True, defaults to False
- loadData(file, _show=True)
Loads and displays data from file. This should only be called for files where
supportsFile()
returns True. Overwrite depending on data supported by the plugin.- Parameters:
file (pathlib.Path) – File from which to load data.
_show (bool, optional) – Show plugin after loading data, defaults to True. Some files are handled by multiple plugins and only one of them should be shown by default.
- moveChannel(up)
Moves the channel up or down in the list of channels.
- Parameters:
up (bool) – Move up if True, else down.
- name: str = 'UCM'
A unique name that will be used in the graphic user interface. Plugins can be accessed directly from the Console using their name.
- optional: bool = True
Defines if the user can deactivate the plugin in the
PluginManager
user interface.
- pluginType: PluginManager.TYPE = 'Channel Manager'
The type defines the location of the plugin in the user interface and allows to run operations on a group of plugins with the same type using
getPluginsByType()
.
- previewFileTypes: List[str] = []
File extensions that are supported by this plugin. If a corresponding file is selected in the
Explorer()
, the pluginsloadData()
function will be called.
- toggleRecording(on=None, manual=False)
Toggle plotting of data in
LiveDisplay
. Extend to add recoding logic for devices.- Parameters:
on (bool, optional) – If true recording will be turned on, if false it will be turned off. If already on or off nothing happens. If None, recording is toggled.
manual (bool, optional) – If true, signal was send directly from corresponding live display. Otherwise might be send from device manager
- useMonitors = True
Use record monitors and compare them to set points.
- version: str = '1.0'
The version of the plugin. Plugins are independent programs that require independent versioning and documentation.
Defines which plugins are loaded and in what order. Only use to replace plugins specified below with extended versions. Define all other plugins in plugins_internal or a user plugin folder.
- esibd.providePlugins.providePlugins()
Returns list of
plugins
that are available for activation in thePluginManager
user interface accessible from Settings.- Returns:
Plugin list
- Return type:
[
Plugin
]
5.2. The core module
This module contains internally used functions and classes. Generally all objects that are used across multiple modules should be defined here to avoid circular imports and keep things consistent. Whenever it is possible to make definitions only locally where they are needed, this is preferred. For now, English is the only supported language and use of hard coded error messages etc. in other files is tolerated if they are unique.
- class esibd.core.Action(*args: Any, **kwargs: Any)
- class esibd.core.Channel(*args: Any, **kwargs: Any)
A
channel
represents a virtual or real parameter and manages all data and metadata related to that parameter. Each device can only have one type of channel, but channels have dynamic interfaces that allow to account for differences in the physical backend.Channels provide a consistent and structured interface to inputs and outputs. In the advanced mode, channels can be duplicated, moved, or deleted. You may also edit channels directly in the corresponding .ini file in the config path.
Channels are accessible from any plugin using
getChannelByName()
. This, and other features like linking channels by equations, depends on the usage of unique and descriptive channel names.- appendValue(lenT, nan=False)
Appends a datapoint to the recorded values.
- Parameters:
lenT (int, optional) – length of corresponding time array, defaults to None
nan (bool) – If true, np.nan is used instead of current value. This should mark a new collection and prevent interpolation in regions without data.
- asDict(temp=False, formatValue=False)
Returns a dictionary containing all channel parameters and their values.
- Parameters:
temp (bool, optional) – If true, dict will contain temporary parameters
- displayedParameters: List[str]
List of parameters that determines which parameters are shown in the user interface and in what order. Compare
insertDisplayedParameter()
. If your custom parameter is not in this list it will not be visible in the user interface.
- enabledChanged()
Extend as needed. Already linked to enabled checkbox.
- getDefaultChannel()
Defines parameter(s) of the default channel. This is also use to assign widgetTypes and if settings are visible outside of advanced mode. See
parameterDict()
. If parameters do not exist in the settings file, the default parameter will be added. Overwrite in dependent classes as needed.
- getSortedDefaultChannel()
Returns default channel sorted in the order defined by
displayedParameters
.
- getValues(length=None, _min=None, _max=None, n=1, subtractBackground=None)
Returns plain Numpy array of values. Note that background subtraction only affects what is displayed, the raw signal and background curves are always retained.
- initGUI(item)
Call after item has been added to tree. Item needs parent for all graphics operations.
- initSettingsContextMenuBase(parameter, pos)
General implementation of a context menu. The relevant actions will be chosen based on the type and properties of the
Parameter
.
- insertDisplayedParameter(parameter, before)
Inserts your custom parameter before an existing parameter in
displayedParameters
.
- lastAppliedValue: any
Reference to last value. Allows to decide if hardware update is required.
- monitorChanged()
Highlights monitors if they deviate to far from set point. Extend for custom monitor logic if applicable.
- onDelete()
Extend to handle events on deleting. E.g. handle references that should remain available.
- plotCurve: pyqtgraph.PlotCurveItem
The plotCurve in the corresponding
LiveDisplay
.
- setDisplayedParameters()
Used to determine which parameters to use and in what order. Extend using
insertDisplayedParameter()
to add more parameters.
- tempParameters()
List of parameters, such as live signal or status, that will not be saved and restored.
- tree: PyQt6.QtWidgets.QTreeWidget
TreeWidget containing the channel widgets.
- updateColor()
Apply new color to all controls.
- values: DynamicNp
The history of values shown in the
LiveDisplay
. UsegetValues()
to get a plain numpy.array.
- class esibd.core.CheckBox(*args: Any, **kwargs: Any)
Allows to set values in a widget in a consistent way.
- class esibd.core.CloseDialog(*args: Any, **kwargs: Any)
Dialog to confirm closing the program.
- class esibd.core.CompactComboBox(*args: Any, **kwargs: Any)
Combobox that stays small while showing full content in dropdown menu.s
- class esibd.core.ControlCursor(*args: Any, **kwargs: Any)
Extending internal implementation to get draggable cursor.
- setPosition(x, y)
emulated mouse event to set position
- class esibd.core.DeviceController(*args: Any, **kwargs: Any)
Each
Device
orChannel
comes with aDeviceController
. TheDeviceController
is not itself aPlugin
. It only abstracts the direct hardware communication fromplugins
allowing them to use minimal and consistent code that can be adjusted and reused independently of the hardware. It should do all resource or time intensive communication work in parallel threads to keep the GUI responsive. Following the producer-consumer pattern, theDeviceController
reads values from a physical device and assigns them to the correspondingChannel
. Thedevices
will collect data from theChannel
independently. In case you work with time sensitive experiments this concept will need to be adapted. Feel free to use the basic functionality provided byDeviceController
or implement your own from scratch. As theDeviceController
only interacts with your customChannel
orDevice
, there are no general requirements for its implementation.- class SignalCommunicate(*args: Any, **kwargs: Any)
Object that bundles pyqtSignals for the
DeviceController
. Extend to add additional events.- closeCommunicationSignal
Signal that triggers the acquisition to stop after communication errors.
- initCompleteSignal
Signal that is emitted after successful initialization of device communication.
- updateValueSignal
Signal that transfers new data from the
acquisitionThread
to the corresponding channels.
- acquiring: bool = False
True, while acquisitionThread is running. AcquisitionThread terminates if set to False.
- acquisitionThread: Thread = None
A parallel thread that regularly reads values from the device.
- closeCommunication()
Closes all open ports. This should free up all resources and allow for clean reinitialization. Extend to add hardware specific code Make sure acquisition is stopped before communication is closed.
- fakeInitialization()
Called in test mode instead of runInitialization
- initComplete()
Called after successful initialization to start acquisition from main thread (access to GUI!).
- initThread: Thread = None
A parallel thread used to initialize communication.
- initializeCommunication()
Starts the
initThread()
.
- initialized: bool = False
Indicates if communications has been initialized successfully and not yet terminated.
- initializing: bool = False
Indicates if communications is being initialized.
- lock: TimeoutLock
Lock used to avoid race conditions when communicating with the hardware.
- parent: any
Reference to the associated class.
- port: serial.Serial = None
Port for serial communication.
- runAcquisition(acquiring)
Runs acquisition loop. Executed in acquisitionThread. Overwrite with hardware specific acquisition code.
- runInitialization()
Hardware specific initialization of communication. Executed in initThread (no access to GUI!).
- serialRead(port, encoding='utf-8', EOL='\n', strip=None)
Reads a string from a serial port. Takes care of decoding messages from bytes and catches common exceptions.
- Parameters:
port (serial.Serial) – Serial port.
encoding (str, optional) – Encoding used for sending and receiving messages, defaults to ‘utf-8’
- Returns:
message
- Return type:
str
- serialWrite(port, message, encoding='utf-8')
Writes a string to a serial port. Takes care of decoding messages to bytes and catches common exceptions.
- Parameters:
port (serial.Serial) – Serial port.
message (str) – Message.
encoding (str, optional) – Encoding used for sending and receiving messages, defaults to ‘utf-8’
- startAcquisition()
Starts data acquisition from physical device.
- stopAcquisition()
Terminates acquisition but leaves communication initialized.
- updateValue()
Called from acquisitionThread to update the value of the channel(s) in the main thread. Overwrite with specific update code.
- class esibd.core.DockWidget(*args: Any, **kwargs: Any)
DockWidget with custom title bar allows to intercept the close and float events triggered by user.
- class SignalCommunicate(*args: Any, **kwargs: Any)
- toggleTitleBar()
Updates titleBar as dock is changing from floating to docked states.
- class esibd.core.DynamicNp(initialData=None, max_size=None, dtype=<class 'numpy.float32'>)
A numpy.array that dynamically increases its size in increments to prevent frequent memory allocation while growing.
- add(x, lenT=None)
Adds the new data point and adjusts the data array as required.
- Parameters:
x (float) – Datapoint to be added
lenT (int, optional) – length of corresponding time array, defaults to None
- get(length=None, _min=None, _max=None, n=1)
Returns actual values.
- Parameters:
length (int) – will return last ‘length’ values.
_min (int) – Index of lower limit.
_max (int) – Index of upper limit.
n (int, optional) – Will only return every nth value, defaults to 1
- Returns:
Values in specified range.
- Return type:
numpy.array
- class esibd.core.EsibdExplorer(*args: Any, **kwargs: Any)
ESIBD Explorer: A comprehensive data acquisition and analysis tool for Electrospray Ion-Beam Deposition experiments and beyond.
Contains minimal code to start, initialize, and close the program. All high level logic is provided by
core
,plugins
and additionalplugins
.- closeEvent(event)
Triggers
PluginManager
to close all plugins and all related communication.
- restoreUiState()
Restores size and location of main window.
- saveUiState()
Saves size and location of main window.
- toggleFullscreen()
Toggles full screen mode.
- class esibd.core.Icon(*args: Any, **kwargs: Any)
QIcon that allows to save the icon file name. Allows to reuse icon elsewhere, e.g., for html about dialog.
- class esibd.core.LabelItem(*args: Any, **kwargs: Any)
- class esibd.core.LedIndicator(*args: Any, **kwargs: Any)
Simple custom LED indicator
- class esibd.core.LineEdit(*args: Any, **kwargs: Any)
- sizeHint()
Return reasonable size hint based on content within minimum and maximum limits
- userEditingFinished
alias of
str
- validateInput()
Validate the text and remove invalid characters
- class esibd.core.Logger(*args: Any, **kwargs: Any)
Redirects stderr and stdout to logfile while still sending them to Console as well. Also shows messages on Status bar. Use
print()
to send messages to the logger.- close()
Disables logging and restores stdout and stderr.
- flush()
Flushes content to log file.
- open()
Activates logging of Plugin.print statements, stdout, and stderr to the log file.
- openLog()
Opens the log file in an external program.
- print(message, sender='ESIBD Explorer 0.7.1', flag=PRINT.MESSAGE)
Augments messages and redirects to log file, statusbar, and console.
- printFromThreadSignal
alias of
str
- class esibd.core.MZCalculator(parentPlugin, ax=None)
Add to a class derived from Scan. Allows to mark mass to charge (m/z) locations within a charge-state distribution, calculates absolute mass, and displays it on the axis. Use Ctrl + left mouse click to mark and Ctrl + right mouse click to reset.
- determine_mass_to_charge()
Estimates charge states based on m/z values provided by user by minimizing standard deviation of absolute mass within a charge state series. Provides standard deviation for neighboring series to allow for validation of the result.
- class esibd.core.MetaChannel(parentPlugin=None, name=None, unit='', recordingData=None, initialValue=None, recordingBackground=None, inout=None)
Manages metadata associated with a channel by a
Scan
orLiveDisplay
. Allows to restore data even if corresponding channels do not exist anymore.- namestr
The scan channel name is usually the same as the name of the corresponding
Channel
.- datanumpy.array
Scan data is saved and restored automatically. Each scan is free to define its data with arbitrary dimensions.
- initialvar
Initial value. Used to restore all conditions after scan has completed.
- backgroundnumpy.array
If used, has to be of same dimension as data.
- unitstr
The channel unit.
- channel:
PluginManager
The actual channel, if it exists.
- class esibd.core.MultiStateAction(*args: Any, **kwargs: Any)
Extends QActions to show different icons depending on multiple states. Values are restored using QSettings if name is provided.
- class esibd.core.NumberBar(*args: Any, **kwargs: Any)
A bar that displays line numbers of an associated editor.
- class esibd.core.Parameter(name, _parent=None, default=None, widgetType=None, index=1, items=None, fixedItems=False, widget=None, internal=False, tree=None, itemWidget=None, toolTip=None, event=None, _min=None, _max=None, indicator=False, instantUpdate=True)
Parameters are used by settings and channels. They take care of providing consistent user controls, linking events, input validation, context menus, and restoring values. Typically they are not initialized directly but via a
parameterDict()
from which settings and channels take the relevant information.- class TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Specifies what type of widget should be used to represent the parameter in the user interface.
- BOOL = 'BOOL'
A boolean, represented by a checkbox.
- COLOR = 'COLOR'
A ColorButton that allows to select a color.
- COMBO = 'COMBO'
A combobox providing text options.
- EXP = 'EXP'
A spinbox with scientific format.
- FLOAT = 'FLOAT'
A floating point spinbox.
- FLOATCOMBO = 'FLOATCOMBO'
A combobox providing floating point options.
- INT = 'INT'
An integer spinbox.
- INTCOMBO = 'INTCOMBO'
A combobox providing integer options.
- LABEL = 'LABEL'
A label that displays information.
- PATH = 'PATH'
A path to a file or directory.
- TEXT = 'TEXT'
An editable text field.
- advanced: bool
If True, parameter will only be visible in advanced mode. Only applies to channel parameters.
- applyChangedEvent()
Assign events to the corresponding controls. Even indicators should be able to trigger events, e.g. to update dependent channels.
- applyWidget()
Creates UI widget depending on
widgetType
. Links dedicatedwidget
if provided.
- attr: str
Allows direct access to the parameter. Only applies to channel and settings parameters.
E.g. The color parameter of a channel specifies attr=’color’ and can thus be accessed via channel.color.
E.g. The Session path parameter in
Settings
specifies attr=’sessionPath’ and can thus be accessed via Settings.sessionPath.E.g. The interval parameter of a device specifies attr=’interval’ and can thus be accessed via device.interval.
E.g. The notes parameter of a scan specifies attr=’notes’ and can thus be accessed via scan.notes.
- equals(value)
Returns True if a representation of value matches the value of the parameter
- event: callable
A function that will be triggered when the parameter value changes.
- extraEvents: List[callable]
Used to add internal events on top of the user assigned ones.
- fixedItems: bool
Indicates if list of items can be edited by the user or should remain fixed.
- fullName: str
Will contain path of setting in HDF5 file if applicable.
- header: str
Header used for the corresponding column in list of channels. The parameter name is used if not specified. Only applies to channel parameters.
- indicator: bool
Indicators cannot be edited by the user.
- instantUpdate: bool
By default, events are triggered as soon as the value changes. If set to False, certain events will only be triggered if editing is finished by the enter key or if the widget loses focus.
- internal: bool
Set to True to save parameter value in the registry (using QSetting) instead of configuration files. This can help to reduce clutter in configuration files and restore essential parameters even if configuration files get moved or lost.
- itemWidget: PyQt6.QtWidgets.QTreeWidgetItem
If this is not None, parameter is part of a channel otherwise of a setting.
- property items
List of options for parameters with a combobox.
- max: float
Maximum limit for numerical properties.
- min: float
Minimum limit for numerical properties.
- settingEvent()
Extend to manage changes to settings
- toolTip: str
Tooltip used to describe the parameter.
- tree: PyQt6.QtWidgets.QTreeWidget
None, unless the parameter is used for settings.
- validateComboInput(value)
Validates input for comboboxes
- property value
The default value of the parameter in any supported type.
- widget: PyQt6.QtWidgets.QWidget
A custom widget that will be used instead of the automatically provided one.
- class esibd.core.PlotItem(*args: Any, **kwargs: Any)
PlotItem providing xyLabel.
- parentPlot()
Plot if Xrange changed by user. When looking at larger x ranges sections might not be shown due to data thinning. Make sure the number of displayed data points is appropriate for your data.
- class esibd.core.PlotWidget(*args: Any, **kwargs: Any)
PlotWidget providing xyLabel.
- class esibd.core.PluginManager
The
PluginManager
is responsible for loading all internal and external Plugins. It catches errors or incompatibilities while loading, initializing, and closing plugins. Users will only see the plugin selection interface accessed from the Settings plugin. ThePluginManager
can be accessed from the Console as PluginManager. It allows plugins to interact by using unique plugin names as attributes, e.g. self.pluginManager.ISEG or self.pluginManager.DeviceManager.- class SignalCommunicate(*args: Any, **kwargs: Any)
- class TYPE(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Each plugin must be of one of the following types to define its location and behavior.
- CHANNELMANAGER = 'Channel Manager'
A plugin that manages channels which are neither inputs or outputs.
- CONSOLE = 'Console'
The internal Console.
- CONTROL = 'Generic Control'
Any control plugin, will be placed next to Settings, Explorer, Devices, and Scans.
- DEVICEMGR = 'DeviceManager'
Device manager, will be placed below live displays.
- DISPLAY = 'Display'
Any display plugin, will be places next to scan displays and static displays.
- INPUTDEVICE = 'Input Device'
Device plugin sending user input to hardware.
- INTERNAL = 'Internal'
A plugin without user interface.
- LIVEDISPLAY = 'LiveDisplay'
Live display associated with a device.
- OUTPUTDEVICE = 'Output Device'
Device plugin sending hardware output to user.
- SCAN = 'Scan'
Scan plugin, will be placed with other controls.
- addPluginTreeWidgetItem(tree, item, name)
Adds a row for given plugin. If not a core plugin it can be enabled or disabled using the checkbox.
- afterFinalizeInit()
Finalize initialization after all other plugins have been initialized.
- closePlugins(reload=False)
Closes all open connections and leave hardware in save state (e.g. voltage off).
- finalizeInit()
Finalize initialization after all other plugins have been initialized.
- finalizeUiState()
Restores dimensions of core plugins.
- getMainPlugins()
Returns all plugins found in the control section, including devices, controls, and scans.
- getPluginsByClass(parentClasses)
Returns all plugins of the specified type.
- Parameters:
parentClasses (class) – A single class or list of classes.
- Returns:
List of matching plugins.
- Return type:
[
Plugin
]
- getPluginsByType(pluginTypes)
Returns all plugins of the specified type.
- loadPlugin(Plugin, dependencyPath=None)
Load a single plugin. Plugins must have a static name and pluginType. ‘mainWindow’ is passed to enable flexible integration, but should only be used at your own risk. Enabled state is saved and restored from an independent file and can also be edited using the plugins dialog.
- loadPlugins(reload=False)
Loads all enabled plugins.
- loadPluginsFromModule(Module, dependencyPath)
Loads plugins from a module.
- property loading
Flag that can be used to suppress events while plugins are loading, initializing, or closing.
- managePlugins()
A dialog to select which plugins should be enabled.
- plugins = []
A central plugin list that allows plugins to interact with each other.
- provideDocks()
Creates docks and positions them as defined by
pluginType
- resetMainDisplayWidgetLimits()
Resets limits to allow for user scaling of plugin sizes.
- runTestParallel()
Runs test of all plugins from parallel thread.
- test()
Calls
runTestParallel()
to test most features of for all plugins.
- updateTheme()
Updates application theme while showing a splash screen if necessary.
- class esibd.core.QLabviewDoubleSpinBox(*args: Any, **kwargs: Any)
Implements handling of arrow key events based on curser position similar as in LabView.
- stepBy(step)
Handles stepping value depending con caret position. This implementation works with negative numbers and of number of digits before the dot.
- textFromValue(value)
make sure nan and inf will be represented by NaN.
- class esibd.core.QLabviewSciSpinBox(*args: Any, **kwargs: Any)
Spinbox for scientific notation.
- class FloatValidator(*args: Any, **kwargs: Any)
Validates input for correct scientific notation.
- stepBy(step)
Handles stepping value depending con caret position. This implementation works with negative numbers and of number of digits before the dot.
- textFromValue(value)
make sure nan and inf will be represented by NaN.
- class esibd.core.QLabviewSpinBox(*args: Any, **kwargs: Any)
Implements handling of arrow key events based on curser position similar as in LabView.
- stepBy(step)
Handles stepping value depending con caret position.
- class esibd.core.RestoreFloatComboBox(*args: Any, **kwargs: Any)
ComboBox that allows to restore its value upon restart using an internal
Setting
- class esibd.core.ScanChannel(*args: Any, **kwargs: Any)
Minimal UI for abstract PID channel.
- getDefaultChannel()
Defines parameter(s) of the default channel. This is also use to assign widgetTypes and if settings are visible outside of advanced mode. See
parameterDict()
. If parameters do not exist in the settings file, the default parameter will be added. Overwrite in dependent classes as needed.
- initGUI(item)
Call after item has been added to tree. Item needs parent for all graphics operations.
- onDelete()
Extend to handle events on deleting. E.g. handle references that should remain available.
- setDisplayedParameters()
Used to determine which parameters to use and in what order. Extend using
insertDisplayedParameter()
to add more parameters.
- tempParameters()
This channel is not restored from file, this every parameter is a tempParameter.
- class esibd.core.SciAxisItem(*args: Any, **kwargs: Any)
Based on original logTickStrings. Only difference to source code is 0.1g -> .0e and consistent use of 1 = 10⁰.
- class esibd.core.Setting(*args: Any, **kwargs: Any)
Parameter to be used as general settings with dedicated UI controls instead of being embedded in a channel.
- resetWidget()
Returns widget back to the Settings tree.
- setWidget(widget)
Allows to change to custom widget after initialization. E.g. to move a setting to a more logical position outside the Settings tree.
- settingEvent()
Executes internal validation based on setting type. Saves parameters to file or qSet to make sure they can be restored even after a crash. Finally executes setting specific event if applicable.
- class esibd.core.SplashScreen(*args: Any, **kwargs: Any)
Program splash screen that indicates loading.
- class esibd.core.StateAction(*args: Any, **kwargs: Any)
Extends QActions to show different icons depending on a state. Values are restored using QSettings if name is provided.
- class esibd.core.ThemedConsole(*args: Any, **kwargs: Any)
pyqtgraph.console.ConsoleWidget with colors adjusting to theme.
Provides controls to interact with the figure. Adds light and dark theme support to NavigationToolbar2QT.
Changes color of icons in matplotlib navigation toolBar to match theme.
- class esibd.core.TimeoutLock(_parent)
A Lock that allows to specify a timeout inside a with statement. Can be used as normal Lock or optionally using ‘with self.lock.acquire_timeout(1) as lock_acquired:’
- acquire_timeout(timeout, timeoutMessage=None, lock_acquired=False)
- Parameters:
timeout (float, optional) – timeout in seconds
timeoutMessage (str, optional) – Message shown in case of a timeout
lock_acquired (bool, optional) – True if lock has already been acquired in callstack. Use to prevent deadlocks
- class esibd.core.ToolButton(*args: Any, **kwargs: Any)
Allows to set values in a widget in a consistent way.
- class esibd.core.TreeWidget(*args: Any, **kwargs: Any)
- itemRect()
Returns the QRect of all visible items.
- totalItems()
total number of items at top level and first child level
- esibd.core.parameterDict(name=None, value=None, default=None, _min=None, _max=None, toolTip=None, items=None, fixedItems=False, tree=None, widgetType=None, advanced=False, header=None, widget=None, event=None, internal=False, attr=None, indicator=False, instantUpdate=True)
Provides default values for all properties of a parameter. See
Parameter
for definitions.
5.3. Constants
Defines constants used throughout the package.
- class esibd.const.Colors
Provides dark mode dependent default colors.
- class esibd.const.INOUT(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Used to specify if a function affects only input, only output, or all channels.
- ALL = 4
Input and output and all others.
- BOTH = 2
Both input and output.
- IN = 0
Input
- NONE = 3
Neither input nor output.
- OUT = 1
Output
- class esibd.const.PRINT(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Used to specify if a function affects only input, only output, or all channels.
- DEBUG = 3
Only show if debug flag is enabled.
- ERROR = 2
Tag message as error and highlight using color.
- EXPLORER = 4
Key messages by Explorer
- MESSAGE = 0
A standard message.
- WARNING = 1
Tag message as warning and highlight using color.
- esibd.const.getClipboardTheme()
Gets the dark clipboard mode from Settings.
- Returns:
Dark clipboard mode
- Return type:
bool
- esibd.const.getShowDebug()
Gets the debug mode from Settings.
- Returns:
Debug mode
- Return type:
bool
- esibd.const.makeSettingWrapper(name, settingsMgr, docstring=None)
Neutral setting wrapper for convenient access to the value of a setting. If you need to handle events on value change, link these directly to the events of the corresponding control.
- esibd.const.makeStateWrapper(stateAction, docstring=None)
State wrapper for convenient access to the value of a StateAction.
- esibd.const.makeWrapper(name, docstring=None)
Neutral property wrapper for convenient access to the value of a parameter inside a channel. If you need to handle events on value change, link these directly to the events of the corresponding control in the finalizeInit method.
- esibd.const.openInDefaultApplication(file)
Opens file in system default application for file type.
- Parameters:
file (str / pathlib.Path) – Path to the file to open.
- esibd.const.smooth(array, smooth)
Smooths a 1D array while keeping edges meaningful. This method is robust if array contains np.nan.
- esibd.const.validatePath(path, default)
Returns a valid path. If the path does not exist, falling back to default. If default does not exist it will be created
- Returns:
Valid path
- Return type:
Path
- Returns:
Indicates if path has changed during validation
- Return type:
bool