from pylablib.devices import NI import logging log = logging.getLogger(__name__) from ..base import Shutter class ShutterDAQ(Shutter): def __init__(self, channel): self.daq_name = 'Dev1' self.channel = channel def open(self): with NI.NIDAQ(self.daq_name) as shutter: shutter.add_voltage_output('vout', self.channel, (0,5)) shutter.set_voltage_outputs('vout', 5) log.info('Shutter opened') def close(self): with NI.NIDAQ(self.daq_name) as shutter: shutter.add_voltage_output('vout', self.channel, (0,5)) shutter.set_voltage_outputs('vout', 0) log.info('Shutter closed') def __repr__(self): return f'ShutterDAQ({self.daq_name}/{self.channel})' # name: channel shutters = { "TAS Lamp Shutter": "ao0", "TAS Pump Shutter": "ao1", } @staticmethod def enumerate_devices(): return list(ShutterDAQ.shutters.keys()) @staticmethod def connect_device(name): if name not in ShutterDAQ.shutters: raise ValueError(f"Unknown shutter {name}. Must be one of {ShutterDAQ.shutters}") return ShutterDAQ(ShutterDAQ.shutters[name])