def create_settings(self): # display settings input_table = pw.InputTable() input_table.add("Display", None) self.channel = pc.Combo() input_table.add("Channel", self.channel) self.axis = pc.Combo() input_table.add("X-Axis", self.axis) self.axis_units = pc.Combo() input_table.add("X-Units", self.axis_units) self.settings_layout.addWidget(input_table) # global daq settings input_table = pw.InputTable() input_table.add("Settings", None) # input_table.add("ms Wait", ms_wait) for sensor in sensors.sensors: input_table.add(sensor.name, None) input_table.add("Status", sensor.busy) input_table.add("Freerun", sensor.freerun) input_table.add("Time", sensor.measure_time) input_table.add("Scan", None) # input_table.add("Loop Time", loop_time) self.idx_string = pc.String(initial_value="None", display=True) input_table.add("Scan Index", self.idx_string) self.settings_layout.addWidget(input_table) # stretch self.settings_layout.addStretch(1)
def create_frame(self): # shared settings input_table = pw.InputTable() allowed = [hardware.name for hardware in opas.hardwares] self.opa_combo = pc.Combo(allowed) input_table.add("OPA", self.opa_combo) self.opa_combo.updated.connect(self.on_opa_combo_updated) self.use_tune_points = pc.Bool(initial_value=True) input_table.add("Use Tune Points", self.use_tune_points) self.layout.addWidget(input_table) # motor settings self.opa_guis = [ OPA_GUI(hardware, self.layout, self.use_tune_points) for hardware in opas.hardwares ] self.opa_guis[0].show() # mono settings allowed = ["Set", "Scan", "Static"] self.mono_method_combo = pc.Combo(allowed, disable_under_module_control=True) self.mono_method_combo.updated.connect(self.update_mono_settings) self.mono_center = pc.Number(initial_value=7000, units="wn", disable_under_module_control=True) self.mono_width = pc.Number(initial_value=500, units="wn", disable_under_module_control=True) self.mono_width.set_disabled_units(True) self.mono_npts = pc.Number(initial_value=51, decimals=0, disable_under_module_control=True) input_table = pw.InputTable() input_table.add("Spectrometer", None) input_table.add("Method", self.mono_method_combo) input_table.add("Center", self.mono_center) input_table.add("Width", self.mono_width) input_table.add("Number", self.mono_npts) self.layout.addWidget(input_table) self.update_mono_settings() # processing input_table = pw.InputTable() input_table.add("Processing", None) self.do_post_process = pc.Bool(initial_value=True) input_table.add("Process", self.do_post_process) # TODO: allowed values, update channel_names = list(yaqc_cmds.sensors.get_channels_dict().keys()) if ("main_channel" not in self.state.keys() or self.state["main_channel"] not in channel_names): self.state["main_channel"] = channel_names[0] self.main_channel = pc.Combo( allowed_values=channel_names, initial_value=self.state["main_channel"], ) input_table.add("Channel", self.main_channel) self.layout.addWidget(input_table) sensor_signals.channels_changed.connect( self.on_device_settings_updated)
def create_frame(self): # axes self.axes = [] input_table = pw.InputTable() input_table.add("Axes", None) self.layout.addWidget(input_table) self.axes_container_widget = QtWidgets.QWidget() self.axes_container_widget.setLayout(QtWidgets.QVBoxLayout()) self.axes_container_widget.layout().setMargin(0) self.layout.addWidget(self.axes_container_widget) add_energy_axis_button = pw.SetButton("ADD ENERGY AXIS") add_energy_axis_button.clicked.connect(lambda: self.add_axis("wn")) self.layout.addWidget(add_energy_axis_button) add_delay_axis_button = pw.SetButton("ADD DELAY AXIS") add_delay_axis_button.clicked.connect(lambda: self.add_axis("ps")) self.layout.addWidget(add_delay_axis_button) add_delay_axis_button = pw.SetButton("ADD ANGLE AXIS") add_delay_axis_button.clicked.connect(lambda: self.add_axis("deg")) self.layout.addWidget(add_delay_axis_button) remove_axis_button = pw.SetButton("REMOVE AXIS", "stop") remove_axis_button.clicked.connect(self.remove_axis) self.layout.addWidget(remove_axis_button) # constants self.constants = [] input_table = pw.InputTable() input_table.add("Constants", None) self.layout.addWidget(input_table) self.constants_container_widget = QtWidgets.QWidget() self.constants_container_widget.setLayout(QtWidgets.QVBoxLayout()) self.constants_container_widget.layout().setMargin(0) self.layout.addWidget(self.constants_container_widget) add_constant_button, remove_constant_button = self.add_buttons() add_constant_button.clicked.connect(self.add_constant) remove_constant_button.clicked.connect(self.remove_constant) # processing input_table = pw.InputTable() input_table.add("Processing", None) channel_names = list(yaqc_cmds.sensors.get_channels_dict().keys()) if ( "main_channel" not in self.state.keys() or self.state["main_channel"] not in channel_names ): self.state["main_channel"] = channel_names[0] self.channel_combo = pc.Combo( allowed_values=channel_names, initial_value=self.state["main_channel"], ) self.channel_combo.updated.connect(self.save_state) input_table.add("Main Channel", self.channel_combo) if "process_all_channels" not in self.state.keys(): self.state["process_all_channels"] = False self.process_all_channels = pc.Bool(initial_value=self.state["process_all_channels"]) self.process_all_channels.updated.connect(self.save_state) input_table.add("Process All Channels", self.process_all_channels) self.layout.addWidget(input_table) sensor_signals.channels_changed.connect(self.on_device_settings_updated)
def __init__(self): QtWidgets.QWidget.__init__(self) layout = QtWidgets.QVBoxLayout() self.setLayout(layout) layout.setMargin(0) input_table = pw.InputTable() input_table.add("Virtual", None) self.use = pc.Bool(initial_value=True) input_table.add("Use", self.use) layout.addWidget(input_table)
def create_frame(self): # shared settings input_table = pw.InputTable() self.shutter_state = { hardware.name: pc.Bool() for hardware in opas.hardwares if hardware.driver.shutter_port } for k, v in self.shutter_state.items(): input_table.add(k, v) self.layout.addWidget(input_table)
def initialize(self): self.layout.addWidget(self.scroll_area) # attributes self.attributes_table.add("Label", self.hardware.label) self.attributes_table.add("Factor", self.hardware.factor) self.scroll_layout.addWidget(self.attributes_table) # deg input table input_table = pw.InputTable() input_table.add("Motor Position", None) input_table.add("Current", self.hardware.motor_position) self.motor_destination = self.hardware.motor_position.associate( display=False) input_table.add("Destination", self.motor_destination) self.scroll_layout.addWidget(input_table) # set deg button self.set_motor_button = pw.SetButton("SET POSITION") self.scroll_layout.addWidget(self.set_motor_button) self.set_motor_button.clicked.connect(self.on_set_motor) g.queue_control.disable_when_true(self.set_motor_button) # zero input table input_table = pw.InputTable() input_table.add("Zero Position", None) input_table.add("Current", self.hardware.zero_position) self.zero_destination = self.hardware.zero_position.associate( display=False) input_table.add("Destination", self.zero_destination) self.scroll_layout.addWidget(input_table) # set zero button self.set_zero_button = pw.SetButton("SET ZERO") self.scroll_layout.addWidget(self.set_zero_button) self.set_zero_button.clicked.connect(self.on_set_zero) g.queue_control.disable_when_true(self.set_zero_button) # horizontal line self.scroll_layout.addWidget(pw.line("H")) # home button self.home_button = pw.SetButton("HOME", "advanced") self.scroll_layout.addWidget(self.home_button) self.home_button.clicked.connect(self.on_home) g.queue_control.disable_when_true(self.home_button) # finish self.scroll_layout.addStretch(1) self.layout.addStretch(1) self.hardware.update_ui.connect(self.update)
def create_frame(self): input_table = pw.InputTable() # opa combo allowed = [hardware.name for hardware in opas.hardwares] self.opa_combo = pc.Combo(allowed) input_table.add("OPA", None) input_table.add("OPA", self.opa_combo) self.npts_opa = pc.Number(decimals=0, initial_value=21) input_table.add("npts", self.npts_opa) # delay self.delay = ScanAxisGUI("delay", "") self.delay.start.write(-3) self.delay.stop.write(3) self.delay.number.write(21) input_table.add("Delay", None) self.layout.addWidget(input_table) self.layout.addWidget(self.delay.widget) # constants self.constants = [] input_table = pw.InputTable() input_table.add("Constants", None) self.layout.addWidget(input_table) self.constants_container_widget = QtWidgets.QWidget() self.constants_container_widget.setLayout(QtWidgets.QVBoxLayout()) self.constants_container_widget.layout().setMargin(0) self.layout.addWidget(self.constants_container_widget) add_constant_button, remove_constant_button = self.add_buttons() add_constant_button.clicked.connect(self.add_constant) remove_constant_button.clicked.connect(self.remove_constant) # processing input_table = pw.InputTable() input_table.add("Processing", None) self.channel_combo = pc.Combo( allowed_values=devices.control.channel_names) input_table.add("Channel", self.channel_combo) self.process_level = pc.Bool(initial_value=False) self.process_gtol = pc.Number(initial_value=0, decimals=5) self.process_ltol = pc.Number(initial_value=1e-2, decimals=5) input_table.add("level", self.process_level) input_table.add("gtol", self.process_gtol) input_table.add("ltol", self.process_ltol) # finish self.layout.addWidget(input_table)
def create_frame(self, layout): # container widget display_container_widget = QtWidgets.QWidget() display_container_widget.setLayout(QtWidgets.QVBoxLayout()) display_layout = display_container_widget.layout() display_layout.setMargin(0) layout.addWidget(display_container_widget) # plot self.plot_widget = pw.Plot1D() self.plot_scatter = self.plot_widget.add_scatter() display_layout.addWidget(self.plot_widget) # vertical line line = pw.line("V") layout.addWidget(line) # settings area settings_container_widget = QtWidgets.QWidget() settings_scroll_area = pw.scroll_area(130) settings_scroll_area.setWidget(settings_container_widget) settings_scroll_area.setMinimumWidth(300) settings_scroll_area.setMaximumWidth(300) settings_container_widget.setLayout(QtWidgets.QVBoxLayout()) settings_layout = settings_container_widget.layout() settings_layout.setMargin(5) layout.addWidget(settings_scroll_area) # input table input_table = pw.InputTable() input_table.add("Display", None) self.display_combobox = pc.Combo() self.display_combobox.updated.connect(self.update_display) input_table.add("Hardware", self.display_combobox) input_table.add("Settings", None) self.use_bool = pc.Bool() self.use_bool.updated.connect(self.on_toggle_use) g.queue_control.disable_when_true(self.use_bool) input_table.add("Use", self.use_bool) input_table.add("Current Offset", self.hardware.offset) settings_layout.addWidget(input_table) # add button self.add_button = pw.SetButton("ADD FILE", color="go") self.add_button.clicked.connect(self.on_add_file) g.queue_control.disable_when_true(self.add_button) settings_layout.addWidget(self.add_button) # table self.table = pw.TableWidget() self.table.verticalHeader().hide() self.table.insertColumn(0) self.table.insertColumn(1) self.table.insertColumn(2) self.table.setHorizontalHeaderLabels(["Hardware", "File Name", ""]) self.table.setColumnWidth(0, 100) self.table.setColumnWidth(1, 100) self.table.horizontalHeader().setStretchLastSection(True) settings_layout.addWidget(self.table)
def create_frame(self): # shared settings input_table = pw.InputTable() allowed = [hardware.name for hardware in opas.hardwares] self.opa_combo = pc.Combo(allowed) input_table.add("OPA", self.opa_combo) self.opa_combo.updated.connect(self.on_opa_combo_updated) self.layout.addWidget(input_table) # motor settings self.opa_guis = [ OPA_GUI(hardware, self.layout) for hardware in opas.hardwares ] self.opa_guis[0].show()
def __init__(self): self.widget = pw.InputTable() self.widget.add("Constant", None) # hardware name allowed_values = [h.name for h in all_hardwares] self.hardware_name_combo = pc.Combo(allowed_values=allowed_values) self.hardware_name_combo.write(spectrometers.hardwares[0].name) # self.hardware_name_combo.set_disabled(True) self.widget.add("Hardware", self.hardware_name_combo) # expression opanames = [h.name for h in opas.hardwares] self.expression = pc.String(initial_value="+".join(opanames)) self.widget.add("Expression", self.expression)
def __init__(self, name, center, width, number, use_tune_points): self.name = name self.use_tune_points = use_tune_points self.input_table = pw.InputTable() self.input_table.add(name, None) allowed = ["Set", "Scan", "Static"] self.method = pc.Combo(allowed_values=allowed) if self.use_tune_points is not None: self.use_tune_points.updated.connect(self.update_disabled) self.method.updated.connect(self.update_disabled) self.input_table.add("Method", self.method) self.center = pc.Number(initial_value=center) self.input_table.add("Center", self.center) self.width = pc.Number(initial_value=width) self.input_table.add("Width", self.width) self.npts = pc.Number(initial_value=number, decimals=0) self.input_table.add("Number", self.npts) self.update_disabled()
def __init__(self, units_kind, axis_index): self.units_kind = units_kind if self.units_kind == "energy": self.units = "wn" initial_start = 1500 initial_stop = 1200 elif self.units_kind == "delay": self.units = "ps" initial_start = -1 initial_stop = 1 elif self.units_kind == "angle": self.units = "deg" initial_start = 0.0 initial_stop = 360.0 else: raise ValueError(f"unexpected units kind: {self.units_kind}") self.widget = pw.InputTable() self.widget.add(str(axis_index) + " (" + self.units_kind + ")", None) # start self.start = pc.Number(initial_value=initial_start, units=self.units) self.start.set_disabled_units(True) self.widget.add("Initial", self.start) # stop self.stop = pc.Number(initial_value=initial_stop, units=self.units) self.stop.set_disabled_units(True) self.widget.add("Final", self.stop) # number self.number = pc.Number(initial_value=51, decimals=0) self.widget.add("Number", self.number) # hardwares if self.units_kind == "energy": hardware_objs = opas.hardwares + spectrometers.hardwares elif self.units_kind == "delay": hardware_objs = delays.hardwares elif self.units_kind == "angle": hardware_objs = filters.hardwares self.hardwares = {} for hw in hardware_objs: checkbox = pc.Bool() self.widget.add(hw.name, checkbox) self.hardwares[hw.name] = checkbox
def __init__(self, motor_name, motor_mutex, driver): QtWidgets.QWidget.__init__(self) self.motor_name = motor_name self.driver = driver self.hardware = driver.hardware self.layout = QtWidgets.QVBoxLayout() self.layout.setMargin(0) # table input_table = pw.InputTable() input_table.add(motor_name, motor_mutex) self.destination = motor_mutex.associate(display=False) input_table.add("Dest. " + motor_name, self.destination) self.layout.addWidget(input_table) # buttons home_button, set_button = self.add_buttons(self.layout, "HOME", "advanced", "SET", "set") home_button.clicked.connect(self.on_home) set_button.clicked.connect(self.on_set) g.queue_control.disable_when_true(home_button) g.queue_control.disable_when_true(set_button) # finish self.setLayout(self.layout)
def create_frame(self, layout): """ Runs before initialize. """ # layout layout.setMargin(5) self.layout = layout # scroll area scroll_container_widget = QtWidgets.QWidget() self.scroll_area = pw.scroll_area(show_bar=False) self.scroll_area.setWidget(scroll_container_widget) self.scroll_area.setMinimumWidth(300) self.scroll_area.setMaximumWidth(300) scroll_container_widget.setLayout(QtWidgets.QVBoxLayout()) self.scroll_layout = scroll_container_widget.layout() self.scroll_layout.setMargin(5) # attributes table self.attributes_table = pw.InputTable() self.attributes_table.add("Attributes", None) name = pc.String(self.hardware.name, display=True) self.attributes_table.add("Name", name) model = pc.String(self.hardware.model, display=True) self.attributes_table.add("Model", model) serial = pc.String(self.hardware.serial, display=True) self.attributes_table.add("Serial", serial) self.position = self.hardware.position.associate() self.hardware.position.updated.connect(self.on_position_updated) self.attributes_table.add("Label", self.hardware.driver.label) self.attributes_table.add("Position", self.position) self.offset = self.hardware.offset.associate() self.hardware.offset.updated.connect(self.on_offset_updated) self.attributes_table.add("Offset", self.offset) # initialization if self.hardware.initialized.read(): self.initialize() else: self.hardware.initialized_signal.connect(self.initialize)
def input_table(self): input_table = pw.InputTable() input_table.add(self.section_name, None) for name, item in self.items.items(): input_table.add(name, item) return input_table
def initialize(self): super().initialize() # self.layout.addWidget(self.scroll_area) # attributes mirror_list = ["front", "side"] input_table = pw.InputTable() self.scroll_layout.addWidget(pw.line("H")) has_mirror = False if hasattr(self.driver.ctrl, "set_entrance_mirror"): has_mirror = True input_table.add("Entrance Mirror", None) input_table.add("Current", self.hardware.entrance_mirror) self.entrance_mirror_dest = self.hardware.entrance_mirror.associate( display=False) input_table.add("Destination", self.entrance_mirror_dest) if hasattr(self.driver.ctrl, "set_exit_mirror"): has_mirror = True input_table.add("Exit Mirror", None) input_table.add("Current", self.hardware.exit_mirror) self.exit_mirror_dest = self.hardware.exit_mirror.associate( display=False) input_table.add("Destination", self.exit_mirror_dest) if has_mirror: self.scroll_layout.addWidget(input_table) input_table = pw.InputTable() self.set_mirror_button = pw.SetButton("SET MIRRORS") self.scroll_layout.addWidget(self.set_mirror_button) self.set_mirror_button.clicked.connect(self.on_set_mirror) g.queue_control.disable_when_true(self.set_mirror_button) self.scroll_layout.addWidget(pw.line("H")) has_slit = False if hasattr(self.driver.ctrl, "set_front_entrance_slit"): has_slit = True input_table.add("Front Entrance Slit", None) input_table.add("Current", self.hardware.front_entrance_slit) self.front_entrance_slit_dest = self.hardware.front_entrance_slit.associate( display=False) input_table.add("Destination", self.front_entrance_slit_dest) if hasattr(self.driver.ctrl, "set_side_entrance_slit"): has_slit = True input_table.add("Side Entrance Slit", None) input_table.add("Current", self.hardware.side_entrance_slit) self.side_entrance_slit_dest = self.hardware.side_entrance_slit.associate( display=False) input_table.add("Destination", self.side_entrance_slit_dest) if hasattr(self.driver.ctrl, "set_front_exit_slit"): has_slit = True input_table.add("Front Exit Slit", None) input_table.add("Current", self.hardware.front_exit_slit) self.front_exit_slit_dest = self.hardware.front_exit_slit.associate( display=False) input_table.add("Destination", self.front_exit_slit_dest) if hasattr(self.driver.ctrl, "set_side_exit_slit"): has_slit = True input_table.add("Side Exit Slit", None) input_table.add("Current", self.hardware.side_exit_slit) self.side_exit_slit_dest = self.hardware.side_exit_slit.associate( display=False) input_table.add("Destination", self.side_exit_slit_dest) if has_slit: self.scroll_layout.addWidget(input_table) self.set_slit_button = pw.SetButton("SET SLITS") self.scroll_layout.addWidget(self.set_slit_button) self.set_slit_button.clicked.connect(self.on_set_slit) g.queue_control.disable_when_true(self.set_slit_button) self.scroll_layout.addWidget(pw.line("H"))
def initialize(self): arr = self.driver.get_arrangement() # self.hardware.driver.initialize() # container widget display_container_widget = QtWidgets.QWidget() display_container_widget.setLayout(QtWidgets.QVBoxLayout()) display_layout = display_container_widget.layout() display_layout.setMargin(0) self.layout.addWidget(display_container_widget) # plot self.plot_widget = pw.Plot1D() self.plot_widget.plot_object.setMouseEnabled(False, False) self.plot_curve = self.plot_widget.add_scatter() self.plot_h_line = self.plot_widget.add_infinite_line(angle=0, hide=False) self.plot_v_line = self.plot_widget.add_infinite_line(angle=90, hide=False) display_layout.addWidget(self.plot_widget) # vertical line line = pw.line("V") self.layout.addWidget(line) # container widget / scroll area settings_container_widget = QtWidgets.QWidget() settings_scroll_area = pw.scroll_area() settings_scroll_area.setWidget(settings_container_widget) settings_scroll_area.setMinimumWidth(300) settings_scroll_area.setMaximumWidth(300) settings_container_widget.setLayout(QtWidgets.QVBoxLayout()) settings_layout = settings_container_widget.layout() settings_layout.setMargin(5) self.layout.addWidget(settings_scroll_area) # opa properties input_table = pw.InputTable() settings_layout.addWidget(input_table) # plot control input_table = pw.InputTable() input_table.add("Display", None) self.plot_motor = pc.Combo(allowed_values=self.driver.curve.arrangements[arr].keys()) self.plot_motor.updated.connect(self.update_plot) input_table.add("Motor", self.plot_motor) allowed_values = list(wt.units.energy.keys()) self.plot_units = pc.Combo( initial_value=self.driver.native_units, allowed_values=allowed_values ) self.plot_units.updated.connect(self.update_plot) input_table.add("Units", self.plot_units) settings_layout.addWidget(input_table) # curves input_table = pw.InputTable() # input_table.add("Curves", None) self.arrangement_combo = pc.Combo(allowed_values=self.driver.curve.arrangements.keys()) self.arrangement_combo.write(arr) self.arrangement_combo.updated.connect(self.on_arrangement_updated) input_table.add("Arrangement", self.arrangement_combo) # limits limits = pc.NumberLimits() # units None self.low_energy_limit_display = pc.Number( units=self.driver.native_units, display=True, limits=limits ) input_table.add("Low Energy Limit", self.low_energy_limit_display) self.high_energy_limit_display = pc.Number( units=self.driver.native_units, display=True, limits=limits ) input_table.add("High Energy Limit", self.high_energy_limit_display) settings_layout.addWidget(input_table) self.driver.limits.updated.connect(self.on_limits_updated) # motors input_table = pw.InputTable() input_table.add("Setable", None) settings_layout.addWidget(input_table) for motor_name, motor_mutex in self.driver.motor_positions.items(): settings_layout.addWidget(MotorControlGUI(motor_name, motor_mutex, self.driver)) self.home_all_button = pw.SetButton("HOME ALL", "advanced") settings_layout.addWidget(self.home_all_button) self.home_all_button.clicked.connect(self.on_home_all) g.queue_control.disable_when_true(self.home_all_button) # stretch settings_layout.addStretch(1) # signals and slots self.arrangement_combo.updated.connect(self.update_plot) self.driver.update_ui.connect(self.update) # finish self.update() self.update_plot() self.on_limits_updated()
def __init__(self, name, home): self.name = name self.input_table = pw.InputTable() self.input_table.add(name, None) self.home = pc.Bool(initial_value=home) self.input_table.add("Home", self.home)