Example #1
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.name_text = ui.Text(value="Unnamed")
     self.x_number = ui.Number(value=0.,
                               minimum=0.,
                               maximum=1000.,
                               decimals=3,
                               suffix="mm")
     self.y_number = ui.Number(value=0.,
                               minimum=0.,
                               maximum=1000.,
                               decimals=3,
                               suffix="mm")
     self.z_number = ui.Number(value=0.,
                               minimum=0.,
                               maximum=1000.,
                               decimals=3,
                               suffix="mm")
     self.comment_text = ui.Text()
     self.button_box = ui.DialogButtonBox(buttons=("ok", "cancel"),
                                          accepted=self.accept,
                                          rejected=self.reject)
     self.layout = ui.Column(
         ui.Label("Name", tool_tip="Position name"), self.name_text,
         ui.Label("X", tool_tip="Position X coordinate"), self.x_number,
         ui.Label("Y", tool_tip="Position Y coordinate"), self.y_number,
         ui.Label("Z", tool_tip="Position Z coordinate"), self.z_number,
         ui.Label("Comment", tool_tip="Optional position comment"),
         self.comment_text, self.button_box)
Example #2
0
    def __init__(self):
        super().__init__(title="Environment")

        # Data series
        self.box_temperature_series = []
        self.chuck_temperature_series = []
        self.box_humidity_series = []

        # Plot
        self.plot = ui.Plot(legend="right")
        self.plot.add_axis("x", align="bottom", type="datetime")
        self.plot.add_axis("y1",
                           align="left",
                           text="Temperature [°C]",
                           color="red")
        self.plot.add_axis("y2",
                           align="right",
                           text="Humidity [%rH]",
                           color="blue")
        self.plot.add_series("box_temperature",
                             "x",
                             "y1",
                             text="Box Temperature",
                             color="red")
        self.plot.add_series("chuck_temperature",
                             "x",
                             "y1",
                             text="Chuck Temperature",
                             color="magenta")
        self.plot.add_series("box_humidity",
                             "x",
                             "y2",
                             text="Box Humidity",
                             color="blue")

        # Inputs
        self.box_temperature_number = ui.Number(suffix="°C",
                                                decimals=1,
                                                readonly=True)
        self.box_humidity_number = ui.Number(suffix="%rH",
                                             decimals=1,
                                             readonly=True)
        self.chuck_temperature_number = ui.Number(suffix="°C",
                                                  decimals=1,
                                                  readonly=True)
        self.box_lux_number = ui.Number(suffix="Lux",
                                        decimals=1,
                                        readonly=True)
        self.box_light_text = ui.Text(readonly=True)
        self.box_door_text = ui.Text(readonly=True)

        # Layout
        self.layout = ui.Column(
            self.plot,
            ui.Label("Box Temperature"), self.box_temperature_number,
            ui.Label("Box Humidity"), self.box_humidity_number,
            ui.Label("Chuck Temperature"), self.chuck_temperature_number,
            ui.Label("Box Light"), self.box_lux_number,
            ui.Label("Box Light State"), self.box_light_text,
            ui.Label("Box Door State"), self.box_door_text, ui.Spacer())
Example #3
0
 def __init__(self, reload=None):
     super().__init__(title="Status")
     self.reload = reload
     self.matrix_model_text = ui.Text(readonly=True)
     self.matrix_channels_text = ui.Text(readonly=True)
     self.hvsrc_model_text = ui.Text(readonly=True)
     self.vsrc_model_text = ui.Text(readonly=True)
     self.lcr_model_text = ui.Text(readonly=True)
     self.elm_model_text = ui.Text(readonly=True)
     self.table_model_text = ui.Text(readonly=True)
     self.table_state_text = ui.Text(readonly=True)
     self.env_model_text = ui.Text(readonly=True)
     self.reload_status_button = ui.Button("&Reload",
                                           clicked=self.on_reload)
     self.layout = ui.Column(
         ui.GroupBox(title="Matrix",
                     layout=ui.Column(
                         ui.Row(ui.Label("Model:"),
                                self.matrix_model_text,
                                stretch=(1, 7)),
                         ui.Row(ui.Label("Closed channels:"),
                                self.matrix_channels_text,
                                stretch=(1, 7)))),
         ui.GroupBox(title="HVSource",
                     layout=ui.Row(ui.Label("Model:"),
                                   self.hvsrc_model_text,
                                   stretch=(1, 7))),
         ui.GroupBox(title="VSource",
                     layout=ui.Row(ui.Label("Model:"),
                                   self.vsrc_model_text,
                                   stretch=(1, 7))),
         ui.GroupBox(title="LCRMeter",
                     layout=ui.Row(ui.Label("Model:"),
                                   self.lcr_model_text,
                                   stretch=(1, 7))),
         ui.GroupBox(title="Electrometer",
                     layout=ui.Row(ui.Label("Model:"),
                                   self.elm_model_text,
                                   stretch=(1, 7))),
         ui.GroupBox(title="Table",
                     layout=ui.Column(
                         ui.Row(ui.Label("Model:"),
                                self.table_model_text,
                                stretch=(1, 7)),
                         ui.Row(ui.Label("State:"),
                                self.table_state_text,
                                stretch=(1, 7)))),
         ui.GroupBox(title="Environment Box",
                     layout=ui.Column(
                         ui.Row(ui.Label("Model:"),
                                self.env_model_text,
                                stretch=(1, 7)))), ui.Spacer(),
         self.reload_status_button)
Example #4
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self._step_size_number = ui.Number(value=0.,
                                        minimum=0.,
                                        maximum=1000.,
                                        decimals=3,
                                        suffix="mm")
     self._z_limit_number = ui.Number(value=0.,
                                      minimum=0.,
                                      maximum=1000.,
                                      decimals=3,
                                      suffix="mm",
                                      visible=False)
     self._step_color_text = ui.Text()
     self._button_box = ui.DialogButtonBox(buttons=("ok", "cancel"),
                                           accepted=self.accept,
                                           rejected=self.reject)
     self.layout = ui.Column(
         ui.Label("Size", tool_tip="Step size in millimeters"),
         self._step_size_number,
         ui.Label("Z-Limit",
                  tool_tip="Z-Limit in millimeters",
                  visible=False), self._z_limit_number,
         ui.Label("Color", tool_tip="Color code for step"),
         self._step_color_text, self._button_box)
Example #5
0
 def __init__(self):
     super().__init__(title="Webserver")
     self._enabled_checkbox = ui.CheckBox(
         text="Enable Server"
     )
     self._host_text = ui.Text()
     self._port_number = ui.Number(
         minimum=0,
         maximum=99999,
         step=1
     )
     self.layout = ui.Column(
         ui.GroupBox(
                 title="JSON API",
                 layout=ui.Column(
                 self._enabled_checkbox,
                 ui.Row(
                     ui.Column(
                         ui.Label("Host"),
                         ui.Label("Port"),
                     ),
                     ui.Column(
                         self._host_text,
                         self._port_number,
                     ),
                     ui.Spacer()
                 ),
                 ui.Spacer(),
                 stretch=(0, 0, 1)
             )
         ),
         ui.Spacer(),
         stretch=(0, 1)
     )
Example #6
0
 def __init__(self, sample_changed=None, **kwargs):
     super().__init__(**kwargs)
     # Properties
     self.title = "Sample"
     # Callbacks
     self.sample_changed = sample_changed
     # Layout
     self._sample_name_prefix_text = ui.Text(
         tool_tip="Sample name prefix",
         clearable=True,
         editing_finished=self.on_sample_name_edited)
     self._sample_name_infix_text = ui.Text(
         tool_tip="Sample name",
         clearable=True,
         editing_finished=self.on_sample_name_edited)
     self._sample_name_suffix_text = ui.Text(
         tool_tip="Sample name suffix",
         clearable=True,
         editing_finished=self.on_sample_name_edited)
     self._sample_type_text = ui.Text(
         tool_tip="Sample type",
         clearable=True,
         editing_finished=self.on_sample_name_edited)
     self._sample_position_text = ui.Text(
         tool_tip="Sample position on the chuck",
         clearable=True,
         editing_finished=self.on_sample_position_edited)
     self._sequence_text = ui.Text(readonly=True)
     self._sample_comment_text = ui.Text(
         tool_tip="Sample comment (optional)",
         clearable=True,
         editing_finished=self.on_sample_comment_edited)
     self._reload_button = ui.ToolButton(
         icon=make_path('assets', 'icons', 'reload.svg'),
         tool_tip="Reload sequence configuration from file.",
         clicked=self.on_reload_clicked)
     self._sequence_manager_button = ui.ToolButton(
         icon=make_path('assets', 'icons', 'gear.svg'),
         tool_tip="Open sequence manager",
         clicked=self.on_sequence_manager_clicked)
     self._sample_groupbox = ui.GroupBox(
         title="Sample",
         layout=ui.Row(ui.Column(ui.Label("Name"), ui.Label("Type"),
                                 ui.Label("Position"), ui.Label("Comment"),
                                 ui.Label("Sequence")),
                       ui.Column(
                           ui.Row(self._sample_name_prefix_text,
                                  self._sample_name_infix_text,
                                  self._sample_name_suffix_text,
                                  stretch=(3, 7, 3)),
                           self._sample_type_text,
                           self._sample_position_text,
                           self._sample_comment_text,
                           ui.Row(self._sequence_text,
                                  self._reload_button,
                                  self._sequence_manager_button,
                                  stretch=(1, 0))),
                       stretch=(0, 1)))
     self.layout.insert(2, self._sample_groupbox)
Example #7
0
    def register_environment(self):
        self.status_env_chuck_temperature = ui.Text(value=NO_VALUE,
                                                    readonly=True)
        self.status_env_box_temperature = ui.Text(value=NO_VALUE,
                                                  readonly=True)
        self.status_env_box_humidity = ui.Text(value=NO_VALUE, readonly=True)

        self.bind("status_env_chuck_temperature",
                  self.status_env_chuck_temperature, NO_VALUE)
        self.bind("status_env_box_temperature",
                  self.status_env_box_temperature, NO_VALUE)
        self.bind("status_env_box_humidity", self.status_env_box_humidity,
                  NO_VALUE)

        self.status_panel.append(
            ui.GroupBox(title="Environment Status",
                        layout=ui.Column(
                            ui.Row(
                                ui.Column(ui.Label("Chuck temp."),
                                          self.status_env_chuck_temperature),
                                ui.Column(ui.Label("Box temp."),
                                          self.status_env_box_temperature),
                                ui.Column(ui.Label("Box humid."),
                                          self.status_env_box_humidity)))))

        def handler(state):
            if 'env_chuck_temperature' in state:
                value = state.get('env_chuck_temperature', )
                self.status_env_chuck_temperature.value = format_metric(
                    value, "°C", decimals=2)
            if 'env_box_temperature' in state:
                value = state.get('env_box_temperature')
                self.status_env_box_temperature.value = format_metric(
                    value, "°C", decimals=2)
            if 'env_box_humidity' in state:
                value = state.get('env_box_humidity')
                self.status_env_box_humidity.value = format_metric(value,
                                                                   "%rH",
                                                                   decimals=2)

        self.state_handlers.append(handler)
Example #8
0
 def __init__(self, position_picked=None, **kwargs):
     super().__init__(**kwargs)
     self.position_picked = position_picked
     self._name_text = ui.Text(value="Unnamed")
     self._x_number = ui.Number(value=0.,
                                minimum=0.,
                                maximum=1000.,
                                decimals=3,
                                suffix="mm")
     self._y_number = ui.Number(value=0.,
                                minimum=0.,
                                maximum=1000.,
                                decimals=3,
                                suffix="mm")
     self._z_number = ui.Number(value=0.,
                                minimum=0.,
                                maximum=1000.,
                                decimals=3,
                                suffix="mm")
     self._comment_text = ui.Text()
     self._assign_button = ui.Button(
         text="Assign Position",
         tool_tip="Assign current table position.",
         clicked=self.on_assign_clicked)
     self._button_box = ui.DialogButtonBox(buttons=("ok", "cancel"),
                                           accepted=self.accept,
                                           rejected=self.reject)
     self.layout = ui.Column(
         ui.Label("Name", tool_tip="Position name"), self._name_text,
         ui.Row(
             ui.Column(ui.Label("X", tool_tip="Position X coordinate"),
                       self._x_number),
             ui.Column(ui.Label("Y", tool_tip="Position Y coordinate"),
                       self._y_number),
             ui.Column(ui.Label("Z", tool_tip="Position Z coordinate"),
                       self._z_number),
             ui.Column(
                 ui.Spacer(),
                 self._assign_button,
             )), ui.Label("Comment", tool_tip="Optional position comment"),
         self._comment_text, ui.Spacer(), self._button_box)
Example #9
0
def main():
    app = comet.Application()
    app.title = "UI Demo"

    values = ["Chapman", "Cleese", "Gilliam", "Idle", "Jones", "Palin"]

    tab1 = ui.Tab(title="Tab 1",
                  layout=ui.Column(
                      ui.Row(ui.Column(
                          ui.GroupBox(title="Numbers",
                                      layout=ui.Column(
                                          ui.Label(text="Number 1"),
                                          ui.Number(value=1,
                                                    minimum=0,
                                                    maximum=10,
                                                    step=1,
                                                    prefix="#"),
                                          ui.Label(text="Number 2"),
                                          ui.Number(value=2.345,
                                                    minimum=0,
                                                    maximum=10,
                                                    step=.1,
                                                    decimals=3,
                                                    suffix="mV"),
                                          ui.Label(text="Number 3"),
                                          ui.Number(value=1.23,
                                                    minimum=0,
                                                    maximum=10,
                                                    decimals=2,
                                                    suffix="mA",
                                                    readonly=True),
                                          ui.Label(text="Number 4"),
                                          ui.Number(value=4.2,
                                                    minimum=0,
                                                    maximum=10,
                                                    decimals=1,
                                                    suffix="dB",
                                                    enabled=False)))),
                             ui.Column(
                                 ui.GroupBox(title="Text",
                                             layout=ui.Column(
                                                 ui.Label(text="Text 1"),
                                                 ui.Text(value="Chapman"),
                                                 ui.Label(text="Text 2"),
                                                 ui.Text(value="Cleese",
                                                         clearable=True),
                                                 ui.Label(text="Text 3"),
                                                 ui.Text(value="Idle",
                                                         readonly=True),
                                                 ui.Label(text="Text 4"),
                                                 ui.Text(value="Palin",
                                                         enabled=False)))),
                             ui.Spacer(),
                             stretch=(2, 2, 3)),
                      ui.Spacer(),
                      stretch=(0, 1)))

    def on_append():
        list1.append(f"Spam {len(list1)}")
        list1.current = list1[0]

    def on_remove():
        if list1.current is not None:
            list1.remove(list1.current)

    list1 = ui.List()
    tab2 = ui.Tab(title="Tab 2",
                  layout=ui.Column(ui.Row(
                      ui.GroupBox(title="List 1",
                                  layout=ui.Column(
                                      list1,
                                      ui.Button(text="&Add",
                                                clicked=on_append),
                                      ui.Button(text="&Remove",
                                                clicked=on_remove))),
                      ui.GroupBox(title="List 2", layout=ui.List(values)),
                      ui.GroupBox(title="List 3",
                                  layout=ui.List(values, enabled=False))),
                                   ui.Spacer(),
                                   stretch=(0, 1)))

    table1 = ui.Table(header=["Key", "Value"])
    tab3 = ui.Tab(title="Tab 3", layout=ui.Column(table1))

    tree1 = ui.Tree(header=["Key", "Value"])
    tab4 = ui.Tab(title="Tab 4", layout=ui.Column(tree1))

    first = ui.Button(text="Click")
    scroll = ui.ScrollArea(layout=ui.Column(*[
        ui.CheckBox(text=f"Option {i+1}", checked=random.choice([True, False]))
        for i in range(64)
    ]))
    second = ui.Column(scroll)
    tab5 = ui.Tab(title="Tab 5", layout=first)
    tab5.layout = second
    del first

    tab6 = ui.Tab(title="Tab 6",
                  layout=ui.Row(ui.Column(
                      ui.Label("Metric 1"),
                      ui.Metric('V',
                                decimals=3,
                                changed=lambda value: print(value)),
                      ui.Label("Metric 2"),
                      ui.Metric('A',
                                prefixes='munp',
                                changed=lambda value: print(value)),
                      ui.Spacer()),
                                ui.Spacer(),
                                stretch=(1, 2)))

    def on_changed(value):
        app.message = value

    def on_click():
        app.message = combobox1.current

    tabs = ui.Tabs(tab1, tab2, tab3, tab4, tab5, tab6)
    combobox1 = ui.ComboBox(values)

    app.layout = ui.Row(ui.Column(
        ui.GroupBox(title="GroupBox 1",
                    layout=ui.Column(
                        ui.Button(text="Button 1", clicked=on_click),
                        ui.Button(text="Button 2", enabled=False),
                        ui.Button(text="Button 3", checkable=True),
                        ui.Button(text="Button 4",
                                  checkable=True,
                                  enabled=False),
                        ui.Button(text="Button 5",
                                  checkable=True,
                                  checked=True))),
        ui.GroupBox(title="GroupBox 2",
                    layout=ui.Column(
                        ui.CheckBox(text="CheckBox 1"),
                        ui.CheckBox(text="CheckBox 2", enabled=False),
                        ui.CheckBox(text="CheckBox 3",
                                    checked=True,
                                    enabled=False),
                        ui.CheckBox(text="CheckBox 4", checked=True))),
        ui.GroupBox(title="GroupBox 3",
                    layout=ui.Column(
                        ui.ComboBox(), combobox1,
                        ui.ComboBox(values,
                                    current="Cleese",
                                    changed=on_changed),
                        ui.ComboBox(values, current="Idle", enabled=False))),
        ui.Spacer()),
                        tabs,
                        stretch=(2, 7))

    # Populate table
    spam = table1.append(["Spam", 42])
    spam[0].checked = True
    #spam[0].enabled = False
    ham = table1.append(["Ham", 41])
    ham[0].checked = True
    #ham[0].enabled = False

    # Populate tree
    spam = tree1.append(["Spam", 42])
    spam[0].checked = True
    spam.append(["Ham", 41])
    spam.append(["Eggs", 40])

    # Add an remove tab
    tab = ui.Tab()
    tabs.insert(0, tab)
    tab.title = "Spam"
    tabs.remove(tab)

    app.message = "Notification message..."
    app.progress = 3, 4

    return app.run()
Example #10
0
    def register_lcr(self):
        def change_lcr_open_correction_mode(mode):
            self.lcr_open_correction_channel.enabled = mode == "multi"

        self.lcr_integration_time = ui.ComboBox(["short", "medium", "long"])
        self.lcr_averaging_rate = ui.Number(minimum=1, maximum=256, decimals=0)
        self.lcr_auto_level_control = ui.CheckBox(text="Auto Level Control")
        self.lcr_soft_filter = ui.CheckBox(text="Filter STD/mean < 0.005")
        self.lcr_open_correction_mode = ui.ComboBox(
            ["single", "multi"], changed=change_lcr_open_correction_mode)
        self.lcr_open_correction_channel = ui.Number(minimum=0,
                                                     maximum=127,
                                                     decimals=0)

        change_lcr_open_correction_mode(self.lcr_open_correction_mode.current)

        self.bind("lcr_integration_time", self.lcr_integration_time, "medium")
        self.bind("lcr_averaging_rate", self.lcr_averaging_rate, 1)
        self.bind("lcr_auto_level_control", self.lcr_auto_level_control, True)
        self.bind("lcr_soft_filter", self.lcr_soft_filter, True)
        self.bind("lcr_open_correction_mode", self.lcr_open_correction_mode,
                  "single")
        self.bind("lcr_open_correction_channel",
                  self.lcr_open_correction_channel, 0)

        self.status_lcr_voltage = ui.Text(value=NO_VALUE, readonly=True)
        self.status_lcr_current = ui.Text(value=NO_VALUE, readonly=True)
        self.status_lcr_output = ui.Text(value=NO_VALUE, readonly=True)

        self.bind("status_lcr_voltage", self.status_lcr_voltage, NO_VALUE)
        self.bind("status_lcr_current", self.status_lcr_current, NO_VALUE)
        self.bind("status_lcr_output", self.status_lcr_output, NO_VALUE)

        self.status_panel.append(
            ui.GroupBox(title="LCR Status",
                        layout=ui.Row(
                            ui.Column(ui.Label("Voltage"),
                                      self.status_lcr_voltage),
                            ui.Column(ui.Label("Current"),
                                      self.status_lcr_current),
                            ui.Column(ui.Label("Output"),
                                      self.status_lcr_output))))

        self.control_tabs.append(
            ui.Tab(title="LCR",
                   layout=ui.Row(
                       ui.GroupBox(title="Open Correction",
                                   layout=ui.Column(
                                       ui.Label(text="Method"),
                                       self.lcr_open_correction_mode,
                                       ui.Label(text="Channel"),
                                       self.lcr_open_correction_channel,
                                       ui.Spacer())),
                       ui.GroupBox(title="Options",
                                   layout=ui.Column(
                                       ui.Label(text="Integration Time"),
                                       self.lcr_integration_time,
                                       ui.Label(text="Averaging Rate"),
                                       self.lcr_averaging_rate,
                                       self.lcr_auto_level_control,
                                       self.lcr_soft_filter, ui.Spacer())),
                       ui.Spacer(),
                       stretch=(1, 1, 1))))

        def handler(state):
            if 'lcr_voltage' in state:
                value = state.get('lcr_voltage')
                self.status_lcr_voltage.value = format_metric(value, "V")
            if 'lcr_current' in state:
                value = state.get('lcr_current')
                self.status_lcr_current.value = format_metric(value, "A")
            if 'lcr_output' in state:
                value = state.get('lcr_output')
                self.status_lcr_output.value = format_switch(value,
                                                             default=NO_VALUE)

        self.state_handlers.append(handler)
Example #11
0
    def register_electrometer(self):
        def toggle_elm_filter(enabled):
            self.elm_filter_count.enabled = enabled
            self.elm_filter_count_label.enabled = enabled
            self.elm_filter_type.enabled = enabled
            self.elm_filter_type_label.enabled = enabled

        self.elm_filter_enable = ui.CheckBox(text="Enable",
                                             changed=toggle_elm_filter)
        self.elm_filter_count = ui.Number(minimum=0, maximum=100, decimals=0)
        self.elm_filter_count_label = ui.Label(text="Count")
        self.elm_filter_type = ui.ComboBox(["repeat", "moving"])
        self.elm_filter_type_label = ui.Label(text="Type")

        self.elm_zero_correction = ui.CheckBox(text="Zero Correction")
        self.elm_integration_rate = ui.Number(minimum=0,
                                              maximum=100.0,
                                              decimals=2,
                                              suffix="Hz")

        def toggle_elm_current_autorange(enabled):
            self.elm_current_range.enabled = not enabled
            self.elm_current_autorange_minimum.enabled = enabled
            self.elm_current_autorange_maximum.enabled = enabled

        self.elm_current_range = ui.Metric(minimum=0,
                                           decimals=3,
                                           prefixes='munp',
                                           unit="A")
        self.elm_current_autorange_enable = ui.CheckBox(
            text="Enable", changed=toggle_elm_current_autorange)
        self.elm_current_autorange_minimum = ui.Metric(minimum=0,
                                                       decimals=3,
                                                       prefixes='munp',
                                                       unit="A")
        self.elm_current_autorange_maximum = ui.Metric(minimum=0,
                                                       decimals=3,
                                                       prefixes='munp',
                                                       unit="A")

        toggle_elm_filter(False)
        toggle_elm_current_autorange(False)

        self.bind("elm_filter_enable", self.elm_filter_enable, False)
        self.bind("elm_filter_count", self.elm_filter_count, 10)
        self.bind("elm_filter_type", self.elm_filter_type, "repeat")
        self.bind("elm_zero_correction", self.elm_zero_correction, False)
        self.bind("elm_integration_rate", self.elm_integration_rate, 50.0)
        self.bind("elm_current_range",
                  self.elm_current_range,
                  20e-12,
                  unit="A")
        self.bind("elm_current_autorange_enable",
                  self.elm_current_autorange_enable, False)
        self.bind("elm_current_autorange_minimum",
                  self.elm_current_autorange_minimum,
                  2.0E-11,
                  unit="A")
        self.bind("elm_current_autorange_maximum",
                  self.elm_current_autorange_maximum,
                  2.0E-2,
                  unit="A")

        self.status_elm_current = ui.Text(value=NO_VALUE, readonly=True)

        self.bind("status_elm_current", self.status_elm_current, NO_VALUE)

        self.status_panel.append(
            ui.GroupBox(title="Electrometer Status",
                        layout=ui.Column(
                            ui.Row(ui.Column(ui.Label("Current"),
                                             self.status_elm_current),
                                   ui.Spacer(),
                                   stretch=(1, 2)))))

        self.control_tabs.append(
            ui.Tab(
                title="Electrometer",
                layout=ui.Row(
                    ui.GroupBox(title="Filter",
                                layout=ui.Column(self.elm_filter_enable,
                                                 self.elm_filter_count_label,
                                                 self.elm_filter_count,
                                                 self.elm_filter_type_label,
                                                 self.elm_filter_type,
                                                 ui.Spacer())),
                    ui.Column(
                        ui.GroupBox(title="Range",
                                    layout=ui.Column(
                                        ui.Label(text="Current Range"),
                                        self.elm_current_range,
                                    )),
                        ui.GroupBox(title="Auto Range",
                                    layout=ui.Column(
                                        self.elm_current_autorange_enable,
                                        ui.Label(text="Minimum Current"),
                                        self.elm_current_autorange_minimum,
                                        ui.Label(text="Maximum Current"),
                                        self.elm_current_autorange_maximum,
                                        ui.Spacer()))),
                    ui.GroupBox(title="Options",
                                layout=ui.Column(
                                    self.elm_zero_correction,
                                    ui.Label(text="Integration Rate"),
                                    self.elm_integration_rate, ui.Spacer())),
                    ui.Spacer(),
                    stretch=(1, 1, 1))))

        def handler(state):
            if 'elm_current' in state:
                value = state.get('elm_current')
                self.status_elm_current.value = format_metric(value, "A")

        self.state_handlers.append(handler)
Example #12
0
    def register_vsource(self):
        self.hvsrc_sense_mode = ui.ComboBox(["local", "remote"])
        self.hvsrc_route_terminal = ui.ComboBox(["front", "rear"])

        def toggle_hvsrc_filter(enabled):
            self.hvsrc_filter_count.enabled = enabled
            self.hvsrc_filter_count_label.enabled = enabled
            self.hvsrc_filter_type.enabled = enabled
            self.hvsrc_filter_type_label.enabled = enabled

        self.hvsrc_filter_enable = ui.CheckBox(text="Enable",
                                               changed=toggle_hvsrc_filter)
        self.hvsrc_filter_count = ui.Number(minimum=0, maximum=100, decimals=0)
        self.hvsrc_filter_count_label = ui.Label(text="Count")
        self.hvsrc_filter_type = ui.ComboBox(["repeat", "moving"])
        self.hvsrc_filter_type_label = ui.Label(text="Type")

        def toggle_hvsrc_source_voltage_autorange(enabled):
            self.hvsrc_source_voltage_range.enabled = not enabled

        self.hvsrc_source_voltage_autorange_enable = ui.CheckBox(
            text="Autorange", changed=toggle_hvsrc_source_voltage_autorange)
        self.hvsrc_source_voltage_range = ui.Number(minimum=-1100,
                                                    maximum=1100,
                                                    decimals=1,
                                                    suffix="V")

        toggle_hvsrc_filter(False)
        toggle_hvsrc_source_voltage_autorange(False)

        self.bind("hvsrc_sense_mode", self.hvsrc_sense_mode, "local")
        self.bind("hvsrc_route_terminal", self.hvsrc_route_terminal, "rear")
        self.bind("hvsrc_filter_enable", self.hvsrc_filter_enable, False)
        self.bind("hvsrc_filter_count", self.hvsrc_filter_count, 10)
        self.bind("hvsrc_filter_type", self.hvsrc_filter_type, "repeat")
        self.bind("hvsrc_source_voltage_autorange_enable",
                  self.hvsrc_source_voltage_autorange_enable, True)
        self.bind("hvsrc_source_voltage_range",
                  self.hvsrc_source_voltage_range,
                  20,
                  unit="V")

        self.status_hvsrc_voltage = ui.Text(value=NO_VALUE, readonly=True)
        self.status_hvsrc_current = ui.Text(value=NO_VALUE, readonly=True)
        self.status_hvsrc_output = ui.Text(value=NO_VALUE, readonly=True)

        self.bind("status_hvsrc_voltage", self.status_hvsrc_voltage, NO_VALUE)
        self.bind("status_hvsrc_current", self.status_hvsrc_current, NO_VALUE)
        self.bind("status_hvsrc_output", self.status_hvsrc_output, NO_VALUE)

        self.status_panel.append(
            ui.GroupBox(title="HV Source Status",
                        layout=ui.Column(
                            ui.Row(
                                ui.Column(ui.Label("Voltage"),
                                          self.status_hvsrc_voltage),
                                ui.Column(ui.Label("Current"),
                                          self.status_hvsrc_current),
                                ui.Column(ui.Label("Output"),
                                          self.status_hvsrc_output)))))

        self.control_tabs.append(
            ui.Tab(
                title="HV Source",
                layout=ui.Row(
                    ui.GroupBox(title="Filter",
                                layout=ui.Column(self.hvsrc_filter_enable,
                                                 self.hvsrc_filter_count_label,
                                                 self.hvsrc_filter_count,
                                                 self.hvsrc_filter_type_label,
                                                 self.hvsrc_filter_type,
                                                 ui.Spacer())),
                    ui.GroupBox(title="Source Voltage Range",
                                layout=ui.Column(
                                    self.hvsrc_source_voltage_autorange_enable,
                                    ui.Label(text="Range"),
                                    self.hvsrc_source_voltage_range,
                                    ui.Spacer())),
                    ui.GroupBox(title="Options",
                                layout=ui.Column(
                                    ui.Label(text="Sense Mode"),
                                    self.hvsrc_sense_mode,
                                    ui.Label(text="Route Terminal"),
                                    self.hvsrc_route_terminal, ui.Spacer())),
                    stretch=(1, 1, 1))))

        def handler(state):
            if 'hvsrc_voltage' in state:
                value = state.get('hvsrc_voltage')
                self.status_hvsrc_voltage.value = format_metric(value, "V")
            if 'hvsrc_current' in state:
                value = state.get('hvsrc_current')
                self.status_hvsrc_current.value = format_metric(value, "A")
            if 'hvsrc_output' in state:
                value = state.get('hvsrc_output')
                self.status_hvsrc_output.value = format_switch(
                    value, default=NO_VALUE)

        self.state_handlers.append(handler)
Example #13
0
from comet import ui

app = comet.Application("comet-example")

# Register resources
app.resources.add("INSTR", comet.Resource("ASRL2::INSTR", visa_library="@sim"))

# Load stored settings (optional)
app.resources.load_settings()

def on_click():
    """Read IDN from IEC60488 compatible resource."""
    try:
        with app.resources.get("INSTR") as instr:
            idn_text.value = comet.IEC60488(instr).identification
    except comet.ResourceError as exc:
        ui.show_exception(exc)

idn_text = ui.Text(readonly=True)

app.layout = ui.Column(
    ui.Row(
        idn_text,
        ui.Button("Reload", clicked=on_click)
    ),
    ui.Spacer(),
    stretch=(0, 1)
)

app.run()
Example #14
0
 def __init__(self, process, lcr_process):
     super().__init__()
     self.lcr_process = lcr_process
     self.lcr_process.finished = self.on_lcr_finished
     self.lcr_process.failed = self.on_lcr_failed
     self.lcr_process.reading = self.on_lcr_reading
     self.mount(process)
     self.resize(640, 480)
     self.title = "Table Control"
     self.add_x_button = KeypadButton(text="+X", clicked=self.on_add_x)
     self.sub_x_button = KeypadButton(text="-X", clicked=self.on_sub_x)
     self.add_y_button = KeypadButton(text="+Y", clicked=self.on_add_y)
     self.sub_y_button = KeypadButton(text="-Y", clicked=self.on_sub_y)
     self.add_z_button = KeypadButton(text="+Z", clicked=self.on_add_z)
     self.sub_z_button = KeypadButton(text="-Z", clicked=self.on_sub_z)
     self.step_up_button = KeypadButton(
         text="↑⇵",
         tool_tip=
         "Step up, move single step up then double step down and double step up (experimental).",
         clicked=self.on_step_up)
     self.control_buttons = (self.add_x_button, self.sub_x_button,
                             self.add_y_button, self.sub_y_button,
                             self.add_z_button, self.sub_z_button,
                             self.step_up_button)
     self._lcr_prim_text = ui.Text(readonly=True)
     self._lcr_sec_text = ui.Text(readonly=True)
     self._lcr_chart = LCRChart()
     self._lcr_groupbox = ui.GroupBox(
         title="Contact Quality (LCR)",
         checkable=True,
         checked=False,
         toggled=self.on_lcr_toggled,
         layout=ui.Column(ui.Row(ui.Label("Cp"), self._lcr_prim_text),
                          ui.Row(ui.Label("Rp"), self._lcr_sec_text),
                          self._lcr_chart))
     self.probecard_light_button = ToggleButton(
         text="PC Light",
         tool_tip="Toggle probe card light",
         checkable=True,
         checked=False,
         enabled=False,
         toggled=self.on_probecard_light_clicked)
     self.microscope_light_button = ToggleButton(
         text="Mic Light",
         tool_tip="Toggle microscope light",
         checkable=True,
         checked=False,
         enabled=False,
         toggled=self.on_microscope_light_clicked)
     self.box_light_button = ToggleButton(text="Box Light",
                                          tool_tip="Toggle box light",
                                          checkable=True,
                                          checked=False,
                                          enabled=False,
                                          toggled=self.on_box_light_clicked)
     # Create movement radio buttons
     self.step_width_buttons = ui.Column()
     for item in self.load_table_step_sizes():
         step_size = item.get('step_size') * comet.ureg('um')
         step_color = item.get('step_color')
         step_size_label = format_metric(step_size.to('m').m,
                                         'm',
                                         decimals=1)
         button = ui.RadioButton(
             text=step_size_label,
             tool_tip=f"Move in {step_size_label} steps.",
             stylesheet=f"QRadioButton:enabled{{color:{step_color};}}",
             checked=len(self.step_width_buttons) == 0,
             toggled=self.on_step_toggled)
         button.movement_width = step_size.to('mm').m
         button.movement_color = step_color
         self.step_width_buttons.append(button)
     self.control_layout = ui.Column(ui.Row(ui.Row(
         ui.Column(KeypadSpacer(), self.sub_y_button, KeypadSpacer()),
         ui.Column(
             self.sub_x_button,
             KeypadSpacer(),
             self.add_x_button,
         ), ui.Column(
             KeypadSpacer(),
             self.add_y_button,
             KeypadSpacer(),
         ), KeypadSpacer(),
         ui.Column(ui.Row(self.add_z_button, self.step_up_button),
                   KeypadSpacer(), self.sub_z_button)),
                                            ui.Spacer(),
                                            stretch=(0, 1)),
                                     ui.Spacer(),
                                     stretch=(0, 1))
     self.positions_widget = TablePositionsWidget(
         enabled=False,
         position_picked=self.on_position_picked,
         absolute_move=self.on_absolute_move)
     self.contacts_widget = TableContactsWidget(
         enabled=False,
         position_picked=self.on_position_picked,
         absolute_move=self.on_absolute_move)
     self._position_widget = PositionWidget()
     self._calibration_widget = CalibrationWidget()
     self.z_limit_label = PositionLabel()
     self.x_hard_limit_label = PositionLabel()
     self.y_hard_limit_label = PositionLabel()
     self.z_hard_limit_label = PositionLabel()
     self.laser_label = SwitchLabel()
     self._calibrate_button = ui.Button(text="Calibrate",
                                        clicked=self.on_calibrate)
     self._update_interval_number = ui.Number(
         value=settings.table_control_update_interval,
         minimum=.5,
         maximum=10.0,
         decimals=2,
         step=0.25,
         suffix="s",
         changed=self.on_update_interval_changed)
     self._interval_groupbox = ui.GroupBox(title="Update Interval",
                                           layout=ui.Row(
                                               self._update_interval_number,
                                               ui.Spacer(),
                                               stretch=(0, 1)))
     self._dodge_height_number = ui.Number(
         tool_tip="Doge height in microns.",
         minimum=0,
         maximum=10000,
         decimals=0,
         step=1,
         suffix="um")
     self._dodge_groupbox = ui.GroupBox(
         title="X/Y Dodge",
         tool_tip="Enables -/+ Z dodge for XY movements.",
         checkable=True,
         layout=ui.Row(ui.Label("Height"),
                       self._dodge_height_number,
                       ui.Spacer(),
                       stretch=(0, 0, 1)))
     self._lcr_reset_on_move_checkbox = ui.CheckBox(
         text="Reset graph on X/Y move")
     self._contact_quality_groupbox = ui.GroupBox(
         title="Contact Quality (LCR)",
         layout=ui.Row(self._lcr_reset_on_move_checkbox,
                       ui.Spacer(),
                       stretch=(0, 1)))
     self._step_up_delay_number = ui.Number(minimum=0,
                                            maximum=1000,
                                            decimals=0,
                                            step=25,
                                            suffix="ms")
     self._step_up_multiply_number = ui.Number(minimum=1,
                                               maximum=10,
                                               decimals=0,
                                               suffix="x")
     self._step_up_groubox = ui.GroupBox(
         title="Step Up (↑⇵)",
         layout=ui.Row(
             ui.Column(ui.Label("Delay"), ui.Label("Multiplicator (⇵)")),
             ui.Column(self._step_up_delay_number,
                       self._step_up_multiply_number), ui.Spacer()))
     self._lcr_update_interval_number = ui.Number(minimum=0,
                                                  maximum=1000,
                                                  decimals=0,
                                                  step=25,
                                                  suffix="ms")
     self._lcr_matrix_channels_text = ui.Text()
     self._lcr_options_groupbox = ui.GroupBox(
         title="Contact Quality (LCR)",
         layout=ui.Row(
             ui.Column(
                 ui.Label("Reading Interval"),
                 ui.Label("Matrix Channels"),
             ),
             ui.Column(
                 ui.Row(self._lcr_update_interval_number, ui.Spacer()),
                 self._lcr_matrix_channels_text)))
     self.progress_bar = ui.ProgressBar(visible=False)
     self.message_label = ui.Label()
     self.stop_button = ui.Button(text="&Stop",
                                  default=False,
                                  auto_default=False,
                                  enabled=False,
                                  clicked=self.on_stop)
     self.close_button = ui.Button(text="&Close",
                                   default=False,
                                   auto_default=False,
                                   clicked=self.on_close)
     self.layout = ui.Column(
         ui.Row(
             ui.Column(
                 ui.Row(
                     ui.GroupBox(
                         title="Control",
                         layout=ui.Column(
                             ui.Spacer(horizontal=False),
                             self.control_layout,
                             ui.Spacer(horizontal=False)
                         )
                     ),
                     ui.GroupBox(
                         title="Step Width",
                         layout=self.step_width_buttons
                     ),
                     self._lcr_groupbox,
                     ui.Column(
                         ui.GroupBox(
                             title="Lights",
                             layout=ui.Column(
                                 self.probecard_light_button,
                                 self.microscope_light_button,
                                 self.box_light_button,
                                 ui.Spacer()
                             )
                         )
                     ),
                     stretch=(0, 0, 1, 0)
                 ),
                 ui.Tabs(
                     ui.Tab(
                         title="Move",
                         layout=self.positions_widget
                     ),
                     ui.Tab(
                         title="Contacts",
                         layout=self.contacts_widget
                     ),
                     ui.Tab(
                         title="Calibrate",
                         layout=ui.Column(
                             ui.GroupBox(
                                 title="Table Calibration",
                                 layout=ui.Column(
                                     ui.Row(
                                         self._calibrate_button,
                                         ui.Label("Calibrate table by moving into cal/rm switches\nof every axis in" \
                                                  " a safe manner to protect the probe card."),
                                         stretch=(0, 1)
                                     )
                                 )
                             ),
                             ui.Spacer(),
                             stretch=(0, 1)
                         )
                     ),
                     ui.Tab(
                         title="Options",
                         layout=ui.Column(
                             ui.Row(
                                 self._interval_groupbox,
                                 self._dodge_groupbox,
                                 self._contact_quality_groupbox,
                                 stretch=(0, 0, 1)
                             ),
                             self._step_up_groubox,
                             self._lcr_options_groupbox,
                             ui.Spacer(),
                             stretch=(0, 0, 0, 1)
                         )
                     )
                 ),
                 stretch=(0, 1)
             ),
             ui.Column(
                 self._position_widget,
                 self._calibration_widget,
                 ui.GroupBox(
                     title="Soft Limits",
                     layout=ui.Row(
                         ui.Column(
                             ui.Label("Z")
                         ),
                         ui.Column(
                             self.z_limit_label
                         )
                     )
                 ),
                 ui.GroupBox(
                     title="Hard Limits",
                     layout=ui.Row(
                         ui.Column(
                             ui.Label("X"),
                             ui.Label("Y"),
                             ui.Label("Z")
                         ),
                         ui.Column(
                             self.x_hard_limit_label,
                             self.y_hard_limit_label,
                             self.z_hard_limit_label
                         )
                     )
                 ),
                 ui.GroupBox(
                     title="Safety",
                     layout=ui.Row(
                         ui.Label(
                             text="Laser Sensor"
                         ),
                         self.laser_label
                     )
                 ),
                 ui.Spacer()
             ),
             stretch=(1, 0)
         ),
         ui.Row(
             self.progress_bar,
             self.message_label,
             ui.Spacer(),
             self.stop_button,
             self.close_button
         ),
         stretch=(1, 0)
     )
     self.close_event = self.on_close_event
     self.reset_position()
     self.reset_caldone()
     self.update_limits()
     self.reset_safety()
     self.update_control_buttons()