# proprietary package :/ import pyBen from os import path class DummyBentham: def __init__(self): pass def return_parameters(self): return {} def park(self): print("Parked") def drive(self, wl): print(f"Set to {wl} nm") class Bentham(): """ Controls the Bentham TMC300 monochromator. This is the source of the probe light beam """ def __init__(self): self.path_cfg = path.abspath('system.cfg') self.path_atr = path.abspath('systemAll-1nm.atr') self.parked = -1 self.wavelength = -1 def return_parameters(self): """ Returns parameters relevant for this device. New parameters to be saved can be added here """ parameters = {'bentham cfg_path': self.path_cfg, 'bentham atr_path': self.path_atr, 'bentham wavelength': self.wavelength} return parameters def park(self): """ Parks the TMC300. Important to do at least once after new lamp was started """ pyBen.build_system_model(self.path_cfg) pyBen.load_setup(self.path_atr) pyBen.initialise() pyBen.park() print('TMC300 initialized and parked') self.parked = 1 def drive(self, wavelength): """ Changes the probe wavelength """ pyBen.build_system_model(self.path_cfg) pyBen.load_setup(self.path_atr) pyBen.initialise() pyBen.select_wavelength(wavelength, 0) print('TMC300 wavelength set to: %0.1f' %wavelength + 'nm') self.wavelength = wavelength self.parked = 0 if __name__ == '__main__': from DeviceManager import DeviceManager dm = DeviceManager() dm.bentham.park() dm.bentham.drive(510)