def __init__(self, pinsx, pinsy, motor_delay, pumper_pin, pumper_speed): print(pinsx, pinsy) self.motor_delay = motor_delay self.motor_delay_mutex = QtCore.QMutex() self.pumper_speed = pumper_speed self.pumper_speed_mutex = QtCore.QMutex()
def __init__(self, ui): self.ui = ui self.main_path = os.getcwd() self.work_logs = { work_logger: [], } self.mutex = QtCore.QMutex() self.dir_mutex = QtCore.QMutex() self.log_mutex = QtCore.QMutex() self.logger = CLogger() self.logger.start() (dirp, filep) = os.path.split(common_db_path) if not os.path.exists(dirp): os.makedirs(dirp) (dirp, filep) = os.path.split(common_config_path) if not os.path.exists(dirp): os.makedirs(dirp) self.init_shelve_data() self.read_common_config() self.init_workspace() self.start_server_thread = CThreadStartServer(self) self.update_thread = CUpdateThreadLogic(self) #self.update_thread.msgboxSin.connect(self.ui.slot_show_message_box) # 常规工作进程-主要处理Update(time) self.work_thread = CWorkThread(self) self.work_thread.workStart.connect(self.WorkStart) self.work_thread.start()
def __init__(self, **kwds): super().__init__(**kwds) self.command_buffer = [] self.buffer_mutex = QtCore.QMutex() self.device_mutex = QtCore.QMutex() self.is_buffered = True self.running = True
def __init__(self, pinsx, pinsy, motor_delay, pumper_pin1, pumper_pin2, pumper_speed, cycle_time, motor_pin_enable): self.motor = StepperMotor(pinsx, pinsy, motor_pin_enable) self.motor_delay = motor_delay self.motor_delay_mutex = QtCore.QMutex() self.pumper = Pumper(pumper_pin1, pumper_pin2, cycle_time) self.pumper_speed = pumper_speed self.pumper_speed_mutex = QtCore.QMutex()
def __init__(self, parent, kanaele): super().__init__() self.parent = parent self.kanaele = kanaele self.pause = False self.running = True self.cond = QtCore.QMutex() self.stop = QtCore.QMutex() self.pauseCond = QtCore.QWaitCondition() self.stoppedCond = QtCore.QWaitCondition() self.parent.emit_message("Keine Verbindung ALC 7000")
def __init__(self, parent): super().__init__(parent) self.parent = parent self.pause = False self.running = True self.cond = QtCore.QMutex() self.stop = QtCore.QMutex() self.pauseCond = QtCore.QWaitCondition() self.stoppedCond = QtCore.QWaitCondition() self.commobject = None # i/o object (PIL-Box, TCP/IP...) self.framecounter = 0 # global frame counter self.addr_framecounter = 0 # frame counter of the last # HP-IL addressing command self.devices = [] # list of devices
def __init__(self, ard1: Arduino_functions.Arduino, ard2: Arduino_functions.Arduino, DAQ_update_interval_ms=250, DAQ_function_to_run_each_update=None, parent=None): super(Arduino_pyqt, self).__init__(parent=parent) class Dev(): name = "Ards" self.dev = Dev() self.ard1 = ard1 self.ard2 = ard2 self.ard1.mutex = QtCore.QMutex() self.ard2.mutex = QtCore.QMutex() self.DAQ_update_counter = 0 self.DAQ_ard1_not_alive_counter = 0 self.DAQ_ard2_not_alive_counter = 0 self.obtained_DAQ_update_interval_ms = np.nan self.obtained_DAQ_rate_Hz = np.nan self.worker_DAQ = self.Worker_DAQ( DAQ_update_interval_ms=DAQ_update_interval_ms, DAQ_function_to_run_each_update=DAQ_function_to_run_each_update, DAQ_critical_not_alive_count=3, DAQ_timer_type=QtCore.Qt.PreciseTimer, DEBUG=DEBUG_worker_DAQ) self.worker_send = self.Worker_send(DEBUG=DEBUG_worker_send) # Create and set up threads if (self.ard1.is_alive and self.ard2.is_alive): self.thread_DAQ = QtCore.QThread() self.thread_DAQ.setObjectName("%s_DAQ" % self.dev.name) self.worker_DAQ.moveToThread(self.thread_DAQ) self.thread_DAQ.started.connect(self.worker_DAQ.run) self.thread_send = QtCore.QThread() self.thread_send.setObjectName("%s_send" % self.dev.name) self.worker_send.moveToThread(self.thread_send) self.thread_send.started.connect(self.worker_send.run) else: self.thread_DAQ = None self.thread_send = None
def __init__(self, DAQ_update_interval_ms, DAQ_function_to_run_each_update=None, DAQ_critical_not_alive_count=1, DAQ_timer_type=QtCore.Qt.CoarseTimer, DAQ_trigger_by=DAQ_trigger.INTERNAL_TIMER, DEBUG=False): super().__init__(None) self.DEBUG = DEBUG self.DEBUG_color = ANSI.CYAN self.dev = self.outer.dev self.update_interval_ms = DAQ_update_interval_ms self.function_to_run_each_update = DAQ_function_to_run_each_update self.critical_not_alive_count = DAQ_critical_not_alive_count self.timer_type = DAQ_timer_type self.trigger_by = DAQ_trigger_by if self.trigger_by == DAQ_trigger.EXTERNAL_WAKE_UP_CALL: self.qwc = QtCore.QWaitCondition() self.mutex_wait = QtCore.QMutex() self.running = True self.calc_DAQ_rate_every_N_iter = max( round(1e3 / self.update_interval_ms), 1) self.prev_tick_DAQ_update = 0 self.prev_tick_DAQ_rate = 0 if self.DEBUG: dprint( "Worker_DAQ %s init: thread %s" % (self.dev.name, curThreadName()), self.DEBUG_color)
class HashRunner(qtc.QRunnable): file_lock = qtc.QMutex() def __init__(self, infile, outfile): super().__init__() self.infile = infile self.outfile = outfile self.hasher = qtc.QCryptographicHash(qtc.QCryptographicHash.Md5) self.setAutoDelete(True) def run(self): print(f'hashing {self.infile}') self.hasher.reset() with open(self.infile, 'rb') as fh: self.hasher.addData(fh.read()) hash_string = bytes(self.hasher.result().toHex()).decode('UTF-8') # Traditional method: #try: # self.file_lock.lock() # with open(self.outfile, 'a', encoding='utf-8') as out: # out.write(f'{self.infile}\t{hash_string}\n') #finally: # self.file_lock.unlock() # Better method: with qtc.QMutexLocker(self.file_lock): with open(self.outfile, 'a', encoding='utf-8') as out: out.write(f'{self.infile}\t{hash_string}\n')
def __init__(self, camera_id = None, parameters = None, **kwds): super().__init__(**kwds) self.cur_offsetx = None self.cur_offsety = None self.old_offsetx = None self.old_offsety = None self.max_offsetx = None self.max_offsety = None self.n_analyzed = 0 self.n_dropped = 0 self.start_time = None self.params_mutex = QtCore.QMutex() self.running = False self.zero_dist = parameters.get("zero_dist") # Initialize library. spinnaker.pySpinInitialize(verbose = False) # Get the camera & set some defaults. self.camera = spinnaker.getCamera(camera_id) # Only Grasshopper has defect correction if self.camera.hasProperty("VideoMode"): self.camera.setProperty("VideoMode", parameters.get("video_mode")) self.camera.setProperty("pgrDefectPixelCorrectionEnable", False)
def __init__(self, parent=None): """ Initializes tracking thread - a child of QThread to be used in conjunction with the ui_widget """ super(TrackingThread, self).__init__(parent) #Values required to run thread self.found_face = False self.mutex = QtCore.QMutex() self.condition = QtCore.QWaitCondition() self.restart = False self.abort = False self.loop_count = 0 #Centers of buttons used for snapping self.button_centers = [] #Connect signal to update buttons to setButtonCenters self.center = None self.pupil_avg = None pyautogui.FAILSAFE = False self.screen_x, self.screen_y = pyautogui.size() self.prev_pos = (0, 0) self.num_new_pos = 0 # Camera and screen parameters self.cam_x = 1920 self.cam_y = 1080
def __init__(self, ui): super(LiveAcquireThread, self).__init__() self.signals = WorkerSignals() self.ui = ui self.cimage = (ctypes.c_int * self.ui.andor.dim)() self.mutex = QtCore.QMutex()
class otherThreader(QtCore.QThread): # 创建信号,括号里填写信号传递的参数 signal = QtCore.pyqtSignal(str) pidsignal = QtCore.pyqtSignal(int) # 创建线程锁 qmut = QtCore.QMutex() def __init__(self, cmd): super().__init__() self.cmd = cmd def run(self): import subprocess self.qmut.lock() subP = subprocess.Popen(self.cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0, shell=True) self.pidsignal.emit(subP.pid) for i in iter(subP.stdout.readline, b''): line = i.strip().decode('GBK') self.signal.emit(str(line)) self.qmut.unlock() subP.kill()
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, capacity: Optional[int], linked_curve: pg.PlotDataItem, shift_right_x_to_zero: bool = False, use_ringbuffer=None, # Deprecated arg for backwards compatibility # pylint: disable=unused-argument ): self.capacity = capacity self.curve = linked_curve self.opts = self.curve.opts # Use for read-only self._shift_right_x_to_zero = shift_right_x_to_zero self._use_ringbuffer = capacity is not None self._mutex = QtCore.QMutex() # To allow proper multithreading self.x_axis_divisor = 1 self.y_axis_divisor = 1 if self._use_ringbuffer: self._buffer_x = RingBuffer(capacity=capacity) self._buffer_y = RingBuffer(capacity=capacity) else: self._buffer_x = np.array([]) self._buffer_y = np.array([]) self._snapshot_x = np.array([]) self._snapshot_y = np.array([])
def __init__(self, **kwds): super().__init__(**kwds) # FIXME: Does this mutex have a purpose? It appears that it is only # used in one place. # self.camera_mutex = QtCore.QMutex()
class atomic_int: mutex = QtCore.QMutex() val = 0 def __init__(self, init_val): assert isinstance(init_val, int) self.val = init_val def get(self): self.mutex.lock() ret = self.val self.mutex.unlock() return ret def dec_and_get(self): self.mutex.lock() self.val -= 1 ret = self.val self.mutex.unlock() return ret def inc_and_get(self): self.mutex.lock() self.val += 1 ret = self.val self.mutex.unlock() return ret
def __init__(self, module_params=None, qt_settings=None, **kwds): super().__init__(**kwds) self.controller_mutex = QtCore.QMutex( ) # a shared Mutex for both stages self.functionalities = {} # a list of the functionalities configuration = module_params.get( "configuration" ) # get the config parameters from the xml file under <PiController> self.controller = piC867.piC867( serialnum1=configuration.get("serialnum1"), serialnum2=configuration.get("serialnum2")) if self.controller.getStatus(): devices = configuration.get("devices") for dev_name in devices.getAttrs(): # XY stage. if (dev_name == "xy_stage"): settings = devices.get(dev_name) # We do this so that the superclass works correctly." self.stage = self.controller self.stage_functionality = PiStageFunctionality( device_mutex=self.controller_mutex, stage=self.stage, update_interval=500, velocity=settings.get("velocity", 10)) else: self.controller = None
def __init__(self, frequent=20): QtCore.QThread.__init__(self) self.stopped = False self.frequent = frequent self.timeSignal = Communicate() self.mutex = QtCore.QMutex() self.frame = 0
def __init__(self, parent, height, width): super(TicTacWidget, self).__init__(parent) game_board = GameBoard(height, width) user = Player(interface_callback=self.user_input) robot = AI() user_choise = ChoosePlayerDialog() user_choise.exec_() player_1, player_2 = (user, robot) if user_choise.first_player else (robot, user) self.tictac = TicTacToe(game_board, player_1, player_2, show_callback=self.update_board_signal.emit) self.update_board_signal.connect(self.update_game_status) # a bit overhead for user input organization self.user_input_wait_condition = QtCore.QWaitCondition() self.user_input_wait_mutex = QtCore.QMutex() self.user_input_data = None self.initBoard() self.game_loop()
def __init__(self, pollMs): QtCore.QThread.__init__(self) self._pollMs = pollMs self._mtx = QtCore.QMutex(QtCore.QMutex.Recursive) self._list = [] self.start() self._update = True
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,task_id,status_signal,image_signal, wait_poll_signal, polling_wait_condition, product,profile,proxy,monitor_delay,error_delay,max_price): self.task_id,self.status_signal,self.image_signal,self.product,self.profile,self.monitor_delay,self.error_delay,self.max_price = task_id,status_signal,image_signal,product,profile,float(monitor_delay),float(error_delay),max_price ####### Browser/Captcha Polling Variables ###### self.captcha_mutex = QtCore.QMutex() self.captcha_wait_condition = polling_wait_condition self.wait_poll_signal = wait_poll_signal ################################################# self.session = requests.Session() if proxy != False: self.session.proxies.update(proxy) starting_msg = "Starting" if settings.dont_buy: starting_msg = "Starting in dev mode will not actually checkout (dont_buy = True)" self.status_signal.emit({"msg":starting_msg,"status":"normal"}) self.product_image, offer_id = self.monitor() did_add = False while did_add is False: did_add = self.atc(offer_id) item_id, fulfillment_option, ship_method = self.check_cart_items() self.submit_shipping_method(item_id, fulfillment_option, ship_method) self.submit_shipping_address() card_data,PIE_key_id,PIE_phase = self.get_PIE() pi_hash = self.submit_payment(card_data,PIE_key_id,PIE_phase) self.submit_billing(pi_hash) self.submit_order()
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, _plotWindow=None): # PlotManagerSetup.PlotWindowInterfaceBase.__init__(self,_plotWindow) QtCore.QObject.__init__(self, None) if _plotWindow: self.plotWindow = _plotWindow import weakref self.plotWindow.plotInterface = weakref.ref(self) self.pW = self.plotWindow.plotWidget self.plot_params = self.plotWindow.getPlotParams() self.plotData = {} self.plotHistData = {} self.plotDrawingObjects = {} self.initSignalsAndSlots() self.plotWindowInterfaceMutex = QtCore.QMutex() self.dirtyFlagIndex = 2 # this is the index of the flag tha is used to signal wheather the data has been modified or not self.autoLegendFlag = False self.legendSetFlag = False # self.legendPosition = Qwt.QwtPlot.BottomLegend # todo self.legendPosition = None self.legend_added = False self.barplot = None self.eraseAllFlag = False self.logScaleFlag = False try: self.title = self.plot_params['title'] except: self.title = 'GENERIC PLOT'
def __init__(self, SharedData, parent=None): QtCore.QThread.__init__(self) super(self.__class__, self).__init__() self.sem = QtCore.QSemaphore() self.lock = QtCore.QMutex() self.cliplen = 2 self.SharedData = SharedData self.CHUNK_SIZE = 512 #sd.default.blocksize = self.CHUNK_SIZE self.fs = 44100 sd.default.samplerate = self.fs self.CHANNELS = 1 sd.default.channels = self.CHANNELS sd.default.device = mydev sd.default.dtype = 'int16' sd.default.never_drop_input = False sd.default.latency = ('low', 'low') self.frames = [] self.stream = sd.Stream(callback=self.callback) try: print("Remove file") os.remove(self.SharedData.audio_filename) except: print("Remove file failed") self.t = 0
def __init__(self, **kwds): super().__init__(**kwds) self.stage_functionality = NoneStageFunctionalityBroken(device_mutex = QtCore.QMutex(), stage = self.stage, update_interval = 500) self.watchdog_timeout = 100
class pingThread(QtCore.QThread): # 创建信号,括号里填写信号传递的参数 signal = QtCore.pyqtSignal(str) signal_list = QtCore.pyqtSignal(list) pidsignal = QtCore.pyqtSignal(int) # 创建线程锁 qmut = QtCore.QMutex() pinglist = [] def __init__(self, cmd): super().__init__() self.cmd = cmd def run(self): import subprocess self.qmut.lock() subP = subprocess.Popen(self.cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0, shell=True) self.pidsignal.emit(subP.pid) for line in iter(subP.stdout.readline, b''): line = line.strip().decode('gbk') # 把ping输出的结果中的主要信息添加到列表中 if 'ms' in line or '),' in line or '),' in line: if 'TTL' not in line: self.pinglist.append(line) # 发送信号 self.signal.emit(str(line)) self.qmut.unlock() subP.kill() # 发送列表 self.signal_list.emit(self.pinglist)
def __init__(self, parent, settings): super(CoreThread, self).__init__(parent) self._logger = logging.getLogger(self.__class__.__name__) self._renderer = None self._settings = settings self._abort = False self._mutex = QtCore.QMutex()
def __init__(self, parent=None) : U.Ui_MainWindow.__init__(self) self.qtimer = QtCore.QTimer() self.data = np.zeros(541) self.dataP = np.zeros(541) self.mutex = QtCore.QMutex() self.reader = ust_reader.UstReader(self.data,self.mutex,self.dataP)