mirror of
https://github.com/nqrduck/nqrduck-autotm.git
synced 2024-12-30 11:28:07 +00:00
Added selection of com ports.
This commit is contained in:
parent
14d14488c7
commit
d820efb16c
6 changed files with 53 additions and 3 deletions
|
@ -24,6 +24,7 @@ dependencies = [
|
|||
"matplotlib",
|
||||
"pyqt6",
|
||||
"NQRduck",
|
||||
"pyserial",
|
||||
]
|
||||
|
||||
[project.entry-points."nqrduck"]
|
||||
|
|
|
@ -1,4 +1,17 @@
|
|||
import logging
|
||||
from serial.tools.list_ports import comports
|
||||
from nqrduck.module.module_controller import ModuleController
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class AutoTMController(ModuleController):
|
||||
pass
|
||||
|
||||
|
||||
def find_devices(self):
|
||||
"""Scan for available serial devices and add them to the model as available devices. """
|
||||
logger.debug("Scanning for available serial devices")
|
||||
ports = comports()
|
||||
self.module.model.available_devices = [port.device for port in ports]
|
||||
logger.debug("Found %s devices", len(self.module.model.available_devices))
|
||||
for device in self.module.model.available_devices:
|
||||
logger.debug("Found device: %s", device)
|
||||
|
|
|
@ -1,4 +1,14 @@
|
|||
from PyQt6.QtCore import pyqtSignal
|
||||
from nqrduck.module.module_model import ModuleModel
|
||||
|
||||
class AutoTMModel(ModuleModel):
|
||||
pass
|
||||
available_devices_changed = pyqtSignal(list)
|
||||
|
||||
@property
|
||||
def available_devices(self):
|
||||
return self._available_devices
|
||||
|
||||
@available_devices.setter
|
||||
def available_devices(self, value):
|
||||
self._available_devices = value
|
||||
self.available_devices_changed.emit(value)
|
||||
|
|
|
@ -54,6 +54,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="refreshButton">
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import logging
|
||||
from PyQt6.QtWidgets import QWidget
|
||||
from PyQt6.QtCore import pyqtSlot
|
||||
from nqrduck.module.module_view import ModuleView
|
||||
from .widget import Ui_Form
|
||||
|
||||
|
@ -13,4 +14,18 @@ class AutoTMView(ModuleView):
|
|||
widget = QWidget()
|
||||
self._ui_form = Ui_Form()
|
||||
self._ui_form.setupUi(self)
|
||||
self.widget = widget
|
||||
self.widget = widget
|
||||
|
||||
# On clicking of the refresh button scan for available usb devices
|
||||
self._ui_form.refreshButton.clicked.connect(self.module.controller.find_devices)
|
||||
|
||||
# Connect the available devices changed signal to the on_available_devices_changed slot
|
||||
self.module.model.available_devices_changed.connect(self.on_available_devices_changed)
|
||||
|
||||
@pyqtSlot(list)
|
||||
def on_available_devices_changed(self, available_devices):
|
||||
"""Update the available devices list in the view. """
|
||||
logger.debug("Updating available devices list")
|
||||
self._ui_form.portBox.clear()
|
||||
self._ui_form.portBox.addItems(available_devices)
|
||||
logger.debug("Updated available devices list")
|
|
@ -40,6 +40,9 @@ class Ui_Form(object):
|
|||
self.pushButton = QtWidgets.QPushButton(parent=Form)
|
||||
self.pushButton.setObjectName("pushButton")
|
||||
self.gridLayout_2.addWidget(self.pushButton, 1, 1, 1, 1)
|
||||
self.refreshButton = QtWidgets.QPushButton(parent=Form)
|
||||
self.refreshButton.setObjectName("refreshButton")
|
||||
self.gridLayout_2.addWidget(self.refreshButton, 1, 0, 1, 1)
|
||||
self.verticalLayout_2.addLayout(self.gridLayout_2)
|
||||
self.label_3 = QtWidgets.QLabel(parent=Form)
|
||||
font = QtGui.QFont()
|
||||
|
@ -123,6 +126,7 @@ class Ui_Form(object):
|
|||
self.label_2.setText(_translate("Form", "Connection Settings:"))
|
||||
self.label.setText(_translate("Form", "Port:"))
|
||||
self.pushButton.setText(_translate("Form", "Connect"))
|
||||
self.refreshButton.setText(_translate("Form", "Refresh"))
|
||||
self.label_3.setText(_translate("Form", "T&M Type:"))
|
||||
self.label_4.setText(_translate("Form", "Frequency Sweep:"))
|
||||
self.label_8.setText(_translate("Form", "MHz"))
|
||||
|
|
Loading…
Reference in a new issue