Beispiel #1
0
    def __init__(self, ipcon, uid, version):
        PluginBase.__init__(self, ipcon, uid, 'Master Brick', version)
        
        self.setupUi(self)

        self.master = BrickMaster(uid, ipcon)
        self.device = self.master
        
        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")
        
        # Chibi widget
        if self.version >= (1, 1, 0):
            self.extension_type_button.pressed.connect(self.extension_pressed)
            async_call(self.master.is_chibi_present, None, self.is_chibi_present_async, self.increase_error_count)
        else:
            self.extension_type_button.setEnabled(False)
            
        # RS485 widget
        if self.version >= (1, 2, 0):
            async_call(self.master.is_rs485_present, None, self.is_rs485_present_async, self.increase_error_count)
                
        # Wifi widget
        if self.version >= (1, 3, 0):
            async_call(self.master.is_wifi_present, None, self.is_wifi_present_async, self.increase_error_count)
Beispiel #2
0
 def __init__ (self, ipcon, uid):
     PluginBase.__init__(self, ipcon, uid)
     
     self.setupUi(self)
     
     self.io = bricklet_io4.IO4(self.uid)
     self.ipcon.add_device(self.io)
     self.version = '.'.join(map(str, self.io.get_version()[1]))
     
     self.qtcb_interrupt.connect(self.cb_interrupt)
     self.io.register_callback(self.io.CALLBACK_INTERRUPT,
                               self.qtcb_interrupt.emit)
     
     self.port_value = [self.av0, self.av1, self.av2, self.av3]
     self.port_direction = [self.ad0, self.ad1, self.ad2, self.ad3]
     self.port_config = [self.ac0, self.ac1, self.ac2, self.ac3]
     
     try:
         value = self.io.get_value()
         dir, config = self.io.get_configuration()
         self.init_values(value, dir, config)
     
         debounce = self.io.get_debounce_period()
         self.debounce_edit.setText(str(debounce))
     except ip_connection.Error:
         pass
     
     self.save_button.pressed.connect(self.save_pressed)
     self.pin_box.currentIndexChanged.connect(self.pin_changed)
     self.direction_box.currentIndexChanged.connect(self.direction_changed)
     self.debounce_save.pressed.connect(self.debounce_save_pressed)
     
     self.pin_changed(0)
Beispiel #3
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.hum = bricklet_humidity.Humidity(self.uid)
        self.ipcon.add_device(self.hum)
        self.version = '.'.join(map(str, self.hum.get_version()[1]))

        self.qtcb_humidity.connect(self.cb_humidity)
        self.hum.register_callback(self.hum.CALLBACK_HUMIDITY,
                                   self.qtcb_humidity.emit)

        self.humidity_label = HumidityLabel('Humidity: ')

        self.current_value = 0

        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)
Beispiel #4
0
    def __init__ (self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)
        
        self.hum = bricklet_humidity.Humidity(self.uid)
        self.ipcon.add_device(self.hum)
        self.version = '.'.join(map(str, self.hum.get_version()[1]))
        
        self.qtcb_humidity.connect(self.cb_humidity)
        self.hum.register_callback(self.hum.CALLBACK_HUMIDITY,
                                   self.qtcb_humidity.emit) 
        
        self.humidity_label = HumidityLabel('Humidity: ')
        
        self.current_value = 0
        
        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)
Beispiel #5
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.vol = bricklet_voltage.Voltage(self.uid)
        self.ipcon.add_device(self.vol)
        self.version = '.'.join(map(str, self.vol.get_version()[1]))

        self.qtcb_voltage.connect(self.cb_voltage)
        self.vol.register_callback(self.vol.CALLBACK_VOLTAGE,
                                   self.qtcb_voltage.emit)

        self.voltage_label = CurrentLabel('Voltage: ')

        self.current_value = 0

        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)
Beispiel #6
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.dr = bricklet_dual_relay.DualRelay(self.uid)
        self.ipcon.add_device(self.dr)
        self.version = '.'.join(map(str, self.dr.get_version()[1]))

        dr1_label = QLabel("Relay 1:")
        self.dr1_button = QPushButton("Off")
        dr1_layout = QHBoxLayout()
        dr1_layout.addStretch()
        dr1_layout.addWidget(dr1_label)
        dr1_layout.addWidget(self.dr1_button)
        dr1_layout.addStretch()

        dr2_label = QLabel("Relay 2:")
        self.dr2_button = QPushButton("Off")
        dr2_layout = QHBoxLayout()
        dr2_layout.addStretch()
        dr2_layout.addWidget(dr2_label)
        dr2_layout.addWidget(self.dr2_button)
        dr2_layout.addStretch()

        self.dr1_button.pressed.connect(self.dr1_pressed)
        self.dr2_button.pressed.connect(self.dr2_pressed)

        layout = QVBoxLayout(self)
        layout.addLayout(dr1_layout)
        layout.addLayout(dr2_layout)
        layout.addStretch()
Beispiel #7
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.al = bricklet_ambient_light.AmbientLight(self.uid)
        self.ipcon.add_device(self.al)
        self.version = ".".join(map(str, self.al.get_version()[1]))

        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 = 0
        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)
Beispiel #8
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)
        self.setupUi(self)

        self.master = brick_master.Master(self.uid)
        self.device = self.master
        self.ipcon.add_device(self.master)
        self.version = '.'.join(map(str, self.master.get_version()[1]))

        self.extension_type_button.pressed.connect(self.extension_pressed)

        self.update_timer = QTimer()
        self.update_timer.timeout.connect(self.update_data)

        num_extensions = 0
        # construct chibi widget
        #        if self.master.is_chibi_present():
        #            num_extensions += 1
        #            chibi = Chibi(self.master)
        #            self.extension_layout.addWidget(chibi)

        if num_extensions == 0:
            self.extension_label.setText("None Present")
        else:
            self.extension_label.setText("" + str(num_extensions) + " Present")
Beispiel #9
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.al = bricklet_ambient_light.AmbientLight(self.uid)
        self.ipcon.add_device(self.al)
        self.version = '.'.join(map(str, self.al.get_version()[1]))

        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 = 0
        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)
Beispiel #10
0
    def __init__ (self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)
        
        self.tem = bricklet_temperature.Temperature(self.uid)
        self.ipcon.add_device(self.tem)
        self.version = '.'.join(map(str, self.tem.get_version()[1]))
        
        self.qtcb_temperature.connect(self.cb_temperature)
        self.tem.register_callback(self.tem.CALLBACK_TEMPERATURE,
                                   self.qtcb_temperature.emit) 
        
        self.temperature_label = TemperatureLabel()
        self.cb_temperature(self.tem.get_temperature())
        
        self.current_value = 0
        
        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)
Beispiel #11
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.lp = bricklet_linear_poti.LinearPoti(self.uid)
        self.ipcon.add_device(self.lp)
        self.version = '.'.join(map(str, self.lp.get_version()[1]))

        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 = 0
        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)
Beispiel #12
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.lp = bricklet_linear_poti.LinearPoti(self.uid)
        self.ipcon.add_device(self.lp)
        self.version = ".".join(map(str, self.lp.get_version()[1]))

        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 = 0
        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, 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()
Beispiel #14
0
    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)
Beispiel #15
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.tem = bricklet_temperature.Temperature(self.uid)
        self.ipcon.add_device(self.tem)
        self.version = '.'.join(map(str, self.tem.get_version()[1]))

        self.qtcb_temperature.connect(self.cb_temperature)
        self.tem.register_callback(self.tem.CALLBACK_TEMPERATURE,
                                   self.qtcb_temperature.emit)

        self.temperature_label = TemperatureLabel()
        self.cb_temperature(self.tem.get_temperature())

        self.current_value = 0

        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)
Beispiel #16
0
 def __init__ (self, ipcon, uid):
     PluginBase.__init__(self, ipcon, uid)
     
     self.dr = bricklet_dual_relay.DualRelay(self.uid)
     self.ipcon.add_device(self.dr)
     self.version = '.'.join(map(str, self.dr.get_version()[1]))
     
     dr1_label = QLabel("Relay 1:")
     self.dr1_button = QPushButton("Off")
     dr1_layout = QHBoxLayout()
     dr1_layout.addStretch()
     dr1_layout.addWidget(dr1_label)
     dr1_layout.addWidget(self.dr1_button)
     dr1_layout.addStretch()
     
     dr2_label = QLabel("Relay 2:")
     self.dr2_button = QPushButton("Off")
     dr2_layout = QHBoxLayout()
     dr2_layout.addStretch()
     dr2_layout.addWidget(dr2_label)
     dr2_layout.addWidget(self.dr2_button)
     dr2_layout.addStretch()
     
     self.dr1_button.pressed.connect(self.dr1_pressed)
     self.dr2_button.pressed.connect(self.dr2_pressed)
     
     layout = QVBoxLayout(self)
     layout.addLayout(dr1_layout)
     layout.addLayout(dr2_layout)
     layout.addStretch()
    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)
Beispiel #18
0
    def __init__ (self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)
        
        self.ai = bricklet_analog_in.AnalogIn(self.uid)
        self.ipcon.add_device(self.ai)
        self.version = '.'.join(map(str, self.ai.get_version()[1]))
        
        self.qtcb_voltage.connect(self.cb_voltage)
        self.ai.register_callback(self.ai.CALLBACK_VOLTAGE,
                                  self.qtcb_voltage.emit) 
        
        self.voltage_label = VoltageLabel('Voltage: ')
        
        self.current_value = 0
        
        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)
Beispiel #19
0
    def __init__ (self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)
        self.setupUi(self)

        self.master = brick_master.Master(self.uid)
        self.device = self.master
        self.ipcon.add_device(self.master)
        self.version = '.'.join(map(str, self.master.get_version()[1]))
        
        self.extension_type_button.pressed.connect(self.extension_pressed)
        
        self.update_timer = QTimer()
        self.update_timer.timeout.connect(self.update_data)
        
        num_extensions = 0
        # construct chibi widget
#        if self.master.is_chibi_present():
#            num_extensions += 1
#            chibi = Chibi(self.master)
#            self.extension_layout.addWidget(chibi)
            
        if num_extensions == 0:
            self.extension_label.setText("None Present")
        else:
            self.extension_label.setText("" + str(num_extensions) + " Present")
 def start(self, device_information):
     self.mw.button_flash.hide()
     PluginBase.start(self, device_information)
     self.mw.set_tool_status_okay("-")
     self.mw.set_uid_status_okay("-")
     self.mw.set_flash_status_okay("-")
     self.mw.set_value_normal('-')
     self.mw.button_continue.hide()
Beispiel #21
0
 def __init__(self, ipcon, uid, version):
     PluginBase.__init__(self, ipcon, uid, 'DC Brick', version)
     
     self.setupUi(self)
     
     self.dc = BrickDC(uid, ipcon)
     self.device = self.dc
     
     self.update_timer = QTimer()
     self.update_timer.timeout.connect(self.update_data)
     
     self.speedometer = SpeedoMeter()
     self.vertical_layout_right.insertWidget(4, self.speedometer)
     
     self.new_value = 0
     self.update_counter = 0
     
     self.full_brake_time = 0
     
     self.velocity_slider.sliderReleased.connect(self.velocity_slider_released)
     self.velocity_slider.valueChanged.connect(self.velocity_spin.setValue)
     self.velocity_spin.editingFinished.connect(self.velocity_spin_finished)
     
     self.acceleration_slider.sliderReleased.connect(self.acceleration_slider_released)
     self.acceleration_slider.valueChanged.connect(self.acceleration_spin.setValue)
     self.acceleration_spin.editingFinished.connect(self.acceleration_spin_finished)
     
     self.frequency_slider.sliderReleased.connect(self.frequency_slider_released)
     self.frequency_slider.valueChanged.connect(self.frequency_spin.setValue)
     self.frequency_spin.editingFinished.connect(self.frequency_spin_finished)
     
     self.radio_mode_brake.toggled.connect(self.brake_value_changed)
     self.radio_mode_coast.toggled.connect(self.coast_value_changed)
     
     self.minimum_voltage_button.pressed.connect(self.minimum_voltage_button_pressed)
     self.full_brake_button.pressed.connect(self.full_brake_pressed)
     self.enable_checkbox.stateChanged.connect(self.enable_state_changed)
     
     self.emergency_signal = None
     self.under_signal = None
     self.current_velocity_signal = None
     self.velocity_reached_signal = None
     
     self.qem = QErrorMessage(self)
     
     self.qtcb_under_voltage.connect(self.cb_under_voltage)
     self.dc.register_callback(self.dc.CALLBACK_UNDER_VOLTAGE,
                               self.qtcb_under_voltage.emit) 
     
     self.qtcb_emergency_shutdown.connect(self.cb_emergency_shutdown)
     self.dc.register_callback(self.dc.CALLBACK_EMERGENCY_SHUTDOWN,
                               self.qtcb_emergency_shutdown.emit) 
     
     self.qtcb_position_reached.connect(self.update_velocity)
     self.dc.register_callback(self.dc.CALLBACK_VELOCITY_REACHED,
                               self.qtcb_position_reached.emit) 
     self.dc.register_callback(self.dc.CALLBACK_CURRENT_VELOCITY,
                               self.qtcb_position_reached.emit) 
Beispiel #22
0
    def __init__ (self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.dist = bricklet_distance_ir.DistanceIR(self.uid)
        self.ipcon.add_device(self.dist)
        self.version = '.'.join(map(str, self.dist.get_version()[1]))
        
        self.qtcb_distance.connect(self.cb_distance)
        self.dist.register_callback(self.dist.CALLBACK_DISTANCE,
                                    self.qtcb_distance.emit) 
        
        self.qtcb_analog.connect(self.cb_analog)
        self.dist.register_callback(self.dist.CALLBACK_ANALOG_VALUE,
                                    self.qtcb_analog.emit) 
        
        self.analog_value = 0
        self.counter = 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("File..");
        self.sample_save = QPushButton("Save");
        
        self.sample_file.pressed.connect(self.sample_file_pressed)
        self.sample_save.pressed.connect(self.sample_save_pressed)
        
        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 = 0
        
        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)
Beispiel #23
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.dist = bricklet_distance_ir.DistanceIR(self.uid)
        self.ipcon.add_device(self.dist)
        self.version = '.'.join(map(str, self.dist.get_version()[1]))

        self.qtcb_distance.connect(self.cb_distance)
        self.dist.register_callback(self.dist.CALLBACK_DISTANCE,
                                    self.qtcb_distance.emit)

        self.qtcb_analog.connect(self.cb_analog)
        self.dist.register_callback(self.dist.CALLBACK_ANALOG_VALUE,
                                    self.qtcb_analog.emit)

        self.analog_value = 0
        self.counter = 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("File..")
        self.sample_save = QPushButton("Save")

        self.sample_file.pressed.connect(self.sample_file_pressed)
        self.sample_save.pressed.connect(self.sample_save_pressed)

        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 = 0

        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)
Beispiel #24
0
 def __init__ (self, ipcon, uid):
     PluginBase.__init__(self, ipcon, uid)
     self.setupUi(self)
     
     self.imu = brick_imu.IMU(self.uid)
     self.device = self.imu
     self.ipcon.add_device(self.imu)
     self.version = '.'.join(map(str, self.imu.get_version()[1]))
     
     self.update_timer = QTimer()
     self.update_timer.timeout.connect(self.update_data)
     
     # Import IMUGLWidget here, not global. If globally included we get
     # 'No OpenGL_accelerate module loaded: No module named OpenGL_accelerate'
     # as soon as IMU is set as device_class in __init__. 
     # No idea why this happens, doesn't make sense.
     from imu_gl_widget import IMUGLWidget
     
     self.imu_gl = IMUGLWidget(self)
     self.imu_gl.setMinimumSize(200, 200)
     self.min_x = 0
     self.min_y = 0
     self.min_z = 0
     self.max_x = 0 
     self.max_y = 0
     self.max_z = 0
     
     self.counter = 0
     
     self.mag_plot = Plot("Magnetic Field [mG]",
                          [["X", Qt.red],
                           ["Y", Qt.green],
                           ["Z", Qt.blue]])
     self.acc_plot = Plot("Acceleration [mG]",
                          [["X", Qt.red],
                           ["Y", Qt.green],
                           ["Z", Qt.blue]])
     self.gyr_plot = Plot("Angular Velocity [%c/s]" % 0xB0,
                          [["X", Qt.red],
                           ["Y", Qt.green],
                           ["Z", Qt.blue]])
     
     self.tem_plot = Plot("Temperature [%cC]" % 0xB0,
                          [["t", Qt.red]])
     
     self.grid_layout.addWidget(self.gyr_plot, 0, 0)
     self.grid_layout.addWidget(self.acc_plot, 0, 2)
     self.grid_layout.addWidget(self.mag_plot, 0, 4)
     self.grid_layout.addWidget(self.imu_gl, 2, 2)
     self.grid_layout.addWidget(self.tem_plot, 2, 4)
     
     self.save_orientation.clicked.connect(self.imu_gl.save_orientation)
     self.clear_graphs.clicked.connect(self.clear_graphs_clicked)
Beispiel #25
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.js = bricklet_joystick.Joystick(self.uid)
        self.ipcon.add_device(self.js)
        self.version = '.'.join(map(str, self.js.get_version()[1]))

        self.qtcb_position.connect(self.cb_position)
        self.js.register_callback(self.js.CALLBACK_POSITION,
                                  self.qtcb_position.emit)

        self.qtcb_pressed.connect(self.cb_pressed)
        self.js.register_callback(self.js.CALLBACK_PRESSED,
                                  self.qtcb_pressed.emit)

        self.qtcb_released.connect(self.cb_released)
        self.js.register_callback(self.js.CALLBACK_RELEASED,
                                  self.qtcb_released.emit)

        self.joystick_frame = JoystickFrame(self)
        self.joystick_frame.setMinimumSize(220, 220)
        self.joystick_frame.setMaximumSize(220, 220)
        self.joystick_frame.set_position(0, 0)

        self.calibration_button = QPushButton('Calibrate (0, 0)')
        self.position_label = PositionLabel('Position: (0, 0)')

        self.calibration_button.pressed.connect(self.calibration_pressed)

        self.current_x = 0
        self.current_y = 0

        plot_list = [['X', Qt.darkGreen, self.get_current_x],
                     ['Y', Qt.blue, self.get_current_y]]
        self.plot_widget = PlotWidget('Position', plot_list)

        layout_h1 = QHBoxLayout()
        layout_h1.addStretch()
        layout_h1.addWidget(self.position_label)
        layout_h1.addStretch()

        layout_h2 = QHBoxLayout()
        layout_h2.addStretch()
        layout_h2.addWidget(self.joystick_frame)
        layout_h2.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h1)
        layout.addLayout(layout_h2)
        layout.addWidget(self.plot_widget)
        layout.addWidget(self.calibration_button)
    def __init__(self, ipcon, uid, version):
        PluginBase.__init__(self, ipcon, uid, 'Industrial Quad Relay Bricklet', version)
        
        self.setupUi(self)
        
        self.iqr = BrickletIndustrialQuadRelay(uid, ipcon)
        
        self.open_pixmap = bmp_to_pixmap('plugin_system/plugins/industrial_quad_relay/relay_open.bmp')
        self.close_pixmap = bmp_to_pixmap('plugin_system/plugins/industrial_quad_relay/relay_close.bmp')
        
        self.relay_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.relay_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.relay_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]
        for icon in self.relay_button_icons:
            icon.setPixmap(self.open_pixmap)
            icon.show()

        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.iqr.get_available_for_group, None, self.get_available_for_group_aysnc, self.increase_error_count)
        
        def get_button_lambda(button):
            return lambda: self.relay_button_pressed(button)
        
        for i in range(len(self.relay_buttons)):
            self.relay_buttons[i].pressed.connect(get_button_lambda(i))
        
        self.qtcb_monoflop.connect(self.cb_monoflop)
        self.iqr.register_callback(self.iqr.CALLBACK_MONOFLOP_DONE,
                                   self.qtcb_monoflop.emit)
        
        self.set_group.pressed.connect(self.set_group_pressed)

        self.monoflop_pin.currentIndexChanged.connect(self.monoflop_pin_changed)
        self.monoflop_go.pressed.connect(self.monoflop_go_pressed)
        self.monoflop_time_before = [1000] * 16
        self.monoflop_pending = [False] * 16

        self.update_timer = QTimer()
        self.update_timer.timeout.connect(self.update)
        self.update_timer.setInterval(50)

        self.reconfigure_everything()
Beispiel #27
0
    def __init__ (self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)
        
        self.js = bricklet_joystick.Joystick(self.uid)
        self.ipcon.add_device(self.js)
        self.version = '.'.join(map(str, self.js.get_version()[1]))
        
        self.qtcb_position.connect(self.cb_position)
        self.js.register_callback(self.js.CALLBACK_POSITION,
                                  self.qtcb_position.emit)
        
        self.qtcb_pressed.connect(self.cb_pressed)
        self.js.register_callback(self.js.CALLBACK_PRESSED,
                                  self.qtcb_pressed.emit)
        
        self.qtcb_released.connect(self.cb_released)
        self.js.register_callback(self.js.CALLBACK_RELEASED,
                                  self.qtcb_released.emit)
        
        self.joystick_frame = JoystickFrame(self)
        self.joystick_frame.setMinimumSize(220, 220)
        self.joystick_frame.setMaximumSize(220, 220)
        self.joystick_frame.set_position(0, 0)
       
        self.calibration_button = QPushButton('Calibrate (0, 0)')
        self.position_label = PositionLabel('Position: (0, 0)')
        
        self.calibration_button.pressed.connect(self.calibration_pressed)
        
        self.current_x = 0
        self.current_y = 0
        
        plot_list = [['X', Qt.darkGreen, self.get_current_x],
                     ['Y', Qt.blue, self.get_current_y]]
        self.plot_widget = PlotWidget('Position', plot_list)
        
        layout_h1 = QHBoxLayout()
        layout_h1.addStretch()
        layout_h1.addWidget(self.position_label)
        layout_h1.addStretch()

        layout_h2 = QHBoxLayout()
        layout_h2.addStretch()
        layout_h2.addWidget(self.joystick_frame)
        layout_h2.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h1)
        layout.addLayout(layout_h2)
        layout.addWidget(self.plot_widget)
        layout.addWidget(self.calibration_button)
Beispiel #28
0
    def __init__ (self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)
        
        self.tem = bricklet_temperature_ir.TemperatureIR(self.uid)
        self.ipcon.add_device(self.tem)
        self.version = '.'.join(map(str, self.tem.get_version()[1]))
        
        self.qtcb_ambient_temperature.connect(self.cb_ambient_temperature)
        self.tem.register_callback(self.tem.CALLBACK_AMBIENT_TEMPERATURE,
                                   self.qtcb_ambient_temperature.emit)
        self.qtcb_object_temperature.connect(self.cb_object_temperature)
        self.tem.register_callback(self.tem.CALLBACK_OBJECT_TEMPERATURE,
                                   self.qtcb_object_temperature.emit) 
        
        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.pressed.connect(self.emissivity_pressed)
        
        self.current_ambient = 0
        self.current_object = 0
        
        plot_list = [['amb', Qt.blue, self.get_current_ambient],
                     ['obj', 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)
Beispiel #29
0
    def __init__ (self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)
        
        self.tem = bricklet_temperature_ir.TemperatureIR(self.uid)
        self.ipcon.add_device(self.tem)
        self.version = '.'.join(map(str, self.tem.get_version()[1]))
        
        self.qtcb_ambient_temperature.connect(self.cb_ambient_temperature)
        self.tem.register_callback(self.tem.CALLBACK_AMBIENT_TEMPERATURE,
                                   self.qtcb_ambient_temperature.emit)
        self.qtcb_object_temperature.connect(self.cb_object_temperature)
        self.tem.register_callback(self.tem.CALLBACK_OBJECT_TEMPERATURE,
                                   self.qtcb_object_temperature.emit) 
        
        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.pressed.connect(self.emissivity_pressed)
        
        self.current_ambient = 0
        self.current_object = 0
        
        plot_list = [['amb', Qt.blue, self.get_current_ambient],
                     ['obj', 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)
Beispiel #30
0
 def __init__ (self, ipcon, uid):
     PluginBase.__init__(self, ipcon, uid)
     
     self.setupUi(self)
     
     self.io = bricklet_io16.IO16(self.uid)
     self.ipcon.add_device(self.io)
     self.version = '.'.join(map(str, self.io.get_version()[1]))
     
     self.qtcb_interrupt.connect(self.cb_interrupt)
     self.io.register_callback(self.io.CALLBACK_INTERRUPT,
                               self.qtcb_interrupt.emit)
     
     self.port_value = { 'a': [self.av0, self.av1, self.av2, self.av3,
                               self.av4, self.av5, self.av6, self.av7],
                         'b': [self.bv0, self.bv1, self.bv2, self.bv3,
                               self.bv4, self.bv5, self.bv6, self.bv7]}
     
     self.port_direction = { 'a': [self.ad0, self.ad1, self.ad2, self.ad3,
                                   self.ad4, self.ad5, self.ad6, self.ad7],
                             'b': [self.bd0, self.bd1, self.bd2, self.bd3,
                                   self.bd4, self.bd5, self.bd6, self.bd7]}
     
     self.port_config = { 'a': [self.ac0, self.ac1, self.ac2, self.ac3,
                                self.ac4, self.ac5, self.ac6, self.ac7],
                          'b': [self.bc0, self.bc1, self.bc2, self.bc3,
                                self.bc4, self.bc5, self.bc6, self.bc7]}
     
     try:
         value = self.io.get_port('a')
         dir, config = self.io.get_port_configuration('a')
         self.init_values('a', value, dir, config)
     
         value = self.io.get_port('b')
         dir, config = self.io.get_port_configuration('b')
         self.init_values('b', value, dir, config)
     
         debounce = self.io.get_debounce_period()
         self.debounce_edit.setText(str(debounce))
     except ip_connection.Error:
         pass
     
     self.save_button.pressed.connect(self.save_pressed)
     self.port_box.currentIndexChanged.connect(self.port_changed)
     self.pin_box.currentIndexChanged.connect(self.pin_changed)
     self.direction_box.currentIndexChanged.connect(self.direction_changed)
     self.debounce_save.pressed.connect(self.debounce_save_pressed)
     
     self.port_changed(0)
Beispiel #31
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)
        self.setupUi(self)

        self.imu = brick_imu.IMU(self.uid)
        self.device = self.imu
        self.ipcon.add_device(self.imu)
        self.version = '.'.join(map(str, self.imu.get_version()[1]))

        self.update_timer = QTimer()
        self.update_timer.timeout.connect(self.update_data)

        # Import IMUGLWidget here, not global. If globally included we get
        # 'No OpenGL_accelerate module loaded: No module named OpenGL_accelerate'
        # as soon as IMU is set as device_class in __init__.
        # No idea why this happens, doesn't make sense.
        from imu_gl_widget import IMUGLWidget

        self.imu_gl = IMUGLWidget(self)
        self.imu_gl.setMinimumSize(200, 200)
        self.min_x = 0
        self.min_y = 0
        self.min_z = 0
        self.max_x = 0
        self.max_y = 0
        self.max_z = 0

        self.counter = 0

        self.mag_plot = Plot("Magnetic Field [mG]",
                             [["X", Qt.red], ["Y", Qt.green], ["Z", Qt.blue]])
        self.acc_plot = Plot("Acceleration [mG]",
                             [["X", Qt.red], ["Y", Qt.green], ["Z", Qt.blue]])
        self.gyr_plot = Plot("Angular Velocity [%c/s]" % 0xB0,
                             [["X", Qt.red], ["Y", Qt.green], ["Z", Qt.blue]])

        self.tem_plot = Plot("Temperature [%cC]" % 0xB0, [["t", Qt.red]])

        self.grid_layout.addWidget(self.gyr_plot, 0, 0)
        self.grid_layout.addWidget(self.acc_plot, 0, 2)
        self.grid_layout.addWidget(self.mag_plot, 0, 4)
        self.grid_layout.addWidget(self.imu_gl, 2, 2)
        self.grid_layout.addWidget(self.tem_plot, 2, 4)

        self.save_orientation.clicked.connect(self.imu_gl.save_orientation)
        self.clear_graphs.clicked.connect(self.clear_graphs_clicked)
    def __init__(self, ipcon, uid, version):
        PluginBase.__init__(self, ipcon, uid, "Temperature IR Bricklet", version)

        self.tem = BrickletTemperatureIR(uid, ipcon)

        self.qtcb_ambient_temperature.connect(self.cb_ambient_temperature)
        self.tem.register_callback(self.tem.CALLBACK_AMBIENT_TEMPERATURE, self.qtcb_ambient_temperature.emit)
        self.qtcb_object_temperature.connect(self.cb_object_temperature)
        self.tem.register_callback(self.tem.CALLBACK_OBJECT_TEMPERATURE, self.qtcb_object_temperature.emit)

        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.pressed.connect(self.emissivity_pressed)

        self.current_ambient = None
        self.current_object = None

        plot_list = [["amb", Qt.blue, self.get_current_ambient], ["obj", 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)
Beispiel #33
0
    def __init__(self, ipcon, uid, version):
        PluginBase.__init__(self, ipcon, uid, 'IO-4 Bricklet', version)
        
        self.setupUi(self)
        
        self.io = BrickletIO4(uid, ipcon)
        
        self.has_monoflop = version >= (1, 1, 1)
        
        self.qtcb_interrupt.connect(self.cb_interrupt)
        self.io.register_callback(self.io.CALLBACK_INTERRUPT,
                                  self.qtcb_interrupt.emit)
        
        self.port_value = [self.av0, self.av1, self.av2, self.av3]
        self.port_direction = [self.ad0, self.ad1, self.ad2, self.ad3]
        self.port_config = [self.ac0, self.ac1, self.ac2, self.ac3]
        self.port_time = [self.at0, self.at1, self.at2, self.at3]

        self.monoflop_active = [False, False, False, False]
        self.monoflop_timebefore = [500, 500, 500, 500]

        self.init_async_generator = self.init_async()
        self.init_async_generator.next()
        
        self.save_button.pressed.connect(self.save_pressed)
        self.pin_box.currentIndexChanged.connect(self.pin_changed)
        self.direction_box.currentIndexChanged.connect(self.direction_changed)
        self.debounce_save.pressed.connect(self.debounce_save_pressed)
        self.time_spinbox.valueChanged.connect(self.time_changed)
        self.go_button.pressed.connect(self.go_pressed)

        self.qtcb_monoflop.connect(self.cb_monoflop)
        self.io.register_callback(self.io.CALLBACK_MONOFLOP_DONE,
                                  self.qtcb_monoflop.emit)

        self.update_timer = QTimer()
        self.update_timer.timeout.connect(self.update)
        self.update_timer.setInterval(50)

        if not self.has_monoflop:
            self.go_button.setText("Go (Firmware > 1.1.0 needed)")
            self.go_button.setEnabled(False)
        
        self.pin_changed(0)
Beispiel #34
0
    def __init__(self, ipcon, uid, version):
        PluginBase.__init__(self, ipcon, uid, 'GPS Bricklet', version)

        self.setupUi(self)

        self.gps = BrickletGPS(uid, ipcon)

        self.qtcb_coordinates.connect(self.cb_coordinates)
        self.gps.register_callback(self.gps.CALLBACK_COORDINATES,
                                   self.qtcb_coordinates.emit)

        self.qtcb_status.connect(self.cb_status)
        self.gps.register_callback(self.gps.CALLBACK_STATUS,
                                   self.qtcb_status.emit)

        self.qtcb_altitude.connect(self.cb_altitude)
        self.gps.register_callback(self.gps.CALLBACK_ALTITUDE,
                                   self.qtcb_altitude.emit)

        self.qtcb_motion.connect(self.cb_motion)
        self.gps.register_callback(self.gps.CALLBACK_MOTION,
                                   self.qtcb_motion.emit)

        self.qtcb_date_time.connect(self.cb_date_time)
        self.gps.register_callback(self.gps.CALLBACK_DATE_TIME,
                                   self.qtcb_date_time.emit)

        self.format_combobox.currentIndexChanged.connect(self.format_changed)
        self.show_pos.pressed.connect(self.show_pos_pressed)
        self.hot_start.pressed.connect(lambda: self.restart_pressed(0))
        self.warm_start.pressed.connect(lambda: self.restart_pressed(1))
        self.cold_start.pressed.connect(lambda: self.restart_pressed(2))
        self.factory_reset.pressed.connect(lambda: self.restart_pressed(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
Beispiel #35
0
 def __init__ (self, ipcon, uid):
     PluginBase.__init__(self, ipcon, uid)
     
     self.pb = bricklet_piezo_buzzer.PiezoBuzzer(self.uid)
     self.ipcon.add_device(self.pb)
     self.version = '.'.join(map(str, self.pb.get_version()[1]))
     
     self.qtcb_beep_finished.connect(self.cb_beep)
     self.pb.register_callback(self.pb.CALLBACK_BEEP_FINISHED,
                               self.qtcb_beep_finished.emit)
     self.qtcb_morse_finished.connect(self.cb_morse)
     self.pb.register_callback(self.pb.CALLBACK_MORSE_CODE_FINISHED,
                               self.qtcb_morse_finished.emit)
     
     self.beep_edit = QLineEdit()
     self.beep_edit.setText(str(1000))
     self.beep_label = QLabel('Duration (ms): ')
     self.beep_button = QPushButton('Send Beep')
     self.beep_layout = QHBoxLayout()
     self.beep_layout.addWidget(self.beep_label)
     self.beep_layout.addWidget(self.beep_edit)
     self.beep_layout.addWidget(self.beep_button)
     
     self.morse_edit = QLineEdit()
     self.morse_edit.setText('- .. -. -.- . .-. ..-. --- .-. --. .')
     self.morse_edit.setMaxLength(60)
     self.morse_label = QLabel('Morse Code: ')
     self.morse_button = QPushButton('Send Morse Code')
     self.morse_layout = QHBoxLayout()
     self.morse_layout.addWidget(self.morse_label)
     self.morse_layout.addWidget(self.morse_edit)
     self.morse_layout.addWidget(self.morse_button)
     
     self.status_label = QLabel('')
     
     self.beep_button.pressed.connect(self.beep_pressed)
     self.morse_button.pressed.connect(self.morse_pressed)
     
     layout = QVBoxLayout(self)
     layout.addLayout(self.beep_layout)
     layout.addLayout(self.morse_layout)
     layout.addWidget(self.status_label)
     layout.addStretch()
Beispiel #36
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.pb = bricklet_piezo_buzzer.PiezoBuzzer(self.uid)
        self.ipcon.add_device(self.pb)
        self.version = '.'.join(map(str, self.pb.get_version()[1]))

        self.qtcb_beep_finished.connect(self.cb_beep)
        self.pb.register_callback(self.pb.CALLBACK_BEEP_FINISHED,
                                  self.qtcb_beep_finished.emit)
        self.qtcb_morse_finished.connect(self.cb_morse)
        self.pb.register_callback(self.pb.CALLBACK_MORSE_CODE_FINISHED,
                                  self.qtcb_morse_finished.emit)

        self.beep_edit = QLineEdit()
        self.beep_edit.setText(str(1000))
        self.beep_label = QLabel('Duration (ms): ')
        self.beep_button = QPushButton('Send Beep')
        self.beep_layout = QHBoxLayout()
        self.beep_layout.addWidget(self.beep_label)
        self.beep_layout.addWidget(self.beep_edit)
        self.beep_layout.addWidget(self.beep_button)

        self.morse_edit = QLineEdit()
        self.morse_edit.setText('- .. -. -.- . .-. ..-. --- .-. --. .')
        self.morse_edit.setMaxLength(60)
        self.morse_label = QLabel('Morse Code: ')
        self.morse_button = QPushButton('Send Morse Code')
        self.morse_layout = QHBoxLayout()
        self.morse_layout.addWidget(self.morse_label)
        self.morse_layout.addWidget(self.morse_edit)
        self.morse_layout.addWidget(self.morse_button)

        self.status_label = QLabel('')

        self.beep_button.pressed.connect(self.beep_pressed)
        self.morse_button.pressed.connect(self.morse_pressed)

        layout = QVBoxLayout(self)
        layout.addLayout(self.beep_layout)
        layout.addLayout(self.morse_layout)
        layout.addWidget(self.status_label)
        layout.addStretch()
Beispiel #37
0
    def __init__(self, ipcon, uid, version):
        PluginBase.__init__(self, ipcon, uid, 'Analog In Bricklet', version)
        
        self.ai = BrickletAnalogIn(uid, ipcon)
        
        self.qtcb_voltage.connect(self.cb_voltage)
        self.ai.register_callback(self.ai.CALLBACK_VOLTAGE,
                                  self.qtcb_voltage.emit) 
        
        self.voltage_label = VoltageLabel('Voltage: ')
        
        self.current_value = None
        
        plot_list = [['', Qt.red, self.get_current_value]]
        self.plot_widget = PlotWidget('Voltage [mV]', plot_list)

        if self.version >= (2, 0, 1):
            self.combo_range = QComboBox()
            self.combo_range.addItem('Automatic')
            self.combo_range.addItem('0V - 6.05V')
            self.combo_range.addItem('0V - 10.32V')
            self.combo_range.addItem('0V - 36.30V')
            self.combo_range.addItem('0V - 45.00V')
            self.combo_range.currentIndexChanged.connect(self.range_changed)

            layout_h1 = QHBoxLayout()
            layout_h1.addStretch()
            layout_h1.addWidget(QLabel('Range:'))
            layout_h1.addWidget(self.combo_range)
            layout_h1.addStretch()

        layout_h2 = QHBoxLayout()
        layout_h2.addStretch()
        layout_h2.addWidget(self.voltage_label)
        layout_h2.addStretch()

        layout = QVBoxLayout(self)
        if self.version >= (2, 0, 1):
            layout.addLayout(layout_h1)
        layout.addLayout(layout_h2)
        layout.addWidget(self.plot_widget)
Beispiel #38
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)
        self.setupUi(self)

        self.master = brick_master.Master(self.uid)
        self.device = self.master
        self.ipcon.add_device(self.master)

        version = self.master.get_version()
        self.version = ".".join(map(str, version[1]))
        self.version_minor = version[1][1]
        self.version_release = version[1][2]

        self.update_timer = QTimer()
        self.update_timer.timeout.connect(self.update_data)

        self.extensions = []
        num_extensions = 0
        # construct chibi widget
        if self.version_minor > 0:
            self.extension_type_button.pressed.connect(self.extension_pressed)
            if self.master.is_chibi_present():
                num_extensions += 1
                chibi = Chibi(self)
                self.extensions.append(chibi)
                self.extension_layout.addWidget(chibi)
        else:
            self.extension_type_button.setEnabled(False)

        # RS485 widget
        if self.version_minor > 1:
            if self.master.is_rs485_present():
                num_extensions += 1
                rs485 = RS485(self)
                self.extensions.append(rs485)
                self.extension_layout.addWidget(rs485)

        if num_extensions == 0:
            self.extension_label.setText("None Present")
        else:
            self.extension_label.setText("" + str(num_extensions) + " Present")
Beispiel #39
0
    def __init__ (self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)
        
        self.cur = bricklet_current25.Current25(self.uid)
        self.ipcon.add_device(self.cur)
        self.version = '.'.join(map(str, self.cur.get_version()[1]))
        
        self.qtcb_current.connect(self.cb_current)
        self.cur.register_callback(self.cur.CALLBACK_CURRENT,
                                   self.qtcb_current.emit) 
        
        self.qtcb_over.connect(self.cb_over)
        self.cur.register_callback(self.cur.CALLBACK_OVER_CURRENT,
                                   self.qtcb_over.emit) 
        
        self.current_label = CurrentLabel('Current: ')
        self.over_label = QLabel('Over Current: No')
        self.calibrate_button = QPushButton('Calibrate')
        self.calibrate_button.pressed.connect(self.calibrate_pressed)
        
        self.current_value = 0
        
        plot_list = [['', Qt.red, self.get_current_value]]
        self.plot_widget = PlotWidget('Current [mA]', plot_list)
        
        layout_h1 = QHBoxLayout()
        layout_h1.addStretch()
        layout_h1.addWidget(self.current_label)
        layout_h1.addStretch()

        layout_h2 = QHBoxLayout()
        layout_h2.addStretch()
        layout_h2.addWidget(self.over_label)
        layout_h2.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h1)
        layout.addLayout(layout_h2)
        layout.addWidget(self.plot_widget)
        layout.addWidget(self.calibrate_button)
Beispiel #40
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.cur = bricklet_current12.Current12(self.uid)
        self.ipcon.add_device(self.cur)
        self.version = '.'.join(map(str, self.cur.get_version()[1]))

        self.qtcb_current.connect(self.cb_current)
        self.cur.register_callback(self.cur.CALLBACK_CURRENT,
                                   self.qtcb_current.emit)

        self.qtcb_over.connect(self.cb_over)
        self.cur.register_callback(self.cur.CALLBACK_OVER_CURRENT,
                                   self.qtcb_over.emit)

        self.current_label = CurrentLabel('Current: ')
        self.over_label = QLabel('Over Current: No')
        self.calibrate_button = QPushButton('Calibrate')
        self.calibrate_button.pressed.connect(self.calibrate_pressed)

        self.current_value = 0

        plot_list = [['', Qt.red, self.get_current_value]]
        self.plot_widget = PlotWidget('Current [mA]', plot_list)

        layout_h1 = QHBoxLayout()
        layout_h1.addStretch()
        layout_h1.addWidget(self.current_label)
        layout_h1.addStretch()

        layout_h2 = QHBoxLayout()
        layout_h2.addStretch()
        layout_h2.addWidget(self.over_label)
        layout_h2.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h1)
        layout.addLayout(layout_h2)
        layout.addWidget(self.plot_widget)
        layout.addWidget(self.calibrate_button)
Beispiel #41
0
    def __init__(self, ipcon, uid, version):
        PluginBase.__init__(self, ipcon, uid, 'Dual Relay Bricklet', version)
        
        self.setupUi(self)
        
        self.dr = BrickletDualRelay(uid, ipcon)
        
        self.has_monoflop = version >= (1, 1, 1)
        
        self.qtcb_monoflop.connect(self.cb_monoflop)
        self.dr.register_callback(self.dr.CALLBACK_MONOFLOP_DONE,
                                  self.qtcb_monoflop.emit)
        
        self.dr1_button.pressed.connect(self.dr1_pressed)
        self.dr2_button.pressed.connect(self.dr2_pressed)
        
        self.go1_button.pressed.connect(self.go1_pressed)
        self.go2_button.pressed.connect(self.go2_pressed)

        self.r1_monoflop = False
        self.r2_monoflop = False

        self.r1_timebefore = 500
        self.r2_timebefore = 500
        
        self.a1_pixmap = bmp_to_pixmap('plugin_system/plugins/dual_relay/relay_a1.bmp')
        self.a2_pixmap = bmp_to_pixmap('plugin_system/plugins/dual_relay/relay_a2.bmp')
        self.b1_pixmap = bmp_to_pixmap('plugin_system/plugins/dual_relay/relay_b1.bmp')
        self.b2_pixmap = bmp_to_pixmap('plugin_system/plugins/dual_relay/relay_b2.bmp')

        self.update_timer = QTimer()
        self.update_timer.timeout.connect(self.update)
        self.update_timer.setInterval(50)

        if not self.has_monoflop:
            self.go1_button.setText("Go (Firmware > 1.1.0 needed)")
            self.go2_button.setText("Go (Firmware > 1.1.0 needed)")
            self.go1_button.setEnabled(False)
            self.go2_button.setEnabled(False)
Beispiel #42
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.rp = bricklet_rotary_poti.RotaryPoti(self.uid)
        self.ipcon.add_device(self.rp)
        self.version = '.'.join(map(str, self.rp.get_version()[1]))

        self.qtcb_position.connect(self.cb_position)
        self.rp.register_callback(self.rp.CALLBACK_POSITION,
                                  self.qtcb_position.emit)

        self.position_knob = Qwt.QwtKnob(self)
        self.position_knob.setTotalAngle(300)
        self.position_knob.setScale(-150, 150, 30)
        self.position_knob.setRange(-150, 150)
        self.position_knob.setReadOnly(True)
        self.position_knob.setFocusPolicy(Qt.NoFocus)
        self.position_knob.setKnobWidth(40)

        self.position_label = PositionLabel('Position: ')

        self.current_value = 0
        plot_list = [['', Qt.red, self.get_current_value]]
        self.plot_widget = PlotWidget('Position', plot_list)

        layout_h1 = QHBoxLayout()
        layout_h1.addStretch()
        layout_h1.addWidget(self.position_label)
        layout_h1.addStretch()

        layout_h2 = QHBoxLayout()
        layout_h2.addStretch()
        layout_h2.addWidget(self.position_knob)
        layout_h2.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h1)
        layout.addLayout(layout_h2)
        layout.addWidget(self.plot_widget)
Beispiel #43
0
    def __init__ (self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)
        
        self.rp = bricklet_rotary_poti.RotaryPoti(self.uid)
        self.ipcon.add_device(self.rp)
        self.version = '.'.join(map(str, self.rp.get_version()[1]))
        
        self.qtcb_position.connect(self.cb_position)
        self.rp.register_callback(self.rp.CALLBACK_POSITION,
                                  self.qtcb_position.emit) 
        
        self.position_knob = Qwt.QwtKnob(self)
        self.position_knob.setTotalAngle(300)
        self.position_knob.setScale(-150, 150, 30)
        self.position_knob.setRange(-150, 150)
        self.position_knob.setReadOnly(True)
        self.position_knob.setFocusPolicy(Qt.NoFocus)
        self.position_knob.setKnobWidth(40)
        
        self.position_label = PositionLabel('Position: ')
        
        self.current_value = 0
        plot_list = [['', Qt.red, self.get_current_value]]
        self.plot_widget = PlotWidget('Position', plot_list)
        
        layout_h1 = QHBoxLayout()
        layout_h1.addStretch()
        layout_h1.addWidget(self.position_label)
        layout_h1.addStretch()

        layout_h2 = QHBoxLayout()
        layout_h2.addStretch()
        layout_h2.addWidget(self.position_knob)
        layout_h2.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h1)
        layout.addLayout(layout_h2)
        layout.addWidget(self.plot_widget)
Beispiel #44
0
    def __init__ (self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)
        
        self.ao = bricklet_analog_out.AnalogOut(self.uid)
        self.ipcon.add_device(self.ao)
        self.version = '.'.join(map(str, self.ao.get_version()[1]))
        
        self.voltage_label = QLabel('Output Voltage (mV): ')
        self.voltage_box = QSpinBox()
        self.voltage_box.setMinimum(0)
        self.voltage_box.setMaximum(5000)
        self.voltage_box.setSingleStep(1)
        self.mode_label = QLabel('Mode: ')
        self.mode_combo = QComboBox()
        self.mode_combo.addItem("Normal Mode")
        self.mode_combo.addItem("1k Ohm resistor to ground")
        self.mode_combo.addItem("100k Ohm resistor to ground")
        self.mode_combo.addItem("500k Ohm resistor to ground")
        
        layout_h1 = QHBoxLayout()
        layout_h1.addStretch()
        layout_h1.addWidget(self.voltage_label)
        layout_h1.addWidget(self.voltage_box)
        layout_h1.addStretch()
        
        layout_h2 = QHBoxLayout()
        layout_h2.addStretch()
        layout_h2.addWidget(self.mode_label)
        layout_h2.addWidget(self.mode_combo)
        layout_h2.addStretch()

        layout = QVBoxLayout(self)
        layout.addLayout(layout_h2)
        layout.addLayout(layout_h1)
        layout.addStretch()
        
        self.voltage_box.editingFinished.connect(self.voltage_finished)
        self.mode_combo.activated.connect(self.mode_changed)
Beispiel #45
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.setupUi(self)

        self.io = bricklet_io16.IO16(self.uid)
        self.ipcon.add_device(self.io)
        self.version = '.'.join(map(str, self.io.get_version()[1]))

        self.qtcb_interrupt.connect(self.cb_interrupt)
        self.io.register_callback(self.io.CALLBACK_INTERRUPT,
                                  self.qtcb_interrupt.emit)

        self.port_value = {
            'a': [
                self.av0, self.av1, self.av2, self.av3, self.av4, self.av5,
                self.av6, self.av7
            ],
            'b': [
                self.bv0, self.bv1, self.bv2, self.bv3, self.bv4, self.bv5,
                self.bv6, self.bv7
            ]
        }

        self.port_direction = {
            'a': [
                self.ad0, self.ad1, self.ad2, self.ad3, self.ad4, self.ad5,
                self.ad6, self.ad7
            ],
            'b': [
                self.bd0, self.bd1, self.bd2, self.bd3, self.bd4, self.bd5,
                self.bd6, self.bd7
            ]
        }

        self.port_config = {
            'a': [
                self.ac0, self.ac1, self.ac2, self.ac3, self.ac4, self.ac5,
                self.ac6, self.ac7
            ],
            'b': [
                self.bc0, self.bc1, self.bc2, self.bc3, self.bc4, self.bc5,
                self.bc6, self.bc7
            ]
        }

        try:
            value = self.io.get_port('a')
            dir, config = self.io.get_port_configuration('a')
            self.init_values('a', value, dir, config)

            value = self.io.get_port('b')
            dir, config = self.io.get_port_configuration('b')
            self.init_values('b', value, dir, config)

            debounce = self.io.get_debounce_period()
            self.debounce_edit.setText(str(debounce))
        except ip_connection.Error:
            pass

        self.save_button.pressed.connect(self.save_pressed)
        self.port_box.currentIndexChanged.connect(self.port_changed)
        self.pin_box.currentIndexChanged.connect(self.pin_changed)
        self.direction_box.currentIndexChanged.connect(self.direction_changed)
        self.debounce_save.pressed.connect(self.debounce_save_pressed)

        self.port_changed(0)
Beispiel #46
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)
        self.setupUi(self)

        self.stepper = brick_stepper.Stepper(self.uid)
        self.device = self.stepper
        self.ipcon.add_device(self.stepper)
        self.version = '.'.join(map(str, self.stepper.get_version()[1]))

        self.endis_all(False)

        self.update_timer = QTimer()
        self.update_timer.timeout.connect(self.update_data)

        self.speedometer = SpeedoMeter()
        self.vertical_layout_right.insertWidget(5, self.speedometer)

        self.new_value = 0
        self.update_counter = 0

        self.full_brake_time = 0

        self.qem = QErrorMessage(self)
        self.qem.setWindowTitle("Under Voltage")

        self.velocity_slider.sliderReleased.connect(
            self.velocity_slider_released)
        self.velocity_slider.valueChanged.connect(self.velocity_spin.setValue)
        self.velocity_spin.editingFinished.connect(self.velocity_spin_finished)

        self.acceleration_slider.sliderReleased.connect(
            self.acceleration_slider_released)
        self.acceleration_slider.valueChanged.connect(
            self.acceleration_spin.setValue)
        self.acceleration_spin.editingFinished.connect(
            self.acceleration_spin_finished)

        self.deceleration_slider.sliderReleased.connect(
            self.deceleration_slider_released)
        self.deceleration_slider.valueChanged.connect(
            self.deceleration_spin.setValue)
        self.deceleration_spin.editingFinished.connect(
            self.deceleration_spin_finished)

        self.decay_slider.sliderReleased.connect(self.decay_slider_released)
        self.decay_slider.valueChanged.connect(self.decay_spin.setValue)
        self.decay_spin.editingFinished.connect(self.decay_spin_finished)

        self.enable_checkbox.stateChanged.connect(self.enable_state_changed)
        self.forward_button.pressed.connect(self.forward_pressed)
        self.stop_button.pressed.connect(self.stop_pressed)
        self.full_brake_button.pressed.connect(self.full_brake_pressed)
        self.backward_button.pressed.connect(self.backward_pressed)
        self.to_button.pressed.connect(self.to_button_pressed)
        self.steps_button.pressed.connect(self.steps_button_pressed)
        self.motor_current_button.pressed.connect(
            self.motor_current_button_pressed)
        self.minimum_motor_voltage_button.pressed.connect(
            self.minimum_motor_voltage_button_pressed)

        self.mode_dropbox.currentIndexChanged.connect(self.mode_changed)

        self.qtcb_position_reached.connect(self.cb_position_reached)
        self.stepper.register_callback(self.stepper.CALLBACK_POSITION_REACHED,
                                       self.qtcb_position_reached.emit)

        self.qtcb_under_voltage.connect(self.cb_under_voltage)
        self.stepper.register_callback(self.stepper.CALLBACK_UNDER_VOLTAGE,
                                       self.qtcb_under_voltage.emit)
Beispiel #47
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)

        self.lcd = bricklet_lcd_20x4.LCD20x4(self.uid)
        self.ipcon.add_device(self.lcd)
        self.version = '.'.join(map(str, self.lcd.get_version()[1]))

        self.qtcb_pressed.connect(self.cb_pressed)
        self.lcd.register_callback(self.lcd.CALLBACK_BUTTON_PRESSED,
                                   self.qtcb_pressed.emit)
        self.qtcb_released.connect(self.cb_released)
        self.lcd.register_callback(self.lcd.CALLBACK_BUTTON_RELEASED,
                                   self.qtcb_released.emit)

        self.line_label = QLabel('Line: ')
        self.line_combo = QComboBox()
        for i in range(LCD20x4.MAX_LINE):
            self.line_combo.addItem(str(i))

        self.pos_label = QLabel('Position: ')
        self.pos_combo = QComboBox()
        for i in range(LCD20x4.MAX_POSITION):
            self.pos_combo.addItem(str(i))

        self.pos_layout = QHBoxLayout()
        self.pos_layout.addWidget(self.pos_label)
        self.pos_layout.addWidget(self.pos_combo)
        self.pos_layout.addStretch()

        self.line_layout = QHBoxLayout()
        self.line_layout.addWidget(self.line_label)
        self.line_layout.addWidget(self.line_combo)
        self.line_layout.addStretch()

        self.text_label = QLabel('Text: ')
        self.text_edit = QLineEdit()
        self.text_edit.setMaxLength(LCD20x4.MAX_POSITION)
        self.text_button = QPushButton('Send Text')
        self.text_layout = QHBoxLayout()
        self.text_layout.addWidget(self.text_label)
        self.text_layout.addWidget(self.text_edit)
        self.text_layout.addWidget(self.text_button)

        self.clear_button = QPushButton("Clear Display")

        self.bl_button = QPushButton()
        self.cursor_button = QPushButton()
        self.blink_button = QPushButton()

        try:
            if self.lcd.is_backlight_on():
                self.bl_button.setText('Backlight Off')
            else:
                self.bl_button.setText('Backlight On')

            cursor, blink = self.lcd.get_config()
            if cursor:
                self.cursor_button.setText('Cursor Off')
            else:
                self.cursor_button.setText('Cursor On')

            if blink:
                self.blink_button.setText('Blink Off')
            else:
                self.blink_button.setText('Blink On')
        except ip_connection.Error:
            pass

        self.onofflayout = QHBoxLayout()
        self.onofflayout.addWidget(self.bl_button)
        self.onofflayout.addWidget(self.cursor_button)
        self.onofflayout.addWidget(self.blink_button)

        self.b0_label = QLabel('Button 0: Released')
        self.b1_label = QLabel('Button 1: Released')
        self.b2_label = QLabel('Button 2: Released')

        self.cursor_button.pressed.connect(self.cursor_pressed)
        self.blink_button.pressed.connect(self.blink_pressed)
        self.clear_button.pressed.connect(self.clear_pressed)
        self.bl_button.pressed.connect(self.bl_pressed)
        self.text_button.pressed.connect(self.text_pressed)

        layout = QVBoxLayout(self)
        layout.addLayout(self.line_layout)
        layout.addLayout(self.pos_layout)
        layout.addLayout(self.text_layout)
        layout.addWidget(self.clear_button)
        layout.addLayout(self.onofflayout)
        layout.addWidget(self.b0_label)
        layout.addWidget(self.b1_label)
        layout.addWidget(self.b2_label)
        layout.addStretch()
Beispiel #48
0
    def __init__ (self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)
     
        self.setupUi(self)
        
        self.dc = brick_dc.DC(self.uid)
        self.device = self.dc
        self.ipcon.add_device(self.dc)
        self.version = '.'.join(map(str, self.dc.get_version()[1]))
        
        self.update_timer = QTimer()
        self.update_timer.timeout.connect(self.update_data)
        

        self.speedometer = SpeedoMeter()
        self.vertical_layout_right.insertWidget(4, self.speedometer)
        
        self.new_value = 0
        self.update_counter = 0
        
        self.full_brake_time = 0
        
        self.velocity_slider.sliderReleased.connect(self.velocity_slider_released)
        self.velocity_slider.valueChanged.connect(self.velocity_spin.setValue)
        self.velocity_spin.editingFinished.connect(self.velocity_spin_finished)
        
        self.acceleration_slider.sliderReleased.connect(self.acceleration_slider_released)
        self.acceleration_slider.valueChanged.connect(self.acceleration_spin.setValue)
        self.acceleration_spin.editingFinished.connect(self.acceleration_spin_finished)
        
        self.frequency_slider.sliderReleased.connect(self.frequency_slider_released)
        self.frequency_slider.valueChanged.connect(self.frequency_spin.setValue)
        self.frequency_spin.editingFinished.connect(self.frequency_spin_finished)
        
        self.radio_mode_brake.toggled.connect(self.brake_value_changed)
        self.radio_mode_coast.toggled.connect(self.coast_value_changed)
        
        self.minimum_voltage_button.pressed.connect(self.minimum_voltage_button_pressed)
        self.full_brake_button.pressed.connect(self.full_brake_pressed)
        self.enable_checkbox.stateChanged.connect(self.enable_state_changed)
        
        self.emergency_signal = None
        self.under_signal = None
        self.current_velocity_signal = None
        self.velocity_reached_signal = None
        
        self.qem = QErrorMessage(self)
        
        self.qtcb_under_voltage.connect(self.cb_under_voltage)
        self.dc.register_callback(self.dc.CALLBACK_UNDER_VOLTAGE,
                                  self.qtcb_under_voltage.emit) 
        
        self.qtcb_emergency_shutdown.connect(self.cb_emergency_shutdown)
        self.dc.register_callback(self.dc.CALLBACK_EMERGENCY_SHUTDOWN,
                                  self.qtcb_emergency_shutdown.emit) 
        
        self.qtcb_position_reached.connect(self.update_velocity)
        self.dc.register_callback(self.dc.CALLBACK_VELOCITY_REACHED,
                                  self.qtcb_position_reached.emit) 
        self.dc.register_callback(self.dc.CALLBACK_CURRENT_VELOCITY,
                                  self.qtcb_position_reached.emit) 
Beispiel #49
0
    def __init__(self, ipcon, uid):
        PluginBase.__init__(self, ipcon, uid)
        self.setupUi(self)

        self.servo = brick_servo.Servo(self.uid)
        self.device = self.servo
        self.ipcon.add_device(self.servo)
        self.version = '.'.join(map(str, self.servo.get_version()[1]))

        self.update_timer = QTimer()
        self.update_timer.timeout.connect(self.update_apply)
        self.update_timer.setInterval(0)
        self.update_timer.setSingleShot(True)

        layout = QVBoxLayout(self)
        layout.addWidget(QLabel('Servo'))
        self.position_list = []
        self.velocity_list = []
        self.acceleration_list = []
        self.enable_list = []

        self.up_ena = [0] * 7
        self.up_pos = [0] * 7
        self.up_vel = [0] * 7
        self.up_acc = [0] * 7

        self.alive = True

        for i in range(1, 8):
            label = QLabel()
            label.setText('Off')
            self.enable_list.append(label)
            self.status_grid.addWidget(label, i, 1)

        for i in range(1, 8):
            pk = PositionKnob()
            self.position_list.append(pk)
            self.status_grid.addWidget(pk, i, 2)

        for i in range(1, 8):
            cb = ColorBar(Qt.Vertical)
            self.velocity_list.append(cb)
            self.status_grid.addWidget(cb, i, 3)

        for i in range(1, 8):
            cb = ColorBar(Qt.Vertical)
            self.acceleration_list.append(cb)
            self.status_grid.addWidget(cb, i, 4)

        self.qem = QErrorMessage(self)
        self.qem.setWindowTitle("Under Voltage")

        self.test_button.clicked.connect(self.test_button_clicked)
        self.output_voltage_button.clicked.connect(
            self.output_voltage_button_clicked)

        self.servo_dropbox.currentIndexChanged.connect(
            lambda x: self.update_servo_specific())
        self.enable_checkbox.stateChanged.connect(self.enable_state_changed)

        self.position_slider.sliderReleased.connect(
            self.position_slider_released)
        self.position_slider.valueChanged.connect(self.position_spin.setValue)
        self.position_spin.editingFinished.connect(self.position_spin_finished)

        self.velocity_slider.sliderReleased.connect(
            self.velocity_slider_released)
        self.velocity_slider.valueChanged.connect(self.velocity_spin.setValue)
        self.velocity_spin.editingFinished.connect(self.velocity_spin_finished)

        self.acceleration_slider.sliderReleased.connect(
            self.acceleration_slider_released)
        self.acceleration_slider.valueChanged.connect(
            self.acceleration_spin.setValue)
        self.acceleration_spin.editingFinished.connect(
            self.acceleration_spin_finished)

        self.period_slider.sliderReleased.connect(self.period_slider_released)
        self.period_slider.valueChanged.connect(self.period_spin.setValue)
        self.period_spin.editingFinished.connect(self.period_spin_finished)

        self.pulse_width_min_spin.editingFinished.connect(
            self.pulse_width_spin_finished)
        self.pulse_width_max_spin.editingFinished.connect(
            self.pulse_width_spin_finished)
        self.degree_min_spin.editingFinished.connect(self.degree_spin_finished)
        self.degree_max_spin.editingFinished.connect(self.degree_spin_finished)

        self.minimum_voltage_button.pressed.connect(
            self.minimum_voltage_button_pressed)

        self.qtcb_under_voltage.connect(self.cb_under_voltage)
        self.servo.register_callback(self.servo.CALLBACK_UNDER_VOLTAGE,
                                     self.qtcb_under_voltage.emit)

        class WorkerThread(QThread):
            def __init__(self, parent=None, func=None):
                QThread.__init__(self, parent)
                self.func = func

            def run(self):
                self.func()

        self.test_event = Event()
        self.test_thread_object = WorkerThread(self, self.test_thread)
        self.update_event = Event()
        self.update_thread_object = WorkerThread(self, self.update_thread)

        self.update_done_event = Event()
        self.update_done_event.set()