def __init__(self, *args): PluginBase.__init__(self, BrickletLine, *args) self.line = self.device self.cbe_reflectivity = CallbackEmulator(self.line.get_reflectivity, self.cb_reflectivity, self.increase_error_count) self.reflectivity_label = ReflectivityLabel() self.rf = ReflectivityFrame() self.current_value = None plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Reflectivity', plot_list) layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.reflectivity_label) layout_h.addStretch() layout_h2 = QHBoxLayout() layout_h2.addStretch() layout_h2.addWidget(self.rf) layout_h2.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addLayout(layout_h2) layout.addWidget(self.plot_widget)
def __init__(self, *args): PluginBase.__init__(self, BrickletDualRelay, *args) self.setupUi(self) self.dr = self.device self.state1_combobox.setItemData(0, True) self.state1_combobox.setItemData(1, False) self.state2_combobox.setItemData(0, True) self.state2_combobox.setItemData(1, False) self.monoflop = Monoflop(self.dr, [1, 2], [self.state1_combobox, self.state2_combobox], self.cb_state_change_by_monoflop, [self.time1_spinbox, self.time2_spinbox], None, self) self.dr1_button.clicked.connect(self.dr1_clicked) self.dr2_button.clicked.connect(self.dr2_clicked) self.go1_button.clicked.connect(self.go1_clicked) self.go2_button.clicked.connect(self.go2_clicked) self.a1_pixmap = load_masked_pixmap( 'plugin_system/plugins/dual_relay/relay_a1.bmp') self.a2_pixmap = load_masked_pixmap( 'plugin_system/plugins/dual_relay/relay_a2.bmp') self.b1_pixmap = load_masked_pixmap( 'plugin_system/plugins/dual_relay/relay_b1.bmp') self.b2_pixmap = load_masked_pixmap( 'plugin_system/plugins/dual_relay/relay_b2.bmp')
def __init__(self, *args): PluginBase.__init__(self, BrickletRGBLED, *args) self.rgb_led = self.device self.changing = False self.set_rgb_value_response_expected = None self.setupUi(self) self.r_syncer = SliderSpinSyncer(self.slider_r, self.spin_r, self.rgb_changed, spin_signal='valueChanged') self.g_syncer = SliderSpinSyncer(self.slider_g, self.spin_g, self.rgb_changed, spin_signal='valueChanged') self.b_syncer = SliderSpinSyncer(self.slider_b, self.spin_b, self.rgb_changed, spin_signal='valueChanged') self.h_syncer = SliderSpinSyncer(self.slider_h, self.spin_h, self.hsl_changed, spin_signal='valueChanged') self.s_syncer = SliderSpinSyncer(self.slider_s, self.spin_s, self.hsl_changed, spin_signal='valueChanged') self.l_syncer = SliderSpinSyncer(self.slider_l, self.spin_l, self.hsl_changed, spin_signal='valueChanged') def set_color(r, g, b): self.changing = True self.spin_r.setValue(r) self.spin_g.setValue(g) self.spin_b.setValue(b) self.changing = False self.rgb_changed() for color, button in zip([(0, 0, 0), (255, 255, 255), (255, 0, 0), (255, 255, 0), (0, 255, 0), (0, 255, 255), (0, 0, 255), (255, 0, 255)], [self.button_black, self.button_white, self.button_red, self.button_yellow, self.button_green, self.button_cyan, self.button_blue, self.button_magenta]): button.clicked.connect(lambda clicked, c=color: set_color(*c)) pixmap = QPixmap(16, 16) QPainter(pixmap).fillRect(0, 0, 16, 16, QColor(*color)) button.setIcon(QIcon(pixmap)) button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
def __init__(self, *args): PluginBase.__init__(self, BrickletAmbientLight, *args) self.al = self.device self.cbe_illuminance = CallbackEmulator(self.al.get_illuminance, self.cb_illuminance, self.increase_error_count) self.illuminance_label = IlluminanceLabel('Illuminance: ') self.alf = AmbientLightFrame() self.current_value = None plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Illuminance [lx]', plot_list) layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.illuminance_label) layout_h.addWidget(self.alf) layout_h.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addWidget(self.plot_widget)
def __init__(self, *args): PluginBase.__init__(self, BrickletDualButton, *args) self.setupUi(self) self.button = self.device self.qtcb_state_changed.connect(self.cb_state_changed) self.button.register_callback(self.button.CALLBACK_STATE_CHANGED, self.qtcb_state_changed.emit) self.led_r = DualButton.OFF self.led_l = DualButton.OFF self.button_r = DualButton.RELEASED self.button_l = DualButton.RELEASED self.button_led_on_button_r.clicked.connect(self.on_button_r_clicked) self.button_led_on_button_l.clicked.connect(self.on_button_l_clicked) self.button_led_off_button_r.clicked.connect(self.off_button_r_clicked) self.button_led_off_button_l.clicked.connect(self.off_button_l_clicked) self.button_toggle_button_r.clicked.connect( self.toggle_button_r_clicked) self.button_toggle_button_l.clicked.connect( self.toggle_button_l_clicked) self.count = 0
def __init__(self, *args): PluginBase.__init__(self, BrickletTilt, *args) self.tilt = self.device self.cbe_tilt_state = CallbackEmulator(self.tilt.get_tilt_state, self.cb_tilt_state, self.increase_error_count) self.label = QLabel("Closed") self.closed_pixmap = load_masked_pixmap('plugin_system/plugins/tilt/tilt_closed.bmp') self.open_pixmap = load_masked_pixmap('plugin_system/plugins/tilt/tilt_open.bmp') self.closed_vibrationg_pixmap = load_masked_pixmap('plugin_system/plugins/tilt/tilt_closed_vibrating.bmp') self.image_label = QLabel("") self.image_label.setPixmap(self.closed_pixmap) layout = QVBoxLayout(self) layout.addStretch() h_layout1 = QHBoxLayout() h_layout1.addStretch() h_layout1.addWidget(self.label) h_layout1.addStretch() h_layout2 = QHBoxLayout() h_layout2.addStretch() h_layout2.addWidget(self.image_label) h_layout2.addStretch() layout.addLayout(h_layout1) layout.addLayout(h_layout2) layout.addStretch()
def __init__(self, ipcon, uid, version): PluginBase.__init__(self, ipcon, uid, 'Tilt Bricklet', version) self.tilt = BrickletTilt(uid, ipcon) self.qtcb_tilt_state.connect(self.cb_tilt_state) self.tilt.register_callback(self.tilt.CALLBACK_TILT_STATE, self.qtcb_tilt_state.emit) self.label = QLabel("Closed") self.closed_pixmap = bmp_to_pixmap('plugin_system/plugins/tilt/tilt_closed.bmp') self.open_pixmap = bmp_to_pixmap('plugin_system/plugins/tilt/tilt_open.bmp') self.closed_vibrationg_pixmap = bmp_to_pixmap('plugin_system/plugins/tilt/tilt_closed_vibrating.bmp') self.image_label = QLabel("") self.image_label.setPixmap(self.closed_pixmap) layout = QVBoxLayout(self) layout.addStretch() h_layout1 = QHBoxLayout() h_layout1.addStretch() h_layout1.addWidget(self.label) h_layout1.addStretch() h_layout2 = QHBoxLayout() h_layout2.addStretch() h_layout2.addWidget(self.image_label) h_layout2.addStretch() layout.addLayout(h_layout1) layout.addLayout(h_layout2) layout.addStretch()
def __init__(self, *args): PluginBase.__init__(self, BrickletHeartRate, *args) self.hr = self.device self.cbe_heart_rate = CallbackEmulator(self.hr.get_heart_rate, self.cb_heart_rate, self.increase_error_count) # FIXME: add beat state getter to Heart Rate Bricklet API self.qtcb_beat_state_changed.connect(self.cb_beat_state_changed) self.hr.register_callback(self.hr.CALLBACK_BEAT_STATE_CHANGED, self.qtcb_beat_state_changed.emit) self.heart_white_bitmap = load_masked_pixmap('plugin_system/plugins/heart_rate/heart_white_small.bmp') self.heart_red_bitmap = load_masked_pixmap('plugin_system/plugins/heart_rate/heart_red_small.bmp') self.heart_icon = QLabel() self.heart_icon.setPixmap(self.heart_white_bitmap) self.current_heart_rate = None plots = [('Heart Rate', Qt.red, lambda: self.current_heart_rate, '{} BPM'.format)] self.plot_widget = PlotWidget('Heart Rate [BPM]', plots, extra_key_widgets=[self.heart_icon]) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget)
def __init__(self, *args): PluginBase.__init__(self, BrickletIndustrialAnalogOut, *args) self.setupUi(self) self.ao = self.device self.voltage_syncer = SliderSpinSyncer(self.slider_voltage, self.spin_voltage, self.voltage_changed) self.current_syncer = SliderSpinSyncer(self.slider_current, self.spin_current, self.current_changed) self.radio_voltage.clicked.connect(self.radio_clicked) self.radio_current.clicked.connect(self.radio_clicked) self.box_voltage_range.currentIndexChanged.connect(self.config_changed) self.box_current_range.currentIndexChanged.connect(self.config_changed) self.checkbox_enable.clicked.connect(self.enable_changed) self.last_voltage = 0 self.last_current = 4000 self.last_voltage_range = 0 self.last_current_range = 1 self.new_voltage(self.last_voltage) self.new_current(self.last_current) self.mode_voltage()
def __init__(self, *args): PluginBase.__init__(self, BrickletDistanceUS, *args) self.dist = self.device self.cbe_distance = CallbackEmulator(self.dist.get_distance_value, self.cb_distance, self.increase_error_count) self.current_distance = None plots = [('Distance Value', Qt.red, lambda: self.current_distance, str)] self.plot_widget = PlotWidget('Distance Value', plots) self.spin_average = QSpinBox() self.spin_average.setMinimum(0) self.spin_average.setMaximum(100) self.spin_average.setSingleStep(1) self.spin_average.setValue(20) self.spin_average.editingFinished.connect(self.spin_average_finished) hlayout = QHBoxLayout() hlayout.addWidget(QLabel('Moving Average Length:')) hlayout.addWidget(self.spin_average) hlayout.addStretch() line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, *args): PluginBase.__init__(self, BrickletDistanceUS, *args) self.dist = self.device self.cbe_distance = CallbackEmulator(self.dist.get_distance_value, self.cb_distance, self.increase_error_count) self.current_distance = None plots = [('Distance Value', Qt.red, lambda: self.current_distance, str) ] self.plot_widget = PlotWidget('Distance Value', plots) self.spin_average = QSpinBox() self.spin_average.setMinimum(0) self.spin_average.setMaximum(100) self.spin_average.setSingleStep(1) self.spin_average.setValue(20) self.spin_average.editingFinished.connect(self.spin_average_finished) hlayout = QHBoxLayout() hlayout.addWidget(QLabel('Moving Average Length:')) hlayout.addWidget(self.spin_average) hlayout.addStretch() line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, *args): PluginBase.__init__(self, BrickletAnalogInV2, *args) self.ai = self.device self.cbe_voltage = CallbackEmulator(self.ai.get_voltage, self.cb_voltage, self.increase_error_count) self.current_voltage = None # float, V plots = [('Voltage', Qt.red, lambda: self.current_voltage, format_voltage)] self.plot_widget = PlotWidget('Voltage [V]', plots) self.spin_average = QSpinBox() self.spin_average.setMinimum(1) self.spin_average.setMaximum(50) self.spin_average.setSingleStep(1) self.spin_average.setValue(50) self.spin_average.editingFinished.connect(self.spin_average_finished) layout_h1 = QHBoxLayout() layout_h1.addWidget(QLabel('Moving Average Length:')) layout_h1.addWidget(self.spin_average) layout_h1.addStretch() line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(layout_h1)
def __init__(self, *args): PluginBase.__init__(self, BrickletIndustrialAnalogOut, *args) self.setupUi(self) self.ao = self.device self.spin_voltage.editingFinished.connect(self.voltage_spin_finished) self.slider_voltage.sliderReleased.connect(self.voltage_slider_released) self.slider_voltage.valueChanged.connect(self.voltage_slider_changed) self.spin_current.editingFinished.connect(self.current_spin_finished) self.slider_current.sliderReleased.connect(self.current_slider_released) self.slider_current.valueChanged.connect(self.current_slider_changed) self.radio_voltage.released.connect(self.radio_released) self.radio_current.released.connect(self.radio_released) self.box_voltage_range.activated.connect(self.config_changed) self.box_current_range.activated.connect(self.config_changed) self.checkbox_enable.clicked.connect(self.enable_changed) self.last_voltage = 0 self.last_current = 4000 self.last_voltage_range = 0 self.last_current_range = 1 self.ui_voltage = [self.label_voltage, self.label_mv, self.label_voltage_range, self.slider_voltage, self.spin_voltage, self.box_voltage_range] self.ui_current = [self.label_current, self.label_ua, self.label_current_range, self.slider_current, self.spin_current, self.box_current_range] self.new_voltage(self.last_voltage) self.new_current(self.last_current) self.mode_voltage()
def __init__(self, *args): PluginBase.__init__(self, BrickletCO2, *args) self.co2 = self.device self.cbe_co2_concentration = CallbackEmulator( self.co2.get_co2_concentration, self.cb_co2_concentration, self.increase_error_count) self.co2_concentration_label = CO2ConcentrationLabel( 'CO2 Concentration: ') self.current_value = None plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('CO2 Concentration [ppm]', plot_list) layout_h2 = QHBoxLayout() layout_h2.addStretch() layout_h2.addWidget(self.co2_concentration_label) layout_h2.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h2) layout.addWidget(self.plot_widget)
def __init__(self, *args): PluginBase.__init__(self, BrickletVoltageCurrent, *args) self.setupUi(self) self.vc = self.device self.cbe_current = CallbackEmulator(self.vc.get_current, self.cb_current, self.increase_error_count) self.cbe_voltage = CallbackEmulator(self.vc.get_voltage, self.cb_voltage, self.increase_error_count) self.cbe_power = CallbackEmulator(self.vc.get_power, self.cb_power, self.increase_error_count) self.current_voltage = None # float, V self.current_current = None # float, A self.current_power = None # float, W plots_voltage = [("Voltage", Qt.red, lambda: self.current_voltage, format_voltage)] plots_current = [("Current", Qt.blue, lambda: self.current_current, format_current)] plots_power = [("Power", Qt.darkGreen, lambda: self.current_power, format_power)] self.plot_widget_voltage = PlotWidget("Voltage [V]", plots_voltage, self.button_clear_graphs) self.plot_widget_current = PlotWidget("Current [A]", plots_current, self.button_clear_graphs) self.plot_widget_power = PlotWidget("Power [W]", plots_power, self.button_clear_graphs) self.save_cal_button.clicked.connect(self.save_cal_clicked) self.save_conf_button.clicked.connect(self.save_conf_clicked) hlayout = QHBoxLayout() hlayout.addWidget(self.plot_widget_voltage) hlayout.addWidget(self.plot_widget_current) hlayout.addWidget(self.plot_widget_power) self.main_layout.insertLayout(0, hlayout)
def __init__(self, device_class, ipcon, device_info, override_base_name=None): PluginBase.__init__(self, device_class, ipcon, device_info, override_base_name) self.start_called = False self.has_comcu = True self.cbe_bootloader_mode = CallbackEmulator(self.device.get_bootloader_mode, self.cb_bootloader_mode, self.increase_error_count) self.status_led_off_action = QAction('Off', self) self.status_led_off_action.triggered.connect(lambda: self.device.set_status_led_config(device_class.STATUS_LED_CONFIG_OFF)) self.status_led_on_action = QAction('On', self) self.status_led_on_action.triggered.connect(lambda: self.device.set_status_led_config(device_class.STATUS_LED_CONFIG_ON)) self.status_led_show_heartbeat_action = QAction('Show Heartbeat', self) self.status_led_show_heartbeat_action.triggered.connect(lambda: self.device.set_status_led_config(device_class.STATUS_LED_CONFIG_SHOW_HEARTBEAT)) self.status_led_show_status_action = QAction('Show Status', self) self.status_led_show_status_action.triggered.connect(lambda: self.device.set_status_led_config(device_class.STATUS_LED_CONFIG_SHOW_STATUS)) self.extra_configs = [(0, 'Status LED:', [self.status_led_off_action, self.status_led_on_action, self.status_led_show_heartbeat_action, self.status_led_show_status_action])] self.reset_action = QAction('Reset', self) self.reset_action.triggered.connect(self.remove_and_reset) self.extra_actions = [(0, None, [self.reset_action])]
def __init__(self, *args): PluginBase.__init__(self, BrickletHeartRate, *args) self.hr = self.device self.cbe_heart_rate = CallbackEmulator(self.hr.get_heart_rate, self.cb_heart_rate, self.increase_error_count) # FIXME: add beat state getter to Heart Rate Bricklet API self.qtcb_beat_state_changed.connect(self.cb_beat_state_changed) self.hr.register_callback(self.hr.CALLBACK_BEAT_STATE_CHANGED, self.qtcb_beat_state_changed.emit) self.heart_rate_label = HeartRateLabel() self.heart_white_bitmap = load_masked_pixmap('plugin_system/plugins/heart_rate/heart_white_small.bmp') self.heart_red_bitmap = load_masked_pixmap('plugin_system/plugins/heart_rate/heart_red_small.bmp') self.heart_icon = QLabel() self.heart_icon.setPixmap(self.heart_white_bitmap) self.current_value = None plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Heart Rate [BPM]', plot_list) layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.heart_rate_label) layout_h.addWidget(self.heart_icon) layout_h.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addWidget(self.plot_widget)
def __init__(self, ipcon, uid, version): PluginBase.__init__(self, ipcon, uid, 'Ambient Light Bricklet', version) self.al = BrickletAmbientLight(uid, ipcon) self.qtcb_illuminance.connect(self.cb_illuminance) self.al.register_callback(self.al.CALLBACK_ILLUMINANCE, self.qtcb_illuminance.emit) self.illuminance_label = IlluminanceLabel('Illuminance: ') self.alf = AmbientLightFrame() self.current_value = None plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Illuminance [lx]', plot_list) layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.illuminance_label) layout_h.addWidget(self.alf) layout_h.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addWidget(self.plot_widget)
def __init__(self, *args): PluginBase.__init__(self, BrickletAnalogOutV2, *args) self.ao = self.device self.input_voltage_label = VoltageLabel() self.output_voltage_label = QLabel('Output Voltage [mV]:') self.output_voltage_box = QSpinBox() self.output_voltage_box.setMinimum(0) self.output_voltage_box.setMaximum(12000) self.output_voltage_box.setSingleStep(1) layout_h1 = QHBoxLayout() layout_h1.addStretch() layout_h1.addWidget(self.output_voltage_label) layout_h1.addWidget(self.output_voltage_box) layout_h1.addStretch() layout_h2 = QHBoxLayout() layout_h2.addStretch() layout_h2.addWidget(self.input_voltage_label) layout_h2.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h2) layout.addLayout(layout_h1) layout.addStretch() self.output_voltage_box.editingFinished.connect(self.voltage_finished) self.cbe_input_voltage = CallbackEmulator(self.ao.get_input_voltage, self.cb_get_input_voltage, self.increase_error_count)
def __init__(self, *args): PluginBase.__init__(self, BrickletOzone, *args) self.ozone = self.device self.cbe_ozone_concentration = CallbackEmulator( self.ozone.get_ozone_concentration, self.cb_ozone_concentration, self.increase_error_count) self.current_ozone_concentration = None plots = [('Ozone Concentration', Qt.red, lambda: self.current_ozone_concentration, '{} ppb'.format)] self.plot_widget = PlotWidget('Ozone Concentration [ppb]', plots) self.spin_average = QSpinBox() self.spin_average.setMinimum(1) self.spin_average.setMaximum(50) self.spin_average.setSingleStep(1) self.spin_average.setValue(50) self.spin_average.editingFinished.connect(self.spin_average_finished) hlayout = QHBoxLayout() hlayout.addWidget(QLabel('Moving Average Length:')) hlayout.addWidget(self.spin_average) hlayout.addStretch() line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, *args): PluginBase.__init__(self, BrickletDualRelay, *args) self.setupUi(self) self.dr = self.device self.state1_combobox.setItemData(0, True) self.state1_combobox.setItemData(1, False) self.state2_combobox.setItemData(0, True) self.state2_combobox.setItemData(1, False) self.monoflop = Monoflop(self.dr, [1, 2], [self.state1_combobox, self.state2_combobox], self.cb_state_change_by_monoflop, [self.time1_spinbox, self.time2_spinbox], None, self) self.dr1_button.clicked.connect(self.dr1_clicked) self.dr2_button.clicked.connect(self.dr2_clicked) self.go1_button.clicked.connect(self.go1_clicked) self.go2_button.clicked.connect(self.go2_clicked) self.a1_pixmap = load_masked_pixmap('plugin_system/plugins/dual_relay/relay_a1.bmp') self.a2_pixmap = load_masked_pixmap('plugin_system/plugins/dual_relay/relay_a2.bmp') self.b1_pixmap = load_masked_pixmap('plugin_system/plugins/dual_relay/relay_b1.bmp') self.b2_pixmap = load_masked_pixmap('plugin_system/plugins/dual_relay/relay_b2.bmp')
def __init__(self, *args): PluginBase.__init__(self, BrickletRS232, *args) self.setupUi(self) self.text.setReadOnly(True) self.rs232 = self.device #self.cbe_read = CallbackEmulator(self.rs232.read, # self.cb_read, # self.increase_error_count) self.input_combobox.addItem("") self.input_combobox.lineEdit().returnPressed.connect(self.input_changed) self.baudrate_combobox.activated.connect(self.configuration_changed) self.parity_combobox.activated.connect(self.configuration_changed) self.stopbits_spinbox.editingFinished.connect(self.configuration_changed) self.wordlength_spinbox.editingFinished.connect(self.configuration_changed) self.hardware_flowcontrol_combobox.activated.connect(self.configuration_changed) self.software_flowcontrol_combobox.activated.connect(self.configuration_changed) self.save_button.pressed.connect(self.save_pressed) self.timer = None
def __init__(self, *args): PluginBase.__init__(self, BrickletSoundIntensity, *args) self.si = self.device self.cbe_intensity = CallbackEmulator(self.si.get_intensity, self.cb_intensity, self.increase_error_count) self.intensity_label = IntensityLabel() self.current_value = None self.thermo = TuningThermo() #plot_list = [['', Qt.red, self.get_current_value]] #self.plot_widget = PlotWidget('Intensity Value', plot_list) layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.intensity_label) layout_h.addStretch() layout_h2 = QHBoxLayout() layout_h2.addStretch() layout_h2.addWidget(self.thermo) layout_h2.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addLayout(layout_h2) layout.addStretch()
def __init__(self, *args): PluginBase.__init__(self, BrickletAnalogOutV2, *args) self.ao = self.device self.input_voltage_label = VoltageLabel() self.output_voltage_label = QLabel('Output Voltage [mV]: ') self.output_voltage_box = QSpinBox() self.output_voltage_box.setMinimum(0) self.output_voltage_box.setMaximum(12000) self.output_voltage_box.setSingleStep(1) layout_h1 = QHBoxLayout() layout_h1.addStretch() layout_h1.addWidget(self.output_voltage_label) layout_h1.addWidget(self.output_voltage_box) layout_h1.addStretch() layout_h2 = QHBoxLayout() layout_h2.addStretch() layout_h2.addWidget(self.input_voltage_label) layout_h2.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h2) layout.addLayout(layout_h1) layout.addStretch() self.output_voltage_box.editingFinished.connect(self.voltage_finished) self.cbe_input_voltage = CallbackEmulator(self.ao.get_input_voltage, self.cb_get_input_voltage, self.increase_error_count)
def __init__(self, *args): PluginBase.__init__(self, BrickletCurrent12, *args) self.cur = self.device self.cbe_current = CallbackEmulator(self.cur.get_current, self.cb_current, self.increase_error_count) self.qtcb_over.connect(self.cb_over) self.cur.register_callback(self.cur.CALLBACK_OVER_CURRENT, self.qtcb_over.emit) self.over_label = QLabel('Over Current: No') self.calibrate_button = QPushButton('Calibrate Zero') self.calibrate_button.clicked.connect(self.calibrate_clicked) self.current_current = None # float, A plots = [('Current', Qt.red, lambda: self.current_current, format_current)] self.plot_widget = PlotWidget('Current [A]', plots, extra_key_widgets=[self.over_label]) line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addWidget(self.calibrate_button)
def __init__(self, *args): PluginBase.__init__(self, BrickletSolidStateRelay, *args) self.setupUi(self) self.ssr = self.device self.qtcb_monoflop.connect(self.cb_monoflop) self.ssr.register_callback(self.ssr.CALLBACK_MONOFLOP_DONE, self.qtcb_monoflop.emit) self.ssr_button.clicked.connect(self.ssr_clicked) self.go_button.clicked.connect(self.go_clicked) self.monoflop = False self.timebefore = 500 self.a_pixmap = load_masked_pixmap( 'plugin_system/plugins/solid_state_relay/relay_a.bmp') self.b_pixmap = load_masked_pixmap( 'plugin_system/plugins/solid_state_relay/relay_b.bmp') self.update_timer = QTimer() self.update_timer.timeout.connect(self.update) self.update_timer.setInterval(50)
def __init__(self, *args): PluginBase.__init__(self, BrickletRotaryPoti, *args) self.rp = self.device self.cbe_position = CallbackEmulator(self.rp.get_position, self.cb_position, self.increase_error_count) self.position_knob = KnobWidget(self) self.position_knob.setFocusPolicy(Qt.NoFocus) self.position_knob.set_total_angle(300) self.position_knob.set_range(-150, 150) self.position_knob.set_scale(30, 3) self.position_knob.set_knob_radius(25) self.current_position = None plots = [('Position', Qt.red, lambda: self.current_position, str)] self.plot_widget = PlotWidget('Position', plots, curve_motion_granularity=40, update_interval=0.025) layout = QHBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(self.position_knob)
def __init__(self, ipcon, uid, version): PluginBase.__init__(self, ipcon, uid, 'Sound Intensity Bricklet', version) self.si = BrickletSoundIntensity(uid, ipcon) self.qtcb_intensity.connect(self.cb_intensity) self.si.register_callback(self.si.CALLBACK_INTENSITY, self.qtcb_intensity.emit) self.intensity_label = IntensityLabel() self.current_value = None self.thermo = TuningThermo() # plot_list = [['', Qt.red, self.get_current_value]] # self.plot_widget = PlotWidget('Intensity', plot_list) layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.intensity_label) layout_h.addStretch() layout_h2 = QHBoxLayout() layout_h2.addStretch() layout_h2.addWidget(self.thermo) layout_h2.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addLayout(layout_h2) layout.addStretch()
def __init__(self, *args): PluginBase.__init__(self, BrickMaster, *args) self.setupUi(self) self.master = self.device self.update_timer = QTimer() self.update_timer.timeout.connect(self.update_data) self.extension_type = None self.extensions = [] self.num_extensions = 0 self.extension_label.setText("None Present") self.tab_widget.removeTab(0) self.tab_widget.hide() if self.firmware_version >= (1, 1, 0): self.check_extensions = True self.extension_type_button.clicked.connect(self.extension_clicked) else: self.check_extensions = False self.extension_type_button.setEnabled(False) if self.firmware_version >= (1, 2, 1): reset = QAction('Reset', self) reset.triggered.connect(lambda: self.master.reset()) self.set_actions(reset) self.extension_type_preset = [None, False, False, False, False, False] self.update_extensions_in_device_info()
def __init__(self, ipcon, uid, version): PluginBase.__init__(self, ipcon, uid, 'LED Strip Bricklet', version) self.setupUi(self) self.has_clock_frequency = version >= (2, 0, 1) self.led_strip = BrickletLEDStrip(uid, ipcon) self.qtcb_frame_rendered.connect(self.cb_frame_rendered) self.button_gradient.pressed.connect(self.gradient_pressed) self.button_color.pressed.connect(self.color_pressed) self.box_frame_duration.valueChanged.connect(self.frame_duration_changed) if self.has_clock_frequency: self.box_clock_frequency.valueChanged.connect(self.clock_frequency_changed) else: self.box_clock_frequency.setValue(20000000) self.box_clock_frequency.setEnabled(False) self.state = self.STATE_IDLE self.gradient_counter = 0 self.voltage = 0 self.voltage_timer = QTimer() self.voltage_timer.timeout.connect(self.update_voltage) self.voltage_timer.setInterval(1000)
def __init__(self, *args): PluginBase.__init__(self, BrickletLoadCell, *args) self.lc = self.device self.cbe_weight = CallbackEmulator(self.lc.get_weight, self.cb_weight, self.increase_error_count) self.weight_label = WeightLabel() self.gain = 0 # 128x self.current_value = None self.calibration = None plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Weight [g]', plot_list) self.button_calibration = QPushButton("Calibration") self.button_calibration.clicked.connect( self.button_calibration_clicked) self.button_tare = QPushButton("Tare") self.button_tare.clicked.connect(self.button_tare_clicked) self.enable_led = QCheckBox("LED On") self.enable_led.stateChanged.connect(self.enable_led_changed) self.spin_average = QSpinBox() self.spin_average.setMinimum(0) self.spin_average.setMaximum(40) self.spin_average.setSingleStep(1) self.spin_average.setValue(5) self.spin_average.editingFinished.connect(self.spin_average_finished) self.label_average = QLabel('Length of moving average:') layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.weight_label) layout_h.addStretch() self.rate_label = QLabel('Rate: ') self.rate_combo = QComboBox() self.rate_combo.addItem("10Hz") self.rate_combo.addItem("80Hz") self.rate_combo.currentIndexChanged.connect(self.new_config) layout_avg = QHBoxLayout() layout_avg.addWidget(self.label_average) layout_avg.addWidget(self.spin_average) layout_avg.addWidget(self.rate_label) layout_avg.addWidget(self.rate_combo) layout_avg.addStretch() layout_avg.addWidget(self.button_calibration) layout_avg.addWidget(self.button_tare) layout_avg.addWidget(self.enable_led) layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addWidget(self.plot_widget) layout.addLayout(layout_avg)
def __init__(self, *args): PluginBase.__init__(self, BrickletGPS, *args) self.setupUi(self) self.gps = self.device self.cbe_universal = CallbackEmulator(self.get_universal, None, self.cb_universal, self.increase_error_count, expand_result_tuple_for_callback=True) self.format_combobox.currentIndexChanged.connect(self.format_changed) self.show_pos.clicked.connect(self.show_pos_clicked) self.hot_start.clicked.connect(lambda: self.restart_clicked(0)) self.warm_start.clicked.connect(lambda: self.restart_clicked(1)) self.cold_start.clicked.connect(lambda: self.restart_clicked(2)) self.factory_reset.clicked.connect(lambda: self.restart_clicked(3)) self.had_fix = False self.last_lat = 0 self.last_ns = 'U' self.last_long = 0 self.last_ew = 'U' self.last_pdop = 0 self.last_hdop = 0 self.last_vdop = 0 self.last_epe = 0
def __init__(self, ipcon, uid, version): PluginBase.__init__(self, ipcon, uid, 'Heart Rate Bricklet', version) self.hr = BrickletHeartRate(uid, ipcon) self.qtcb_heart_rate.connect(self.cb_heart_rate) self.hr.register_callback(self.hr.CALLBACK_HEART_RATE, self.qtcb_heart_rate.emit) self.qtcb_beat_state_changed.connect(self.cb_beat_state_changed) self.hr.register_callback(self.hr.CALLBACK_BEAT_STATE_CHANGED, self.qtcb_beat_state_changed.emit) self.heart_rate_label = HeartRateLabel() self.heart_white_bitmap = bmp_to_pixmap('plugin_system/plugins/heart_rate/heart_white_small.bmp') self.heart_red_bitmap = bmp_to_pixmap('plugin_system/plugins/heart_rate/heart_red_small.bmp') self.heart_icon = QLabel() self.heart_icon.setPixmap(self.heart_white_bitmap) self.current_value = None plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Heart Rate [BPM]', plot_list) layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.heart_rate_label) layout_h.addWidget(self.heart_icon) layout_h.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addWidget(self.plot_widget)
def __init__(self, ipcon, uid, version): PluginBase.__init__(self, ipcon, uid, 'Industrial Digital In 4 Bricklet', version) self.setupUi(self) self.idi4 = BrickletIndustrialDigitalIn4(uid, ipcon) self.gnd_pixmap = bmp_to_pixmap('plugin_system/plugins/industrial_digital_in_4/dio_gnd.bmp') self.vcc_pixmap = bmp_to_pixmap('plugin_system/plugins/industrial_digital_in_4/dio_vcc.bmp') self.pin_buttons = [self.b0, self.b1, self.b2, self.b3, self.b4, self.b5, self.b6, self.b7, self.b8, self.b9, self.b10, self.b11, self.b12, self.b13, self.b14, self.b15] self.pin_button_icons = [self.b0_icon, self.b1_icon, self.b2_icon, self.b3_icon, self.b4_icon, self.b5_icon, self.b6_icon, self.b7_icon, self.b8_icon, self.b9_icon, self.b10_icon, self.b11_icon, self.b12_icon, self.b13_icon, self.b14_icon, self.b15_icon] self.pin_button_labels = [self.b0_label, self.b1_label, self.b2_label, self.b3_label, self.b4_label, self.b5_label, self.b6_label, self.b7_label, self.b8_label, self.b9_label, self.b10_label, self.b11_label, self.b12_label, self.b13_label, self.b14_label, self.b15_label] self.groups = [self.group0, self.group1, self.group2, self.group3] self.lines = [[self.line0, self.line0a, self.line0b, self.line0c], [self.line1, self.line1a, self.line1b, self.line1c], [self.line2, self.line2a, self.line2b, self.line2c], [self.line3, self.line3a, self.line3b, self.line3c]] for lines in self.lines: for line in lines: line.setVisible(False) self.available_ports = 0 async_call(self.idi4.get_available_for_group, None, self.get_available_for_group_aysnc, self.increase_error_count) self.qtcb_interrupt.connect(self.cb_interrupt) self.idi4.register_callback(self.idi4.CALLBACK_INTERRUPT, self.qtcb_interrupt.emit) self.set_group.pressed.connect(self.set_group_pressed) self.debounce_go.pressed.connect(self.debounce_go_pressed) self.reconfigure_everything()
def __init__(self, *args): PluginBase.__init__(self, BrickletUVLight, *args) self.uv_light = self.device self.cbe_uv_light = CallbackEmulator(self.uv_light.get_uv_light, self.cb_uv_light, self.increase_error_count) self.uv_label = UVLabel(u'UV Light: ') self.index_label = IndexLabel(u'UV Index: ') self.current_uv_light = None plot_list = [['', Qt.red, self.get_current_uv_light]] self.plot_widget_uv = PlotWidget(u'UV Light [µW/cm²]', plot_list) layout_h1 = QHBoxLayout() layout_h1.addStretch() layout_h1.addWidget(self.uv_label) layout_h1.addStretch() layout_h2 = QHBoxLayout() layout_h2.addStretch() layout_h2.addWidget(self.index_label) layout_h2.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h1) layout.addLayout(layout_h2) layout.addWidget(self.plot_widget_uv)
def __init__(self, ipcon, uid, version): PluginBase.__init__(self, ipcon, uid, 'Linear Poti Bricklet', version) self.lp = BrickletLinearPoti(uid, ipcon) self.qtcb_position.connect(self.cb_position) self.lp.register_callback(self.lp.CALLBACK_POSITION, self.qtcb_position.emit) self.slider = QSlider(Qt.Horizontal) self.slider.setRange(0, 100) self.position_label = PositionLabel('Position: ') self.current_value = None plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Position', plot_list) layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.position_label) layout_h.addWidget(self.slider) layout_h.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addWidget(self.plot_widget)
def __init__(self, *args): PluginBase.__init__(self, None, *args, override_base_name='Unknown') # All new released Bricklets will have a comcu self.has_comcu = True info = args[1] layout = QVBoxLayout() layout.addStretch() label = QLabel("""The {6} with * Device Identifier: {0} * UID: {1} * Position: {2} * FW Version: {3}.{4}.{5} is not yet supported. Please update Brick Viewer!""".format(info.device_identifier, info.uid, info.position.upper(), info.firmware_version_installed[0], info.firmware_version_installed[1], info.firmware_version_installed[2], 'Brick' if str(info.device_identifier).startswith('1') else 'Bricklet')) #label.setAlignment(Qt.AlignHCenter) layout.addWidget(label) layout.addStretch() hbox = QHBoxLayout(self) hbox.addStretch() hbox.addLayout(layout) hbox.addStretch()
def __init__(self, *args): PluginBase.__init__(self, BrickletLinearPoti, *args) self.lp = self.device self.cbe_position = CallbackEmulator(self.lp.get_position, self.cb_position, self.increase_error_count) self.slider = QSlider(Qt.Horizontal) self.slider.setRange(0, 100) self.position_label = PositionLabel('Position: ') self.current_value = None plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Position', plot_list) layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.position_label) layout_h.addWidget(self.slider) layout_h.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addWidget(self.plot_widget)
def __init__(self, *args): PluginBase.__init__(self, BrickletOLED64x48, *args) self.setupUi(self) self.oled = self.device self.scribble_widget = ScribbleWidget(64, 48, 7, QColor(Qt.white), QColor(Qt.black), enable_grid=False) self.image_button_layout.insertWidget(0, self.scribble_widget) self.contrast_syncer = SliderSpinSyncer( self.contrast_slider, self.contrast_spin, lambda value: self.new_configuration()) self.char_syncer = SliderSpinSyncer(self.char_slider, self.char_spin, self.char_slider_changed) self.draw_button.clicked.connect(self.draw_clicked) self.clear_button.clicked.connect(self.clear_clicked) self.send_button.clicked.connect(self.send_clicked) self.clear_display_button.clicked.connect(self.clear_display_clicked) self.invert_checkbox.stateChanged.connect(self.new_configuration) self.current_char_value = -1
def __init__(self, *args): PluginBase.__init__(self, BrickletIndustrialDigitalIn4, *args) self.setupUi(self) self.idi4 = self.device self.gnd_pixmap = load_masked_pixmap('plugin_system/plugins/industrial_digital_in_4/dio_gnd.bmp') self.vcc_pixmap = load_masked_pixmap('plugin_system/plugins/industrial_digital_in_4/dio_vcc.bmp') self.pin_buttons = [self.b0, self.b1, self.b2, self.b3, self.b4, self.b5, self.b6, self.b7, self.b8, self.b9, self.b10, self.b11, self.b12, self.b13, self.b14, self.b15] self.pin_button_icons = [self.b0_icon, self.b1_icon, self.b2_icon, self.b3_icon, self.b4_icon, self.b5_icon, self.b6_icon, self.b7_icon, self.b8_icon, self.b9_icon, self.b10_icon, self.b11_icon, self.b12_icon, self.b13_icon, self.b14_icon, self.b15_icon] self.pin_button_labels = [self.b0_label, self.b1_label, self.b2_label, self.b3_label, self.b4_label, self.b5_label, self.b6_label, self.b7_label, self.b8_label, self.b9_label, self.b10_label, self.b11_label, self.b12_label, self.b13_label, self.b14_label, self.b15_label] self.groups = [self.group0, self.group1, self.group2, self.group3] self.lines = [[self.line0, self.line0a, self.line0b, self.line0c], [self.line1, self.line1a, self.line1b, self.line1c], [self.line2, self.line2a, self.line2b, self.line2c], [self.line3, self.line3a, self.line3b, self.line3c]] for lines in self.lines: for line in lines: line.setVisible(False) self.available_ports = 0 async_call(self.idi4.get_available_for_group, None, self.get_available_for_group_aysnc, self.increase_error_count) self.cbe_value = CallbackEmulator(self.idi4.get_value, self.cb_value, self.increase_error_count) self.set_group.clicked.connect(self.set_group_clicked) self.debounce_go.clicked.connect(self.debounce_go_clicked) self.reconfigure_everything()
def __init__(self, *args): PluginBase.__init__(self, BrickletLoadCell, *args) self.lc = self.device self.cbe_weight = CallbackEmulator(self.lc.get_weight, self.cb_weight, self.increase_error_count) self.weight_label = WeightLabel() self.gain = 0 # 128x self.current_value = None self.calibration = None plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Weight [g]', plot_list) self.button_calibration = QPushButton("Calibration") self.button_calibration.clicked.connect(self.button_calibration_clicked) self.button_tare = QPushButton("Tare") self.button_tare.clicked.connect(self.button_tare_clicked) self.enable_led = QCheckBox("LED On") self.enable_led.stateChanged.connect(self.enable_led_changed) self.spin_average = QSpinBox() self.spin_average.setMinimum(0) self.spin_average.setMaximum(40) self.spin_average.setSingleStep(1) self.spin_average.setValue(5) self.spin_average.editingFinished.connect(self.spin_average_finished) self.label_average = QLabel('Length of moving average:') layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.weight_label) layout_h.addStretch() self.rate_label = QLabel('Rate: ') self.rate_combo = QComboBox() self.rate_combo.addItem("10Hz") self.rate_combo.addItem("80Hz") self.rate_combo.currentIndexChanged.connect(self.new_config) layout_avg = QHBoxLayout() layout_avg.addWidget(self.label_average) layout_avg.addWidget(self.spin_average) layout_avg.addWidget(self.rate_label) layout_avg.addWidget(self.rate_combo) layout_avg.addStretch() layout_avg.addWidget(self.button_calibration) layout_avg.addWidget(self.button_tare) layout_avg.addWidget(self.enable_led) layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addWidget(self.plot_widget) layout.addLayout(layout_avg)
def __init__(self, ipcon, uid, version): PluginBase.__init__(self, ipcon, uid, 'Line Bricklet', version) self.line = BrickletLine(uid, ipcon) self.qtcb_reflectivity.connect(self.cb_reflectivity) self.line.register_callback(self.line.CALLBACK_REFLECTIVITY, self.qtcb_reflectivity.emit) self.reflectivity_label = ReflectivityLabel() self.rf = ReflectivityFrame() self.current_value = None plot_list = [['', Qt.red, self.get_current_value]] self.plot_widget = PlotWidget('Reflectivity', plot_list) layout_h = QHBoxLayout() layout_h.addStretch() layout_h.addWidget(self.reflectivity_label) layout_h.addStretch() layout_h2 = QHBoxLayout() layout_h2.addStretch() layout_h2.addWidget(self.rf) layout_h2.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addLayout(layout_h2) layout.addWidget(self.plot_widget)
def __init__(self, *args): PluginBase.__init__(self, BrickletGPS, *args) self.setupUi(self) self.gps = self.device self.cbe_universal = CallbackEmulator(self.get_universal, self.cb_universal, self.increase_error_count) self.format_combobox.currentIndexChanged.connect(self.format_changed) self.show_pos.clicked.connect(self.show_pos_clicked) self.hot_start.clicked.connect(lambda: self.restart_clicked(0)) self.warm_start.clicked.connect(lambda: self.restart_clicked(1)) self.cold_start.clicked.connect(lambda: self.restart_clicked(2)) self.factory_reset.clicked.connect(lambda: self.restart_clicked(3)) self.had_fix = False self.last_lat = 0 self.last_ns = 'U' self.last_long = 0 self.last_ew = 'U' self.last_pdop = 0 self.last_hdop = 0 self.last_vdop = 0 self.last_epe = 0
def __init__(self, *args): PluginBase.__init__(self, BrickletIndustrialDual020mA, *args) self.dual020 = self.device self.str_connected = 'Sensor {0} is currently <font color="green">connected</font>' self.str_not_connected = 'Sensor {0} is currently <font color="red">not connected</font>' self.cbe_current0 = CallbackEmulator(functools.partial(self.dual020.get_current, 0), functools.partial(self.cb_current, 0), self.increase_error_count) self.cbe_current1 = CallbackEmulator(functools.partial(self.dual020.get_current, 1), functools.partial(self.cb_current, 1), self.increase_error_count) self.current_label = [CurrentLabel(), CurrentLabel()] self.sample_rate_label1 = QLabel('Sample Rate:') self.sample_rate_combo = QComboBox() self.sample_rate_combo.addItem('240') self.sample_rate_combo.addItem('60') self.sample_rate_combo.addItem('15') self.sample_rate_combo.addItem('4') self.sample_rate_label2 = QLabel('Samples per second') self.connected_label = [QLabel(self.str_not_connected.format(0)), QLabel(self.str_not_connected.format(1))] self.current_value = [None, None] self.sample_rate_combo.currentIndexChanged.connect(self.sample_rate_combo_index_changed) plot_list = [['Sensor 0', Qt.red, self.get_current_value0], ['Sensor 1', Qt.blue, self.get_current_value1]] self.plot_widget = PlotWidget('Current [mA]', plot_list) layout_h = QHBoxLayout() layout_h.addWidget(QLabel("Sensor 0: ")) layout_h.addWidget(self.current_label[0]) layout_h.addStretch() layout_h.addWidget(self.connected_label[0]) layout_h2 = QHBoxLayout() layout_h2.addWidget(QLabel("Sensor 1: ")) layout_h2.addWidget(self.current_label[1]) layout_h2.addStretch() layout_h2.addWidget(self.connected_label[1]) layout_h3 = QHBoxLayout() layout_h3.addWidget(self.sample_rate_label1) layout_h3.addWidget(self.sample_rate_combo) layout_h3.addWidget(self.sample_rate_label2) layout_h3.addStretch() layout = QVBoxLayout(self) layout.addLayout(layout_h) layout.addLayout(layout_h2) layout.addWidget(self.plot_widget) layout.addLayout(layout_h3)
def __init__(self, *args): PluginBase.__init__(self, BrickletLoadCell, *args) self.lc = self.device self.cbe_weight = CallbackEmulator(self.lc.get_weight, self.cb_weight, self.increase_error_count) self.gain = 0 # 128x self.current_weight = None # int, g self.calibration = None plots = [('Weight', Qt.red, lambda: self.current_weight, format_weight) ] self.plot_widget = PlotWidget('Weight [g]', plots) self.button_calibration = QPushButton("Calibration...") self.button_calibration.clicked.connect( self.button_calibration_clicked) self.button_tare = QPushButton("Tare") self.button_tare.clicked.connect(self.button_tare_clicked) self.enable_led = QCheckBox("Enable LED") self.enable_led.stateChanged.connect(self.enable_led_changed) self.spin_average = QSpinBox() self.spin_average.setMinimum(0) self.spin_average.setMaximum(40) self.spin_average.setSingleStep(1) self.spin_average.setValue(5) self.spin_average.editingFinished.connect(self.spin_average_finished) self.label_average = QLabel('Moving Average Length:') self.rate_label = QLabel('Rate:') self.rate_combo = QComboBox() self.rate_combo.addItem("10 Hz") self.rate_combo.addItem("80 Hz") self.rate_combo.currentIndexChanged.connect(self.new_config) hlayout = QHBoxLayout() hlayout.addWidget(self.label_average) hlayout.addWidget(self.spin_average) hlayout.addWidget(self.rate_label) hlayout.addWidget(self.rate_combo) hlayout.addStretch() hlayout.addWidget(self.button_calibration) hlayout.addWidget(self.button_tare) hlayout.addWidget(self.enable_led) line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, *args): PluginBase.__init__(self, BrickletPTC, *args) self.ptc = self.device self.str_connected = 'Sensor is <font color="green">connected</font>' self.str_not_connected = 'Sensor is <font color="red">not connected</font>' self.cbe_temperature = CallbackEmulator(self.ptc.get_temperature, self.cb_temperature, self.increase_error_count) #self.cbe_resistance = CallbackEmulator(self.ptc.get_resistance, # self.cb_resistance, # self.increase_error_count) #self.resistance_label = ResistanceLabel() self.wire_label = QLabel('Wire Type:') self.wire_combo = QComboBox() self.wire_combo.addItem('2-Wire') self.wire_combo.addItem('3-Wire') self.wire_combo.addItem('4-Wire') self.noise_label = QLabel('Noise Rejection Filter:') self.noise_combo = QComboBox() self.noise_combo.addItem('50 Hz') self.noise_combo.addItem('60 Hz') self.connected_label = QLabel(self.str_connected) self.current_temperature = None # float, °C self.wire_combo.currentIndexChanged.connect(self.wire_combo_index_changed) self.noise_combo.currentIndexChanged.connect(self.noise_combo_index_changed) plots = [('Temperature', Qt.red, lambda: self.current_temperature, u'{} °C'.format)] self.plot_widget = PlotWidget(u'Temperature [°C]', plots, extra_key_widgets=[self.connected_label]) hlayout = QHBoxLayout() hlayout.addWidget(self.wire_label) hlayout.addWidget(self.wire_combo) hlayout.addStretch() hlayout.addWidget(self.noise_label) hlayout.addWidget(self.noise_combo) line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(line) layout.addLayout(hlayout) self.connected_timer = QTimer() self.connected_timer.timeout.connect(self.update_connected) self.connected_timer.setInterval(1000)
def __init__(self, *args): PluginBase.__init__(self, BrickletAnalogIn, *args) self.ai = self.device self.cbe_voltage = CallbackEmulator(self.ai.get_voltage, self.cb_voltage, self.increase_error_count) self.current_voltage = None # float, V plots = [('Voltage', Qt.red, lambda: self.current_voltage, format_voltage)] self.plot_widget = PlotWidget('Voltage [V]', plots) layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) if self.firmware_version >= (2, 0, 1): self.combo_range = QComboBox() self.combo_range.addItem('Automatic', BrickletAnalogIn.RANGE_AUTOMATIC) if self.firmware_version >= (2, 0, 3): self.combo_range.addItem('0 - 3.30 V', BrickletAnalogIn.RANGE_UP_TO_3V) self.combo_range.addItem('0 - 6.05 V', BrickletAnalogIn.RANGE_UP_TO_6V) self.combo_range.addItem('0 - 10.32 V', BrickletAnalogIn.RANGE_UP_TO_10V) self.combo_range.addItem('0 - 36.30 V', BrickletAnalogIn.RANGE_UP_TO_36V) self.combo_range.addItem('0 - 45.00 V', BrickletAnalogIn.RANGE_UP_TO_45V) self.combo_range.currentIndexChanged.connect(self.range_changed) hlayout = QHBoxLayout() hlayout.addWidget(QLabel('Range:')) hlayout.addWidget(self.combo_range) hlayout.addStretch() if self.firmware_version >= (2, 0, 3): self.spin_average = QSpinBox() self.spin_average.setMinimum(0) self.spin_average.setMaximum(255) self.spin_average.setSingleStep(1) self.spin_average.setValue(50) self.spin_average.editingFinished.connect( self.spin_average_finished) hlayout.addWidget(QLabel('Average Length:')) hlayout.addWidget(self.spin_average) line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout.addWidget(line) layout.addLayout(hlayout)
def __init__(self, *args): PluginBase.__init__(self, BrickletRS232, *args) self.setupUi(self) # the firmware version of a EEPROM Bricklet can (under common circumstances) # not change during the lifetime of an EEPROM Bricklet plugin. therefore, # it's okay to make final decisions based on it here self.has_error_callback = self.firmware_version >= (2, 0, 1) self.text.setReadOnly(True) self.rs232 = self.device self.read_callback_was_enabled = None self.qtcb_read.connect(self.cb_read) self.rs232.register_callback(self.rs232.CALLBACK_READ, self.qtcb_read.emit) if self.has_error_callback: self.label_no_error_support.hide() self.qtcb_error.connect(self.cb_error) self.rs232.register_callback(self.rs232.CALLBACK_ERROR, self.qtcb_error.emit) else: self.widget_errors.hide() self.input_combobox.addItem("") self.input_combobox.lineEdit().setMaxLength(58) self.input_combobox.lineEdit().returnPressed.connect(self.input_changed) self.line_ending_lineedit.setValidator(HexValidator()) self.line_ending_combobox.currentIndexChanged.connect(self.line_ending_changed) self.line_ending_lineedit.editingFinished.connect(self.line_ending_changed) self.baudrate_combobox.currentIndexChanged.connect(self.configuration_changed) self.parity_combobox.currentIndexChanged.connect(self.configuration_changed) self.stopbits_spinbox.valueChanged.connect(self.configuration_changed) self.wordlength_spinbox.valueChanged.connect(self.configuration_changed) self.flowcontrol_combobox.currentIndexChanged.connect(self.configuration_changed) self.text_type_combobox.currentIndexChanged.connect(self.text_type_changed) self.hextext = QHexeditWidget(self.text.font()) self.hextext.hide() self.layout().insertWidget(2, self.hextext) self.button_clear_text.clicked.connect(lambda: self.text.setPlainText("")) self.button_clear_text.clicked.connect(self.hextext.clear) self.save_button.clicked.connect(self.save_clicked) self.error_overrun = 0 self.error_parity = 0 self.error_framing = 0 self.last_char = ''
def __init__(self, *args): PluginBase.__init__(self, None, *args, override_base_name='Error') layout = QVBoxLayout(self) layout.addStretch() label = QLabel("An error occured while the tab for this Brick or Bricklet was created.") label.setAlignment(Qt.AlignHCenter) layout.addWidget(label) layout.addStretch()