Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## *Simple**FOC**Studio*

Graphical user interface for the [*Simple**FOC**library*](https://github.com/simplefoc). This application allows to tune and configure any BLDC/Stepper *Simple**FOC**library* controlled device, using serial port communications and the [Commander](https://docs.simplefoc.com/commander_interface) interface.
Graphical user interface for the [*Simple**FOC**library*](https://github.com/simplefoc). This application allows to tune and configure any BLDC/Stepper *Simple**FOC**library* controlled device, using serial port communications or wireless connections with the the [Commander](https://docs.simplefoc.com/commander_interface) interface.
#### The main features are:

- Plug and play with the *Simple**FOC**library* version 2.1
Expand Down
106 changes: 96 additions & 10 deletions src/gui/configtool/configureConnectionDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ def setupUi(self, device=None):
self.connectionIDlineEdit.setObjectName('connectionNameEdit')
self.gridLayout.addWidget(self.connectionIDlineEdit, 2, 3, 1, 1)

self.buttonBox = QtWidgets.QDialogButtonBox(self)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(
QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName('buttonBox')

self.gridLayout.addWidget(self.buttonBox, 3, 0, 1, 4)

self.setWindowTitle('Configure serial connection')
self.portNameLabel.setText('Port Name')
Expand All @@ -99,8 +92,6 @@ def setupUi(self, device=None):
self.stopBitsLabel.setText('Stop bits')
self.connectionIDLabel.setText('Conn ID')

self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)

QtCore.QMetaObject.connectSlotsByName(self)

Expand Down Expand Up @@ -130,4 +121,99 @@ def stopBitsExtractor(self, value):
if value == '1.5':
return float(self.stopBitsComboBox.currentText())
else:
return int(self.stopBitsComboBox.currentText())
return int(self.stopBitsComboBox.currentText())

class ConfigureWirelessConnectionDialog(QtWidgets.QDialog):
def __init__(self, parent=None):
super().__init__(parent)

self.setupUI(SimpleFOCDevice.getInstance())

def setupUI(self, device=None):
self.layout = QtWidgets.QFormLayout()

self.ip = QtWidgets.QLineEdit()
self.port = QtWidgets.QLineEdit()

self.layout.addRow("IP:", self.ip)
self.layout.addRow("tcp port:", self.port)
self.setLayout(self.layout)
self.setWindowTitle('Configure tcp connection')
if device is not None:
self.fillForm(device)

def fillForm(self, deviceConnector):
self.ip.setText(deviceConnector.ip)
self.port.setText(deviceConnector.port)

def getConfigValues(self):
values = {
'ip': self.ip.text(),
'port': self.port.text(),
}
return values

class ConfigureConnectionDialog(QtWidgets.QDialog):
def __init__(self):
super().__init__()
self.stackIndex = 0
self.setupUi(SimpleFOCDevice.getInstance())

def setupUi(self, device=None):

self.layout = QtWidgets.QVBoxLayout()
self.configType = "Serial"
self.comboBox = QtWidgets.QComboBox()
self.comboBox.addItem("Serial")
self.comboBox.addItem("Wireless")
self.layout.addWidget(QtWidgets.QLabel("Please select a configuration type"))
self.layout.addWidget(self.comboBox)

self.stackedWidget = QtWidgets.QStackedWidget()
self.serialConfigWidget = ConfigureSerailConnectionDialog()
self.wirelessConfigWidget = ConfigureWirelessConnectionDialog()

self.stackedWidget.addWidget(self.serialConfigWidget)
self.stackedWidget.addWidget(self.wirelessConfigWidget)

self.buttonBox = QtWidgets.QDialogButtonBox(self)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(
QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName('buttonBox')

self.layout.addWidget(self.stackedWidget)
self.layout.addWidget(self.buttonBox)
self.comboBox.currentIndexChanged.connect(self.displayConfigWidget)

self.buttonBox.accepted.connect(self.acceptCallback)
self.buttonBox.rejected.connect(self.reject)
self.stackedWidget.setCurrentIndex(self.stackIndex)

self.setLayout(self.layout)
self.setWindowTitle('Configure connection')

def displayConfigWidget(self, index):
self.stackedWidget.setCurrentIndex(index)

def getConfigValues(self):
currentIndex = self.stackedWidget.currentIndex()
if self.configType == "Serial": # Serial Config Selected
config = self.serialConfigWidget.getConfigValues()
else: # Wireless Config Selected
config = self.wirelessConfigWidget.getConfigValues()

return self.configType, config

def acceptCallback(self):
# Custom logic here
currentIndex = self.stackedWidget.currentIndex()
if currentIndex == 0: # Serial Config Selected
self.configType = "Serial"
else: # Wireless Config Selected
self.configType = "Wireless"

self.stackIndex = currentIndex
# After custom logic, call accept() to close the dialog
self.accept()

8 changes: 4 additions & 4 deletions src/gui/configtool/connectionControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from PyQt5 import QtWidgets

from src.gui.configtool.configureConnectionDialog import \
ConfigureSerailConnectionDialog
ConfigureConnectionDialog
from src.gui.sharedcomnponets.sharedcomponets import GUIToolKit
from src.simpleFOCConnector import SimpleFOCDevice

Expand Down Expand Up @@ -77,8 +77,8 @@ def connectionStateChanged(self, isConnected):
self.connectDisconnectButton.setText('Connect')

def configureDeviceAction(self):
dialog = ConfigureSerailConnectionDialog()
dialog = ConfigureConnectionDialog()
result = dialog.exec_()
if result:
deviceConfig = dialog.getConfigValues()
self.device.configureConnection(deviceConfig)
connType, deviceConfig = dialog.getConfigValues()
self.device.configureConnection(connType, deviceConfig)
Loading