def __init__(self): super().__init__(title="Options") self._png_plots_checkbox = ui.CheckBox("Save plots as PNG") self._points_in_plots_checkbox = ui.CheckBox("Show points in plots") self._png_analysis_checkbox = ui.CheckBox( "Add analysis preview to PNG") self._export_json_checkbox = ui.CheckBox("Write JSON data (*.json)") self._export_txt_checkbox = ui.CheckBox( "Write plain text data (*.txt)") self._write_logfiles_checkbox = ui.CheckBox( "Write measurement log files (*.log)") self._vsrc_instrument_combobox = ui.ComboBox( ["K2410", "K2470", "K2657A"]) self._hvsrc_instrument_combobox = ui.ComboBox( ["K2410", "K2470", "K2657A"]) self._retry_measurement_number = ui.Number( minimum=0, suffix="x", tool_tip="Number of retries for measurements with failed analysis." ) self._retry_contact_number = ui.Number( minimum=0, suffix="x", tool_tip= "Number of re-contact retries for measurements with failed analysis." ) self.layout = ui.Column( ui.Row(ui.GroupBox(title="Plots", layout=ui.Column( self._png_plots_checkbox, self._points_in_plots_checkbox, )), ui.GroupBox(title="Analysis", layout=ui.Column(self._png_analysis_checkbox, ui.Spacer())), stretch=(0, 1)), ui.Row(ui.GroupBox(title="Formats", layout=ui.Column(self._export_json_checkbox, self._export_txt_checkbox)), ui.GroupBox(title="Log files", layout=ui.Column(self._write_logfiles_checkbox, ui.Spacer())), stretch=(0, 1)), ui.GroupBox(title="Instruments", layout=ui.Row(ui.Column(ui.Label("V Source"), ui.Label("HV Source")), ui.Column( self._vsrc_instrument_combobox, self._hvsrc_instrument_combobox), ui.Spacer(vertical=False), stretch=(0, 0, 1))), ui.GroupBox(title="Auto Retry", layout=ui.Row( ui.Column(ui.Label("Retry Measurements"), ui.Label("Retry Contact")), ui.Column(self._retry_measurement_number, self._retry_contact_number), ui.Spacer())), ui.Spacer(), stretch=(0, 0, 0, 0, 1))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.location_combo_box = ui.ComboBox( editable=True, focus_out=self.update_locations, changed=self.on_location_changed, ) self.location_combo_box.duplicates_enabled = False self.select_button = ui.ToolButton(icon=make_path( 'assets', 'icons', 'search.svg'), tool_tip="Select a directory.", clicked=self.on_select_clicked) self.remove_button = ui.ToolButton( icon=make_path('assets', 'icons', 'delete.svg'), tool_tip="Remove directory from list.", clicked=self.on_remove_clicked) self.append(self.location_combo_box) self.append(self.select_button) self.append(self.remove_button)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.title = "Bias + IV Ramp" self.register_vsource() self.register_hvsource() self.register_environment() self.plot = ui.Plot(height=300, legend="right") self.plot.add_axis("x", align="bottom", text="Voltage [V]") self.plot.add_axis("y", align="right", text="Current [uA]") self.plot.add_series("vsrc", "x", "y", text="V Source", color="blue") self.plot.add_series("xfit", "x", "y", text="Fit", color="magenta") self.data_tabs.insert(0, ui.Tab(title="IV Curve", layout=self.plot)) self.voltage_start = ui.Number(decimals=3, suffix="V") self.voltage_stop = ui.Number(decimals=3, suffix="V") self.voltage_step = ui.Number(minimum=0, maximum=200, decimals=3, suffix="V") self.waiting_time = ui.Number(minimum=0, decimals=2, suffix="s") self.bias_voltage = ui.Number(decimals=3, suffix="V") self.bias_mode = ui.ComboBox(["constant", "offset"]) self.hvsrc_current_compliance = ui.Metric(minimum=0, decimals=3, prefixes='mun', unit="A") self.hvsrc_accept_compliance = ui.CheckBox("Accept Compliance") self.vsrc_current_compliance = ui.Metric(minimum=0, decimals=3, prefixes='mun', unit="A") self.vsrc_accept_compliance = ui.CheckBox("Accept Compliance") self.bind("voltage_start", self.voltage_start, 0, unit="V") self.bind("voltage_stop", self.voltage_stop, 0, unit="V") self.bind("voltage_step", self.voltage_step, 0, unit="V") self.bind("waiting_time", self.waiting_time, 1, unit="s") self.bind("bias_voltage", self.bias_voltage, 0, unit="V") self.bind("bias_mode", self.bias_mode, "constant") self.bind("hvsrc_current_compliance", self.hvsrc_current_compliance, 0, unit="A") self.bind("hvsrc_accept_compliance", self.hvsrc_accept_compliance, False) self.bind("vsrc_current_compliance", self.vsrc_current_compliance, 0, unit="A") self.bind("vsrc_accept_compliance", self.vsrc_accept_compliance, False) self.general_tab.layout = ui.Row( ui.GroupBox(title="HV Source Ramp", layout=ui.Column(ui.Label(text="Start"), self.voltage_start, ui.Label(text="Stop"), self.voltage_stop, ui.Label(text="Step"), self.voltage_step, ui.Label(text="Waiting Time"), self.waiting_time, ui.Spacer())), ui.GroupBox(title="V Source Bias", layout=ui.Column(ui.Label(text="Bias Voltage"), self.bias_voltage, ui.Label(text="Bias Compliance"), self.vsrc_current_compliance, self.vsrc_accept_compliance, ui.Label(text="Bias Mode"), self.bias_mode, ui.Spacer())), ui.GroupBox(title="HV Source", layout=ui.Column(ui.Label(text="Compliance"), self.hvsrc_current_compliance, self.hvsrc_accept_compliance, ui.Spacer())), stretch=(1, 1, 1)) ampere = comet.ureg('A') volt = comet.ureg('V') self.series_transform['vsrc'] = lambda x, y: ((x * ampere).to('uA').m, (y * volt).to('V').m) self.series_transform['xfit'] = self.series_transform.get('vsrc')
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()
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)
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)
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)