Library Reference
The plugin 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.Plugin(*args: Any, **kwargs: Any)
Pluginsabstract basic GUI code for devices, scans, and other high level UI elements.All plugins are ultimately derived from the
Pluginclass. 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)
Bundle pyqtSignals.
- addAction(event: Callable | None = None, toolTip: str = '', *, icon: Icon | str, before: QAction | None = None) Action
Add a simple Action to the toolBar.
- Parameters:
event (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 actionbefore (
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(layout: PyQt6.QtWidgets.QLayout) None
Use this to add a content layout instead of a content widget to the user interface.
- Parameters:
layout (QLayout) – Content layout
- addContentWidget(contentWidget: PyQt6.QtWidgets.QWidget) None
Use this to add your main content widget to the user interface.
- Parameters:
contentWidget (QWidget) – Content widget
- addMultiStateAction(states: list[MultiState], event: Callable | None = None, before: QAction | None = None, attr: str = '', restore: bool = True, defaultState: int = 0) MultiStateAction
Add 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 ‘’
restore (bool, optional) – If True state will be restored when the program is restarted, defaults to True
defaultState (int, optional) – Index of default state, defaults to 0
- Returns:
The new StateAction
- Return type:
- addRightAxis(ax: matplotlib.axes.Axes) None
Add additional y labels on the right.
- Parameters:
ax (matplotlib.axes) – A matplotlib axes.
- addStateAction(event: Callable | None = None, toolTipFalse: str = '', *, iconFalse: Icon, toolTipTrue: str = '', iconTrue: Icon | None = None, before: Action | None = None, attr: str = '', restore: bool = True, defaultState: bool = False) StateAction
Add 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.toolTipTrue (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 ‘’
restore (bool, optional) – If True state will be restored when the program is restarted, defaults to True
defaultState (bool, optional) – Default state as saved by qSettings, defaults to False
- Returns:
The new StateAction
- Return type:
- addToolbarStretch() None
Add a dummy action that can be used to stretch the gap between actions on the left and right of a toolbar.
- afterFinalizeInit() None
Execute after all other plugins are finalized.
- bufferLagging(wait: int | None = None) bool
Wait for excess events to be processed.
Only call from parallel thread, e.g. during testing or scanning!
- Parameters:
wait (int) – Indicates how long the thread should wait to allow lag to recover, defaults to 5
- close() bool
Close plugin cleanly without leaving any data or communication running.
Extend to make sure your custom data and custom communication is closed.
- closeGUI() None
Close 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() None
Perform additional closing actions when user is closing the plugin GUI.
- copyClipboard() None
Copy matplotlib figure to clipboard.
- copyLineDataClipboard(line: Line2D) None
Copy data as text to clipboard.
- Parameters:
line (Line2D) – The line with the data do be copied.
- defaultLabelPlot() None
Add file name labels to plot to trace back which file it is based on.
- dependencyPath: Path = WindowsPath('.')
Path to the plugin dependency files. Typically this is the same or relative to the plugin source code path. Can be used to locate dependencies like external scripts or media which are stored next to the plugin file or in sub folders relative to its location.
- disconnect_all_signals() None
Disconnect all signals.
- displayActive() bool
Indicate if the display is active.
- dock: DockWidget | None
The dockWidget that allows to float and rearrange the plugin user interface.
- documentation: str = ''
The plugin documentation used in the internal about dialog in the Browser. If None, the doc string __doc__ will be used instead. The latter may contain rst commands for sphinx documentation which should not be exposed to the user.
- fig: Figure | None
A figure, initialized e.g. using plt.figure(constrained_layout=True, dpi=getDPI()) and followed by self.makeFigureCanvasWithToolbar(self.fig).
- finalizeInit() None
Execute final initialization code after all other Plugins are initialized.
Use this for code that modifies other
Plugins, e.g. adding anActionto theDeviceManager.
- generatePythonPlotCode() str
Provide plugin specific code to plot data exported by the plugin independently.
This is a starting point to reproduce and adjust figures e.g. for publications or independent data analysis.
- Returns:
Python plot code
- Return type:
str
- getDefaultSettings() dict[str, dict[str, str | Path | int | float | PyQt6.QtGui.QColor | bool | PyQt6.QtWidgets.QTreeWidget | PARAMETERTYPE | PyQt6.QtWidgets.QWidget | Callable | None]]
Define 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. NOTE: While settings with attributes will be automatically accessible, it is good practice to define the type of the attribute for type checking.
- Returns:
Settings dictionary
- Return type:
- getIcon(desaturate: bool = False) Icon
Get 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.
- getQtPen(channel: Channel | MetaChannel | Parameter) PyQt6.QtGui.QPen
Create a pen used for QT plots. Use custom definition for dashed lines that allows to see dashes in the legend.
- Parameters:
channel (Channel) – Channel or associated parameter.
- Returns:
returns a QtPen with the corresponding color, linewidth and linestyle
- Return type:
QPen
- getSupportedFiles() list[str]
Return supported file types.
- getToolBarActionsHTML() str
Return HTML code that lists all toolbar actions including the corresponding icons.
- Returns:
HTML code documenting toolbar actions.
- Return type:
str
- hdfUpdateVersion(file: File) None
Update version in the Info group.
- Parameters:
file (h5py.File) – The file in which to update the version.
- 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.
- imageToClipboard(image: QPixmap | QImage) None
Set an image to the clipboard.
While testing, images are written to files instead of clipboard for later inspection and to not spam the clipboard.
- Parameters:
image (QPixmap | QImage) – The image to be set to the clipboard.
- initDock() None
Initialize the
DockWidget.
- initFig() None
Initialize a figure.
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() None
Initialize the graphic user interface (GUI), independent of all other plugins.
- initializedDock: bool
A flag signaling if the plugin
dockhas 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.
- labelAxis: matplotlib.axes.Axes = None
Axis used for plot labels.
- labelPlot(label: str) None
Add file name labels to plot to trace back which file it is based on.
- Parameters:
ax (matplotlib.axes.Axes) – A matplotlib axes.
label (str) – The plot label.
- line: Line2D
A line to store matplotlib lines for simple displays.
- loadData(file: Path, showPlugin: bool = True) None
Load 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.
showPlugin (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: bool
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.
- makeCoreIcon(file: str, desaturate: bool = False) Icon
Return an icon based on a filename. Looks for files in the
dependencyPath().
- makeFigureCanvasWithToolbar(figure: matplotlib.figure.Figure) None
Create canvas, which can be added to the user interface, and adds the corresponding navToolBar to the plugin titleBar.
- Parameters:
figure (matplotlib.figure.Figure) – A matplotlib figure.
- makeIcon(file: str, path: Path | None = None, desaturate: bool = False) Icon
Return an icon based on a filename. Looks for files in the
dependencyPath()unless otherwise specified.
- 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.
- optional: bool = True
Defines if the user can deactivate the plugin in the
PluginManageruser interface.
- parentPlugin: Plugin
A Plugin that acts as a parent by providing references for and using this plugin
- plot() None
If applicable, overwrite with a plugin specific plot method.
- pluginManager: PluginManager
A reference to the central
PluginManager.
- pluginType: PLUGINTYPE = '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: str, flag: PRINT = PRINT.MESSAGE) None
Send a message to stdout, the statusbar, the Console, and to the logfile.
It will automatically add a timestamp and the name of the sending plugin.
- processEvents() None
Process all open events in the event loop before continuing. Is ignored in testmode where this could lead to a dead lock.
- provideDock() bool
Add existing
dockto UI at position defined byesibd.plugins.Plugin.pluginType.Always call from the main_thread.
- provideFig() None
Create or reinitialize a matplotlib figure.
- raiseDock(showPlugin: bool = True) None
Raise
dockif showPlugin is True.- Parameters:
showPlugin (bool, optional) – Only show one plugin, even though multiple plugins may load a file, defaults to True
- removeAnnotations(ax: matplotlib.axes.Axes) None
Remove all annotations from an axes.
- Parameters:
ax (matplotlib.axes.Axes) – A matplotlib axes.
- requireGroup(group: Group, name: str) Group
Replace require_group from h5py, and adds support for track_order.
- Parameters:
group (h5py.Group) – Valid group.
name (str) – Name of new group.
- Returns:
New group.
- Return type:
h5py.Group
- requiredPlugin(name: str) None
Display error message if required plugin is not available.
- Parameters:
name (str) – Name of required Plugin.
- resizing: bool = False
Indicate if the plugin is resizing. May be used to increase performance by suppressing updates while resizing.
- runTestParallel() None
Run 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.
- scan = None
A
Scan()that provides content to display.
- setFloat() None
Turn the plugin into a popup. It can be combined with others or docked in another place in the main window.
- setLabelMargin(ax: matplotlib.axes.Axes, margin: float) None
Set top margin only, to reserve space for file name label.
- Parameters:
ax (matplotlib.axis.Axes) – The axis to which to add the top margin
margin (float) – The margin to add. 0.15 -> add 15 % margin
- sourceCodePath: Path = WindowsPath('.')
Path to the plugin source code file.
- stopTest() None
Stop testing.
- supportedVersion: str = '1.0'
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: Path) bool
Test 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() None
Runs
runTestParallel()in parallel thread.
- testComplete() None
Resets testing flag after last test completed.
- testControl(control: PushButton | ToolButton | ColorButton | CheckBox | Label | CompactComboBox | LineEdit | LedIndicator | LabviewSpinBox | LabviewDoubleSpinBox | LabviewSciSpinBox | PyQt6.QtGui.QAction | Action | StateAction | MultiStateAction | RestoreFloatComboBox | None, value: Any, delay: float = 0, label: str = '') None
Changes control states and triggers corresponding events.
- Parameters:
- testPythonPlotCode(closePopup: bool = False) None
Generate and run python plot code for given file.
Will save figure to file.
- Parameters:
closePopup (bool, optional) – Determine if popup should be closed automatically, defaults to False
- testTimeout: int = 60
- property testing: bool
Indicates if the plugin, or any other plugin, is currently testing.
- tilt_xlabels(ax: matplotlib.axes.Axes, rotation: int = 30) None
Replace autofmt_xdate which is currently not compatible with constrained_layout.
- Parameters:
ax (matplotlib.axes.Axes) – The axis for which to tilt the labels.
rotation (int, optional) – The tilt angle in degrees, defaults to 30
- titleBar: QToolBar | None
Actions can be added to the titleBar using
addAction()oraddStateAction().
- titleBarLabel: QLabel | None
The label used in the titleBar.
- toggleAdvanced(advanced: bool | None = False) None
Overwrite to show advanced options.
- Parameters:
advanced (bool, optional) – Indicates if advanced options should be visible, defaults to None
- toggleTitleBar() None
Adjust the title bar layout and
titleBarLabeldepending on the state of thedock(tabbed, floating, …).Extend to make sure toggleTitleBar is called for dependent plugins if applicable.
- toggleTitleBarDelayed(delay: int = 500) None
Delay toggleTitleBar until GUI updates have been completed.
- Parameters:
delay (int, optional) – Delay in ms, defaults to 500
- toggleVideoRecorder() None
Toggles visibility of videoRecorderActions.
- updateTheme() None
Change 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.
- useAdvancedOptions: bool = False
Adds toolbox icon to show advanced plugin options.
- version: str = ''
The version of the plugin. Plugins are independent programs that require independent versioning and documentation.
- waitForCondition(condition: Callable, interval: float = 0.5, timeout: int = 5, timeoutMessage: str = '') bool
Wait 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 for condition to return True
interval (float) – wait interval seconds before checking condition
timeout (float) – timeout in seconds
timeoutMessage (str) – message displayed if timeout is reached
- class esibd.plugins.ChannelManager(*args: Any, **kwargs: Any)
Generic plugin with a tree of channels. This can be extended to implement device plugins, plugins with relay channels, and more.
- class ChannelPlot(*args: Any, **kwargs: Any)
Simplified version of the Line plugin for plotting channels.
- finalizeInit() None
Execute final initialization code after all other Plugins are initialized.
Use this for code that modifies other
Plugins, e.g. adding anActionto theDeviceManager.
- getIcon(desaturate: bool = False) Icon
Get 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.
- initFig() None
Initialize a figure.
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() None
Initialize the graphic user interface (GUI), independent of all other plugins.
- parentPlugin: ChannelManager
A Plugin that acts as a parent by providing references for and using this plugin
- pluginType = '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() bool
Add existing
dockto UI at position defined byesibd.plugins.Plugin.pluginType.Always call from the main_thread.
- runTestParallel() None
Run 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 = '1.0'
The version of the plugin. Plugins are independent programs that require independent versioning and documentation.
- property LOADVALUES: str
Load values string for context menus.
- class SignalCommunicate(*args: Any, **kwargs: Any)
Bundle pyqtSignals.
- plotSignal
Signal that triggers plotting of history.
alias of
bool
- addChannel(item: dict[str, Any], index: int | None = None) Channel
Map dictionary to
Channel.- Parameters:
item (dict) – Dictionary containing channel details.
index (int, optional) – Index where channel should be inserted, defaults to None
- Returns:
The newly created channel
- Return type:
- bufferLagging(wait: int | None = None) bool
Wait for excess events to be processed.
Only call from parallel thread, e.g. during testing or scanning!
- Parameters:
wait (int) – Indicates how long the thread should wait to allow lag to recover, defaults to 5
- channelConfigChanged(file: Path | None = None, useDefaultFile: bool = True) bool
Scan for changes when saving configuration.
- channelPlotActive() bool
Indicate if the channel plot is active.
- channelSelection(selectedChannel: Channel) None
Ensure that only one channel is selected at all times.
- Parameters:
selectedChannel (esibd.core.Channel) – The Channel that has been selected by the user.
- channelType
Type of
Channelused by the device. Overwrite by appropriate type in derived classes.alias of
Channel
- clearPlot() None
Clear the plot in the liveDisplay.
- close() bool
Close plugin cleanly without leaving any data or communication running.
Extend to make sure your custom data and custom communication is closed.
- closeCommunication() None
Stop recording and also closes all device communication.
Extend to add custom code to close device communication.
- closeGUI() None
Close 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.
- compareItemsConfig(items: list[dict[str, str | Path | int | float | PyQt6.QtGui.QColor | bool]], ignoreIndicators: bool = False) tuple[list[str], bool]
Compare channel items from file with current configuration.
This allows to track changes and decide if files need to be updated.
- Parameters:
items (list[dict[str, ParameterType]]) –
Channelitems from fileignoreIndicators (bool) – Set to True if deciding about file updates (indicators are not saved in files).
- convertDataDisplay(data: ndarray[Any, dtype[float32]]) ndarray[Any, dtype[float32]]
Overwrite to apply scaling and offsets to data before it is displayed. Use, e.g., to convert to another unit.
This should only affect display in
LiveDisplays.- Parameters:
data (np.ndarray) – Original data.
- Returns:
Scaled data.
- Return type:
np.ndarray
- copyClipboard() None
Copy matplotlib figure to clipboard.
- customConfigFile(file: str) Path
Return custom config file including full path.
- Parameters:
file (str) – File name.
- Returns:
File including full path.
- Return type:
pathlib.Path
- defaultChannel: Channel
The default channel is an instance of channelType that is only used for reference when loading and saving the channel configuration.
- deleteChannel() None
Delete the currently selected channel.
- exportConfiguration(file: Path | None = None, useDefaultFile: bool = False) None
Save an .ini or .h5 file which contains the configuration for this
Device.Channels can be added and edited through the user interface, but the .ini file can also be edited manually with a text editor.
- finalizeInit() None
Execute final initialization code after all other Plugins are initialized.
Use this for code that modifies other
Plugins, e.g. adding anActionto theDeviceManager.
- getActiveChannelsAndParameters() list[Channel | Parameter]
Return all channels that are enabled or not real.
- getChannelByName(name: str) Channel | None
Return a device specific channel based on its unique name.
- Parameters:
name (str) – Name of the channel to be found.
- Returns:
Found channel, defaults to None if no channel found.
- Return type:
- getDefaultSettings() dict[str, dict]
Define 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. NOTE: While settings with attributes will be automatically accessible, it is good practice to define the type of the attribute for type checking.
- Returns:
Settings dictionary
- Return type:
- initGUI() None
Initialize the graphic user interface (GUI), independent of all other plugins.
- initializeCommunication() None
Extend to initialize communication.
Can be used to initialize GUI. Redirect initialization of hardware communication to the corresponding
DeviceController.
- isOn() bool
Overwrite to signal if device output (e.g. for voltage supplies) is on.
- liveDisplay: LiveDisplay
Internal plugin to display data in real time.
- liveDisplayActive() bool
Indicate if the liveDisplay is active.
- loadConfiguration(file: Path | None = None, useDefaultFile: bool = False, append: bool = False) None
Load
channelconfiguration from file.If only values should be loaded without complete reinitialization, use
loadValuesinstead.- Parameters:
file (pathlib.Path, optional) – File from which to load configuration, defaults to None
useDefaultFile (bool, optional) – Use internal configuration file if True, defaults to False
append (bool, optional) – True if changelog should be appended to previous change logs, e.g. when loading from multiple devices at once. Defaults to False
- loadValues(file: Path | None = None, append: bool = False) None
Load values only, instead of entire configuration, for
channelsmatching 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.
- minTime() float64
Get the oldest time in the stored history.
- modifyChannel() Channel | None
Return selected channel. Note, channels can only be selected in advanced mode.
- Returns:
The selected channel. None if no channel found.
- Return type:
- moveChannel(up: bool) Channel | None
Move the channel up or down in the list of channels.
- Parameters:
up (bool) – Move up if True, else down.
- name = '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.
- plot(apply: bool = False) None
Plot for all active LiveDisplays.
- Parameters:
apply (bool) – Apply most recent data, otherwise update rate depends on data thinning.
- pluginType = '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().
- property recording: bool
Indicates the recording state.
- runDataThread(recording: Callable) None
Trigger regular plotting of data.
Extend or Overwrite to add logic for appending data to channels.
- Parameters:
recording (Callable) – Queries recording state.
- runTestParallel() None
Run 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.
- saveConfiguration() None
Save configuration to file in current session.
- setOn(on: bool | None = None) None
Toggles device on state.
- Parameters:
on (bool, optional) – Requested state, defaults to None. Extended versions of this function may perform tasks based on self.isOn() even if on=None.
- showChannelPlot() None
Show a plot based on the current values of all real channels.
- startRecording() None
Start the data recording thread.
- staticDisplay: StaticDisplay
Internal plugin to display data from file.
- staticDisplayActive() bool
Indicate if the staticDisplay is active.
- supportsFile(file: Path) bool
Test 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
- toggleAdvanced(advanced: bool | None = False) None
Overwrite to show advanced options.
- Parameters:
advanced (bool, optional) – Indicates if advanced options should be visible, defaults to None
- toggleChannelPlot(visible: bool) None
Toggles visibility of the channelPlot.
- Parameters:
visible (bool) – Requested visibility for channelPlot.
- toggleLiveDisplay(visible: bool | None = None) None
Toggle visibility of the liveDisplay.
- Parameters:
visible (bool) – Requested visibility for liveDisplay.
- toggleRecording(on: bool | None = None, manual: bool = True) None
Turn recording on or off or toggles state.
Data will be plotted in
LiveDisplayif that is active. Extend to add recoding logic for devices.- Parameters:
- toggleStaticDisplay(visible: bool) None
Toggles visibility of the staticDisplay.
- Parameters:
visible (bool) – Requested visibility for staticDisplay.
- toggleTitleBar() None
Adjust the title bar layout and
titleBarLabeldepending on the state of thedock(tabbed, floating, …).Extend to make sure toggleTitleBar is called for dependent plugins if applicable.
- updateChannelConfig(items: list[dict[str, str | Path | int | float | PyQt6.QtGui.QColor | bool]], file: Path, append: bool = False) None
Scan for changes when loading configuration and displays change log before overwriting old channel configuration.
- updateChannelValue(name: str, value: float) None
Update channel value und adds message to change log if the value has changed.
- Parameters:
name (str) – Channel name.
value (float) – The new value.
- updateTheme() None
Change 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.
- useAdvancedOptions = True
Adds toolbox icon to show advanced plugin options.
- 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 = '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)
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)
Bundle pyqtSignals.
- appendDataSignal
Signal that triggers appending of data from channels to history.
alias of
bool
- appendData(nan: bool = False, skipPlotting: bool = False) None
Append data from device acquisition to channels and updates plots.
- appendOutputData(h5file: File, useAllHistory: bool = False) None
Append
Devicedata to hdf file.- Parameters:
h5file (h5py.File) – The file to which append the data.
useAllHistory (bool, optional) – Export entire history and not just visible part, defaults to False
- applyValues(apply: bool = False) None
Apply
Channelvalues 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
- bufferLagging(wait: int | None = None) bool
Wait for excess events to be processed.
Only call from parallel thread, e.g. during testing or scanning!
- Parameters:
wait (int) – Indicates how long the thread should wait to allow lag to recover, defaults to 5
- clearHistory() None
Clear all data history for this device. Should only be needed if history gets out of sync and needs clean initialization.
- close() bool
Close plugin cleanly without leaving any data or communication running.
Extend to make sure your custom data and custom communication is closed.
- closeCommunication() None
Stop all communication of this Device.
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.
- deleteChannel() None
Delete the currently selected channel.
- duplicateChannel() None
Duplicates the currently selected channel.
- errorCountChanged() None
Start a timer to reset error count if no further errors occur.
- estimateStorage() None
Estimates storage space required to save maximal history depending on sample rate, number of channels, and backgrounds.
- exportOutputData(useDefaultFile: bool = False, useAllHistory: bool = False) None
Export output data.
- finalizeInit() None
Execute final initialization code after all other Plugins are initialized.
Use this for code that modifies other
Plugins, e.g. adding anActionto theDeviceManager.
- getDefaultSettings() dict[str, dict]
Define 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. NOTE: While settings with attributes will be automatically accessible, it is good practice to define the type of the attribute for type checking.
- Returns:
Settings dictionary
- Return type:
- getDisplayUnit() str
Overwrite if you want to change units dynamically.
- getSupportedFiles() list[str]
Return supported file types.
- initGUI() None
Initialize the graphic user interface (GUI), independent of all other plugins.
- initializeCommunication() None
Initialize communication of device or channel controllers.
- property initialized: bool
Extend or overwrite to indicate when the device is initialized.
Default implementation works when using
DeviceController.
- loadConfiguration(file: Path | None = None, useDefaultFile: bool = False, append: bool = False) None
Load
channelconfiguration from file.If only values should be loaded without complete reinitialization, use
loadValuesinstead.- Parameters:
file (pathlib.Path, optional) – File from which to load configuration, defaults to None
useDefaultFile (bool, optional) – Use internal configuration file if True, defaults to False
append (bool, optional) – True if changelog should be appended to previous change logs, e.g. when loading from multiple devices at once. Defaults to False
- loadData(file: Path, showPlugin: bool = True) None
Load 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.
showPlugin (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.
- measureInterval(reset: bool = True) None
Measures interval since last successful plotting.
- Parameters:
reset (bool, optional) – Only reset if plotting was successful or not required, defaults to True
- moveChannel(up: bool) None
Move the channel up or down in the list of channels.
- Parameters:
up (bool) – Move up if True, else down.
- name = 'Device'
A unique name that will be used in the graphic user interface. Plugins can be accessed directly from the Console using their name.
- property plotableChannels: bool
Extend or overwrite to indicate when the device has plotable channels.
Default implementation works when using
DeviceController.
- pluginType = 'Input Device'
Devicesare categorized as input or output devices. Overwrite withOUTPUTDEVICEafter inheriting if applicable.
- restoreOutputData() None
Restore data from internal restore file.
- runDataThread(recording: Callable) None
Regularly triggers appending and plotting of data.
This uses the current value of
channelswhich is updated independently by the correspondingDeviceController.- Parameters:
recording (Callable) – Queries recording state.
- runTestParallel() None
Run 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.
- setBackground() None
Set the background based on current channel values.
Only used by output devices.
- setOn(on: bool | None = None) None
Toggles device on state.
- Parameters:
on (bool, optional) – Requested state, defaults to None. Extended versions of this function may perform tasks based on self.isOn() even if on=None.
- startAcquisition() None
Start device Acquisition.
Default implementation works when using
DeviceController.
- stopAcquisition() None
Stop device acquisition.
Communication stays initialized! Default implementation works when using
DeviceController.
- subtractBackgroundActive() bool
Indicate if backgrounds should be subtracted.
- subtractBackgroundChanged() None
Update plot if background subtraction is toggled.
- toggleRecording(on: bool | None = None, manual: bool = False) None
Turn recording on or off or toggles state.
Data will be plotted in
LiveDisplayif that is active. Extend to add recoding logic for devices.- Parameters:
- unit: str = 'unit'
Unit used in user interface.
- updateErrorCountToolTip() None
Update the tooltip of the error count setting.
- updateTheme() None
Change 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.
- updateValues(N: int = 2, apply: bool = False) None
Update 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 most scenarios. More complex algorithms should only be implemented if they are required to solve a practical problem.
- useBackgrounds = False
If True, the device implements controls to define and subtract background signals.
- version = 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)
Bundle functionality of devices and thus allows to initialize, start, and stop data acquisition from all devices with a single click.
In the Advanced mode it allows to import all channels of all devices from a single file. Ideally, plugins that control potentially dangerous hardware like power supplies, cryo coolers, or vacuum valves should add a status icon to the device 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)
Bundle pyqtSignals.
- closeCommunicationSignal
Signal that triggers stop communication.
- exportOutputDataSignal
Signal that triggers export of configuration.
alias of
Path
- loadConfigurationSignal
Signal that triggers loading of configuration.
alias of
Path
- restoreOutputDataSignal
Signal that triggers restoring of device data.
- storeOutputDataSignal
Signal that triggers storage of device data.
- wakeSignal
Signal that triggers keyboard action to prevent screen lock.
- afterFinalizeInit() None
Execute after all other plugins are finalized.
- channels(inout: INOUT = INOUT.BOTH) list[Channel]
Get a flat list of all channels based on device type.
- clearPlot() None
Clear plots for all plugins.
- close() bool
Close plugin cleanly without leaving any data or communication running.
Extend to make sure your custom data and custom communication is closed.
- closeCommunication(manual: bool = False, closing: bool = False, message: str = 'Stopping communication.') None
Close all communication.
- Parameters:
manual (bool, optional) – Indicates if triggered by user and needs confirmation dialog before proceeding. Defaults to False
closing (bool, optional) – Indicate that the application is closing, defaults to False
message (str, optional) – Message indicating that the communication is stopped. Optionally add reason. Defaults to ‘Stopping communication.’
- documentation = '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. In the Advanced mode it allows to\n import all channels of all devices from a single file. Ideally, plugins\n that control potentially dangerous hardware like power supplies, cryo\n coolers, or vacuum valves should add a status icon to the device\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.\n '
The plugin documentation used in the internal about dialog in the Browser. If None, the doc string __doc__ will be used instead. The latter may contain rst commands for sphinx documentation which should not be exposed to the user.
- exportConfiguration(file: Path | None = None, useDefaultFile: bool = False) None
Export configuration for multiple Devices and ChannelManagers.
- exportOutputData(file: Path | None = None, useAllHistory: bool = False) None
Export output data for all active LiveDisplays.
- exportOutputDataKwargs(file: Path | None = None, useAllHistory: bool = False) None
Export output data for all active LiveDisplays.
This version is compatible with pyqtSignal (no keyword argument) and @synchronized() (works only with keyword arguments). :param file: The file to which the data should be added, defaults to None :type file: Path | None, optional :param useAllHistory: Export entire history and not just visible part, defaults to False :type useAllHistory: bool, optional
- finalizeInit() None
Execute final initialization code after all other Plugins are initialized.
Use this for code that modifies other
Plugins, e.g. adding anActionto theDeviceManager.
- getActiveLiveDisplays() list[LiveDisplay]
Get all active liveDisplays.
- getActiveStaticDisplays() list[StaticDisplay]
Get all active staticDisplays.
- getChannelByName(name: str, inout: INOUT = INOUT.BOTH) Channel | None
Get channel based on unique name and type.
- getDefaultSettings() dict[str, dict[str, str | Path | int | float | PyQt6.QtGui.QColor | bool | PyQt6.QtWidgets.QTreeWidget | PARAMETERTYPE | PyQt6.QtWidgets.QWidget | Callable | None]]
Define 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. NOTE: While settings with attributes will be automatically accessible, it is good practice to define the type of the attribute for type checking.
- Returns:
Settings dictionary
- Return type:
- getDevices(inout: INOUT = INOUT.BOTH) list[ChannelManager] | list[Device]
Get devices depending on device type.
- getRelays() list[ChannelManager]
Get all channel managers. These usually do not have real channels but channels that link to device channels in other plugins.
- globalUpdate(apply: bool = False, inout: INOUT = INOUT.BOTH) None
Update channel values based on equations for all devices of provided type.
- iconFile = 'DeviceManager.png'
Default icon file. Expected to be in dependencyPath.
- initDock() None
Initialize the
DockWidget.
- initGUI() None
Initialize the graphic user interface (GUI), independent of all other plugins.
- initializeCommunication() None
Initialize communication for all Devices and ChannelManagers.
- initialized() bool
Indicate if communication to at least one device is initialized.
- livePlot(apply: bool = False) None
Update plots for all active liveDisplays.
- Parameters:
apply (bool, optional) – Indicates if plot curves should be recreated or just updated. Defaults to False
- loadConfiguration(file: Path | None = None) None
Load configuration of all devices from a single file.
- Parameters:
file (Path | None, optional) – File to load from. Should only be passed as argument for automated testing, defaults to None
- loadData(file: Path, showPlugin: bool = True) None
Load 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.
showPlugin (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.
- name = 'DeviceManager'
A unique name that will be used in the graphic user interface. Plugins can be accessed directly from the Console using their name.
- plot() None
Clear plots for all plugins.
- pluginType = '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().
- property recording: bool
Indicates if at least one device is recording.
- restoreConfiguration() None
Load configuration and settings for all devices and scans.
- restoreOutputData() None
Restore all outputData for all Devices.
- runTestParallel() None
Run 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.
- stopRecording() None
Stop recording for all devices. Communication stays active.
- stopScans(closing: bool = False) None
Stop all scans and waits for them to finish.
- Parameters:
closing (bool, optional) – Indicate that the application is closing and needs to wait for scans to finish. Defaults to False
- storeOutputData() None
Regularly stores device settings and data to minimize loss in the event of a program crash.
- toggleAdvanced(advanced: bool | None = False) None
Overwrite to show advanced options.
- Parameters:
advanced (bool, optional) – Indicates if advanced options should be visible, defaults to None
- toggleRecording() None
Toggle recording of data.
- updateStaticPlot() None
Update all staticPlots.
- useAdvancedOptions = True
Adds toolbox icon to show advanced plugin options.
- version = '1.0'
The version of the plugin. Plugins are independent programs that require independent versioning and documentation.
- wake() None
Trigger keyboard action to prevent screen lock.
- class esibd.plugins.Settings(*args: Any, **kwargs: Any)
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 PluginManager and Console can be opened from here.
- buildSessionPath() Path
Build the session path based on timestamp. Extend to add additional elements to session path.
- componentInputValidation(component: str) str
Validate a path component.
- Parameters:
component (str) – Path component.
- Returns:
Validated path component.
- Return type:
str
- finalizeInit() None
Execute final initialization code after all other Plugins are initialized.
Use this for code that modifies other
Plugins, e.g. adding anActionto theDeviceManager.
- getDefaultSettings() dict[str, dict]
Provide settings and corresponding default values.
- Returns:
Dictionary of settings
- Return type:
dict[str, dict]
- getFullSessionPath() Path
Return full session path inside data path.
- getMeasurementFileName(extension: str) Path
Get measurement file name based on session path, measurement number, and plugin specific file extension.
- Parameters:
extension (str) – Plugin specific file extension.
- Returns:
Full measurement file path with measurement number and extension.
- Return type:
pathlib.Path
- iconFile = 'gear.png'
Default icon file. Expected to be in dependencyPath.
- incrementMeasurementNumber() None
Increment without triggering event.
- init() None
Init all internal settings and those of all other plugins.
- initDock() None
Initialize the
DockWidget.
- initGUI() None
Initialize the graphic user interface (GUI), independent of all other plugins.
- loadData(file: Path, showPlugin: bool = False) None
Load 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.
showPlugin (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.
- loadSettings(file: Path | None = None, useDefaultFile: bool = False) None
Load settings from hdf or ini file.
- name = 'Settings'
A unique name that will be used in the graphic user interface. Plugins can be accessed directly from the Console using their name.
- pathInputValidation(path: Path) Path
Validate path.
- Parameters:
path (pathlib.Path) – The path to validate.
- Returns:
Validated path.
- Return type:
pathlib.Path
- pluginType = '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().
- resetTimeChanged() None
Update all tooltips that mention the error reset time.
- runTestParallel() None
Run 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.
- testModeChanged() None
Close communication so it can be reinitialized with new test mode state.
- toggleAdvanced(advanced: bool | None = False) None
Overwrite to show advanced options.
- Parameters:
advanced (bool, optional) – Indicates if advanced options should be visible, defaults to None
- updateConfigPath() None
Reload settings and plugin configuration after changing configuration path.
- updateDPI() None
Update DPI in all active matplotlib figures.
- updateDataPath() None
Update session path and Explorer root directory after changing data path.
- updatePluginPath() None
Restart after changing user plugin path.
- updateSessionPath(mesNum: int = 0) None
Update the session path based on settings. Overwrite if you want to use different fields instead.
- Parameters:
mesNum (int, optional) – measurement number, defaults to 0
- useAdvancedOptions = True
Adds toolbox icon to show advanced plugin options.
- version = '1.0'
The version of the plugin. Plugins are independent programs that require independent versioning and documentation.
- class esibd.plugins.UCM(*args: Any, **kwargs: Any)
Allow 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.
- connectSource(giveFeedback: bool = False) None
Connect the sourceChannel.
- Parameters:
giveFeedback (bool, optional) – Report on success of connection, defaults to False
- getDefaultChannel() dict[str, dict]
Define Parameter(s) of the default Channel.
This is also use to assign parameterTypes, if Parameters are visible outside of advanced mode, and many other parameter properties. See
parameterDict(). If parameters do not exist in the settings file, the default Parameter will be added. Overwrite in dependent classes as needed.NOTE: While parameters with attributes will be automatically accessible, it is good practice to define the type of the attribute for type checking.
- getDisplayUnit() str
Return the unit of the corresponding device. May represent display unit if defined.
- getSourceChannelValues() None
Get value and if applicable monitor from sourceChannel.
- initGUI(item: dict) None
Initialize Channel GUI.
Call after corresponding QTreeWidgetItem has been added to tree. Item needs parent for all graphics operations.
- Parameters:
item (dict) – Dictionary containing all channel information.
- monitorChanged() None
Disable internal monitor event.
- onDelete() None
Extend to handle events on deleting. E.g. handle references that should remain available.
- relayMonitorEvent() None
Update monitor and monitor stylesheet when sourceChannel.monitor changed.
- relayValueEvent() None
Update value when sourceChannel.value changed.
- removeEvents() None
Remove extra events from sourceChannel.
- setDisplayedParameters() None
Determine which parameters to use and in what order.
Extend using
insertDisplayedParameter()to add more parameters.
- setSourceChannelValue() None
Update sourceChannel.value.
- tempParameters() list[str]
List of parameters, such as live signal or status, that will not be saved and restored.
- afterFinalizeInit() None
Execute after all other plugins are finalized.
- channelType
alias of
UCMChannel
- channels: list[UCMChannel]
List of
channels.
- connectAllSources(update: bool = False) None
Connect all available source channels.
- Parameters:
update (bool, optional) – Indicates that all channels should be (re-)connected. Otherwise will only attempt to connect channels that are not yet connected. Defaults to False
- documentation = '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.\n '
The plugin documentation used in the internal about dialog in the Browser. If None, the doc string __doc__ will be used instead. The latter may contain rst commands for sphinx documentation which should not be exposed to the user.
- duplicateChannel() None
Duplicates the currently selected channel.
- iconFile = 'UCM.png'
Default icon file. Expected to be in dependencyPath.
- initGUI() None
Initialize the graphic user interface (GUI), independent of all other plugins.
- loadConfiguration(file: Path | None = None, useDefaultFile: bool = False, append: bool = False) None
Load
channelconfiguration from file.If only values should be loaded without complete reinitialization, use
loadValuesinstead.- Parameters:
file (pathlib.Path, optional) – File from which to load configuration, defaults to None
useDefaultFile (bool, optional) – Use internal configuration file if True, defaults to False
append (bool, optional) – True if changelog should be appended to previous change logs, e.g. when loading from multiple devices at once. Defaults to False
- loadData(file: Path, showPlugin: bool = True) None
Load 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.
showPlugin (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: bool) None
Move the channel up or down in the list of channels.
- Parameters:
up (bool) – Move up if True, else down.
- name = 'UCM'
A unique name that will be used in the graphic user interface. Plugins can be accessed directly from the Console using their name.
- pluginType = '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().
- reconnectSource(name: str) None
Try to reconnect linked channels if applicable.
This is needed e.g. after renaming, moving, or deleting channels. If the channel has been deleted, the reconnection attempt will fail and and the linking channel will indicated that no source has been found.
- Parameters:
name (str) – Name of the channel to reconnect.
- toggleRecording(on: bool | None = None, manual: bool = False) None
Turn recording on or off or toggles state.
Data will be plotted in
LiveDisplayif that is active. Extend to add recoding logic for devices.- Parameters:
- useMonitors = True
Use record monitors and compare them to set points.
- version = '1.0'
The version of the plugin. Plugins are independent programs that require independent versioning and documentation.
- class esibd.plugins.PID(*args: Any, **kwargs: Any)
Allow 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.
- connectSource(giveFeedback: bool = False) None
Connect the source and inputChannels.
- Parameters:
giveFeedback (bool, optional) – Report on success of connection, defaults to False
- findChannel(name: str, DEVICE: str) tuple[Channel | None, str]
Find the source or inputChannel based on its name and sets its device icon.
- Parameters:
name (str) – Channel name.
DEVICE (str) – Input or Outputdevice icon parameter
- Returns:
channel, notes
- Return type:
Channel, str
- getDefaultChannel() dict[str, dict]
Define Parameter(s) of the default Channel.
This is also use to assign parameterTypes, if Parameters are visible outside of advanced mode, and many other parameter properties. See
parameterDict(). If parameters do not exist in the settings file, the default Parameter will be added. Overwrite in dependent classes as needed.NOTE: While parameters with attributes will be automatically accessible, it is good practice to define the type of the attribute for type checking.
- initGUI(item: dict) None
Initialize Channel GUI.
Call after corresponding QTreeWidgetItem has been added to tree. Item needs parent for all graphics operations.
- Parameters:
item (dict) – Dictionary containing all channel information.
- monitorChanged() None
Disable internal monitor event.
- onDelete() None
Extend to handle events on deleting. E.g. handle references that should remain available.
- removeEvents() None
Remove extra events from sourceChannel.
- setDisplayedParameters() None
Determine which parameters to use and in what order.
Extend using
insertDisplayedParameter()to add more parameters.
- stepPID() None
Set inputChannel.value based on sourceChannel.value and PID state.
- tempParameters() list[str]
List of parameters, such as live signal or status, that will not be saved and restored.
- updatePID() None
Update P, I, and D in the pid controller based on the channel values.
- updateSampleTime() None
Update the sample time in the pid controller based on the channel value.
- updateSetpoint() None
Update the setpoint in the pid controller based on the channel value.
- valueChanged() None
Update PID when setpoint changed.
- afterFinalizeInit() None
Execute after all other plugins are finalized.
- channelType
alias of
PIDChannel
- channels: list[PIDChannel]
List of
channels.
- connectAllSources(update: bool = False) None
Connect all available source channels.
- Parameters:
update (bool, optional) – Indicates that all channels should be (re-)connected. Otherwise will only attempt to connect channels that are not yet connected. Defaults to False
- duplicateChannel() None
Duplicates the currently selected channel.
- iconFile = 'PID.png'
Default icon file. Expected to be in dependencyPath.
- loadConfiguration(file: Path | None = None, useDefaultFile: bool = False, append: bool = False) None
Load
channelconfiguration from file.If only values should be loaded without complete reinitialization, use
loadValuesinstead.- Parameters:
file (pathlib.Path, optional) – File from which to load configuration, defaults to None
useDefaultFile (bool, optional) – Use internal configuration file if True, defaults to False
append (bool, optional) – True if changelog should be appended to previous change logs, e.g. when loading from multiple devices at once. Defaults to False
- loadData(file: Path, showPlugin: bool = True) None
Load 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.
showPlugin (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: bool) None
Move the channel up or down in the list of channels.
- Parameters:
up (bool) – Move up if True, else down.
- name = 'PID'
A unique name that will be used in the graphic user interface. Plugins can be accessed directly from the Console using their name.
- pluginType = '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().
- reconnectSource(name: str) None
Try to reconnect linked channels if applicable.
This is needed e.g. after renaming, moving, or deleting channels. If the channel has been deleted, the reconnection attempt will fail and and the linking channel will indicated that no source has been found.
- Parameters:
name (str) – Name of the channel to reconnect.
- updateTheme() None
Change 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.
- useDisplays = False
use liveDisplay, StaticDisplay, ChannelPlot, and all related functionality.
- useMonitors = True
Use record monitors and compare them to set points.
- useOnOffLogic = True
Creates an Action in the DeviceManager that handles turning key functions on and off.
- version = '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 devices, scans, examples, displays, or a user plugin folder.
The core module
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)
An Action that allows to change values from another thread and retains a reference to icon an toolTip.
- class SignalCommunicate(*args: Any, **kwargs: Any)
Bundle pyqtSignals.
- setValueFromThreadSignal
alias of
bool
- getToolTip() str
Get the tooltip. API consistent with other Action classes.
- setValue(value: bool) None
Set action state. API consistent with other Action classes.
- Parameters:
value (bool) – New state.
- property state: bool
Return the state. API consistent with other Action classes.
- class esibd.core.Application(*args: Any, **kwargs: Any)
Application that has a mouseInterceptor.
- class esibd.core.Channel(*args: Any, **kwargs: Any)
Represent a virtual or real Parameter and manage 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 (import after edit or changes will be lost).
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.- class SignalCommunicate(*args: Any, **kwargs: Any)
Bundle pyqtSignals.
- updateValueSignal
alias of
float
- waitUntilStableSignal
alias of
int
- property acquiring: bool
Indicates if the channel is acquiring data.
- activeChanged() None
Update channel after active state has changed.
- appendValue(lenT: int, nan: bool = False) None
Append 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.
- applyValue(apply: bool = False) None
Apply value to device if value has changed or explicitly requested.
- Parameters:
apply (bool) – If True, value will be applied even if it has not changed. Defaults to None
- asDict(includeTempParameters: bool = False, formatValue: bool = False, escapePercent: bool = False) dict[str, str | Path | int | float | PyQt6.QtGui.QColor | bool]
Return a dictionary containing all Channel Parameters and their values.
- Parameters:
- Returns:
The channel as dictionary.
- Return type:
dict[str, ParameterType]
- channelParent: ChannelManager | Device | Scan
The Device or Scan containing this channel.
- clearHistory() None
Clear all history data including backgrounds if applicable.
- clearHistoryInternal() None
Clear all history data including backgrounds if applicable.
- clearPlotCurve() None
Clear the plot curve. It will be recreated (with updated values and settings) next time plot is called.
- collapseChanged(toggle: bool = True) None
Update visible channels after collapse has changed.
- Parameters:
toggle (bool, optional) – Toggles display of visible channels, defaults to True
- 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() None
Extend as needed. Already linked to enabled checkbox.
- equationChanged() None
Update channel after equation has changed.
- getDefaultChannel() dict[str, dict]
Define Parameter(s) of the default Channel.
This is also use to assign parameterTypes, if Parameters are visible outside of advanced mode, and many other parameter properties. See
parameterDict(). If parameters do not exist in the settings file, the default Parameter will be added. Overwrite in dependent classes as needed.NOTE: While parameters with attributes will be automatically accessible, it is good practice to define the type of the attribute for type checking.
- getDevice() ChannelManager | Device | Scan
Get the device. Overwrite for more specific cases like relay channels where the channel parent is not the device.
- getDisplayUnit() str
Return the unit of the corresponding device. May represent display unit if defined.
- getIcon(desaturate: bool = False) Icon
Get the channel Icon. This is typically identical with the corresponding device Icon, but some devices may have channel specific Icons.
- getParameterByName(name: str) Parameter
Get a Channel Parameter by name.
- Parameters:
name (str) – The name of the Parameter.
- Returns:
The requested Parameter.
- Return type:
- getQtLineStyle() PyQt6.QtCore.Qt.PenStyle
Get Qt.PenStyle matching matplotlib linestyle.
- getSortedDefaultChannel() dict[str, dict]
Return default Channel parameters sorted in the order defined by
displayedParameters.
- getValues(*, length: int | None = None, index_min: int | None = None, index_max: int | None = None, n: int = 1, subtractBackground: bool = False) ndarray[tuple[Any, ...], dtype[float64 | float32]]
Return plain Numpy array of values.
Note that background subtraction only affects what is displayed, the raw signal and background curves are always retained.
- Parameters:
length (int) – will return last ‘length’ values.
index_min (int) – Index of lower limit.
index_max (int) – Index of upper limit.
n (int, optional) – Will only return every nth value, defaults to 1
subtractBackground (bool, optional) – Indicates if the background should be subtracted, defaults to False
- Returns:
The array of values.
- Return type:
np.ndarray[Any, np.dtype[np.float32]]
- initGUI(item: dict) None
Initialize Channel GUI.
Call after corresponding QTreeWidgetItem has been added to tree. Item needs parent for all graphics operations.
- Parameters:
item (dict) – Dictionary containing all channel information.
- initSettingsContextMenuBase(parameter: Parameter | Setting, pos: PyQt6.QtCore.QPoint) None
General implementation of a context menu.
The relevant actions will be chosen based on the type and properties of the
Parameter.- Parameters:
parameter (esibd.core.Parameter) – The parameter for which the context menu is requested.
pos (QPoint) – The position of the context menu.
- property initialized: bool
Indicate if the channel is initialized and ready for plotting.
- insertDisplayedParameter(parameter: str, before: str) None
Insert your custom Parameter before an existing Parameter in
displayedParameters.
- invalid_chars: list[str]
Invalid characters will be removed from list of valid characters of the channel name.
- lastAppliedValue: ParameterType | None
Reference to last value. Allows to decide if hardware update is required.
- property legendName: str
Name used in legends. Matches signature of Parameters.
- property loading: bool
Indicates if the corresponding device is currently loading.
- logY: bool = False
Indicates if logarithmic controls and scales should be used.
- monitorChanged() None
Highlights monitors if they deviate to far from set point. Extend for custom monitor logic if applicable.
- nameChanged() None
Update display and linked channels if channel name changed.
- onDelete() None
Extend to handle events on deleting. E.g. handle references that should remain available.
- plotCurve: PlotCurveItem | PlotDataItem | None
The plotCurve in the corresponding
LiveDisplay.
- realChanged() None
Extend as needed. Already linked to real checkbox.
- resetUnstable() None
Indicate signal is stable.
- scalingChanged() None
Adjust height of all Channel Parameters according to new scaling value.
- setDisplayedParameters() None
Determine which parameters to use and in what order.
Extend using
insertDisplayedParameter()to add more parameters.
- sizeHint(column) PyQt6.QtCore.QSize
Provide a custom size hint based on the item’s content.
- tempParameters() list[str]
List of parameters, such as live signal or status, that will not be saved and restored.
- toggleBackgroundVisible() bool
Show the background widget if applicable and hides it otherwise.
- Returns:
True if background is visible.
- Return type:
bool
- tree: QTreeWidget | None
TreeWidget containing the channel widgets.
- property unit: str
The unit of the corresponding device.
- updateColor() PyQt6.QtGui.QColor
Apply new color to all controls.
- updateDisplay() None
Update live and static displays.
- updateMax() None
Apply new maximum to value widget.
- updateMin() None
Apply new minimum to value widget.
- updateValueParallel(value: float) None
Update the value (thread safe).
- Parameters:
value (float) – new value
- updateWarningState(warn: bool = False) None
Update warningState of monitor and applies corresponding style sheet.
- Parameters:
warn (bool, optional) – Indicates if the warningStyleSheet should be used, defaults to False
- valueChanged() None
Update after value has changed.
- values: DynamicNp
The history of values shown in the
LiveDisplay. UsegetValues()to get a plain numpy.array.
- waitToStabilize = False
Indicates if the device is stabilized. Will return NaN if unstable.
- waitUntilStable(wait: int) None
Wait for signal to stabilize.
Will return NaN until stable. Make sure to call from the main_thread.
- Parameters:
wait (int) – Wait time in ms.
- class esibd.core.CheckBox(*args: Any, **kwargs: Any)
Allows to set values in a widget in a consistent way.
- class SignalCommunicate(*args: Any, **kwargs: Any)
Bundle pyqtSignals.
- setValueFromThreadSignal
alias of
bool
- setValue(value: bool) None
Set value using consistent API for Parameter widgets.
- Parameters:
value (bool) – The new checked state.
- class esibd.core.CloseDialog(*args: Any, **kwargs: Any)
Dialog to confirm closing the program.
- class esibd.core.ColorButton(*args: Any, **kwargs: Any)
ColorButton as ParameterWidget.
- class esibd.core.CompactComboBox(*args: Any, **kwargs: Any)
Combobox that stays small while showing full content in dropdown menus.
- setPopupMinimumWidthForItems() None
Calculate and sets the minimum combobox width.
- showPopup() None
Show popup after setting minimum width.
- wheelEvent(e: QWheelEvent | None) None
Ignore wheel event.
- class esibd.core.ContextAction(text: str, event: Callable, action: QAction | None = None)
An action that can be added to a context menu.
- class esibd.core.ControlCursor(*args: Any, **kwargs: Any)
Extending internal implementation to get draggable cursor.
- getPosition()
Get current position.
- ondrag(event) None
Continuously updates cursor position.
- setPosition(x, y) None
Emulated mouse event to set position.
- updatePosition() None
Update position. Usually required to reset position after cursors have been lost by drawing other elements.
- class esibd.core.CursorAxes(*args: Any, **kwargs: Any)
An axes with comes with a controllable cursor.
- class esibd.core.DebouncedCanvas(*args: Any, **kwargs: Any)
Figure Canvas that defers drawing until manual resize is complete.
This makes the GUI more responsive.
- request_update() None
Restart the timer every time this is called.
- class esibd.core.DeviceController(*args: Any, **kwargs: Any)
Each
DeviceorChannelcomes with aDeviceController.The
DeviceControlleris not itself aPlugin. It only abstracts the direct hardware communication frompluginsallowing 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, theDeviceControllerreads values from a physical device and assigns them to the correspondingChannel. Thedeviceswill collect data from theChannelindependently. In case you work with time sensitive experiments this concept will need to be adapted. Feel free to use the basic functionality provided byDeviceControlleror implement your own from scratch. As theDeviceControlleronly interacts with your customChannelorDevice, there are no general requirements for its implementation.- class SignalCommunicate(*args: Any, **kwargs: Any)
Bundle pyqtSignals.
- closeCommunicationSignal
Signal that triggers the acquisition to stop after communication errors.
- initCompleteSignal
Signal that is emitted after successful initialization of device communication.
- updateValuesSignal
Signal that transfers new data from the
acquisitionThreadto the corresponding channels.
- acquiring: bool = False
True, while acquisitionThread is running. AcquisitionThread terminates if set to False.
- acquisitionThread: Thread | None = None
A parallel thread that regularly reads values from the device.
- applyValue(channel: Channel) None
Apply value to device.
Should only be called for real channels!
- Parameters:
channel (esibd.core.Channel) – Channel for which the value should be applied.
- applyValueFromThread(channel: Channel) None
Apply value to device (thread safe).
- Parameters:
channel (esibd.core.Channel) – Channel for which the value should be applied.
- clearBuffer(port: serial.Serial) None
Clear the buffer at the serial port.
- Parameters:
port (serial.Serial, optional) – The port at which to clear the buffer, defaults to None
- closeCommunication() None
Close all open ports. Ths method has to be extended as described below.
This should free up all resources and allow for clean reinitialization. Extend to add hardware specific code. Keep following order to make sure acquisition is stopped before communication is closed: 1. super().closeCommunication() 2. closing your custom hardware communication 3. self.initialized = False
- closing: bool = False
Indicates if communications is being closed.
- property errorCount: int
Convenience method to access the errorCount of the device.
- fakeInitialization() None
Faking successful initialization in test mode. Called instead of runInitialization.
- fakeNumbers() None
Write fake channel values in an array that will be used in updateValue.
- initComplete() None
Start acquisition from main thread (access to GUI!). Called after successful initialization.
- initThread: Thread | None = None
A parallel thread used to initialize communication.
- initializeCommunication() None
Start the
initThread().
- initializeValues(reset: bool = False) None
Initialize array used to store current values or readbacks.
- Parameters:
reset (bool, optional) – If True, will reset values to np.nan, defaults to False
- 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.
- maxErrorCount: int
Close communication if exceeded.
- property name: str
Convenience method to access the name of the device.
- port: serial.Serial | None = None
Port for serial communication.
- print(message: str, flag: PRINT = PRINT.MESSAGE) None
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.
- readNumbers() None
Write channel values in an array that will be used in updateValue.
- resetErrorCount() None
Reset error count to 0.
- rng = Generator(PCG64) at 0x1AE41D24BA0
Random number generator.
- runAcquisition() None
Run acquisition loop. Executed in acquisitionThread.
Overwrite with hardware specific acquisition code.
- runInitialization() None
Hardware specific initialization of communication. Executed in initThread (no access to GUI!).
- serialRead(port: serial.Serial, encoding: str = 'utf-8', EOL: str = '\n', strip: str = '') str
Read a string from a serial port.
Takes care of decoding messages from bytes and catches common exceptions.
- serialWrite(port: serial.Serial, message: str, encoding: str = 'utf-8') None
Write 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() None
Start data acquisition from physical device.
- stopAcquisition() bool
Terminate acquisition but leaves communication initialized.
- toggleOn() None
Toggles device on or off.
- toggleOnFromThread(parallel: bool = True) None
Toggles device on or off (tread safe).
- Parameters:
parallel (bool, optional) – Use parallel thread. Run in main thread if you want the application to wait for this to complete! Defaults to True
- updateValues() None
Update the value or monitor of the channel(s) in the main thread. Called from acquisitionThread.
- 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)
Bundle pyqtSignals.
- closeEvent(event: QCloseEvent | None) None
Close the GUI when the dock is closing.
- on_top_level_changed() None
Update toolbars after dragging plugins to new location.
- resetResize() None
Reset resizing flag.
- resizeEvent(a0: QResizeEvent | None) None
Temporary set resizing flag.
- toggleTitleBar() None
Update titleBar as dock is changing from floating to docked states.
- class esibd.core.DynamicNp(initialData: ~numpy.ndarray[tuple[~typing.Any, ...], ~numpy.dtype[~numpy.float64 | ~numpy.float32]] | None = None, max_size: int | None = None, dtype: type = <class 'numpy.float32'>)
A numpy.array that dynamically increases its size in increments to prevent frequent memory allocation while growing.
- add(x: float, lenT: int | None = None) None
Add the new data point and adjust the data array as required.
- Parameters:
x (float) – Datapoint or array to be added
lenT (int, optional) – length of corresponding time array, defaults to None
- get(length: int | None = None, index_min: int | None = None, index_max: int | None = None, n: int = 1) ndarray[tuple[Any, ...], dtype[float64 | float32]]
Return actual values.
- Parameters:
length (int) – will return last ‘length’ values.
index_min (int) – Index of lower limit.
index_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
- init(initialData: ndarray[tuple[Any, ...], dtype[float64 | float32]] | None = None, max_size: int | None = None) None
Initialize DynamicNp. This is also used if data is cropped or padded.
- 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,pluginsand additionalplugins.- closeApplication(restart: bool = False, confirm: bool = True) bool
Close communication and plugins, restart if applicable.
- closeEvent(a0: QCloseEvent | None) None
Triggers PluginManager to close all plugins and all related communication.
- Parameters:
a0 (QCloseEvent) – The close event.
- restoreUiState() None
Restores size and location of main window.
- saveUiState() None
Save size and location of main window.
- toggleFullscreen() None
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.IconStatusBar(*args: Any, **kwargs: Any)
Statusbar that shows an icon in front of the message to indicate the type of message.
- iconClicked
alias of
bool
- setFlag(flag: PRINT = PRINT.MESSAGE) None
Set the status icon depending on the message flag.
- Parameters:
flag (esibd.const.PRINT, optional) – The message flag, defaults to PRINT.MESSAGE
- class esibd.core.Label(*args: Any, **kwargs: Any)
QLabel as ParameterWidget.
- class esibd.core.LabelItem(*args: Any, **kwargs: Any)
LabelItem that passes color changes on to the label text.
- setColor(color: ColorType) None
Set the color.
- Parameters:
color (ColorType) – The color to be applied.
- class esibd.core.LabviewDoubleSpinBox(*args: Any, **kwargs: Any)
Implements handling of arrow key events based on curser position similar as in LabView.
- contextMenuEvent(e: QContextMenuEvent | None) None
Do not use context menu for indicators.
- keyPressEvent(event: PyQt6.QtGui.QKeyEvent) None
Allow to manually rest a value from NaN.
- setDisplayDecimals(displayDecimals: int) None
Set display precision.
- Parameters:
displayDecimals (int) – Number of displayed decimals.
- setValue(val: float) None
Display nan and inf as text.
- stepBy(steps: int) None
Handle stepping value depending con caret position. This implementation works with negative numbers and of number of digits before the dot.
- textFromValue(v: float) str
Make sure nan and inf will be represented by NaN.
- value() float
Return nan instead of trying convert it.
- valueFromText(text: str | None) float
Convert text to value.
- Parameters:
text (str) – Input text.
- Returns:
value
- Return type:
float
- wheelEvent(e: QWheelEvent | None) None
Overwrite to disable accidental change of values via the mouse wheel.
- class esibd.core.LabviewSciSpinBox(*args: Any, **kwargs: Any)
Spinbox for scientific notation.
- class FloatValidator(*args: Any, **kwargs: Any)
Validates input for correct scientific notation.
- stepBy(steps: int) None
Handle stepping value depending con caret position. This implementation works with negative numbers and of number of digits before the dot.
- textFromValue(v: float) str
Make sure nan and inf will be represented by NaN.
- class esibd.core.LabviewSpinBox(*args: Any, **kwargs: Any)
Implements handling of arrow key events based on curser position similar as in LabView.
- contextMenuEvent(e: QContextMenuEvent | None) None
Suppresses context menu for indicators.
- keyPressEvent(event: PyQt6.QtGui.QKeyEvent) None
Allow to manually rest a value from NaN.
- setValue(val: int) None
Display nan and inf as text.
- stepBy(steps: int) None
Handle stepping value depending con caret position.
- textFromValue(v: int) str
Make sure nan and inf will be represented by NaN.
- value() int
Return nan instead of trying convert it.
- valueFromText(text: str | None) int
Convert text to value.
- Parameters:
text (str) – Input text.
- Returns:
value
- Return type:
int
- wheelEvent(e: QWheelEvent | None) None
Overwrite to disable accidental change of values via the mouse wheel.
- class esibd.core.LedIndicator(*args: Any, **kwargs: Any)
Simple custom LED indicator.
- mousePressEvent(e: QMouseEvent | None) None
Allow to open context menu while preventing change of LedIndicator state by user.
- property offColor: PyQt6.QtGui.QColor
Off color.
- property onColor: PyQt6.QtGui.QColor
On color.
- class esibd.core.LineEdit(*args: Any, **kwargs: Any)
LineEdit with input validation and custom signal onEditingFinished.
- allowEmptyText: bool = True
If False, empty text is not allowed and will be replaced with last valid text
- onEditingFinished() None
Process new value and update tree if applicable after editing was finished by Enter or loosing focus.
- onTextChanged(text: str) None
Validate text and adjust width after text was changed by user or setText.
- Parameters:
text (str) – The new text.
- onTextEdited() None
Set flag to indicate text was edited by user but editing is not yet finished, emitted on every keystroke.
- sizeHint() PyQt6.QtCore.QSize
Return reasonable size hint based on content within minimum and maximum limits.
- validateInput() None
Validate the text and remove invalid characters.
- class esibd.core.Logger(*args: Any, **kwargs: Any)
Redirect 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() None
Disables logging and restores stdout and stderr.
- closeTestLogFile() None
Add header and close test log file.
This runs in the main thread!
- flush() None
Flushes content to log file.
- open() None
Activates logging of Plugin.print statements, stdout, and stderr to the log file.
- openLog() None
Open the log file in an external program.
- openTestLogFile(tester: str = '') None
Open the test log file for writing.
- Parameters:
tester (str) – The testing plugin
- print(message: str, sender: str = 'ESIBD Explorer 1.0.0', flag: PRINT = PRINT.MESSAGE) None
Augments messages and redirects to log file, statusbar, and console.
- printFromThreadSignal
alias of
str
- purge() None
Purges the log file to keep it below purgeLimit.
- write(message: str, fromConsole: bool = False) None
Direct messages to terminal, log file, and Console.
Called directly from stdout or stderr or indirectly via
print().- Parameters:
message (str) – The message.
fromConsole (bool) – Indicates if called from Console while executing code and intercepting stdout.
- writeToLogAndTerminal(message: str) None
Write to log files only. Save to use without creating stdout recursion.
- Parameters:
message (str) – The message.
- class esibd.core.MZCalculator(parentPlugin: Plugin, ax: Axes | None = 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.
- addMZ(x: float, y: float) None
Add a single m/z value and evaluates the likely mass.
- Parameters:
x (float) – m/z value.
y (float) – Intensity.
- clear() None
Clear all data and removes labels.
- determine_mass_to_charge() None
Estimate 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.
- mass_string(offset: int, label: str) str
Indicate mass and standard deviation.
- Parameters:
offset (int) – Charge offset relative to likely charge.
label (str) – Descriptor for type of estimation.
- Returns:
Complete string.
- Return type:
str
- msOnClick(event: matplotlib.backend_bases.Event) None
Add a new m/z value for Ctrl+left mouse click.
Clears all data and labels for Ctrl+right mouse click.
- Parameters:
event (Event) – The click event.
- setAxis(ax: matplotlib.axes.Axes) None
Set the axes and canvas to be used.
- Parameters:
ax (matplotlib.axes) – A matplotlib axes.
- update_mass_to_charge() None
Update labels indicating mass and mass-to-charge values.
- class esibd.core.MetaChannel(parentPlugin: ChannelManager | Scan | StaticDisplay, name: str = '', unit: str = '', recordingData: np.ndarray | DynamicNp | None = None, initialValue: float | None = None, recordingBackground: np.ndarray | None = None, inout: INOUT | None = None)
Manage metadata associated with a channel by a
ScanorLiveDisplay.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.
- connectSource(giveFeedback: bool = False) None
Connect the sourceChannel.
- Parameters:
giveFeedback (bool, optional) – Report on success of connection, defaults to False
- display() bool
Indicate of the source channel should be displayed.
- onDelete() None
Provide onDelete for channel API consistency.
- class esibd.core.MouseInterceptor(*args: Any, **kwargs: Any)
Intercepts mouse clicks and applies ripple effect.
- eventFilter(a0: QObject | None, a1: QEvent | None) bool
Intercept mouse clicks and applies ripple effect.
- Parameters:
a0 (QObject) – Sender of the event.
a1 (QEvent) – The Event.
- Returns:
Indicates if the event has been handled. Always False as we want to add the ripple effect without altering anything else.
- Return type:
bool
- ripple(x: int, y: int, color: PyQt6.QtGui.QColor) None
Initialize an instance of the RippleEffect at the given location.
- Parameters:
x (int) – X position.
y (int) – Y position.
color (QColor) – Ripple color.
- rippleEffectSignal
alias of
int
- class esibd.core.MultiState(label: Enum, toolTip: str, icon: Icon)
Represents a state of a MultiStateAction including label, toolTip and icon.
- class esibd.core.MultiStateAction(*args: Any, **kwargs: Any)
Show different icons depending on multiple states.
Values are restored using QSettings if name is provided.
- getToolTip() str
Get the tooltip. API consistent with other Action classes.
- rollState() None
Roll to next state.
- setValue(value: Enum) None
Set action state. API consistent with other Action classes.
- Parameters:
value (Enum) – A valid label corresponding to one of the defined states.
- property state: Enum
Label representation of current state.
- stateFromEnum(state: Enum) int
Return state corresponding to provided label.
- Parameters:
state (Enum) – State Enum.
- Returns:
Index of corresponding state, defaults to 0.
- Return type:
int
- updateIcon() None
Update icon and icon toolTip based on current state.
- class esibd.core.NumberBar(*args: Any, **kwargs: Any)
A bar that displays line numbers of an associated editor.
- updateTheme() None
Change between dark and light themes.
- update_on_scroll(rect, scroll) None
Update NumberBar when scrolling in editor.
- update_width(string) None
Adjust with to number of required digits.
- class esibd.core.Parameter(name: str, parameterParent: SettingsManager | Channel, default: ParameterType | None = None, parameterType: PARAMETERTYPE | None = None, column: int = 1, items: str = '', fixedItems: bool = False, widget: QWidget | None = None, internal: bool = False, recorded: bool = False, tree: QTreeWidget | None = None, itemWidget: QTreeWidgetItem | None = None, toolTip: str = '', event: Callable | None = None, minimum: float | None = None, maximum: float | None = None, unit: str = '', indicator: bool = False, restore: bool = True, instantUpdate: bool = True, displayDecimals: int = 2, logY: bool = False)
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 SignalCommunicate(*args: Any, **kwargs: Any)
Bundle pyqtSignals.
- updateValueSignal
alias of
object
- addItem(value: str) None
Add an item to a combobox and selects it.
- Parameters:
value (str) – The new value to be added.
- advanced: bool
If True, parameter will only be visible in advanced mode.
- applyChangedEvent() None
Assign events to the corresponding controls.
Even indicators should be able to trigger events, e.g. to update dependent channels.
- applyWidget() None
Create UI widget depending on
parameterType.Links dedicated
widgetif 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
Settingsspecifies 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.
- changedEvent() None
Event that is triggered when the value of the Parameter changes.
Depending on the type and configuration of Parameter specific additional events will be triggered.
- clearPlotCurve() None
Clear the plotCurve.
- clearingPlotCurve = False
Flag to prevent multiple clearing attempts at the same time.
- color: str = ''
Color of the parameter. Needed to plot recorded parameters.
- containerize(widget: PushButton | ToolButton | ColorButton | CheckBox | Label | CompactComboBox | LineEdit | LedIndicator | LabviewSpinBox | LabviewDoubleSpinBox | LabviewSciSpinBox) PyQt6.QtWidgets.QWidget
Add a container around the widget that ensures correct handling of visibility and color changes.
- Parameters:
widget (QWidget) – The widget to be added to a container.
- Returns:
The container containing the widget.
- Return type:
QWidget
- convertDataDisplay(data: ndarray) ndarray
Overwrite to apply scaling and offsets to data before it is displayed. Use, e.g., to convert to another unit.
This should only affect display in
LiveDisplays.- Parameters:
data (np.ndarray) – Original data.
- Returns:
Scaled data.
- Return type:
np.ndarray
- property default: str | Path | int | float | PyQt6.QtGui.QColor | bool | None
The default value.
- display: bool = False
Indicates that this parameter will be displayed, just like the channel values or backgrounds.
- displayDecimals: int
Number of decimal places to display if applicable.
- property displayGroup: str
Return displayGroup of the associated Channel if applicable.
- editCurrentItem(value: str) None
Edits currently selected item of a combobox.
- Parameters:
value (str) – The new value to be validated.
- property enabled: bool
Return enabled of the associated Channel if applicable.
- equals(value: str | Path | int | float | PyQt6.QtGui.QColor | bool) bool
Return True if a representation of value matches the value of the Parameter.
- Parameters:
value (ParameterType) – The value to compare against.
- Returns:
True if value equals self.value.
- Return type:
bool
- event: Callable | None
A function that will be triggered when the parameter value changes.
- extraContextActions: list[ContextAction]
List of extra actions for the parameter context menu.
- 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.
- formatValue(value: str | Path | int | float | PyQt6.QtGui.QColor | bool | None = None, escapePercent: bool = False) str
Format value as a string, depending on Parameter type.
- Parameters:
value (ParameterType, optional) – A value to be formatted using the Parameter formatting, defaults to None and uses self.value
escapePercent (bool) – % has to be escaped by %% for use with configparser.
- Returns:
Formatted value as text.
- Return type:
str
- fullName: str
Will contain path of Setting in HDF5 file if applicable.
- getDevice() ChannelManager | Device | Scan
Return the device of the associated Channel if applicable.
- getDisplayUnit() str
Return the parameter unit.
- getQtLineStyle() PyQt6.QtCore.Qt.PenStyle
Return the linestyle of the associated Channel if applicable.
- getValues(*, length: int | None = None, index_min: int | None = None, index_max: int | None = None, n: int = 1, **kwargs) ndarray[tuple[Any, ...], dtype[float64 | float32]]
Return plain Numpy array of values.
Signature matching
getValues()- Parameters:
length (int) – will return last ‘length’ values.
index_min (int) – Index of lower limit.
index_max (int) – Index of upper limit.
n (int, optional) – Will only return every nth value, defaults to 1
kwargs – Used to match signature with
getValues(). Note that the subtractBackground keyword will be ignored.
- Returns:
The array of values.
- Return type:
np.ndarray[Any, np.dtype[np.float32]]
- getWidget() PushButton | ToolButton | ColorButton | CheckBox | Label | CompactComboBox | LineEdit | LedIndicator | LabviewSpinBox | LabviewDoubleSpinBox | LabviewSciSpinBox | None
Return the widget used to display the Parameter value in the user interface.
- 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.
- initContextMenu(pos: PyQt6.QtCore.QPoint) None
Initialize the context menu of the parent at the location of the Parameter.
- Parameters:
pos (QPoint) – The position of the context menu.
- 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: QTreeWidgetItem | None
Widget used to display the value of the parameter. None if parameter is part of a channel. Defined if it is part of a Setting.
- property items: list[str]
List of items for parameters with a combobox.
- property legendName: str
Return full Name including channel and parameter name if applicable.
- property linewidth: int
Return linewidth of the associated Channel if applicable.
- logY: bool
Indicates if logarithmic controls and scales should be used.
- makeDefault() None
Make current value the default value.
- max: float | None
Maximum limit for numerical properties.
- min: float | None
Minimum limit for numerical properties.
- parameterType: PARAMETERTYPE
The parameterType determines which widget is used to represent the parameter in the user interface.
- plotCurve: PlotCurveItem | PlotDataItem | None
The plotCurve in the corresponding
LiveDisplay.
- property real: bool
Return real of the associated Channel if applicable.
- recorded: bool
Indicates that this parameter will be recorded, just like the channel values or backgrounds.
- removeCurrentItem() None
Remove currently selected item from combobox.
- safeConnect(control: PyQt6.QtWidgets.QWidget, signal: PyQt6.QtCore.pyqtBoundSignal, event: Callable) None
Make sure there is never more than one event assigned to the signal.
- Parameters:
control (QWidget) – The control emitting the signal.
signal (pyqtSignal) – The signal.
event (Callable) – The event to be connected to the signal.
- setEnabled(enabled: bool) None
Control user access using setEnabled or setReadOnly depending on the widget type.
- Parameters:
enabled (bool) – The requested enabled state.
- setHeight(height: float | None = None) None
Set the height of the Parameter while accounting for different types of Parameter widgets.
- Parameters:
height (float, optional) – Target height, defaults to None
- setToDefault() None
Set Parameter value to its default.
- setValueChanged() None
Indicate that value actually changed.
The changedEvent might be ignored e.g. if there was an input but the value did not change.
- setValueWithoutEvents(value: str | Path | int | float | PyQt6.QtGui.QColor | bool | None) None
Set the parameter value without triggering valueChanged Events.
In most cases, use parameter.value = value instead.
- Parameters:
value (ParameterType | None) – The new value.
- setVisible(visible: bool) None
Set parameter visibility.
- Parameters:
visible (bool) – Visible or hidden.
- settingEvent() None
Extend to manage changes to settings.
- property smooth: int
Return smooth of the associated Channel if applicable.
- toolTip: str
Tooltip used to describe the parameter.
- tree: QTreeWidget | None
None, unless the parameter is used for settings.
- unit: str = ''
Physical unit of the parameter.
- updateDisplay() None
Toggle display of parameter.
- updateValueParallel(value: str | Path | int | float | PyQt6.QtGui.QColor | bool) None
Update the value (thread safe).
- Parameters:
value (ParameterType) – new value
- validateComboInput(value: str) bool
Validate input for comboboxes.
- Parameters:
value (str) – The new value to be validated.
- Returns:
True if valid.
- Return type:
bool
- property value: str | Path | int | float | PyQt6.QtGui.QColor | bool | None
Return value in correct format, based on parameterType.
- values: DynamicNp
The history of values shown in the
LiveDisplay. UsegetValues()to get a plain numpy.array.
- widget: QWidget | None
A custom widget that will be used instead of the automatically provided one.
- class esibd.core.ParameterWidget
Implement functionality shared by all parameter widgets.
- class esibd.core.PlotCurveItem(*args: Any, **kwargs: Any)
PlotCurveItem that stores a reference to its parent and legend to allow for clean removal of references before deletion.
- class esibd.core.PlotDataItem(*args: Any, **kwargs: Any)
PlotCurveItem that stores a reference to its parent and legend to allow for clean removal of references before deletion.
- class esibd.core.PlotItem(*args: Any, **kwargs: Any)
PlotItem providing xyLabel.
- connectMouse() None
Connect the mouse to the scene to update xyLabel. Plot when user moves or rescales x range.
- property dragging: bool
Indicate if dragging event has been called recently.
- finalizeInit() None
Apply final formatting.
- init() None
Init plotItem formatting and events.
- mouseMoveEvent(event: QGraphicsSceneMouseEvent | None) None
Update the xyLabel with the current position.
- Parameters:
event (QGraphicsSceneMouseEvent) – The mouseMoveEvent
- parentPlot() None
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.
- property legend: pg.LegendItem | None
The plot legend.
- class esibd.core.PluginManager
The
PluginManageris 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. The
PluginManagercan 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)
Bundle pyqtSignals.
- addPluginTreeWidgetItem(item: Mapping, name: str) None
Add a row for given plugin. If not a core plugin it can be enabled or disabled using the checkbox.
- Parameters:
item (Mapping) – Dictionary with plugin information.
name (str) – Plugin name.
- afterFinalizeInit() None
Finalize initialization after all other plugins have been initialized.
- closePlugins() None
Close all open connections and leave hardware in save state (e.g. voltage off).
- connectAllSources(update: bool = True) None
Connect all available source channels.
- Parameters:
update (bool, optional) – Indicates that all channels should be (re-)connected. Otherwise will only attempt to connect channels that are not yet connected. Defaults to True
- finalizeInit() None
Finalize initialization after all other plugins have been initialized.
- finalizeUiState() None
Restores dimensions of core plugins.
- getMainPlugins() list[Plugin]
Return all plugins found in the control section, including devices, controls, and scans.
- getPluginsByClass(parentClasses: type[A] | tuple[type[A]]) list[A]
Return all plugins of the specified type.
- getPluginsByType(pluginTypes: PLUGINTYPE | list[PLUGINTYPE]) list[Plugin]
Return all plugins of the specified type.
- Parameters:
pluginTypes (
PLUGINTYPE()) – A single type or list of types.- Returns:
List of matching plugins.
- Return type:
[
Plugin]
- loadPlugin(Plugin: type[Plugin], dependencyPath: Path, sourceCodePath: Path) Plugin | 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.
- Parameters:
- Returns:
Instance of the plugin.
- Return type:
class:~esibd.plugins.Plugin
- loadPlugins() None
Load all enabled plugins.
- loadPluginsFromModule(Module: ModuleType, dependencyPath: Path, sourceCodePath: Path) None
Load plugins from a module.
- Parameters:
Module (ModuleType) – A module providing one or multiple plugins.
dependencyPath (pathlib.Path, optional) – The path where dependencies like icons are stored, defaults to None
sourceCodePath (Path) – Path to the plugin source code.
- loadPluginsFromPath(path: Path | None) None
Load plugins from a path.
- Parameters:
path (pathlib.Path) – The path in which to look for plugins.
- property loading: bool
Flag that can be used to suppress events while plugins are loading, initializing, or closing.
- managePlugins() None
Select which plugins should be enabled.
- provideDocks() None
Create docks and positions them as defined by
pluginType.
- reconnectSource(name: str) None
Try to reconnect linked channels if applicable.
This is needed e.g. after renaming, moving, or deleting channels. If the channel has been deleted, the reconnection attempt will fail and and the linking channel will indicated that no source has been found.
- Parameters:
name (str) – Channel name to reconnect.
- resetMainDisplayWidgetLimits() None
Reset limits to allow for user scaling of plugin sizes.
- property resizing: bool
Indicates if any plugin is currently resizing.
- runTestParallel() None
Run test of all plugins from parallel thread.
- showThreads() None
Show all currently running threads in the Text plugin.
- stopTest() None
Stop test after current step completes.
- test() None
Test most features of for all plugins. Calls
runTestParallel().
- property testing: bool
Indicates if the PluginManager or any individual plugin is currently testing.
- toggleSelection(enabled: bool) None
Toggle selection of channels. Mostly used for development purposes when running tests with changing selection of plugins.
- Parameters:
enabled (bool) – Enable all or none of the channels.
- toggleSelectionContextMenu(pos: PyQt6.QtCore.QPoint) None
Context menu to toggle selection of plugins.
- Parameters:
pos (QPoint) – The position of the context menu.
- toggleTitleBar(update: bool = False) None
Toggles between showing icons or text in tabs.
- Parameters:
update (bool, optional) – Indicates if the list of tabBars should be updated, defaults to False
- toggleTitleBarDelayed(update: bool = False, delay: int = 500) None
Delay toggleTitleBar until GUI updates have been completed.
- toggleVideoRecorder() None
Toggles visibility of videoRecorderActions for all plugins.
- updateTheme() None
Update application theme while showing a splash screen if necessary.
- class esibd.core.PushButton(*args: Any, **kwargs: Any)
PushButton as ParameterWidget.
- class esibd.core.RelayChannel
Channel that wraps another sourceChannel. Used to display and access some elements of sourceChannel in other parts of the program.
- property acquiring: bool
SourceChannel.acquiring if available. Default provided.
- property active: bool
SourceChannel.active if available. Default provided.
- property color: str
SourceChannel.color if available. Default provided.
- property enabled: bool
SourceChannel.enabled if available. Default provided.
- getDevice() ChannelManager | Device | Scan
SourceChannel.getDevice() if available. Default provided.
- getQtLineStyle() PyQt6.QtCore.Qt.PenStyle
SourceChannel.QtLineStyle if available. Default provided.
- getRecordingData() ndarray | None
SourceChannel.getRecordingData() if available. Default provided.
- getValues(*, length: int | None = None, index_min: int | None = None, index_max: int | None = None, n: int = 1, subtractBackground: bool = False) ndarray | None
SourceChannel.getValues() if available. Default provided.
- Parameters:
length (int) – will return last ‘length’ values.
index_min (int) – Index of lower limit.
index_max (int) – Index of upper limit.
n (int, optional) – Will only return every nth value, defaults to 1
subtractBackground (bool, optional) – Indicates if the background should be subtracted, defaults to False
- Returns:
The array of values.
- Return type:
np.ndarray
- property linestyle: str
SourceChannel.linestyle if available. Default provided.
- property linewidth: int
SourceChannel.linewidth if available. Default provided.
- property logY: bool
SourceChannel.logY if available. Default provided.
- property max: int | float
SourceChannel.max if available. Default provided.
- property min: int | float
SourceChannel.min if available. Default provided.
- property real: bool
SourceChannel.real if available. Default provided.
- property recording: bool
SourceChannel.recording if available. Default provided.
- property smooth: int
SourceChannel.smooth if available. Default provided.
- subtractBackgroundActive() bool
SourceChannel.subtractBackgroundActive() if available. Default provided.
- property value: int | float
SourceChannel.value if available. Default provided.
- property waitToStabilize: bool
SourceChannel.waitToStabilize if available. Default provided.
- class esibd.core.ReplWidget(*args: Any, **kwargs: Any)
Add logging to terminal and log files. See original class for Documentation.
- displayException() None
Display the current exception and stack.
Also print to terminal and log files.
- runCmd(cmd: str) None
Print command to terminal and log files.
- Parameters:
cmd (str) – console command
- class esibd.core.RestoreFloatComboBox(*args: Any, **kwargs: Any)
ComboBox that allows to restore its value upon restart using an internal
Setting.
- class esibd.core.RestoreIntComboBox(*args: Any, **kwargs: Any)
ComboBox that allows to restore its value upon restart using an internal
Setting.
- class esibd.core.RestoreNumberComboBox(*args: Any, **kwargs: Any)
ComboBox that allows to restore its value upon restart using an internal
Setting.
- class esibd.core.RippleEffect(*args: Any, **kwargs: Any)
Creates a fading ripple effect at the clicked QAction.
- expand() None
Expand and fades the ripple effect.
- paintEvent(a0: QPaintEvent | None) None
Draws the ripple effect.
- Parameters:
a0 (QPaintEvent) – The paint event.
- class esibd.core.ScanChannel(*args: Any, **kwargs: Any)
Minimal UI for abstract PID channel.
- connectSource(giveFeedback: bool = False) None
Connect the sourceChannel.
- Parameters:
giveFeedback (bool, optional) – Report on success of connection, defaults to False
- getDefaultChannel() dict[str, dict]
Define Parameter(s) of the default Channel.
This is also use to assign parameterTypes, if Parameters are visible outside of advanced mode, and many other parameter properties. See
parameterDict(). If parameters do not exist in the settings file, the default Parameter will be added. Overwrite in dependent classes as needed.NOTE: While parameters with attributes will be automatically accessible, it is good practice to define the type of the attribute for type checking.
- initGUI(item: dict) None
Initialize Channel GUI.
Call after corresponding QTreeWidgetItem has been added to tree. Item needs parent for all graphics operations.
- Parameters:
item (dict) – Dictionary containing all channel information.
- property loading: bool
Indicates if the corresponding device is currently loading.
- onDelete() None
Extend to handle events on deleting. E.g. handle references that should remain available.
- relayValueEvent() None
Update value when sourceChannel.value changed.
- removeEvents() None
Remove extra events from sourceChannel.
- setDisplayedParameters() None
Determine which parameters to use and in what order.
Extend using
insertDisplayedParameter()to add more parameters.
- tempParameters() list[str]
Return list of tempParameters.
ScanChannels are not restored from file, thus every parameter is a tempParameter.
- updateDisplay() None
Update live and static displays.
- class esibd.core.SciAxisItem(*args: Any, **kwargs: Any)
Version of original logTickStrings that provide improved formatting of tick labels.
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() None
Return widget back to the Settings tree.
- setWidget(widget: PyQt6.QtWidgets.QWidget) None
Allow to change to custom widget after initialization. E.g. to move a Setting to a more logical position outside the Settings tree.
- Parameters:
widget (QWidget) – An appropriate widget to display the Setting value.
- settingEvent() None
Execute 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.
- toolTip: str
Tooltip used to describe the parameter.
- class esibd.core.SplashScreen(*args: Any, **kwargs: Any)
Program splash screen that indicates loading.
- animate() None
Advances to the next frame.
- close() bool
Close the splash screen.
- show() None
Show the splash screen.
- class esibd.core.StateAction(*args: Any, **kwargs: Any)
Show different icons depending on a state.
Values are restored using QSettings if name is provided.
- getToolTip() str
Get the tooltip. API consistent with other Action classes.
- setValue(value: bool) None
Set action state. API consistent with other Action classes.
- Parameters:
value (bool) – New state.
- property state: bool
Returns the state.
- toggle() bool
Toggles the state.
- updateIcon(state: bool) None
Update icon and icon toolTip.
- Parameters:
state (bool) – The state for which icon and toolTip should be set.
- class esibd.core.StdoutInterceptor(*args: Any, **kwargs: Any)
Add logging to terminal and log files. See original class for Documentation.
- write(strn: str) None
Print response to terminal and log files.
- Parameters:
strn (str) – response to input command
- class esibd.core.ThemedConsole(*args: Any, **kwargs: Any)
pyqtgraph.console.ConsoleWidget with colors adjusting to theme.
- scrollToBottom() None
Scrolls to bottom to show recently added messages.
- updateTheme() None
Change between dark and light themes.
Provide controls to interact with the figure.
Adds light and dark theme support to NavigationToolbar2QT.
Adjust theme used for saved figure.
Change color of icons in matplotlib navigation toolBar to match theme.
- class esibd.core.TimeoutLock(lockParent: Plugin | DeviceController | Logger)
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(blocking: bool = True, timeout: int = -1) bool
Acquires the lock.
- Parameters:
blocking (bool, optional) – If it is set to True, the calling thread will be blocked if some other thread is holding the flag and once that lock is released, then the calling thread will acquire the lock and return True. If it is set to False, it will not block the thread if the lock is already acquired by some other thread, and will return False. Defaults to True
timeout (int, optional) – Timeout for lock acquisition, defaults to -1
- Returns:
True if lock has been acquired.
- Return type:
bool
- acquire_timeout(timeout: int, timeoutMessage: str = '', already_acquired: bool = False)
Acquire lock.
Shows timeoutMessage if lock could not be acquired before timeout expires.
- Parameters:
- Yield:
True if lock is acquired
- Return type:
bool
- release() None
Releases the lock.
- class esibd.core.ToolButton(*args: Any, **kwargs: Any)
Allows to set values in a widget in a consistent way.
- class SignalCommunicate(*args: Any, **kwargs: Any)
Bundle pyqtSignals.
- setValueFromThreadSignal
alias of
bool
- setValue(value: bool) None
Set value using consistent API for parameter widgets.
- Parameters:
value (bool) – New checked state.
- class esibd.core.TransparentTextDelegate(*args: Any, **kwargs: Any)
Delegate that ensures transparent text stays transparent even if QWidgetItem gets selected.
- class esibd.core.TreeWidget(*args: Any, **kwargs: Any)
A TreeWidget with extended options to control its height.
- count_child_items(item: PyQt6.QtWidgets.QTreeWidgetItem) int
Count the number of child items of a QTreeWidgetItem.
- Parameters:
item (QTreeWidgetItem) – The item of which the children should be counted.
- Returns:
The child count.
- Return type:
int
- expandAllItems(depth: int = 1) None
Expand all Items up to a given level.
- Parameters:
depth (int, optional) – Limit expansion depth to prevent infinite loops (e.g. channel.device.channel.device…), defaults to 1
- grabItems() PyQt6.QtGui.QPixmap
Grab a QPixmap of the items.
- itemRect() PyQt6.QtCore.QRect
Return the QRect of all visible items.
- itemWidth() int
Width of fist visible item.
- item_depth(item: PyQt6.QtWidgets.QTreeWidgetItem) int
Recursively count item depth from root (root = 0).
- Parameters:
item (QTreeWidgetItem) – The item for which to return the depth.
- Returns:
item depth
- Return type:
int
- sizeHint() PyQt6.QtCore.QSize
SizeHint with custom minimal or complete height.
- totalHeight(limit: int = 0) int
Total height of all items.
- Parameters:
limit (int, optional) – Limit the number of items considered, defaults to 0
- Returns:
Total height of all considered items.
- Return type:
int
- totalItems() int
Total number of items at top level and first child level.
- tree_height_hint_complete() int
Calculate the complete height, corresponding to all items.
- tree_height_hint_minimal() int
Calculate the minimal height, corresponding to up to 6 items.
- class esibd.core.TreeWidgetItem(*args: Any, **kwargs: Any)
TreeWidgetItem with path_info.
- class esibd.core.VideoRecorder(parentPlugin: Plugin)
Allows to record videos of a plugin.
- capture_frame() None
Capture a single video frame.
- startRecording() None
Initialize video recorder and starts recording.
- stopRecording() None
Stop recording and finalizes the video file.
- class esibd.core.ViewBox(*args: Any, **kwargs: Any)
ViewBox providing mouseEnabledChangedUser event.
- setMouseEnabled(x: bool | None = None, y: bool | None = None) None
Call user event if values have changed.
- userMouseEnabledChanged
alias of
bool
- esibd.core.parameterDict(name: str = '', value: ParameterType | None = None, default: ParameterType | None = None, minimum: float | None = None, maximum: float | None = None, unit: str = '', toolTip: str = '', items: str | None = None, fixedItems: bool = False, tree: QTreeWidget | None = None, parameterType: PARAMETERTYPE | None = None, advanced: bool = False, header: str = '', widget: QWidget | None = None, event: Callable | None = None, internal: bool = False, recorded: bool = False, attr: str = '', indicator: bool = False, restore: bool = True, logY: bool = False, instantUpdate: bool = True, displayDecimals: int = 2) dict[str, str | Path | int | float | PyQt6.QtGui.QColor | bool | PyQt6.QtWidgets.QTreeWidget | PARAMETERTYPE | PyQt6.QtWidgets.QWidget | Callable | None]
Provide default values for all properties of a Parameter.
- Parameters:
name (str, optional) – The Parameter name. Only use last element of
fullNamein case its a path, defaults to ‘’value (ParameterType, optional) – The value of the Parameter in any supported type, defaults to None
default (ParameterType, optional) – The default value of the Parameter in any supported type, defaults to None
minimum (float, optional) – Minimum limit for numerical properties, defaults to None
maximum (float, optional) – Maximum limit for numerical properties., defaults to None
unit (str, optional) – The physical unit of the parameter., defaults to ‘’
toolTip (str, optional) – ToolTip used to describe the Parameter, defaults to ‘’
items (str, optional) – Coma separated list of options for parameters with a comboBox, defaults to None
fixedItems (bool, optional) – Indicates if list of items can be edited by the user or should remain fixed., defaults to False
tree (QTreeWidget, optional) – None, unless the Parameter is used for settings., defaults to None
parameterType (esibd.core.PARAMETERTYPE, optional) – The parameterType determines which widget is used to represent the Parameter in the user interface, defaults to None
advanced (bool, optional) – If True, Parameter will only be visible in advanced mode, defaults to False
header (str, optional) – Header used for the corresponding column in list of Channels. The Parameter name is used if not specified. Only applies to Channel Parameters. Defaults to ‘’
widget (QWidget, optional) – A custom widget that will be used instead of the automatically provided one., defaults to None
event (Callable, optional) – A function that will be triggered when the Parameter value changes, defaults to None
internal (bool, optional) – 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. Defaults to False
recorded (bool, optional) – Indicates that this parameter will be recorded, just like the channel values or backgrounds, defaults to False
attr (str, optional) – Allows direct access to the Parameter. Only applies to Channel and Settings Parameters. Defaults to ‘’
indicator (bool, optional) – Indicators cannot be edited by the user, defaults to False
restore (bool, optional) – Indicates if the parameter will be restored, defaults to True. Note that temp parameters of channels will never be restored.
logY (bool, optional) – Indicates if logarithmic controls and scales should be used.
instantUpdate (bool, optional) – 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. Defaults to True
displayDecimals (int, optional) – Number of decimal places to display if applicable, defaults to 2
- Returns:
Dictionary containing all Parameter information.
- Return type:
dict[str, ParameterType]
Constants
Defines constants used throughout the package.
- class esibd.const.Colors
Provides dark mode dependent default colors.
- property bg: str
Background color.
- property bgAlt1: str
First alternative background color.
- property bgAlt2: str
Second alternative background color.
- property blue: str
ESIBD blue.
- property fg: str
Foreground color.
- property green: str
ESIBD green.
- property highlight: str
Highlight color.
- property red: str
ESIBD red.
- property yellow: str
ESIBD yellow.
- class esibd.const.INOUT(value)
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.PARAMETERTYPE(value)
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.
- class esibd.const.PLUGINTYPE(value)
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.
- class esibd.const.PRINT(value)
Specify type of message in Plugin.print.
- CONSOLE = 4
Tag message as Console input or output.
- DEBUG = 5
Only show if debug flag is enabled.
- ERROR = 3
Tag message as error.
- EXPLORER = 0
Key messages by Explorer
- MESSAGE = 1
A standard message.
- TRACE = 7
All messages, including detailed trace of instrument communication.
- VERBOSE = 6
Additional details that would be distracting if not needed for specific test.
- WARNING = 2
Tag message as warning.
- esibd.const.color_distance(c1: tuple[float, float, float], c2: tuple[float, float, float]) float
Measure color distance.
- Parameters:
c1 (rgb tuple[float, float, float]) – first color
c2 (rgb tuple[float, float, float]) – second color
- Returns:
color distance
- Return type:
float
- esibd.const.datasetToStrList(dataset: Dataset) list[str]
Convert a h5py string dataset into a list of str.
- Parameters:
dataset (h5py.Dataset) – The dataset.
- Returns:
The list.
- Return type:
list[str]
- esibd.const.dynamicImport(module: str, path: Path | str) ModuleType | None
Import a module from the given path at runtime.
This is more general and robust than importing modules relative to plugin path.
- Parameters:
module (str) – module name
path (Path | str) – module path
- Returns:
Module
- Return type:
ModuleType
- esibd.const.getClipboardTheme() bool
Get the dark clipboard mode from Settings.
- Returns:
Dark clipboard mode
- Return type:
bool
- esibd.const.getDarkMode() bool
Get the dark mode from Settings.
- Returns:
Dark mode
- Return type:
bool
- esibd.const.getDebugMode() bool
Get the debug mode from Settings.
- Returns:
Debug mode
- Return type:
bool
- esibd.const.getLogLevel(asString: bool = False) int | str
Get the log level from Settings.
- Parameters:
asString (str) – Indicate if the log level should be returned as a string.
- Returns:
Log level
- Return type:
int | str
- esibd.const.getTestMode() bool
Get the test mode from Settings.
- Returns:
Test mode
- Return type:
bool
- esibd.const.getValidConfigPath() Path
Get validated configuration path.
- Returns:
Validated path and indication if path has changed during validation.
- Return type:
pathlib.Path, bool
- esibd.const.getValidDataPath() Path
Get validated data path.
- Returns:
Validated path and indication if path has changed during validation.
- Return type:
pathlib.Path, bool
- esibd.const.getValidPluginPath() Path
Get validated plugin path.
- Returns:
Validated path and indication if path has changed during validation.
- Return type:
pathlib.Path, bool
- esibd.const.getWakeMode() bool
Get the wake mode from Settings.
- Returns:
Wake mode
- Return type:
bool
- esibd.const.hex_to_rgb(hex_color: str) tuple[float, float, float]
Convert a hex color to rgb.
- Parameters:
hex_color (str) – hex color string
- Returns:
converted rbg color
- Return type:
tuple[float, float, float]
- esibd.const.infoDict(name: str) dict[str, str]
Return a dictionary with general information, usually used to add this information to exported files.
- Parameters:
name (str) – Usually the name of the plugin requesting the infoDict.
- Returns:
infoDict
- Return type:
dict
- esibd.const.makeSettingWrapper(name: str, settingsMgr: SettingsManager, docstring: str = '') property
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.
- Parameters:
name (str) – The Setting name.
settingsMgr (esibd.plugins.SettingsManager) – The SettingsManager of the Setting.
docstring (str, optional) – The docstring used for the attribute, defaults to None
- esibd.const.makeWrapper(name: str, docstring: str = '') property
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.
- Parameters:
name (str) – The Parameter name.
docstring (str, optional) – The docstring used for the attribute, defaults to None
- esibd.const.mix_hex_colors(color1: str, color2: str, ratio: float) str
Mix two hex colors by ratio.
- Parameters:
color1 – First color, e.g. “#FF0000”
color2 – Second color, e.g. “#0000FF”
ratio – 0.0 (all color1) to 1.0 (all color2)
- Returns:
Mixed hex color as string
- esibd.const.openInDefaultApplication(file: str | Path) None
Open file in system default application for file type.
- Parameters:
file (str / pathlib.Path) – Path to the file to open.
- esibd.const.plotting(func: Callable) Callable
Decorate to check for and sets the plotting flag to make sure func is not executed before previous call is processed.
Only use within a class that contains the plotting flag. This is intended for Scans, but might be used elsewhere.
- Parameters:
func (Callable) – function to add the decorator to
- Returns:
decorated function
- Return type:
Callable
- esibd.const.pluginSupported(pluginVersion: str) bool
Test if given version is supported by comparing to current program version.
- Parameters:
pluginVersion (str) – Version that the plugin supports.
- Returns:
True if the plugin is supported.
- Return type:
bool
- esibd.const.rgb_to_hex(rgba: tuple[float, float, float, float]) str
Convert colors from rgb to hex.
- Parameters:
rgba (tuple) – RGBA color tuple.
- Returns:
Hex color string.
- Return type:
str
- esibd.const.setDarkMode(darkMode: bool) None
Set the dark mode from Settings.
- Parameters:
darkMode (bool) – True if dark mode active.
- esibd.const.shorten_text(text: str, max_length: int = 100) str
Shorten text e.g. for concise and consistent log file format.
- Parameters:
text (str) – Original text.
max_length (int, optional) – Length after shortening. Defaults to 100
- Returns:
shortened text
- Return type:
str
- esibd.const.similar_but_distinct_color(color_hex: str, index: int) str
Return a similar but distinct color.
This is used for related plots. The color should be close enough so it is clear that the plots are related, but distinct enough that they can be identified in the plot legend.
- Parameters:
color_hex (str) – initial hex color.
index (int) – increase index if you need additional colors.
- Returns:
similar but distinct hex color.
- Return type:
str
- esibd.const.smooth(data: ndarray[tuple[Any, ...], dtype[float32]], smooth: int) ndarray[tuple[Any, ...], dtype[float32]]
Smooth a 1D array while keeping edges meaningful.
This method is robust if array contains np.nan.
- Parameters:
data (np.typing.NDArray[np.float32]) – Array to be smoothed.
smooth (int) – With of box used for smoothing.
- Returns:
convolvedArray
- Return type:
np.typing.NDArray[np.float32]
- esibd.const.synchronized(timeout: int = 5) Callable
Decorate to add thread-safety using a lock from the instance.
NOTE: Only works with keyword arguments. Positional arguments apart form self will not be passed on.
Use with @synchronized() or @synchronized(timeout=5).
- Parameters:
timeout (int, optional) – Will wait this long for lock to become available. Defaults to 5
- Returns:
decorator
- Return type:
decorator
- esibd.const.validatePath(path: Path | str | None, default: Path) tuple[Path, bool]
Return a valid path. If the path does not exist, falling back to default.
If default does not exist it will be created.
- Parameters:
path (pathlib.Path) – Valid path
default (pathlib.Path) – Default path that is returned if path is not valid.
- Returns:
Validated path and indication if path has changed during validation.
- Return type:
pathlib.Path, bool