def __init__(self, *args): super().__init__(BrickletCO2V2, *args) self.co2 = self.device self.cbe_all_values = CallbackEmulator(self, self.co2.get_all_values, None, self.cb_all_values, self.increase_error_count) self.current_co2 = CurveValueWrapper() # int, ppm self.current_temperature = CurveValueWrapper() # float, °C self.current_humidity = CurveValueWrapper() # float, %RH plots_co2 = [('CO2', Qt.red, self.current_co2, '{} PPM'.format)] self.plot_widget_co2 = PlotWidget('CO2 [PPM]', plots_co2, y_resolution=1.0) plots_temperature = [('Temperature', Qt.red, self.current_temperature, '{} °C'.format)] self.plot_widget_temperature = PlotWidget('Temperature [°C]', plots_temperature, y_resolution=0.01) plots_humidity = [('Relative Humidity', Qt.red, self.current_humidity, '{} %RH'.format)] self.plot_widget_humidity = PlotWidget('Relative Humidity [%RH]', plots_humidity, y_resolution=0.01) layout_plot1 = QHBoxLayout() layout_plot1.addWidget(self.plot_widget_co2) layout_plot2 = QHBoxLayout() layout_plot2.addWidget(self.plot_widget_temperature) layout_plot2.addWidget(self.plot_widget_humidity) layout_main = QVBoxLayout(self) layout_main.addLayout(layout_plot1) layout_main.addLayout(layout_plot2)
def __init__(self, *args): COMCUPluginBase.__init__(self, BrickletEnergyMonitor, *args) self.setupUi(self) self.energy_monitor = self.device self.cbe_get_energy_data = CallbackEmulator( self.energy_monitor.get_energy_data, None, self.cb_energy_data, self.increase_error_count) self.cbe_get_transformer_status = CallbackEmulator( self.energy_monitor.get_transformer_status, None, self.cb_transformer_status, self.increase_error_count) plots_waveform_v = [('Waveform V', Qt.red, None, None)] self.plot_widget_waveform_v = PlotWidget( 'Voltage [V]', plots_waveform_v, clear_button=None, x_diff=768 * ENERGY_MONITOR_MS_PER_TICK, x_scale_title_text='Time [ms]', key=None, x_scale_visible=False) plots_waveform_a = [('Waveform A', Qt.red, None, None)] self.plot_widget_waveform_a = PlotWidget( 'Current [A]', plots_waveform_a, clear_button=None, x_diff=768 * ENERGY_MONITOR_MS_PER_TICK, x_scale_title_text='Time [ms]', key=None) self.plot_widget_waveform_v.add_y_scale_sibling( self.plot_widget_waveform_a) self.plot_widget_waveform_a.add_y_scale_sibling( self.plot_widget_waveform_v) # try to make the actual curve area equal in height by fiddling with the # minimum-height and the stretch factors self.plot_widget_waveform_v.setMinimumHeight(194) self.plot_widget_waveform_a.setMinimumHeight(250) self.layout_graph.insertWidget(0, self.plot_widget_waveform_v, 86) self.layout_graph.addWidget(self.plot_widget_waveform_a, 100) self.x_data = [ x * ENERGY_MONITOR_MS_PER_TICK for x in list(range(768)) ] self.button_energy.clicked.connect(self.button_energy_clicked) self.button_transformer_settings.clicked.connect( self.button_transformer_settings_clicked) self.voltage_connected = True self.current_connected = True self.running = False
def __init__(self, *args): super().__init__(BrickletAirQuality, *args) self.air_quality = self.device self.cbe_all_values = CallbackEmulator(self, self.air_quality.get_all_values, None, self.cb_all_values, self.increase_error_count) self.current_iaq_index = CurveValueWrapper() # float self.current_temperature = CurveValueWrapper() # float, °C self.current_humidity = CurveValueWrapper() # float, %RH self.current_air_pressure = CurveValueWrapper() # float, hPa self.iaq_accuracy_label = QLabel("(Accuracy: TBD)") plots_iaq_index = [('IAQ Index', Qt.red, self.current_iaq_index, '{}'.format)] self.plot_widget_iaq_index = PlotWidget( 'IAQ Index', plots_iaq_index, extra_key_widgets=(self.iaq_accuracy_label, ), y_resolution=1.0) plots_temperature = [('Temperature', Qt.red, self.current_temperature, '{} °C'.format)] self.plot_widget_temperature = PlotWidget('Temperature [°C]', plots_temperature, y_resolution=0.01) plots_humidity = [('Relative Humidity', Qt.red, self.current_humidity, '{} %RH'.format)] self.plot_widget_humidity = PlotWidget('Relative Humidity [%RH]', plots_humidity, y_resolution=0.01) plots_air_pressure = [ ('Air Pressure', Qt.red, self.current_air_pressure, '{} hPa (QFE)'.format) ] self.plot_widget_air_pressure = PlotWidget('Air Pressure [hPa]', plots_air_pressure, y_resolution=0.01) layout_plot1 = QHBoxLayout() layout_plot1.addWidget(self.plot_widget_iaq_index) layout_plot1.addWidget(self.plot_widget_temperature) layout_plot2 = QHBoxLayout() layout_plot2.addWidget(self.plot_widget_humidity) layout_plot2.addWidget(self.plot_widget_air_pressure) layout_main = QVBoxLayout(self) layout_main.addLayout(layout_plot1) layout_main.addLayout(layout_plot2)
def __init__(self, *args): COMCUPluginBase.__init__(self, BrickletVoltageCurrentV2, *args) self.setupUi(self) self.vc = self.device self.cbe_voltage = CallbackEmulator(self.vc.get_voltage, None, self.cb_voltage, self.increase_error_count) self.cbe_current = CallbackEmulator(self.vc.get_current, None, self.cb_current, self.increase_error_count) self.cbe_power = CallbackEmulator(self.vc.get_power, None, self.cb_power, self.increase_error_count) self.current_voltage = CurveValueWrapper() # float, V self.current_current = CurveValueWrapper() # float, A self.current_power = CurveValueWrapper() # float, W plots_voltage = [('Voltage', Qt.red, self.current_voltage, format_voltage)] plots_current = [('Current', Qt.blue, self.current_current, format_current)] plots_power = [('Power', Qt.darkGreen, self.current_power, format_power)] self.plot_widget_voltage = PlotWidget( 'Voltage [V]', plots_voltage, clear_button=self.button_clear_graphs, y_resolution=0.001) self.plot_widget_current = PlotWidget( 'Current [A]', plots_current, clear_button=self.button_clear_graphs, y_resolution=0.001) self.plot_widget_power = PlotWidget( 'Power [W]', plots_power, clear_button=self.button_clear_graphs, y_resolution=0.001) self.save_conf_button.clicked.connect(self.save_conf_clicked) self.calibration = None self.button_calibration.clicked.connect(self.calibration_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, *args): super().__init__(BrickletHumidityV2, *args) self.hum = self.device self.cbe_humidity = CallbackEmulator(self.hum.get_humidity, None, self.cb_humidity, self.increase_error_count) self.cbe_temperature = CallbackEmulator(self.hum.get_temperature, None, self.cb_temperature, self.increase_error_count) self.current_humidity = CurveValueWrapper() # float, %RH self.current_temperature = CurveValueWrapper() # float, °C moving_average_humidity = MovingAverageConfig( 1, 1000, self.new_moving_average_humidity) plots_humidity = [('Relative Humidity', Qt.red, self.current_humidity, '{} %RH'.format)] self.plot_widget_humidity = PlotWidget( 'Relative Humidity [%RH]', plots_humidity, moving_average_config=moving_average_humidity, y_resolution=0.01) moving_average_temperature = MovingAverageConfig( 1, 1000, self.new_moving_average_temperature) plots_temperature = [('Temperature', Qt.red, self.current_temperature, '{} °C'.format)] self.plot_widget_temperature = PlotWidget( 'Temperature [°C]', plots_temperature, moving_average_config=moving_average_temperature, y_resolution=0.01) self.enable_heater = QCheckBox("Enable Heater") self.enable_heater.stateChanged.connect(self.enable_heater_changed) layout_plot = QHBoxLayout() layout_plot.addWidget(self.plot_widget_humidity) layout_plot.addWidget(self.plot_widget_temperature) layout_config = QHBoxLayout() layout_config.addStretch() layout_config.addWidget(self.enable_heater) layout_config.addStretch() layout_main = QVBoxLayout(self) layout_main.addLayout(layout_plot) layout_main.addLayout(layout_config)
def __init__(self, *args): COMCUPluginBase.__init__(self, BrickletHumidityV2, *args) self.hum = self.device self.cbe_humidity = CallbackEmulator(self.hum.get_humidity, self.cb_humidity, self.increase_error_count) self.cbe_temperature = CallbackEmulator(self.hum.get_temperature, self.cb_temperature, self.increase_error_count) self.current_humidity = None # float, %RH self.current_temperature = None # float, °C moving_average_humidity = MovingAverageConfig( 1, 1000, self.new_moving_average_humidity) plots_humidity = [(u'Relative Humidity', Qt.red, lambda: self.current_humidity, u'{} %RH'.format)] self.plot_widget_humidity = PlotWidget( u'Relative Humidity [%RH]', plots_humidity, moving_average_config=moving_average_humidity) moving_average_temperature = MovingAverageConfig( 1, 1000, self.new_moving_average_temperature) plots_temperature = [ (u'Temperature', Qt.red, lambda: self.current_temperature, u'{} °C'.format) ] self.plot_widget_temperature = PlotWidget( u'Temperature [°C]', plots_temperature, moving_average_config=moving_average_temperature) self.enable_heater = QCheckBox("Enable Heater") self.enable_heater.stateChanged.connect(self.enable_heater_changed) layout_plot = QHBoxLayout() layout_plot.addWidget(self.plot_widget_humidity) layout_plot.addWidget(self.plot_widget_temperature) layout_config = QHBoxLayout() layout_config.addStretch() layout_config.addWidget(self.enable_heater) layout_config.addStretch() layout_main = QVBoxLayout(self) layout_main.addLayout(layout_plot) layout_main.addLayout(layout_config)
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): COMCUPluginBase.__init__(self, BrickletTemperatureV2, *args) self.tem = self.device self.cbe_temperature = CallbackEmulator(self.tem.get_temperature, self.cb_temperature, self.increase_error_count) self.current_temperature = None # float, °C plots_temperature = [(u'Temperature', Qt.red, lambda: self.current_temperature, u'{} °C'.format)] self.plot_widget_temperature = PlotWidget(u'Temperature [°C]', plots_temperature) self.enable_heater = QCheckBox("Enable Heater") self.enable_heater.stateChanged.connect(self.enable_heater_changed) layout_plot = QHBoxLayout() layout_plot.addWidget(self.plot_widget_temperature) layout_config = QHBoxLayout() layout_config.addStretch() layout_config.addWidget(self.enable_heater) layout_config.addStretch() layout_main = QVBoxLayout(self) layout_main.addLayout(layout_plot) layout_main.addLayout(layout_config)
def __init__(self, *args): super().__init__(BrickletMotorizedLinearPoti, *args) self.mp = self.device self.cbe_position = CallbackEmulator(self.mp.get_position, None, self.cb_position, self.increase_error_count) self.current_position = CurveValueWrapper() self.slider = QSlider(Qt.Horizontal) self.slider.setRange(0, 100) self.slider.setMinimumWidth(200) self.slider.setEnabled(False) plots = [('Potentiometer Position', Qt.red, self.current_position, str) ] self.plot_widget = PlotWidget('Position', plots, extra_key_widgets=[self.slider], update_interval=0.025, y_resolution=1.0) self.motor_slider = QSlider(Qt.Horizontal) self.motor_slider.setRange(0, 100) self.motor_slider.valueChanged.connect(self.motor_slider_value_changed) self.motor_hold_position = QCheckBox("Hold Position") self.motor_drive_mode = QComboBox() self.motor_drive_mode.addItem('Fast') self.motor_drive_mode.addItem('Smooth') def get_motor_slider_value(): return self.motor_slider.value() self.motor_hold_position.stateChanged.connect( lambda x: self.motor_slider_value_changed(get_motor_slider_value() )) self.motor_drive_mode.currentIndexChanged.connect( lambda x: self.motor_slider_value_changed(get_motor_slider_value() )) self.motor_position_label = MotorPositionLabel( 'Motor Target Position:') hlayout = QHBoxLayout() hlayout.addWidget(self.motor_position_label) hlayout.addWidget(self.motor_slider) hlayout.addWidget(self.motor_drive_mode) hlayout.addWidget(self.motor_hold_position) line = QFrame() line.setObjectName("line") 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, 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, 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, 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, BrickletCurrent25, *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, 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): COMCUPluginBase.__init__(self, BrickletHallEffectV2, *args) self.setupUi(self) self.hf = self.device self.cbe_magnetic_flux_density = CallbackEmulator( self.hf.get_magnetic_flux_density, None, self.cb_magnetic_flux_density, self.increase_error_count) self.cbe_counter = CallbackEmulator(self.get_counter, False, self.cb_counter, self.increase_error_count) self.current_magnetic_flux_density = CurveValueWrapper() plots = [('Magnetic Flux Density', Qt.red, self.current_magnetic_flux_density, '{} µT'.format)] self.plot_widget = PlotWidget('Magnetic Flux Density [µT]', plots, y_resolution=1.0) self.button_reset.clicked.connect(self.button_reset_clicked) self.spinbox_low.editingFinished.connect(self.new_config) self.spinbox_high.editingFinished.connect(self.new_config) self.spinbox_debounce.editingFinished.connect(self.new_config) self.main_vert_layout.insertWidget(0, self.plot_widget)
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, *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): super().__init__(BrickletDistanceUSV2, *args) self.dist = self.device self.cbe_distance = CallbackEmulator(self, self.dist.get_distance, None, self.cb_distance, self.increase_error_count) self.current_distance = CurveValueWrapper() plots = [('Distance', Qt.red, self.current_distance, '{:.1f} cm'.format)] self.plot_widget = PlotWidget('Distance [cm]', plots, y_resolution=1.0) self.update_rate_label = QLabel('Update Rate:') self.update_rate_combo = QComboBox() self.update_rate_combo.addItem(" 2 Hz") self.update_rate_combo.addItem("10 Hz") self.update_rate_combo.currentIndexChanged.connect( self.new_update_rate) hlayout = QHBoxLayout() hlayout.addWidget(self.update_rate_label) hlayout.addWidget(self.update_rate_combo) hlayout.addStretch() layout = QVBoxLayout(self) layout.addWidget(self.plot_widget) layout.addLayout(hlayout)
def __init__(self, *args): COMCUPluginBase.__init__(self, BrickletSoundPressureLevel, *args) self.setupUi(self) self.sound_pressure_level = self.device self.cbe_get_decibel = CallbackEmulator(self, self.sound_pressure_level.get_decibel, None, self.cb_decibel, self.increase_error_count) self.qtcb_spectrum.connect(self.cb_spectrum) self.thermo = TuningThermo() plots_spectrum = [('Spectrum', Qt.red, None, '{} °C'.format)] self.plot_widget_spectrum = PlotWidget('Value [dB]', plots_spectrum, clear_button=None, x_diff=20480, x_scale_title_text='Frequency [Hz]', x_scale_skip_last_tick=False, key=None, y_resolution=0.1, y_scale_shrinkable=False) self.plot_widget_spectrum.set_x_scale(512*40//5, 1) self.combo_fft_size.currentIndexChanged.connect(self.config_changed) self.combo_weighting.currentIndexChanged.connect(self.config_changed) self.layout_graph.addWidget(self.plot_widget_spectrum) self.layout_decibel.insertWidget(3, self.thermo) self.last_spectrum_length = 512 self.last_y_data = [0]*512
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, 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, *args): super().__init__(BrickletCurrent12, *args) self.cur = self.device self.cbe_current = CallbackEmulator(self.cur.get_current, None, 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 = CurveValueWrapper() # float, A plots = [('Current', Qt.red, self.current_current, format_current)] self.plot_widget = PlotWidget('Current [A]', plots, extra_key_widgets=[self.over_label], y_resolution=0.001) line = QFrame() line.setObjectName("line") 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, 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, 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): super().__init__(BrickletTemperatureV2, *args) self.tem = self.device self.cbe_temperature = CallbackEmulator(self.tem.get_temperature, None, self.cb_temperature, self.increase_error_count) self.current_temperature = CurveValueWrapper() # float, °C plots_temperature = [('Temperature', Qt.red, self.current_temperature, '{} °C'.format)] self.plot_widget_temperature = PlotWidget('Temperature [°C]', plots_temperature, y_resolution=0.01) self.enable_heater = QCheckBox("Enable Heater") self.enable_heater.stateChanged.connect(self.enable_heater_changed) layout_plot = QHBoxLayout() layout_plot.addWidget(self.plot_widget_temperature) layout_config = QHBoxLayout() layout_config.addStretch() layout_config.addWidget(self.enable_heater) layout_config.addStretch() layout_main = QVBoxLayout(self) layout_main.addLayout(layout_plot) layout_main.addLayout(layout_config)
def __init__(self, *args): super().__init__(BrickletRotaryPoti, *args) self.rp = self.device self.cbe_position = CallbackEmulator(self.rp.get_position, None, 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 = CurveValueWrapper() plots = [('Position', Qt.red, self.current_position, str)] self.plot_widget = PlotWidget('Position', plots, update_interval=0.025, y_resolution=1.0) layout = QHBoxLayout(self) layout.addWidget(self.plot_widget) layout.addWidget(self.position_knob)
def __init__(self, *args): super().__init__(BrickletLoadCell, *args) self.lc = self.device self.cbe_weight = CallbackEmulator(self.lc.get_weight, None, self.cb_weight, self.increase_error_count) self.gain = 0 # 128x self.current_weight = CurveValueWrapper() # int, g self.calibration = None plots = [('Weight', Qt.red, self.current_weight, format_weight)] self.plot_widget = PlotWidget('Weight [g]', plots, y_resolution=1.0) 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.setObjectName("line") 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): super().__init__(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, self.ptc.get_temperature, None, self.cb_temperature, self.increase_error_count) 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 = CurveValueWrapper() # 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, self.current_temperature, '{} °C'.format)] self.plot_widget = PlotWidget('Temperature [°C]', plots, extra_key_widgets=[self.connected_label], y_resolution=0.01) 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.setObjectName("line") 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) self.connected_timer.timeout.connect(self.update_connected) self.connected_timer.setInterval(1000)
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, 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)