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)