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 step(self, num_timesteps=1): """Perform a given number of visual simulation steps. Args: num_timesteps (int): The number of timesteps to simulate. """ # Check running status. if not self._running: raise utility.SimulatonWorkflowException() # Perform threading initialization for graphics. self._setup_required = True self._update_semaphore = QtCore.QSemaphore(0) self._q_app = QtWidgets.QApplication([]) self._view = visual.AdjGraphicsView(self._q_app.desktop().screenGeometry(), self._update_semaphore) self._visual_thread = visual.AdjThread(self._q_app, self, num_timesteps) self._visual_thread.finished.connect(self._q_app.exit) self._visual_thread.update_signal.connect(self._view.update) # Begin simulation. self._visual_thread.start() self._q_app.exec_() # Cleanup variables. self._visual_thread.quit() del self._visual_thread del self._view del self._q_app del self._update_semaphore
def __init__(self, fct=defaultFunction): super(SimTimer, self).__init__() self.state = SimState.Stopped self.interval = -1 self.wait = QtCore.QSemaphore(0) self.timeoutFunction = fct
def __init__(self): # Graphical User Interface super(SlaveWindow, self).__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.draw_semaphore = QtCore.QSemaphore(1) self.setAttribute(QtCore.Qt.WA_DeleteOnClose, False) self.thread = None
def __init__(self, algo, device, size, current_round, position, diff_offset, verify): ## TODO verify QtCore.QThread.__init__(self) self.algo = algo self.device = device self.size = size self.current_round = current_round self.position = position self.diff_offset = diff_offset self.verify = verify self.semaphore = QtCore.QSemaphore(1)
def __init__(self, backend): super().__init__(backend) self.lock = QtCore.QSemaphore(1) self.signals = CameraManagerSignals() self.watch_for_exposure_end = False self.exposure_start_time = None self.current_exposure_length = None self.exposure_camera_settings = None # timer if we have to maintain progress self.exposure_timer = None # polling camera status self.timer = QtCore.QTimer() self.timer.timeout.connect(self.camera_status_poll) self.timer.start(1000)
def __init__(self, stepper=DummyStepper(), stepInt_s=0.2): """The SimLoop requires a stepper object, that will be called at each single step. This object must have a method step(iter) and a method init() which should reset the state of the stepper after the simulator has been stopped and restarted. This object needs also the step interval in s. """ super(SimLoop, self).__init__() self.speed = 1 self.stepper = stepper self.state = SimState.Stopped self.wait = QtCore.QSemaphore(0) self.lock = QtCore.QMutex() self.iteration = 0 self.stepInterval = stepInt_s self.timer = SimTimer(self.playStep) self.stepEnabled = True
def __init__(self, algo, device, size): QtCore.QThread.__init__(self) self.algo = algo self.device = device self.size = size self.semaphore = QtCore.QSemaphore(1)
def __init__(self, backend): super().__init__(backend) self.lock = QtCore.QSemaphore(1) self.signals = FilterManagerSignals()