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)
def btn_start_logging_clicked(self): """ Start/Stop of the logging process """ if (self.data_logger_thread is not None) and (not self.data_logger_thread.stopped): self.btn_start_logging.clicked.disconnect() self.data_logger_thread.stop() self._reset_stop() elif self.data_logger_thread is None: from data_logger import main arguments_map = {} arguments_map[ main.GUI_CONFIG] = GuiConfigHandler.create_config_file(self) self._gui_job = GuiDataJob(name="GuiData-Writer") self.connect(self._gui_job, QtCore.SIGNAL(GuiDataJob.SIGNAL_NEW_DATA), self.table_add_row) arguments_map[main.GUI_ELEMENT] = self._gui_job self.data_logger_thread = main.main(arguments_map) if self.data_logger_thread is not None: self.btn_start_logging.setText("Stop Logging") self.tab_devices.setEnabled(False) self.tab_setup.setEnabled(False) # self.tab_xively.setEnabled(False)#nyi self.tab_widget.setCurrentIndex( self.tab_widget.indexOf(self.tab_console)) self.tab_reset_warning()
def btn_save_config_clicked(self): """ Opens a FileSelectionDialog and saves the current config. """ conf = GuiConfigHandler.create_config_file(self) fn = QtGui.QFileDialog.getSaveFileName(self, 'Save Config-File', os.getcwd(), filter='*.json') if fn == "": # cancel EventLogger.debug("Cancelled load Config.") return try: with open(fn, 'w') as outfile: json.dump(conf, outfile, sort_keys=True, indent=2) except Exception as e1: EventLogger.warning("Load Config - Exception: " + str(e1)) QMessageBox.warning( self, 'Error', 'Could not save the Config-File! Look at the Log-File for further information.', QMessageBox.Ok) return QMessageBox.information(self, 'Success', 'Config-File saved!', QMessageBox.Ok) EventLogger.info("Config-File saved to: " + str(fn))
def btn_start_logging_clicked(self): """ Start/Stop of the logging process """ if (self.data_logger_thread is not None) and (not self.data_logger_thread.stopped): self.btn_start_logging.clicked.disconnect() self.data_logger_thread.stop() self._reset_stop() elif self.data_logger_thread is None: from data_logger import main arguments_map = {} arguments_map[main.GUI_CONFIG] = GuiConfigHandler.create_config_file(self) self._gui_job = GuiDataJob(name="GuiData-Writer") self.connect(self._gui_job, QtCore.SIGNAL(GuiDataJob.SIGNAL_NEW_DATA), self.table_add_row) arguments_map[main.GUI_ELEMENT] = self._gui_job self.data_logger_thread = main.main(arguments_map) if self.data_logger_thread is not None: self.btn_start_logging.setText("Stop Logging") self.tab_devices.setEnabled(False) self.tab_setup.setEnabled(False) # self.tab_xively.setEnabled(False)#nyi self.tab_widget.setCurrentIndex(self.tab_widget.indexOf(self.tab_console)) self.tab_reset_warning()
def btn_load_config_clicked(self): """ Opens a FileSelectionDialog and loads the selected config. """ fn = QtGui.QFileDialog.getOpenFileName(self, "Open Config-File...", os.getcwd(), "JSON-Files (*.json)") if fn == "": # cancel EventLogger.debug("Cancelled save Config.") return config_json = None try: with codecs.open(fn, 'r', 'UTF-8') as content_file: try: config_json = json.load(content_file) except ValueError as e: EventLogger.warning("Load Config - Cant parse the configuration file: " + str(e)) except Exception as e1: EventLogger.warning("Load Config - Exception: " + str(e1)) return EventLogger.info("Loaded Config-File from: " + str(fn)) # devices config_blueprint = GuiConfigHandler.load_devices(config_json) if config_blueprint is None: return self.create_tree_items(config_blueprint) # general_section from brickv.data_logger.configuration_validator import ConfigurationReader self.update_setup_tab(config_json[ConfigurationReader.GENERAL_SECTION])
def btn_start_logging_clicked(self): """ Start/Stop of the logging process """ if (self.data_logger_thread is not None) and (not self.data_logger_thread.stopped): self.btn_start_logging.clicked.disconnect() self.data_logger_thread.stop() self._reset_stop() elif self.data_logger_thread is None: from brickv.data_logger import main self._gui_job = GuiDataJob(name="GuiData-Writer") self.connect(self._gui_job, QtCore.SIGNAL(GuiDataJob.SIGNAL_NEW_DATA), self.table_add_row) self.data_logger_thread = main.main( None, GuiConfigHandler.create_config(self), self._gui_job) if self.data_logger_thread is not None: self.btn_start_logging.setText("Stop Logging") self.btn_start_logging.setIcon( QIcon(load_pixmap('data_logger/stop-icon.png'))) self.tab_devices.setEnabled(False) self.tab_setup.setEnabled(False) self.tab_widget.setCurrentIndex( self.tab_widget.indexOf(self.tab_data)) self.tab_reset_warning()
def btn_start_logging_clicked(self): """ Start/Stop of the logging process """ if (self.data_logger_thread is not None) and (not self.data_logger_thread.stopped): self.btn_start_logging.clicked.disconnect() self.data_logger_thread.stop() self._reset_stop() elif self.data_logger_thread is None: from brickv.data_logger import main self._gui_job = GuiDataJob(name="GuiData-Writer") self.connect(self._gui_job, QtCore.SIGNAL(GuiDataJob.SIGNAL_NEW_DATA), self.table_add_row) self.data_logger_thread = main.main(None, GuiConfigHandler.create_config(self), self._gui_job) if self.data_logger_thread is not None: self.btn_start_logging.setText("Stop Logging") self.btn_start_logging.setIcon(QIcon(load_pixmap('data_logger/stop-icon.png'))) self.tab_devices.setEnabled(False) self.tab_setup.setEnabled(False) self.tab_widget.setCurrentIndex(self.tab_widget.indexOf(self.tab_data)) self.tab_reset_warning()
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)
def btn_save_config_clicked(self): filename = get_save_file_name(get_main_window(), 'Save Config', get_home_path(), 'JSON Files (*.json)') if len(filename) == 0: return if not filename.lower().endswith('.json'): filename += '.json' config = GuiConfigHandler.create_config(self) if not save_config(config, filename): QMessageBox.warning(get_main_window(), 'Save Config', 'Could not save config to file! See Debug tab for details.', QMessageBox.Ok)
def btn_save_config_clicked(self): filename = get_save_file_name(self, 'Save Config', get_home_path(), 'JSON Files(*.json)') if len(filename) == 0: return if not filename.lower().endswith('.json'): filename += '.json' config = GuiConfigHandler.create_config(self) if not save_config(config, filename): QMessageBox.warning(self, 'Save Config', 'Could not save config to file! See Debug tab for details.', QMessageBox.Ok)
def btn_load_config_clicked(self): """ Opens a FileSelectionDialog and loads the selected config. """ fn = QtGui.QFileDialog.getOpenFileName(self, "Open Config-File...", os.getcwd(), "JSON-Files (*.json)") if fn == "": # cancel EventLogger.debug("Cancelled save Config.") return config_json = None try: with codecs.open(fn, 'r', 'UTF-8') as content_file: try: config_json = json.load(content_file) except ValueError as e: EventLogger.warning( "Load Config - Cant parse the configuration file: " + str(e)) except Exception as e1: EventLogger.warning("Load Config - Exception: " + str(e1)) return EventLogger.info("Loaded Config-File from: " + str(fn)) # devices config_blueprint = GuiConfigHandler.load_devices(config_json) if config_blueprint is None: return self.create_tree_items(config_blueprint) # general_section from brickv.data_logger.configuration_validator import ConfigurationReader self.update_setup_tab(config_json[ConfigurationReader.GENERAL_SECTION])
def btn_save_config_clicked(self): """ Opens a FileSelectionDialog and saves the current config. """ conf = GuiConfigHandler.create_config_file(self) fn = QtGui.QFileDialog.getSaveFileName(self, 'Save Config-File', os.getcwd(), filter='*.json') if fn == "": # cancel EventLogger.debug("Cancelled load Config.") return try: with open(fn, 'w') as outfile: json.dump(conf, outfile, sort_keys=True, indent=2) except Exception as e1: EventLogger.warning("Load Config - Exception: " + str(e1)) QMessageBox.warning(self, 'Error', 'Could not save the Config-File! Look at the Log-File for further information.', QMessageBox.Ok) return QMessageBox.information(self, 'Success', 'Config-File saved!', QMessageBox.Ok) EventLogger.info("Config-File saved to: " + str(fn))