Skip to content
Snippets Groups Projects
Commit ebc2ceef authored by Daniel Meißner's avatar Daniel Meißner Committed by Daniel Meißner
Browse files

gui: added logic to extract hardware device selection

parent aa05233e
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ import sys
import os
import logging
import datetime
import re
from PyQt5 import QtCore, QtGui, QtWidgets, uic
......@@ -35,11 +36,8 @@ class SuGui(QtWidgets.QMainWindow):
"""
Start button action in main window.
"""
if len(self.lineEdit_dump_file.text()) == 0:
QtWidgets.QMessageBox.about(self, "Dumpfile path missing…", \
"Please insert dump file path. ")
else:
pass
if self._check_dependencies_before_start_capture():
print self._extract_selected_hardware_device()
def stop_button(self):
"""
......@@ -60,8 +58,8 @@ class SuGui(QtWidgets.QMainWindow):
"""
self.comboBox_hardware.clear()
for device in Hardware().get_connected_supported_devices():
text = device['id'] + ": " + device['name']
self.comboBox_hardware.insertItem(0, self.tr(text))
text = device['name'] + " (" + device['id'] + ")"
self.comboBox_hardware.addItem(self.tr(text))
def _get_default_dump_file_path(self):
"""
......@@ -75,3 +73,46 @@ class SuGui(QtWidgets.QMainWindow):
path = os.path.expanduser("~") + "/su/dump_file-" + dt + ".iq"
return path
def _extract_selected_hardware_device(self):
"""
Extract device key from combo box.
"""
device_id = re.search(r"\w{4}:\w{4}", self.comboBox_hardware. \
currentText()).group()
device_key = ''
for key, value in Hardware().SUPPORTED_HARDWARE.items():
if value == device_id:
device_key = key
return device_key
def _check_dependencies_before_start_capture(self):
"""
Private method to check needed dependencies before starting capturing
data. The following states needs to be passed:
1. A dump file path need to be befined
2. Supported RF hardware need to be connected
3. RF hardware need to be selected
It returns True or False.
"""
if len(self.lineEdit_dump_file.text()) == 0:
QtWidgets.QMessageBox.about(self, "Dumpfile path missing…", \
"Please add dump file path.")
return False
elif len(Hardware().get_connected_supported_devices()) == 0:
QtWidgets.QMessageBox.about(self, "No supported RF hardware "\
"connected…", \
"Please connect RF hardware.")
self.refresh_hw_button()
return False
elif len(self.comboBox_hardware.currentText()) == 0:
QtWidgets.QMessageBox.about(self, "No supported RF hardware "\
"selected…", \
"Select RF hardware.")
self.refresh_hw_button()
return False
else:
return True
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment