lightlab.laboratory.instruments.bases module¶
This module provides an interface for instruments, hosts and benches in the lab.
Summary¶
Exceptions:
NotFoundError |
Error thrown when instrument is not found |
Classes:
Bench |
Represents an experiment bench for the purpose of facilitating its location in lab. |
Device |
Represents a device in lab. |
Host |
Computer host, from which GPIB/VISA commands are issued. |
Instrument |
Represents an instrument in lab. |
LocalHost |
|
MockInstrument |
Reference¶
-
class
Host(name='Unnamed Host', hostname=None, **kwargs)[source]¶ Bases:
lightlab.laboratory.NodeComputer host, from which GPIB/VISA commands are issued.
-
mac_address= None¶
-
os= 'linux-ubuntu'¶
-
hostname= None¶
-
name¶
-
instruments¶
-
gpib_port_to_address(port, board=0)[source]¶ Parameters: Returns: the address that can be used in an initializer
Return type: (str)
-
list_resources_info(use_cached=True)[source]¶ Executes a query to the NI Visa Resource manager and returns a list of instruments connected to it.
Parameters: use_cached (bool) – query only if not cached, default True Returns: list of pyvisa.highlevel.ResourceInfo named tuples. Return type: list
-
list_gpib_resources_info(use_cached=True)[source]¶ Like
list_resources_info(), but only returns gpib resources.Parameters: use_cached (bool) – query only if not cached, default True. Returns: list of pyvisa.highlevel.ResourceInfonamed tuples.Return type: (list)
-
get_all_gpib_id(use_cached=True)[source]¶ Queries the host for all connected GPIB instruments, and queries their identities with
instrID().Warning: This might cause your instrument to lock into remote mode.
Parameters: use_cached (bool) – query only if not cached, default True Returns: dictionary with gpib addresses as keys and identity strings as values. Return type: dict
-
findGpibAddressById(id_string_search, use_cached=True)[source]¶ Finds a gpib address using
get_all_gpib_id(), given an identity string.Parameters: Returns: address if found.
Return type: Raises: NotFoundError– If the instrument is not found.
-
addInstrument(*instruments)[source]¶ Adds an instrument to lab.instruments if it is not already present.
Parameters: *instruments (Instrument) – instruments
-
removeInstrument(*instruments)[source]¶ Disconnects the instrument from the host
Parameters: *instruments (Instrument) – instruments Todo
Remove all connections
-
checkInstrumentsLive()[source]¶ Checks whether all instruments are “live”.
Instrument status is checked with the
Instrument.isLive()methodReturns: True if all instruments are live, False otherwise Return type: (bool)
-
-
class
Bench(name, *args, **kwargs)[source]¶ Bases:
lightlab.laboratory.NodeRepresents an experiment bench for the purpose of facilitating its location in lab.
-
name= None¶
-
instruments¶
-
devices¶
-
addInstrument(*instruments)[source]¶ Adds an instrument to lab.instruments if it is not already present and connects to the host.
Parameters: *instruments (Instrument) – instruments
-
removeInstrument(*instruments)[source]¶ Detaches the instrument from the bench.
Parameters: *instruments (Instrument) – instruments Todo
Remove all connections
-
addDevice(*devices)[source]¶ Adds a device to lab.devices if it is not already present and places it in the bench.
Parameters: *devices (Device) – devices
-
-
class
Instrument(name='Unnamed Instrument', id_string=None, address=None, **kwargs)[source]¶ Bases:
lightlab.laboratory.NodeRepresents an instrument in lab.
This class stores information about instruments, for the purpose of facilitating verifying whether it is connected to the correct devices.
- Driver feedthrough
- Methods, properties, and even regular attributes
that are in
essential_attributesof the class will get/set/call through to the driver object. - Do not instantiate directly
- Calling a VISAInstrumentDriver class will return an Instrument object
Short example:
osa = Apex_AP2440A_OSA(name='foo', address='NULL') osa.spectrum()
- Long example
- Instrument configuration
- Detailed testing
test_driver_init()
-
essentialMethods= ['startup']¶ list of methods to be fed through the driver
-
essentialProperties= []¶ list of properties to be fed through the driver
-
optionalAttributes= []¶ list of optional attributes to be fed through the driver
-
ports= None¶ list(str) Port names of instruments. To be used with labstate connections.
-
address= None¶ Complete Visa address of the instrument (e.g.
visa://hostname/GPIB0::1::INSTR)
-
implementedOptionals¶
-
hardware_warmup()[source]¶ Called before the beginning of an experiment.
Typical warmup procedures include RESET gpib commands.
-
hardware_cooldown()[source]¶ Called after the end of an experiment.
Typical cooldown procedures include laser turn-off, or orderly wind-down of current etc.
-
warmedUp()[source]¶ A context manager that warms up and cools down in a “with” block
Usage:
with instr.warmedUp() as instr: # warms up instrument instr.doStuff() raise Exception("Interrupting experiment") # cools down instrument, even in the event of exception
-
driver_class¶ Class of the actual equipment driver (from
lightlab.equipment.lab_instruments)This way the object knows how to instantiate a driver instance from the labstate.
-
driver_object¶ Instance of the equipment driver.
-
driver¶ Alias of
driver_object().
-
bench¶ Property that only accepts <class ‘lightlab.laboratory.instruments.bases.Bench’> values
-
host¶ Property that only accepts <class ‘lightlab.laboratory.instruments.bases.Host’> values
-
name¶ (property) Instrument name (can only set during initialization)
-
id_string¶ The id_string should match the value returned by
self.driver.instrID(), and is checked by the commandself.isLive()in order to authenticate that the intrument in that address is the intended one.
-
exception
NotFoundError[source]¶ Bases:
RuntimeErrorError thrown when instrument is not found
-
class
Device(name, **kwargs)[source]¶ Bases:
lightlab.laboratory.NodeRepresents a device in lab. Only useful for documenting the experiment.
Todo
Add equality function
-
name= None¶ device name
-
ports= None¶ list(str) port names
-
bench¶ Property that only accepts <class ‘lightlab.laboratory.instruments.bases.Bench’> values
-