def __init__(self, qpd, stage, lock_fn, min_sum, z_center, slow_stage = False, parent = None): QtCore.QThread.__init__(self, parent) self.qpd = qpd self.stage = stage self.lock_fn = lock_fn self.sum_min = min_sum self.count = 0 self.debug = 1 self.find_sum = False self.locked = 0 self.max_pos = 0 self.max_sum = 0 self.offset = 0 self.qpd_mutex = QtCore.QMutex() self.running = 1 self.slow_stage = slow_stage self.stage_mutex = QtCore.QMutex() self.stage_z = z_center - 1.0 self.sum = 0 self.target = None self.unacknowledged = 1 self.z_center = z_center self.requested_sum = 0
def __init__(self, parent=None): QtCore.QThread.__init__(self, parent) self.buffer = [] self.buffer_mutex = QtCore.QMutex() self.aotf_mutex = QtCore.QMutex() self.running = 1 self.aotf = False
def __init__(self, parameters, parent): QtCore.QThread.__init__(self, parent) AmplitudeModulation.__init__(self, parameters, parent) self.command_buffer = [] self.buffer_mutex = QtCore.QMutex() self.device_mutex = QtCore.QMutex() self.is_buffered = True self.running = True
def __init__(self, sdevice, parent=None): QtCore.QThread.__init__(self, parent) self.buffer = [] self.buffer_mutex = QtCore.QMutex() self.sdevice_mutex = QtCore.QMutex() self.running = 1 self.sdevice = sdevice if not (self.sdevice.getStatus()): self.sdevice.shutDown() self.sdevice = False
def __init__(self, parent=None): QtCore.QThread.__init__(self, parent) self.buffer = [] self.buffer_mutex = QtCore.QMutex() self.aotf_mutex = QtCore.QMutex() self.running = 1 # connect to the AOTF global have_aotf if have_aotf: self.aotf = AOTF.AOTF() if not (self.aotf.getStatus()): self.aotf = 0 else: self.aotf = 0
def __init__(self, parent=None): QtCore.QThread.__init__(self, parent) self.buffer = [] self.buffer_mutex = QtCore.QMutex() self.cube_mutex = QtCore.QMutex() self.running = 1 global have_cube if have_cube: self.cube = cube405.Cube405() if not (self.cube.getStatus()): self.cube.shutDown() self.cube = 0 else: self.cube = 0
def __init__(self, _viewManager=None, _plotSupportFlag=False): QtCore.QObject.__init__(self, None) self.vm = _viewManager self.plotsSupported = _plotSupportFlag self.plotWindowList = [] self.plotWindowMutex = QtCore.QMutex() self.signalsInitialized = False
def __init__(self, MainWindow): self.setupUi(MainWindow) self.MainWindow = MainWindow self.show_plc_addrs = [] self.show_plc_vals = [] self.write_plc_addrs = [] self.write_plc_vals = [] self.create_ui_container() self.show_plc_ip.activated[str].connect(self.on_show_plc_change) self.write_plc_ip.activated[str].connect(self.on_write_plc_change) self.update_show_plc_addr.clicked.connect(self.on_update_show_plc_addr) self.submit_write_vals.clicked.connect(self.on_submit_write_vals) self.action_conn_PLC.setStatusTip('链接到PLC,只会链接到没有链接的PLC') self.action_conn_PLC.triggered.connect(self.on_conn_plc) self.action_close_PLC.setStatusTip('断开和所有PLC的链接') self.action_close_PLC.triggered.connect(self.on_close_plc) self.action_Exit.setStatusTip('退出应用') self.action_Exit.triggered.connect(self.on_exit) self.action_Help.setStatusTip('打开帮助') self.action_Help.triggered.connect(self.on_help) self.action_About.setStatusTip('关于') self.action_About.triggered.connect(self.on_about) self.icon = QtGui.QIcon() self.icon.addPixmap(QtGui.QPixmap('image/singleM.ico'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.mutex = QtCore.QMutex() self.checkConfig() self.checkDonThread = CheckDonThread(self) self.MainWindow.connect(self.checkDonThread, QtCore.SIGNAL('check_don_result'), self.check_don_result) self.checkDonThread.start() self.run_socket_service() if self.autoConn: self.on_conn_plc()
def __init__(self,parent=None): QtCore.QThread.__init__(self,parent) self.msg = '' self.mt_stop = False self.mt_pause = False self.mutex = QtCore.QMutex() self.mt_pauseCondition = QtCore.QWaitCondition()
def __init__(self, dag, parent): QtCore.QThread.__init__(self, parent) self.dag = dag self._abort = False self._stop = False self._mutex = QtCore.QMutex() self._condition = QtCore.QWaitCondition()
def __init__(self, hardware, parameters, parent = None): QtCore.QThread.__init__(self, parent) # Other class initializations self.acquire = IdleActive() self.frame_number = 0 self.key = -1 self.mutex = QtCore.QMutex() self.parameters = parameters self.running = True self.shutter = False # Camera initialization self.camera = False self.got_camera = False self.reversed_shutter = False self.parameters.add("camera1.save", params.ParameterSetBoolean("", "save", True, is_mutable = False, is_saved = False)) self.parameters.add("camera1.x_pixels", params.ParameterInt("", "x_pixels", 1, is_mutable = False, is_saved = True)) self.parameters.add("camera1.y_pixels", params.ParameterInt("", "y_pixels", 1, is_mutable = False, is_saved = True))
def __init__(self, hardware, parameters, parent = None): lock_fn = lambda(x): 0.05*x # The numpy fitting routine is apparently not thread safe. fit_mutex = QtCore.QMutex() # Lower objective camera and piezo. cam1 = uc480Cam.CameraQPD300(camera_id = 2, fit_mutex = fit_mutex) stage1 = mclController.MCLStage("c:/Program Files/Mad City Labs/NanoDrive/", serial_number = 2636) control_thread1 = stageOffsetControl.StageCamThread(cam1, stage1, lock_fn, 50.0, parameters.get("qpd_zcenter")) # Upper objective camera and piezo. cam2 = uc480Cam.CameraQPD300(camera_id = 3, fit_mutex = fit_mutex) stage2 = mclController.MCLStage("c:/Program Files/Mad City Labs/NanoDrive/", serial_number = 2637) control_thread2 = stageOffsetControl.StageCamThread(cam2, stage2, lock_fn, 50.0, parameters.get("qpd_zcenter")) ir_laser = LDC210.LDC210PWMLJ() focusLockZ.FocusLockZDualCam.__init__(self, parameters, [control_thread1, control_thread2], [ir_laser, False], parent)
def __init__(self, timeout=None): """ constructor :param timeout: timeout for setting connection in ms :type timeout: :obj:`int` """ BaseSource.__init__(self, timeout) #: (:obj:`str`) hidra port number self.__portnumber = "50001" #: (:obj:`str`) hidra client server self.__targetname = socket.getfqdn() #: (:obj:`str`) server host self.__shost = None #: (:obj:`list` < :obj:`str`, :obj:`str`, #: :obj:`int` :obj:`list` < :obj:`str`> >) hidra target: #: [host name, portnumber, priority, a list of extensions] self.__target = [ self.__targetname, self.__portnumber, 19, [".cbf", ".tif", ".tiff"] ] #: (:class:`hidra.transfer.Transfer`) hidra query self.__query = None #: (:class:`PyQt4.QtCore.QMutex`) zmq bind address self.__mutex = QtCore.QMutex()
def __init__(self, widget, oneShotEnable=True): """ Instantiate a newly opened output """ QtCore.QObject.__init__(self) # our output queue self._queue = Queue.Queue(0) # for counting self._lock = QtCore.QMutex() self._count = 0 # the controlling widget self._widget = widget # our input queue self._inputQueue = None # whether we are primed self._recording = False if oneShotEnable: # automatically shut off streaming when counter hits zero self.connect(self, QtCore.SIGNAL('countDone()'), self.stopRecording) if self._widget: # allow the widget to know whether recording was stopped self.connect(self, QtCore.SIGNAL('recordingChanged(bool)'), self._widget.setRecording) # allow the widget to know whether the count was changed self.connect(self, QtCore.SIGNAL('countChanged(int)'), self._widget.setCount) # allow the widget to access the input self.connect(self._widget, QtCore.SIGNAL('recordingChanged(bool)'), self.setRecording) self.connect(self._widget, QtCore.SIGNAL('countChanged(int)'), self.setCount)
def __init__(self): super(Player, self).__init__() self.mutex = QtCore.QMutex() self.condition = QtCore.QWaitCondition() self.allow_play = False if not self.isRunning(): self.start(QtCore.QThread.LowPriority)
def __init__(self, directory, parent=None): super(ImportThread, self).__init__(parent) self.directory = directory self.mutex = QtCore.QMutex() self.condition = QtCore.QWaitCondition() self.filenames = QtCore.QStringList() self.abort = False
def run(self): print('Main program run...') self.o_printLock = QtCore.QMutex() self.t_controllers = [] t_waitingTime = [ 6.,5.,7.] for i in range(3): o_controller = QArkWorkerThreadController(_cls_worker=MyWorker , _t_workerParameters={'wid':i,'wait':t_waitingTime[i],'print_lock':self.o_printLock} , _o_exceptionHandler=self.getExceptionHandler() , _b_selfIO=False ) o_controller.workerError.connect(self.handleErrorHandledSlot) o_controller.workerFinished.connect(self.handleWorkerHasFinished) o_controller.writeStdOutRequest.connect(self.handleMessageSentSlot) self.t_controllers.append(o_controller) #o_timerInterruptCtrl2 = QtCore.QTimer() #o_timerInterruptCtrl2.start(int(0.2 * t_waitingTime[2] * 1000)) #o_timerInterruptCtrl2.timeout.connect(self.simuUserInterrupt) for o_ctrl in self.t_controllers: print_lock('start {}'.format(o_ctrl), self.o_printLock) o_ctrl.startThread()
def __init__(self, n, model, pt, aa, algo, use_heur=False, worst=None, best=None, parent=None): super(qt_thread_algo, self).__init__(parent) self.mutex = QtCore.QMutex() self.stopped = False self.results = [] self.fitness = [] self.model = model.copy() self.n = n self.ncrit = len(model.criteria) self.ncat = len(model.categories) self.pt = pt self.aa = aa self.worst = worst self.best = best self.algo = algo self.use_heur = use_heur
def __init__(self, app, parent=None): apport.ui.UserInterface.__init__(self) QtGui.QWidget.__init__(self, parent) self.ui = Ui_bugtoolUI() self.ui.setupUi(self) self.active_widgets = [] self.screenData = None self.moveInc = 1 self.app = app self.app.setQuitOnLastWindowClosed(True) self.running = True self.is_active = False self.waitNextClick = QtCore.QWaitCondition() self.mutex = QtCore.QMutex() QtCore.QObject.connect(self.ui.buttonNext, QtCore.SIGNAL("clicked()"), self.slotNext) QtCore.QObject.connect(self.ui.buttonCancel, QtCore.SIGNAL("clicked()"), self.closeEvent) # Forcing show() on __init__() since run_argv() may block the UI self.show() rect = QtGui.QDesktopWidget().screenGeometry() self.move(rect.width()/2 - self.width()/2, rect.height()/2 -\ self.height()/2) #self.app.exec_() self.run_argv()
def __init__(self, video_engine, parent=None): # Set up to sync with double-buffer, vertical refresh. Add Alpha and Depth buffers. fmt = QtOpenGL.QGLFormat() fmt.setSwapInterval(2) fmt.setDoubleBuffer(True) fmt.setAlpha(True) fmt.setDepth(True) QtOpenGL.QGLWidget.__init__(self, fmt, parent) # set application settings self.settings = LuxSettings() # create a mutex for the state self.lock = QtCore.QMutex() # height and width of viewport self.width = 512 self.height = 512 # set dirty state self.dirty = True # start up an update timer self.timerId = self.startTimer(30) # whether GL is initialized self.initialized = False # Start the simulator audio client. Connects to JACK server, # which must be running. self.makeCurrent() self.video_engine = video_engine
def __init__(self, user_id, password, start_date, end_date=None, query_dict=None, category_tree=None, parent=None): super(PiggyBanker, self).__init__(parent) self.mutex = QtCore.QMutex() self.condition = QtCore.QWaitCondition() self.user_id = user_id self.password = password self.sleeper = 10 self.start_date = start_date if query_dict is None: #get all data for a writer between dates if only dates are given. self.query_dict = {"WriterID": self.user_id} else: #If some query dictionary is supplied, get all data corresponding to that. self.query_dict = query_dict if end_date is None: self.end_date = self.start_date else: self.end_date = end_date if category_tree is None: self.category_tree = MOSES.getCategoryTree(self.user_id, self.password) else: self.category_tree = category_tree if not self.isRunning(): self.start(QtCore.QThread.LowPriority)
def __init__(self, parent=None): """ constructor :param parent: parent object :type parent: :class:`PyQt4.QtCore.QObject` """ BaseSourceWidget.__init__(self, parent) self._ui = _zmqformclass() self._ui.setupUi(self) #: (:obj:`str`) source name self.name = "ZMQ Stream" #: (:obj:`str`) datasource class name self.datasource = "ZMQSource" #: (:obj:`list` <:obj:`str`>) subwidget object names self.widgetnames = [ "pickleLabel", "pickleLineEdit", "pickleTopicLabel", "pickleTopicComboBox" ] #: (:obj:`list` <:obj:`str`> >) zmq source datasources self.__zmqtopics = [] #: (:obj:`bool`) automatic zmq topics enabled self.__autozmqtopics = False #: (:class:`PyQt4.QtCore.QMutex`) zmq datasource mutex self.__mutex = QtCore.QMutex() self._detachWidgets() self._ui.pickleLineEdit.textEdited.connect(self.updateButton) self._ui.pickleTopicComboBox.currentIndexChanged.connect( self._updateZMQComboBox)
def __init__(self, com_port, baudrate=115200, timeout=0.001, parent=None, verbose=False): QtCore.QThread.__init__(self, parent) # Create serial port self.com = serial.Serial(port=com_port, baudrate=baudrate, timeout=timeout) self.verbose = verbose # For debugging purposes self.running = True # Flag for running the loop # Create a com port mutex self.com_mutex = QtCore.QMutex() # Maximum number of reads to check for a com response self.max_num_reads = 10 self.pause_time = 0.1 # time in seconds to wait between com checks for response if self.verbose: print "Created W1 Serial Thread"
def __init__(self): super(Worker, self).__init__() self._abort = False self._interrupt = False self._method = "none" self.mutex = QtCore.QMutex() self.condition = QtCore.QWaitCondition()
class FileWatcher(QtCore.QThread): mutex = QtCore.QMutex() def __init__(self,parent=None,target=""): super(FileWatcher,self).__init__(parent) self.stopped = False self.last_ts = 0.0 self.targetfile = target def run(self): setup = Setup.Setup() with Logger.Logger(setup.SLOWMONITOR_LOG) as logger: logger.logger.info("file watch thread is running...") while not self.stopped: timestamp = os.stat(self.targetfile).st_mtime if timestamp == self.last_ts: pass elif timestamp > self.last_ts: self.last_ts = timestamp self.finished.emit() else: with Logger.Logger(setup.SLOWMONITOR_LOG) as logger: logger.logger.error("FileWatcher: timestamp shows the past to the last one.") time.sleep(setup.ALARM_TIME_FILEWATCH) with Logger.Logger(setup.SLOWMONITOR_LOG) as logger: logger.logger.warning("sound thread is stopped.") def stop(self): with QtCore.QMutexLocker(self.mutex): self.stopped = True def setup(self): with QtCore.QMutexLocker(self.mutex): self.stopped = False
def __init__(self, lock, parent = None): super(MoxaSetupThread, self).__init__(parent) self.lock = lock self.mutex = QtCore.QMutex() self.stopped = False self.completed = False self.assign = False
def __init__(self, dialog, parent=None): super(ClientThread, self).__init__(parent) self.dialog = dialog self.getParametersFromDialog() self.mutex = QtCore.QMutex() self.reset = False self.abort = False
def init(): global DC sys.path.append(os.path.join(config.daemonDir, 'util')) import daemon_control as DC global DAEMON_SOCK, DAEMON_MUTEX, ERR_MSG DAEMON_SOCK = DC.get_daemon_control_sock(retry=True, max_retries=200) DAEMON_MUTEX = QtCore.QMutex() ERR_MSG = { DC.ControlResErr.NO_DNODE: 'NO_DNODE: No datanode connected', DC.ControlResErr.DAEMON: 'DAEMON: Internal daemon error', DC.ControlResErr.DAEMON_IO: 'DAEMON_IO: Daemon I/O error', DC.ControlResErr.C_VALUE: 'C_VALUE: Invalid arguments on client control socket', DC.ControlResErr.C_PROTO: 'C_PROTO: Protocol error on client control socket', DC.ControlResErr.D_PROTO: 'D_Proto: Protocol error on datanode control socket', DC.ControlResErr.DNODE: 'DNODE: Datanode transaction failed', DC.ControlResErr.DNODE_ASYNC: 'DNODE_ASYNC: Asynchronous datanode error', DC.ControlResErr.DNODE_DIED: 'DNODE_DIED: Datanode connection died while processing request' } global INITIALIZED INITIALIZED = True
def __init__(self, job_changer): self.__work = {} self.__i = 0 self.__jobChanger = job_changer self.__mutex = QtCore.QMutex() self.__thread = None self.__finish_func = None
def __init__(self, bucketName, key, parent=None): self.emitter = QtCore.QObject() QtCore.QRunnable.__init__(self) self.bucketName = bucketName self.key = key self.filePath = None self.mutex = QtCore.QMutex()