X-Git-Url: http://git.smho.de/gw/?p=owSlave2.git;a=blobdiff_plain;f=DS18B20_Thermocouble%2Fconvthermocouple.py;fp=DS18B20_Thermocouble%2Fconvthermocouple.py;h=c11c3ddf200e36537e8efb371d9f4e6a73fcc340;hp=79f65effab4dd25cb120c93f045374a2b405628d;hb=a6a04f58e4afd20f206fdf4a8a7b3ce4062f1b67;hpb=cd92472e6fd63693741f8e168123a4182802651b diff --git a/DS18B20_Thermocouble/convthermocouple.py b/DS18B20_Thermocouble/convthermocouple.py index 79f65ef..c11c3dd 100644 --- a/DS18B20_Thermocouble/convthermocouple.py +++ b/DS18B20_Thermocouble/convthermocouple.py @@ -1,31 +1,31 @@ -fi=open("Typ-J.csv","r") -lastv=0 -v=0 -lastt=0 -t=0 -rs="" -wc=0 -for l in fi.readlines(): - #print(l) - ll=l.split(";") - i=0 - for n in ll[1:10]: - s=ll[0]+"."+str(i) - lastv=v - lastt=t - v=float(n) - t=float(s) - if (int(v)!=int(lastv)): - interp=lastt+(t-lastt)/(v-lastv)*(int(v)-lastv) - print int(v),interp - rs=rs+", %f" %(interp) - wc=wc+1 - if (v==0): - interp=lastt+(t-lastt)/(v-lastv)*(int(v)-lastv) - print int(v),interp - rs="{0" - wc=1 - - i=i+1 -print rs+"};" +fi=open("Typ-J.csv","r") +lastv=0 +v=0 +lastt=0 +t=0 +rs="" +wc=0 +for l in fi.readlines(): + #print(l) + ll=l.split(";") + i=0 + for n in ll[1:10]: + s=ll[0]+"."+str(i) + lastv=v + lastt=t + v=float(n) + t=float(s) + if (int(v)!=int(lastv)): + interp=lastt+(t-lastt)/(v-lastv)*(int(v)-lastv) + print int(v),interp + rs=rs+", %f" %(interp) + wc=wc+1 + if (v==0): + interp=lastt+(t-lastt)/(v-lastv)*(int(v)-lastv) + print int(v),interp + rs="{0" + wc=1 + + i=i+1 +print rs+"};" print wc \ No newline at end of file