diff --git a/gui/gui.py b/gui/gui.py index 118c308..612d7d2 100644 --- a/gui/gui.py +++ b/gui/gui.py @@ -117,6 +117,9 @@ def data_row(self, data, row): self.twinax.set_ylim(0, 10) self.canvas.draw() + def status_update(self, status): + self.statusBar().showMessage(status) + def set_backend(self, backend): self.backend = backend backend.subscribe(self) diff --git a/instr_thread.py b/instr_thread.py index 1e80cb5..8d06c58 100644 --- a/instr_thread.py +++ b/instr_thread.py @@ -10,6 +10,7 @@ class InstrumentSignals(QObject): start = pyqtSignal() stop = pyqtSignal() data_row = pyqtSignal(dict) + status_update = pyqtSignal(str) command = pyqtSignal(dict) @@ -31,8 +32,10 @@ def run(self): instruments = Instruments() self.instr = instruments.instr() if not self.instr: + self.signals.status_update.emit("No devices found") return + self.signals.status_update.emit("Connected to {} on {}".format(self.instr.name, self.instr.port)) while self.loop: if len(self.commands) > 0: self.handle_command(self.commands.pop(0)) diff --git a/instruments/px100.py b/instruments/px100.py index c0c8e6c..6f53de9 100644 --- a/instruments/px100.py +++ b/instruments/px100.py @@ -115,6 +115,7 @@ def probe(self): if not isinstance(self.device, visa.resources.SerialInstrument): return False + self.port = self.device.resource_name.split('::')[0].replace('ASRL', '') self.__setup_device() self.__clear_device() diff --git a/main.py b/main.py index 5943eae..a250fc5 100644 --- a/main.py +++ b/main.py @@ -23,6 +23,7 @@ def __init__(self): def instr_thread(self): self.instr_worker = InstrumentWorker() self.instr_worker.signals.data_row.connect(self.data_callback) + self.instr_worker.signals.status_update.connect(self.status_callback) self.threadpool.start(self.instr_worker) self.instr_worker.signals.start.emit() @@ -34,6 +35,11 @@ def data_callback(self, data): for r in self.data_receivers: r.data_row(self.datastore, data) + def status_callback(self, status): + for r in self.data_receivers: + if hasattr(r, 'status_update'): + r.status_update(status) + def send_command(self, command): self.instr_worker.signals.command.emit(command)