Example #1
0
 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)
Example #2
0
 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)
Example #3
0
 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)
Example #4
0
 def initialize(self):
     self.layout.addWidget(self.scroll_area)
     # attributes
     self.attributes_table.add("Label", self.hardware.label)
     self.scroll_layout.addWidget(self.attributes_table)
     # 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)
Example #5
0
 def add_table_row(self, corr):
     # insert into table
     new_row_index = self.table.rowCount()
     self.table.insertRow(new_row_index)
     # hardware
     label = pw.Label(corr.setpoints.name)
     label.setMargin(3)
     self.table.setCellWidget(new_row_index, 0, label)
     # path
     name = pathlib.Path(corr.path).stem
     label = pw.Label(name)
     label.setMargin(3)
     label.setToolTip(str(corr.path))
     self.table.setCellWidget(new_row_index, 1, label)
     # button
     button = pw.SetButton("REMOVE", color="stop")
     g.queue_control.disable_when_true(button)
     button.setProperty("TableRowIndex", new_row_index)
     button.clicked.connect(
         lambda: self.on_remove_file(button.property("TableRowIndex")))
     self.table.setCellWidget(new_row_index, 2, button)
Example #6
0
    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"))
Example #7
0
 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()