def __init__(self, parent=None): """Initialise Linux pseudo terminal """ QThread.__init__(self, parent) self.master, self.slave = pty.openpty() self.ptyname = os.ttyname(self.slave) self.stop = False
def __init__(self, UserKeys, filePaths): QThread.__init__(self) self.userkey = str(UserKeys) self.filepath = str(filePaths) self.verifySig = None self.sig = hmac.new(self.userkey, '', hashlib.sha256) self.head = ''
def test_methodinvoke(self): executor = ThreadExecutor() state = [None, None] class StateSetter(QObject): @Slot(object) def set_state(self, value): state[0] = value state[1] = QThread.currentThread() def func(callback): callback(QThread.currentThread()) obj = StateSetter() f1 = executor.submit(func, methodinvoke(obj, "set_state", (object,))) f1.result() # So invoked method can be called QCoreApplication.processEvents() self.assertIs(state[1], QThread.currentThread(), "set_state was called from the wrong thread") self.assertIsNot(state[0], QThread.currentThread(), "set_state was invoked in the main thread") executor.shutdown(wait=True)
def __init__(self, tasks, library, urls, avai, modified, name, rlock, processed, case): """Constructs new worker instance. Args: tasks: initial tasks queue (it will get tasks from here) library: main library part (library[1]) urls: urls library part (library[3]) avai: available library part (library[4]) name: used database name rlock: RLock object used to provide thread-safety (should be the same for all instances of Bee!) processed: processed artists storage (used in ~behaviour mode) case: case sensitivity """ QThread.__init__(self) self.tasks = tasks self.library = library self.urls = urls self.avai = avai self.modified = modified self.name = name self.rlock = rlock self.processed = processed self.case = case self.start()
def __init__(self, ui, parent = None): QThread.__init__(self, parent) self.ui = ui self.mode="linear" self.add[str].connect(self.onAdd) self.rem[str].connect(self.onRem) self.sub1 = rospy.Subscriber("/chromosom/addComponent", String, self.add_callback) self.sub2 = rospy.Subscriber("/chromosom/remComponent", String, self.rem_callback) self.pub_add = rospy.Publisher('/chromosom/addComponent', String) self.pub_rem = rospy.Publisher('/chromosom/remComponent', String) ui.btnOpen.clicked.connect(self.open_gripper) ui.btnClose.clicked.connect(self.close_gripper) ui.btnOn.clicked.connect(self.power_on) ui.btnOff.clicked.connect(self.power_off) ui.btnToolChange.clicked.connect(self.tool_change) ui.rLin.clicked.connect(self.lin) ui.rDWA.clicked.connect(self.DWA) ui.btnA.clicked.connect(self.A) ui.btnB.clicked.connect(self.B) self.sss = simple_script_server()
def __init__(self): QThread.__init__(self) self.warnedDevices=[] self.instaladorRunning="/tmp/instalador-running" #"/tmp/instaladornano-running" #### # HARDWARE INITIAL DEFINITIONS - IvMan work #### global lshal lshal=getoutput("lshal").rsplit('\n') #Guardem l'estat actual de Hardware self.bus = dbus.SystemBus() self.hal_manager_obj = self.bus.get_object("org.freedesktop.Hal", "/org/freedesktop/Hal/Manager") self.hal_manager = dbus.Interface(self.hal_manager_obj, "org.freedesktop.Hal.Manager") # gdl_changed will be invoked when the Global Device List is changed # per the hal spec self.hal_manager.connect_to_signal("DeviceAdded", lambda *args: self.gdl_changed("DeviceAdded", *args)) self.hal_manager.connect_to_signal("DeviceRemoved", lambda *args: self.gdl_changed("DeviceRemoved", *args)) self.hal_manager.connect_to_signal("NewCapability", lambda *args: self.gdl_changed("NewCapability", *args))
def start(self): """ Reimplemented from `QThread.start` """ QThread.start(self) # Need to also handle method invoke from this thread self.moveToThread(self)
def __init__(self,fileSharerGui,peerIp,filePath,filename): QThread.__init__(self) self.fileSharerGui=fileSharerGui self.peerIp=peerIp self.filePath=filePath self.filename=filename self.lock=threading.Lock()
def __init__(self, location, link, parent=None): QThread.__init__(self, parent) self.url = link self.location = location self._run_semaphore = QSemaphore(1)
def __init__(self, interval, projectDir, vcs, parent = None): """ Constructor @param interval new interval in seconds (integer) @param projectDir project directory to monitor (string or QString) @param vcs reference to the version control object @param parent reference to the parent object (QObject) """ QThread.__init__(self, parent) self.setObjectName("VcsStatusMonitorThread") self.setTerminationEnabled(True) self.projectDir = QString(projectDir) self.vcs = vcs self.interval = interval self.autoUpdate = False self.statusList = QStringList() self.reportedStates = {} self.shouldUpdate = False self.monitorMutex = QMutex() self.monitorCondition = QWaitCondition() self.__stopIt = False
def __init__(self, parent, pattern=None, location=None, settings=None): """ Initializes the class. :param parent: Object parent. :type parent: QObject """ LOGGER.debug("> Initializing '{0}()' class.".format(self.__class__.__name__)) QThread.__init__(self, parent) # --- Setting class attributes. --- self.__container = parent self.__pattern = None self.pattern = pattern self.__location = None self.location = location self.__settings = None self.settings = settings self.__searchResults = None self.__interrupt = False self.__lock = QMutex()
def __init__(self, file): QThread.__init__(self) EventHandler.__init__(self) self.file = file self.file.connection(self) self.pattern = "" self.wild = ""
def __init__(self, main_window, exp_number, scan_number_list): """ Initialization :param main_window: :param exp_number: :param scan_number_list: """ QThread.__init__(self) # check assert main_window is not None, 'Main window cannot be None' assert isinstance(exp_number, int), 'Experiment number must be an integer.' assert isinstance(scan_number_list, list), 'Scan number list must be a list but not %s.' \ '' % str(type(scan_number_list)) # set values self._mainWindow = main_window self._expNumber = exp_number self._scanNumberList = scan_number_list # connect to the updateTextEdit slot defined in app1.py self.peakAddedSignal.connect(self._mainWindow.update_peak_added_info) self.peakStatusSignal.connect(self._mainWindow.update_adding_peaks_status) self.peakAddedErrorSignal.connect(self._mainWindow.report_peak_addition) return
def __init__(self, IOout, fd, sig): QThread.__init__(self) self.ioOut = IOout self.pipe = os.pipe() os.close(fd) os.dup2(self.pipe[1], fd) self.sig = sig
def __init__(self, deviceVendor, deviceProduct): QThread.__init__(self) # Get list of available devices devices = map(InputDevice, list_devices()) # Try to find the desired device for device in devices: # If multiple devices of same type available, # select the first, e.g. phys ".../input0" isDesiredDevice = \ (device.info.vendor == deviceVendor) and \ (device.info.product == deviceProduct) and \ (device.phys.endswith('0')) if isDesiredDevice: self.device = device break # Get exclusive access to the device if self.isConnected(): print 'Grab keypad input device.' self.device.grab()
def __init__(self,bssid, client,interface): QThread.__init__(self) self.bssid = bssid self.client = client self.interface = interface self.status = False self.pkts = []
def __init__(self, parent): QThread.__init__(self) self.result = None self.parent = parent self._stopped = False self.mutex = QMutex() self.filePrefix = None self.fileFormat = None self.wallColoring = None self.cellColoring = None self.pointColoring = None self.extraDrawing = [] self.pointSize = None self.pointLineColor = None self.pointLineThickness = None self.ellipsisDraw = None self.overSampling = None self.wallThickness = None self.bgColor = None self.loading = False self._crop = QRect(0,0,1,1) self._pix = None self._end_image_plot = False self._loading_arguments = {} self.retryObject = None
def __init__(self): QThread.__init__(self) self.results = [] self._cancel = False self.locations = [] self.execute = self.navigate_code self.dirty = False
def __init__(self,tc_service_endpoint, zmq_context): QThread.__init__(self) self.proxy = TemperatureControllerProxy(tc_service_endpoint,zmq_context) self.__requested_setpoint1 = None self.__requested_setpoint2 = None self.__requested_remote_setpoint = None
def __init__(self, arraysize, pattern, writePW, gndPW, loop): QThread.__init__(self) self.arraysize = arraysize # Memory array size (1,2,3) self.pattern = pattern # Pattern written into array self.writePW = int(writePW) # Write pulse width self.gndPW = int(gndPW) # Ground pulse width self.loop = int(loop) # Loop number
def __init__(self, arraysize, pattern, writePW, gndPW, loop): QThread.__init__(self) self.arraysize = arraysize self.pattern = pattern self.writePW = int(writePW) self.gndPW = int(gndPW) self.loop = int(loop)
def __init__(self, obj = None, maskSet = None, parent = None): QThread.__init__(self, parent) self.Obj = obj self.Parent = parent self.maskSet = maskSet self.flag = ''
def __init__(self, parent = None): print "We made an *L*worker." QThread.__init__(self, parent) self.lstate=0 self.exiting = False self.start() print "L------About to call the caller."
def __init__(self,app): """ Set up the initial thread for monitoring the directory """ QThread.__init__(self) self.dw = KDirWatch() self.app = app
def __init__(self, parent = None): print "We made a worker." QThread.__init__(self, parent) self.exiting = False time.sleep(.1) self.start() print "About to call the caller."
def __init__( self, files, needPrj ): QThread.__init__( self, QThread.currentThread() ) self.inFiles = files self.needPrj = needPrj self.mutex = QMutex() self.stopMe = 0
def __init__(self, manager): QThread.__init__(self) self._manager = manager #runnable hold a function to call! self.runnable = self.collect_data_thread #this attribute contains the plugins to download/update self.plug = None
def __init__(self, queue): """ Keyword arguments: queue -- a Queue object """ QThread.__init__(self) self._queue = queue
def __init__(self, parent): QThread.__init__(self, parent) self.mutex = QMutex() self.stopped = False self.results = None self.nb = None self.error_flag = None
def __init__(self, login_handler): signal = SIGNAL('login vc finish') self.mw = login_handler.mw self.mw.connect(self.mw, signal, login_handler.login_vc_finish) self.signal = signal QThread.__init__(self)
def __init__(self, args): QThread.__init__(self) self.args = args self.process = None
def __init__(self): QThread.__init__(self)
def __init__(self, ow_gradient_descent): QThread.__init__(self) self.ow_gradient_descent = ow_gradient_descent
def __init__(self, ontology, rules, output): QThread.__init__(self) self.ontology = ontology self.rules = rules self.output = output
def __init__(self, spareDB, db): QThread.__init__(self) self.spareDB = spareDB self.db = db
def __init__(self, weboob, item, minfo): QThread.__init__(self) self.weboob = weboob self.items = [item] self.minfo = minfo
def __init__(self, gateway): QThread.__init__(self) self.gateway = gateway self.result = ''
def __init__(self, cmd): QThread.__init__(self) self.cmd = cmd self.process = None
def __init__(self, filename): QThread.__init__(self) self.filepath = filename
def __init__(self, port, plugins={}, options={}): QThread.__init__(self) self.port = port self.PumpPlugins = plugins self.loaderPlugins = options
def __init__(self, filepath, La_Name, Template): QThread.__init__(self) self.filepath = filepath self.LaName = La_Name self.template = Template
def __init__(self, port, plugins={}, data={}): QThread.__init__(self) self.port = port self.plugins = plugins self.loaderPlugins = data
def stop(self): self.mutex.lock() self.stopMe = 1 self.mutex.unlock() QThread.wait(self)
def __init__(self, filepath, Template): QThread.__init__(self) self.filepath = filepath self.template = Template
def __init__(self, Version, Rlogger, localC, remoteC): QThread.__init__(self) self.Version = Version self.localC = localC self.remoteC = remoteC self.Rchangelog = Rlogger
class BoBlo(QWidget): ''' Revisar layouts para proporciones ''' def __init__(self): super().__init__() self.setGeometry(200, 100, 1024, 768) self.setWindowTitle('BoBlo - Bottle Blocks') self.setWindowIcon(QIcon(get_absolute_path('images/icon2.png'))) self.screenShape = QDesktopWidget().screenGeometry() self.bg_width = 1280 self.bg_height = 990 # self.resize(self.screenShape.width(), self.screenShape.height()) self.combinations = list() self.plastic = 0 self.button_stylesheet = "QPushButton {background-color: #8FCBF4;" \ "border-style: outset;" \ "border-width: 2px;" \ "border-radius: 10px;" \ "border-color: #C6E2FF;" \ "font: bold 15pt \"Comic Sans MS\";" \ "min-width: 10em;" \ "padding: 6px;}" \ "QPushButton:pressed {background-color: #4F94CD}" self.background = QLabel(self) self.background.setGeometry(375, 0, self.bg_width, self.bg_height) self.background.setPixmap( QPixmap(get_absolute_path("./images/background.jpg")).scaled( self.bg_width, self.bg_height)) self.label_grs1 = QLabel(str(self.plastic), self) self.label_grs1.setFont(QFont("Comic Sans MS", 40, QFont.Bold)) self.label_grs1.setGeometry(640, 270, 310, 120) self.label_grs1.setAlignment(Qt.AlignRight) self.label_grs1.hide() self.label_grs2 = QLabel(str(self.plastic), self) self.label_grs2.setFont(QFont("Comic Sans MS", 40, QFont.Bold)) self.label_grs2.setGeometry(820, 58, 310, 120) self.label_grs2.setAlignment(Qt.AlignCenter) self.label_grs2.hide() self.label_blocks = QLabel(str(plastic_to_blocks(self.plastic)), self) self.label_blocks.setFont(QFont("Comic Sans MS", 50, QFont.Bold)) self.label_blocks.setGeometry(700, 330, 310, 150) self.label_blocks.setAlignment(Qt.AlignRight) self.label_blocks.hide() self.text_dato = QLabel(self) self.text_dato.move(570, 550) self.text_dato.setPixmap( QPixmap(get_absolute_path("./images/dato1.png"))) self.text1 = QLabel(self) self.text1.move(570, 100) self.text1.setPixmap(QPixmap(get_absolute_path("./images/text1.png"))) self.pic1 = QLabel(self) self.pic1.move(1070, 400) self.pic1.setPixmap( QPixmap(get_absolute_path("./images/image_step1.png"))) self.text2 = QLabel(self) self.text2.move(570, 50) self.text2.setPixmap(QPixmap(get_absolute_path("./images/text2.png"))) self.text2.hide() self.text3 = QLabel(self) self.text3.move(930, 260) self.text3.setPixmap(QPixmap(get_absolute_path("./images/text3.png"))) self.text3.hide() self.text4 = QLabel(self) self.text4.move(570, 50) self.text4.setPixmap(QPixmap(get_absolute_path("./images/text4.png"))) self.text4.hide() self.pic2 = QLabel(self) self.pic2.move(1070, 350) self.pic2.setPixmap(QPixmap(get_absolute_path("./images/boblo1.png"))) self.pic2.hide() self.text5 = QLabel(self) self.text5.move(570, 50) self.text5.setPixmap(QPixmap(get_absolute_path("./images/text5.png"))) self.text5.hide() self.to_step3 = QPushButton("&Quiero mis piezas", self) self.to_step3.setGeometry(1120, 570, 300, 90) self.to_step3.setStyleSheet(self.button_stylesheet) self.to_step3.hide() self.icon_arrow = QIcon(get_absolute_path("./images/arrow.png")) self.to_step4 = QPushButton("", self) self.to_step4.setIcon(self.icon_arrow) self.to_step4.setIconSize(QSize(250, 60)) self.to_step4.setGeometry(1120, 570, 300, 90) self.to_step4.setStyleSheet(self.button_stylesheet) self.to_step4.hide() self.icon_arrowi = QIcon(get_absolute_path("./images/arrowi.png")) self.back_to_step2 = QPushButton("", self) self.back_to_step2.setIcon(self.icon_arrowi) self.back_to_step2.setIconSize(QSize(250, 60)) self.back_to_step2.setGeometry(644, 570, 300, 90) self.back_to_step2.setStyleSheet(self.button_stylesheet) self.back_to_step2.hide() self.to_step5 = QPushButton("", self) self.to_step5.setIcon(self.icon_arrow) self.to_step5.setIconSize(QSize(250, 60)) self.to_step5.setGeometry(1140, 610, 300, 90) self.to_step5.setStyleSheet(self.button_stylesheet) self.to_step5.hide() # self.options = OptionsList(self) self.options = OptionsTable(self) self.options.setGeometry(620, 170, 824, 430) self.options.hide() self.text6 = QLabel(self) self.text6.move(570, 100) self.text6.setPixmap(QPixmap(get_absolute_path("./images/text6.png"))) self.text6.hide() self.text7 = QLabel(self) self.text7.move(570, 480) self.text7.setPixmap(QPixmap(get_absolute_path("./images/text7.png"))) self.text7.hide() self.text_process = QLabel(self) self.text_process.move(570, 480) self.text_process.setPixmap( QPixmap(get_absolute_path("./images/process1.png"))) self.text_process.hide() self.restart = QPushButton("&OK", self) self.restart.setGeometry(1120, 570, 300, 90) self.restart.setStyleSheet(self.button_stylesheet) self.restart.hide() self.audio = QSound(get_absolute_path("./audio/boblo.wav")) # threading self.start_thread() def restart_values(self): self.plastic = 0 self.combinations = list() self.label_grs1.setText(str(self.plastic)) self.label_grs2.setText(str(self.plastic)) self.options = OptionsTable(self) self.options.setGeometry(620, 170, 824, 430) self.options.hide() def set_combinations(self, blocks): self.all_combinations(blocks) if len(self.combinations) != 0: if len(self.combinations) == 1 and sum( self.combinations[0].values()) == 0: self.emit(SIGNAL("invalid")) else: self.combinations.append({8: 5, 4: 5, 2: 5, 1: 5}) print(self.combinations) self.options.set_data(self.combinations) return def all_combinations(self, blocks, step=8, comb={8: 0, 4: 0, 2: 0, 1: 0}): ''' Options: 4x2 (8), 2x2 (4), 2x1 (2), 1x1 (1) Restricciones: - Max. 1 de 1x1 (impar) - Max 5 de un tipo - Max 8 piezas en total - Max 5 entre 1x1 y 2x1 ''' actual_sum = sum([x[0] * x[1] for x in comb.items()]) if step == 0: # restricciones if actual_sum == blocks: if comb[1] <= 1 and (comb[1] + comb[2]) <= 5 and sum( comb.values()) <= 8: if len([v for v in comb.values() if v > 5]) == 0: self.combinations.append(comb) return else: max_cant = (blocks - actual_sum) // step if step == 8: next_step = 4 elif step == 4: next_step = 2 elif step == 2: next_step = 1 else: next_step = 0 for i in range(0, max_cant + 1): aux = dict(comb) aux[step] = i self.all_combinations(blocks, next_step, aux) def start_thread(self): self.weight_monitor = ArduinoMonitor() self.t = QThread(self) self.weight_monitor.weight_signal.connect(self.update_weight) self.weight_monitor.moveToThread(self.t) self.t.started.connect(self.weight_monitor.check_weight) self.t.start() @pyqtSlot(str) def update_weight(self, grs): # actualizar peso en interfaz if grs != "Exito": self.plastic = int(grs) self.label_grs1.setText(str(self.plastic)) self.label_grs2.setText(str(self.plastic)) if int(grs) != 0: self.emit(SIGNAL("weight")) else: print(grs)
class SearchPlugin(widget, base, Page): title = "Search" icon = resolve("search.svg") def __init__(self, api, parent=None): super(SearchPlugin, self).__init__(parent) self.setupUi(self) self.api = api self.project = None self.dbpath = None self.flickcharm = FlickCharm() self.flickcharm.activateOn(self.resultsView) self.searchbox.textChanged.connect(self.search) self.searchbox.installEventFilter(self) self.resultsView.itemClicked.connect(self.jump_to) self.rebuildLabel.linkActivated.connect(self.rebuild_index) self.fuzzyCheck.stateChanged.connect(self.fuzzy_changed) self.indexbuilder = None self.indexthread = None def fuzzy_changed(self, state): self.search(self.searchbox.text()) def index_built(self, dbpath, timing): self.dbpath = dbpath self.resultsView.clear() self.searchbox.setEnabled(True) print "Index built in: {} seconds".format(timing) def eventFilter(self, object, event): if event.type() == QEvent.FocusIn: RoamEvents.openkeyboard.emit() return False @property def db(self): db = sqlite3.connect(self.dbpath) db.create_function("rank", 1, make_rank_func((1., .1, 0, 0))) return db def project_loaded(self, project): self.project = project self.build_index(project) def rebuild_index(self): self.build_index(self.project) def build_index(self, project): self.searchbox.setEnabled(False) self.resultsView.setEnabled(False) self.resultsView.addItem( "Just let me build the search index first....") validformat, settings = valid_search_settings(project.settings) if not validformat: RoamEvents.raisemessage("Searching", "Invalid search config.", level=1) self.searchbox.hide() self.resultsView.clear() self.resultsView.addItem("Invalid search config found") return self.indexthread = QThread() self.indexbuilder = IndexBuilder(project.folder, settings) self.indexbuilder.moveToThread(self.indexthread) self.indexbuilder.indexBuilt.connect(self.index_built) self.indexbuilder.finished.connect(self.indexthread.quit) self.indexthread.started.connect(self.indexbuilder.build_index) self.indexthread.finished.connect(self.indexbuilder.quit) self.indexthread.start() def search(self, text): db = self.db c = db.cursor() self.resultsView.clear() self.resultsView.setEnabled(False) if not text: return if self.fuzzyCheck.isChecked(): search = "* ".join(text.split()) + "*" else: search = text query = c.execute( """SELECT layer, featureid, snippet(search, '[',']') as snippet FROM search JOIN featureinfo on search.docid = featureinfo.id WHERE search match '{}' LIMIT 100""".format( search)).fetchall() for layer, featureid, snippet in query: item = QListWidgetItem() text = "{}\n {}".format(layer, snippet.replace('\n', ' ')) item.setText(text) item.setData(Qt.UserRole, (layer, featureid, snippet)) self.resultsView.addItem(item) self.resultsView.setEnabled(True) if self.resultsView.count() == 0: self.resultsView.addItem("No Results") db.close() def jump_to(self, item): data = item.data(32) layername, fid = data[0], data[1] layer = roam.api.utils.layer_by_name(layername) layer.select(fid) feature = layer.selectedFeatures()[0] self.api.mainwindow.canvas.zoomToSelected(layer) layer.removeSelection() self.api.mainwindow.showmap() RoamEvents.selectionchanged.emit({layer: [feature]})
def __init__(self, app): QThread.__init__(self) self.app = app self.running = True
def __init__(self, name, crazyflie): QThread.__init__(self) self.topic_name = name self.cf = crazyflie self.cf_physical_params = CF_parameters() # Import the PID gains (from the firmware) self.cf_pid_gains = CF_pid_params() # Out from the PIDs, values of # r, p, y, thrust self.desired_rpy = np.zeros(3) # Comes from the external position controller self.desired_thrust = 0.0 self.mode = "" self.setPoint = np.zeros(4) self.stop_flag = True ###################### # Position ###################### self.x_pid = PID(self.cf_pid_gains.KP_X, self.cf_pid_gains.KI_X, self.cf_pid_gains.KD_X, self.cf_pid_gains.INT_MAX_X, self.cf_pid_gains.X_DT) self.y_pid = PID(self.cf_pid_gains.KP_Y, self.cf_pid_gains.KI_Y, self.cf_pid_gains.KD_Y, self.cf_pid_gains.INT_MAX_Y, self.cf_pid_gains.Y_DT) self.z_pid = PID(self.cf_pid_gains.KP_Z, self.cf_pid_gains.KI_Z, self.cf_pid_gains.KD_Z, self.cf_pid_gains.INT_MAX_Z, self.cf_pid_gains.Z_DT) self.desired_pos = np.zeros(3) ###################### # Linear velocities ###################### self.vx_pid = PID(self.cf_pid_gains.KP_VX, self.cf_pid_gains.KI_VX, self.cf_pid_gains.KD_VX, self.cf_pid_gains.INT_MAX_VX, self.cf_pid_gains.VX_DT) self.vy_pid = PID(self.cf_pid_gains.KP_VY, self.cf_pid_gains.KI_VY, self.cf_pid_gains.KD_VY, self.cf_pid_gains.INT_MAX_VY, self.cf_pid_gains.VY_DT) self.vz_pid = PID(self.cf_pid_gains.KP_VZ, self.cf_pid_gains.KI_VZ, self.cf_pid_gains.KD_VZ, self.cf_pid_gains.INT_MAX_VZ, self.cf_pid_gains.VZ_DT) self.desired_lin_vel = np.zeros(3) ###################### # Angular velocities ###################### self.wx_pid = PID(self.cf_pid_gains.KP_WX, self.cf_pid_gains.KI_WX, self.cf_pid_gains.KD_WX, self.cf_pid_gains.INT_MAX_WX, self.cf_pid_gains.WX_DT) self.wy_pid = PID(self.cf_pid_gains.KP_WY, self.cf_pid_gains.KI_WY, self.cf_pid_gains.KD_WY, self.cf_pid_gains.INT_MAX_WY, self.cf_pid_gains.WY_DT) self.wz_pid = PID(self.cf_pid_gains.KP_WZ, self.cf_pid_gains.KI_WZ, self.cf_pid_gains.KD_WZ, self.cf_pid_gains.INT_MAX_WZ, self.cf_pid_gains.WZ_DT) self.desired_ang_vel = np.zeros(3) ###################### # Attitudes ###################### self.roll_pid = PID(self.cf_pid_gains.KP_ROLL, self.cf_pid_gains.KI_ROLL, self.cf_pid_gains.KD_ROLL, self.cf_pid_gains.INT_MAX_ROLL, self.cf_pid_gains.ROLL_DT) self.pitch_pid = PID(self.cf_pid_gains.KP_PITCH, self.cf_pid_gains.KI_PITCH, self.cf_pid_gains.KD_PITCH, self.cf_pid_gains.INT_MAX_PITCH, self.cf_pid_gains.PITCH_DT) self.yaw_pid = PID(self.cf_pid_gains.KP_YAW, self.cf_pid_gains.KI_YAW, self.cf_pid_gains.KD_YAW, self.cf_pid_gains.INT_MAX_YAW, self.cf_pid_gains.YAW_DT) self.desired_att = np.zeros(3)
def __init__(self, url): QThread.__init__(self) self.url = url self.response = None
def __init__(self, parent=None): QThread.__init__(self, parent)
def __init__(self, get_messages_fn): """Initializes the EventWatcher.""" QThread.__init__(self) self.__state = "stopped" self.fn = get_messages_fn self.logger = logging.getLogger(__name__)
def __init__(self, cameraOperator, platform, main): QThread.__init__(self) self.autofocus = Autofocus(cameraOperator, platform, self) self.scheduler = Scheduler(self.autofocus) self.main = main
def __init__(self, parent=None): super(MapWidget, self).__init__(parent) self.setupUi(self) self.snapping = True icon = roam_style.iconsize() self.projecttoolbar.setIconSize(QSize(icon, icon)) self.current_form = None self.last_form = None self.firstshow = True self.layerbuttons = [] self.editfeaturestack = [] self.lastgpsposition = None self.project = None self.gps = None self.gpslogging = None self.selectionbands = defaultdict(partial(QgsRubberBand, self.canvas)) self.bridge = QgsLayerTreeMapCanvasBridge(QgsProject.instance().layerTreeRoot(), self.canvas) self.bridge.setAutoSetupOnFirstLayer(False) QgsProject.instance().writeProject.connect(self.bridge.writeProject) QgsProject.instance().readProject.connect(self.bridge.readProject) # self.canvas.setInteractive(False) self.canvas.setCanvasColor(Qt.white) self.canvas.enableAntiAliasing(True) self.canvas.setWheelAction(QgsMapCanvas.WheelZoomToMouseCursor) self.snappingutils = SnappingUtils(self.canvas, self) self.canvas.setSnappingUtils(self.snappingutils) QgsProject.instance().readProject.connect(self.snappingutils.readConfigFromProject) if hasattr(self.canvas, 'setParallelRenderingEnabled'): threadcount = QThread.idealThreadCount() threadcount = 2 if threadcount > 2 else 1 QgsApplication.setMaxThreads(threadcount) self.canvas.setParallelRenderingEnabled(True) pal = QgsPalLabeling() self.canvas.mapRenderer().setLabelingEngine(pal) self.canvas.setFrameStyle(QFrame.NoFrame) self.editgroup = QActionGroup(self) self.editgroup.setExclusive(True) self.editgroup.addAction(self.actionPan) self.editgroup.addAction(self.actionZoom_In) self.editgroup.addAction(self.actionZoom_Out) self.editgroup.addAction(self.actionInfo) self.actionGPS = GPSAction(":/icons/gps", self.canvas, self) self.projecttoolbar.addAction(self.actionGPS) if roam.config.settings.get('north_arrow', False): self.northarrow = NorthArrow(":/icons/north", self.canvas) self.northarrow.setPos(10, 10) self.canvas.scene().addItem(self.northarrow) smallmode = roam.config.settings.get("smallmode", False) self.projecttoolbar.setSmallMode(smallmode) self.scalebar_enabled = roam.config.settings.get('scale_bar', False) if self.scalebar_enabled: self.scalebar = ScaleBarItem(self.canvas) self.canvas.scene().addItem(self.scalebar) self.projecttoolbar.setContextMenuPolicy(Qt.CustomContextMenu) gpsspacewidget = QWidget() gpsspacewidget.setMinimumWidth(30) gpsspacewidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.topspaceraction = self.projecttoolbar.insertWidget(self.actionGPS, gpsspacewidget) self.dataentryselection = QAction(self.projecttoolbar) self.dataentryaction = self.projecttoolbar.insertAction(self.topspaceraction, self.dataentryselection) self.dataentryselection.triggered.connect(self.select_data_entry) self.marker = GPSMarker(self.canvas) self.marker.hide() self.currentfeatureband = CurrentSelection(self.canvas) self.currentfeatureband.setIconSize(30) self.currentfeatureband.setWidth(10) self.currentfeatureband.setColor(QColor(186, 93, 212, 50)) self.currentfeatureband.setOutlineColour(QColor(186, 93, 212)) self.gpsband = QgsRubberBand(self.canvas) self.gpsband.setColor(QColor(165, 111, 212, 75)) self.gpsband.setWidth(5) RoamEvents.refresh_map.connect(self.refresh_map) RoamEvents.editgeometry.connect(self.queue_feature_for_edit) RoamEvents.selectioncleared.connect(self.clear_selection) RoamEvents.selectionchanged.connect(self.highlight_selection) RoamEvents.openfeatureform.connect(self.feature_form_loaded) RoamEvents.sync_complete.connect(self.refresh_map) RoamEvents.snappingChanged.connect(self.snapping_changed) self.snappingbutton = QToolButton() self.snappingbutton.setText("Snapping: On") self.snappingbutton.setAutoRaise(True) self.snappingbutton.pressed.connect(self.toggle_snapping) spacer = QWidget() spacer2 = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) spacer2.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.scalewidget = QgsScaleComboBox() self.scalebutton = QToolButton() self.scalebutton.setAutoRaise(True) self.scalebutton.setMaximumHeight(self.statusbar.height()) self.scalebutton.pressed.connect(self.selectscale) self.scalebutton.setText("Scale") self.scalelist = BigList(parent=self.canvas, centeronparent=True, showsave=False) self.scalelist.hide() self.scalelist.setlabel("Map Scale") self.scalelist.setmodel(self.scalewidget.model()) self.scalelist.closewidget.connect(self.scalelist.close) self.scalelist.itemselected.connect(self.update_scale_from_item) self.scalelist.itemselected.connect(self.scalelist.close) self.positionlabel = QLabel('') self.gpslabel = QLabel("GPS: Not active") self.gpslabelposition = QLabel("") self.statusbar.addWidget(self.snappingbutton) self.statusbar.addWidget(spacer2) self.statusbar.addWidget(self.gpslabel) self.statusbar.addWidget(self.gpslabelposition) self.statusbar.addPermanentWidget(self.scalebutton) self.canvas.extentsChanged.connect(self.updatestatuslabel) self.canvas.scaleChanged.connect(self.updatestatuslabel) GPS.gpsposition.connect(self.update_gps_label) GPS.gpsdisconnected.connect(self.gps_disconnected) self.connectButtons()
def __init__(self, server, broadcast, received_message_window): QThread.__init__(self) self.server = server self.running = True self.broadcast = broadcast self.received_message_window = received_message_window
def __init__(self, parent=None): QThread.__init__(self, parent=parent) self.cameraSettings()
def __init__(self, serialPort): QThread.__init__(self) self.serialPort = serialPort #print type(serialPort) self.Message = WheelBotMsg(serialPort) print self.Message.ser.is_open
def __init__(self, ontologies, output): QThread.__init__(self) self.ontologies = ontologies self.output = output
class AbstractBuildRunner(QObject): """ Base class to run a build. Create the required test runner and build manager, along with a thread that should be used for blocking tasks. """ running_state_changed = Signal(bool) worker_created = Signal(object) worker_class = None def __init__(self, mainwindow): QObject.__init__(self) self.mainwindow = mainwindow self.thread = None self.worker = None self.pending_threads = [] self.test_runner = None self.download_manager = None self.options = None self.stopped = False def init_worker(self, fetch_config, options): """ Create and initialize the worker. Should be subclassed to configure the worker, and should return the worker method that should start the work. """ self.options = options # global preferences global_prefs = get_prefs() self.global_prefs = global_prefs # apply the global prefs now apply_prefs(global_prefs) if fetch_config.is_nightly(): fetch_config.set_base_url(global_prefs['archive_base_url']) download_dir = global_prefs['persist'] if not download_dir: download_dir = self.mainwindow.persist persist_limit = int( abs(global_prefs['persist_size_limit']) * 1073741824) self.download_manager = GuiBuildDownloadManager( download_dir, persist_limit) self.test_runner = GuiTestRunner() self.thread = QThread() # options for the app launcher launcher_kwargs = {} for name in ('profile', 'preferences'): if name in options: value = options[name] if value: launcher_kwargs[name] = value # add add-ons paths to the app launcher launcher_kwargs['addons'] = options['addons'] self.test_runner.launcher_kwargs = launcher_kwargs self.worker = self.worker_class(fetch_config, self.test_runner, self.download_manager) # Move self.bisector in the thread. This will # allow to the self.bisector slots (connected after the move) # to be automatically called in the thread. self.worker.moveToThread(self.thread) self.worker_created.emit(self.worker) def start(self, fetch_config, options): action = self.init_worker(fetch_config, options) assert callable(action), "%s should be callable" % action self.thread.start() # this will be called in the worker thread. QTimer.singleShot(0, action) self.stopped = False self.running_state_changed.emit(True) @Slot() def stop(self, wait=True): self.stopped = True if self.options: if self.options['profile'] and \ self.options['profile_persistence'] == 'clone-first': self.options['profile'].cleanup() if self.download_manager: self.download_manager.cancel() if self.thread: self.thread.quit() if wait: if self.download_manager: self.download_manager.wait(raise_if_error=False) if self.thread: # wait for thread(s) completion - this is the case when # user close the application self.thread.wait() for thread in self.pending_threads: thread.wait() self.thread = None elif self.thread: # do not block, just keep track of the thread - we got here # when user uses the stop button. self.pending_threads.append(self.thread) self.thread.finished.connect(self._remove_pending_thread) if self.test_runner: self.test_runner.finish(None) self.running_state_changed.emit(False) log('Stopped') @Slot() def _remove_pending_thread(self): for thread in self.pending_threads[:]: if thread.isFinished(): self.pending_threads.remove(thread)
def __init__(self, msg): QThread.__init__(self) self.msg = msg