Skip to content

Commit 7c669e7

Browse files
committed
autotune: remember log once selected
1 parent be4fb4a commit 7c669e7

2 files changed

Lines changed: 34 additions & 21 deletions

File tree

autotune/autotune.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -688,23 +688,19 @@ def plotInputOutput(self, redraw=False):
688688
self.canvas.draw()
689689

690690
def loadLog(self):
691-
options = QFileDialog.Options()
692-
options |= QFileDialog.DontUseNativeDialog
693-
self.file_name, _ = QFileDialog.getOpenFileName(self,"QFileDialog.getOpenFileName()", "","ULog (*.ulg)", options=options)
694-
695-
if self.file_name:
696-
select = DataSelectionWindow(self.file_name)
697-
698-
if select.exec_():
699-
self.reset()
700-
self.t = select.t - select.t[0]
701-
self.input = select.u
702-
self.u = self.input
703-
self.y = select.y
704-
self.true_airspeed = select.v
705-
self.refreshInputOutputData()
706-
self.runIdentification()
707-
self.computeController()
691+
select = DataSelectionWindow(self.file_name)
692+
693+
if select.exec_():
694+
self.reset()
695+
self.file_name = select.file_name
696+
self.t = select.t - select.t[0]
697+
self.input = select.u
698+
self.u = self.input
699+
self.y = select.y
700+
self.true_airspeed = select.v
701+
self.refreshInputOutputData()
702+
self.runIdentification()
703+
self.computeController()
708704

709705
def refreshInputOutputData(self):
710706
self.reset()

autotune/data_selection_window.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QFormLayout, QRadioButton, QMessageBox
1+
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QFormLayout, QRadioButton, QMessageBox, QFileDialog
22

33
import matplotlib.pyplot as plt
44
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
@@ -12,13 +12,17 @@ class DataSelectionWindow(QDialog):
1212
def __init__(self, filename):
1313
QDialog.__init__(self)
1414

15-
self.file_name = filename
16-
1715
self.figure = plt.figure(1)
1816
self.canvas = FigureCanvas(self.figure)
1917

2018
layout_v = QVBoxLayout()
2119

20+
top_group = QHBoxLayout()
21+
btn_browse = QPushButton("Browse files")
22+
btn_browse.clicked.connect(self.browseFiles)
23+
top_group.addWidget(btn_browse)
24+
25+
layout_v.addLayout(top_group)
2226
layout_v.addWidget(self.canvas)
2327

2428
xyz_group = QHBoxLayout()
@@ -42,7 +46,12 @@ def __init__(self, filename):
4246

4347
self.setLayout(layout_v)
4448

45-
self.refreshInputOutputData()
49+
if filename:
50+
self.file_name = filename
51+
self.refreshInputOutputData()
52+
53+
else:
54+
self.browseFiles()
4655

4756
def loadLog(self):
4857
if self.t_stop > self.t_start:
@@ -51,6 +60,14 @@ def loadLog(self):
5160
else:
5261
self.printRangeError()
5362

63+
def browseFiles(self):
64+
options = QFileDialog.Options()
65+
options |= QFileDialog.DontUseNativeDialog
66+
self.file_name, _ = QFileDialog.getOpenFileName(self,"QFileDialog.getOpenFileName()", "","ULog (*.ulg)", options=options)
67+
68+
if self.file_name:
69+
self.refreshInputOutputData()
70+
5471
def printRangeError(self):
5572
msg = QMessageBox()
5673
msg.setIcon(QMessageBox.Critical)

0 commit comments

Comments
 (0)