Exemplo n.º 1
0
    def _btn_add_device_clicked(self):
        """
            Add the selected device from the list/DataLogger-Config.
        """
        items = self.list_widget.selectedItems()
        cur_dev = GuiConfigHandler.get_simple_blueprint(self.Ui_Logger)
        for item in items:
            name = item.text()
            if name == self._no_connected_device_string or name == self._list_separator_string:
                # ignore those
                continue

            dev_name, uid = Utilities.parse_device_name(name)
            dev = GuiConfigHandler.get_device_blueprint(dev_name)
            if dev is None:
                EventLogger.debug("DeviceDialog._btn_add_device_clicked: Blueprint(" + str(dev_name) + ") was None!")
                continue

            if uid is not None:
                if self.__is_device_in_list(dev_name, uid, cur_dev):
                    continue
                # else
                dev[Identifier.DD_UID] = uid

            else:
                dev[Identifier.DD_UID] = Identifier.DD_UID_DEFAULT

            self._logger_window.add_item_to_tree(dev)
Exemplo n.º 2
0
    def _btn_add_all_devices_clicked(self):
        cur_dev = GuiConfigHandler.get_simple_blueprint(self.Ui_Logger)
        connected_devices = infos.get_device_infos()
        if len(connected_devices) <= 0:
            return
        con_dev = []
        for device_info in connected_devices:
            if device_info.name in Identifier.DEVICE_DEFINITIONS:
                tmp = {}
                tmp[device_info.name] = device_info.uid
                con_dev.append(tmp)

        for dev in con_dev:
            for key in dev.keys():
                if not self.__is_device_in_list(key, dev[key], cur_dev):
                    blueprint = GuiConfigHandler.get_device_blueprint(key)
                    if blueprint is None:
                        return
                    blueprint[Identifier.DD_UID] = dev[key]
                    self._logger_window.add_item_to_tree(blueprint)