def prepare_daq(self, daqstream): # The master counter will determine trial time, i.e. # trial_time = counter_limit * read_daq / rate_daq self.counter0 = Counter(101, reset_on_timeout=False) self.counter1 = Counter(1000) self.counter2 = Counter(1000) self.counter0.timeout.connect(self.finish_trial) self.daqstream = daqstream
def prepare_daq(self, daqstream): self.daqstream = daqstream self.daqstream.start() # If we want every trial to have specified length we need to use # something like this. This is reset at the start of every new trial. self.timer = Counter(50) # number of daq read cycles self.timer.timeout.connect(self.finish_trial)
def test_incremental_timer_noreset(): timer = Counter(2, reset_on_timeout=False) assert timer.count == 0 timer.increment() timer.increment() assert timer.count == 2 timer.reset() assert timer.count == 0
def test_incremental_timer(): timer = Counter(2) recv = TimeoutReceiver() timer.timeout.connect(recv.rx) assert timer.count == 0 timer.increment() assert not recv.received assert timer.count == 1 assert timer.progress == 0.5 timer.increment() assert recv.received assert timer.count == 0 with pytest.raises(ValueError): Counter(-1) Counter(0)
def prepare_graphics(self, container): canvas = Canvas() container.set_widget(canvas) # create a couple text items that tick with each daq update self.text1 = Text('0') self.text1.pos = -0.5, 0 canvas.add_item(self.text1) self.text2 = Text('0') self.text2.pos = 0.5, 0 canvas.add_item(self.text2) # counters keeping track of the updates self.counter1 = Counter(100, reset_on_timeout=False) self.counter2 = Counter(100, reset_on_timeout=False) # stop updating when the faster DAQ has updated 100 times self.counter1.timeout.connect(self.done)
def test_incremental_timer_float(): timer = Counter(3.5) recv = TimeoutReceiver() timer.timeout.connect(recv.rx) timer.increment() assert not recv.received timer.increment() timer.increment() assert recv.received
def prepare_daq(self, daqstream): """Initialize input stream and define how many updates (i.e., cycles) take place within each trial (optional). """ self.daqstream = daqstream self.daqstream.start() # The following two lines define how many cycles will take place within # each trial. The length of the trial is n_cycles * (read_size) / rate. # When the counter reaches the maximum count value it will send a # a signal to start the new trial. self.timer = Counter(50) self.timer.timeout.connect(self.finish_trial)
def prepare_daq(self, daqstream): self.daqstream = daqstream self.daqstream.start() self.timer = Counter(50) self.timer.timeout.connect(self.finish_trial)