def __init__(self, section_name, parent):
     super().__init__(section_name, parent)
     self.items["Channel"] = pc.Combo(devices.control.channel_names)
     self.items["level"] = pc.Bool(initial_value=False)
     self.items["gtol"] = pc.Number(initial_value=1e-3, decimals=5)
     self.items["ltol"] = pc.Number(initial_value=1e-2, decimals=5)
     self.items["Apply"] = pc.Bool(initial_value=False)
Beispiel #2
0
 def __init__(self, *args, **kwargs):
     self.kind = "spectrometer"
     mirror_list = ["front", "side"]
     self.entrance_mirror = pc.Combo(
         allowed_values=mirror_list,
         display=True,
     )
     self.exit_mirror = pc.Combo(
         allowed_values=mirror_list,
         display=True,
     )
     self.slit_limits = pc.NumberLimits(min_value=0,
                                        max_value=7,
                                        units="mm")
     self.front_entrance_slit = pc.Number(limits=self.slit_limits,
                                          units="mm",
                                          display=True)
     self.front_exit_slit = pc.Number(limits=self.slit_limits,
                                      units="mm",
                                      display=True)
     self.side_entrance_slit = pc.Number(limits=self.slit_limits,
                                         units="mm",
                                         display=True)
     self.side_exit_slit = pc.Number(limits=self.slit_limits,
                                     units="mm",
                                     display=True)
     hw.Hardware.__init__(self, *args, **kwargs)
Beispiel #3
0
 def __init__(self, *arks, **kwargs):
     self.kind = "delay"
     self.factor = pc.Number(1, decimals=0, display=True)
     self.motor_limits = pc.NumberLimits(min_value=0, max_value=50, units="mm")
     self.motor_position = pc.Number(units="mm", display=True, limits=self.motor_limits)
     self.zero_position = pc.Number(display=True, units="mm", limits=self.motor_limits)
     hw.Hardware.__init__(self, *arks, **kwargs)
     self.label = pc.String(self.name, display=True)
Beispiel #4
0
 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)
Beispiel #5
0
 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()
Beispiel #6
0
 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)
Beispiel #7
0
 def load_state(self, state):
     self.position = pc.Number(
         initial_value=state.get("position", 0),
         units=self.native_units,
         name="Position",
         display=True,
         set_method="set_position",
         limits=self.limits,
     )
     self.position.set_units(state.get("display_units", self.native_units))
Beispiel #8
0
 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
Beispiel #9
0
 def __init__(self, *args, **kwargs):
     pc.Hardware.__init__(self, *args, **kwargs)
     self.driver.initialized_signal.connect(self.on_address_initialized)
     self.exposed = self.driver.exposed
     for obj in self.exposed:
         obj.updated.connect(self.update)
     self.recorded = self.driver.recorded
     self.offset = self.driver.offset
     self.position = self.exposed[0]
     self.native_units = self.driver.native_units
     self.destination = pc.Number(units=self.native_units, display=True)
     self.destination.write(self.position.read(self.native_units),
                            self.native_units)
     self.limits = self.driver.limits
     hardwares.append(self)
Beispiel #10
0
 def __init__(self, *args, **kwargs):
     self.yaqd_port = kwargs["yaqd_port"]
     self.yaqd_host = kwargs.get("yaqd_host", "127.0.0.1")
     self.client = yaqc.Client(self.yaqd_port, host=self.yaqd_host)
     self.motor_positions = {
         k: pc.Number(name=k, decimals=6, display=True) for k in self.client.get_setable_names()
     }
     hw.Driver.__init__(self, *args, **kwargs)
     self.shutter_port = kwargs.get("shutter_yaqd_port")
     if self.shutter_port:
         self.shutter_position = pc.Bool(name="Shutter", display=True, set_method="set_shutter")
         self.shutter = yaqc.Client(self.shutter_port)
         self.shutter.set_identifier("closed")
         self.exposed += [self.shutter_position]
     self.curve = attune.Instrument(**self.client.get_instrument())
     self.load_curve()
     self.get_motor_positions()
     self.get_position()
Beispiel #11
0
 def __init__(self, *args, **kwargs):
     self.yaqd_port = kwargs["yaqd_port"]
     self.yaqd_host = kwargs.get("yaqd_host", "127.0.0.1")
     self.client = yaqc.Client(self.yaqd_port, host=self.yaqd_host)
     self.client.register_connection_callback(
         signals.updated_attune_store.emit)
     signals.updated_attune_store.connect(self.on_updated_attune_store)
     self.motor_positions = {
         k: pc.Number(name=k, decimals=6, display=True)
         for k in self.client.get_setable_names()
     }
     hw.Driver.__init__(self, *args, **kwargs)
     self.shutter_port = kwargs.get("shutter_yaqd_port")
     if self.shutter_port:
         self.shutter_position = pc.Bool(name="Shutter",
                                         display=True,
                                         set_method="set_shutter")
         self.shutter = yaqc.Client(self.shutter_port)
         self.shutter.set_identifier("closed")
         self.exposed += [self.shutter_position]
     self.on_updated_attune_store()
Beispiel #12
0
 def __init__(self, *args, **kwargs):
     self.freerun = pc.Bool(initial_value=False)
     self.Widget = kwargs.pop("Widget")
     self.data = Data()
     self.active = True
     # shape
     if "shape" in kwargs.keys():
         self.shape = kwargs.pop("shape")
     else:
         self.shape = (1, )
     # map
     if "has_map" in kwargs.keys():
         self.has_map = kwargs.pop("has_map")
     else:
         self.has_map = False
     self.has_map = False  # turning this feature off for now  --Blaise 2020-09-25
     self.measure_time = pc.Number(initial_value=np.nan,
                                   display=True,
                                   decimals=3)
     super().__init__(*args, **kwargs)
     self.settings_updated.emit()
     self.freerun.write(True)
     self.on_freerun_updated()
Beispiel #13
0
 def __init__(self, hardware, **kwargs):
     pc.Driver.__init__(self)
     # basic attributes
     self.hardware = hardware
     self.enqueued = self.hardware.enqueued
     self.busy = self.hardware.busy
     self.name = self.hardware.name
     self.model = self.hardware.model
     self.serial = self.hardware.serial
     self.label = pc.String(kwargs["label"], display=True)
     self.native_units = kwargs["native_units"]
     self.state_filepath = (
         pathlib.Path(appdirs.user_data_dir("yaqc-cmds", "yaqc-cmds")) /
         "hardware" / f"{self.name}-state.toml")
     self.state_filepath.parent.mkdir(parents=True, exist_ok=True)
     # mutex attributes
     self.limits = pc.NumberLimits(units=self.native_units)
     if self.state_filepath.exists():
         state = toml.load(self.state_filepath)
     else:
         state = {}
     self.offset = pc.Number(initial_value=0,
                             units=self.native_units,
                             name="Offset",
                             display=True)
     self.load_state(state)
     # attributes for 'exposure'
     self.exposed = [self.position]
     self.recorded = collections.OrderedDict()
     print(self.name, type(self.name))
     self.recorded[self.name] = [
         self.position,
         self.native_units,
         1.0,
         self.label.read(),
         False,
     ]
 def __init__(self, section_name, parent):
     super().__init__(section_name, parent)
     self.items["Motor"] = pc.Combo()
     self.items["Width"] = pc.Number(initial_value=1, decimals=3)
     self.items["Num"] = pc.Number(initial_value=31, decimals=0)
 def __init__(self, section_name, parent):
     super().__init__(section_name, parent)
     self.items["Axis"] = pc.Combo()
     self.items["Width"] = pc.Number(initial_value=-250)
     self.items["Num"] = pc.Number(initial_value=51, decimals=0)
Beispiel #16
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()