本文整理汇总了Python中brickv.utils.CallbackEmulator类的典型用法代码示例。如果您正苦于以下问题:Python CallbackEmulator类的具体用法?Python CallbackEmulator怎么用?Python CallbackEmulator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CallbackEmulator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
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)
示例2: AmbientLight
class AmbientLight(PluginBase):
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 start(self):
async_call(self.al.get_illuminance, None, self.cb_illuminance, self.increase_error_count)
self.cbe_illuminance.set_period(100)
self.plot_widget.stop = False
def stop(self):
self.cbe_illuminance.set_period(0)
self.plot_widget.stop = True
def destroy(self):
pass
def get_url_part(self):
return 'ambient_light'
@staticmethod
def has_device_identifier(device_identifier):
return device_identifier == BrickletAmbientLight.DEVICE_IDENTIFIER
def get_current_value(self):
return self.current_value
def cb_illuminance(self, illuminance):
self.current_value = illuminance/10.0
self.illuminance_label.setText(str(self.current_value))
value = illuminance*255/9000
self.alf.set_color(value, value, value)
示例3: LinearPoti
class LinearPoti(PluginBase):
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 start(self):
async_call(self.lp.get_position, None, self.cb_position, self.increase_error_count)
self.cbe_position.set_period(25)
self.plot_widget.stop = False
def stop(self):
self.cbe_position.set_period(0)
self.plot_widget.stop = True
def destroy(self):
pass
def get_url_part(self):
return 'linear_poti'
@staticmethod
def has_device_identifier(device_identifier):
return device_identifier == BrickletLinearPoti.DEVICE_IDENTIFIER
def get_current_value(self):
return self.current_value
def cb_position(self, position):
self.current_value = position
self.slider.setValue(position)
self.position_label.setText(str(position))
示例4: __init__
def __init__(self, *args):
PluginBase.__init__(self, BrickletIndustrialDualAnalogIn, *args)
self.analog_in = self.device
self.cbe_voltage0 = CallbackEmulator(functools.partial(self.analog_in.get_voltage, 0),
functools.partial(self.cb_voltage, 0),
self.increase_error_count)
self.cbe_voltage1 = CallbackEmulator(functools.partial(self.analog_in.get_voltage, 1),
functools.partial(self.cb_voltage, 1),
self.increase_error_count)
self.voltage_label = [VoltageLabel(), VoltageLabel()]
self.sample_rate_label1 = QLabel('Sample Rate:')
self.sample_rate_combo = QComboBox()
self.sample_rate_combo.addItem('976')
self.sample_rate_combo.addItem('488')
self.sample_rate_combo.addItem('244')
self.sample_rate_combo.addItem('122')
self.sample_rate_combo.addItem('61')
self.sample_rate_combo.addItem('4')
self.sample_rate_combo.addItem('2')
self.sample_rate_combo.addItem('1')
self.sample_rate_label2 = QLabel('Samples per second')
self.voltage_value = [None, None]
self.sample_rate_combo.currentIndexChanged.connect(self.sample_rate_combo_index_changed)
plot_list = [['Channel 0', Qt.red, self.get_voltage_value0],
['Channel 1', Qt.blue, self.get_voltage_value1]]
self.plot_widget = PlotWidget('Voltage [V]', plot_list)
layout_h = QHBoxLayout()
layout_h.addStretch()
layout_h.addWidget(QLabel("Channel 0: "))
layout_h.addWidget(self.voltage_label[0])
layout_h.addStretch()
layout_h1 = QHBoxLayout()
layout_h1.addStretch()
layout_h1.addWidget(QLabel("Channel 1: "))
layout_h1.addWidget(self.voltage_label[1])
layout_h1.addStretch()
layout_h2 = QHBoxLayout()
layout_h2.addWidget(self.sample_rate_label1)
layout_h2.addWidget(self.sample_rate_combo)
layout_h2.addWidget(self.sample_rate_label2)
layout_h2.addStretch()
layout = QVBoxLayout(self)
layout.addLayout(layout_h)
layout.addLayout(layout_h1)
layout.addWidget(self.plot_widget)
layout.addLayout(layout_h2)
示例5: Temperature
class Temperature(PluginBase):
def __init__(self, *args):
PluginBase.__init__(self, BrickletTemperature, *args)
self.tem = self.device
self.cbe_temperature = CallbackEmulator(self.tem.get_temperature,
self.cb_temperature,
self.increase_error_count)
self.temperature_label = TemperatureLabel()
self.current_value = None
plot_list = [['', Qt.red, self.get_current_value]]
self.plot_widget = PlotWidget('Temperature [%cC]' % 0xB0, plot_list)
layout_h = QHBoxLayout()
layout_h.addStretch()
layout_h.addWidget(self.temperature_label)
layout_h.addStretch()
layout = QVBoxLayout(self)
layout.addLayout(layout_h)
layout.addWidget(self.plot_widget)
def start(self):
async_call(self.tem.get_temperature, None, self.cb_temperature, self.increase_error_count)
self.cbe_temperature.set_period(100)
self.plot_widget.stop = False
def stop(self):
self.cbe_temperature.set_period(0)
self.plot_widget.stop = True
def destroy(self):
pass
def get_url_part(self):
return 'temperature'
@staticmethod
def has_device_identifier(device_identifier):
return device_identifier == BrickletTemperature.DEVICE_IDENTIFIER
def get_current_value(self):
return self.current_value
def cb_temperature(self, temperature):
self.current_value = temperature/100.0
self.temperature_label.setText(str(temperature/100.0))
示例6: Voltage
class Voltage(PluginBase):
def __init__(self, *args):
PluginBase.__init__(self, BrickletVoltage, *args)
self.vol = self.device
self.cbe_voltage = CallbackEmulator(self.vol.get_voltage,
self.cb_voltage,
self.increase_error_count)
self.voltage_label = CurrentLabel('Voltage: ')
self.current_value = None
plot_list = [['', Qt.red, self.get_current_value]]
self.plot_widget = PlotWidget('Voltage [mV]', plot_list)
layout_h = QHBoxLayout()
layout_h.addStretch()
layout_h.addWidget(self.voltage_label)
layout_h.addStretch()
layout = QVBoxLayout(self)
layout.addLayout(layout_h)
layout.addWidget(self.plot_widget)
def start(self):
async_call(self.vol.get_voltage, None, self.cb_voltage, self.increase_error_count)
self.cbe_voltage.set_period(100)
self.plot_widget.stop = False
def stop(self):
self.cbe_voltage.set_period(0)
self.plot_widget.stop = True
def destroy(self):
pass
def get_url_part(self):
return 'voltage'
@staticmethod
def has_device_identifier(device_identifier):
return device_identifier == BrickletVoltage.DEVICE_IDENTIFIER
def get_current_value(self):
return self.current_value
def cb_voltage(self, voltage):
self.current_value = voltage
self.voltage_label.setText(str(voltage/1000.0))
示例7: Humidity
class Humidity(PluginBase):
def __init__(self, *args):
PluginBase.__init__(self, BrickletHumidity, *args)
self.hum = self.device
self.cbe_humidity = CallbackEmulator(self.hum.get_humidity,
self.cb_humidity,
self.increase_error_count)
self.humidity_label = HumidityLabel('Humidity: ')
self.current_value = None
plot_list = [['', Qt.red, self.get_current_value]]
self.plot_widget = PlotWidget('Relative Humidity [%RH]', plot_list)
layout_h = QHBoxLayout()
layout_h.addStretch()
layout_h.addWidget(self.humidity_label)
layout_h.addStretch()
layout = QVBoxLayout(self)
layout.addLayout(layout_h)
layout.addWidget(self.plot_widget)
def start(self):
async_call(self.hum.get_humidity, None, self.cb_humidity, self.increase_error_count)
self.cbe_humidity.set_period(100)
self.plot_widget.stop = False
def stop(self):
self.cbe_humidity.set_period(0)
self.plot_widget.stop = True
def destroy(self):
pass
def get_url_part(self):
return 'humidity'
@staticmethod
def has_device_identifier(device_identifier):
return device_identifier == BrickletHumidity.DEVICE_IDENTIFIER
def get_current_value(self):
return self.current_value
def cb_humidity(self, humidity):
self.current_value = humidity/10.0
self.humidity_label.setText(str(humidity/10.0))
示例8: DistanceUS
class DistanceUS(PluginBase):
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.distance_label = DistanceLabel('Distance Value: ')
self.current_value = None
plot_list = [['', Qt.red, self.get_current_value]]
self.plot_widget = PlotWidget('Distance', plot_list)
layout_h1 = QHBoxLayout()
layout_h1.addStretch()
layout_h1.addWidget(self.distance_label)
layout_h1.addStretch()
layout = QVBoxLayout(self)
layout.addLayout(layout_h1)
layout.addWidget(self.plot_widget)
def start(self):
async_call(self.dist.get_distance_value, None, self.cb_distance, self.increase_error_count)
self.cbe_distance.set_period(100)
self.plot_widget.stop = False
def stop(self):
self.cbe_distance.set_period(0)
self.plot_widget.stop = True
def destroy(self):
pass
def get_url_part(self):
return 'distance_us'
@staticmethod
def has_device_identifier(device_identifier):
return device_identifier == BrickletDistanceUS.DEVICE_IDENTIFIER
def get_current_value(self):
return self.current_value
def cb_distance(self, distance):
self.current_value = distance
self.distance_label.setText(str(distance))
示例9: __init__
def __init__(self, *args):
PluginBase.__init__(self, BrickletDistanceIR, *args)
self.dist = self.device
self.cbe_distance = CallbackEmulator(self.dist.get_distance,
self.cb_distance,
self.increase_error_count)
self.cbe_analog_value = CallbackEmulator(self.dist.get_analog_value,
self.cb_analog_value,
self.increase_error_count)
self.analog_value = 0
self.distance_label = DistanceLabel('Distance: ')
self.analog_label = AnalogLabel('Analog value: ')
self.sample_layout = QHBoxLayout()
self.sample_label = QLabel('Sample Points:')
self.sample_edit = QLineEdit()
self.sample_file = QPushButton("Browse")
self.sample_save = QPushButton("Save")
self.sample_file.clicked.connect(self.sample_file_clicked)
self.sample_save.clicked.connect(self.sample_save_clicked)
self.sample_layout.addWidget(self.sample_label)
self.sample_layout.addWidget(self.sample_edit)
self.sample_layout.addWidget(self.sample_file)
self.sample_layout.addWidget(self.sample_save)
self.current_value = None
plot_list = [['', Qt.red, self.get_current_value]]
self.plot_widget = PlotWidget('Distance [cm]', plot_list)
layout_h1 = QHBoxLayout()
layout_h1.addStretch()
layout_h1.addWidget(self.distance_label)
layout_h1.addStretch()
layout_h2 = QHBoxLayout()
layout_h2.addStretch()
layout_h2.addWidget(self.analog_label)
layout_h2.addStretch()
layout = QVBoxLayout(self)
layout.addLayout(layout_h1)
layout.addLayout(layout_h2)
layout.addWidget(self.plot_widget)
layout.addLayout(self.sample_layout)
示例10: __init__
def __init__(self, *args):
PluginBase.__init__(self, BrickletTemperatureIR, *args)
self.tem = self.device
self.cbe_ambient_temperature = CallbackEmulator(self.tem.get_ambient_temperature,
self.cb_ambient_temperature,
self.increase_error_count)
self.cbe_object_temperature = CallbackEmulator(self.tem.get_object_temperature,
self.cb_object_temperature,
self.increase_error_count)
self.ambient_label = AmbientLabel()
self.object_label = ObjectLabel()
self.emissivity_label = QLabel('Emissivity: ')
self.emissivity_edit = QLineEdit()
self.emissivity_button = QPushButton('Save')
self.emissivity_layout = QHBoxLayout()
self.emissivity_layout.addWidget(self.emissivity_label)
self.emissivity_layout.addWidget(self.emissivity_edit)
self.emissivity_layout.addWidget(self.emissivity_button)
self.emissivity_button.clicked.connect(self.emissivity_clicked)
self.current_ambient = None
self.current_object = None
plot_list = [['Ambient', Qt.blue, self.get_current_ambient],
['Object', Qt.red, self.get_current_object]]
self.plot_widget = PlotWidget('Temperature [%cC]' % 0xB0, plot_list)
layout_h1 = QHBoxLayout()
layout_h1.addStretch()
layout_h1.addWidget(self.ambient_label)
layout_h1.addStretch()
layout_h2 = QHBoxLayout()
layout_h2.addStretch()
layout_h2.addWidget(self.object_label)
layout_h2.addStretch()
layout = QVBoxLayout(self)
layout.addLayout(layout_h1)
layout.addLayout(layout_h2)
layout.addWidget(self.plot_widget)
layout.addLayout(self.emissivity_layout)
示例11: __init__
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)
示例12: __init__
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)
示例13: __init__
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()
示例14: __init__
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)
示例15: __init__
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)