[dataio] adding stop button
This commit is contained in:
parent
e3ed301252
commit
32c79ff47b
@ -18,8 +18,7 @@ class SinProducer:
|
||||
buffer: CircBuffer,
|
||||
) -> None:
|
||||
self.buffer = buffer
|
||||
|
||||
# self.stopbutton = stopbutton
|
||||
self.stop = False
|
||||
|
||||
def produce_sin(
|
||||
self,
|
||||
@ -32,20 +31,27 @@ class SinProducer:
|
||||
log.debug("producing Sin")
|
||||
start_time = time.time()
|
||||
t = 0
|
||||
while time.time() - start_time < 20:
|
||||
while not self.stop:
|
||||
s = AMPLITUDE * np.sin(2 * np.pi * FREQUENCY * t)
|
||||
self.buffer.append(s)
|
||||
t += 1 / self.buffer.samplerate
|
||||
time.sleep(1 / self.buffer.samplerate)
|
||||
|
||||
end_time = time.time()
|
||||
|
||||
data = self.buffer.get_all()
|
||||
log.debug(data.shape[0])
|
||||
log.debug(data.shape[0] / self.buffer.samplerate)
|
||||
log.debug(f"duration sinus {end_time-start_time}")
|
||||
log.debug(f"Stimulation time {t}")
|
||||
# log.debug(data.shape[0])
|
||||
# log.debug(data.shape[0] / self.buffer.samplerate)
|
||||
# plt.plot(np.arange(data.size) / self.buffer.samplerate, data)
|
||||
# plt.show()
|
||||
|
||||
def stop_request(self):
|
||||
self.stop = True
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
buf = CircBuffer(1_000_000, 1, samplerate=10000)
|
||||
buf = CircBuffer(1_000_000, 1, samplerate=10_000)
|
||||
pro_sin = SinProducer(buf)
|
||||
pro_sin.produce_sin()
|
||||
|
Loading…
Reference in New Issue
Block a user