factor block_size
This commit is contained in:
parent
15e7a87959
commit
96b2f204e4
2
dmi.py
2
dmi.py
|
@ -14,7 +14,7 @@ def main():
|
||||||
freq_base = 1088230e3
|
freq_base = 1088230e3
|
||||||
block_size = 4096
|
block_size = 4096
|
||||||
|
|
||||||
gui = GUI()
|
gui = GUI(block_size)
|
||||||
try:
|
try:
|
||||||
induction = InductionHeater("/dev/ttyUSB0", 350e3, 445e3)
|
induction = InductionHeater("/dev/ttyUSB0", 350e3, 445e3)
|
||||||
induction.start()
|
induction.start()
|
||||||
|
|
19
gui.py
19
gui.py
|
@ -48,10 +48,11 @@ class ParentComm:
|
||||||
|
|
||||||
|
|
||||||
class GUI:
|
class GUI:
|
||||||
def __init__(self):
|
def __init__(self, block_size):
|
||||||
self.impl = ParentComm()
|
self.impl = ParentComm()
|
||||||
self.impl.create_subprocess([sys.executable,
|
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):
|
def update_beat_spectrum(self, data):
|
||||||
obj = {"action": "update_beat_spectrum", "data": data}
|
obj = {"action": "update_beat_spectrum", "data": data}
|
||||||
|
@ -61,17 +62,3 @@ class GUI:
|
||||||
obj = {"action": "terminate"}
|
obj = {"action": "terminate"}
|
||||||
self.impl.write_pyon(obj)
|
self.impl.write_pyon(obj)
|
||||||
self.impl.close()
|
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()
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
@ -10,7 +11,7 @@ from sipyco import pyon
|
||||||
|
|
||||||
|
|
||||||
class SpectrogramWidget(pg.PlotWidget):
|
class SpectrogramWidget(pg.PlotWidget):
|
||||||
def __init__(self, block_size=4096):
|
def __init__(self, block_size):
|
||||||
super(SpectrogramWidget, self).__init__()
|
super(SpectrogramWidget, self).__init__()
|
||||||
|
|
||||||
self.block_size = block_size
|
self.block_size = block_size
|
||||||
|
@ -61,6 +62,8 @@ class IPCClient(AsyncioChildComm):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
block_size = int(sys.argv[1])
|
||||||
|
|
||||||
app = QtWidgets.QApplication([])
|
app = QtWidgets.QApplication([])
|
||||||
loop = QEventLoop(app)
|
loop = QEventLoop(app)
|
||||||
asyncio.set_event_loop(loop)
|
asyncio.set_event_loop(loop)
|
||||||
|
@ -69,7 +72,7 @@ def main():
|
||||||
ipc = IPCClient(os.getenv("NOPTICA2_IPC"))
|
ipc = IPCClient(os.getenv("NOPTICA2_IPC"))
|
||||||
loop.run_until_complete(ipc.connect())
|
loop.run_until_complete(ipc.connect())
|
||||||
try:
|
try:
|
||||||
main_widget = SpectrogramWidget()
|
main_widget = SpectrogramWidget(block_size)
|
||||||
main_widget.show()
|
main_widget.show()
|
||||||
ipc.set_close_cb(main_widget.close)
|
ipc.set_close_cb(main_widget.close)
|
||||||
asyncio.ensure_future(ipc.listen(main_widget))
|
asyncio.ensure_future(ipc.listen(main_widget))
|
||||||
|
|
Loading…
Reference in New Issue