qudi.core

This file contains the Qudi Manager class.

Functions

get_logger(name)

Classes

StatusVar([name, default, constructor, ...])

This class defines a status variable that is loaded before activation and saved after deactivation.

ConfigOption([name, default, missing, ...])

This class represents a configuration entry in the config file that is loaded before module initalisation.

Connector(interface[, name, optional])

A connector used to connect qudi modules with each other.

Base(*args, **kwargs)

Base class for all loadable modules

LogicBase(*args, **kwargs)

GuiBase(*args, **kwargs)

This is the GUI base class.

class qudi.core.Base(*args, **kwargs)[source]

Bases: PySide2.QtCore.QObject

Base class for all loadable modules

  • Ensure that the program will not die during the load of modules

  • Initialize modules

  • Provides a self identification of the used module

  • per-module logging facility

  • Provides a self de-initialization of the used module

  • Get your own configuration (for save)

  • Get name of status variables

  • Get status variables

  • Reload module data (from saved variables)

__init__(qudi_main_weakref: Any, name: str, config: Mapping[str, Any] | None = None, callbacks: Mapping[str, Callable] | None = None, **kwargs)[source]

Initialize Base instance. Set up its state machine and initialize ConfigOption meta attributes from given config.

Parameters:
selfobject

The object being initialized.

namestr

Unique name for this module instance.

configurationdict

Parameters from the configuration file.

callbacksdict

Dictionary specifying functions to be run on state machine transitions.

connect_modules(connections: Mapping[str, Any]) None[source]

Connects given modules (values) to their respective Connector (keys).

DO NOT CALL THIS METHOD UNLESS YOU KNOW WHAT YOU ARE DOING!

disconnect_modules() None[source]

Disconnects all Connector instances for this module.

DO NOT CALL THIS METHOD UNLESS YOU KNOW WHAT YOU ARE DOING!

property is_module_threaded: bool

Returns whether the module shall be started in its own thread.

property log: Logger

Returns the module logger instance

property module_base: str

Read-only property returning the module base of this module instance (‘hardware’ ‘logic’ or ‘gui’)

property module_default_data_dir: str

Read-only property returning the generic default directory in which to save data. Module implementations can overwrite this property with a custom path but should only do so with a very good reason.

property module_name: str

Read-only property returning the module name of this module instance as specified in the config.

property module_status_variables: Dict[str, Any]

!! processed by numpydoc !!

property module_thread: QThread | None

Read-only property returning the current module QThread instance if the module is threaded. Returns None otherwise.

property module_uuid: UUID

Read-only property returning a unique uuid for this module instance.

move_to_main_thread() None[source]

Method that will move this module into the main/manager thread.

abstract on_activate() None[source]

Method called when module is activated. Must be implemented by actual qudi module.

abstract on_deactivate() None[source]

Method called when module is deactivated. Must be implemented by actual qudi module.

staticMetaObject = <PySide2.QtCore.QMetaObject object>
class qudi.core.ConfigOption(name: str | None = None, default: Any | None = None, *, missing: str | None = 'nothing', constructor: Callable | None = None, checker: Callable | None = None, converter: Callable | None = None)[source]

Bases: builtins.object

This class represents a configuration entry in the config file that is loaded before module initalisation.

__init__(name: str | None = None, default: Any | None = None, *, missing: str | None = 'nothing', constructor: Callable | None = None, checker: Callable | None = None, converter: Callable | None = None)[source]

Create a ConfigOption object.

Parameters:
nameOptional[str], optional

Identifier of the option in the configuration file.

defaultOptional[Any], optional

Default value for the case that the option is not set in the config file.

missingOptional[str], optional

Action to take when the option is not set. ‘nothing’ does nothing, ‘warn’ logs a warning, ‘error’ logs an error and prevents the module from loading.

constructorOptional[Callable], optional

Constructor function for complex config option behavior.

checkerOptional[Callable], optional

Static function that checks if value is okay.

converterOptional[Callable], optional

Static function that forces type interpretation.

check(value: Any) bool[source]

If checker function set, check value. Assume everything is ok otherwise.

constructor(func: Callable) Callable[source]

Decorator for declaring a constructor function for this ConfigOption.

Parameters:
funcCallable

Constructor function for this ConfigOption.

Returns:
Callable

Returns the original function so it can be used as a decorator.

convert(value: Any) Any[source]

If converter function set, convert value (pass-through otherwise).

copy(**kwargs)[source]

Create a new instance of ConfigOption with copied values and update.

Parameters:
**kwargs

Extra arguments or overrides for the constructor of this class.

property optional: bool

!! processed by numpydoc !!

class qudi.core.Connector(interface: str | Type, name: str | None = None, optional: bool = False)[source]

Bases: builtins.object

A connector used to connect qudi modules with each other.

__call__() Any[source]

Return reference to the module that this connector is connected to.

__init__(interface: str | Type, name: str | None = None, optional: bool = False)[source]

Initialize a Connector instance.

Parameters:
interfaceUnion[str, Type]

Name of the interface class to connect to or the interface class itself.

namestr, optional

Name of the connector in qudi config. Will set attribute name if omitted.

optionalbool, optional

Flag indicating if the connection is mandatory (False by default).

Raises:
AssertionError

If interface is not a string or a type. If name is not None or a non-empty string. If optional is not a boolean.

connect(target: Any) None[source]

Check if target is connectible by this connector and connect.

copy(**kwargs)[source]

Create a new instance of Connector with copied values and update

disconnect() None[source]

Disconnect connector.

property is_connected: bool

Read-only property to check if the Connector instance is connected to a target module.

Returns:
bool

Connection status flag. - True: Connected - False: Disconnected

class qudi.core.GuiBase(*args, **kwargs)[source]

Bases: qudi.core.module.Base

This is the GUI base class. It provides functions that every GUI module should have.

abstract show() None[source]
staticMetaObject = <PySide2.QtCore.QMetaObject object>
class qudi.core.LogicBase(*args, **kwargs)[source]

Bases: qudi.core.module.Base

staticMetaObject = <PySide2.QtCore.QMetaObject object>
class qudi.core.StatusVar(name: str | None = None, default: Any | None = None, *, constructor: Callable | None = None, representer: Callable | None = None)[source]

Bases: builtins.object

This class defines a status variable that is loaded before activation and saved after deactivation.

__init__(name: str | None = None, default: Any | None = None, *, constructor: Callable | None = None, representer: Callable | None = None)[source]
Parameters:
namestr

Identifier of the status variable when stored.

defaultAny

Default value for the status variable when a saved version is not present.

constructorcallable

Constructor function for the variable; use for type checks or conversion.

representercallable

Representer function for the status variable; use for saving conversion.

constructor(func: Callable) Callable[source]

This is the decorator for declaring constructor function for this StatusVar.

Parameters:
funccallable

Constructor function for this StatusVar.

Returns:
callable

The original function so this can be used as a decorator.

copy(**kwargs)[source]

Create a new instance of StatusVar with copied and updated values.

Parameters:
**kwargsdict

Additional or overridden parameters for the constructor of this class.

representer(func: Callable) Callable[source]

This is the decorator for declaring a representer function for this StatusVar.

Parameters:
funccallable

Representer function for this StatusVar.

Returns:
callable

The original function so this can be used as a decorator.

qudi.core.get_logger(name)[source]