55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
from ..base import LedControlDevice
|
|
from ...utility.visa import enumerate_devices
|
|
|
|
import logging
|
|
log = logging.getLogger(__name__)
|
|
|
|
import pyvisa
|
|
|
|
class DC2200(LedControlDevice):
|
|
"""
|
|
Class for controlling Thorlabs DC2200 LED controller.
|
|
This works only when the LED is connected to Terminal 2
|
|
Args:
|
|
instr (pyvisa.Resource): pyvisa resource object for the LED controller.
|
|
"""
|
|
def __init__(self, instr: pyvisa.Resource):
|
|
super().__init__()
|
|
self.instr = instr
|
|
# led presence test
|
|
self.instr.write('OUTPut:TERMinal2:TEST:INITiate')
|
|
presence = self.instr.query('OUTPut:TERMinal2:TEST:STATus?')
|
|
# Led name, format:
|
|
# "<vendor_name_string>,<led_head_model_name_string >, < led_head_serial_no_string >, < fw_version_major_num >, < fw_version_minor_num >, < fw_version_subminor_num > "
|
|
self.led_name = self.instr.query('SYSTem:TERMinal2:HTYPe?')
|
|
# constant brightness
|
|
self.instr.write('SOURCE1:MODE CB')
|
|
# turn off
|
|
self.instr.write(f'SOURCE1:CBRightness:BRIGhtness 0')
|
|
self.instr.write('OUTPUT1:STATE ON')
|
|
|
|
def on(self):
|
|
self.instr.write(f'SOURCE1:CBRightness:BRIGhtness 100')
|
|
|
|
def off(self):
|
|
self.instr.write(f'SOURCE1:CBRightness:BRIGhtness 0')
|
|
|
|
def set_level(self, level:int):
|
|
self.instr.write(f'SOURCE1:CBRightness:BRIGhtness {level}')
|
|
|
|
@staticmethod
|
|
def enumerate_devices(query="(GPIB)|(USB)?*:INSTR"):
|
|
return enumerate_devices("DC2200", query)
|
|
|
|
@staticmethod
|
|
def connect_device(name):
|
|
rm = pyvisa.ResourceManager()
|
|
instr = rm.open_resource(name)
|
|
return DC2200(instr)
|
|
|
|
def get_led_name(self) -> None|str:
|
|
return self.led_name
|
|
|
|
def __str__(self):
|
|
return "Thorlabs DC2200"
|