factor block_size

This commit is contained in:
Sebastien Bourdeauducq 2020-08-10 19:28:45 +08:00
parent 15e7a87959
commit 96b2f204e4
3 changed files with 9 additions and 19 deletions

2
dmi.py
View File

@ -14,7 +14,7 @@ def main():
freq_base = 1088230e3
block_size = 4096
gui = GUI()
gui = GUI(block_size)
try:
induction = InductionHeater("/dev/ttyUSB0", 350e3, 445e3)
induction.start()

19
gui.py
View File

@ -48,10 +48,11 @@ class ParentComm:
class GUI:
def __init__(self):
def __init__(self, block_size):
self.impl = ParentComm()
self.impl.create_subprocess([sys.executable,
os.path.join(os.path.dirname(os.path.abspath(__file__)), "gui_impl.py")])
os.path.join(os.path.dirname(os.path.abspath(__file__)), "gui_impl.py"),
str(block_size)])
def update_beat_spectrum(self, data):
obj = {"action": "update_beat_spectrum", "data": data}
@ -61,17 +62,3 @@ class GUI:
obj = {"action": "terminate"}
self.impl.write_pyon(obj)
self.impl.close()
def main():
gui = GUI()
try:
for i in range(200):
gui.update_beat_spectrum(np.random.normal(size=4096))
time.sleep(1/60)
finally:
gui.close()
if __name__ == "__main__":
main()

View File

@ -1,5 +1,6 @@
import asyncio
import os
import sys
import logging
import numpy as np
@ -10,7 +11,7 @@ from sipyco import pyon
class SpectrogramWidget(pg.PlotWidget):
def __init__(self, block_size=4096):
def __init__(self, block_size):
super(SpectrogramWidget, self).__init__()
self.block_size = block_size
@ -61,6 +62,8 @@ class IPCClient(AsyncioChildComm):
def main():
block_size = int(sys.argv[1])
app = QtWidgets.QApplication([])
loop = QEventLoop(app)
asyncio.set_event_loop(loop)
@ -69,7 +72,7 @@ def main():
ipc = IPCClient(os.getenv("NOPTICA2_IPC"))
loop.run_until_complete(ipc.connect())
try:
main_widget = SpectrogramWidget()
main_widget = SpectrogramWidget(block_size)
main_widget.show()
ipc.set_close_cb(main_widget.close)
asyncio.ensure_future(ipc.listen(main_widget))