|
| 1 | +##################################################################### |
| 2 | +# # |
| 3 | +# /labscript_devices/ZaberStageController/blacs_tabs.py # |
| 4 | +# # |
| 5 | +# Copyright 2019, Monash University and contributors # |
| 6 | +# # |
| 7 | +# This file is part of labscript_devices, in the labscript suite # |
| 8 | +# (see http://labscriptsuite.org), and is licensed under the # |
| 9 | +# Simplified BSD License. See the license.txt file in the root of # |
| 10 | +# the project for the full license. # |
| 11 | +# # |
| 12 | +##################################################################### |
| 13 | + |
| 14 | +from blacs.device_base_class import DeviceTab |
| 15 | +from .utils import get_device_number |
| 16 | + |
| 17 | +class ZaberStageControllerTab(DeviceTab): |
| 18 | + def initialise_GUI(self): |
| 19 | + # Capabilities |
| 20 | + self.base_units = 'steps' |
| 21 | + self.base_min = 0 |
| 22 | + self.base_step = 100 |
| 23 | + self.base_decimals = 0 |
| 24 | + |
| 25 | + device = self.settings['connection_table'].find_by_name(self.device_name) |
| 26 | + self.com_port = device.BLACS_connection |
| 27 | + self.mock = device.properties['mock'] |
| 28 | + |
| 29 | + # Create the AO output objects |
| 30 | + ao_prop = {} |
| 31 | + for stage in device.child_list.values(): |
| 32 | + connection = stage.parent_port |
| 33 | + base_min, base_max = stage.properties['limits'] |
| 34 | + ao_prop[connection] = { |
| 35 | + 'base_unit': self.base_units, |
| 36 | + 'min': base_min, |
| 37 | + 'max': base_max, |
| 38 | + 'step': self.base_step, |
| 39 | + 'decimals': self.base_decimals, |
| 40 | + } |
| 41 | + # Sort by device number: |
| 42 | + ao_prop = {c: ao_prop[c] for c in sorted(ao_prop, key=get_device_number)} |
| 43 | + self.child_connections = list(ao_prop.keys()) |
| 44 | + # Create the output objects |
| 45 | + self.create_analog_outputs(ao_prop) |
| 46 | + # Create widgets for output objects |
| 47 | + _, ao_widgets, _ = self.auto_create_widgets() |
| 48 | + # and auto place the widgets in the UI |
| 49 | + self.auto_place_widgets(("Zaber Stages", ao_widgets)) |
| 50 | + |
| 51 | + # Set the capabilities of this device |
| 52 | + self.supports_remote_value_check(True) |
| 53 | + self.supports_smart_programming(False) #TODO: Implement? |
| 54 | + |
| 55 | + def initialise_workers(self): |
| 56 | + # Create and set the primary worker |
| 57 | + self.create_worker( |
| 58 | + "main_worker", |
| 59 | + "labscript_devices.ZaberStageController.blacs_workers.ZaberWorker", |
| 60 | + { |
| 61 | + 'com_port': self.com_port, |
| 62 | + 'mock': self.mock, |
| 63 | + 'child_connections': self.child_connections, |
| 64 | + }, |
| 65 | + ) |
| 66 | + self.primary_worker = "main_worker" |
0 commit comments