class Line(PluginBase): qtcb_reflectivity = pyqtSignal(int) 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 cb_reflectivity(self, reflectivity): self.current_value = reflectivity self.rf.set_reflectivity(reflectivity) self.reflectivity_label.setText(str(reflectivity)) def get_current_value(self): return self.current_value def start(self): async_call(self.line.get_reflectivity, None, self.cb_reflectivity, self.increase_error_count) async_call(self.line.set_reflectivity_callback_period, 100, None, self.increase_error_count) self.plot_widget.stop = False def stop(self): async_call(self.line.set_reflectivity_callback_period, 0, None, self.increase_error_count) self.plot_widget.stop = True def get_url_part(self): return 'line' @staticmethod def has_device_identifier(device_identifier): return device_identifier == BrickletLine.DEVICE_IDENTIFIER
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)