aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2021-12-15 22:33:05 -0500
committerEugeniy E. Mikhailov <evgmik@gmail.com>2021-12-15 22:33:05 -0500
commit8f15837d857388666078cc43a22c541e3f36df91 (patch)
tree35956e954f9948cb8d73dcc4705d79f0f379b5f3 /examples
parente5136fb9edffb98d44f79956cafbde36088e2fe9 (diff)
downloadqolab-8f15837d857388666078cc43a22c541e3f36df91.tar.gz
qolab-8f15837d857388666078cc43a22c541e3f36df91.zip
redone updates status
Diffstat (limited to 'examples')
-rw-r--r--examples/lock_eit.py33
1 files changed, 24 insertions, 9 deletions
diff --git a/examples/lock_eit.py b/examples/lock_eit.py
index b574606..5383d8a 100644
--- a/examples/lock_eit.py
+++ b/examples/lock_eit.py
@@ -78,8 +78,7 @@ def updateLogPlot(apparatus):
log_chart.set_figure(f)
plt.close(f)
print(f're-plotting')
- st.text=f're-plotting {time.time()}'
- jp.run_task(wp.update())
+ update_webpage()
async def updateLogPlotLoop(apparatus):
while True:
@@ -104,8 +103,8 @@ async def updateLogFileLoop(apparatus):
await asyncio.sleep(10)
-freqZero = 6834687190
-freqDeltaM2 = 6835387164
+freqZero = 6834686400
+freqDeltaM2 = 6835387100
async def main():
apparatus = BasicInstrument()
@@ -133,16 +132,21 @@ async def main():
apparatus.rfgen = rfgen
apparatus.pid = pid
apparatus.log = initLog()
+ apparatus.state = None
apparatus.runStatus = False
SweepSpan = 10000
apparatus.rfgen.stopFrequencySweep()
- apparatus.rfgen.setFreqFixed(freqDeltaM2+100)
+ apparatus.rfgen.setFreqFixed(freqDeltaM2)
+ # apparatus.rfgen.setFreqFixed(freqZero)
print('========== Initial lock ===========')
+ apparatus.state = 'Initial lock'
+ update_webpage()
+ apparatus.log = initLog()
apparatus.logFileName = None
apparatus.pid.reset()
apparatus.runStatus = True
@@ -151,20 +155,30 @@ async def main():
updateLogPlot(apparatus)
print('========= Long term lock ===========')
+ apparatus.state = 'Long term lock'
+ update_webpage()
apparatus.log = initLog()
apparatus.logFileName = None
# apparatus.logFileName = apparatus.getNextDataFile()
apparatus.pid.reset()
apparatus.runStatus = True
- res = await asyncio.gather( feedbackLoop(apparatus, nsteps=1000), updateLogPlotLoop(apparatus), updateLogFileLoop(apparatus) )
+ res = await asyncio.gather( feedbackLoop(apparatus, nsteps=10000), updateLogPlotLoop(apparatus), updateLogFileLoop(apparatus) )
print(apparatus.logFileName)
updateLogPlot(apparatus)
# apparatus.log.save(apparatus.logFileName, item_format='.15e')
- print(apparatus.logFileName)
- print('========= Done working with hardware ===========')
+ apparatus.state = 'Done working with hardware'
+ update_webpage()
return(apparatus)
+def update_webpage(byWhom=None):
+ timestr = time.strftime("%a, %d %b %Y, %H:%M:%S", time.localtime())
+ clock_upd.text = f'Last update at {timestr}'
+ try:
+ status_line.text=apparatus.state
+ except NameError:
+ pass
+ jp.run_task(wp.update())
async def getPage():
return wp
@@ -175,12 +189,13 @@ async def jp_startup():
if __name__ == '__main__':
wp = jp.WebPage(delete_flag=False)
d=jp.Div(text='Magnetometer log', a=wp, classes='text-white bg-blue-500 text-center text-xl')
+ clock_upd = jp.Div(text='Loading...', classes='w-96 text-xl m-1 p-1 bg-gray-300 font-mono', a=wp)
+ status_line = jp.Div(test='Status string',classes='w-96 text-xl m-1 p-1 bg-gray-300 font-mono', a=wp)
f = plt.figure()
log_chart = jp.Matplotlib(a=wp)
plt.close(f)
# mpl.use("TkAgg")
# apparatus = asyncio.run(main())
- st = jp.Div(test='Status string', a=wp)
jp.justpy(getPage, startup=jp_startup)