InstrumentManager

The InstrumentManager object is the primary interface to communicating with instruments. It simplifies script development by abstracting instruments as Python objects.

class labtronyx.InstrumentManager(**kwargs)[source]

Labtronyx InstrumentManager

Facilitates communication with instruments using all available interfaces.

Parameters:
  • server (bool) – Enable RPC endpoint
  • server_port (int) – RPC endpoint port
  • plugin_dirs (list) – List of directories containing plugins
  • logger (logging.Logger) – Logger
addPluginSearchDirectory(path)[source]

Add a search path for plugins. Directory will be searched immediately and all discovered plugins will be cataloged. If a search path has already been searched, it will not be searched again. Interfaces will not be started automatically. Use enableInterface() to start the interface once it has been discovered.

Parameters:path (str) – Search directory
closeScript(script_uuid)[source]

Destroy a script instance that is not currently running.

Parameters:script_uuid (str) – Script Instance UUID
Return type:bool
disableInterface(interface)[source]

Disable an interface that is running.

Parameters:interface (str) – Interface Name (interfaceName attribute of plugin) or Interface UUID
Return type:bool
enableInterface(interfaceName, **kwargs)[source]

Enable or restart an interface. Use this method to pass parameters to an interface. If an interface with the same name is already running, it will be stopped first. Each interface may only have one instance at a time (Singleton pattern).

Parameters:interfaceName (str) – Interface Name (interfaceName attribute of plugin) or plugin FQN
Return type:bool
Raises:KeyError
findInstruments(**kwargs)[source]

Alias for findResources()

findResources(**kwargs)[source]

Get a list of resources/instruments that match the parameters specified. Parameters can be any key found in the resource property dictionary, such as these:

Parameters:
  • uuid – Unique Resource Identifier (UUID)
  • interface – Interface
  • resourceID – Interface Resource Identifier (Port, Address, etc.)
  • resourceType – Resource Type (Serial, VISA, etc.)
  • deviceVendor – Instrument Vendor
  • deviceModel – Instrument Model Number
  • deviceSerial – Instrument Serial Number
Return type:

list[labtronyx.bases.resource.ResourceBase]

getAddress()[source]

Get the local IP Address

Returns:str
getAttributes()[source]

Get the class attributes for all loaded plugins. Dictionary keys are the Fully Qualified Names (FQN) of the plugins

Return type:dict[str:dict]
static getHostname()[source]

Get the local hostname

Return type:str
getLog()[source]

Get the last 100 log entries

Returns:list
getPluginSearchDirectories()[source]

Get a list of all the searched paths for plugins.

Return type:list
getProperties()[source]

Returns the property dictionaries for all resources

Return type:dict[str:dict]
getResource(interfaceName, resID, driverName=None)[source]

Get a resource by name from the specified interface. Not supported by all interfaces, see interface documentation for more details.

Parameters:
  • interfaceName (str) – Interface name
  • resID (str) – Resource Identifier
  • driverName (str) – Driver to load for resource
Returns:

Resource object

Return type:

labtronyx.bases.resource.ResourceBase

Raises:

InterfaceUnavailable

Raises:

ResourceUnavailable

Raises:

InterfaceError

static getVersion()[source]

Get the Labtronyx version

Return type:dict{str: str}
listInterfaces()[source]

Get a list of interface names that are enabled

Returns:Interface names
Return type:list[str]
listResources()[source]

Get a list of UUIDs for all resources

Deprecated:Deprecated by getProperties()
Return type:list[str]
openScript(script_fqn, **kwargs)[source]

Create an instance of a script. The script must have already been loaded by the plugin manager. Any required script parameters can be provided using keyword arguments.

Parameters:script_fqn (str) – Fully Qualified Name of the script plugin
Returns:Script Instance UUID
Return type:str
Raises:KeyError
Raises:RuntimeError
refresh()[source]

Refresh all interfaces and resources. Attempts enumeration on all interfaces, then calls the refresh method for all resources.

runScript(script_uuid)[source]

Run a script that has been previously opened using openScript(). The script is run in a separate thread

Parameters:script_uuid (str) – Script Instance UUID
Raises:KeyError
Raises:ThreadError
server_start(new_thread=True)[source]

Start the API/RPC Server and Event publisher. If new_thread is True, the server will be started in a new thread in a non-blocking fashion.

If a server is already running, it will be stopped and then restarted.

Returns:True if successful, False otherwise
Return type:bool
server_stop()[source]

Stop the Server

stopScript(script_uuid)[source]

Stop a script that is currently running. Does not currently do anything.

Parameters:script_uuid (str) – Script Instance UUID
Raises:KeyError
interfaces
Returns:Dictionary of interface plugin instances {UUID -> Interface Object}
Return type:dict[str:labtronyx.bases.interface.InterfaceBase]
scripts
Returns:Dictionary of script plugin instances {UUID -> Script object}
Return type:dict[str:labtronyx.bases.script.ScriptBase]