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
21 changes: 20 additions & 1 deletion plottr/apps/autoplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ def setDefaults(self, data: DataDictBase) -> None:


def autoplotQcodesDataset(log: bool = False,
pathAndId: Union[Tuple[str, int], None] = None) \
pathAndId: Union[Tuple[str, int], None] = None,
monitorInterval: float = 0.0) \
-> Tuple[Flowchart, QCAutoPlotMainWindow]:
"""
Sets up a simple flowchart consisting of a data selector,
Expand Down Expand Up @@ -332,10 +333,28 @@ def autoplotQcodesDataset(log: bool = False,
monitor=True,
loaderName='Data loader')
win.show()
win.setMonitorInterval(monitorInterval)

return fc, win


def autoplotQcodesDatasetApp(*args: Any) -> Tuple[Flowchart, AutoPlotMainWindow]:
"""
Function used by the apprunner script to convert the arguments
in a console to python objects and run autoplotQcodesDataset.

returns the flowchart and the window created by the autolpot creation function.
"""
log = bool(args[0][0])
path = args[0][1]
_id = int(args[0][2])
refresh = 0.0
if len(args[0]) == 4:
refresh = float(args[0][3])

return autoplotQcodesDataset(log, (path, _id), refresh)


def autoplotDDH5(filepath: str = '',
groupname: str = 'data',
plotWidgetClass: Optional[Type[PlotWidget]] = None) \
Expand Down
32 changes: 16 additions & 16 deletions plottr/apps/inspectr.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,18 @@
from plottr.gui.widgets import MonitorIntervalInput, FormLayoutWrapper, dictToTreeWidgetItems

from .autoplot import autoplotQcodesDataset, QCAutoPlotMainWindow
from .appmanager import AppManager


__author__ = 'Wolfgang Pfaff'
__license__ = 'MIT'

# Change this variable to change the module of the app that monitr should open.
AUTOPLOTMODULE = 'plottr.apps.autoplot'

# Function that the app manager should run to open a new app.
AUTOPLOTFUNC = 'autoplotQcodesDatasetApp'

LOGGER = plottrlog.getLogger('plottr.apps.inspectr')


Expand Down Expand Up @@ -310,8 +317,6 @@ def __init__(self, parent: Optional[QtWidgets.QWidget] = None,
"""Constructor for :class:`QCodesDBInspector`."""
super().__init__(parent)

self._plotWindows: Dict[int, WindowDict] = {}

self.filepath = dbPath
self.dbdf: Optional[pandas.DataFrame] = None
self.monitor = QtCore.QTimer()
Expand All @@ -324,6 +329,9 @@ def __init__(self, parent: Optional[QtWidgets.QWidget] = None,

self.setWindowTitle('Plottr | QCoDeS dataset inspectr')

# App manager
self.appManager = AppManager()

### GUI elements

# Main Selection widgets
Expand Down Expand Up @@ -439,14 +447,13 @@ def closeEvent(self, event: QtGui.QCloseEvent) -> None:
"""
When closing the inspectr window, do some house keeping:
* stop the monitor, if running
* close all plot windows
* closes the app manager.
"""

if self.monitor.isActive():
self.monitor.stop()

for runId, info in self._plotWindows.items():
info['window'].close()
self.appManager.close()

@Slot()
def showDBPath(self) -> None:
Expand Down Expand Up @@ -505,10 +512,7 @@ def DBLoaded(self, dbdf: pandas.DataFrame) -> None:

if self.monitor.isActive() and self.autoLaunchPlots.elements['Auto-plot new'].isChecked():
for idx in newIdxs:
self.plotRun(idx)
self._plotWindows[idx]['window'].setMonitorInterval(
self.monitorInput.spin.value()
)
self.plotRun(idx, monitorInterval=self.monitorInput.spin.value())

@Slot()
def updateDates(self) -> None:
Expand Down Expand Up @@ -594,14 +598,10 @@ def setRunSelection(self, runId: int) -> None:
self._sendInfo.emit(contentInfo)

@Slot(int)
def plotRun(self, runId: int) -> None:
def plotRun(self, runId: int, monitorInterval: float = 0.0) -> None:
assert self.filepath is not None
fc, win = autoplotQcodesDataset(pathAndId=(self.filepath, runId))
self._plotWindows[runId] = {
'flowchart': fc,
'window': win,
}
win.showTime()
self.appManager.launchApp(runId, AUTOPLOTMODULE, AUTOPLOTFUNC, 'False', str(self.filepath), str(runId),
str(monitorInterval))

def setTag(self, item: QtWidgets.QTreeWidgetItem, tag: str) -> None:
# set tag in the database
Expand Down