Skip to content

Commit

Permalink
Show device info in status bar of the main window
Browse files Browse the repository at this point in the history
  • Loading branch information
misdoro committed Jan 26, 2021
1 parent d7522de commit 2cf3fbe
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions instr_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class InstrumentSignals(QObject):
start = pyqtSignal()
stop = pyqtSignal()
data_row = pyqtSignal(dict)
status_update = pyqtSignal(str)
command = pyqtSignal(dict)


Expand All @@ -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))
Expand Down
1 change: 1 addition & 0 deletions instruments/px100.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
6 changes: 6 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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)

Expand Down

0 comments on commit 2cf3fbe

Please sign in to comment.