aboutsummaryrefslogtreecommitdiff
path: root/acquisition/parent_hardware.py
diff options
context:
space:
mode:
authorBlaise Thompson <blaise@untzag.com>2018-03-27 16:06:30 -0500
committerBlaise Thompson <blaise@untzag.com>2018-03-27 16:06:30 -0500
commit093ce016b23812d0aaf58c2b05c9d4189791e2a6 (patch)
tree125fb4613ebdb38d63d5f87a6d62eb8063118495 /acquisition/parent_hardware.py
parent8c9fc50d417809d7c5ad1b512f55c83307a83364 (diff)
2018-03-27 16:06
Diffstat (limited to 'acquisition/parent_hardware.py')
-rw-r--r--acquisition/parent_hardware.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/acquisition/parent_hardware.py b/acquisition/parent_hardware.py
new file mode 100644
index 0000000..8ced565
--- /dev/null
+++ b/acquisition/parent_hardware.py
@@ -0,0 +1,40 @@
+class Hardware(QtCore.QObject):
+ update_ui = QtCore.pyqtSignal()
+ initialized_signal = QtCore.pyqtSignal()
+
+ def __init__(self, driver_class, driver_arguments, gui_class,
+ name, model, serial=None):
+ """
+ Hardware representation object living in the main thread.
+
+ Parameters
+ driver_class : Driver class
+ driver_arguments : dictionary
+ name : string
+ model : string
+ serial : string or None (optional)
+ """
+ QtCore.QObject.__init__(self)
+ self.name = name
+ self.model = model
+ self.serial = serial
+ # create objects
+ self.thread = QtCore.QThread()
+ self.enqueued = Enqueued()
+ self.busy = Busy()
+ self.driver = driver_class(self, **driver_arguments)
+ self.initialized = self.driver.initialized
+ self.gui = gui_class(self)
+ self.q = Q(self.enqueued, self.busy, self.driver)
+ # start thread
+ self.driver.moveToThread(self.thread)
+ self.thread.start()
+ # connect to address object signals
+ self.driver.update_ui.connect(self.update)
+ self.busy.update_signal = self.driver.update_ui
+ # initialize drivers
+ self.q.push('initialize')
+ # integrate close into PyCMDS shutdown
+ self.shutdown_timeout = 30 # seconds
+ g.shutdown.add_method(self.close)
+ g.hardware_waits.add(self.wait_until_still)