Instrument configurationΒΆ

In [1]:
from lightlab.laboratory.state import lab
from lightlab.equipment.lab_instruments import *

host = lab.hosts['gunther']
bench = lab.benches['bert']

# Do not edit this
print('Host available addresses:')
for resource in host.list_gpib_resources_info():
    print(resource)
Host available addresses:
visa://labdns-gunther.school.edu/GPIB0::16::INSTR
visa://labdns-gunther.school.edu/GPIB0::18::INSTR
visa://labdns-gunther.school.edu/GPIB0::21::INSTR
In [2]:
# Uncomment only one at a time
info = Keithley_2400_SM, 'Keithley 21', host.gpib_port_to_address(21), {}
# info = ILX_7900B_LS, 'Laser Array 12', host.gpib_port_to_address(12), dict(useChans=range(8))

# Do not edit this
theDriver, theName, theAddress, extraKwargs = info
newInst = theDriver(name=theName,
                  address=theAddress,
                  bench=bench,
                  host=host,
                  **extraKwargs)

try:
    oldInst = lab.instruments_dict[newInst.name]
except KeyError:
    print('This is a new instrument')
else:
    print('You are overwriting! Make sure everything is specified (i.e. ports, useChans, etc.)\n')
    oldInst.display()
    print('\n*** TO ***\n')
    newInst.display()
You are overwriting! Make sure everything is specified (i.e. ports, useChans, etc.)

Keithley 21
Bench: Bench bert
Host: Host brian
address: GPIB0::21::INSTR
driver_class: Keithley_2400_SM
=====
Ports
=====
   No ports.
***

*** TO ***

Keithley 21
Bench: Bench bert
Host: Host gunther
address: visa://labdns-gunther.school.edu/GPIB0::21::INSTR
driver_class: Keithley_2400_SM
=====
Ports
=====
   No ports.
***
In [3]:
# Make the change and save. Be careful!
lab.deleteInstrumentFromName(newInst.name)  # deleting previous instance, if it is there
lab.insertInstrument(newInst)  # inserting new instance
lab.saveState()
In [4]:
# Test it
gotten = lab.instruments_dict[newInst.name]
gotten.isLive()
Out[4]:
True