Phtometer now works ok

This commit is contained in:
jens 2020-12-26 11:23:14 +01:00
parent d813dfe958
commit d7f89bc334
4 changed files with 34 additions and 48 deletions

View File

@ -46,8 +46,6 @@ import time
# byte[12]: The number of integrations to average
def rxtx(panel, SerQueue, progress_var):
config.still_working = True
print('start rxtx',config.still_working)
if (config.AVGn[0] == 0):
threadser = threading.Thread(target=rxtxoncethread, args=(panel, SerQueue, progress_var), daemon=True)
elif (config.AVGn[0] == 1):
@ -111,8 +109,6 @@ def rxtxoncethread(panel, SerQueue, progress_var):
config.rxData16[rxi] = (config.rxData8[2*rxi+1] << 8) + config.rxData8[2*rxi]
#plot the new data
config.still_working=False
print('before bupdate.invoke',config.still_working)
panel.bupdate.invoke()
#hold values for saving data to file as the SHperiod and ICGperiod may be updated after acquisition
config.SHsent = config.SHperiod

View File

@ -609,7 +609,6 @@ class Jfsphoto (object):
def do_methods(self,panel):
self.nofin = True
def get_duration():
if panel.tint.get().split()[4]=='ms':
@ -631,63 +630,50 @@ class Jfsphoto (object):
'size': 8,
}
def waitfor():
print('wait',config.still_working)
self.nofin = config.still_working
#panel.bcollect.invoke()
# print('Working')
# self.df['m1'] = config.rxData16
# d = self.df.iloc[p]['darkline']
# b = self.df.iloc[p]['baseline']
# w = self.df.iloc[p]["m1"]
# val[3]= np.log10(b/(d-w))
# val[4]= panel.SHvalue.get()
# val[5]= panel.ICGvalue.get()
# tree.item(x, text=name,values=val)
def cb1(event):
print(panel.SHvalue.get(), panel.ICGvalue.get())
print(f' time {panel.tint.get()} {get_duration()} ms ')
def cb(event):
#if self.check_requirement() == True:
def get_messurement(name):
# get selected and save values
name = tree.selection()[0]
val= tree.item(name)["values"]
#name = tree. val=selection()[0]
# get parent for nm
x = name.split(' ')
nm = tree.item(x[0])["values"][1]
## nm -> point
p = int((nm - self.nm_left)*(1/self.nm_step))
self.df['m1'] = config.rxData16
d = self.df.iloc[p]['darkline']
b = self.df.iloc[p]['baseline']
w = self.df.iloc[p]["m1"]
return np.log10(b/(d-w))
def waitfor(x,name,val):
# self.df['m1'] = config.rxData16
# d = self.df.iloc[p]['darkline']
# b = self.df.iloc[p]['baseline']
# w = self.df.iloc[p]["m1"]
# val[3]= np.log10(b/(d-w))
val[3] = get_messurement(name)
val[4]= panel.SHvalue.get()
val[5]= panel.ICGvalue.get()
tree.item(x, text=name,values=val)
def cb(event):
if self.check_requirement() == True:
panel.bcollect.invoke()
# get selected and save values
name = tree.selection()[0]
val= tree.item(name)["values"]
# get parent for nm
x = name.split(' ')
#nm = tree.item(x[0])["values"][1]
## nm -> point
#p = int((nm - self.nm_left)*(1/self.nm_step))
#print(f'nm {nm} point {p}')
s1 = str(val[2])+' '+tree.item(x[0])["values"][2]
s = 'Is a Cuvet for '+x[0]+' in concentration\n of '+s1+' in the photometer ? '
if tk.messagebox.askokcancel(title='Messurement', message=s):
panel.bcollect.invoke()
## 3000 shoud be calculated
#panel.after(3000,waitfor(x,name,val,p))
#print(get_duration())
#time.sleep(3)
#while config.still_working==True :
while self.nofin == True:
tree.after(1000,waitfor)
print('get rxData16')
self.df['m1'] = config.rxData16
d = self.df.iloc[p]['darkline']
b = self.df.iloc[p]['baseline']
w = self.df.iloc[p]["m1"]
#print(d,b,w,d-w, np.log10(b/(d-w)))
val[3]= np.log10(b/(d-w))
val[4]= panel.SHvalue.get()
val[5]= panel.ICGvalue.get()
tree.item(x, text=name,values=val)
#panel.after(get_duration(),waitfor(x,name,val,p))
panel.after(get_duration(),waitfor(x,name,val))
def cb2(event):
y = []
@ -787,10 +773,12 @@ class Jfsphoto (object):
self.methods.remove(p)
def waitfor_darkline():
panel.bcollect.invoke()
if (self.do_save_darkline(config.rxData16)==1):
panel.jfsdark_check.config(state=tk.NORMAL)
def waitfor_baseline():
panel.bcollect.invoke()
base = self.darkData16-config.rxData16
if (self.do_save_baseline(base)==1):
panel.jfsbase_check.config(state=tk.NORMAL)
@ -814,15 +802,19 @@ class Jfsphoto (object):
panel.bcollect.invoke()
panel.after(1000,waitfor_baseline)
def do_messurement():
panel.bcollect.invoke()
if tk.messagebox.askokcancel(title='Messurements', message= 'Sample Cuvet inside \n lightsource [on]'):
panel.bcollect.invoke()
x=[]
y=[]
for child in tree.get_children(l6['text']):
x.append(float(tree.item(child)["values"][2]))
y.append(float(tree.item(child)["values"][3]))
model = np.polyfit(x,y,1)
a = 0.5
a = get_messurement(l6['text'])
#print(a)
#a = model[0]* c +model[1]
c = (a - model[1])/model[0]
l8.config(text=str(round(c,3))+' '+tree.item(l6['text'])['values'][2])

View File

@ -4,7 +4,7 @@ nm_right = 811.0
nm_step = 0.13279
[methods]
crystal = 1,576,mymol,0.0,5,15|1,3.0,0.22895393029132272,80,100000|2,6.0,0.4887269366213052,80,100000|3,9.0,0.7151233139883822,80,100000|4,12.0,0.8900731939852544,80,100000|5,15.0,1.1073861897687294,80,100000
crystal = 1,576,mymol,0.0,5,15|1,3.0,0.23294505746566566,80,100000|2,6.0,0.5003896696237482,80,100000|3,9.0,0.6314310052189019,80,100000|4,12.0,0.7934140103632163,80,100000|5,15.0,1.1044743475181251,80,100000
crystalx = 0,576,mymol,0.0,5,15|1,3.0,0.23572229297382125,80,100000|2,6.0,0.49418983232280744,80,100000|3,9.0,0.6972117246796802,80,100000|4,12.0,0.8832872046419623,80,100000|5,15.0,1.0800630625574945,80,100000
test = 0,405,mmol,0.0,5,30|1,6.0,0.0,200,100000|2,12.0,0.0,200,100000|3,18.0,0.0,0,0|4,24.0,0.0,0,0|5,30.0,0.0,0,0

View File

@ -2,7 +2,7 @@ import numpy as np
#serial definitions
port = 'COM7' #'/dev/ttyACM0'
port = 'COM3' #'/dev/ttyACM0'
baudrate = 115200
#Data as the program handles
@ -33,5 +33,3 @@ balanced = 0
#Photometer status Photometer off
photometer = 0
# wait for data
still_working = True