def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.setupUi(self) self.parent = parent self.ipcon = parent.ipcon self.imu = parent.imu self.cal_acc = CalibrateAccelerometer(self) self.cal_mag = CalibrateMagnetometer(self) self.cal_gyr_bias = CalibrateGyroscopeBias(self) self.cal_gyr_bias = CalibrateGyroscopeBias(self) self.cal_gyr_gain = CalibrateGyroscopeGain(self) self.cal_imex = CalibrateImportExport(self) self.tab_widget = QTabWidget() self.tab_widget.currentChanged.connect(self.current_tab_changed) self.tab_widget.addTab(self.cal_acc, "Accelerometer") self.tab_widget.addTab(self.cal_mag, "Magnetometer") self.tab_widget.addTab(self.cal_gyr_bias, "Gyroscope Bias") self.tab_widget.addTab(self.cal_gyr_gain, "Gyroscope Gain") self.tab_widget.addTab(self.cal_imex, "Import/Export") self.vlayout.addWidget(self.tab_widget) self.refresh_values()
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.setupUi(self) self.parent = parent self.master = self.parent.master self.client_group = [ (self.wifi_client_status_status, self.wifi_client_status_status_label), (self.wifi_client_status_signal_strength, self.wifi_client_status_signal_strength_label), (self.wifi_client_status_ip, self.wifi_client_status_ip_label), (self.wifi_client_status_subnet_mask, self.wifi_client_status_subnet_mask_label), (self.wifi_client_status_gateway, self.wifi_client_status_gateway_label), (self.wifi_client_status_mac_address, self.wifi_client_status_mac_address_label), (self.wifi_client_status_rx, self.wifi_client_status_rx_label), (self.wifi_client_status_tx, self.wifi_client_status_tx_label), ] self.ap_group = [ (self.wifi_ap_status_connected_count, self.wifi_ap_status_connected_count_label), (self.wifi_ap_status_ip, self.wifi_ap_status_ip_label), (self.wifi_ap_status_subnet_mask, self.wifi_ap_status_subnet_mask_label), (self.wifi_ap_status_gateway, self.wifi_ap_status_gateway_label), (self.wifi_ap_status_mac_address, self.wifi_ap_status_mac_address_label), (self.wifi_ap_status_rx, self.wifi_ap_status_rx_label), (self.wifi_ap_status_tx, self.wifi_ap_status_tx_label), ] self.wifi_status_button_close.clicked.connect(self.close) self.update_status()
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.parent = parent self.setupUi(self) # Synced voltage, current and power. Updated with callbacks. self.voltage = 0 self.current = 0 self.power = 0 # Synced calibration parameters. Updated with get_calibration() calls. self.cal_v_mul = 1 self.cal_v_div = 1 self.cal_c_mul = 1 self.cal_c_div = 1 self.btn_cal_v.clicked.connect(self.cal_v_clicked) self.btn_cal_c.clicked.connect(self.cal_c_clicked) self.btn_cal_rst.clicked.connect(self.cal_rst_clicked) self.cbe_voltage = CallbackEmulator(self.parent.vc.get_voltage, None, self.cb_voltage, self.parent.increase_error_count) self.cbe_current = CallbackEmulator(self.parent.vc.get_current, None, self.cb_current, self.parent.increase_error_count) self.cbe_power = CallbackEmulator(self.parent.vc.get_power, None, self.cb_power, self.parent.increase_error_count)
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.parent = parent self.setupUi(self) # Synced air pressure, altitude and temperature. Updated with callbacks. self.air_pressure = 0 self.altitude = 0 self.temperature = 0 self.btn_cal_remove.clicked.connect(self.btn_cal_remove_clicked) self.btn_cal_calibrate.clicked.connect(self.btn_cal_calibrate_clicked) self.cbe_air_pressure = CallbackEmulator(self.parent.barometer.get_air_pressure, None, self.cb_air_pressure, self.parent.increase_error_count) self.cbe_altitude = CallbackEmulator(self.parent.barometer.get_altitude, None, self.cb_altitude, self.parent.increase_error_count) self.cbe_temperature = CallbackEmulator(self.parent.barometer.get_temperature, None, self.cb_temperature, self.parent.increase_error_count)
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.parent = parent self.setupUi(self) # Synced air pressure, altitude and temperature. Updated with callbacks. self.air_pressure = 0 self.altitude = 0 self.temperature = 0 self.btn_cal_remove.clicked.connect(self.btn_cal_remove_clicked) self.btn_cal_calibrate.clicked.connect(self.btn_cal_calibrate_clicked) self.btn_close.clicked.connect(self.close) self.cbe_air_pressure = CallbackEmulator( self.parent.barometer.get_air_pressure, None, self.cb_air_pressure, self.parent.increase_error_count) self.cbe_altitude = CallbackEmulator( self.parent.barometer.get_altitude, None, self.cb_altitude, self.parent.increase_error_count) self.cbe_temperature = CallbackEmulator( self.parent.barometer.get_temperature, None, self.cb_temperature, self.parent.increase_error_count)
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.setupUi(self) self.parent = parent self.rtc = parent.rtc self.measured_ppm = 0 self.measured_ppm_avg = 0 self.measured_ppm_history = [] self.measured_ppm_index = 0 self.label_error_title.hide() self.label_error_message.hide() self.qtcb_measured_duration.connect(self.cb_measured_duration) self.qtcb_measurement_error.connect(self.cb_measurement_error) self.button_restart.clicked.connect(self.restart) self.button_close.clicked.connect(self.close) self.spin_new_offset.valueChanged.connect(self.update_new_offset_label) self.button_optimize.clicked.connect(self.optimize) self.button_save.clicked.connect(self.save) self.label_current_offset.setText('%.02f ppm (%d)' % (self.parent.offset * 2.17, self.parent.offset)) self.spin_new_offset.setValue(self.parent.offset) self.measurment_thread = MeasurmentThread(self) self.measurment_thread.start()
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.setupUi(self) self.parent = parent self.master = self.parent.master self.button_close.clicked.connect(self.close) self.update_status()
def untab(self): index = self.tab_widget.indexOf(self) if index > -1: if self.cb_on_untab != None: self.cb_on_untab(index) self.tab_widget.removeTab(index) self.setWindowFlags(get_modeless_dialog_flags(Qt.Window)) self.setWindowTitle(self.name) self.adjustSize() self.show()
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.setupUi(self) self.parent = parent self.master = parent.master self.button_type_save.clicked.connect(self.save_clicked) self.combo_extension.currentIndexChanged.connect(self.index_changed) self.index_changed(0)
def untab(self): index = self.tab_widget.indexOf(self) if index > -1: if self.cb_on_untab != None: self.cb_on_untab(index) self.tab_widget.removeTab(index) self.setWindowFlags(get_modeless_dialog_flags(Qt.Window)) self.setWindowTitle('Brick Viewer ' + config.BRICKV_VERSION + ' - ' + self.name) self.adjustSize() self.show()
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.setupUi(self) self.text_browser.setHtml(""" <p><b>General:</b> The IMU does continous self-calibration during usage. It is not necessary to start a specific calibration process.</p> <p>Accelerometer and gyroscope are factory calibrated and are less susceptible to external disturbances. As a result the offsets can be seen as negligble and calibration is not important. For the magnetometer on the other hand calibration is mandatory after each "power on reset".</p> <p>To make this easier we allow to save the calibration to the flash of the IMU Bricklet and load the calibration on each startup. This way there is no "startup phase" that is necessary until the IMU Bricklet has calibrated itself.</p> <p><b>Calibration values:</b> Saving a calibration is only possible if all sensors are fully calibrated.</p> <ul> <li>green = fully calibrated,</li> <li>yellow = calibration OK,</li> <li>orange = calibration recommended and</li> <li>red = not calibrated.</li> </ul> <p><b>Accelerometer:</b> Place the IMU Bricklet in 6 different stable position for a period of a few seconds. Use slow movement between stable positions. Use at least one position that is perpendicular to the x, y and z axis.</p> <p><b>Magnetometer:</b> Make random movements (e.g. write a figure 8 in air).</p> <p><b>Gyroscope:</b> Place the IMU Bricklet in a single stable position for a period of several seconds.</p> <p><b>System:</b> Wait for the system to stabilize. Use only small movements during stabilization.</p>""") self.parent = parent self.ipcon = parent.ipcon self.imu = parent.imu self.acc_color = ColorFrame(15, 15, Qt.red) self.mag_color = ColorFrame(15, 15, Qt.red) self.gyr_color = ColorFrame(15, 15, Qt.red) self.sys_color = ColorFrame(15, 15, Qt.red) self.grid.addWidget(self.acc_color, 2, 2) self.grid.addWidget(self.mag_color, 3, 2) self.grid.addWidget(self.gyr_color, 4, 2) self.grid.addWidget(self.sys_color, 5, 2) self.save_calibration.clicked.connect(self.save_calibration_clicked) self.button_close.clicked.connect(self.close)
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.setupUi(self) self.parent = parent self.lc = parent.lc self.button_zero.clicked.connect(self.button_zero_clicked) self.button_weight.clicked.connect(self.button_weight_clicked) self.button_weight.setEnabled(False) self.label_step1.setStyleSheet('QLabel { color : red }') self.label_step2.setStyleSheet('') self.label_status.setText('Calibration in progress...')
def tab(self): if self.windowFlags() & get_modeless_dialog_flags(Qt.Window): self.setWindowFlags(Qt.Widget) index = self.tab_widget.addTab(self, self.name) # (re-)instantiating button here because the TabBar takes ownership and # destroys it when this TabWindow is untabbed self.button = IconButton(self, self.button_icon_default, self.button_icon_mouse_over) self.tab_widget.tabBar().setTabButton(index, QTabBar.LeftSide, self.button) self.button.clicked.connect(lambda: self.button_handler(self.tab_widget.indexOf(self))) if self.cb_on_tab != None: self.cb_on_tab(index)
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.parent = parent self.setupUi(self) self.current_value = 0 self.button_cal_remove.clicked.connect(self.remove_clicked) self.button_cal_offset.clicked.connect(self.offset_clicked) self.button_cal_gain.clicked.connect(self.gain_clicked) self.cbe_voltage = CallbackEmulator(self.parent.ai.get_voltage, None, self.cb_voltage, self.parent.increase_error_count)
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.setupUi(self) self.text_browser.setHtml(""" <p><b>General:</b> The IMU does continous self-calibration during usage. It is not necessary to start a specific calibration process.</p> <p>Accelerometer and gyroscope are factory calibrated and are less susceptible to external disturbances. As a result the offsets can be seen as negligble and calibration is not important. For the magnetometer on the other hand calibration is mandatory after each "power on reset".</p> <p>To make this easier we allow to save the calibration to the flash of the IMU Brick and load the calibration on each startup. This way there is no "startup phase" that is necessary until the IMU Brick has calibrated itself.</p> <p><b>Calibration values:</b> Saving a calibration is only possible if all sensors are fully calibrated.</p> <ul> <li>green = fully calibrated,</li> <li>yellow = calibration OK,</li> <li>orange = calibration recommended and</li> <li>red = not calibrated.</li> </ul> <p><b>Accelerometer:</b> Place the IMU Brick in 6 different stable position for a period of a few seconds. Use slow movement between stable positions. Use at least one position that is perpendicular to the x, y and z axis.</p> <p><b>Magnetometer:</b> Make random movements (e.g. write a figure 8 in air).</p> <p><b>Gyroscope:</b> Place the IMU Brick in a single stable position for a period of several seconds.</p> <p><b>System:</b> Wait for the system to stabilize. Use only small movements during stabilization.</p>""") self.parent = parent self.ipcon = parent.ipcon self.imu = parent.imu self.acc_color = ColorFrame() self.mag_color = ColorFrame() self.gyr_color = ColorFrame() self.sys_color = ColorFrame() self.grid.addWidget(self.acc_color, 2, 2) self.grid.addWidget(self.mag_color, 3, 2) self.grid.addWidget(self.gyr_color, 4, 2) self.grid.addWidget(self.sys_color, 5, 2) self.save_calibration.clicked.connect(self.save_calibration_clicked)
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.parent = parent self.setupUi(self) self.cbe_mfd = CallbackEmulator(self.parent.compass.get_magnetic_flux_density, None, self.cb_mfd, self.parent.increase_error_count) self.x = [0, 0, 0] self.y = [0, 0, 0] self.z = [0, 0, 0] self.button_calibration_remove.clicked.connect(self.calibration_remove_clicked) self.button_calibration_save.clicked.connect(self.calibration_save_clicked) self.button_calibration_save.setEnabled(False)
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.setupUi(self) self.button_calibrate.setEnabled(False) self.brick_infos = [] self.parent = parent self.button_calibrate.clicked.connect(self.calibrate_clicked) self.combo_brick.currentIndexChanged.connect(self.brick_changed) self.check_enable_calibration.stateChanged.connect(self.enable_calibration_changed) infos.get_infos_changed_signal().connect(self.update_bricks) self.update_bricks()
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.setupUi(self) self.ipcon_available = False self.gc_runs = 0 self.gc_collected = 0 self.gc_uncollectable = 0 self.gc_stats_changed.connect(self.update_gc_stats) self.button_force_gc.clicked.connect(self.force_gc) self.button_close.clicked.connect(self.hide) gc.callbacks.append(self.gc_callback)
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.parent = parent self.values0 = [0]*10 self.values1 = [0]*10 self.values_index = 0 self.setupUi(self) self.button_cal_remove.clicked.connect(self.remove_clicked) self.button_cal_offset.clicked.connect(self.offset_clicked) self.button_cal_gain.clicked.connect(self.gain_clicked) self.cbe_adc = CallbackEmulator(self.parent.analog_in.get_adc_values, self.cb_adc_values, self.parent.increase_error_count)
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.parent = parent self.values0 = [0] * 10 self.values1 = [0] * 10 self.values_index = 0 self.setupUi(self) self.button_cal_remove.clicked.connect(self.remove_clicked) self.button_cal_offset.clicked.connect(self.offset_clicked) self.button_cal_gain.clicked.connect(self.gain_clicked) self.cbe_adc_values = CallbackEmulator( self.parent.analog_in.get_adc_values, None, self.cb_adc_values, self.parent.increase_error_count)
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self._logger_window = parent self.device_name_by_device_identifier = {} for display_name, device_spec in device_specs.items(): self.device_name_by_device_identifier[ device_spec['class'].DEVICE_IDENTIFIER] = display_name self.qtcb_enumerate.connect(self.cb_enumerate) self.qtcb_connected.connect(self.cb_connected) self.host = None self.port = None self.secret = None self.ipcon = IPConnection() self.ipcon.register_callback(IPConnection.CALLBACK_CONNECTED, self.qtcb_connected.emit) self.ipcon.register_callback(IPConnection.CALLBACK_ENUMERATE, self.qtcb_enumerate.emit) self.setupUi(self) self.btn_add_device.clicked.connect(self.btn_add_device_clicked) self.btn_refresh.clicked.connect(self.btn_refresh_clicked) self.btn_close.clicked.connect(self.btn_close_clicked) self.tree_widget.itemActivated.connect(self.add_item) self.connected_uids = [] self.available_item = QTreeWidgetItem(['No devices available']) self.supported_item = QTreeWidgetItem(['Supported devices']) self.tree_widget.addTopLevelItem(self.available_item) self.tree_widget.addTopLevelItem(self.supported_item) for device_name in device_specs: self.supported_item.addChild(QTreeWidgetItem([device_name])) self.supported_item.sortChildren(0, Qt.AscendingOrder) self.supported_item.setExpanded(True)
def __init__(self, parent): super().__init__(parent, get_modeless_dialog_flags()) self.setupUi(self) self.ipcon_available = False self.button_save_report_to_csv_file.clicked.connect( self.save_report_to_csv_file) self.button_close.clicked.connect(self.hide) self.fixed_column_names = [ 'Name', 'UID', 'Position', 'FW Version', 'Metric Errors' ] self.dynamic_column_names = [] self.metric_errors = {} # by uid self.old_values = {} # by uid, by metric name self.tree_view_model = QStandardItemModel(self) self.tree_view_proxy_model = DevicesProxyModel(self) self.tree_view_proxy_model.setSourceModel(self.tree_view_model) self.tree_view.setModel(self.tree_view_proxy_model) self.tree_view.setSortingEnabled(True) self.tree_view.header().setSortIndicator(2, Qt.AscendingOrder) self.tree_view.setExpandsOnDoubleClick(False) self.delayed_refresh_tree_view_timer = QTimer(self) self.delayed_refresh_tree_view_timer.timeout.connect( self.delayed_refresh_tree_view) self.delayed_refresh_tree_view_timer.setInterval(100) inventory.info_changed.connect( lambda: self.delayed_refresh_tree_view_timer.start()) self.update_metric_values_timer = QTimer(self) self.update_metric_values_timer.timeout.connect( lambda: self.update_metric_values()) self.update_metric_values_timer.setInterval(1000) self.update_metric_values_timer.start() self.refresh_tree_view() self.update_ui_state()
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self._logger_window = parent self.device_name_by_device_identifier = {} for display_name, device_spec in device_specs.items(): self.device_name_by_device_identifier[device_spec['class'].DEVICE_IDENTIFIER] = display_name self.qtcb_enumerate.connect(self.cb_enumerate) self.qtcb_connected.connect(self.cb_connected) self.host = None self.port = None self.secret = None self.ipcon = IPConnection() self.ipcon.register_callback(IPConnection.CALLBACK_CONNECTED, self.qtcb_connected.emit) self.ipcon.register_callback(IPConnection.CALLBACK_ENUMERATE, self.qtcb_enumerate.emit) self.setupUi(self) self.btn_add_device.clicked.connect(self.btn_add_device_clicked) self.btn_refresh.clicked.connect(self.btn_refresh_clicked) self.btn_close.clicked.connect(self.btn_close_clicked) self.tree_widget.itemActivated.connect(self.add_item) self.connected_uids = [] self.available_item = QTreeWidgetItem(['No devices available']) self.supported_item = QTreeWidgetItem(['Supported devices']) self.tree_widget.addTopLevelItem(self.available_item) self.tree_widget.addTopLevelItem(self.supported_item) for device_name in device_specs: self.supported_item.addChild(QTreeWidgetItem([device_name])) self.supported_item.sortChildren(0, Qt.AscendingOrder) self.supported_item.setExpanded(True)
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.parent = parent self.setupUi(self) self.cbe_mfd = CallbackEmulator( self.parent.compass.get_magnetic_flux_density, None, self.cb_mfd, self.parent.increase_error_count) self.x = [0, 0, 0] self.y = [0, 0, 0] self.z = [0, 0, 0] self.button_calibration_remove.clicked.connect( self.calibration_remove_clicked) self.button_calibration_save.clicked.connect( self.calibration_save_clicked) self.button_calibration_save.setEnabled(False)
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.setupUi(self) self.ipcon_available = False self.button_calibrate.setEnabled(False) self.brick_infos = [] self.parent = parent self.button_calibrate.clicked.connect(self.calibrate_clicked) self.combo_brick.currentIndexChanged.connect(self.brick_changed) self.check_enable_calibration.stateChanged.connect(self.enable_calibration_changed) inventory.info_changed.connect(self.update_bricks) self.button_close.clicked.connect(self.hide) self.update_bricks()
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.setupUi(self) self.parent = parent self.rtc = parent.rtc self.measured_ppm = 0 self.measured_ppm_avg = 0 self.measured_ppm_history = [] self.measured_ppm_index = 0 self.timeout_count = 0 self.label_warning_title.hide() self.label_warning_message.hide() self.label_timeout_title.hide() self.label_timeout_count.hide() self.qtcb_measured_duration.connect(self.cb_measured_duration) self.qtcb_warning.connect(self.cb_warning) self.qtcb_timeout.connect(self.cb_timeout) self.button_restart.clicked.connect(self.restart) self.button_close.clicked.connect(self.close) self.spin_new_offset.valueChanged.connect(self.update_new_offset_label) self.button_optimize.clicked.connect(self.optimize) self.button_save.clicked.connect(self.save) if abs(self.parent.offset * 2.17) <= 20.0: color = '<font>' else: color = '<font color="#FF0000">' self.label_current_offset.setText( '%s%.02f ppm</font> (%d)' % (color, self.parent.offset * 2.17, self.parent.offset)) self.spin_new_offset.setValue(self.parent.offset) self.measurment_thread = MeasurmentThread(self) self.measurment_thread.start()
def __init__(self, parent): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self.setupUi(self) self.parent = parent self.rtc = parent.rtc self.measured_ppm = 0 self.measured_ppm_avg = 0 self.measured_ppm_history = [] self.measured_ppm_index = 0 self.timeout_count = 0 self.label_warning_title.hide() self.label_warning_message.hide() self.label_timeout_title.hide() self.label_timeout_count.hide() self.qtcb_measured_duration.connect(self.cb_measured_duration) self.qtcb_warning.connect(self.cb_warning) self.qtcb_timeout.connect(self.cb_timeout) self.button_restart.clicked.connect(self.restart) self.button_close.clicked.connect(self.close) self.spin_new_offset.valueChanged.connect(self.update_new_offset_label) self.button_optimize.clicked.connect(self.optimize) self.button_save.clicked.connect(self.save) if abs(self.parent.offset * 2.17) <= 20.0: color = '<font>' else: color = '<font color="#FF0000">' self.label_current_offset.setText('%s%.02f ppm</font> (%d)' % (color, self.parent.offset * 2.17, self.parent.offset)) self.spin_new_offset.setValue(self.parent.offset) self.measurment_thread = MeasurmentThread(self) self.measurment_thread.start()
def __init__(self, parent, host_infos): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self._gui_logger = GUILogger("GUILogger", logging.INFO) self._gui_job = None EventLogger.add_logger(self._gui_logger) self.data_logger_thread = None self.tab_debug_warning = False self.device_dialog = None self.last_host_index = -1 self.setupUi(self) self.model_data = QStandardItemModel(self) self.model_data.setHorizontalHeaderLabels(['Time', 'Name', 'UID', 'Var', 'Raw', 'Unit']) self.table_data.setModel(self.model_data) self.table_data.setColumnWidth(0, 160) self.table_data.setColumnWidth(1, 170) self.table_data.setColumnWidth(2, 50) self.table_data.setColumnWidth(3, 110) self.table_data.setColumnWidth(4, 70) self.table_data.setColumnWidth(5, 100) self.model_devices = QStandardItemModel(self) self.model_devices.setHorizontalHeaderLabels(['Device', 'Value']) self.tree_devices.setModel(self.model_devices) self.tree_devices.setColumnWidth(0, 300) self.signal_initialization() self.check_authentication.stateChanged.connect(self.authentication_state_changed) self.label_secret.hide() self.edit_secret.hide() self.edit_secret.setEchoMode(QLineEdit.Password) self.check_secret_show.hide() self.check_secret_show.stateChanged.connect(self.secret_show_state_changed) self.btn_start_logging.setIcon(QIcon(load_pixmap('data_logger/start-icon.png'))) self.example_timestamp = time.time() self.edit_csv_file_name.setText(os.path.join(get_home_path(), 'logger_data_{0}.csv'.format(int(self.example_timestamp)))) self.edit_log_file_name.setText(os.path.join(get_home_path(), 'logger_debug_{0}.log'.format(int(self.example_timestamp)))) self.combo_data_time_format.addItem(utils.timestamp_to_de(self.example_timestamp) + ' (DD.MM.YYYY HH:MM:SS)', 'de') self.combo_data_time_format.addItem(utils.timestamp_to_de_msec(self.example_timestamp) + ' (DD.MM.YYYY HH:MM:SS,000)', 'de-msec') self.combo_data_time_format.insertSeparator(self.combo_data_time_format.count()) self.combo_data_time_format.addItem(utils.timestamp_to_us(self.example_timestamp) + ' (MM/DD/YYYY HH:MM:SS)', 'us') self.combo_data_time_format.addItem(utils.timestamp_to_us_msec(self.example_timestamp) + ' (MM/DD/YYYY HH:MM:SS.000)', 'us-msec') self.combo_data_time_format.insertSeparator(self.combo_data_time_format.count()) self.combo_data_time_format.addItem(utils.timestamp_to_iso(self.example_timestamp) + ' (ISO 8601)', 'iso') self.combo_data_time_format.addItem(utils.timestamp_to_iso_msec(self.example_timestamp) + ' (ISO 8601 + Milliseconds)', 'iso-msec') self.combo_data_time_format.insertSeparator(self.combo_data_time_format.count()) self.combo_data_time_format.addItem(utils.timestamp_to_unix(self.example_timestamp) + ' (Unix)', 'unix') self.combo_data_time_format.addItem(utils.timestamp_to_unix_msec(self.example_timestamp) + ' (Unix + Milliseconds)', 'unix-msec') self.combo_data_time_format.insertSeparator(self.combo_data_time_format.count()) t = utils.timestamp_to_strftime(self.example_timestamp, self.edit_data_time_format_strftime.text()) if len(t) == 0: t = '<empty>' self.combo_data_time_format.addItem((t + ' (strftime)'), 'strftime') self.combo_debug_time_format.addItem(utils.timestamp_to_de(self.example_timestamp) + ' (DD.MM.YYYY HH:MM:SS)', 'de') self.combo_debug_time_format.addItem(utils.timestamp_to_us(self.example_timestamp) + ' (MM/DD/YYYY HH:MM:SS)', 'us') self.combo_debug_time_format.addItem(utils.timestamp_to_iso(self.example_timestamp) + ' (ISO 8601)', 'iso') self.combo_debug_time_format.addItem(utils.timestamp_to_unix(self.example_timestamp) + ' (Unix)', 'unix') self.combo_log_level.addItem('Debug', 'debug') self.combo_log_level.addItem('Info', 'info') self.combo_log_level.addItem('Warning', 'warning') self.combo_log_level.addItem('Error', 'error') self.combo_log_level.addItem('Critical', 'critical') self.combo_log_level.setCurrentIndex(0) # debug self.combo_debug_level.addItem('Debug', logging.DEBUG) self.combo_debug_level.addItem('Info', logging.INFO) self.combo_debug_level.addItem('Warning', logging.WARNING) self.combo_debug_level.addItem('Error', logging.ERROR) self.combo_debug_level.addItem('Critical', logging.CRITICAL) self.combo_debug_level.setCurrentIndex(1) # info for host_info in host_infos: self.combo_host.addItem(host_info.host, (host_info.port, host_info.use_authentication, host_info.secret)) self._host_index_changed(0) self.update_ui_state()
def __init__(self, parent, host_infos): QDialog.__init__(self, parent, get_modeless_dialog_flags()) self._gui_logger = GUILogger("GUILogger", logging.INFO) self._gui_job = None EventLogger.add_logger(self._gui_logger) self.data_logger_thread = None self.tab_debug_warning = False self.device_dialog = None self.last_host_index = -1 self.setupUi(self) self.model_data = QStandardItemModel(self) self.model_data.setHorizontalHeaderLabels( ['Time', 'Name', 'UID', 'Var', 'Raw', 'Unit']) self.table_data.setModel(self.model_data) self.table_data.setColumnWidth(0, 160) self.table_data.setColumnWidth(1, 170) self.table_data.setColumnWidth(2, 50) self.table_data.setColumnWidth(3, 110) self.table_data.setColumnWidth(4, 70) self.table_data.setColumnWidth(5, 100) self.model_devices = QStandardItemModel(self) self.model_devices.setHorizontalHeaderLabels(['Device', 'Value']) self.tree_devices.setModel(self.model_devices) self.tree_devices.setColumnWidth(0, 300) self.signal_initialization() self.check_authentication.stateChanged.connect( self.authentication_state_changed) self.label_secret.hide() self.edit_secret.hide() self.edit_secret.setEchoMode(QLineEdit.Password) self.check_secret_show.hide() self.check_secret_show.stateChanged.connect( self.secret_show_state_changed) self.btn_start_logging.setIcon( QIcon(load_pixmap('data_logger/start-icon.png'))) self.example_timestamp = time.time() self.edit_csv_file_name.setText( os.path.join( get_home_path(), 'logger_data_{0}.csv'.format(int(self.example_timestamp)))) self.edit_log_file_name.setText( os.path.join( get_home_path(), 'logger_debug_{0}.log'.format(int(self.example_timestamp)))) self.combo_data_time_format.addItem( utils.timestamp_to_de(self.example_timestamp) + ' (DD.MM.YYYY HH:MM:SS)', 'de') self.combo_data_time_format.addItem( utils.timestamp_to_de_msec(self.example_timestamp) + ' (DD.MM.YYYY HH:MM:SS,000)', 'de-msec') self.combo_data_time_format.insertSeparator( self.combo_data_time_format.count()) self.combo_data_time_format.addItem( utils.timestamp_to_us(self.example_timestamp) + ' (MM/DD/YYYY HH:MM:SS)', 'us') self.combo_data_time_format.addItem( utils.timestamp_to_us_msec(self.example_timestamp) + ' (MM/DD/YYYY HH:MM:SS.000)', 'us-msec') self.combo_data_time_format.insertSeparator( self.combo_data_time_format.count()) self.combo_data_time_format.addItem( utils.timestamp_to_iso(self.example_timestamp) + ' (ISO 8601)', 'iso') self.combo_data_time_format.addItem( utils.timestamp_to_iso_msec(self.example_timestamp) + ' (ISO 8601 + Milliseconds)', 'iso-msec') self.combo_data_time_format.insertSeparator( self.combo_data_time_format.count()) self.combo_data_time_format.addItem( utils.timestamp_to_unix(self.example_timestamp) + ' (Unix)', 'unix') self.combo_data_time_format.addItem( utils.timestamp_to_unix_msec(self.example_timestamp) + ' (Unix + Milliseconds)', 'unix-msec') self.combo_data_time_format.insertSeparator( self.combo_data_time_format.count()) t = utils.timestamp_to_strftime( self.example_timestamp, self.edit_data_time_format_strftime.text()) if len(t) == 0: t = '<empty>' self.combo_data_time_format.addItem((t + ' (strftime)'), 'strftime') self.combo_debug_time_format.addItem( utils.timestamp_to_de(self.example_timestamp) + ' (DD.MM.YYYY HH:MM:SS)', 'de') self.combo_debug_time_format.addItem( utils.timestamp_to_us(self.example_timestamp) + ' (MM/DD/YYYY HH:MM:SS)', 'us') self.combo_debug_time_format.addItem( utils.timestamp_to_iso(self.example_timestamp) + ' (ISO 8601)', 'iso') self.combo_debug_time_format.addItem( utils.timestamp_to_unix(self.example_timestamp) + ' (Unix)', 'unix') self.combo_log_level.addItem('Debug', 'debug') self.combo_log_level.addItem('Info', 'info') self.combo_log_level.addItem('Warning', 'warning') self.combo_log_level.addItem('Error', 'error') self.combo_log_level.addItem('Critical', 'critical') self.combo_log_level.setCurrentIndex(0) # debug self.combo_debug_level.addItem('Debug', logging.DEBUG) self.combo_debug_level.addItem('Info', logging.INFO) self.combo_debug_level.addItem('Warning', logging.WARNING) self.combo_debug_level.addItem('Error', logging.ERROR) self.combo_debug_level.addItem('Critical', logging.CRITICAL) self.combo_debug_level.setCurrentIndex(1) # info for host_info in host_infos: self.combo_host.addItem( host_info.host, (host_info.port, host_info.use_authentication, host_info.secret)) self._host_index_changed(0) self.update_ui_state()