def __init__(self, out_q): # Thread setup super(QMain.ArbiterListen, self).__init__() # recv monitor self._frame_counter = QtCore.QElapsedTimer() self._frame_counter.restart() self.fps = 1 # setup ZMQ self._zctx = zmq.Context() self.dets_recv = self._zctx.socket(zmq.SUB) self.dets_recv.subscribe(Comms.ABT_TOPIC_ROIDS) self.dets_recv.connect("tcp://localhost:{}".format( Comms.ABT_PORT_DATA)) self.poller = zmq.Poller() self.poller.register(self.dets_recv, zmq.POLLIN) # output Queue self._q = out_q # Thread Control self.running = True
def __init__(self, games, parent=None): super(Player, self).__init__(parent) self._games = games # Initiate UI and timer. self._setup_ui() self._game_cbbox.addItems(games.keys()) self._initiate_btn.clicked.connect(self.initiate_game) self._play_btn.clicked.connect(self.start_playing) self._stop_btn.clicked.connect(self.stop_playing) # Move the window in the top left corner of the screen. self.move(0, 0) # Ensure that this dialog is always on top of all windows. self.setWindowFlag(QtCore.Qt.WindowStaysOnTopHint) # Create timer and elapsed timer to display duration. self._duration_timer = QtCore.QTimer() self._duration_timer.setInterval(1000) self._duration_timer.timeout.connect(self._update_time) self._elapsed_timer = QtCore.QElapsedTimer() self._elapsed_timer.start() # Initiate state. self.reset() # Grab keyboard as long as window is opened. self.grabKeyboard()
def __init__(self): super().__init__() self._layout = widgets.QHBoxLayout() self._layout.setContentsMargins(0, 0, 0, 0) self.setLayout(self._layout) self._wettkampf = None self._timer = core.QTimer() self._timer.timeout.connect(self._aktualisiere_zug) self._elapsed_timer = core.QElapsedTimer() self._play_pause_knopf = widgets.QPushButton() self._play_pause_knopf.setIcon(self.style().standardIcon( widgets.QStyle.SP_MediaPlay)) self._play_pause_knopf.clicked.connect(self.toggl_play_pause) self._geschwindigkeit_auswahl = widgets.QComboBox() self._geschwindigkeit_auswahl.setEditable(False) self._geschwindigkeit_auswahl.addItem("Echtzeit", 100000) self._geschwindigkeit_auswahl.addItem("Schnell", 1000) self._geschwindigkeit_auswahl.addItem("Normal", 500) self._geschwindigkeit_auswahl.addItem("Langsam", 250) self._geschwindigkeit_auswahl.addItem("Sehr Langsam", 100) self._geschwindigkeit_auswahl.setCurrentText("Normal") for index in range(self._geschwindigkeit_auswahl.count()): zuege_pro_sekunde = self._geschwindigkeit_auswahl.itemData(index) tooltip = "{} Züge pro Sekunde".format( zuege_pro_sekunde if self._geschwindigkeit_auswahl. itemText(index) != "Echtzeit" else "∞") self._geschwindigkeit_auswahl.setItemData(index, tooltip, core.Qt.ToolTipRole) self._zug_label = widgets.QLabel() self._fortschritts_balken = ClickableProgressBar() self._fortschritts_balken.setFixedHeight(10) self._fortschritts_balken.setTextVisible(False) self._fortschritts_balken.on_click(self._on_fortschritt_clicked) self._fertig_knopf = widgets.QPushButton("Fertig") self._fertig_knopf.setDisabled(True) self._fertig_knopf.clicked.connect( lambda: self._fortschritts_balken.setValue( self._fortschritts_balken.maximum())) self._layout.addWidget(self._play_pause_knopf) self._layout.addWidget(self._geschwindigkeit_auswahl) self._layout.addWidget(self._zug_label) self._layout.addWidget(self._fortschritts_balken, stretch=1) self._layout.addWidget(self._fertig_knopf)
def __init__(self, parent=None): super().__init__(parent) self._frame_counter = QtCore.QElapsedTimer() self._wh = (0, 0) # hopefully get this on first resize self.fps = 1 self.shape1 = None self.x_rot_speed = 4 self.x_shape_rot = 0 self.y_rot_speed = 2 self.y_shape_rot = 0 self.z_rot_speed = 1 self.z_shape_rot = 0 timer = QtCore.QTimer(self) timer.timeout.connect(self.advance) timer.start(10) #ms self._frame_counter.restart()
def run(self): try: time = QtCore.QDateTime.currentDateTime() #self.debugTime = time self.startExperimentTime = time timer = QtCore.QElapsedTimer() isSerialOpen = self.openSerial(self.incubator) if isSerialOpen: logging.info("Experiment started at:{}".format( self.startExperimentTime.toString("dd.MM.yy hh:mm"))) self.mainController() # timer to only call the function every minute. logging.debug("Simulation started") self.simulateExperiment( time, hours=(time.daysTo( QtCore.QDateTime(self.experiment[-1].dateEndTime)) + 1) * 24) logging.debug("Simulation ended") self.isExperimentRunning = True self.previousLightState = None timer.start() while self.isExperimentRunning: if timer.elapsed() > 60000: # check serial is open #self.checkArduinoAlive() #sleep(0.2) self.mainController() timer.restart() # sleep to save cpu, if more than 0.2 it becomes apparently # unresponsive for the user. sleep(0.2) self.closeSerial() print("serial closed") else: logging.debug("stopping experiment, serial not open") self.isExperimentRunning = False except Exception as e: print(e) logging.error(f"something happened in run, error:{e}") self.closeSerial() self.isExperimentRunning = False