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.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)
Object than bundles pyqtSignals for the device
- appendDataSignal
Signal that triggers appending of data from channels to history.
- plotSignal
Signal that triggers plotting of history.
- apply(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
- 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.
- convertDataDisplay(data)
Overwrite to apply scaling and offsets to data before it is displayed. Use, e.g., to convert to another unit.
- 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.
- 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
.
- getChannelByName(name)
Returns a device specific channel based on its unique name.
- 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.
- getSelectedChannel()
Returns selected channel. Note, channels can only be selected in advanced mode.
- getUnit()
Overwrite if you want to change units dynamically.
- init()
Extend device initialization as needed. Note, this inits the device GUI. Device communication is initialized by the corresponding
DeviceController
.
- initialized()
Extend to indicate when the device is initialized.
- 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 configuraion. Channels that exist in the file but not in the current configuration will be ignored. Only used by input devices.
- 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.
- 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)
Regulartly 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()
Extend to start all device related communication.
- staticDisplay: StaticDisplay
Internal plugin to display data from file.
- stop()
Stops recording and also closes all device communication. Extend to add custom code to close device communication.
- stopAcquisition()
Extend to stop all device related communication.
- 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()
Toggle recoding of data in
LiveDisplay
.
- unit: str = 'unit'
Unit used in user interface.
- updateChannelConfig(items, file)
Scans for changes when loading configuration and displays change log before overwriting old channel configuraion.
- 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.
- useBackgrounds: bool
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.
- storeSignal
Signal that triggers storage of device data.
- 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.
- 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: [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. The toolbar provides icons to initialize, start, pause, stop acquisition, optionally subtract backgrounds, or export displayed data to the current session. 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.
- copyClipboard()
Extends matplotlib based version to add support for pyqtgraph.
- documentation: str = 'Live displays show the history of measured data over time. The toolbar\n provides icons to initialize, start, pause, stop acquisition, optionally\n subtract backgrounds, or export displayed data to the current session.\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.
- plot(apply=False)
Plots the enabled and initialized channels in the main output plot The x axis is either time or a selected channel
- 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.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.- addAction(func=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 (
BetterIcon
, 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
- addRightAxis(ax)
Adds additional y labels on the right.
- addStateAction(func=None, toolTipFalse='', iconFalse=None, toolTipTrue='', iconTrue=None, before=None, attr=None, restore=True)
Adds an action with can be toggled between two states, each having a dedicated tooltip and icon.
- Parameters:
func (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 (
BetterIcon
, 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 (
BetterIcon
, 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) – Enables direct access to the state of the stateAction using self.attr, defaults to None
restore (bool, optional) – If True state will be restored when the program is restarted, defaults to True
- Returns:
The new StateAction
- Return type:
- 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 subfolders relative to its location.
- dock: BetterDockWidget
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()
Gets the plugin icon. Overwrite to introduce custom icons. Consider using a themed icon that works in dark and light modes.
- Returns:
Icon
- Return type:
- initDock()
Initializes the
BetterDockWidget
.
- 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.
- makeCoreIcon(file)
Returns an icon based on a filename. Looks for files in the internal media folder.
- Parameters:
file (str) – Icon file name.
- Returns:
Icon
- Return type:
- 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)
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: [<class '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(g, name)
Replaces require_group from h5py, and adds support for track_order.
- requiredPlugin(name)
Throws exeption if required plugin is not available.
- runTestParallel()
Runs a series of tests by changing values of selected controls and triggering the corresponding events. Extend to add more plugin specific tests.
- Returns:
Returns True if the plugin is initialized and further tests can be executed.
- Return type:
bool
- setLabelMargin(ax, margin)
Sets top margin only, to reserve space for file name label.
- supportedVersion: str = '0.6.16'
By default the current program version is used. You can define a fixed 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)
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.
- 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 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
- addInputChannel(channelName, _from, to, step)
Converting channel to generic input data. Returns True if channel is valid for scanning.
- 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: [<class 'esibd.core.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: [<class 'esibd.core.MetaChannel'>]
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.
- 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 relevent 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 configuraion.
- 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.
- 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, …) 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()
.
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 accross 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.BetterDockWidget(*args: Any, **kwargs: Any)
DockWidget with custom title bar allows to intercept the close and float events triggred by user.
- class SignalCommunicate(*args: Any, **kwargs: Any)
- toggleTitleBar()
Updates titlebar as dock is changing from floating to docked states.
- class esibd.core.BetterIcon(*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.BetterPlotWidget(*args: Any, **kwargs: Any)
PlotWidget providing xyLabel.
- 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.
- asDict()
Returns a dictionary containing all channel parameters and their values.
- displayedParameters: [<class '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.
- 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.
- 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 independent 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.- initCompleteSignal
Signal that is emitted after successful initialization of device communication.
- stopSignal
Signal that triggers the acquisition to stop after communication errors.
- 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.
- close()
Terminates acquisition and closes all open ports. Extend to add hardware specific code.
- init()
Starts the
initThread()
.
- initComplete()
Called after successful initialization to start acquisition.
- initThread: Thread = None
A parallel thread used to initialize communication.
- initialized: bool = False
Indicates if communications has been initialized successfully and not yet terminated.
- initializing: bool = False
Indicates if communications is beeing 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 acquisitoin loop. Executed in acquisitionThread. Overwrite with hardware specific acquisition code.
- runInitialization()
Hardware specific initialization of communication. Executed in initThread.
- serialRead(port, encoding='utf-8', EOL='\n')
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.
- stop()
Overwrite to stop recording and acquisition in case a communication error occured. This should free up all resources and allow for clean reinitialization.
- 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.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.
- 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.LedIndicator(*args: Any, **kwargs: Any)
Simple custom LED indicator
- class esibd.core.Logger(*args: Any, **kwargs: Any)
Redicrects 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.6.16', flag=PRINT.MESSAGE)
Augments messages and redirects to log file, console, statusbar, and console.
- printFromThreadSignal
alias of
str
- class esibd.core.MZCaculator(parentPlugin, ax=None)
Add to a class derived from Scan. Allows to mark mass to charge (m/z) locations within a chargestate distrubution, 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 neightbouring series to allow for validation of the result.
- class esibd.core.MetaChannel(name, data, initial=None, background=None, unit='', channel=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 usualy 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.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, 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.
- 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.
- extendedEvent: callable
Used to add internal events on top of the user assigned ones.
- 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.
- 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.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.
- 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, name, enabled, version_, pluginType, previewFileTypes, description, optional=True)
Adds a row for given plugin. If not a core plugin it can be enabled or disabled using the checkbox.
- closePlugins(reload=False)
Closes all open connections and leave hardware in save state (e.g. voltage off).
- finalizeInit()
Finalize initalization 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.
- getPluginsByType(pluginTypes)
Returns all plugins of the specified type.
- Parameters:
pluginTypes (
TYPE()
) – A single type or list of types.- Returns:
_description_
- Return type:
_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 if 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 digets before the dot.
- 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 digets before the dot.
- 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.SciAxisItem(*args: Any, **kwargs: Any)
Based on original logTickStrings. Only difference to source code is 0.1g -> .0e and consistend 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 Settigs 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.
- setStack(frame=None, tb=None)
Display a call stack and exception traceback.
This allows the user to probe the contents of any frame in the given stack.
frame may either be a Frame instance or None, in which case the current frame is retrieved from
sys._getframe()
.If tb is provided then the frames in the traceback will be appended to the end of the stack list. If tb is None, then sys.exc_info() will be checked instead.
- write(strn, html=False, scrollToBottom='auto')
Write a string into the console.
If scrollToBottom is ‘auto’, then the console is automatically scrolled to fit the new text only if it was already at the bottom.
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
A Lock that allows to specify a timeout inside a with statement. Can be used as normal Lock or optonally using ‘with self.lock.acquire_timeout(2) as acquired:’
- class esibd.core.ToolButton(*args: Any, **kwargs: Any)
Allows to set values in a widget independent consistent way.
- esibd.core.parameterDict(name=None, value=None, default=None, _min=None, _max=None, toolTip=None, items=None, 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 througout the package.
- class esibd.const.Colors
Provides dark mode dependant defaul 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.
- BOTH = 2
Both input and output.
- IN = 0
Input
- 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.
- 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.