Exemplo n.º 1
0
    def get_wifi_encryption_async(self, enc):
        encryption, key, key_index, eap_options, ca_certificate_length, client_certificate_length, private_key_length = enc

        if self.connection in (2, 3, 4, 5):
            encryption -= 2

        eap_outer = eap_options & 0b00000011
        eap_inner = (eap_options & 0b00000100) >> 2
        key = key.replace('\0', '')

        self.wifi_eap_outer_auth.setCurrentIndex(eap_outer)
        self.wifi_eap_inner_auth.setCurrentIndex(eap_inner)
        self.wifi_encryption.setCurrentIndex(encryption)

        if key == '-' and self.parent.version >= (2, 0, 2):
            async_call(self.master.get_long_wifi_key, None, self.get_long_wifi_key_async, self.parent.increase_error_count)
        else:
            self.wifi_key.setText(key)

        self.wifi_key_index.setValue(key_index)

        self.wifi_connection.currentIndexChanged.connect(self.connection_changed)
        self.wifi_encryption.currentIndexChanged.connect(self.encryption_changed)
        self.wifi_save.pressed.connect(self.save_pressed)
        self.wifi_show_status.pressed.connect(self.show_status_pressed)
        self.wifi_ca_certificate_browse.pressed.connect(self.ca_certificate_browse_pressed)
        self.wifi_client_certificate_browse.pressed.connect(self.client_certificate_browse_pressed)
        self.wifi_private_key_browse.pressed.connect(self.private_key_browse_pressed)

        self.connection_changed(0)
        self.encryption_changed(0)
        self.wifi_encryption.setCurrentIndex(encryption) # ensure that the correct encryption is displayed
    def reconfigure_everything_async1(self, group):
        for i in range(4):
            if group[i] == 'n':
                self.groups[i].setCurrentIndex(0)
            else:
                item = 'Port ' + group[i].upper()
                index = self.groups[i].findText(item, Qt.MatchStartsWith)
                if index == -1:
                    self.groups[i].setCurrentIndex(0)
                else:
                    self.groups[i].setCurrentIndex(index)

        self.monoflop_pin.clear()

        if group[0] == 'n' and group[1] == 'n' and group[2] == 'n' and group[3] == 'n':
            self.show_buttons(0)
            self.hide_buttons(1)
            self.hide_buttons(2)
            self.hide_buttons(3)
            self.monoflop_pin.addItem('Pin 0')
            self.monoflop_pin.addItem('Pin 1')
            self.monoflop_pin.addItem('Pin 2')
            self.monoflop_pin.addItem('Pin 3')
        else:
            for i in range(4):
                if group[i] == 'n':
                    self.hide_buttons(i)
                else:
                    for j in range(4):
                        self.monoflop_pin.addItem('Pin ' + str(i*4+j))
                    self.show_buttons(i)

        self.monoflop_pin.setCurrentIndex(0)

        async_call(self.iqr.get_value, None, self.reconfigure_everything_async2, self.increase_error_count)
    def update(self):
        try:
            pin = int(self.monoflop_pin.currentText().replace('Pin ', ''))
        except ValueError:
            return

        async_call(self.iqr.get_monoflop, pin, lambda monoflop: self.update_async(pin, *monoflop), self.increase_error_count)
Exemplo n.º 4
0
    def update(self):
        for pin in range(4):
            if self.monoflop_active[pin]:
                def get_lambda(pin):
                    return lambda x: self.update_async(pin, x)

                async_call(self.io.get_monoflop, pin, get_lambda(pin), self.increase_error_count)
    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()
Exemplo n.º 6
0
    def stop(self):
        async_call(self.barometer.set_air_pressure_callback_period, 0, None, self.increase_error_count)
        async_call(self.barometer.set_altitude_callback_period, 0, None, self.increase_error_count)

        self.air_pressure_plot_widget.stop = True
        self.altitude_plot_widget.stop = True

        self.chip_temp_timer.stop()
Exemplo n.º 7
0
 def update(self):
     for port in ['a', 'b']:
         for pin in range(8):
             if self.monoflop_active[port][pin]:
                 def get_lambda(port, pin):
                     return lambda x: self.update_async(port, pin, x)
                 
                 async_call(self.io.get_port_monoflop, (port, pin), get_lambda(port, pin), self.increase_error_count)
Exemplo n.º 8
0
    def start(self):
        async_call(self.tem.get_ambient_temperature, None, self.cb_ambient_temperature, self.increase_error_count)
        async_call(self.tem.get_object_temperature, None, self.cb_object_temperature, self.increase_error_count)
        async_call(self.tem.get_emissivity, None, self.cb_emissivity, self.increase_error_count)

        async_call(self.tem.set_ambient_temperature_callback_period, 250, None, self.increase_error_count)
        async_call(self.tem.set_object_temperature_callback_period, 250, None, self.increase_error_count)

        self.plot_widget.stop = False
Exemplo n.º 9
0
    def dr2_pressed(self):
        if 'On' in self.dr2_button.text():
            self.dr2_button.setText('Switch Off')
            self.dr2_image.setPixmap(self.a2_pixmap)
        else:
            self.dr2_button.setText('Switch On')
            self.dr2_image.setPixmap(self.b2_pixmap)

        async_call(self.dr.get_state, None, self.get_state_dr2_pressed, self.increase_error_count)
 def reconfigure_everything(self):
     for i in range(4):
         self.groups[i].clear()
         self.groups[i].addItem('Off')
         for j in range(4):
             if self.available_ports & (1 << j):
                 item = 'Port ' + chr(ord('A') + j)
                 self.groups[i].addItem(item)
                 
     async_call(self.idi4.get_group, None, self.reconfigure_everything_async, self.increase_error_count)
Exemplo n.º 11
0
 def minimum_motor_voltage_button_pressed(self):
     qid = QInputDialog(self)
     qid.setInputMode(QInputDialog.IntInput)
     qid.setIntMinimum(0)
     qid.setIntMaximum(40000)
     qid.setIntStep(100)
     async_call(self.stepper.get_minimum_voltage, None, qid.setIntValue, self.increase_error_count)
     qid.intValueSelected.connect(self.minimum_motor_voltage_selected)
     qid.setLabelText("Choose minimum motor voltage in mV.")
     qid.open()
Exemplo n.º 12
0
    def __init__(self, parent):
        QWidget.__init__(self)
        self.setupUi(self)

        self.parent = parent
        self.master = parent.master

        if parent.version >= (1, 2, 0):
            async_call(self.master.get_rs485_configuration, None, self.get_rs485_configuration_async, self.parent.increase_error_count)
            self.update_generator = self.update_addresses()
            self.update_generator.next()
Exemplo n.º 13
0
    def output_voltage_button_clicked(self):
        qid = QInputDialog(self)
        qid.setInputMode(QInputDialog.IntInput)
        qid.setIntMinimum(2000)
        qid.setIntMaximum(9000)
        qid.setIntStep(100)
        async_call(self.servo.get_output_voltage, None, qid.setIntValue, self.increase_error_count)
        qid.intValueSelected.connect(self.output_voltage_selected)
        qid.setLabelText("Choose Output Voltage in mV.")
#                         "<font color=red>Setting this too high can destroy your servo.</font>")
        qid.open()
Exemplo n.º 14
0
 def update(self):
     if self.r1_monoflop:
         try:
             async_call(self.dr.get_monoflop, 1, lambda a: self.time1_spinbox.setValue(a[2]), self.increase_error_count)
         except ip_connection.Error:
             pass
     if self.r2_monoflop:
         try:
             async_call(self.dr.get_monoflop, 2, lambda a: self.time2_spinbox.setValue(a[2]), self.increase_error_count)
         except ip_connection.Error:
             pass
Exemplo n.º 15
0
    def motor_current_button_pressed(self):
        qid = QInputDialog(self)
        qid.setInputMode(QInputDialog.IntInput)
        qid.setIntMinimum(0)
        qid.setIntMaximum(2500)
        qid.setIntStep(100)
        async_call(self.stepper.get_motor_current, None, qid.setIntValue, self.increase_error_count)
        qid.intValueSelected.connect(self.motor_current_selected)
        qid.setLabelText("Choose motor current in mA.")
#                         "<font color=red>Setting this too high can destroy your Motor.</font>")
        qid.open()
    def monoflop_pin_changed(self):
        try:
            pin = int(self.monoflop_pin.currentText().replace('Pin ', ''))
        except ValueError:
            return

        if self.monoflop_pending[pin]:
            async_call(self.iqr.get_monoflop, pin, self.monoflop_pin_changed_async, self.increase_error_count)
            self.monoflop_time.setEnabled(False)
        else:
            self.monoflop_time.setValue(self.monoflop_time_before[pin])
            self.monoflop_time.setEnabled(True)
    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()
    def reconfigure_everything_async2(self, value_mask):
        for pin in range(16):
            if value_mask & (1 << pin):
                self.relay_buttons[pin].setText('Switch Off')
                self.relay_button_icons[pin].setPixmap(self.close_pixmap)
            else:
                self.relay_buttons[pin].setText('Switch On')
                self.relay_button_icons[pin].setPixmap(self.open_pixmap)

            index = self.monoflop_pin.findText('Pin {0}'.format(pin))
            if index >= 0:
                def get_monoflop_lambda(pin):
                    return lambda monoflop: self.reconfigure_everything_async3(pin, *monoflop)
                async_call(self.iqr.get_monoflop, pin, get_monoflop_lambda(pin), self.increase_error_count)
Exemplo n.º 19
0
    def start(self):
        if not self.alive:
            return

        self.gl_layout.activate()
        async_call(self.imu.set_all_data_period, 100, None, self.increase_error_count)
        async_call(self.imu.set_orientation_period, 100, None, self.increase_error_count)
        async_call(self.imu.set_quaternion_period, 50, None, self.increase_error_count)
        self.update_timer.start(50)
        
        async_call(self.imu.get_convergence_speed, None, self.speed_spinbox.setValue, self.increase_error_count)
Exemplo n.º 20
0
    def start(self):
        async_call(self.barometer.get_air_pressure, None, self.cb_air_pressure, self.increase_error_count)
        async_call(self.barometer.get_altitude, None, self.cb_altitude, self.increase_error_count)

        async_call(self.barometer.set_air_pressure_callback_period, 100, None, self.increase_error_count)
        async_call(self.barometer.set_altitude_callback_period, 100, None, self.increase_error_count)

        self.air_pressure_plot_widget.stop = False
        self.altitude_plot_widget.stop = False

        self.update_chip_temp()
        self.chip_temp_timer.start()
Exemplo n.º 21
0
    def update_addresses(self):
        self.update_address = 0
        self.update_address_slave = 0

        def get_rs485_address_async(address_async):
            self.update_address = address_async
            self.update_generator.next()

        def get_rs485_slave_address_async(update_address_slave_async):
            self.update_address_slave = update_address_slave_async
            self.update_generator.next()

        async_call(self.master.get_rs485_address, None, get_rs485_address_async, self.parent.increase_error_count)
        yield

        address_slave = []
        for i in range(32):
            async_call(self.master.get_rs485_slave_address, i, get_rs485_slave_address_async, self.parent.increase_error_count)
            yield

            if self.update_address_slave == 0:
                break
            else:
                address_slave.append(str(self.update_address_slave))

        address_slave_text = ', '.join(address_slave)

        typ = 0
        if self.update_address == 0:
            typ = 1

            # trigger enumerate for rs485 slaves
            if infos.infos[self.parent.uid].enumeration_type == IPConnection.ENUMERATION_TYPE_CONNECTED:
                self.parent.ipcon.enumerate()

        self.lineedit_slave_address.setText(address_slave_text)
        self.address_spinbox.setValue(self.update_address)

        self.save_button.pressed.connect(self.save_pressed)
        self.rs485_type.currentIndexChanged.connect(self.rs485_type_changed)

        self.rs485_type.setCurrentIndex(typ)
        self.rs485_type_changed(typ)
Exemplo n.º 22
0
 def start(self):
     if self.version >= (2, 0, 1):
         async_call(self.ai.get_range, None, self.get_range_async, self.increase_error_count)
     async_call(self.ai.get_voltage, None, self.cb_voltage, self.increase_error_count)
     async_call(self.ai.set_voltage_callback_period, 100, None, self.increase_error_count)
     
     self.plot_widget.stop = False
Exemplo n.º 23
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)
Exemplo n.º 24
0
 def stop(self):
     async_call(self.vc.set_current_callback_period, 0, None, self.increase_error_count)
     async_call(self.vc.set_voltage_callback_period, 0, None, self.increase_error_count)
     async_call(self.vc.set_power_callback_period, 0, None, self.increase_error_count)
     
     self.plot_widget_current.stop = True
     self.plot_widget_voltage.stop = True
     self.plot_widget_power.stop = True
Exemplo n.º 25
0
    def init_async(self):
        self.init_value = 0
        self.init_dir = 0
        self.init_config = 0
        self.init_monoflop = 0
        
        def get_port_async(value):
            self.init_value = value
            self.init_async_generator.next()
        
        def get_port_configuration_async(conf):
            self.init_dir, self.init_config = conf
            self.init_async_generator.next()
            
        def get_monoflop_async(init_monoflop):
            self.init_monoflop = init_monoflop
            self.init_async_generator.next()
        
        def get_debounce_period_async(debounce_period):
            self.debounce_edit.setText(str(debounce_period))
        
        for port in ['a', 'b']:
            async_call(self.io.get_port, port, get_port_async, self.increase_error_count)
            yield
            async_call(self.io.get_port_configuration, port, get_port_configuration_async, self.increase_error_count)
            yield

            time = [0, 0, 0, 0, 0, 0, 0, 0]
            time_remaining = [0, 0, 0, 0, 0, 0, 0, 0]

            if self.has_monoflop:
                for pin in range(8):
                    async_call(self.io.get_port_monoflop, (port, pin), get_monoflop_async, self.increase_error_count)
                    yield

                    time[pin] = self.init_monoflop.time
                    time_remaining[pin] = self.init_monoflop.time_remaining

            self.init_values(port, self.init_value, self.init_dir, self.init_config, time, time_remaining)

        async_call(self.io.get_debounce_period, None, get_debounce_period_async, self.increase_error_count)
Exemplo n.º 26
0
    def update_data(self):
        async_call(self.stepper.get_remaining_steps, None, self.remaining_steps_update, self.increase_error_count)
        async_call(self.stepper.get_current_position, None, self.position_update, self.increase_error_count)
        async_call(self.stepper.get_current_velocity, None, self.speedometer.set_velocity, self.increase_error_count)

        self.update_counter += 1
        if self.update_counter % 10 == 0:
            async_call(self.stepper.get_motor_current, None, self.maximum_current_update, self.increase_error_count)
            async_call(self.stepper.get_stack_input_voltage, None, self.stack_input_voltage_update, self.increase_error_count)
            async_call(self.stepper.get_external_input_voltage, None, self.external_input_voltage_update, self.increase_error_count)
            async_call(self.stepper.get_minimum_voltage, None, self.minimum_voltage_update, self.increase_error_count)
            async_call(self.stepper.get_step_mode, None, self.mode_update, self.increase_error_count)
Exemplo n.º 27
0
 def update_start(self):
     async_call(self.stepper.get_max_velocity, None, self.get_max_velocity_async, self.increase_error_count)
     async_call(self.stepper.get_speed_ramping, None, self.get_speed_ramping_async, self.increase_error_count)
     async_call(self.stepper.is_enabled, None, self.is_enabled_async, self.increase_error_count)
Exemplo n.º 28
0
    def stop(self):
        async_call(self.io.set_interrupt, 0, None, self.increase_error_count)

        self.update_timer.stop()
Exemplo n.º 29
0
 def update_chip_temp(self):
     async_call(self.barometer.get_chip_temperature, None, self.update_chip_temp_async, self.increase_error_count)
Exemplo n.º 30
0
 def get_reference_pressed(self):
     async_call(self.barometer.get_reference_air_pressure, None, self.get_reference_pressed_async, self.increase_error_count)