Qudi
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
core.manager.Manager Class Reference

The Manager object is responsible for: More...

Inheritance diagram for core.manager.Manager:
Inheritance graph
[legend]
Collaboration diagram for core.manager.Manager:
Collaboration graph
[legend]

Public Member Functions

def __init__ (self, args, kwargs)
 Constructor for Qudi main management class. More...
 
def getMainDir (self)
 Returns the absolut path to the directory of the main software. More...
 
def readConfig (self, configFile)
 Read configuration file and sort entries into categories. More...
 
def configure (self, cfg)
 Sort modules from configuration into categories. More...
 
def readConfigFile (self, fileName, missingOk=True)
 Actually check if the configuration file exists and read it. More...
 
def writeConfigFile (self, data, fileName)
 Write a file into the currently used config directory. More...
 
def configFileName (self, name)
 Get the full path of a configuration file from its filename. More...
 
def saveConfig (self, filename)
 Save configuration to a file. More...
 
def loadConfig (self, filename, restart=False)
 Load configuration from file. More...
 
def reloadConfigPart (self, base, mod)
 Reread the configuration file and update the internal configuration of module. More...
 
def importModule (self, baseName, module)
 Module loading #. More...
 
def configureModule (self, moduleObject, baseName, className, instanceName, configuration=None)
 Instantiate an object from the class that makes up a Qudi module from a loaded python module object. More...
 
def connectModule (self, base, mkey)
 Connects the given module in mkey to main object with the help of base. More...
 
def loadConfigureModule (self, base, key)
 Loads the configuration Module in key with the help of base class. More...
 
def reloadConfigureModule (self, base, key)
 Reloads the configuration module in key with the help of base class. More...
 
def isModuleDefined (self, base, name)
 Check if module is present in module definition. More...
 
def isModuleLoaded (self, base, name)
 Check if module was loaded. More...
 
def isModuleActive (self, base, name)
 Returns whether a given module is active. More...
 
def findBase (self, name)
 Find base for a given module name. More...
 
def activateModule (self, base, name)
 Activate the module given in key with the help of base class. More...
 
def deactivateModule (self, base, name)
 Activated the module given in key with the help of base class. More...
 
def getReverseRecursiveModuleDependencies (self, base, module, deps=None)
 Based on input connector declarations, determine in which other modules need to be removed when stopping. More...
 
def getRecursiveModuleDependencies (self, base, key)
 Based on input connector declarations, determine in which other modules are needed for a specific module to run. More...
 
def getAllRecursiveModuleDependencies (self, allmods)
 Build a dependency tre for defined or loaded modules. More...
 
def startModule (self, base, key)
 Figure out the module dependencies in terms of connections, load and activate module. More...
 
def stopModule (self, base, key)
 Figure out the module dependencies in terms of connections and deactivate module. More...
 
def restartModuleRecursive (self, base, key)
 Figure out the module dependencies in terms of connections, reload and activate module. More...
 
def startAllConfiguredModules (self)
 Connect all Qudi modules from the currently loaded configuration and activate them.
 
def getStatusDir (self)
 Get the directory where the app state is saved, create it if necessary. More...
 
def saveStatusVariables (self, base, module, variables)
 If a module has status variables, save them to a file in the application status directory. More...
 
def loadStatusVariables (self, base, module)
 If a status variable file exists for a module, load it into a dictionary. More...
 
def removeStatusFile (self, base, module)
 
def quit (self)
 Nicely request that all modules shut down. More...
 
def realQuit (self)
 Stop all modules, no questions asked. More...
 
def restart (self)
 Nicely request that all modules shut down for application restart. More...
 
def registerTaskRunner (self, reference)
 Register/deregister/replace a task runner object. More...
 

Public Attributes

 lock
 
 tree
 
 hasGui
 
 currentDir
 
 baseDir
 
 alreadyQuit
 
 remote_server
 
 tm
 
 tr
 
 gui
 
 configDir
 
 rm
 
 configFile
 

Static Public Attributes

 sigConfigChanged = QtCore.Signal()
 
 sigModulesChanged = QtCore.Signal()
 
 sigModuleHasQuit = QtCore.Signal(object)
 
 sigLogDirChanged = QtCore.Signal(object)
 
 sigAbortAll = QtCore.Signal()
 
 sigManagerQuit = QtCore.Signal(object, bool)
 
 sigShutdownAcknowledge = QtCore.Signal(bool, bool)
 
 sigShowManager = QtCore.Signal()
 

Detailed Description

The Manager object is responsible for:

sigConfigChanged: the configuration has changed, please reread your configuration sigModulesChanged: the available modules have changed sigModuleHasQuit: the module whose name is passed is now deactivated sigAbortAll: abort all running things as quicly as possible sigManagerQuit: the manager is quitting sigManagerShow: show whatever part of the GUI is important

Constructor & Destructor Documentation

◆ __init__()

def core.manager.Manager.__init__ (   self,
  args,
  kwargs 
)

Constructor for Qudi main management class.

Parameters
argsargparse command line arguments

Member Function Documentation

◆ activateModule()

def core.manager.Manager.activateModule (   self,
  base,
  name 
)

Activate the module given in key with the help of base class.

Parameters
stringbase: module base package (hardware, logic or gui)
stringname: module which is going to be activated.

◆ configFileName()

def core.manager.Manager.configFileName (   self,
  name 
)

Get the full path of a configuration file from its filename.

Parameters
stringname: filename of file in configuration directory
Returns
string: full path to file

◆ configure()

def core.manager.Manager.configure (   self,
  cfg 
)

Sort modules from configuration into categories.

Parameters
dictcfg: dictionary from configuration file

There are the main categories hardware, logic, gui, startup and global. Startup modules can be logic or gui and are loaded directly on 'startup'. 'global' contains settings for the whole application. hardware, logic and gui contain configuration of and for loadable modules.

◆ configureModule()

def core.manager.Manager.configureModule (   self,
  moduleObject,
  baseName,
  className,
  instanceName,
  configuration = None 
)

Instantiate an object from the class that makes up a Qudi module from a loaded python module object.

Parameters
objectmoduleObject: loaded python module
stringbaseName: module base package (hardware, logic or gui)
stringclassName: name of the class we want an object from (same as module name usually)
stringinstanceName: unique name thet the Qudi module instance was given in the configuration
dictconfiguration: configuration options for the Qudi module
Returns
object: Qudi module instance (object of the class derived from Base)

This method will add the resulting Qudi module instance to internal bookkeeping.

◆ connectModule()

def core.manager.Manager.connectModule (   self,
  base,
  mkey 
)

Connects the given module in mkey to main object with the help of base.

Parameters
stringbase: module base package (hardware, logic or gui)
stringmkey: module which you want to connect
Returns
int: 0 on success, -1 on failure

◆ deactivateModule()

def core.manager.Manager.deactivateModule (   self,
  base,
  name 
)

Activated the module given in key with the help of base class.

Parameters
stringbase: module base package (hardware, logic or gui)
stringname: module which is going to be activated.

◆ findBase()

def core.manager.Manager.findBase (   self,
  name 
)

Find base for a given module name.

Parameters
strname: module name
Returns
str: base name

◆ getAllRecursiveModuleDependencies()

def core.manager.Manager.getAllRecursiveModuleDependencies (   self,
  allmods 
)

Build a dependency tre for defined or loaded modules.

Parameters
dictallmods: dictionary containing module bases (self.tree['loaded'] equivalent)
Returns
dict: module dependencies in the right format for the toposort function

◆ getMainDir()

def core.manager.Manager.getMainDir (   self)

Returns the absolut path to the directory of the main software.

Returns
string: path to the main tree of the software

◆ getRecursiveModuleDependencies()

def core.manager.Manager.getRecursiveModuleDependencies (   self,
  base,
  key 
)

Based on input connector declarations, determine in which other modules are needed for a specific module to run.

Parameters
strbase: Module category
strkey: Unique configured module name for module where we want the dependencies
Returns
dict: module dependencies in the right format for the toposort function

◆ getReverseRecursiveModuleDependencies()

def core.manager.Manager.getReverseRecursiveModuleDependencies (   self,
  base,
  module,
  deps = None 
)

Based on input connector declarations, determine in which other modules need to be removed when stopping.

Parameters
strbase: Module category
strkey: Unique configured module name for module where we want the dependencies
Returns
dict: module dependencies in the right format for the toposort function

◆ getStatusDir()

def core.manager.Manager.getStatusDir (   self)

Get the directory where the app state is saved, create it if necessary.

Returns
str: path of application status directory

◆ importModule()

def core.manager.Manager.importModule (   self,
  baseName,
  module 
)

Module loading #.

Load a python module that is a loadable Qudi module.

      @param string baseName: the module base package (hardware, logic, or gui)
      @param string module: the python module name inside the base package

      @return object: the loaded python module

◆ isModuleActive()

def core.manager.Manager.isModuleActive (   self,
  base,
  name 
)

Returns whether a given module is active.

Parameters
stringbase: module base package (hardware, logic or gui)
stringkey: module which is going to be activated.

◆ isModuleDefined()

def core.manager.Manager.isModuleDefined (   self,
  base,
  name 
)

Check if module is present in module definition.

Parameters
strbase: module base package
strname: unique module name
Returns
bool: module is present in definition

◆ isModuleLoaded()

def core.manager.Manager.isModuleLoaded (   self,
  base,
  name 
)

Check if module was loaded.

Parameters
strbase: module base package
strname: unique module name
Returns
bool: module is loaded

◆ loadConfig()

def core.manager.Manager.loadConfig (   self,
  filename,
  restart = False 
)

Load configuration from file.

Parameters
strfilename: path of file to be loaded

◆ loadConfigureModule()

def core.manager.Manager.loadConfigureModule (   self,
  base,
  key 
)

Loads the configuration Module in key with the help of base class.

Parameters
stringbase: module base package (hardware, logic or gui)
stringkey: module which is going to be loaded
Returns
int: 0 on success, -1 on fatal error, 1 on error

◆ loadStatusVariables()

def core.manager.Manager.loadStatusVariables (   self,
  base,
  module 
)

If a status variable file exists for a module, load it into a dictionary.

Parameters
strbase: the module category
strmodule: the unique mduel name
Returns
dict: dictionary of satus variable names and values

◆ quit()

def core.manager.Manager.quit (   self)

Nicely request that all modules shut down.

◆ readConfig()

def core.manager.Manager.readConfig (   self,
  configFile 
)

Read configuration file and sort entries into categories.

Parameters
stringconfigFile: path to configuration file

◆ readConfigFile()

def core.manager.Manager.readConfigFile (   self,
  fileName,
  missingOk = True 
)

Actually check if the configuration file exists and read it.

Parameters
stringfileName: path to configuration file
boolmissingOk: suppress exception if file does not exist
Returns
dict: configuration from file

◆ realQuit()

def core.manager.Manager.realQuit (   self)

Stop all modules, no questions asked.

◆ registerTaskRunner()

def core.manager.Manager.registerTaskRunner (   self,
  reference 
)

Register/deregister/replace a task runner object.

Parameters
objectreference: reference to a task runner or null class

If a reference is passed that is not None, it is kept and passed out as the task runner instance. If a None is passed, the reference is discarded. Id another reference is passed, the current one is replaced.

◆ reloadConfigPart()

def core.manager.Manager.reloadConfigPart (   self,
  base,
  mod 
)

Reread the configuration file and update the internal configuration of module.

str modname: name of module where config file should be reloaded.

◆ reloadConfigureModule()

def core.manager.Manager.reloadConfigureModule (   self,
  base,
  key 
)

Reloads the configuration module in key with the help of base class.

Parameters
stringbase: module base package (hardware, logic or gui)
stringkey: module which is going to be loaded
Returns
int: 0 on success, -1 on failure

◆ restart()

def core.manager.Manager.restart (   self)

Nicely request that all modules shut down for application restart.

◆ restartModuleRecursive()

def core.manager.Manager.restartModuleRecursive (   self,
  base,
  key 
)

Figure out the module dependencies in terms of connections, reload and activate module.

Parameters
strbase: Module category
strkey: Unique configured module name

◆ saveConfig()

def core.manager.Manager.saveConfig (   self,
  filename 
)

Save configuration to a file.

Parameters
strfilename: path where the config flie should be saved

◆ saveStatusVariables()

def core.manager.Manager.saveStatusVariables (   self,
  base,
  module,
  variables 
)

If a module has status variables, save them to a file in the application status directory.

Parameters
strbase: the module category
strmodule: the unique module name
dictvariables: a dictionary of status variable names and values

◆ startModule()

def core.manager.Manager.startModule (   self,
  base,
  key 
)

Figure out the module dependencies in terms of connections, load and activate module.

Parameters
strbase: Module category
strkey: Unique module name
Returns
int: 0 on success, -1 on error

If the module is already loaded, just activate it. If the module is an active GUI module, show its window.

◆ stopModule()

def core.manager.Manager.stopModule (   self,
  base,
  key 
)

Figure out the module dependencies in terms of connections and deactivate module.

Parameters
strbase: Module category
strkey: Unique module name

◆ writeConfigFile()

def core.manager.Manager.writeConfigFile (   self,
  data,
  fileName 
)

Write a file into the currently used config directory.

Parameters
dictdata: dictionary to write into file
stringfileName: path for filr to be written

The documentation for this class was generated from the following file: